Cleaned up code.

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8705 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
phamt 2011-01-19 15:56:43 +00:00
parent 8df42da717
commit 7fa8e28706
11 changed files with 107 additions and 161 deletions

View File

@ -68,10 +68,9 @@ function loadConfigPage() {
$('#content').append(tab.object());
// Create loader
var loader = createLoader();
loader = $('<center></center>').append(loader);
var loader = $('<center></center>').append(createLoader());
// Configure xCAT datable tables
// Add tab to configure xCAT tables
tab.add('configTablesTab', 'Tables', loader, false);
// Add the update tab
@ -135,8 +134,7 @@ function loadTableNames(data) {
var id = (e.target) ? e.target.id : e.srcElement.id;
// Create loader
var loader = createLoader();
loader = $('<center></center>').append(loader);
var loader = $('<center></center>').append(createLoader());
// Add a new tab for this table
var configTab = getConfigTab();

View File

@ -32,8 +32,7 @@ bladePlugin.prototype.loadInventory = function(data) {
var inv = data.rsp;
// Remove loader
var loaderId = tabId + 'TabLoader';
$('#' + loaderId).remove();
$('#' + tabId).find('img').remove();
// Create division to hold inventory
var invDivId = tabId + 'Inventory';
@ -122,13 +121,11 @@ bladePlugin.prototype.loadProvisionPage = function(tabId) {
// Create status bar
var statBarId = 'bladeProvisionStatBar' + inst;
var statBar = createStatusBar(statBarId);
statBar.hide();
var statBar = createStatusBar(statBarId).hide();
provForm.append(statBar);
// Create loader
var loader = createLoader('bladeProvisionLoader' + inst);
loader.hide();
var loader = createLoader('bladeProvisionLoader' + inst).hide();
statBar.append(loader);
// Create info bar
@ -184,12 +181,9 @@ bladePlugin.prototype.loadProvisionPage = function(tabId) {
*/
bladePlugin.prototype.loadResources = function() {
// Get resource tab ID
var tabID = 'bladeResourceTab';
// Get loader ID
var loaderID = 'bladeResourceLoader';
if ($('#' + loaderID).length) {
$('#' + loaderID).remove();
}
var tabId = 'bladeResourceTab';
// Remove loader
$('#' + tabId).find('img').remove();
// Create info bar
var infoBar = createInfoBar('Under construction');

View File

@ -32,8 +32,7 @@ fspPlugin.prototype.loadInventory = function(data) {
var inv = data.rsp;
// Remove loader
var loaderId = tabId + 'TabLoader';
$('#' + loaderId).remove();
$('#' + tabId).find('img').remove();
// Create division to hold inventory
var invDivId = tabId + 'Inventory';
@ -122,13 +121,11 @@ fspPlugin.prototype.loadProvisionPage = function(tabId) {
// Create status bar
var statBarId = 'fspProvisionStatBar' + inst;
var statBar = createStatusBar(statBarId);
statBar.hide();
var statBar = createStatusBar(statBarId).hide();
provForm.append(statBar);
// Create loader
var loader = createLoader('fspProvisionLoader' + inst);
loader.hide();
var loader = createLoader('fspProvisionLoader' + inst).hide();
statBar.append(loader);
// Create info bar
@ -184,12 +181,9 @@ fspPlugin.prototype.loadProvisionPage = function(tabId) {
*/
fspPlugin.prototype.loadResources = function() {
// Get resource tab ID
var tabID = 'fspResourceTab';
// Get loader ID
var loaderID = 'fspResourceLoader';
if ($('#' + loaderID).length) {
$('#' + loaderID).remove();
}
var tabId = 'fspResourceTab';
// Remove loader
$('#' + tabId).find('img').remove();
// Create info bar
var infoBar = createInfoBar('Under construction');
@ -198,7 +192,7 @@ fspPlugin.prototype.loadResources = function() {
var resrcForm = $('<div class="form"></div>');
resrcForm.append(infoBar);
$('#' + tabID).append(resrcForm);
$('#' + tabId).append(resrcForm);
};
/**

View File

@ -32,8 +32,7 @@ hmcPlugin.prototype.loadInventory = function(data) {
var inv = data.rsp;
// Remove loader
var loaderId = tabId + 'TabLoader';
$('#' + loaderId).remove();
$('#' + tabId).find('img').remove();
// Create division to hold inventory
var invDivId = tabId + 'Inventory';
@ -155,13 +154,11 @@ hmcPlugin.prototype.loadProvisionPage = function(tabId) {
// Create status bar
var statBarId = 'hmcProvisionStatBar' + inst;
var statBar = createStatusBar(statBarId);
statBar.hide();
var statBar = createStatusBar(statBarId).hide();
provForm.append(statBar);
// Create loader
var loader = createLoader('hmcProvisionLoader' + inst);
loader.hide();
var loader = createLoader('hmcProvisionLoader' + inst).hide();
statBar.append(loader);
// Create info bar
@ -217,12 +214,9 @@ hmcPlugin.prototype.loadProvisionPage = function(tabId) {
*/
hmcPlugin.prototype.loadResources = function() {
// Get resource tab ID
var tabID = 'hmcResourceTab';
// Get loader ID
var loaderID = 'hmcResourceLoader';
if ($('#' + loaderID).length) {
$('#' + loaderID).remove();
}
var tabId = 'hmcResourceTab';
// Remove loader
$('#' + tabId).find('img').remove();
// Create info bar
var infoBar = createInfoBar('Under construction');
@ -231,7 +225,7 @@ hmcPlugin.prototype.loadResources = function() {
var resrcForm = $('<div class="form"></div>');
resrcForm.append(infoBar);
$('#' + tabID).append(resrcForm);
$('#' + tabId).append(resrcForm);
};
/**

View File

@ -32,8 +32,7 @@ ipmiPlugin.prototype.loadInventory = function(data) {
var inv = data.rsp;
// Remove loader
var loaderId = tabId + 'TabLoader';
$('#' + loaderId).remove();
$('#' + tabId).find('img').remove();
// Create division to hold inventory
var invDivId = tabId + 'Inventory';
@ -122,13 +121,11 @@ ipmiPlugin.prototype.loadProvisionPage = function(tabId) {
// Create status bar
var statBarId = 'ipmiProvisionStatBar' + inst;
var statBar = createStatusBar(statBarId);
statBar.hide();
var statBar = createStatusBar(statBarId).hide();
provForm.append(statBar);
// Create loader
var loader = createLoader('ipmiProvisionLoader' + inst);
loader.hide();
var loader = createLoader('ipmiProvisionLoader' + inst).hide();
statBar.append(loader);
// Create info bar
@ -184,12 +181,9 @@ ipmiPlugin.prototype.loadProvisionPage = function(tabId) {
*/
ipmiPlugin.prototype.loadResources = function() {
// Get resource tab ID
var tabID = 'ipmiResourceTab';
// Get loader ID
var loaderID = 'ipmiResourceLoader';
if ($('#' + loaderID).length) {
$('#' + loaderID).remove();
}
var tabId = 'ipmiResourceTab';
// Remove loader
$('#' + tabId).find('img').remove();
// Create info bar
var infoBar = createInfoBar('Under construction');
@ -198,7 +192,7 @@ ipmiPlugin.prototype.loadResources = function() {
var resrcForm = $('<div class="form"></div>');
resrcForm.append(infoBar);
$('#' + tabID).append(resrcForm);
$('#' + tabId).append(resrcForm);
};
/**

View File

@ -30,10 +30,9 @@ ivmPlugin.prototype.loadInventory = function(data) {
var node = args[1].replace('node=', '');
// Get node inventory
var inv = data.rsp;
// Remove loader
var loaderId = tabId + 'TabLoader';
$('#' + loaderId).remove();
$('#' + tabId).find('img').remove();
// Create division to hold inventory
var invDivId = tabId + 'Inventory';
@ -122,13 +121,11 @@ ivmPlugin.prototype.loadProvisionPage = function(tabId) {
// Create status bar
var statBarId = 'ivmProvisionStatBar' + inst;
var statBar = createStatusBar(statBarId);
statBar.hide();
var statBar = createStatusBar(statBarId).hide();
provForm.append(statBar);
// Create loader
var loader = createLoader('ivmProvisionLoader' + inst);
loader.hide();
var loader = createLoader('ivmProvisionLoader' + inst).hide();
statBar.append(loader);
// Create info bar
@ -184,12 +181,9 @@ ivmPlugin.prototype.loadProvisionPage = function(tabId) {
*/
ivmPlugin.prototype.loadResources = function() {
// Get resource tab ID
var tabID = 'ivmResourceTab';
// Get loader ID
var loaderID = 'ivmResourceLoader';
if ($('#' + loaderID).length) {
$('#' + loaderID).remove();
}
var tabId = 'ivmResourceTab';
// Remove loader
$('#' + tabId).find('img').remove();
// Create info bar
var infoBar = createInfoBar('Under construction');
@ -198,7 +192,7 @@ ivmPlugin.prototype.loadResources = function() {
var resrcForm = $('<div class="form"></div>');
resrcForm.append(infoBar);
$('#' + tabID).append(resrcForm);
$('#' + tabId).append(resrcForm);
};
/**

View File

@ -299,20 +299,17 @@ zvmPlugin.prototype.loadInventory = function(data) {
var node = args[1].replace('node=', '');
// Get node inventory
var inv = data.rsp[0].split(node + ':');
// Remove loader
var loaderId = tabId + 'TabLoader';
$('#' + loaderId).remove();
$('#' + tabId).find('img').remove();
// Create status bar
var statBarId = node + 'StatusBar';
var statBar = createStatusBar(statBarId);
// Add loader to status bar and hide it
loaderId = node + 'StatusBarLoader';
var loader = createLoader(loaderId);
var loader = createLoader(node + 'StatusBarLoader').hide();
statBar.append(loader);
loader.hide();
statBar.hide();
// Create array of property keys
@ -839,13 +836,11 @@ zvmPlugin.prototype.loadProvisionPage = function(tabId) {
// Create status bar
var statBarId = 'zProvisionStatBar' + inst;
var statBar = createStatusBar(statBarId);
statBar.hide();
var statBar = createStatusBar(statBarId).hide();
provForm.append(statBar);
// Create loader
var loader = createLoader('zProvisionLoader' + inst);
loader.hide();
var loader = createLoader('zProvisionLoader' + inst).hide();
statBar.append(loader);
// Create info bar

View File

@ -100,7 +100,7 @@ function loadHcpInfo(data) {
}
} // End of if (hcp)
} else {
// Create warning dialog
// Create warning dialog
var warnDialog = $('<div class="ui-state-error ui-corner-all">'
+ '<p><span class="ui-icon ui-icon-alert"></span>'
+ 'z/VM SMAPI is not responding to ' + hcp + '. It needs to be reset.</p>'
@ -195,8 +195,7 @@ function loadUserEntry(data) {
var userEntry = data.rsp[0].split(node + ':');
// Remove loader
var loaderId = node + 'TabLoader';
$('#' + loaderId).remove();
$('#' + node + 'TabLoader').remove();
var toggleLinkId = node + 'ToggleLink';
$('#' + toggleLinkId).click(function() {
@ -251,14 +250,11 @@ function loadUserEntry(data) {
/**
* Save
*/
var saveBtn = createButton('Save');
saveBtn.hide();
var saveBtn = createButton('Save').hide();
saveBtn.bind('click', function(event) {
// Show loader
var statusId = node + 'StatusBar';
var statusBarLoaderId = node + 'StatusBarLoader';
$('#' + statusBarLoaderId).show();
$('#' + statusId).show();
$('#' + node + 'StatusBarLoader').show();
$('#' + node + 'StatusBar').show();
// Replace user entry
var newUserEntry = jQuery.trim(txtArea.val()) + '\n';
@ -294,8 +290,7 @@ function loadUserEntry(data) {
/**
* Cancel
*/
var cancelBtn = createButton('Cancel');
cancelBtn.hide();
var cancelBtn = createButton('Cancel').hide();
cancelBtn.bind('click', function(event) {
txtArea.attr('readonly', 'readonly');
txtArea.css( {
@ -1571,10 +1566,8 @@ function openAddNicDialog(node, hcp) {
incrementNodeProcess(node);
// Show loader
var statusId = node + 'StatusBar';
var statusBarLoaderId = node + 'StatusBarLoader';
$('#' + statusBarLoaderId).show();
$('#' + statusId).show();
$('#' + node + 'StatusBarLoader').show();
$('#' + node + 'StatusBar').show();
// Close dialog
$(this).dialog( "close" );
@ -1614,10 +1607,8 @@ function removeProcessor(node, address) {
incrementNodeProcess(node);
// Show loader
var statusId = node + 'StatusBar';
var statusBarLoaderId = node + 'StatusBarLoader';
$('#' + statusBarLoaderId).show();
$('#' + statusId).show();
$('#' + node + 'StatusBarLoader').show();
$('#' + node + 'StatusBar').show();
}
/**
@ -1647,10 +1638,8 @@ function removeDisk(node, address) {
incrementNodeProcess(node);
// Show loader
var statusId = node + 'StatusBar';
var statusBarLoaderId = node + 'StatusBarLoader';
$('#' + statusBarLoaderId).show();
$('#' + statusId).show();
$('#' + node + 'StatusBarLoader').show();
$('#' + node + 'StatusBar').show();
}
/**
@ -1683,10 +1672,8 @@ function removeNic(node, nic) {
incrementNodeProcess(node);
// Show loader
var statusId = node + 'StatusBar';
var statusBarLoaderId = node + 'StatusBarLoader';
$('#' + statusBarLoaderId).show();
$('#' + statusId).show();
$('#' + node + 'StatusBarLoader').show();
$('#' + node + 'StatusBar').show();
}
/**
@ -1826,9 +1813,9 @@ function loadDiskPoolTable(data) {
var tmp = data.rsp[0].split(hcp + ': ');
// Remove loader
var loaderID = 'zvmResourceLoader';
if ($('#' + loaderID).length) {
$('#' + loaderID).remove();
var loaderId = 'zvmResourceLoader';
if ($('#' + loaderId).length) {
$('#' + loaderId).remove();
}
// Resource tab ID
@ -1887,19 +1874,19 @@ function loadNetworkTable(data) {
var tmp = data.rsp[0].split(hcp + ': ');
// Remove loader
var loaderID = 'zvmResourceLoader';
if ($('#' + loaderID).length) {
$('#' + loaderID).remove();
var loaderId = 'zvmResourceLoader';
if ($('#' + loaderId).length) {
$('#' + loaderId).remove();
}
// Resource tab ID
var tabID = 'zvmResourceTab';
var info = $('#' + tabID).find('.ui-state-highlight');
var tabId = 'zvmResourceTab';
var info = $('#' + tabId).find('.ui-state-highlight');
// If there is no info bar
if (!info.length) {
// Create info bar
info = createInfoBar('Below are disks and networks found by the hardware control point. It shows disk pools defined in the EXTENT CONTROL file and LANs|VSWITCHes available to use.');
$('#' + tabID).append(info);
$('#' + tabId).append(info);
}
// Get datatable
@ -1911,16 +1898,16 @@ function loadNetworkTable(data) {
fieldSet.append(legend);
// Create table
var tableID = 'zNetworkDataTable';
var table = new DataTable(tableID);
var tableId = 'zNetworkDataTable';
var table = new DataTable(tableId);
table.init( [ 'Hardware control point', 'Type', 'Name', 'Details' ]);
// Append datatable to tab
fieldSet.append(table.object());
$('#' + tabID).append(fieldSet);
$('#' + tabId).append(fieldSet);
// Turn into datatable
dTable = $('#' + tableID).dataTable();
dTable = $('#' + tableId).dataTable();
setNetworkDataTable(dTable);
// Set the column width
@ -1953,12 +1940,10 @@ function connect2GuestLan(data) {
var address = args[1].replace('addr=', '');
var lanName = args[2].replace('lan=', '');
var lanOwner = args[3].replace('owner=', '');
var statBarId = node + 'StatusBar';
// Write ajax response to status bar
var prg = writeRsp(rsp, node + ': ');
$('#' + statBarId).append(prg);
$('#' + node + 'StatusBar').append(prg);
// Connect NIC to Guest LAN
$.ajax( {
@ -1989,12 +1974,10 @@ function connect2VSwitch(data) {
var node = args[0].replace('node=', '');
var address = args[1].replace('addr=', '');
var vswitchName = args[2].replace('vsw=', '');
var statBarId = node + 'StatusBar';
// Write ajax response to status bar
var prg = writeRsp(rsp, node + ': ');
$('#' + statBarId).append(prg);
$('#' + node + 'StatusBar').append(prg);
// Connect NIC to VSwitch
$.ajax( {

View File

@ -102,36 +102,36 @@ function checkGangliaRPMs(data) {
success : function(data) {
if (data.rsp[0].indexOf("not-monitored") > -1) {
// Create link to start Ganglia
var startLnk = $('<a href="#">Click here</a>');
startLnk.css( {
'color' : 'blue',
'text-decoration' : 'none'
});
startLnk.click(function() {
// Turn on Ganglia for all nodes
monitorNode('', 'on');
});
// Create warning bar
var warningBar = $('<div class="ui-state-error ui-corner-all"></div>');
var msg = $('<p></p>');
msg.append('<span class="ui-icon ui-icon-alert"></span>');
msg.append('Please start Ganglia Monitoring on xCAT. ');
msg.append(startLnk);
msg.append(' to start Ganglia Monitoring.');
warningBar.append(msg);
warningBar.css('margin-bottom', '10px');
// If there are any warning messages, append this warning after it
var curWarnings = $('#gangliamon').find('.ui-state-error');
var gangliaTab = $('#gangliamon');
if (curWarnings.length) {
curWarnings.after(warningBar);
} else {
warningBar.prependTo(gangliaTab);
var startLnk = $('<a href="#">Click here</a>');
startLnk.css( {
'color' : 'blue',
'text-decoration' : 'none'
});
startLnk.click(function() {
// Turn on Ganglia for all nodes
monitorNode('', 'on');
});
// Create warning bar
var warningBar = $('<div class="ui-state-error ui-corner-all"></div>');
var msg = $('<p></p>');
msg.append('<span class="ui-icon ui-icon-alert"></span>');
msg.append('Please start Ganglia Monitoring on xCAT. ');
msg.append(startLnk);
msg.append(' to start Ganglia Monitoring.');
warningBar.append(msg);
warningBar.css('margin-bottom', '10px');
// If there are any warning messages, append this warning after it
var curWarnings = $('#gangliamon').find('.ui-state-error');
var gangliaTab = $('#gangliamon');
if (curWarnings.length) {
curWarnings.after(warningBar);
} else {
warningBar.prependTo(gangliaTab);
}
}
}
}
}
});
}
return;
@ -323,8 +323,7 @@ function loadNodes4Ganglia(data) {
// Variable to send command and request node status
var getNodeStatus = true;
var node;
var args;
var node, args;
for ( var i in rsp) {
// Get the node
var pos = rsp[i].indexOf('Object name:');

View File

@ -33,8 +33,8 @@ function loadNetbootPage(tgtNodes) {
var netbootForm = $('<div class="form"></div>');
// Create status bar
var barId = 'netbootStatusBar' + inst;
var statusBar = createStatusBar(barId).hide();
var statBarId = 'netbootStatusBar' + inst;
var statusBar = createStatusBar(statBarId).hide();
netbootForm.append(statusBar);
// Create loader
@ -178,7 +178,7 @@ function loadNetbootPage(tgtNodes) {
cmd : 'rnetboot',
tgt : tgts,
args : optStr,
msg : 'out=' + barId + ';cmd=rnetboot;tgt=' + tgts
msg : 'out=' + statBarId + ';cmd=rnetboot;tgt=' + tgts
},
success : updateStatusBar

View File

@ -89,6 +89,7 @@ Tab.prototype.add = function(tabId, tabName, tabCont, closeable) {
// Do not remove first tab
if (tabIndex != 0) {
tabs.tabs('remove', tabIndex);
tabs.tabs('select', 0);
}
});
}
@ -349,7 +350,7 @@ function createWarnBar(msg) {
*
* @param loaderId
* Loader ID
* @return Nothing
* @return Loader
*/
function createLoader(loaderId) {
var loader = $('<img id="' + loaderId + '" src="images/loader.gif"></img>');