xcat-core/xCAT-UI/js/custom/hmc.js
2011-08-24 10:30:30 +00:00

168 lines
3.8 KiB
JavaScript

/**
* Execute when the DOM is fully loaded
*/
$(document).ready(function() {
// Load utility scripts
});
/**
* Constructor
*
* @return Nothing
*/
var hmcPlugin = function() {
};
/**
* Load node inventory
*
* @param data
* Data from HTTP request
* @return Nothing
*/
hmcPlugin.prototype.loadInventory = function(data) {
// Get arguments
var args = data.msg.split(',');
// Get tab ID
var tabId = args[0].replace('out=', '');
// Get node
var node = args[1].replace('node=', '');
// Get node inventory
var inv = data.rsp;
// Remove loader
$('#' + tabId).find('img').remove();
// Create division to hold inventory
var invDivId = tabId + 'Inventory';
var invDiv = $('<div class="inventory" id="' + invDivId + '"></div>');
// Loop through each line
var fieldSet, legend, oList, item;
for (var k = 0; k < inv.length; k++) {
// Remove node name in front
var str = inv[k].replace(node + ': ', '');
str = jQuery.trim(str);
// If string is a header
if (str.indexOf('I/O Bus Information') > -1 || str.indexOf('Machine Configuration Info') > -1) {
// Create a fieldset
fieldSet = $('<fieldset></fieldset>');
legend = $('<legend>' + str + '</legend>');
fieldSet.append(legend);
oList = $('<ol></ol>');
fieldSet.append(oList);
invDiv.append(fieldSet);
} else {
// If no fieldset is defined
if (!fieldSet) {
// Define general fieldset
fieldSet = $('<fieldset></fieldset>');
legend = $('<legend>General</legend>');
fieldSet.append(legend);
oList = $('<ol></ol>');
fieldSet.append(oList);
invDiv.append(fieldSet);
}
// Append the string to a list
item = $('<li></li>');
item.append(str);
oList.append(item);
}
}
// Append to inventory form
$('#' + tabId).append(invDiv);
};
/**
* Load clone page
*
* @param node
* Source node to clone
* @return Nothing
*/
hmcPlugin.prototype.loadClonePage = function(node) {
// Get nodes tab
var tab = getNodesTab();
var newTabId = node + 'CloneTab';
// If there is no existing clone tab
if (!$('#' + newTabId).length) {
// Create status bar and hide it
var statBarId = node + 'CloneStatusBar';
var statBar = $('<div class="statusBar" id="' + statBarId + '"></div>').hide();
// Create info bar
var infoBar = createInfoBar('Under construction');
// Create clone form
var cloneForm = $('<div class="form"></div>');
cloneForm.append(statBar);
cloneForm.append(infoBar);
// Add clone tab
tab.add(newTabId, 'Clone', cloneForm, true);
}
tab.select(newTabId);
};
/**
* Load provision page
*
* @param tabId
* The provision tab ID
* @return Nothing
*/
hmcPlugin.prototype.loadProvisionPage = function(tabId) {
// Create provision form
var provForm = $('<div class="form"></div>');
// Create info bar
var infoBar = createInfoBar('Provision a node on system P server.');
provForm.append(infoBar);
// Append to provision tab
$('#' + tabId).append(provForm);
/**
* Create provision new node division
*/
// You should copy whatever is in this function, put it here, and customize it
createProvision('hmc', provForm);
};
/**
* Load resources
*
* @return Nothing
*/
hmcPlugin.prototype.loadResources = function() {
// Get resource tab ID
var tabId = 'hmcResourceTab';
// Remove loader
$('#' + tabId).find('img').remove();
// Create info bar
var infoBar = createInfoBar('Under construction');
// Create resource form
var resrcForm = $('<div class="form"></div>');
resrcForm.append(infoBar);
$('#' + tabId).append(resrcForm);
};
/**
* Add node range
*
* @return Nothing
*/
hmcPlugin.prototype.addNode = function() {
openDialog('info', 'Under construction');
};