diff --git a/xCAT-UI/js/custom/customUtils.js b/xCAT-UI/js/custom/customUtils.js index 234b61175..92f68bc07 100644 --- a/xCAT-UI/js/custom/customUtils.js +++ b/xCAT-UI/js/custom/customUtils.js @@ -41,7 +41,7 @@ function createNodesDatatable(group, outId) { var headers = new Object(); // Clear nodes datatable division - $('#' + outId).children().remove(); + $('#' + outId).empty(); // Create nodes datatable var node, args; diff --git a/xCAT-UI/js/custom/hmc.js b/xCAT-UI/js/custom/hmc.js index c2e90569f..98159d3c8 100644 --- a/xCAT-UI/js/custom/hmc.js +++ b/xCAT-UI/js/custom/hmc.js @@ -119,32 +119,36 @@ hmcPlugin.prototype.loadClonePage = function(node) { */ hmcPlugin.prototype.loadProvisionPage = function(tabId) { // Get OS image names - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'tabdump', - tgt : '', - args : 'osimage', - msg : '' - }, + if (!$.cookie('imagenames')){ + $.ajax( { + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'tabdump', + tgt : '', + args : 'osimage', + msg : '' + }, - success : setOSImageCookies - }); + success : setOSImageCookies + }); + } // Get groups - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'extnoderange', - tgt : '/.*', - args : 'subgroups', - msg : '' - }, + if (!$.cookie('groups')){ + $.ajax( { + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'extnoderange', + tgt : '/.*', + args : 'subgroups', + msg : '' + }, - success : setGroupsCookies - }); + success : setGroupsCookies + }); + } // Get provision tab instance var inst = tabId.replace('hmcProvisionTab', ''); @@ -169,44 +173,43 @@ hmcPlugin.prototype.loadProvisionPage = function(tabId) { $('#' + tabId).append(provForm); // Create provision type drop down - var provType = $('
'); - var typeLabel = $(''); - var typeSelect = $(''); - var provNewNode = $(''); - var provExistNode = $(''); - typeSelect.append(provNewNode); - typeSelect.append(provExistNode); - provType.append(typeLabel); - provType.append(typeSelect); - provForm.append(provType); + provForm.append('
'); /** * Create provision new node division */ // You should copy whatever is in this function, put it here, and customize it - var provNew = createProvisionNew('hmc', inst); - provForm.append(provNew); + //var provNew = createProvisionNew('hmc', inst); + //provForm.append(provNew); /** * Create provision existing node division */ // You should copy whatever is in this function, put it here, and customize it - var provExisting = createProvisionExisting('hmc', inst); - provForm.append(provExisting); + provForm.append(createHmcProvisionExisting(inst)); - // Toggle provision new/existing on select - typeSelect.change(function() { - var selected = $(this).val(); - if (selected == 'new') { - provNew.toggle(); - provExisting.toggle(); - } else { - provNew.toggle(); - provExisting.toggle(); - } + var hmcProvisionBtn = createButton('Provision'); + hmcProvisionBtn.bind('click', function(event) { + //TODO Insert provision code here + openDialog('info', 'Under construction'); }); + provForm.append(hmcProvisionBtn); + + // update the node table on group select + provForm.find('#groupname').bind('change', function(){ + var groupName = $(this).val(); + var nodeArea = $('#hmcSelectNodesTable' + inst); + nodeArea.empty(); + if (!groupName){ + nodeArea.html('Select a group to view its nodes'); + return; + } + + nodeArea.append(createLoader()); + createNodesArea(groupName, 'hmcSelectNodesTable'+ inst); + }); + // Toggle provision new/existing on select }; - /** * Load resources * @@ -235,4 +238,137 @@ hmcPlugin.prototype.loadResources = function() { */ hmcPlugin.prototype.addNode = function() { openDialog('info', 'Under construction'); -}; \ No newline at end of file +}; + +/** + * Create hmc provision existing form + * + * @return: form content + */ +function createHmcProvisionExisting(inst){ + //create the group area. + var strGroup = '
'; + var groupNames = $.cookie('groups'); + if (groupNames){ + strGroup += ''; + } + else{ + strGroup += ''; + } + strGroup += '
'; + + //create nodes area + var strNodes = '
Select a group to view its nodes
'; + + //create boot method + var strBoot = '
'; + + // Create operating system + var strOs = '
'; + var osName = $.cookie('osvers'); + if (osName){ + strOs += ''; + } + else{ + strOs += ''; + } + strOs += '
'; + + //create architecture + var strArch = '
'; + var archName = $.cookie('osarchs'); + if ('' != archName){ + strArch += ''; + } + else{ + strArch += ''; + } + strArch += '
'; + + //create profile + var strPro = '
'; + var proName = $.cookie('profiles'); + if ('' != proName){ + strPro += ''; + } + else{ + strPro += ''; + } + strPro += '
'; + + var strRet = strGroup + strNodes + strBoot + strOs + strArch + strPro; + return strRet; +} + +/** + * refresh the nodes area base on group selected + * + * @return Nothing + */ +function createNodesArea(groupName, areaId){ + // Get group nodes + $.ajax( { + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'nodels', + tgt : groupName, + args : '', + msg : areaId + }, + + /** + * Create nodes datatable + * + * @param data + * Data returned from HTTP request + * @return Nothing + */ + success : function(data) { + var areaObj = $('#' + data.msg); + var nodes = data.rsp; + var index; + var showStr = ''; + showStr += ''; + for (index in nodes){ + var node = nodes[index][0]; + if ('' == node){ + continue; + } + showStr += ''; + } + showStr += '
Node
' + node + '
'; + areaObj.empty().append(showStr); + if (index > 10){ + areaObj.css('height', '300px'); + } + else{ + areaObj.css('height', 'auto'); + } + } // End of function(data) + }); +} \ No newline at end of file diff --git a/xCAT-UI/js/nodes/nodes.js b/xCAT-UI/js/nodes/nodes.js index 22ab329a3..ebd563c2e 100644 --- a/xCAT-UI/js/nodes/nodes.js +++ b/xCAT-UI/js/nodes/nodes.js @@ -2166,9 +2166,9 @@ function findRow(str, table, col){ function selectAllCheckbox(event, obj) { // Get datatable ID // This will ascend from - var tableId = obj.parent().parent().parent().parent().attr('id'); + var tableObj = obj.parent().parent().parent().parent(); var status = obj.attr('checked'); - $('#' + tableId + ' :checkbox').attr('checked', status); + tableObj.find(' :checkbox').attr('checked', status); event.stopPropagation(); }