Formatted code.

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@12511 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
phamt 2012-05-04 00:54:58 +00:00
parent 8a15295c6a
commit e2484fafe5
27 changed files with 19549 additions and 20184 deletions

View File

@ -7,36 +7,30 @@ var configDatatables = new Object(); // Datatables on the config page
/**
* Set the datatable
*
* @param id
* The ID of the datatable
* @param obj
* Datatable object
* @return Nothing
* @param id The ID of the datatable
* @param obj Datatable object
*/
function setConfigDatatable(id, obj) {
configDatatables[id] = obj;
configDatatables[id] = obj;
}
/**
* Get the datatable with the given ID
*
* @param id
* The ID of the datatable
* @param id The ID of the datatable
* @return Datatable object
*/
function getConfigDatatable(id) {
return configDatatables[id];
return configDatatables[id];
}
/**
* Set the configure tab
*
* @param obj
* Tab object
* @return Nothing
* @param obj Tab object
*/
function setConfigTab(obj) {
configTabs = obj;
configTabs = obj;
}
/**
@ -46,462 +40,449 @@ function setConfigTab(obj) {
* @return Tab object
*/
function getConfigTab() {
return configTabs;
return configTabs;
}
/**
* Load configure page
*
* @return Nothing
*/
function loadConfigPage() {
// If the configure page has already been loaded
if ($('#content').children().length) {
// Do not reload configure page
return;
}
// If the configure page has already been loaded
if ($('#content').children().length) {
// Do not reload configure page
return;
}
// Create configure tab
var tab = new Tab();
setConfigTab(tab);
tab.init();
$('#content').append(tab.object());
// Create configure tab
var tab = new Tab();
setConfigTab(tab);
tab.init();
$('#content').append(tab.object());
// Create loader
var loader = $('<center></center>').append(createLoader());
// Create loader
var loader = $('<center></center>').append(createLoader());
// Add tab to configure xCAT tables
tab.add('configTablesTab', 'Tables', loader, false);
// Add tab to configure xCAT tables
tab.add('configTablesTab', 'Tables', loader, false);
// Add the update tab
tab.add('updateTab', 'Update', '', false);
// Add the discover tab
tab.add('discoverTab', 'Discover', '', false);
// Add the self-service tab
tab.add('serviceTab', 'Service', '', false);
// Add the update tab
tab.add('updateTab', 'Update', '', false);
// Add the discover tab
tab.add('discoverTab', 'Discover', '', false);
// Add the self-service tab
tab.add('serviceTab', 'Service', '', false);
// Get list of tables and their descriptions
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'tabdump',
tgt : '',
args : '-d',
msg : ''
},
// Get list of tables and their descriptions
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'tabdump',
tgt : '',
args : '-d',
msg : ''
},
success : loadTableNames
});
success : loadTableNames
});
loadUpdatePage();
loadDiscoverPage();
loadServicePage();
loadUpdatePage();
loadDiscoverPage();
loadServicePage();
}
/**
* Load xCAT database table names and their descriptions
*
* @param data
* Data returned from HTTP request
* @return Nothing
* @param data Data returned from HTTP request
*/
function loadTableNames(data) {
// Get output
var tables = data.rsp;
// Get output
var tables = data.rsp;
// Remove loader
var tabId = 'configTablesTab';
$('#' + tabId).find('img').hide();
// Remove loader
var tabId = 'configTablesTab';
$('#' + tabId).find('img').hide();
// Create a groups division
var tablesDIV = $('<div id="configTable"></div>');
$('#' + tabId).append(tablesDIV);
// Create a groups division
var tablesDIV = $('<div id="configTable"></div>');
$('#' + tabId).append(tablesDIV);
// Create info bar
var infoBar = createInfoBar('Select a table to view or edit.');
tablesDIV.append(infoBar);
// Create info bar
var infoBar = createInfoBar('Select a table to view or edit.');
tablesDIV.append(infoBar);
// Create a list for the tables
var list = $('<ul></ul>');
// Loop through each table
for ( var i = 0; i < tables.length; i++) {
// Create a link for each table
var args = tables[i].split(':');
var link = $('<a style="color: blue;" id="' + args[0] + '">' + args[0] + '</a>');
// Create a list for the tables
var list = $('<ul></ul>');
// Loop through each table
for ( var i = 0; i < tables.length; i++) {
// Create a link for each table
var args = tables[i].split(':');
var link = $('<a style="color: blue;" id="' + args[0] + '">' + args[0] + '</a>');
// Open table on click
link.bind('click', function(e) {
// Get table ID that was clicked
var id = (e.target) ? e.target.id : e.srcElement.id;
// Open table on click
link.bind('click', function(e) {
// Get table ID that was clicked
var id = (e.target) ? e.target.id : e.srcElement.id;
// Create loader
var loader = $('<center></center>').append(createLoader());
// Create loader
var loader = $('<center></center>').append(createLoader());
// Add a new tab for this table
var configTab = getConfigTab();
if (!$('#' + id + 'Tab').length) {
configTab.add(id + 'Tab', id, loader, true);
// Add a new tab for this table
var configTab = getConfigTab();
if (!$('#' + id + 'Tab').length) {
configTab.add(id + 'Tab', id, loader, true);
// Get contents of selected table
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'tabdump',
tgt : '',
args : id,
msg : id
},
// Get contents of selected table
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'tabdump',
tgt : '',
args : id,
msg : id
},
success : loadTable
});
}
success : loadTable
});
}
// Select new tab
configTab.select(id + 'Tab');
});
// Select new tab
configTab.select(id + 'Tab');
});
var item = $('<li></li>');
item.append(link);
var item = $('<li></li>');
item.append(link);
// Append the table description
item.append(': ' + args[1]);
// Append the table description
item.append(': ' + args[1]);
// Append item to list
list.append(item);
}
// Append item to list
list.append(item);
}
tablesDIV.append(list);
tablesDIV.append(list);
}
/**
* Load a given database table
*
* @param data
* Data returned from HTTP request
* @return Nothing
* @param data Data returned from HTTP request
*/
function loadTable(data) {
// Get response
var rsp = data.rsp;
// Get table ID
var id = data.msg;
// Get response
var rsp = data.rsp;
// Get table ID
var id = data.msg;
// Remove loader
var tabId = id + 'Tab';
$('#' + tabId).find('img').remove();
// Remove loader
var tabId = id + 'Tab';
$('#' + tabId).find('img').remove();
// Create info bar
var infoBar = createInfoBar('Click on a cell to edit. Click outside the table to write to the cell. Once you are satisfied with how the table looks, click on Save.');
$('#' + tabId).append(infoBar);
// Create info bar
var infoBar = createInfoBar('Click on a cell to edit. Click outside the table to write to the cell. Once you are satisfied with how the table looks, click on Save.');
$('#' + tabId).append(infoBar);
// Create action bar
var actionBar = $('<div></div>');
$('#' + tabId).append(actionBar);
// Create action bar
var actionBar = $('<div></div>');
$('#' + tabId).append(actionBar);
// Get table headers
var args = rsp[0].replace('#', '');
var headers = args.split(',');
// Get table headers
var args = rsp[0].replace('#', '');
var headers = args.split(',');
// Create container for original table contents
var origCont = new Array(); // Original table content
origCont[0] = rsp[0].split(','); // Headers
// Create container for original table contents
var origCont = new Array(); // Original table content
origCont[0] = rsp[0].split(','); // Headers
// Create container for new table contents
var newCont = new Object();
var tmp = new Object();
tmp[0] = '#' + headers[0]; // Put a # in front of the header
for ( var i = 1; i < headers.length; i++) {
tmp[i] = headers[i];
}
newCont[0] = tmp;
// Create container for new table contents
var newCont = new Object();
var tmp = new Object();
tmp[0] = '#' + headers[0]; // Put a # in front of the header
for ( var i = 1; i < headers.length; i++) {
tmp[i] = headers[i];
}
newCont[0] = tmp;
// Create a new datatable
var tableId = id + 'Datatable';
var table = new DataTable(tableId);
// Create a new datatable
var tableId = id + 'Datatable';
var table = new DataTable(tableId);
// Add column for the remove row button
headers.unshift('');
table.init(headers);
headers.shift();
// Add column for the remove row button
headers.unshift('');
table.init(headers);
headers.shift();
// Append datatable to tab
$('#' + tabId).append(table.object());
// Append datatable to tab
$('#' + tabId).append(table.object());
// Data table
var dTable;
// Add table rows
// Start with the 2nd row (1st row is the headers)
for ( var i = 1; i < rsp.length; i++) {
// Split into columns
var cols = rsp[i].split(',');
// Add table rows
// Start with the 2nd row (1st row is the headers)
for ( var i = 1; i < rsp.length; i++) {
// Split into columns
var cols = rsp[i].split(',');
// Go through each column
for ( var j = 0; j < cols.length; j++) {
// Go through each column
for ( var j = 0; j < cols.length; j++) {
// If the column is not complete
if (cols[j].count('"') == 1) {
while (cols[j].count('"') != 2) {
// Merge this column with the adjacent one
cols[j] = cols[j] + "," + cols[j + 1];
// If the column is not complete
if (cols[j].count('"') == 1) {
while (cols[j].count('"') != 2) {
// Merge this column with the adjacent one
cols[j] = cols[j] + "," + cols[j + 1];
// Remove merged row
cols.splice(j + 1, 1);
}
}
// Remove merged row
cols.splice(j + 1, 1);
}
}
// Replace quote
cols[j] = cols[j].replace(new RegExp('"', 'g'), '');
}
// Replace quote
cols[j] = cols[j].replace(new RegExp('"', 'g'), '');
}
// Add remove button
cols.unshift('<span class="ui-icon ui-icon-close" onclick="deleteRow(this)"></span>');
// Add remove button
cols.unshift('<span class="ui-icon ui-icon-close" onclick="deleteRow(this)"></span>');
// Add row
table.add(cols);
// Add row
table.add(cols);
// Save original table content
origCont[i] = cols;
}
// Save original table content
origCont[i] = cols;
}
// Turn table into datatable
var dTable = $('#' + id + 'Datatable').dataTable({
'iDisplayLength': 50,
'bLengthChange': false,
"sScrollX": "100%",
"bAutoWidth": true
});
/**
* Enable editable columns
*/
// Do not make 1st column editable
$('#' + tableId + ' td:not(td:nth-child(1))').editable(
function(value, settings) {
// Get column index
var colPos = this.cellIndex;
// Get row index
var rowPos = dTable.fnGetPosition(this.parentNode);
/**
* Enable editable columns
*/
// Do not make 1st column editable
$('#' + tableId + ' td:not(td:nth-child(1))').editable(
function(value, settings) {
// Get column index
var colPos = this.cellIndex;
// Get row index
var rowPos = dTable.fnGetPosition(this.parentNode);
// Update datatable
dTable.fnUpdate(value, rowPos, colPos);
// Update datatable
dTable.fnUpdate(value, rowPos, colPos);
return (value);
}, {
onblur : 'submit', // Clicking outside editable area submits changes
type : 'textarea',
placeholder: ' ',
height : '30px' // The height of the text area
});
return (value);
}, {
onblur : 'submit', // Clicking outside editable area submits changes
type : 'textarea',
placeholder: ' ',
height : '30px' // The height of the text area
});
// Create action bar
var actionBar = $('<div class="actionBar"></div>');
var saveLnk = $('<a>Save</a>');
saveLnk.click(function() {
// Get table ID and name
var tableId = $(this).parents('.dataTables_wrapper').attr('id').replace('_wrapper', '');
var tableName = tableId.replace('Datatable', '');
// Get datatable
var dTable = $('#' + tableId).dataTable();
// Get the nodes from the table
var dRows = dTable.fnGetNodes();
// Turn table into datatable
dTable = $('#' + id + 'Datatable').dataTable({
'iDisplayLength': 50,
'bLengthChange': false,
"sScrollX": "100%",
"bAutoWidth": true
});
// Go through each row
for ( var i = 0; i < dRows.length; i++) {
// If there is row with values
if (dRows[i]) {
// Go through each column
// Ignore the 1st column because it is a button
var cols = dRows[i].childNodes;
var vals = new Object();
for ( var j = 1; j < cols.length; j++) {
var val = cols.item(j).firstChild.nodeValue;
// Insert quotes
if (val == ' ') {
vals[j - 1] = '';
} else {
vals[j - 1] = val;
}
}
// Create action bar
var actionBar = $('<div class="actionBar"></div>');
var saveLnk = $('<a>Save</a>');
saveLnk.click(function() {
// Get table ID and name
var tableId = $(this).parents('.dataTables_wrapper').attr('id').replace('_wrapper', '');
var tableName = tableId.replace('Datatable', '');
// Get datatable
var dTable = $('#' + tableId).dataTable();
// Get the nodes from the table
var dRows = dTable.fnGetNodes();
// Save row
newCont[i + 1] = vals;
}
}
// Update xCAT table
$.ajax({
type : 'POST',
url : 'lib/tabRestore.php',
dataType : 'json',
data : {
table : tableName,
cont : newCont
},
success : function(data) {
// Create info message
var dialog = $('<div></div>').append(createInfoBar('Changes saved!'));
// Open dialog
dialog.dialog({
modal: true,
title: 'Info',
width: 400,
buttons: {
"Ok": function(){
$(this).dialog("close");
}
}
});
}
});
});
var undoLnk = $('<a>Undo</a>');
undoLnk.click(function() {
// Get table ID
var tableId = $(this).parents('.dataTables_wrapper').attr('id').replace('_wrapper', '');
// Get datatable
var dTable = $('#' + tableId).dataTable();
// Clear entire datatable
dTable.fnClearTable();
// Go through each row
for ( var i = 0; i < dRows.length; i++) {
// If there is row with values
if (dRows[i]) {
// Go through each column
// Ignore the 1st column because it is a button
var cols = dRows[i].childNodes;
var vals = new Object();
for ( var j = 1; j < cols.length; j++) {
var val = cols.item(j).firstChild.nodeValue;
// Insert quotes
if (val == ' ') {
vals[j - 1] = '';
} else {
vals[j - 1] = val;
}
}
// Add original content back into datatable
for ( var i = 1; i < origCont.length; i++) {
dTable.fnAddData(origCont[i], true);
}
// Save row
newCont[i + 1] = vals;
}
}
// Update xCAT table
$.ajax( {
type : 'POST',
url : 'lib/tabRestore.php',
dataType : 'json',
data : {
table : tableName,
cont : newCont
},
success : function(data) {
// Create info message
var dialog = $('<div></div>').append(createInfoBar('Changes saved!'));
// Open dialog
dialog.dialog({
modal: true,
title: 'Info',
width: 400,
buttons: {
"Ok": function(){
$(this).dialog("close");
}
}
});
}
});
});
var undoLnk = $('<a>Undo</a>');
undoLnk.click(function() {
// Get table ID
var tableId = $(this).parents('.dataTables_wrapper').attr('id').replace('_wrapper', '');
// Get datatable
var dTable = $('#' + tableId).dataTable();
// Clear entire datatable
dTable.fnClearTable();
// Enable editable columns (again)
// Do not make 1st column editable
$('#' + tableId + ' td:not(td:nth-child(1))').editable(
function(value, settings) {
// Get column index
var colPos = this.cellIndex;
// Get row index
var rowPos = dTable.fnGetPosition(this.parentNode);
// Add original content back into datatable
for ( var i = 1; i < origCont.length; i++) {
dTable.fnAddData(origCont[i], true);
}
// Update datatable
dTable.fnUpdate(value, rowPos, colPos);
// Enable editable columns (again)
// Do not make 1st column editable
$('#' + tableId + ' td:not(td:nth-child(1))').editable(
function(value, settings) {
// Get column index
var colPos = this.cellIndex;
// Get row index
var rowPos = dTable.fnGetPosition(this.parentNode);
return (value);
}, {
onblur : 'submit', // Clicking outside editable area submits changes
type : 'textarea',
placeholder: ' ',
height : '30px' // The height of the text area
});
});
var addLnk = $('<a>Add row</a>');
addLnk.click(function() {
// Create an empty row
var row = new Array();
// Update datatable
dTable.fnUpdate(value, rowPos, colPos);
/**
* Remove button
*/
row.push('<span class="ui-icon ui-icon-close" onclick="deleteRow(this)"></span>');
for ( var i = 0; i < headers.length; i++) {
row.push('');
}
return (value);
}, {
onblur : 'submit', // Clicking outside editable area submits changes
type : 'textarea',
placeholder: ' ',
height : '30px' // The height of the text area
});
});
var addLnk = $('<a>Add row</a>');
addLnk.click(function() {
// Create an empty row
var row = new Array();
// Get table ID and name
var tableId = $(this).parents('.dataTables_wrapper').attr('id').replace('_wrapper', '');
// Get datatable
var dTable = $('#' + tableId).dataTable();
// Add the row to the data table
dTable.fnAddData(row);
/**
* Remove button
*/
row.push('<span class="ui-icon ui-icon-close" onclick="deleteRow(this)"></span>');
for ( var i = 0; i < headers.length; i++) {
row.push('');
}
// Enable editable columns (again)
// Do not make 1st column editable
$('#' + tableId + ' td:not(td:nth-child(1))').editable(
function(value, settings) {
// Get column index
var colPos = this.cellIndex;
// Get row index
var rowPos = dTable.fnGetPosition(this.parentNode);
// Get table ID and name
var tableId = $(this).parents('.dataTables_wrapper').attr('id').replace('_wrapper', '');
var tableName = tableId.replace('Datatable', '');
// Get datatable
var dTable = $('#' + tableId).dataTable();
// Add the row to the data table
dTable.fnAddData(row);
// Update datatable
dTable.fnUpdate(value, rowPos, colPos);
// Enable editable columns (again)
// Do not make 1st column editable
$('#' + tableId + ' td:not(td:nth-child(1))').editable(
function(value, settings) {
// Get column index
var colPos = this.cellIndex;
// Get row index
var rowPos = dTable.fnGetPosition(this.parentNode);
// Update datatable
dTable.fnUpdate(value, rowPos, colPos);
return (value);
}, {
onblur : 'submit', // Clicking outside editable area submits changes
type : 'textarea',
placeholder: ' ',
height : '30px' // The height of the text area
});
});
// Create an action menu
var actionsMenu = createMenu([saveLnk, undoLnk, addLnk]);
actionsMenu.superfish();
actionsMenu.css('display', 'inline-block');
actionBar.append(actionsMenu);
// Set correct theme for action menu
actionsMenu.find('li').hover(function() {
setMenu2Theme($(this));
}, function() {
setMenu2Normal($(this));
});
// Create a division to hold actions menu
var menuDiv = $('<div id="' + id + 'Datatable_menuDiv" class="menuDiv"></div>');
$('#' + id + 'Datatable_wrapper').prepend(menuDiv);
menuDiv.append(actionBar);
$('#' + id + 'Datatable_filter').appendTo(menuDiv);
return (value);
}, {
onblur : 'submit', // Clicking outside editable area submits changes
type : 'textarea',
placeholder: ' ',
height : '30px' // The height of the text area
});
});
// Create an action menu
var actionsMenu = createMenu([saveLnk, undoLnk, addLnk]);
actionsMenu.superfish();
actionsMenu.css('display', 'inline-block');
actionBar.append(actionsMenu);
// Set correct theme for action menu
actionsMenu.find('li').hover(function() {
setMenu2Theme($(this));
}, function() {
setMenu2Normal($(this));
});
// Create a division to hold actions menu
var menuDiv = $('<div id="' + id + 'Datatable_menuDiv" class="menuDiv"></div>');
$('#' + id + 'Datatable_wrapper').prepend(menuDiv);
menuDiv.append(actionBar);
$('#' + id + 'Datatable_filter').appendTo(menuDiv);
}
/**
* Delete a row in the data table
*
* @param obj
* The object that was clicked
* @return Nothing
* @param obj The object that was clicked
*/
function deleteRow(obj) {
// Get table ID
var tableId = $(obj).parents('table').attr('id');
// Get table ID
var tableId = $(obj).parents('table').attr('id');
// Get datatable
var dTable = $('#' + tableId).dataTable();
// Get datatable
var dTable = $('#' + tableId).dataTable();
// Get all nodes within the datatable
var rows = dTable.fnGetNodes();
// Get target row
var tgtRow = $(obj).parent().parent().get(0);
// Get all nodes within the datatable
var rows = dTable.fnGetNodes();
// Get target row
var tgtRow = $(obj).parent().parent().get(0);
// Find the target row in the datatable
for ( var i in rows) {
// If the row matches the target row
if (rows[i] == tgtRow) {
// Remove row
dTable.fnDeleteRow(i, null, true);
break;
}
}
// Find the target row in the datatable
for ( var i in rows) {
// If the row matches the target row
if (rows[i] == tgtRow) {
// Remove row
dTable.fnDeleteRow(i, null, true);
break;
}
}
}
/**
* Count the number of occurrences of a specific character in a string
*
* @param c
* Character to count
* @param c Character to count
* @return The number of occurrences
*/
String.prototype.count = function(c) {
return (this.length - this.replace(new RegExp(c, 'g'), '').length)/c.length;
return (this.length - this.replace(new RegExp(c, 'g'), '').length)/c.length;
};

View File

@ -1,408 +1,372 @@
/*associate the step name with step number*/
var steps = ['Platform', 'Complete'];
// Associate the step name with step number
var steps = [ 'Platform', 'Complete' ];
/*associate the function with step number*/
var initFunctions = [initSelectPlatform, complete];
// Associate the function with step number
var initFunctions = [ initSelectPlatform, complete ];
var nextFunctions = [ getPlatform, undefined ];
/*associate the function witch should be called before the page changed(when click next or back)
*if there is no need to call functions, use undefined.*/
var nextFunctions = [getPlatform, undefined];
/*save current step number*/
// Save current step number
var currentStep = 0;
/*save user's input*/
// Save user's input
var discoverEnv;
/**
* create the discover page
*
* @return nothing
* Create the discovery page
*/
function loadDiscoverPage(){
currentStep = 0;
discoverEnv = new Object();
$('#discoverTab').append('<div class="discovercontent" id="discoverContentDiv"><div>');
initSelectPlatform();
function loadDiscoverPage() {
currentStep = 0;
discoverEnv = new Object();
$('#discoverTab').append('<div class="discovercontent" id="discoverContentDiv"><div>');
initSelectPlatform();
}
/**
* create the navigator buttons on the bottom of discover page
*
* @param
*
* @return nothing
* Create the navigation buttons on the bottom of discovery page
*/
function createDiscoverButtons(){
var buttonDiv = $('<div style="text-align:center;padding:20px 0px 10px 0px;"></div>');
var backButton = createBackButton();
var nextButton = createNextButton();
var cancelButton = createCancelButton();
if (backButton)
buttonDiv.append(backButton);
if (nextButton)
buttonDiv.append(nextButton);
if (cancelButton)
buttonDiv.append(cancelButton);
function createDiscoverButtons() {
var buttonDiv = $('<div style="text-align:center;padding:20px 0px 10px 0px;"></div>');
var backButton = createBackButton();
var nextButton = createNextButton();
var cancelButton = createCancelButton();
$('#discoverContentDiv').append(buttonDiv);
if (backButton)
buttonDiv.append(backButton);
if (nextButton)
buttonDiv.append(nextButton);
if (cancelButton)
buttonDiv.append(cancelButton);
$('#discoverContentDiv').append(buttonDiv);
}
function createCancelButton(){
if (0 == currentStep)
return undefined;
if ((steps.length - 1) == currentStep)
return undefined;
var cancelbutton = createButton('Cancel');
cancelbutton.bind('click', function(){
$('#discoverTab').empty();
for (var name in discoverEnv)
removeDiscoverEnv(name);
loadDiscoverPage();
});
return cancelbutton;
function createCancelButton() {
if (0 == currentStep)
return undefined;
if ((steps.length - 1) == currentStep)
return undefined;
var cancelbutton = createButton('Cancel');
cancelbutton.bind('click', function() {
$('#discoverTab').empty();
for (var name in discoverEnv)
removeDiscoverEnv(name);
loadDiscoverPage();
});
return cancelbutton;
}
/**
* create the next button base on the currentStep, the last step does not need this button
*
* @return nothing
* Create the next button base on the current step,
* the last step does not need this button
*/
function createNextButton(){
var tempFlag = true;
if ((steps.length - 1) == currentStep)
return undefined;
var nextButton = createButton('Next');
nextButton.bind('click', function(){
if (nextFunctions[currentStep])
tempFlag = nextFunctions[currentStep]('next');
if (!tempFlag)
return;
currentStep ++;
initFunctions[currentStep]('next');
});
return nextButton;
function createNextButton() {
var tempFlag = true;
if ((steps.length - 1) == currentStep)
return undefined;
var nextButton = createButton('Next');
nextButton.bind('click', function() {
if (nextFunctions[currentStep])
tempFlag = nextFunctions[currentStep]('next');
if (!tempFlag)
return;
currentStep++;
initFunctions[currentStep]('next');
});
return nextButton;
}
/**
* create the next button base on the currentStep, the first step does not need this button
*
* @return nothing
* Create the next button base on the current step,
* the first step does not need this button
*/
function createBackButton(){
var tempFlag = true;
if (0 == currentStep)
return undefined;
var backButton = createButton('Back');
backButton.bind('click', function(){
if (nextFunctions[currentStep])
tempFlag = nextFunctions[currentStep]('back');
if (!tempFlag)
return;
currentStep--;
function createBackButton() {
var tempFlag = true;
if (0 == currentStep)
return undefined;
initFunctions[currentStep]('back');
});
return backButton;
var backButton = createButton('Back');
backButton.bind('click', function() {
if (nextFunctions[currentStep])
tempFlag = nextFunctions[currentStep]('back');
if (!tempFlag)
return;
currentStep--;
initFunctions[currentStep]('back');
});
return backButton;
}
/**
* get the input value on discover page
* Get the input value on discovery page
*
* @param envName
* value's name(discoverEnv's key)
* @return
* if there is assciate value, return the value.
* else return null.
* @param envName Value name (discoverEnv key)
* @return If there is an associate value, return the value, else return NULL
*/
function getDiscoverEnv(envName){
if (discoverEnv[envName])
return discoverEnv[envName];
else
return '';
function getDiscoverEnv(envName) {
if (discoverEnv[envName])
return discoverEnv[envName];
else
return '';
}
/**
* set the input value on discover page
* Set the input value on discovery page
*
* @param envName
* value's name(discoverEnv's key)
* @param envValue
* value
* @return nothing
* @param envName Value name (discoverEnv key)
* @param envValue Value
*/
function setDiscoverEnv(envName, envValue){
if (envName)
discoverEnv[envName] = envValue;
function setDiscoverEnv(envName, envValue) {
if (envName)
discoverEnv[envName] = envValue;
}
/**
* delete the input value on discover page
* Delete the input value on discovery page
*
* @param envName
* value's name(discoverEnv's key)
* @return nothing
* @param envName Value name (discoverEnv's key)
*/
function removeDiscoverEnv(envName){
if (discoverEnv[envName])
delete discoverEnv[envName];
function removeDiscoverEnv(envName) {
if (discoverEnv[envName])
delete discoverEnv[envName];
}
/**
* Expand the noderange into node names.
* Expand the noderange into node names
*
* @param nodeRange
* @return node names array
* @param nodeRange Node range
* @return Array of node names
*/
function expandNR(nodeRange){
var retArray = new Array();
var tempResult;
if ('' == nodeRange)
return retArray;
tempResult = nodeRange.match(/(.*?)\[(.*?)\](.*)/);
if (null != tempResult){
var parts = tempResult[2].split('-');
if (2 > parts.length)
return retArray;
var start = Number(parts[0]);
var end = Number(parts[1]);
var len = parts[0].length;
for (var i = parts[0]; i <= parts[1]; i++){
var ts = i.toString();
if (ts.length < len)
ts = "000000".substring(0, (len - ts.length)) + ts;
function expandNR(nodeRange) {
var retArray = new Array();
var tempResult;
if ('' == nodeRange)
return retArray;
retArray = retArray.concat(expandNR(tempResult[1] + ts + tempResult[3]));
}
return retArray;
}
var tempArray = nodeRange.split('-');
if (2 > tempArray.length){
retArray.push(nodeRange);
return retArray;
}
var begin = tempArray[0].match(/^(\D+)(\d+)$/);
if (2 > begin){
retArray.push(nodeRange);
return retArray;
}
var end = tempArray[1].match(/^(\D+)(\d+)$/);
if (2 > end){
retArray.push(nodeRange);
return retArray;
}
if (begin[1] != end[1]){
retArray.push(nodeRange);
return retArray;
}
var prefix = begin[1];
var len = begin[2].length;
for (var i = begin[2]; i <= end[2]; i++){
var ts = i.toString();
if (ts.length < len)
ts = "000000".substring(0, (len - ts.length)) + ts;
retArray.push(prefix + ts);
}
return retArray;
tempResult = nodeRange.match(/(.*?)\[(.*?)\](.*)/);
if (null != tempResult) {
var parts = tempResult[2].split('-');
if (2 > parts.length)
return retArray;
var len = parts[0].length;
for (var i = parts[0]; i <= parts[1]; i++) {
var ts = i.toString();
if (ts.length < len)
ts = "000000".substring(0, (len - ts.length)) + ts;
retArray = retArray.concat(expandNR(tempResult[1] + ts
+ tempResult[3]));
}
return retArray;
}
var tempArray = nodeRange.split('-');
if (2 > tempArray.length) {
retArray.push(nodeRange);
return retArray;
}
var begin = tempArray[0].match(/^(\D+)(\d+)$/);
if (2 > begin) {
retArray.push(nodeRange);
return retArray;
}
var end = tempArray[1].match(/^(\D+)(\d+)$/);
if (2 > end) {
retArray.push(nodeRange);
return retArray;
}
if (begin[1] != end[1]) {
retArray.push(nodeRange);
return retArray;
}
var prefix = begin[1];
var len = begin[2].length;
for (var i = begin[2]; i <= end[2]; i++) {
var ts = i.toString();
if (ts.length < len)
ts = "000000".substring(0, (len - ts.length)) + ts;
retArray.push(prefix + ts);
}
return retArray;
}
/**
* collect all inputs' value from the page
* Collect all input values from the page
*
* @return true: this step is correct, can go to the next page
* false: this step contains error.
* @return True if this step is correct and can go to the next page, false if this step contains error
*/
function collectInputValue(){
$('#discoverContentDiv input[type=text]').each(function(){
var name = $(this).attr('name');
var value = $(this).attr('value');
if ('' != value)
setDiscoverEnv(name, value);
else
removeDiscoverEnv(name);
});
return true;
function collectInputValue() {
$('#discoverContentDiv input[type=text]').each(function() {
var name = $(this).attr('name');
var value = $(this).attr('value');
if ('' != value)
setDiscoverEnv(name, value);
else
removeDiscoverEnv(name);
});
return true;
}
/**
* verify the ip address,
* Verify the IP address
*
* @param
*
* @return true: for valid IP address
* false : for invalid IP address
* @param ip IP address
* @return True if IP address is valid, false otherwise
*/
function verifyIp(ip){
function verifyIp(ip) {
var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-4])$/;
return reg.test(ip);
}
/**
* transfer ip into decimal
* Transalate IP into decimal
*
* @param
*
* @return decimal type ip address
* @param ip IP address
* @return Decimal type for IP address
*/
function ip2Decimal(ip){
function ip2Decimal(ip) {
if (!verifyIp(ip))
return 0;
var retIp = 0;
var tempArray = ip.split('.');
for (var i = 0; i < 4; i++){
for (var i = 0; i < 4; i++) {
retIp = (retIp << 8) | parseInt(tempArray[i]);
}
//change the int into unsigned int type
// Change the int into unsigned int type
retIp = retIp >>> 0;
return retIp;
}
/**
* calculate the end IP address by start IP and the number of IP range.
*
* @param
*
* @return
* Calculate the ending IP address from the starting IP address and the IP range number.
*/
function calcEndIp(ipStart, num){
function calcEndIp(ipStart, num) {
var sum = 0;
var tempNum = Number(num);
var temp = /(\d+)\.(\d+)\.(\d+)\.(\d+)/;
var ipArray = temp.exec(ipStart);
ipArray.shift();
sum = Number(ipArray[3]) + tempNum;
if (sum <= 254){
if (sum <= 254) {
ipArray[3] = sum;
return (ipArray.join('.'));
}
ipArray[3] = sum % 254;
sum = Number(ipArray[2]) + parseInt(sum / 254);
if (sum <= 255){
if (sum <= 255) {
ipArray[2] = sum;
return (ipArray.join('.'));
}
ipArray[2] = sum % 255;
sum = Number(ipArray[1]) + parseInt(sum / 255);
if (sum <= 255){
if (sum <= 255) {
ipArray[1] = sum;
return (ipArray.join('.'));
}
ipArray[1] = sum % 255;
ipArray[0] = ipArray[0] + parseInt(sum / 255);
return (ipArray.join('.'));
}
/**
* Step 1: show the wizard's function
* platform selector(system P or system X)
*
* @return nothing
* Step 1: Show the wizard's function platform selector (System p or System x)
*/
function initSelectPlatform(){
var type = '';
$('#discoverContentDiv').empty();
$('.tooltip').remove();
var selectPlatform = $('<div style="min-height:360px"><h2>' + steps[currentStep] + '</h2></div>');
var infoMsg = 'This wizard will guide you through the process of defining the naming conventions within' +
'your cluster, discovering the hardware on your network, and automatically defining it in the xCAT' +
'database. Choose which type of hardware you want to discover, and then click Next.';
var info = createInfoBar(infoMsg);
selectPlatform.append(info);
var hwList = $('<ol>Platforms available:</ol>');
hwList.append('<li><input type="radio" name="platform" id="idataplex"><label>iDataPlex</label></input></li>');
hwList.append('<li><input type="radio" name="platform" disabled="true" id="blade"><span style="color:gray;"> BladeCenter</span></input></li>');
hwList.append('<li><input type="radio" name="platform" id="ih"> System p hardware (P7 IH)</input></li>');
hwList.append('<li><input type="radio" name="platform" id="nonih"> System p hardware (Non P7 IH)</input></li>');
hwList.find('li').css('padding', '2px 10px');
selectPlatform.append(hwList);
$('#discoverContentDiv').append(selectPlatform);
if (getDiscoverEnv('machineType'))
type = getDiscoverEnv('machineType');
else
type = 'ih';
$('#discoverContentDiv #' + type).attr('checked', 'checked');
createDiscoverButtons();
function initSelectPlatform() {
var type = '';
$('#discoverContentDiv').empty();
$('.tooltip').remove();
var selectPlatform = $('<div style="min-height:360px"><h2>' + steps[currentStep] + '</h2></div>');
var infoMsg = 'This wizard will guide you through the process of defining the naming conventions within'
+ 'your cluster, discovering the hardware on your network, and automatically defining it in the xCAT'
+ 'database. Choose which type of hardware you want to discover, and then click Next.';
var info = createInfoBar(infoMsg);
selectPlatform.append(info);
var hwList = $('<ol>Platforms available:</ol>');
hwList.append('<li><input type="radio" name="platform" id="idataplex"><label>iDataPlex</label></input></li>');
hwList.append('<li><input type="radio" name="platform" disabled="true" id="blade"><span style="color:gray;"> BladeCenter</span></input></li>');
hwList.append('<li><input type="radio" name="platform" id="ih"> System p hardware (P7 IH)</input></li>');
hwList.append('<li><input type="radio" name="platform" id="nonih"> System p hardware (Non P7 IH)</input></li>');
hwList.find('li').css('padding', '2px 10px');
selectPlatform.append(hwList);
$('#discoverContentDiv').append(selectPlatform);
if (getDiscoverEnv('machineType'))
type = getDiscoverEnv('machineType');
else
type = 'ih';
$('#discoverContentDiv #' + type).attr('checked', 'checked');
createDiscoverButtons();
}
/**
* Step 1: Get the platform type
*
* @return true
*/
function getPlatform(){
var radioValue = $('#discoverContentDiv :checked').attr('id');
var platformObj;
switch(radioValue){
case 'ih':
case 'nonih':
platformObj = new hmcPlugin();
break;
case 'idataplex':
platformObj = new ipmiPlugin();
break;
case 'blade':
break;
}
steps = ['Platform'].concat(platformObj.getStep(), 'compelte');
initFunctions = [initSelectPlatform].concat(platformObj.getInitFunction(), complete);
nextFunctions = [getPlatform].concat(platformObj.getNextFunction(), undefined);
setDiscoverEnv('machineType', radioValue);
return true;
function getPlatform() {
var radioValue = $('#discoverContentDiv :checked').attr('id');
var platformObj = null;
switch (radioValue) {
case 'ih':
case 'nonih':
platformObj = new hmcPlugin();
break;
case 'idataplex':
platformObj = new ipmiPlugin();
break;
case 'blade':
break;
}
steps = [ 'Platform' ].concat(platformObj.getStep(), 'compelte');
initFunctions = [ initSelectPlatform ].concat(platformObj.getInitFunction(), complete);
nextFunctions = [ getPlatform ].concat(platformObj.getNextFunction(), undefined);
setDiscoverEnv('machineType', radioValue);
return true;
}
/**
* last step: complete
*
* @param
*
* @return
* Last step: Complete
*/
function complete(){
$('#discoverContentDiv').empty();
$('.tooltip').remove();
var showStr = '<div style="min-height:360px"><h2>' + steps[currentStep] + '<br/><br/></h2>';
showStr += 'You can go to the <a href="index.php">nodes page</a> to check nodes which were defined just now.';
$('#discoverContentDiv').append(showStr);
createDiscoverButtons();
function complete() {
$('#discoverContentDiv').empty();
$('.tooltip').remove();
var showStr = '<div style="min-height:360px"><h2>' + steps[currentStep] + '<br/><br/></h2>';
showStr += 'You can go to the <a href="index.php">nodes page</a> to check nodes which were defined just now.';
$('#discoverContentDiv').append(showStr);
createDiscoverButtons();
}

View File

@ -6,360 +6,352 @@ var topPriority = 0;
/**
* Load the service portal's provision page
*
* @param tabId
* Tab ID where page will reside
* @return Nothing
* @param tabId Tab ID where page will reside
*/
function loadServicePage(tabId) {
// Create info bar
var infoBar = createInfoBar('Select a platform to configure, then click Ok.');
// Create self-service portal page
var tabId = 'serviceTab';
var servicePg = $('<div class="form"></div>');
$('#' + tabId).append(infoBar, servicePg);
// Create info bar
var infoBar = createInfoBar('Select a platform to configure, then click Ok.');
// Create self-service portal page
var tabId = 'serviceTab';
var servicePg = $('<div class="form"></div>');
$('#' + tabId).append(infoBar, servicePg);
// Create radio buttons for platforms
var hwList = $('<ol>Platforms available:</ol>');
var esx = $('<li><input type="radio" name="hw" value="esx" checked/>ESX</li>');
var kvm = $('<li><input type="radio" name="hw" value="kvm"/>KVM</li>');
var zvm = $('<li><input type="radio" name="hw" value="zvm"/>z\/VM</li>');
hwList.append(esx);
hwList.append(kvm);
hwList.append(zvm);
servicePg.append(hwList);
// Create radio buttons for platforms
var hwList = $('<ol>Platforms available:</ol>');
var esx = $('<li><input type="radio" name="hw" value="esx" checked/>ESX</li>');
var kvm = $('<li><input type="radio" name="hw" value="kvm"/>KVM</li>');
var zvm = $('<li><input type="radio" name="hw" value="zvm"/>z\/VM</li>');
hwList.append(esx);
hwList.append(kvm);
hwList.append(zvm);
servicePg.append(hwList);
/**
* Ok
*/
var okBtn = createButton('Ok');
okBtn.bind('click', function(event) {
var configTabs = getConfigTab();
// Get hardware that was selected
var hw = $(this).parent().find('input[name="hw"]:checked').val();
var newTabId = hw + 'ProvisionTab';
/**
* Ok
*/
var okBtn = createButton('Ok');
okBtn.bind('click', function(event) {
var configTabs = getConfigTab();
// Get hardware that was selected
var hw = $(this).parent().find('input[name="hw"]:checked').val();
var newTabId = hw + 'ProvisionTab';
if ($('#' + newTabId).size() > 0){
configTabs.select(newTabId);
} else {
var title = '';
// Create an instance of the plugin
var plugin;
switch (hw) {
case "kvm":
plugin = new kvmPlugin();
title = 'KVM';
break;
case "esx":
plugin = new esxPlugin();
title = 'ESX';
break;
case "zvm":
plugin = new zvmPlugin();
title = 'z/VM';
// Get zVM host names
if (!$.cookie('srv_zvm')){
$.ajax( {
url : 'lib/srv_cmd.php',
dataType : 'json',
data : {
cmd : 'webportal',
tgt : '',
args : 'lszvm',
msg : ''
},
if ($('#' + newTabId).size() > 0){
configTabs.select(newTabId);
} else {
var title = '';
// Create an instance of the plugin
var plugin = null;
switch (hw) {
case "kvm":
plugin = new kvmPlugin();
title = 'KVM';
break;
case "esx":
plugin = new esxPlugin();
title = 'ESX';
break;
case "zvm":
plugin = new zvmPlugin();
title = 'z/VM';
// Get zVM host names
if (!$.cookie('srv_zvm')){
$.ajax( {
url : 'lib/srv_cmd.php',
dataType : 'json',
data : {
cmd : 'webportal',
tgt : '',
args : 'lszvm',
msg : ''
},
success : function(data) {
setzVMCookies(data);
}
});
}
break;
}
success : function(data) {
setzVMCookies(data);
}
});
}
break;
}
// Select tab
configTabs.add(newTabId, title, '', true);
configTabs.select(newTabId);
plugin.loadConfigPage(newTabId);
}
});
servicePg.append(okBtn);
// Select tab
configTabs.add(newTabId, title, '', true);
configTabs.select(newTabId);
plugin.loadConfigPage(newTabId);
}
});
servicePg.append(okBtn);
}
/**
* Load the user panel where users can be created, modified, or deleted
*
* @param panelId
* Panel ID
* @return Nothing
* @param panelId Panel ID
*/
function loadUserPanel(panelId) {
// Get users list
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'tabdump',
tgt : '',
args : 'passwd',
msg : panelId
},
// Get users list
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'tabdump',
tgt : '',
args : 'passwd',
msg : panelId
},
success : loadUserTable
});
success : loadUserTable
});
}
/**
* Load user datatable
*
* @param data
* HTTP request data
* @return Nothing
* @param data HTTP request data
*/
function loadUserTable(data) {
// Get response
var rsp = data.rsp;
// Get panel ID
var panelId = data.msg;
// Wipe panel clean
$('#' + panelId).empty();
// Add info bar
$('#' + panelId).append(createInfoBar('Create, edit, and delete users for the self-service portal. Double-click on a cell to edit a users properties. Click outside the table to save changes. Hit the Escape key to ignore changes.'));
// Get table headers
// The table headers in the passwd table are: key, username, password, cryptmethod, comments, and disable
var headers = new Array('priority', 'username', 'password', 'max-vm');
// Get response
var rsp = data.rsp;
// Get panel ID
var panelId = data.msg;
// Wipe panel clean
$('#' + panelId).empty();
// Add info bar
$('#' + panelId).append(createInfoBar('Create, edit, and delete users for the self-service portal. Double-click on a cell to edit a users properties. Click outside the table to save changes. Hit the Escape key to ignore changes.'));
// Get table headers
// The table headers in the passwd table are: key, username, password, cryptmethod, comments, and disable
var headers = new Array('priority', 'username', 'password', 'max-vm');
// Create a new datatable
var tableId = 'userDatatable';
var table = new DataTable(tableId);
// Create a new datatable
var tableId = 'userDatatable';
var table = new DataTable(tableId);
// Add column for the checkbox
headers.unshift('<input type="checkbox" onclick="selectAllCheckbox(event, $(this))">');
table.init(headers);
headers.shift();
// Add column for the checkbox
headers.unshift('<input type="checkbox" onclick="selectAllCheckbox(event, $(this))">');
table.init(headers);
headers.shift();
// Append datatable to panel
$('#' + panelId).append(table.object());
// Append datatable to panel
$('#' + panelId).append(table.object());
// Add table rows
// Start with the 2nd row (1st row is the headers)
for ( var i = 1; i < rsp.length; i++) {
// Split into columns
var tmp = rsp[i].split(',');
// Go through each column
for (var j = 0; j < tmp.length; j++) {
// Replace quote
tmp[j] = tmp[j].replace(new RegExp('"', 'g'), '');
}
// Only add users having the key = xcat
if (tmp[0] == 'xcat') {
// Columns are: priority, username, password, and max-vm
var cols = new Array('', tmp[1], tmp[2], '');
// Add remove button where id = user name
cols.unshift('<input type="checkbox" name="' + tmp[1] + '"/>');
// Add row
table.add(cols);
}
}
// Add table rows
// Start with the 2nd row (1st row is the headers)
for ( var i = 1; i < rsp.length; i++) {
// Split into columns
var tmp = rsp[i].split(',');
// Go through each column
for (var j = 0; j < tmp.length; j++) {
// Replace quote
tmp[j] = tmp[j].replace(new RegExp('"', 'g'), '');
}
// Only add users having the key = xcat
if (tmp[0] == 'xcat') {
// Columns are: priority, username, password, and max-vm
var cols = new Array('', tmp[1], tmp[2], '');
// Add remove button where id = user name
cols.unshift('<input type="checkbox" name="' + tmp[1] + '"/>');
// Add row
table.add(cols);
}
}
// Turn table into datatable
$('#' + tableId).dataTable({
'iDisplayLength': 50,
'bLengthChange': false,
"sScrollX": "100%",
"bAutoWidth": true
});
// Turn table into datatable
$('#' + tableId).dataTable({
'iDisplayLength': 50,
'bLengthChange': false,
"sScrollX": "100%",
"bAutoWidth": true
});
// Create action bar
var actionBar = $('<div class="actionBar"></div>');
var createLnk = $('<a>Create</a>');
createLnk.click(function() {
openCreateUserDialog();
});
var deleteLnk = $('<a>Delete</a>');
deleteLnk.click(function() {
var users = getNodesChecked(tableId);
if (users) {
openDeleteUserDialog(users);
}
});
var refreshLnk = $('<a>Refresh</a>');
refreshLnk.click(function() {
loadUserPanel(panelId);
});
// Create an action menu
var actionsMenu = createMenu([createLnk, deleteLnk, refreshLnk]);
actionsMenu.superfish();
actionsMenu.css('display', 'inline-block');
actionBar.append(actionsMenu);
// Set correct theme for action menu
actionsMenu.find('li').hover(function() {
setMenu2Theme($(this));
}, function() {
setMenu2Normal($(this));
});
// Create a division to hold actions menu
var menuDiv = $('<div id="' + tableId + '_menuDiv" class="menuDiv"></div>');
$('#' + tableId + '_wrapper').prepend(menuDiv);
menuDiv.append(actionBar);
$('#' + tableId + '_filter').appendTo(menuDiv);
// Get policy data
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'tabdump',
tgt : '',
args : 'policy',
msg : tableId
},
// Create action bar
var actionBar = $('<div class="actionBar"></div>');
var createLnk = $('<a>Create</a>');
createLnk.click(function() {
openCreateUserDialog();
});
var deleteLnk = $('<a>Delete</a>');
deleteLnk.click(function() {
var users = getNodesChecked(tableId);
if (users) {
openDeleteUserDialog(users);
}
});
var refreshLnk = $('<a>Refresh</a>');
refreshLnk.click(function() {
loadUserPanel(panelId);
});
// Create an action menu
var actionsMenu = createMenu([createLnk, deleteLnk, refreshLnk]);
actionsMenu.superfish();
actionsMenu.css('display', 'inline-block');
actionBar.append(actionsMenu);
// Set correct theme for action menu
actionsMenu.find('li').hover(function() {
setMenu2Theme($(this));
}, function() {
setMenu2Normal($(this));
});
// Create a division to hold actions menu
var menuDiv = $('<div id="' + tableId + '_menuDiv" class="menuDiv"></div>');
$('#' + tableId + '_wrapper').prepend(menuDiv);
menuDiv.append(actionBar);
$('#' + tableId + '_filter').appendTo(menuDiv);
// Get policy data
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'tabdump',
tgt : '',
args : 'policy',
msg : tableId
},
success : loadUserTable4Policy
});
/**
* Enable editable cells
*/
// Do not make 1st or 2nd column editable
$('#' + tableId + ' td:not(td:nth-child(1),td:nth-child(2))').editable(
function(value, settings) {
// If users did not make changes, return the value directly
// jeditable saves the old value in this.revert
if ($(this).attr('revert') == value){
return value;
}
var panelId = $(this).parents('.ui-accordion-content').attr('id');
// Get column index
var colPos = this.cellIndex;
// Get row index
var dTable = $('#' + tableId).dataTable();
var rowPos = dTable.fnGetPosition(this.parentNode);
// Update datatable
dTable.fnUpdate(value, rowPos, colPos, false);
// Get table headers
var headers = $('#' + nodesTableId).parents('.dataTables_scroll').find('.dataTables_scrollHead thead tr:eq(0) th');
// Get user attributes
var priority = $(this).parent().find('td:eq(1)').text();
var user = $(this).parent().find('td:eq(2)').text();
var password = $(this).parent().find('td:eq(3)').text();
var maxVM = $(this).parent().find('td:eq(4)').text();
// Send command to change user attributes
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'webrun',
tgt : '',
args : 'updateuser;' + priority + ';' + user + ';' + password + ';' + maxVM,
msg : panelId
},
success : updatePanel
});
success : loadUserTable4Policy
});
/**
* Enable editable cells
*/
// Do not make 1st or 2nd column editable
$('#' + tableId + ' td:not(td:nth-child(1),td:nth-child(2))').editable(
function(value, settings) {
// If users did not make changes, return the value directly
// jeditable saves the old value in this.revert
if ($(this).attr('revert') == value){
return value;
}
var panelId = $(this).parents('.ui-accordion-content').attr('id');
// Get column index
var colPos = this.cellIndex;
// Get row index
var dTable = $('#' + tableId).dataTable();
var rowPos = dTable.fnGetPosition(this.parentNode);
// Update datatable
dTable.fnUpdate(value, rowPos, colPos, false);
// Get table headers
var headers = $('#' + nodesTableId).parents('.dataTables_scroll').find('.dataTables_scrollHead thead tr:eq(0) th');
// Get user attributes
var priority = $(this).parent().find('td:eq(1)').text();
var user = $(this).parent().find('td:eq(2)').text();
var password = $(this).parent().find('td:eq(3)').text();
var maxVM = $(this).parent().find('td:eq(4)').text();
// Send command to change user attributes
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'webrun',
tgt : '',
args : 'updateuser;' + priority + ';' + user + ';' + password + ';' + maxVM,
msg : panelId
},
success : updatePanel
});
return value;
}, {
onblur : 'submit', // Clicking outside editable area submits changes
type : 'textarea',
placeholder: ' ',
event : "dblclick", // Double click and edit
height : '30px' // The height of the text area
});
// Resize accordion
$('#' + tableId).parents('.ui-accordion').accordion('resize');
return value;
}, {
onblur : 'submit', // Clicking outside editable area submits changes
type : 'textarea',
placeholder: ' ',
event : "dblclick", // Double click and edit
height : '30px' // The height of the text area
});
// Resize accordion
$('#' + tableId).parents('.ui-accordion').accordion('resize');
}
/**
* Update user datatable for policy
*
* @param data
* HTTP request data
* @return Nothing
* @param data HTTP request data
*/
function loadUserTable4Policy(data) {
// Get response
var rsp = data.rsp;
// Get datatable ID
var tableId = data.msg;
// Get datatable
var datatable = $('#' + tableId).dataTable();
// Get response
var rsp = data.rsp;
// Get datatable ID
var tableId = data.msg;
// Get datatable
var datatable = $('#' + tableId).dataTable();
// Update max-vm column
// The data coming back contains: priority, name, host, commands, noderange, parameters, time, rule, comments, disable
// Start with the 2nd row (1st row is the headers)
topPriority = 0;
for ( var i = 1; i < rsp.length; i++) {
// Split into columns
var tmp = rsp[i].split(',');
// Go through each column
for (var j = 0; j < tmp.length; j++) {
// Replace quote
tmp[j] = tmp[j].replace(new RegExp('"', 'g'), '');
}
// Get the row containing the user name
var rowPos = -1;
if (tmp[1])
rowPos = findRow(tmp[1], '#' + tableId, 2);
// Update the priority and max-vm columns
if (rowPos > -1) {
var maxVM = tmp[8].replace('max-vm:', '');
maxVM = maxVM.replace(';', '');
datatable.fnUpdate(maxVM, rowPos, 4, false);
var priority = tmp[0];
datatable.fnUpdate(priority, rowPos, 1, false);
// Set the highest priority
if (priority > topPriority)
topPriority = priority;
}
}
// Adjust column sizes
adjustColumnSize(tableId);
// Resize accordion
$('#' + tableId).parents('.ui-accordion').accordion('resize');
// Update max-vm column
// The data coming back contains: priority, name, host, commands, noderange, parameters, time, rule, comments, disable
// Start with the 2nd row (1st row is the headers)
topPriority = 0;
for ( var i = 1; i < rsp.length; i++) {
// Split into columns
var tmp = rsp[i].split(',');
// Go through each column
for (var j = 0; j < tmp.length; j++) {
// Replace quote
tmp[j] = tmp[j].replace(new RegExp('"', 'g'), '');
}
// Get the row containing the user name
var rowPos = -1;
if (tmp[1])
rowPos = findRow(tmp[1], '#' + tableId, 2);
// Update the priority and max-vm columns
if (rowPos > -1) {
var maxVM = tmp[8].replace('max-vm:', '');
maxVM = maxVM.replace(';', '');
datatable.fnUpdate(maxVM, rowPos, 4, false);
var priority = tmp[0];
datatable.fnUpdate(priority, rowPos, 1, false);
// Set the highest priority
if (priority > topPriority)
topPriority = priority;
}
}
// Adjust column sizes
adjustColumnSize(tableId);
// Resize accordion
$('#' + tableId).parents('.ui-accordion').accordion('resize');
}
/**
* Open a dialog to create a user
*/
function openCreateUserDialog() {
var dialogId = 'createUser';
var dialog = $('<div id="' + dialogId + '" class="form"></div>');
var dialogId = 'createUser';
var dialog = $('<div id="' + dialogId + '" class="form"></div>');
var info = createInfoBar('Create an xCAT user. A priority will be generated for the new user.');
dialog.append(info);
@ -369,57 +361,57 @@ function openCreateUserDialog() {
// Create node inputs
dialog.append($('<div><label>Priority:</label><input name="priority" type="text" disabled="disabled" value="' + userPriority + '"></div>'));
dialog.append($('<div><label>User name:</label><input name="username" type="text"></div>'));
dialog.append($('<div><label>Password:</label><input name="password" type="password"></div>'));
dialog.append($('<div><label>Maximum virtual machines:</label><input name="maxvm" type="text"></div>'));
dialog.append($('<div><label>User name:</label><input name="username" type="text"></div>'));
dialog.append($('<div><label>Password:</label><input name="password" type="password"></div>'));
dialog.append($('<div><label>Maximum virtual machines:</label><input name="maxvm" type="text"></div>'));
dialog.dialog({
title: 'Create user',
title: 'Create user',
modal: true,
width: 400,
close: function(){
$(this).remove();
$(this).remove();
},
buttons: {
"OK" : function(){
// Remove any warning messages
$(this).find('.ui-state-error').remove();
// Change dialog buttons
$('#' + dialogId).dialog('option', 'buttons', {
'Close':function(){
$(this).dialog('close');
}
});
var priority = $(this).find('input[name="priority"]').val();
var user = $(this).find('input[name="username"]').val();
var password = $(this).find('input[name="password"]').val();
var maxVM = $(this).find('input[name="maxvm"]').val();
// Verify inputs are provided
if (!user || !password || !maxVM) {
var warn = createWarnBar('Please provide a value for each missing field!');
warn.prependTo($(this));
} else {
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'webrun',
tgt : '',
args : 'updateuser;' + priority + ';' + user + ';' + password + ';' + maxVM,
msg : dialogId
},
success : updatePanel
});
// Update highest priority
topPriority = priority;
}
// Remove any warning messages
$(this).find('.ui-state-error').remove();
// Change dialog buttons
$('#' + dialogId).dialog('option', 'buttons', {
'Close':function(){
$(this).dialog('close');
}
});
var priority = $(this).find('input[name="priority"]').val();
var user = $(this).find('input[name="username"]').val();
var password = $(this).find('input[name="password"]').val();
var maxVM = $(this).find('input[name="maxvm"]').val();
// Verify inputs are provided
if (!user || !password || !maxVM) {
var warn = createWarnBar('Please provide a value for each missing field!');
warn.prependTo($(this));
} else {
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'webrun',
tgt : '',
args : 'updateuser;' + priority + ';' + user + ';' + password + ';' + maxVM,
msg : dialogId
},
success : updatePanel
});
// Update highest priority
topPriority = priority;
}
},
"Cancel": function(){
$(this).dialog('close');
$(this).dialog('close');
}
}
});
@ -428,110 +420,104 @@ function openCreateUserDialog() {
/**
* Update dialog
*
* @param data
* HTTP request data
* @return Nothing
* @param data HTTP request data
*/
function updatePanel(data) {
var dialogId = data.msg;
var infoMsg;
var dialogId = data.msg;
var infoMsg;
// Create info message
if (jQuery.isArray(data.rsp)) {
infoMsg = '';
for (var i in data.rsp) {
infoMsg += data.rsp[i] + '</br>';
}
} else {
infoMsg = data.rsp;
}
// Create info bar with close button
var infoBar = $('<div class="ui-state-highlight ui-corner-all"></div>').css('margin', '5px 0px');
var icon = $('<span class="ui-icon ui-icon-info"></span>').css({
'display': 'inline-block',
'margin': '10px 5px'
});
// Create close button to close info bar
var close = $('<span class="ui-icon ui-icon-close"></span>').css({
'display': 'inline-block',
'float': 'right'
}).click(function() {
$(this).parent().remove();
});
var msg = $('<pre>' + infoMsg + '</pre>').css({
'display': 'inline-block',
'width': '85%'
});
infoBar.append(icon, msg, close);
infoBar.prependTo($('#' + dialogId));
// Create info message
if (jQuery.isArray(data.rsp)) {
infoMsg = '';
for (var i in data.rsp) {
infoMsg += data.rsp[i] + '</br>';
}
} else {
infoMsg = data.rsp;
}
// Create info bar with close button
var infoBar = $('<div class="ui-state-highlight ui-corner-all"></div>').css('margin', '5px 0px');
var icon = $('<span class="ui-icon ui-icon-info"></span>').css({
'display': 'inline-block',
'margin': '10px 5px'
});
// Create close button to close info bar
var close = $('<span class="ui-icon ui-icon-close"></span>').css({
'display': 'inline-block',
'float': 'right'
}).click(function() {
$(this).parent().remove();
});
var msg = $('<pre>' + infoMsg + '</pre>').css({
'display': 'inline-block',
'width': '85%'
});
infoBar.append(icon, msg, close);
infoBar.prependTo($('#' + dialogId));
}
/**
* Open dialog to confirm user delete
*
* @param users
* Users to delete
* @return Nothing
* @param users Users to delete
*/
function openDeleteUserDialog(users) {
// Create form to delete disk to pool
var dialogId = 'deleteUser';
var deleteForm = $('<div id="' + dialogId + '" class="form"></div>');
// Create info bar
var info = createInfoBar('Are you sure you want to delete ' + users.replace(new RegExp(',', 'g'), ', ') + '?');
deleteForm.append(info);
// Open dialog to delete user
deleteForm.dialog({
title:'Delete user',
modal: true,
width: 400,
close: function(){
$(this).remove();
// Create form to delete disk to pool
var dialogId = 'deleteUser';
var deleteForm = $('<div id="' + dialogId + '" class="form"></div>');
// Create info bar
var info = createInfoBar('Are you sure you want to delete ' + users.replace(new RegExp(',', 'g'), ', ') + '?');
deleteForm.append(info);
// Open dialog to delete user
deleteForm.dialog({
title:'Delete user',
modal: true,
width: 400,
close: function(){
$(this).remove();
},
buttons: {
"Ok": function(){
// Remove any warning messages
$(this).find('.ui-state-error').remove();
// Change dialog buttons
$(this).dialog('option', 'buttons', {
'Close': function() {$(this).dialog("close");}
});
// Delete user
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'webrun',
tgt : '',
args : 'deleteuser;' + users,
msg : dialogId
},
success : updatePanel
});
},
"Cancel": function() {
$(this).dialog( "close" );
}
}
});
buttons: {
"Ok": function(){
// Remove any warning messages
$(this).find('.ui-state-error').remove();
// Change dialog buttons
$(this).dialog('option', 'buttons', {
'Close': function() {$(this).dialog("close");}
});
// Delete user
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'webrun',
tgt : '',
args : 'deleteuser;' + users,
msg : dialogId
},
success : updatePanel
});
},
"Cancel": function() {
$(this).dialog( "close" );
}
}
});
}
/**
* Round a floating point to a given precision
*
* @param value
* Floating point
* @param precision
* Decimal precision
* @returns Floating point number
* @param value Floating point
* @param precision Decimal precision
* @returns Floating point number
*/
function toFixed(value, precision) {
var power = Math.pow(10, precision || 0);

View File

@ -1,321 +1,310 @@
/**
* Load update page
*
* @return Nothing
*/
function loadUpdatePage() {
var repositoryDiv = $('<div id="repository"></div>');
var rpmDiv = $('<div id="rpm"></div>');
var statusDiv = createStatusBar("update");
statusDiv.hide();
var repositoryDiv = $('<div id="repository"></div>');
var rpmDiv = $('<div id="rpm"></div>');
var statusDiv = createStatusBar("update");
statusDiv.hide();
$('#updateTab').append(statusDiv);
$('#updateTab').append('<br/>');
$('#updateTab').append(repositoryDiv);
$('#updateTab').append(rpmDiv);
$('#updateTab').append(statusDiv);
$('#updateTab').append('<br/>');
$('#updateTab').append(repositoryDiv);
$('#updateTab').append(rpmDiv);
var infoBar = createInfoBar('Select the repository to use and the RPMs to update, then click Update.');
repositoryDiv.append(infoBar);
var infoBar = createInfoBar('Select the repository to use and the RPMs to update, then click Update.');
repositoryDiv.append(infoBar);
repositoryDiv.append("<fieldset><legend>Repository</legend></fieldset>");
$.ajax( {
url : 'lib/systemcmd.php',
dataType : 'json',
data : {
cmd : 'ostype'
},
repositoryDiv.append("<fieldset><legend>Repository</legend></fieldset>");
$.ajax( {
url : 'lib/systemcmd.php',
dataType : 'json',
data : {
cmd : 'ostype'
},
success : showRepository
});
success : showRepository
});
rpmDiv.append("<fieldset></fieldset>");
$.ajax( {
url : 'lib/systemcmd.php',
dataType : 'json',
data : {
cmd : 'rpm -q xCAT-client perl-xCAT xCAT-server xCAT xCAT-rmc xCAT-UI'
},
rpmDiv.append("<fieldset></fieldset>");
$.ajax( {
url : 'lib/systemcmd.php',
dataType : 'json',
data : {
cmd : 'rpm -q xCAT-client perl-xCAT xCAT-server xCAT xCAT-rmc xCAT-UI'
},
success : showRpmInfo
});
success : showRpmInfo
});
}
/**
* Show the RPM Repository, it can use user's last choice and input
* Show the RPM repository (it can use the user's last choice and input)
*
* @param data
* Data returned from HTTP request
* @return Nothing
* @param data Data returned from HTTP request
*/
function showRepository(data) {
var develRepository = "";
var stableRepository = "";
var show = "";
var develRepository = "";
var stableRepository = "";
var show = "";
// Get the corresponding repository by OS Type
if (data.rsp == "aix") {
// No repository exists for AIX on sourceforge!
develRepository = "http://xcat.sourceforge.net/aix/devel/xcat-core/";
stableRepository = "http://xcat.sourceforge.net/aix/xcat-core/";
} else {
develRepository = "http://sourceforge.net/projects/xcat/files/yum/devel/xcat-core/";
stableRepository = "http://sourceforge.net/projects/xcat/files/yum/stable/xcat-core/";
}
// Get the corresponding repository by OS Type
if (data.rsp == "aix") {
// No repository exists for AIX on Sourceforge!
develRepository = "http://xcat.sourceforge.net/aix/devel/xcat-core/";
stableRepository = "http://xcat.sourceforge.net/aix/xcat-core/";
} else {
develRepository = "http://sourceforge.net/projects/xcat/files/yum/devel/xcat-core/";
stableRepository = "http://sourceforge.net/projects/xcat/files/yum/stable/xcat-core/";
}
var repoList = $('<ol></ol>');
var repoList = $('<ol></ol>');
// Display the Devel Repository, remember user's last selection
show = show + "<li><input type='radio' ";
if ($.cookie('xcatrepository') == 1) {
show = show + "checked='true'";
}
show = show + "name='reporadio' value='" + develRepository + "'>";
show = show + "<strong>Development</strong>: " + develRepository + "</li>";
repoList.append(show);
// Display the Devel Repository, remember user's last selection
show = show + "<li><input type='radio' ";
if ($.cookie('xcatrepository') == 1) {
show = show + "checked='true'";
}
show = show + "name='reporadio' value='" + develRepository + "'>";
show = show + "<strong>Development</strong>: " + develRepository + "</li>";
repoList.append(show);
// Display the Stable Repository, remember user's last selection
show = "<li><input type='radio' ";
if ($.cookie('xcatrepository') == 2) {
show = show + "checked='true'";
}
show = show + "name='reporadio' value='" + stableRepository + "' checked='true'>";
show = show + "<strong>Stable</strong>: " + stableRepository + "</li>";
repoList.append(show);
// Display the Stable Repository, remember user's last selection
show = "<li><input type='radio' ";
if ($.cookie('xcatrepository') == 2) {
show = show + "checked='true'";
}
show = show + "name='reporadio' value='" + stableRepository + "' checked='true'>";
show = show + "<strong>Stable</strong>: " + stableRepository + "</li>";
repoList.append(show);
// Display the Input Repository, remember user's last selection
if (($.cookie('xcatrepository')) && ($.cookie('xcatrepository') != 1)
&& ($.cookie('xcatrepository') != 2)) {
show = "<li><input type='radio' checked='true' name='reporadio' value=''>Other: ";
show += "<input style='width: 500px' id='repositoryaddr' value='"
+ $.cookie('xcatrepository') + "'</li>";
} else {
show = "<li><input type='radio' name='reporadio' value=''>Other: ";
show += "<input style='width: 500px' id='repositoryaddr' value=''</li>";
}
repoList.append(show);
$('#repository fieldset').append(repoList);
// Display the Input Repository, remember user's last selection
if (($.cookie('xcatrepository')) && ($.cookie('xcatrepository') != 1)
&& ($.cookie('xcatrepository') != 2)) {
show = "<li><input type='radio' checked='true' name='reporadio' value=''>Other: ";
show += "<input style='width: 500px' id='repositoryaddr' value='"
+ $.cookie('xcatrepository') + "'</li>";
} else {
show = "<li><input type='radio' name='reporadio' value=''>Other: ";
show += "<input style='width: 500px' id='repositoryaddr' value=''</li>";
}
repoList.append(show);
$('#repository fieldset').append(repoList);
}
/**
* Show all xCAT RPMs
*
* @param data
* Data returned from HTTP request
* @return Nothing
* @param data Data returned from HTTP request
*/
function showRpmInfo(data) {
var rpms = null;
var show = "";
var rpmNames = new Array("xCAT-client", "perl-xCAT", "xCAT-server", "xCAT", "xCAT-rmc",
"xCAT-UI");
var temp = 0;
if (null == data.rsp) {
$('#rpm fieldset').append("Error getting RPMs!");
return;
}
var rpms = null;
var show = "";
var rpmNames = new Array("xCAT-client", "perl-xCAT", "xCAT-server", "xCAT", "xCAT-rmc",
"xCAT-UI");
var temp = 0;
if (null == data.rsp) {
$('#rpm fieldset').append("Error getting RPMs!");
return;
}
rpms = data.rsp.split(/\n/);
// No rpm installed, return
if (1 > rpms.length) {
$('#rpm fieldset').append("No RPMs installed!");
return;
}
rpms = data.rsp.split(/\n/);
// No rpm installed, return
if (1 > rpms.length) {
$('#rpm fieldset').append("No RPMs installed!");
return;
}
// Clear the old data
$('#rpm fieldset').children().remove();
$('#rpm fieldset').append("<legend>xCAT RPMs</legend>");
show = "<table id=rpmtable >";
show += "<thead class='ui-widget-header'><tr>";
show += "<th><input type='checkbox' id='selectall' value='' onclick='updateSelectAll()'></th>";
show += "<th><b>Package Name</b></th><th><b>Version</b></th>";
show += "</tr></thead>";
for (temp = 0; temp < rpms.length; temp++) {
// Empty line continue
if (!rpms[temp]) {
continue;
}
// Clear the old data
$('#rpm fieldset').children().remove();
$('#rpm fieldset').append("<legend>xCAT RPMs</legend>");
show = "<table id=rpmtable >";
show += "<thead class='ui-widget-header'><tr>";
show += "<th><input type='checkbox' id='selectall' value='' onclick='updateSelectAll()'></th>";
show += "<th><b>Package Name</b></th><th><b>Version</b></th>";
show += "</tr></thead>";
for (temp = 0; temp < rpms.length; temp++) {
// Empty line continue
if (!rpms[temp]) {
continue;
}
// The RPM is not installed, continue
if (rpms[temp].indexOf("not") != -1) {
continue;
}
// The RPM is not installed, continue
if (rpms[temp].indexOf("not") != -1) {
continue;
}
// Show the version in table
show += "<tr>";
show += "<td><input type='checkbox' value='" + rpmNames[temp] + "'></td>";
show += "<td>" + rpmNames[temp] + "</td><td>"
+ rpms[temp].substr(rpmNames[temp].length + 1) + "</td>";
show += "</tr>";
}
show += "</table>";
show += "<br\>";
$('#rpm fieldset').append(show);
// Show the version in table
show += "<tr>";
show += "<td><input type='checkbox' value='" + rpmNames[temp] + "'></td>";
show += "<td>" + rpmNames[temp] + "</td><td>"
+ rpms[temp].substr(rpmNames[temp].length + 1) + "</td>";
show += "</tr>";
}
show += "</table>";
show += "<br\>";
$('#rpm fieldset').append(show);
// Add the update button
var updateButton = createButton('Update');
$('#rpm fieldset').append(updateButton);
updateButton.bind('click', function() {
updateRpm();
});
// Add the update button
var updateButton = createButton('Update');
$('#rpm fieldset').append(updateButton);
updateButton.bind('click', function() {
updateRpm();
});
}
/**
* Select all checkboxes
*
* @return Nothing
*/
function updateSelectAll() {
var check_status = $('#selectall').attr('checked');
$('input:checkbox').attr('checked', check_status);
var check_status = $('#selectall').attr('checked');
$('input:checkbox').attr('checked', check_status);
}
/**
* Update selected xCAT RPMs
*
* @return Nothing
*/
function updateRpm() {
// Remove any warning messages
$('#updateTab').find('.ui-state-error').remove();
// Remove any warning messages
$('#updateTab').find('.ui-state-error').remove();
var rpmPath = $('input[type=radio]:checked').val();
var rpmPathType = "0";
var rpms = "";
var temp = "";
var rpmPath = $('input[type=radio]:checked').val();
var rpmPathType = "0";
var rpms = "";
var temp = "";
if (undefined == rpmPath) {
rpmPath = "";
}
if (undefined == rpmPath) {
rpmPath = "";
}
// Select other and we should use the value in the input
if ("" == rpmPath) {
// Store repo in a cookie
rpmPath = $('#repositoryaddr').val();
rpmPathType = rpmPath;
} else {
if (-1 == rpmPath.toLowerCase().indexOf("devel")) {
rpmPathType = "2";
} else {
rpmPathType = "1";
}
}
// Select other and we should use the value in the input
if ("" == rpmPath) {
// Store repo in a cookie
rpmPath = $('#repositoryaddr').val();
rpmPathType = rpmPath;
} else {
if (-1 == rpmPath.toLowerCase().indexOf("devel")) {
rpmPathType = "2";
} else {
rpmPathType = "1";
}
}
$("input[type=checkbox]:checked").each(function() {
temp = $(this).val();
if ("" == temp) {
return true;
}
$("input[type=checkbox]:checked").each(function() {
temp = $(this).val();
if ("" == temp) {
return true;
}
var pattern = new RegExp("^" + temp + ",|," + temp + ",");
if (pattern.test(rpms)) {
return true;
}
rpms = rpms + temp + ",";
});
var pattern = new RegExp("^" + temp + ",|," + temp + ",");
if (pattern.test(rpms)) {
return true;
}
rpms = rpms + temp + ",";
});
if (0 < rpms.length) {
rpms = rpms.slice(0, -1);
}
if (0 < rpms.length) {
rpms = rpms.slice(0, -1);
}
// Check RPM and repository
var errMsg = '';
if (!rpms) {
errMsg = "Please select an RPM!<br>";
}
// Check RPM and repository
var errMsg = '';
if (!rpms) {
errMsg = "Please select an RPM!<br>";
}
if (!rpmPath) {
errMsg += "Please select or specify a repository!";
}
if (!rpmPath) {
errMsg += "Please select or specify a repository!";
}
if (!rpms || !rpmPath) {
// Show warning message
var warn = createWarnBar(errMsg);
warn.prependTo($('#updateTab'));
return;
}
if (!rpms || !rpmPath) {
// Show warning message
var warn = createWarnBar(errMsg);
warn.prependTo($('#updateTab'));
return;
}
// Remember users' choice and input
$.cookie('xcatrepository', rpmPathType, {
path : '/xcat',
expires : 10
});
// Remember users' choice and input
$.cookie('xcatrepository', rpmPathType, {
path : '/xcat',
expires : 10
});
$('#update').show();
$('#update div').empty();
$('#update div').append("<p>Updating <b>" + rpms + "</b> from <b>" + rpmPath + "</b></p>");
$('#update div').append("<img id='loadingpic' src='images/loader.gif'>");
$('#rpm button').attr('disabled', 'true');
$('#update').show();
$('#update div').empty();
$('#update div').append("<p>Updating <b>" + rpms + "</b> from <b>" + rpmPath + "</b></p>");
$('#update div').append("<img id='loadingpic' src='images/loader.gif'>");
$('#rpm button').attr('disabled', 'true');
// Send the update command to server
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'webrun',
tgt : '',
args : 'update;' + rpms + ";" + rpmPath,
msg : ''
},
// Send the update command to server
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'webrun',
tgt : '',
args : 'update;' + rpms + ";" + rpmPath,
msg : ''
},
success : showUpdateResult
});
success : showUpdateResult
});
}
/**
* Show the results of the RPM update
*
* @param data
* Data returned from HTTP request
* @return Nothing
* @param data Data returned from HTTP request
*/
function showUpdateResult(data) {
var temp = 0;
$('#loadingpic').remove();
var temp = 0;
$('#loadingpic').remove();
var resArray = data.rsp[0].split(/\n/);
if (0 < resArray.length) {
// Show last lines
if (('' == resArray[resArray.length - 1]) && (resArray.length > 1)) {
$('#update div').append('<pre>' + resArray[resArray.length - 2] + '</pre>');
} else {
$('#update div').append('<pre>' + resArray[resArray.length - 1] + '</pre>');
}
var resArray = data.rsp[0].split(/\n/);
if (0 < resArray.length) {
// Show last lines
if (('' == resArray[resArray.length - 1]) && (resArray.length > 1)) {
$('#update div').append('<pre>' + resArray[resArray.length - 2] + '</pre>');
} else {
$('#update div').append('<pre>' + resArray[resArray.length - 1] + '</pre>');
}
// Create link to show details
$('#update div').append('<br/><a>Show details</a>');
$('#update div a').css( {
'color' : '#0000FF',
'cursor' : 'pointer'
}).bind('click', function() {
// Toggle details and change text
$('#resDetail').toggle();
if ($('#update div a').text() == 'Show details') {
$('#update div a').text('Hide details');
} else {
$('#update div a').text('Show details');
}
});
// Create link to show details
$('#update div').append('<br/><a>Show details</a>');
$('#update div a').css( {
'color' : '#0000FF',
'cursor' : 'pointer'
}).bind('click', function() {
// Toggle details and change text
$('#resDetail').toggle();
if ($('#update div a').text() == 'Show details') {
$('#update div a').text('Hide details');
} else {
$('#update div a').text('Show details');
}
});
var resDetail = $('<pre id="resDetail"></pre>');
resDetail.hide();
$('#update div').append(resDetail);
for (temp = 0; temp < resArray.length; temp++) {
resDetail.append(resArray[temp] + '<br/>');
}
}
var resDetail = $('<pre id="resDetail"></pre>');
resDetail.hide();
$('#update div').append(resDetail);
for (temp = 0; temp < resArray.length; temp++) {
resDetail.append(resArray[temp] + '<br/>');
}
}
// Update the rpm info
$.ajax( {
url : 'lib/systemcmd.php',
dataType : 'json',
data : {
cmd : 'rpm -q xCAT-client perl-xCAT xCAT-server xCAT xCAT-rmc xCAT-UI'
},
// Update the rpm info
$.ajax( {
url : 'lib/systemcmd.php',
dataType : 'json',
data : {
cmd : 'rpm -q xCAT-client perl-xCAT xCAT-server xCAT xCAT-rmc xCAT-UI'
},
success : showRpmInfo
});
success : showRpmInfo
});
$('#rpm button').attr('disabled', '');
$('#rpm button').attr('disabled', '');
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,30 +1,30 @@
function loadHelpPage(){
// Create help tab
// Create help tab
var tab = new Tab();
tab.init();
$('#content').append(tab.object());
// Add help content
// Add help content
var helpForm = $('<div class="form"></div>');
helpForm.append(
'<fieldset>' +
'<legend>Quick Start</legend>' +
'<div style="display: inline-table; vertical-align: middle;"><img src="images/help/quick_start.png" style="width: 90%;"></img></div>' +
'<ol style="display: inline-table; vertical-align: middle;">' +
'<li><a href="configure.php" style="color: blue;">1. Discover hardware</a><br/>Discover all hardware in the cluster. Define them in the xCAT database. Initialize your cluster.</li>' +
'<li><a href="index.php" style="color: blue;">2. Verify defined nodes</a><br/>View nodes definition by groups in a table or graphical style.</li>' +
'<li><a href="configure.php" style="color: blue;">3. Install compute nodes</a><br/>Copy useful files from DVD onto harddisk. Create Linux images. Install compute nodes in stateful, stateless, and statelite style.</li>' +
'<li><a href="provision.php" style="color: blue;">4. Provision nodes</a><br/>Create stateful, stateless, or statelite virtual machines. Install an operating system on a physical machine.</li>' +
'<li><a href="monitor.php" style="color: blue;">5. Monitor Cluster</a><br/>Monitor your xCAT cluster using one or more third party monitoring software such as Ganglia, RMC, etc. </li>' +
'<fieldset>' +
'<legend>Quick Start</legend>' +
'<div style="display: inline-table; vertical-align: middle;"><img src="images/help/quick_start.png" style="width: 90%;"></img></div>' +
'<ol style="display: inline-table; vertical-align: middle;">' +
'<li><a href="configure.php" style="color: blue;">1. Discover hardware</a><br/>Discover all hardware in the cluster. Define them in the xCAT database. Initialize your cluster.</li>' +
'<li><a href="index.php" style="color: blue;">2. Verify defined nodes</a><br/>View nodes definition by groups in a table or graphical style.</li>' +
'<li><a href="configure.php" style="color: blue;">3. Install compute nodes</a><br/>Copy useful files from DVD onto harddisk. Create Linux images. Install compute nodes in stateful, stateless, and statelite style.</li>' +
'<li><a href="provision.php" style="color: blue;">4. Provision nodes</a><br/>Create stateful, stateless, or statelite virtual machines. Install an operating system on a physical machine.</li>' +
'<li><a href="monitor.php" style="color: blue;">5. Monitor Cluster</a><br/>Monitor your xCAT cluster using one or more third party monitoring software such as Ganglia, RMC, etc. </li>' +
'</ol>' +
'</fieldset>' +
'<fieldset>' +
'<legend>Advanced</legend>' +
'<div style="display: inline-table; vertical-align: middle;"><img src="images/help/advanced_settings.png" style="width: 90%;"></img></div>' +
'<ol style="display: inline-table; vertical-align: middle;">' +
'<li><a href="configure.php" style="color: blue;">a. Edit the xCAT database tables</a></li>' +
'<li><a href="configure.php" style="color: blue;">b. Update the xCAT RPM on the Management Node</a></li>' +
'</ol>' +
'</fieldset>');
'<fieldset>' +
'<legend>Advanced</legend>' +
'<div style="display: inline-table; vertical-align: middle;"><img src="images/help/advanced_settings.png" style="width: 90%;"></img></div>' +
'<ol style="display: inline-table; vertical-align: middle;">' +
'<li><a href="configure.php" style="color: blue;">a. Edit the xCAT database tables</a></li>' +
'<li><a href="configure.php" style="color: blue;">b. Update the xCAT RPM on the Management Node</a></li>' +
'</ol>' +
'</fieldset>');
tab.add('helpTab', 'Help', helpForm, false);
}

File diff suppressed because it is too large Load Diff

View File

@ -11,300 +11,290 @@ var monitorTabs; // Monitor tabs
* @return Nothing
*/
function setMonitorTab(o) {
monitorTabs = o;
monitorTabs = o;
}
/**
* Get the monitor tab
*
* @param Nothing
* @return Tab object
*/
function getMonitorTab() {
return monitorTabs;
return monitorTabs;
}
/**
* Load the monitor page
*
* @return Nothing
*/
function loadMonitorPage() {
// If the page is already loaded
if ($('#monitor_page').children().length) {
// Do not reload the monitor page
return;
}
// If the page is already loaded
if ($('#monitor_page').children().length) {
// Do not reload the monitor page
return;
}
// Create monitor tab
var tab = new Tab();
setMonitorTab(tab);
tab.init();
$('#content').append(tab.object());
// Create monitor tab
var tab = new Tab();
setMonitorTab(tab);
tab.init();
$('#content').append(tab.object());
var monitorForm = $('<div class="form"></div>');
monitorForm.append('Getting monitoring status ').append(createLoader());
tab.add('monitorTab', 'Monitor', monitorForm, false);
var monitorForm = $('<div class="form"></div>');
monitorForm.append('Getting monitoring status ').append(createLoader());
tab.add('monitorTab', 'Monitor', monitorForm, false);
// Get monitoring status of each tool
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'webrun',
tgt : '',
args : 'monls',
msg : ''
},
// Get monitoring status of each tool
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'webrun',
tgt : '',
args : 'monls',
msg : ''
},
/**
* Load monitoring status
*
* @param data
* Data returned from HTTP request
* @return Nothing
*/
success : function(data){
// Initialize status for each tool
var statusHash = new Object();
statusHash['xcatmon'] = 'Off';
statusHash['rmcmon'] = 'Off';
statusHash['rmcevent'] = 'Off';
statusHash['gangliamon'] = 'Off';
statusHash['pcpmon'] = 'Off';
if (data.rsp[0]) {
var tempArray = data.rsp[0].split(';');
var position = 0;
var name = '';
var status = '';
for ( var i in tempArray) {
position = tempArray[i].indexOf(':');
if (position == -1) {
continue;
}
/**
* Load monitoring status
*
* @param data Data returned from HTTP request
*/
success : function(data){
// Initialize status for each tool
var statusHash = new Object();
statusHash['xcatmon'] = 'Off';
statusHash['rmcmon'] = 'Off';
statusHash['rmcevent'] = 'Off';
statusHash['gangliamon'] = 'Off';
statusHash['pcpmon'] = 'Off';
if (data.rsp[0]) {
var tempArray = data.rsp[0].split(';');
var position = 0;
var name = '';
var status = '';
for ( var i in tempArray) {
position = tempArray[i].indexOf(':');
if (position == -1) {
continue;
}
name = tempArray[i].substr(0, position);
status = tempArray[i].substr(position + 1);
statusHash[name] = status;
}
}
// Create a status buttonset for each monitoring tool
var statusButtonHash = new Object();
for ( var name in statusHash) {
var statusButton = $('<div></div>').css({
'width': '100px',
'text-align': 'center'
});
statusButtonHash[name] = statusButton;
// Set button to correct status
if (statusHash[name] == 'On') {
statusButton.append($('<input type="radio" id="' + name + 'On" name="' + name + '" value="On" checked="checked"/><label for="' + name + 'On">On</label>'));
statusButton.append($('<input type="radio" id="' + name + 'Off" name="' + name + '" value="Off"/><label for="' + name + 'Off">Off</label>'));
} else {
statusButton.append($('<input type="radio" id="' + name + 'On" name="' + name + '" value="On"/><label for="' + name + 'On">On</label>'));
statusButton.append($('<input type="radio" id="' + name + 'Off" name="' + name + '" value="Off" checked="checked"/><label for="' + name + 'Off">Off</label>'));
}
name = tempArray[i].substr(0, position);
status = tempArray[i].substr(position + 1);
statusHash[name] = status;
}
}
// Create a status buttonset for each monitoring tool
var statusButtonHash = new Object();
for ( var name in statusHash) {
var statusButton = $('<div></div>').css({
'width': '100px',
'text-align': 'center'
});
statusButtonHash[name] = statusButton;
// Set button to correct status
if (statusHash[name] == 'On') {
statusButton.append($('<input type="radio" id="' + name + 'On" name="' + name + '" value="On" checked="checked"/><label for="' + name + 'On">On</label>'));
statusButton.append($('<input type="radio" id="' + name + 'Off" name="' + name + '" value="Off"/><label for="' + name + 'Off">Off</label>'));
} else {
statusButton.append($('<input type="radio" id="' + name + 'On" name="' + name + '" value="On"/><label for="' + name + 'On">On</label>'));
statusButton.append($('<input type="radio" id="' + name + 'Off" name="' + name + '" value="Off" checked="checked"/><label for="' + name + 'Off">Off</label>'));
}
statusButton.find('label').css({
'margin': '0px',
'padding': '0px',
'font-size': '10px',
'width': 'auto'
});
statusButton.buttonset();
// Turn on or off monitoring tool when clicked
statusButton.find('input["' + name + '"]:radio').change(toggleMonitor);
}
var monTable = $('<table></table>');
monTable.append($('<thead class="ui-widget-header"><tr><th><b>Tool</b></th><th><b>Status</b></th><th><b>Description</b></th></tr></thead>'));
var monTableBody = $('<tbody></tbody>');
monTable.append(monTableBody);
var xcatMon = $('<tr></tr>');
xcatMon.append($('<td><a href="#" name="xcatmon">xCAT</a></td>'));
xcatMon.append($('<td></td>').append(statusButtonHash['xcatmon']));
xcatMon.append($('<td>Provides node status monitoring using fping on AIX and nmap on Linux. It also provides application status monitoring. The status and the appstatus columns of the nodelist table will be updated periodically with the latest status values for the nodes.</td>'));
monTableBody.append(xcatMon);
var rmcMon = $('<tr></tr>');
rmcMon.append($('<td><a href="#" name="rmcmon">RMC</a></td>'));
rmcMon.append($('<td></td>').append(statusButtonHash['rmcmon']));
rmcMon.append($('<td>IBM\'s Resource Monitoring and Control (RMC) subsystem is our recommended software for monitoring xCAT clusters. It\'s is part of the IBM\'s Reliable Scalable Cluster Technology (RSCT) that provides a comprehensive clustering environment for AIX and Linux.</td>'));
monTableBody.append(rmcMon);
var rmcEvent = $('<tr></tr>');
rmcEvent.append($('<td><a href="#" name="rmcevent">RMC Event</a></td>'));
rmcEvent.append($('<td></td>').append(statusButtonHash['rmcevent']));
rmcEvent.append($('<td>Listing event monitoring information recorded by the RSCT Event Response resource manager in the audit log. Creating and removing a condition/response association.</td>'));
monTableBody.append(rmcEvent);
statusButton.find('label').css({
'margin': '0px',
'padding': '0px',
'font-size': '10px',
'width': 'auto'
});
statusButton.buttonset();
// Turn on or off monitoring tool when clicked
statusButton.find('input["' + name + '"]:radio').change(toggleMonitor);
}
var monTable = $('<table></table>');
monTable.append($('<thead class="ui-widget-header"><tr><th><b>Tool</b></th><th><b>Status</b></th><th><b>Description</b></th></tr></thead>'));
var monTableBody = $('<tbody></tbody>');
monTable.append(monTableBody);
var xcatMon = $('<tr></tr>');
xcatMon.append($('<td><a href="#" name="xcatmon">xCAT</a></td>'));
xcatMon.append($('<td></td>').append(statusButtonHash['xcatmon']));
xcatMon.append($('<td>Provides node status monitoring using fping on AIX and nmap on Linux. It also provides application status monitoring. The status and the appstatus columns of the nodelist table will be updated periodically with the latest status values for the nodes.</td>'));
monTableBody.append(xcatMon);
var rmcMon = $('<tr></tr>');
rmcMon.append($('<td><a href="#" name="rmcmon">RMC</a></td>'));
rmcMon.append($('<td></td>').append(statusButtonHash['rmcmon']));
rmcMon.append($('<td>IBM\'s Resource Monitoring and Control (RMC) subsystem is our recommended software for monitoring xCAT clusters. It\'s is part of the IBM\'s Reliable Scalable Cluster Technology (RSCT) that provides a comprehensive clustering environment for AIX and Linux.</td>'));
monTableBody.append(rmcMon);
var rmcEvent = $('<tr></tr>');
rmcEvent.append($('<td><a href="#" name="rmcevent">RMC Event</a></td>'));
rmcEvent.append($('<td></td>').append(statusButtonHash['rmcevent']));
rmcEvent.append($('<td>Listing event monitoring information recorded by the RSCT Event Response resource manager in the audit log. Creating and removing a condition/response association.</td>'));
monTableBody.append(rmcEvent);
var gangliaMon = $('<tr></tr>');
gangliaMon.append($('<td><a href="#" name="gangliamon">Ganglia</a></td>'));
gangliaMon.append($('<td></td>').append(statusButtonHash['gangliamon']));
gangliaMon.append($('<td>A scalable distributed monitoring system for high-performance computing systems such as clusters and Grids.</td>'));
monTableBody.append(gangliaMon);
var pcpMon = $('<tr></tr>');
pcpMon.append($('<td><a href="#" name="pcpmon">PCP</a></td>'));
pcpMon.append($('<td></td>').append(statusButtonHash['pcpmon']));
pcpMon.append($('<td>Not yet supported</td>'));
monTableBody.append(pcpMon);
// Do not word wrap
monTableBody.find('td:nth-child(1)').css('white-space', 'nowrap');
monTableBody.find('td:nth-child(3)').css({
'white-space': 'normal',
'text-align': 'left'
});
// Append info bar
$('#monitorTab div').empty().append(createInfoBar('Select a monitoring tool to use'));
$('#monitorTab .form').append(monTable);
// Open monitoring tool onclick
$('#monitorTab .form a').bind('click', function() {
loadMonitorTab($(this).attr('name'));
});
}
});
// Create resources tab
var resrcForm = $('<div class="form"></div>');
var gangliaMon = $('<tr></tr>');
gangliaMon.append($('<td><a href="#" name="gangliamon">Ganglia</a></td>'));
gangliaMon.append($('<td></td>').append(statusButtonHash['gangliamon']));
gangliaMon.append($('<td>A scalable distributed monitoring system for high-performance computing systems such as clusters and Grids.</td>'));
monTableBody.append(gangliaMon);
var pcpMon = $('<tr></tr>');
pcpMon.append($('<td><a href="#" name="pcpmon">PCP</a></td>'));
pcpMon.append($('<td></td>').append(statusButtonHash['pcpmon']));
pcpMon.append($('<td>Not yet supported</td>'));
monTableBody.append(pcpMon);
// Do not word wrap
monTableBody.find('td:nth-child(1)').css('white-space', 'nowrap');
monTableBody.find('td:nth-child(3)').css({
'white-space': 'normal',
'text-align': 'left'
});
// Append info bar
$('#monitorTab div').empty().append(createInfoBar('Select a monitoring tool to use'));
$('#monitorTab .form').append(monTable);
// Open monitoring tool onclick
$('#monitorTab .form a').bind('click', function() {
loadMonitorTab($(this).attr('name'));
});
}
});
// Create resources tab
var resrcForm = $('<div class="form"></div>');
// Create info bar
var resrcInfoBar = createInfoBar('Select a platform to view its current resources.');
resrcForm.append(resrcInfoBar);
// Create info bar
var resrcInfoBar = createInfoBar('Select a platform to view its current resources.');
resrcForm.append(resrcInfoBar);
// Create radio buttons for platforms
var hwList = $('<ol>Platforms available:</ol>');
var esx = $('<li><input type="radio" name="hw" value="esx" checked/>ESX</li>');
var kvm = $('<li><input type="radio" name="hw" value="kvm"/>KVM</li>');
var zvm = $('<li><input type="radio" name="hw" value="zvm"/>z\/VM</li>');
var ipmi = $('<li><input type="radio" name="hw" value="ipmi"/>iDataPlex</li>');
var blade = $('<li><input type="radio" name="hw" value="blade"/>BladeCenter</li>');
var hmc = $('<li><input type="radio" name="hw" value="hmc"/>System p</li>');
hwList.append(esx);
hwList.append(kvm);
hwList.append(zvm);
hwList.append(blade);
hwList.append(ipmi);
hwList.append(hmc);
resrcForm.append(hwList);
// Create radio buttons for platforms
var hwList = $('<ol>Platforms available:</ol>');
var esx = $('<li><input type="radio" name="hw" value="esx" checked/>ESX</li>');
var kvm = $('<li><input type="radio" name="hw" value="kvm"/>KVM</li>');
var zvm = $('<li><input type="radio" name="hw" value="zvm"/>z\/VM</li>');
var ipmi = $('<li><input type="radio" name="hw" value="ipmi"/>iDataPlex</li>');
var blade = $('<li><input type="radio" name="hw" value="blade"/>BladeCenter</li>');
var hmc = $('<li><input type="radio" name="hw" value="hmc"/>System p</li>');
hwList.append(esx);
hwList.append(kvm);
hwList.append(zvm);
hwList.append(blade);
hwList.append(ipmi);
hwList.append(hmc);
resrcForm.append(hwList);
var okBtn = createButton('Ok');
okBtn.bind('click', function(event) {
// Get hardware that was selected
var hw = $(this).parent().find('input[name="hw"]:checked').val();
var okBtn = createButton('Ok');
okBtn.bind('click', function(event) {
// Get hardware that was selected
var hw = $(this).parent().find('input[name="hw"]:checked').val();
// Generate new tab ID
var newTabId = hw + 'ResourceTab';
if (!$('#' + newTabId).length) {
// Create loader
var loader = $('<center></center>').append(createLoader(hw + 'ResourceLoader'));
// Generate new tab ID
var newTabId = hw + 'ResourceTab';
if (!$('#' + newTabId).length) {
// Create loader
var loader = $('<center></center>').append(createLoader(hw + 'ResourceLoader'));
// Create an instance of the plugin
var plugin;
var displayName = "";
switch (hw) {
case "kvm":
plugin = new kvmPlugin();
displayName = "KVM";
break;
case "esx":
plugin = new esxPlugin();
displayName = "ESX";
break;
case "blade":
plugin = new bladePlugin();
displayName = "BladeCenter";
break;
case "hmc":
plugin = new hmcPlugin();
displayName = "System p";
break;
case "ipmi":
plugin = new ipmiPlugin();
displayName = "iDataPlex";
break;
case "zvm":
plugin = new zvmPlugin();
displayName = "z\/VM";
break;
}
// Add resource tab and load resources
tab.add(newTabId, displayName, loader, true);
plugin.loadResources();
}
// Create an instance of the plugin
var plugin = null;
var displayName = "";
switch (hw) {
case "kvm":
plugin = new kvmPlugin();
displayName = "KVM";
break;
case "esx":
plugin = new esxPlugin();
displayName = "ESX";
break;
case "blade":
plugin = new bladePlugin();
displayName = "BladeCenter";
break;
case "hmc":
plugin = new hmcPlugin();
displayName = "System p";
break;
case "ipmi":
plugin = new ipmiPlugin();
displayName = "iDataPlex";
break;
case "zvm":
plugin = new zvmPlugin();
displayName = "z\/VM";
break;
}
// Add resource tab and load resources
tab.add(newTabId, displayName, loader, true);
plugin.loadResources();
}
// Select tab
tab.select(newTabId);
});
resrcForm.append(okBtn);
tab.add('resourceTab', 'Resources', resrcForm, false);
// Select tab
tab.select(newTabId);
});
resrcForm.append(okBtn);
tab.add('resourceTab', 'Resources', resrcForm, false);
}
/**
* Load monitoring tool in a new tab
*
* @param name
* Name of monitoring tool
* @return Nothing
* @param name Name of monitoring tool
*/
function loadMonitorTab(name) {
// If the tab exist, then we only need to select it
var tab = getMonitorTab();
if ($("#" + name).length) {
tab.select(name);
return;
}
// If the tab exist, then we only need to select it
var tab = getMonitorTab();
if ($("#" + name).length) {
tab.select(name);
return;
}
switch (name) {
case 'xcatmon':
tab.add(name, 'xCAT', '', true);
loadXcatMon();
break;
case 'rmcmon':
tab.add(name, 'RMC Monitor', '', true);
loadRmcMon();
break;
case 'gangliamon':
tab.add(name, 'Ganglia', '', true);
loadGangliaMon();
break;
case 'rmcevent':
tab.add(name, 'RMC Event', '', true);
loadRmcEvent();
break;
case 'pcpmon':
loadUnfinish(name, tab);
break;
}
switch (name) {
case 'xcatmon':
tab.add(name, 'xCAT', '', true);
loadXcatMon();
break;
case 'rmcmon':
tab.add(name, 'RMC Monitor', '', true);
loadRmcMon();
break;
case 'gangliamon':
tab.add(name, 'Ganglia', '', true);
loadGangliaMon();
break;
case 'rmcevent':
tab.add(name, 'RMC Event', '', true);
loadRmcEvent();
break;
case 'pcpmon':
loadUnfinish(name, tab);
break;
}
tab.select(name);
tab.select(name);
}
/**
* Load tab showing 'Under contruction'
*
* @param monitorName
* Name of monitoring tool
* @param tab
* Tab area
* @return Nothing
* @param monitorName Name of monitoring tool
* @param tab Tab area
*/
function loadUnfinish(monitorName, tab) {
var unfinishPage = $('<div></div>');
unfinishPage.append(createInfoBar('Not yet supported'));
tab.add(monitorName, 'Unfinished', unfinishPage, true);
var unfinishPage = $('<div></div>');
unfinishPage.append(createInfoBar('Not yet supported'));
tab.add(monitorName, 'Unfinished', unfinishPage, true);
}
/**
@ -312,65 +302,63 @@ function loadUnfinish(monitorName, tab) {
*
* @return Nothing
*/
function toggleMonitor() {
// Get the name of the monitoring tool
var name = $(this).attr('name');
// Get the status to toggle to, either on or off
var status = $(this).val();
function toggleMonitor() {
// Get the name of the monitoring tool
var name = $(this).attr('name');
// Get the status to toggle to, either on or off
var status = $(this).val();
// Start or stop monitoring plugin
var command = 'monstart';
if (status == 'Off') {
command = 'monstop' ;
}
// Start or stop monitoring on xCAT
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : command,
tgt : '',
args : name + '',
msg : ''
},
success : function(data) {
// Start or stop monitoring on remote nodes
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : command,
tgt : '',
args : name + ';-r',
msg : name + ' switched ' + status
},
success : updateMonStatus
});
}
});
// Start or stop monitoring plugin
var command = 'monstart';
if (status == 'Off') {
command = 'monstop' ;
}
// Start or stop monitoring on xCAT
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : command,
tgt : '',
args : name + '',
msg : ''
},
success : function(data) {
// Start or stop monitoring on remote nodes
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : command,
tgt : '',
args : name + ';-r',
msg : name + ' switched ' + status
},
success : updateMonStatus
});
}
});
}
/**
* Update the monitoring status on Monitor tab
*
* @param data
* Data returned from HTTP request
* @return Nothing
* @param data Data returned from HTTP request
*/
function updateMonStatus(data) {
var rsp = data.rsp[data.rsp.length-1];
var msg = data.msg;
// Create appropriate info or warning bar
var bar = '';
if (rsp.indexOf('started') > -1 || rsp.indexOf('stopped') > -1) {
bar = createInfoBar(msg);
} else {
var bar = createWarnBar('Failed to ' + msg + '. ' + rsp);
}
// Prepend info or warning bar to tab
bar.prependTo($('#monitorTab .form'));
bar.delay(4000).slideUp();
var rsp = data.rsp[data.rsp.length-1];
var msg = data.msg;
// Create appropriate info or warning bar
var bar = '';
if (rsp.indexOf('started') > -1 || rsp.indexOf('stopped') > -1) {
bar = createInfoBar(msg);
} else {
bar = createWarnBar('Failed to ' + msg + '. ' + rsp);
}
// Prepend info or warning bar to tab
bar.prependTo($('#monitorTab .form'));
bar.delay(4000).slideUp();
}

File diff suppressed because it is too large Load Diff

View File

@ -7,402 +7,402 @@ var xcatMonTableId = "xcatMonSettingTable";
* Load xCAT monitoring
*/
function loadXcatMon() {
// Find xCAT monitoring tab
var xcatMonTab = $('#xcatmon');
xcatMonTab.append("<div id= xcatmonTable></div>");
// Find xCAT monitoring tab
var xcatMonTab = $('#xcatmon');
xcatMonTab.append("<div id= xcatmonTable></div>");
// Show content of monsetting table
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'tabdump',
tgt : '',
args : 'monsetting',
msg : ''
},
success : loadXcatMonSetting
});
// Show content of monsetting table
$.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'tabdump',
tgt : '',
args : 'monsetting',
msg : ''
},
success : loadXcatMonSetting
});
}
function loadXcatMonSetting(data) {
var apps = ""; // Contains the xcatmon config
var rsp = data.rsp;
var apps_flag = 0;
var ping; // xcatmon ping interval
var ping_flag = 0;
var apps = ""; // Contains the xcatmon config
var rsp = data.rsp;
var apps_flag = 0;
var ping; // xcatmon ping interval
var ping_flag = 0;
// Create an info bar
var infoBar = createInfoBar('Click on a cell to edit. Click outside the table to write to the cell. Once you are finished configuring the xCAT monitor, click on Apply.');
$('#xcatmonTable').append(infoBar);
// Create an info bar
var infoBar = createInfoBar('Click on a cell to edit. Click outside the table to write to the cell. Once you are finished configuring the xCAT monitor, click on Apply.');
$('#xcatmonTable').append(infoBar);
// Create xcatmon table
var xcatmonTable = new DataTable(xcatMonTableId);
// Create xcatmon table
var xcatmonTable = new DataTable(xcatMonTableId);
// Create datatable
var dTable;
// Create datatable
var dTable;
// Create table header
var header = rsp[0].split(",");
header.splice(3, 2);
header.splice(0, 1);
header[0] = "App Name";
header[1] = "Configure";
header.push('<input type="checkbox" onclick="selectAllCheckbox(event,$(this))">');
header.unshift('');
xcatmonTable.init(header);
// Create table header
var header = rsp[0].split(",");
header.splice(3, 2);
header.splice(0, 1);
header[0] = "App Name";
header[1] = "Configure";
header.push('<input type="checkbox" onclick="selectAllCheckbox(event,$(this))">');
header.unshift('');
xcatmonTable.init(header);
// Create container for original table contents
var origCont = new Array();
origCont[0] = header; // Table headers
// Create container for original table contents
var origCont = new Array();
origCont[0] = header; // Table headers
// Create container for new contents to use later updating monsetting table
var newCont = new Object();
newCont[0] = rsp[0].split(","); // Table headers
// Create container for new contents to use later updating monsetting table
var newCont = new Object();
newCont[0] = rsp[0].split(","); // Table headers
// Create container for other monsetting lines
var otherCont = new Array();
// Create container for other monsetting lines
var otherCont = new Array();
$('#xcatmonTable').append(xcatmonTable.object());
var m = 1; // Count for origCont
var n = 0;
for ( var i = 1; i < rsp.length; i++) {
var pos = rsp[i].indexOf("xcatmon"); // Only check xcatmon setting
if (pos == 1) {
if ((rsp[i].indexOf("apps") == -1) && (rsp[i].indexOf("ping") == -1)) {
var cols = rsp[i].split(',');
for ( var j = 0; j < cols.length; j++) {
if (cols[j].count('"') % 2 == 1) {
while (cols[j].count('"') % 2 == 1) {
cols[j] = cols[j] + "," + cols[j + 1];
cols.splice(j + 1, 1);
}
}
cols[j] = cols[j].replace(new RegExp('"', 'g'), '');
}
$('#xcatmonTable').append(xcatmonTable.object());
var m = 1; // Count for origCont
var n = 0;
for ( var i = 1; i < rsp.length; i++) {
var pos = rsp[i].indexOf("xcatmon"); // Only check xcatmon setting
if (pos == 1) {
if ((rsp[i].indexOf("apps") == -1) && (rsp[i].indexOf("ping") == -1)) {
var cols = rsp[i].split(',');
for ( var j = 0; j < cols.length; j++) {
if (cols[j].count('"') % 2 == 1) {
while (cols[j].count('"') % 2 == 1) {
cols[j] = cols[j] + "," + cols[j + 1];
cols.splice(j + 1, 1);
}
}
cols[j] = cols[j].replace(new RegExp('"', 'g'), '');
}
cols.splice(3, 2);
cols.splice(0, 1);
cols.push('<input type="checkbox" name="' + cols[0] + '" title="Checking this box will add/remove the app from the configured app value"/>');
cols.unshift('<span class="ui-icon ui-icon-close" onclick="deleteXcatMonRow(this)"></span>');
cols.splice(3, 2);
cols.splice(0, 1);
cols.push('<input type="checkbox" name="' + cols[0] + '" title="Checking this box will add/remove the app from the configured app value"/>');
cols.unshift('<span class="ui-icon ui-icon-close" onclick="deleteXcatMonRow(this)"></span>');
// Add column to table
xcatmonTable.add(cols);
origCont[m++] = cols;
} else {
if (!apps_flag) { // Check the apps setting
if (rsp[i].indexOf("apps") > -1) {
apps = rsp[i].split(',');
// Add column to table
xcatmonTable.add(cols);
origCont[m++] = cols;
} else {
if (!apps_flag) { // Check the apps setting
if (rsp[i].indexOf("apps") > -1) {
apps = rsp[i].split(',');
for ( var j = 0; j < apps.length; j++) {
if (apps[j].count('"') % 2 == 1) {
while (apps[j].count('"') % 2 == 1) {
apps[j] = apps[j] + "," + apps[j + 1];
apps.splice(j + 1, 1);
}
}
apps[j] = apps[j].replace(new RegExp('"', 'g'), '');
}
for ( var j = 0; j < apps.length; j++) {
if (apps[j].count('"') % 2 == 1) {
while (apps[j].count('"') % 2 == 1) {
apps[j] = apps[j] + "," + apps[j + 1];
apps.splice(j + 1, 1);
}
}
apps[j] = apps[j].replace(new RegExp('"', 'g'), '');
}
apps_flag = 1; // Set the flag to 1 to avoid this subroute
}
}
apps_flag = 1; // Set the flag to 1 to avoid this subroute
}
}
// Get into the ping settings
if (!ping_flag) {
// Check the ping interval
if (rsp[i].indexOf("ping-interval") > -1) {
ping = rsp[i].split(',');
for ( var j = 0; j < ping.length; j++) {
if (ping[j].count('"') % 2 == 1) {
while (ping[j].count('"') % 2 == 1) {
ping[j] = ping[j] + "," + ping[j + 1];
ping.splice(j + 1, 1);
}
}
ping[j] = ping[j].replace((new RegExp('"', 'g')),
'');
}
ping_flag = 1;
}
}
}
} else if (pos != 1) {
// The other monitor in the monsetting table
var otherCols = rsp[i].split(',');
for ( var k = 0; k < otherCols.length; k++) {
if (otherCols[k].count('"') % 2 == 1) {
while (otherCols[k].count('"') % 2 == 1) {
otherCols[k] = otherCols[k] + "," + otherCols[k + 1];
otherCols.splice(k + 1, 1);
}
}
otherCols[k] = otherCols[k].replace(new RegExp('"', 'g'), '');
}
// Get into the ping settings
if (!ping_flag) {
// Check the ping interval
if (rsp[i].indexOf("ping-interval") > -1) {
ping = rsp[i].split(',');
for ( var j = 0; j < ping.length; j++) {
if (ping[j].count('"') % 2 == 1) {
while (ping[j].count('"') % 2 == 1) {
ping[j] = ping[j] + "," + ping[j + 1];
ping.splice(j + 1, 1);
}
}
ping[j] = ping[j].replace((new RegExp('"', 'g')),
'');
}
ping_flag = 1;
}
}
}
} else if (pos != 1) {
// The other monitor in the monsetting table
var otherCols = rsp[i].split(',');
for ( var k = 0; k < otherCols.length; k++) {
if (otherCols[k].count('"') % 2 == 1) {
while (otherCols[k].count('"') % 2 == 1) {
otherCols[k] = otherCols[k] + "," + otherCols[k + 1];
otherCols.splice(k + 1, 1);
}
}
otherCols[k] = otherCols[k].replace(new RegExp('"', 'g'), '');
}
otherCont[n++] = otherCols;
otherCont[n++] = otherCols;
}
}
// If app is not in the monsetting table, then create default apps row
if (!apps_flag) {
apps = rsp[0].split(',');
apps[0] = "xcatmon";
apps[1] = "apps";
apps[2] = "";
apps[3] = "";
apps[4] = "";
}
}
}
// If app is not in the monsetting table, then create default apps row
if (!apps_flag) {
apps = rsp[0].split(',');
apps[0] = "xcatmon";
apps[1] = "apps";
apps[2] = "";
apps[3] = "";
apps[4] = "";
}
// If the ping interval is not in the monsetting table, then create the
// default ping-interval
if (!ping_flag) {
ping = rsp[0].split(',');
ping[0] = "xcatmon";
ping[1] = "ping-interval";
// Set default ping-interval setting to 5
ping[2] = "5";
ping[3] = "";
ping[4] = "";
}
// If the ping interval is not in the monsetting table, then create the
// default ping-interval
if (!ping_flag) {
ping = rsp[0].split(',');
ping[0] = "xcatmon";
ping[1] = "ping-interval";
// Set default ping-interval setting to 5
ping[2] = "5";
ping[3] = "";
ping[4] = "";
}
// Set checkbox to be true
var checked = apps[2].split(',');
for ( var i = 0; i < checked.length; i++) {
$("input:checkbox[name=" + checked[i] + "]").attr('checked', true);
for ( var j = 0; j < origCont.length; j++) {
if (origCont[j][1] == checked[i]) {
origCont[j].splice(3, 1);
origCont[j].push('<input type="checkbox" name="' + origCont[j][1] + '" title="Check this checkbox to add/remove the app from the configured app value." checked=true/>');
}
}
// Set checkbox to be true
var checked = apps[2].split(',');
for ( var i = 0; i < checked.length; i++) {
$("input:checkbox[name=" + checked[i] + "]").attr('checked', true);
for ( var j = 0; j < origCont.length; j++) {
if (origCont[j][1] == checked[i]) {
origCont[j].splice(3, 1);
origCont[j].push('<input type="checkbox" name="' + origCont[j][1] + '" title="Check this checkbox to add/remove the app from the configured app value." checked=true/>');
}
}
}
$(":checkbox").tooltip();
}
$(":checkbox").tooltip();
// Make the table editable
$('#' + xcatMonTableId + ' td:not(td:nth-child(1),td:last-child)').editable(function(value, settings) {
var colPos = this.cellIndex;
var rowPos = dTable.fnGetPosition(this.parentNode);
dTable.fnUpdate(value, rowPos, colPos);
return (value);
}, {
onblur : 'submit',
type : 'textarea',
placeholder : ' ',
height : '30px'
});
// Make the table editable
$('#' + xcatMonTableId + ' td:not(td:nth-child(1),td:last-child)').editable(function(value, settings) {
var colPos = this.cellIndex;
var rowPos = dTable.fnGetPosition(this.parentNode);
dTable.fnUpdate(value, rowPos, colPos);
return (value);
}, {
onblur : 'submit',
type : 'textarea',
placeholder : ' ',
height : '30px'
});
// Save datatable
dTable = $('#' + xcatMonTableId).dataTable({
'iDisplayLength' : 50,
'bLengthChange' : false,
"sScrollX" : "100%",
"bAutoWidth" : true
});
// Save datatable
dTable = $('#' + xcatMonTableId).dataTable({
'iDisplayLength' : 50,
'bLengthChange' : false,
"sScrollX" : "100%",
"bAutoWidth" : true
});
// Create action bar
var actionBar = $('<div class="actionBar"></div>');
var addRowLnk = $('<a>Add row</a>');
addRowLnk.bind('click', function(event) {
// Create container for new row
var row = new Array();
// Create action bar
var actionBar = $('<div class="actionBar"></div>');
var addRowLnk = $('<a>Add row</a>');
addRowLnk.bind('click', function(event) {
// Create container for new row
var row = new Array();
// Add delete button to row
row.push('<span class="ui-icon ui-icon-close" onclick="deleteXcatMonRow(this)"></span>');
for ( var i = 0; i < header.length - 2; i++)
row.push('');
// Add delete button to row
row.push('<span class="ui-icon ui-icon-close" onclick="deleteXcatMonRow(this)"></span>');
for ( var i = 0; i < header.length - 2; i++)
row.push('');
// Add checkbox
row.push('<input type="checkbox" name="' + row[2] + '" title="Checking this checkbox will add/remove the app from the configured apps value"/>');
// Get the datatable of the table
var dTable = $('#' + xcatMonTableId).dataTable();
// Add the new row to the datatable
dTable.fnAddData(row);
// Add checkbox
row.push('<input type="checkbox" name="' + row[2] + '" title="Checking this checkbox will add/remove the app from the configured apps value"/>');
// Get the datatable of the table
var dTable = $('#' + xcatMonTableId).dataTable();
// Add the new row to the datatable
dTable.fnAddData(row);
// make the datatable editable
$(":checkbox[title]").tooltip();
$('#' + xcatMonTableId + ' td:not(td:nth-child(1),td:last-child)').editable(function(value, settings) {
var colPos = this.cellIndex;
var rowPos = dTable
.fnGetPosition(this.parentNode);
dTable.fnUpdate(value, rowPos,
colPos);
return (value);
}, {
onblur : 'submit',
type : 'textarea',
placeholder : ' ',
height : '30px'
});
});
// make the datatable editable
$(":checkbox[title]").tooltip();
$('#' + xcatMonTableId + ' td:not(td:nth-child(1),td:last-child)').editable(function(value, settings) {
var colPos = this.cellIndex;
var rowPos = dTable
.fnGetPosition(this.parentNode);
dTable.fnUpdate(value, rowPos,
colPos);
return (value);
}, {
onblur : 'submit',
type : 'textarea',
placeholder : ' ',
height : '30px'
});
});
// Create apply button to store the contents of the table to the monsetting table
var applyLnk = $('<a>Apply</a>');
applyLnk.bind('click', function(event) {
// Get the datatable
var dTable = $('#' + xcatMonTableId).dataTable();
// Get datatable rows
var dRows = dTable.fnGetNodes();
var count = 0;
// Create a new container for the apps value
var appValue = '';
var tableName = 'monsetting';
var closeBtn = createButton('close');
// Create apply button to store the contents of the table to the monsetting table
var applyLnk = $('<a>Apply</a>');
applyLnk.bind('click', function(event) {
// Get the datatable
var dTable = $('#' + xcatMonTableId).dataTable();
// Get datatable rows
var dRows = dTable.fnGetNodes();
var count = 0;
// Create a new container for the apps value
var appValue = '';
var tableName = 'monsetting';
var closeBtn = createButton('close');
// Get the row contents
for ( var i = 0; i < dRows.length; i++) {
if (dRows[i]) {
// Get the row columns
var cols = dRows[i].childNodes;
// Create a container for the new columns
var vals = new Array();
// Get the row contents
for ( var i = 0; i < dRows.length; i++) {
if (dRows[i]) {
// Get the row columns
var cols = dRows[i].childNodes;
// Create a container for the new columns
var vals = new Array();
for ( var j = 1; j < cols.length - 1; j++) {
var val = cols.item(j).firstChild.nodeValue;
if (val == ' ')
vals[j - 1] = '';
else
vals[j - 1] = val;
}
for ( var j = 1; j < cols.length - 1; j++) {
var val = cols.item(j).firstChild.nodeValue;
if (val == ' ')
vals[j - 1] = '';
else
vals[j - 1] = val;
}
var vals_orig = new Array();
// Copy data from vals to vals_orig
for ( var p = 0; p < 2; p++) {
var val = vals[p];
vals_orig[p] = val;
}
var vals_orig = new Array();
// Copy data from vals to vals_orig
for ( var p = 0; p < 2; p++) {
var val = vals[p];
vals_orig[p] = val;
}
vals.push('');
vals.push('');
vals.unshift('xcatmon');
// Stored new column to newCont
newCont[i + 1] = vals;
vals.push('');
vals.push('');
vals.unshift('xcatmon');
// Stored new column to newCont
newCont[i + 1] = vals;
if (cols.item(cols.length - 1).firstChild.checked) {
vals_orig.push('<input type="checkbox" name="' + vals_orig[0] + '" title="Checking this checkbox will add/remove the app from the configured apps value" checked=true/>');
} else {
vals_orig.push('<input type="checkbox" name="' + vals_orig[0] + '" title="Checking this checkbox will add/remove the app from the configured apps value"/>');
}
if (cols.item(cols.length - 1).firstChild.checked) {
vals_orig.push('<input type="checkbox" name="' + vals_orig[0] + '" title="Checking this checkbox will add/remove the app from the configured apps value" checked=true/>');
} else {
vals_orig.push('<input type="checkbox" name="' + vals_orig[0] + '" title="Checking this checkbox will add/remove the app from the configured apps value"/>');
}
// Add delete button to row
vals_orig.unshift('<span class="ui-icon ui-icon-close" onclick="deleteXcatMonRow(this)"></span>');
// Add row to origCont
origCont[i + 1] = vals_orig;
count = i + 1;
// Add delete button to row
vals_orig.unshift('<span class="ui-icon ui-icon-close" onclick="deleteXcatMonRow(this)"></span>');
// Add row to origCont
origCont[i + 1] = vals_orig;
count = i + 1;
// Check checkbox for every row when merging the app name with the apps values
if (cols.item(cols.length - 1).firstChild.checked)
appValue = appValue.concat(cols.item(2).firstChild.nodeValue + ",");
}
}
// Check checkbox for every row when merging the app name with the apps values
if (cols.item(cols.length - 1).firstChild.checked)
appValue = appValue.concat(cols.item(2).firstChild.nodeValue + ",");
}
}
count++;
// Delete the last comma of the apps value
appValue = appValue.substring(0, (appValue.length - 1));
apps[2] = appValue;
count++;
// Delete the last comma of the apps value
appValue = appValue.substring(0, (appValue.length - 1));
apps[2] = appValue;
newCont[count++] = apps;
newCont[count++] = ping;
newCont[count++] = apps;
newCont[count++] = ping;
// Add to other monitor settings
for ( var j = 0; j < otherCont.length; j++) {
newCont[count++] = otherCont[j];
}
// Add to other monitor settings
for ( var j = 0; j < otherCont.length; j++) {
newCont[count++] = otherCont[j];
}
// Create save dialog
var dialogSave = $('<div id="saveDialog" align="center">Saving configuration</div>');
dialogSave.append(createLoader());
$('#xcatmon').append(dialogSave);
$("#saveDialog").dialog({
modal : true
});
$('.ui-dialog-titlebar-close').hide();
$.ajax({
type : 'POST',
url : 'lib/tabRestore.php',
dataType : 'json',
data : {
table : tableName,
cont : newCont
},
success : function(data) {
// empty the dialog.add the close button
$("#saveDialog").empty().append('<p>Configuration saved!</p>');
$("#saveDialog").append(closeBtn);
}
});
// Create save dialog
var dialogSave = $('<div id="saveDialog" align="center">Saving configuration</div>');
dialogSave.append(createLoader());
$('#xcatmon').append(dialogSave);
$("#saveDialog").dialog({
modal : true
});
$('.ui-dialog-titlebar-close').hide();
$.ajax({
type : 'POST',
url : 'lib/tabRestore.php',
dataType : 'json',
data : {
table : tableName,
cont : newCont
},
success : function(data) {
// empty the dialog.add the close button
$("#saveDialog").empty().append('<p>Configuration saved!</p>');
$("#saveDialog").append(closeBtn);
}
});
// Close button
closeBtn.bind('click', function(event) {
$("#saveDialog").dialog("destroy");
$("#saveDialog").remove();
});
// Close button
closeBtn.bind('click', function(event) {
$("#saveDialog").dialog("destroy");
$("#saveDialog").remove();
});
// Clear the newCont
newCont = null;
newCont = new Object();
newCont[0] = rsp[0].split(",");
});
// Clear the newCont
newCont = null;
newCont = new Object();
newCont[0] = rsp[0].split(",");
});
var cancelLnk = $('<a>Cancel</a>');
cancelLnk.bind('click', function(event) {
// Get the datatable for the page
var dTable = $('#' + xcatMonTableId).dataTable();
var cancelLnk = $('<a>Cancel</a>');
cancelLnk.bind('click', function(event) {
// Get the datatable for the page
var dTable = $('#' + xcatMonTableId).dataTable();
// Clear the datatable
dTable.fnClearTable();
// Clear the datatable
dTable.fnClearTable();
// Add the contents of origCont to the datatable
for ( var i = 1; i < origCont.length; i++)
dTable.fnAddData(origCont[i], true);
// Add the contents of origCont to the datatable
for ( var i = 1; i < origCont.length; i++)
dTable.fnAddData(origCont[i], true);
$(":checkbox[title]").tooltip();
$('#' + xcatMonTableId + ' td:not(td:nth-child(1),td:last-child)').editable(function(value, settings) {
var colPos = this.cellIndex;
var rowPos = dTable.fnGetPosition(this.parentNode);
dTable.fnUpdate(value, rowPos, colPos);
return (value);
}, {
onblur : 'submit',
type : 'textarea',
placeholder : ' ',
height : '30px'
});
});
$(":checkbox[title]").tooltip();
$('#' + xcatMonTableId + ' td:not(td:nth-child(1),td:last-child)').editable(function(value, settings) {
var colPos = this.cellIndex;
var rowPos = dTable.fnGetPosition(this.parentNode);
dTable.fnUpdate(value, rowPos, colPos);
return (value);
}, {
onblur : 'submit',
type : 'textarea',
placeholder : ' ',
height : '30px'
});
});
// Create actions menu
var actionsLnk = '<a>Actions</a>';
var actsMenu = createMenu([ addRowLnk, applyLnk, cancelLnk ]);
var actionsMenu = createMenu([ [ actionsLnk, actsMenu ] ]);
actionsMenu.superfish();
actionsMenu.css('display', 'inline-block');
actionBar.append(actionsMenu);
// Create actions menu
var actionsLnk = '<a>Actions</a>';
var actsMenu = createMenu([ addRowLnk, applyLnk, cancelLnk ]);
var actionsMenu = createMenu([ [ actionsLnk, actsMenu ] ]);
actionsMenu.superfish();
actionsMenu.css('display', 'inline-block');
actionBar.append(actionsMenu);
// Create a division to hold actions menu
var menuDiv = $('<div id="' + xcatMonTableId + '_menuDiv" class="menuDiv"></div>');
$('#' + xcatMonTableId + '_wrapper').prepend(menuDiv);
menuDiv.append(actionBar);
$('#' + xcatMonTableId + '_filter').appendTo(menuDiv);
// Create a division to hold actions menu
var menuDiv = $('<div id="' + xcatMonTableId + '_menuDiv" class="menuDiv"></div>');
$('#' + xcatMonTableId + '_wrapper').prepend(menuDiv);
menuDiv.append(actionBar);
$('#' + xcatMonTableId + '_filter').appendTo(menuDiv);
}
/**
* Delete a row from the table
*/
function deleteXcatMonRow(obj) {
var dTable = $('#' + xcatMonTableId).dataTable();
var rows = dTable.fnGetNodes();
var tgtRow = $(obj).parent().parent().get(0);
for ( var i in rows) {
if (rows[i] == tgtRow) {
dTable.fnDeleteRow(i, null, true);
break;
}
}
var dTable = $('#' + xcatMonTableId).dataTable();
var rows = dTable.fnGetNodes();
var tgtRow = $(obj).parent().parent().get(0);
for ( var i in rows) {
if (rows[i] == tgtRow) {
dTable.fnDeleteRow(i, null, true);
break;
}
}
}

View File

@ -1,39 +1,39 @@
var hardwareInfo = {
'7037-A50' : [ 'P5-185', 5 ],
'9115-505' : [ 'P5-505', 1 ],
'9110-510' : [ 'P5-510', 2 ],
'9110-51A' : [ 'P5-510', 2 ],
'9111-520' : [ 'P5-520', 4 ],
'913A-52A' : [ 'P5-52A', 4 ],
'9113-550' : [ 'P5-550', 4 ],
'9133-55A' : [ 'P5-55A', 4 ],
'9116-561' : [ 'P5-560Q', 4 ],
'9117-570' : [ 'P5-570', 4 ],
'9118-575' : [ 'P5-575', 42 ],
'9119-590' : [ 'P5-590', 42 ],
'9119-595' : [ 'P5-595', 42 ],
'7037-A50' : [ 'P5-185', 5 ],
'9115-505' : [ 'P5-505', 1 ],
'9110-510' : [ 'P5-510', 2 ],
'9110-51A' : [ 'P5-510', 2 ],
'9111-520' : [ 'P5-520', 4 ],
'913A-52A' : [ 'P5-52A', 4 ],
'9113-550' : [ 'P5-550', 4 ],
'9133-55A' : [ 'P5-55A', 4 ],
'9116-561' : [ 'P5-560Q', 4 ],
'9117-570' : [ 'P5-570', 4 ],
'9118-575' : [ 'P5-575', 42 ],
'9119-590' : [ 'P5-590', 42 ],
'9119-595' : [ 'P5-595', 42 ],
//P6
'8203-E4A' : [ 'P6-520', 4 ],
'9407-M15' : [ 'P6-520', 4 ],
'9408-M25' : [ 'P6-520', 4 ],
'8204-E8A' : [ 'P6-550', 4 ],
'9409-M50' : [ 'P6-550', 4 ],
'8234-EMA' : [ 'P6-560', 4 ],
'9117-MMA' : [ 'P6-570', 4 ],
'9125-F2A' : [ 'P6-575', 42 ],
'9119-FHA' : [ 'P6-595', 42 ],
// P6
'8203-E4A' : [ 'P6-520', 4 ],
'9407-M15' : [ 'P6-520', 4 ],
'9408-M25' : [ 'P6-520', 4 ],
'8204-E8A' : [ 'P6-550', 4 ],
'9409-M50' : [ 'P6-550', 4 ],
'8234-EMA' : [ 'P6-560', 4 ],
'9117-MMA' : [ 'P6-570', 4 ],
'9125-F2A' : [ 'P6-575', 42 ],
'9119-FHA' : [ 'P6-595', 42 ],
//P7
'8202-E4B' : [ 'P7-720', 4 ],
'8205-E6B' : [ 'P7-740', 4 ],
'8231-E2B' : [ 'P7-710/730', 2 ],
'8233-E8B' : [ 'P7-750', 4 ],
'8236-E8C' : [ 'P7-755', 4 ],
'9117-MMB' : [ 'P7-770', 4 ],
'9119-FHB' : [ 'P7-795', 4 ],
'9179-MHB' : [ 'P7-780', 42 ],
'8231-E2C' : [ 'P7 HE', 4 ],
'9125-F2C' : [ 'Power 775', 2],
'78AC-100' : [ 'Power 775', 2] //fsp
// P7
'8202-E4B' : [ 'P7-720', 4 ],
'8205-E6B' : [ 'P7-740', 4 ],
'8231-E2B' : [ 'P7-710/730', 2 ],
'8233-E8B' : [ 'P7-750', 4 ],
'8236-E8C' : [ 'P7-755', 4 ],
'9117-MMB' : [ 'P7-770', 4 ],
'9119-FHB' : [ 'P7-795', 4 ],
'9179-MHB' : [ 'P7-780', 42 ],
'8231-E2C' : [ 'P7 HE', 4 ],
'9125-F2C' : [ 'Power 775', 2],
'78AC-100' : [ 'Power 775', 2] // FSP
};

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -6,12 +6,10 @@ var provisionTabs; // Provision tabs
/**
* Set the provision tab
*
* @param obj
* Tab object
* @return Nothing
* @param obj Tab object
*/
function setProvisionTab(obj) {
provisionTabs = obj;
provisionTabs = obj;
}
/**
@ -21,157 +19,155 @@ function setProvisionTab(obj) {
* @return Tab object
*/
function getProvisionTab() {
return provisionTabs;
return provisionTabs;
}
/**
* Load provision page
*
* @return Nothing
*/
function loadProvisionPage() {
// If the page is loaded
if ($('#content').children().length) {
// Do not load again
return;
}
// If the page is loaded
if ($('#content').children().length) {
// Do not load again
return;
}
// Get OS image names
if (!$.cookie('imagenames')){
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'tabdump',
tgt : '',
args : 'osimage',
msg : ''
},
// Get OS image names
if (!$.cookie('imagenames')){
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'tabdump',
tgt : '',
args : 'osimage',
msg : ''
},
success : setOSImageCookies
});
}
success : setOSImageCookies
});
}
// Get groups
if (!$.cookie('groups')){
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'extnoderange',
tgt : '/.*',
args : 'subgroups',
msg : ''
},
// Get groups
if (!$.cookie('groups')){
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'extnoderange',
tgt : '/.*',
args : 'subgroups',
msg : ''
},
success : setGroupsCookies
});
}
// Create info bar
var infoBar = createInfoBar('Select a platform to provision or re-provision a node on, then click Ok.');
// Create provision page
var provPg = $('<div class="form"></div>');
provPg.append(infoBar);
success : setGroupsCookies
});
}
// Create info bar
var infoBar = createInfoBar('Select a platform to provision or re-provision a node on, then click Ok.');
// Create provision page
var provPg = $('<div class="form"></div>');
provPg.append(infoBar);
// Create provision tab
var tab = new Tab('provisionPageTabs');
setProvisionTab(tab);
tab.init();
$('#content').append(tab.object());
// Create provision tab
var tab = new Tab('provisionPageTabs');
setProvisionTab(tab);
tab.init();
$('#content').append(tab.object());
// Create radio buttons for platforms
var hwList = $('<ol>Platforms available:</ol>');
var esx = $('<li><input type="radio" name="hw" value="esx" checked/>ESX</li>');
var kvm = $('<li><input type="radio" name="hw" value="kvm"/>KVM</li>');
var zvm = $('<li><input type="radio" name="hw" value="zvm"/>z\/VM</li>');
var ipmi = $('<li><input type="radio" name="hw" value="ipmi"/>iDataPlex</li>');
var blade = $('<li><input type="radio" name="hw" value="blade"/>BladeCenter</li>');
var hmc = $('<li><input type="radio" name="hw" value="hmc"/>System p</li>');
hwList.append(esx);
hwList.append(kvm);
hwList.append(zvm);
hwList.append(blade);
hwList.append(ipmi);
hwList.append(hmc);
provPg.append(hwList);
// Create radio buttons for platforms
var hwList = $('<ol>Platforms available:</ol>');
var esx = $('<li><input type="radio" name="hw" value="esx" checked/>ESX</li>');
var kvm = $('<li><input type="radio" name="hw" value="kvm"/>KVM</li>');
var zvm = $('<li><input type="radio" name="hw" value="zvm"/>z\/VM</li>');
var ipmi = $('<li><input type="radio" name="hw" value="ipmi"/>iDataPlex</li>');
var blade = $('<li><input type="radio" name="hw" value="blade"/>BladeCenter</li>');
var hmc = $('<li><input type="radio" name="hw" value="hmc"/>System p</li>');
hwList.append(esx);
hwList.append(kvm);
hwList.append(zvm);
hwList.append(blade);
hwList.append(ipmi);
hwList.append(hmc);
provPg.append(hwList);
/**
* Ok
*/
var okBtn = createButton('Ok');
okBtn.bind('click', function(event) {
// Get hardware that was selected
var hw = $(this).parent().find('input[name="hw"]:checked').val();
var inst = 0;
var newTabId = hw + 'ProvisionTab' + inst;
while ($('#' + newTabId).length) {
// If one already exists, generate another one
inst = inst + 1;
newTabId = hw + 'ProvisionTab' + inst;
}
/**
* Ok
*/
var okBtn = createButton('Ok');
okBtn.bind('click', function(event) {
// Get hardware that was selected
var hw = $(this).parent().find('input[name="hw"]:checked').val();
var inst = 0;
var newTabId = hw + 'ProvisionTab' + inst;
while ($('#' + newTabId).length) {
// If one already exists, generate another one
inst = inst + 1;
newTabId = hw + 'ProvisionTab' + inst;
}
// Create an instance of the plugin
var title = '';
var title = '';
var plugin;
switch (hw) {
case "kvm":
plugin = new kvmPlugin();
title = 'KVM';
break;
case "esx":
plugin = new esxPlugin();
title = 'ESX';
break;
case "blade":
plugin = new bladePlugin();
title = 'BladeCenter';
break;
case "hmc":
plugin = new hmcPlugin();
title = 'System p';
break;
case "ipmi":
plugin = new ipmiPlugin();
title = 'iDataPlex';
break;
case "zvm":
plugin = new zvmPlugin();
title = 'z/VM';
break;
case "kvm":
plugin = new kvmPlugin();
title = 'KVM';
break;
case "esx":
plugin = new esxPlugin();
title = 'ESX';
break;
case "blade":
plugin = new bladePlugin();
title = 'BladeCenter';
break;
case "hmc":
plugin = new hmcPlugin();
title = 'System p';
break;
case "ipmi":
plugin = new ipmiPlugin();
title = 'iDataPlex';
break;
case "zvm":
plugin = new zvmPlugin();
title = 'z/VM';
break;
}
// Select tab
tab.add(newTabId, title, '', true);
tab.select(newTabId);
plugin.loadProvisionPage(newTabId);
});
provPg.append(okBtn);
});
provPg.append(okBtn);
// Add provision tab
tab.add('provisionTab', 'Provision', provPg, false);
// Add image tab
tab.add('imagesTab', 'Images', '', false);
// Load tabs onselect
$('#provisionPageTabs').bind('tabsselect', function(event, ui){
// Load image page
if (!$('#imagesTab').children().length && ui.index == 1) {
$('#imagesTab').append($('<center></center>').append(createLoader('')));
loadImagesPage();
}
});
// Open the quick provision tab
if (window.location.search) {
tab.add('quickProvisionTab', 'Quick Provision', '', true);
tab.select('quickProvisionTab');
var provForm = $('<div class="form"></div>');
$('#quickProvisionTab').append(provForm);
appendProvisionSection('quick', provForm);
}
// Add provision tab
tab.add('provisionTab', 'Provision', provPg, false);
// Add image tab
tab.add('imagesTab', 'Images', '', false);
// Load tabs onselect
$('#provisionPageTabs').bind('tabsselect', function(event, ui){
// Load image page
if (!$('#imagesTab').children().length && ui.index == 1) {
$('#imagesTab').append($('<center></center>').append(createLoader('')));
loadImagesPage();
}
});
// Open the quick provision tab
if (window.location.search) {
tab.add('quickProvisionTab', 'Quick Provision', '', true);
tab.select('quickProvisionTab');
var provForm = $('<div class="form"></div>');
$('#quickProvisionTab').append(provForm);
appendProvisionSection('quick', provForm);
}
}

View File

@ -1,288 +1,288 @@
rconsTerm = function(nodeName, height, width) {
var sid = nodeName;
var keyBuf = [];
var receivingFlag = false;
var sendTimeout = "";
var errorTimeout = "";
var queryStable = 's=' + sid + '&w=' + height + '&h=' + width + '&c=1&k=';
var maxDelay = 200;
var firstFlag = true;
var sid = nodeName;
var keyBuf = [];
var receivingFlag = false;
var sendTimeout = "";
var errorTimeout = "";
var queryStable = 's=' + sid + '&w=' + height + '&h=' + width + '&c=1&k=';
var maxDelay = 200;
var firstFlag = true;
var workingStatus = "";
var termArea = "";
var errorArea = "";
var workingStatus = "";
var termArea = "";
var errorArea = "";
var ie = 0;
if (window.ActiveXObject) {
ie = 1;
}
var ie = 0;
if (window.ActiveXObject) {
ie = 1;
}
rconsInit();
// init
function rconsInit() {
// create status, configure the css
workingStatus = $('<span>.</span>');
workingStatus.attr('class', 'off');
rconsInit();
// init
function rconsInit() {
// Create status, configure the css
workingStatus = $('<span>.</span>');
workingStatus.attr('class', 'off');
// create the disconnect button
var disconnectButton = $('<a class="off">Disconnect</a>');
disconnectButton.bind('click', function() {
window.close();
});
// Create the disconnect button
var disconnectButton = $('<a class="off">Disconnect</a>');
disconnectButton.bind('click', function() {
window.close();
});
// create the control panel, add to the rcons div
var controlPanel = $('<pre class="stat"></pre>');
$('#term').append(controlPanel);
// Create the control panel, add to the rcons div
var controlPanel = $('<pre class="stat"></pre>');
$('#term').append(controlPanel);
// create the error erea
errorArea = $('<span></span>');
// Create the error erea
errorArea = $('<span></span>');
// add all item to controlPanel
controlPanel.append(workingStatus);
controlPanel.append(disconnectButton);
controlPanel.append(errorArea);
// Add all item to control panel
controlPanel.append(workingStatus);
controlPanel.append(disconnectButton);
controlPanel.append(errorArea);
// create the termArea
termArea = $('<div></div>');
$('#term').append(termArea);
// Create the termArea
termArea = $('<div></div>');
$('#term').append(termArea);
// bind keypress event
document.onkeypress = rconsKeypress;
document.onkeydown = rconsKeydown;
window.onbeforeunload = function() {
rconsDisconnect();
alert("Closing remote console");
};
// Bind keypress event
document.onkeypress = rconsKeypress;
document.onkeydown = rconsKeydown;
window.onbeforeunload = function() {
rconsDisconnect();
alert("Closing remote console");
};
rconsSend();
}
rconsSend();
}
// close the connection
function rconsDisconnect() {
window.clearTimeout(sendTimeout);
window.clearTimeout(errorTimeout);
// Close the connection
function rconsDisconnect() {
window.clearTimeout(sendTimeout);
window.clearTimeout(errorTimeout);
$.ajax({
type : "POST",
url : "lib/rcons.php",
data : queryStable + '&q=1',
dataType : 'json'
});
}
$.ajax({
type : "POST",
url : "lib/rcons.php",
data : queryStable + '&q=1',
dataType : 'json'
});
}
// translate the key press
function rconsKeypress(event) {
if (!event)
var event = window.event;
var kc = "";
var k = "";
if (event.keyCode)
kc = event.keyCode;
if (event.which)
kc = event.which;
if (event.altKey) {
if (kc >= 65 && kc <= 90)
kc += 32;
if (kc >= 97 && kc <= 122) {
k = String.fromCharCode(27) + String.fromCharCode(kc);
}
} else if (event.ctrlKey) {
if (kc >= 65 && kc <= 90)
k = String.fromCharCode(kc - 64); // Ctrl-A..Z
else if (kc >= 97 && kc <= 122)
k = String.fromCharCode(kc - 96); // Ctrl-A..Z
else if (kc == 54)
k = String.fromCharCode(30); // Ctrl-^
else if (kc == 109)
k = String.fromCharCode(31); // Ctrl-_
else if (kc == 219)
k = String.fromCharCode(27); // Ctrl-[
else if (kc == 220)
k = String.fromCharCode(28); // Ctrl-\
else if (kc == 221)
k = String.fromCharCode(29); // Ctrl-]
else if (kc == 219)
k = String.fromCharCode(29); // Ctrl-]
else if (kc == 219)
k = String.fromCharCode(0); // Ctrl-@
} else if (event.which == 0) {
if (kc == 9)
k = String.fromCharCode(9); // Tab
else if (kc == 8)
k = String.fromCharCode(127); // Backspace
else if (kc == 27)
k = String.fromCharCode(27); // Escape
else {
if (kc == 33)
k = "[5~"; // PgUp
else if (kc == 34)
k = "[6~"; // PgDn
else if (kc == 35)
k = "[4~"; // End
else if (kc == 36)
k = "[1~"; // Home
else if (kc == 37)
k = "[D"; // Left
else if (kc == 38)
k = "[A"; // Up
else if (kc == 39)
k = "[C"; // Right
else if (kc == 40)
k = "[B"; // Down
else if (kc == 45)
k = "[2~"; // Ins
else if (kc == 46)
k = "[3~"; // Del
else if (kc == 112)
k = "[[A"; // F1
else if (kc == 113)
k = "[[B"; // F2
else if (kc == 114)
k = "[[C"; // F3
else if (kc == 115)
k = "[[D"; // F4
else if (kc == 116)
k = "[[E"; // F5
else if (kc == 117)
k = "[17~"; // F6
else if (kc == 118)
k = "[18~"; // F7
else if (kc == 119)
k = "[19~"; // F8
else if (kc == 120)
k = "[20~"; // F9
else if (kc == 121)
k = "[21~"; // F10
else if (kc == 122)
k = "[23~"; // F11
else if (kc == 123)
k = "[24~"; // F12
if (k.length) {
k = String.fromCharCode(27) + k;
}
}
} else {
if (kc == 8)
k = String.fromCharCode(127); // Backspace
else
k = String.fromCharCode(kc);
}
if (k.length) {
if (k == "+") {
rconsQueue("%2B");
} else {
rconsQueue(escape(k));
}
}
event.cancelBubble = true;
if (event.stopPropagation)
event.stopPropagation();
if (event.preventDefault)
event.preventDefault();
return false;
}
// Translate the key press
function rconsKeypress(event) {
if (!event)
var event = window.event;
var kc = "";
var k = "";
if (event.keyCode)
kc = event.keyCode;
if (event.which)
kc = event.which;
if (event.altKey) {
if (kc >= 65 && kc <= 90)
kc += 32;
if (kc >= 97 && kc <= 122) {
k = String.fromCharCode(27) + String.fromCharCode(kc);
}
} else if (event.ctrlKey) {
if (kc >= 65 && kc <= 90)
k = String.fromCharCode(kc - 64); // Ctrl-A..Z
else if (kc >= 97 && kc <= 122)
k = String.fromCharCode(kc - 96); // Ctrl-A..Z
else if (kc == 54)
k = String.fromCharCode(30); // Ctrl-^
else if (kc == 109)
k = String.fromCharCode(31); // Ctrl-_
else if (kc == 219)
k = String.fromCharCode(27); // Ctrl-[
else if (kc == 220)
k = String.fromCharCode(28); // Ctrl-\
else if (kc == 221)
k = String.fromCharCode(29); // Ctrl-]
else if (kc == 219)
k = String.fromCharCode(29); // Ctrl-]
else if (kc == 219)
k = String.fromCharCode(0); // Ctrl-@
} else if (event.which == 0) {
if (kc == 9)
k = String.fromCharCode(9); // Tab
else if (kc == 8)
k = String.fromCharCode(127); // Backspace
else if (kc == 27)
k = String.fromCharCode(27); // Escape
else {
if (kc == 33)
k = "[5~"; // PgUp
else if (kc == 34)
k = "[6~"; // PgDn
else if (kc == 35)
k = "[4~"; // End
else if (kc == 36)
k = "[1~"; // Home
else if (kc == 37)
k = "[D"; // Left
else if (kc == 38)
k = "[A"; // Up
else if (kc == 39)
k = "[C"; // Right
else if (kc == 40)
k = "[B"; // Down
else if (kc == 45)
k = "[2~"; // Ins
else if (kc == 46)
k = "[3~"; // Del
else if (kc == 112)
k = "[[A"; // F1
else if (kc == 113)
k = "[[B"; // F2
else if (kc == 114)
k = "[[C"; // F3
else if (kc == 115)
k = "[[D"; // F4
else if (kc == 116)
k = "[[E"; // F5
else if (kc == 117)
k = "[17~"; // F6
else if (kc == 118)
k = "[18~"; // F7
else if (kc == 119)
k = "[19~"; // F8
else if (kc == 120)
k = "[20~"; // F9
else if (kc == 121)
k = "[21~"; // F10
else if (kc == 122)
k = "[23~"; // F11
else if (kc == 123)
k = "[24~"; // F12
if (k.length) {
k = String.fromCharCode(27) + k;
}
}
} else {
if (kc == 8)
k = String.fromCharCode(127); // Backspace
else
k = String.fromCharCode(kc);
}
if (k.length) {
if (k == "+") {
rconsQueue("%2B");
} else {
rconsQueue(escape(k));
}
}
event.cancelBubble = true;
if (event.stopPropagation)
event.stopPropagation();
if (event.preventDefault)
event.preventDefault();
return false;
}
// translate the key press, same with rconsKeypress
function rconsKeydown(event) {
if (!event)
var event = window.event;
if (ie) {
o = {
9 : 1,
8 : 1,
27 : 1,
33 : 1,
34 : 1,
35 : 1,
36 : 1,
37 : 1,
38 : 1,
39 : 1,
40 : 1,
45 : 1,
46 : 1,
112 : 1,
113 : 1,
114 : 1,
115 : 1,
116 : 1,
117 : 1,
118 : 1,
119 : 1,
120 : 1,
121 : 1,
122 : 1,
123 : 1
};
if (o[event.keyCode] || event.ctrlKey || event.altKey) {
event.which = 0;
return keypress(event);
}
}
}
// Translate the key press, same with rconsKeypress
function rconsKeydown(event) {
if (!event)
var event = window.event;
if (ie) {
o = {
9 : 1,
8 : 1,
27 : 1,
33 : 1,
34 : 1,
35 : 1,
36 : 1,
37 : 1,
38 : 1,
39 : 1,
40 : 1,
45 : 1,
46 : 1,
112 : 1,
113 : 1,
114 : 1,
115 : 1,
116 : 1,
117 : 1,
118 : 1,
119 : 1,
120 : 1,
121 : 1,
122 : 1,
123 : 1
};
if (o[event.keyCode] || event.ctrlKey || event.altKey) {
event.which = 0;
return keypress(event);
}
}
}
// send the command and request to server
function rconsSend() {
var keyPressList = '';
var requireString = '';
if (receivingFlag) {
return;
}
// Send the command and request to server
function rconsSend() {
var keyPressList = '';
var requireString = '';
if (receivingFlag) {
return;
}
receivingFlag = true;
workingStatus.attr('class', 'on');
receivingFlag = true;
workingStatus.attr('class', 'on');
while (keyBuf.length > 0) {
keyPressList += keyBuf.pop();
}
while (keyBuf.length > 0) {
keyPressList += keyBuf.pop();
}
if (firstFlag) {
requireString = queryStable + keyPressList + '&f=1';
firstFlag = false;
} else {
requireString = queryStable + keyPressList;
}
if (firstFlag) {
requireString = queryStable + keyPressList + '&f=1';
firstFlag = false;
} else {
requireString = queryStable + keyPressList;
}
$.ajax({
type : "POST",
url : "lib/rcons.php",
data : requireString,
dataType : 'json',
success : function(data) {
rconsUpdate(data);
}
});
$.ajax({
type : "POST",
url : "lib/rcons.php",
data : requireString,
dataType : 'json',
success : function(data) {
rconsUpdate(data);
}
});
errorTimeout = window.setTimeout(rconsSendError, 15000);
errorTimeout = window.setTimeout(rconsSendError, 15000);
}
}
// when receive the response, update the term area
function rconsUpdate(data) {
window.clearTimeout(errorTimeout);
errorArea.empty();
if (data.term) {
termArea.empty().append(data.term);
maxDelay = 200;
} else {
maxDelay = 2000;
}
// When response received, update the term area
function rconsUpdate(data) {
window.clearTimeout(errorTimeout);
errorArea.empty();
if (data.term) {
termArea.empty().append(data.term);
maxDelay = 200;
} else {
maxDelay = 2000;
}
receivingFlag = false;
workingStatus.attr('class', 'off');
sendTimeout = window.setTimeout(rconsSend, maxDelay);
}
receivingFlag = false;
workingStatus.attr('class', 'off');
sendTimeout = window.setTimeout(rconsSend, maxDelay);
}
function rconsSendError() {
workingStatus.attr('class', 'off');
errorArea.empty().append('Send require error.');
}
function rconsSendError() {
workingStatus.attr('class', 'off');
errorArea.empty().append('Send require error.');
}
function rconsQueue(kc) {
keyBuf.unshift(kc);
if (false == receivingFlag) {
window.clearTimeout(sendTimeout);
sendTimeout = window.setTimeout(rconsSend, 1);
}
}
function rconsQueue(kc) {
keyBuf.unshift(kc);
if (false == receivingFlag) {
window.clearTimeout(sendTimeout);
sendTimeout = window.setTimeout(rconsSend, 1);
}
}
};

File diff suppressed because it is too large Load Diff

View File

@ -6,358 +6,340 @@
* @return String of nodes shown
*/
function getNodesShown(tableId) {
// String of nodes shown
var shownNodes = '';
// Get rows of shown nodes
var nodes = $('#' + tableId + ' tbody tr');
// Go through each row
var cols;
for (var i = 0; i < nodes.length; i++) {
// Get second column containing node name
cols = nodes.eq(i).find('td');
shownNodes += cols.eq(1).text() + ',';
}
// Remove last comma
shownNodes = shownNodes.substring(0, shownNodes.length-1);
return shownNodes;
// String of nodes shown
var shownNodes = '';
// Get rows of shown nodes
var nodes = $('#' + tableId + ' tbody tr');
// Go through each row
var cols;
for (var i = 0; i < nodes.length; i++) {
// Get second column containing node name
cols = nodes.eq(i).find('td');
shownNodes += cols.eq(1).text() + ',';
}
// Remove last comma
shownNodes = shownNodes.substring(0, shownNodes.length-1);
return shownNodes;
}
/**
* Find the row index containing a column with a given string
*
* @param str
* String to search for
* @param table
* Table to check
* @param col
* Column to find string under
* @param str String to search for
* @param table Table to check
* @param col Column to find string under
* @return The row index containing the search string
*/
function findRow(str, table, col){
var dTable, rows;
// Get datatable
dTable = $(table).dataTable();
rows = dTable.fnGetData();
// Loop through each row
for (var i in rows) {
// If the column contains the search string
if (rows[i][col].indexOf(str) > -1) {
return i;
}
}
return -1;
var dTable, rows;
// Get datatable
dTable = $(table).dataTable();
rows = dTable.fnGetData();
// Loop through each row
for (var i in rows) {
// If the column contains the search string
if (rows[i][col].indexOf(str) > -1) {
return i;
}
}
return -1;
}
/**
* Select all checkboxes in the datatable
*
* @param event
* Event on element
* @param obj
* Object triggering event
* @return Nothing
* @param event Event on element
* @param obj Object triggering event
*/
function selectAll(event, obj) {
var status = obj.attr('checked');
var checkboxes = obj.parents('.dataTables_scroll').find('.dataTables_scrollBody input:checkbox');
if (status) {
checkboxes.attr('checked', true);
} else {
checkboxes.attr('checked', false);
}
event.stopPropagation();
var status = obj.attr('checked');
var checkboxes = obj.parents('.dataTables_scroll').find('.dataTables_scrollBody input:checkbox');
if (status) {
checkboxes.attr('checked', true);
} else {
checkboxes.attr('checked', false);
}
event.stopPropagation();
}
/**
* Get node attributes from HTTP request data
*
* @param propNames
* Hash table of property names
* @param keys
* Property keys
* @param data
* Data from HTTP request
* @param propNames Hash table of property names
* @param keys Property keys
* @param data Data from HTTP request
* @return Hash table of property values
*/
function getAttrs(keys, propNames, data) {
// Create hash table for property values
var attrs = new Object();
// Create hash table for property values
var attrs = new Object();
// Go through inventory and separate each property out
var curKey; // Current property key
var addLine; // Add a line to the current property?
for ( var i = 1; i < data.length; i++) {
addLine = true;
// Go through inventory and separate each property out
var curKey; // Current property key
var addLine; // Add a line to the current property?
for ( var i = 1; i < data.length; i++) {
addLine = true;
// Loop through property keys
// Does this line contains one of the properties?
for ( var j = 0; j < keys.length; j++) {
// Find property name
if (data[i].indexOf(propNames[keys[j]]) > -1) {
attrs[keys[j]] = new Array();
// Loop through property keys
// Does this line contains one of the properties?
for ( var j = 0; j < keys.length; j++) {
// Find property name
if (data[i].indexOf(propNames[keys[j]]) > -1) {
attrs[keys[j]] = new Array();
// Get rid of property name in the line
data[i] = data[i].replace(propNames[keys[j]], '');
// Trim the line
data[i] = jQuery.trim(data[i]);
// Get rid of property name in the line
data[i] = data[i].replace(propNames[keys[j]], '');
// Trim the line
data[i] = jQuery.trim(data[i]);
// Do not insert empty line
if (data[i].length > 0) {
attrs[keys[j]].push(data[i]);
}
// Do not insert empty line
if (data[i].length > 0) {
attrs[keys[j]].push(data[i]);
}
curKey = keys[j];
addLine = false; // This line belongs to a property
}
}
curKey = keys[j];
addLine = false; // This line belongs to a property
}
}
// Line does not contain a property
// Must belong to previous property
if (addLine && data[i].length > 1) {
data[i] = jQuery.trim(data[i]);
attrs[curKey].push(data[i]);
}
}
// Line does not contain a property
// Must belong to previous property
if (addLine && data[i].length > 1) {
data[i] = jQuery.trim(data[i]);
attrs[curKey].push(data[i]);
}
}
return attrs;
return attrs;
}
/**
* Create a tool tip for comments
*
* @param comment
* Comments to be placed in a tool tip
* @param comment Comments to be placed in a tool tip
* @return Tool tip
*/
function createCommentsToolTip(comment) {
// Create tooltip container
var toolTip = $('<div class="tooltip"></div>');
// Create textarea to hold comment
var txtArea = $('<textarea>' + comment + '</textarea>').css({
'font-size': '10px',
'height': '50px',
'width': '200px',
'background-color': '#000',
'color': '#fff',
'border': '0px',
'display': 'block'
});
// Create links to save and cancel changes
var lnkStyle = {
'color': '#58ACFA',
'font-size': '10px',
'display': 'inline-block',
'padding': '5px',
'float': 'right'
};
var saveLnk = $('<a>Save</a>').css(lnkStyle).hide();
var cancelLnk = $('<a>Cancel</a>').css(lnkStyle).hide();
var infoSpan = $('<span>Click to edit</span>').css(lnkStyle);
// Save changes onclick
saveLnk.bind('click', function(){
// Get node and comment
var node = $(this).parent().parent().find('img').attr('id').replace('Tip', '');
var comments = $(this).parent().find('textarea').val();
// Save comment
$.ajax( {
url : 'lib/srv_cmd.php',
dataType : 'json',
data : {
cmd : 'chdef',
tgt : '',
args : '-t;node;-o;' + node + ';usercomment=' + comments,
msg : 'out=manageTab;tgt=' + node
},
success: showChdefOutput
});
// Hide cancel and save links
$(this).hide();
cancelLnk.hide();
});
// Cancel changes onclick
cancelLnk.bind('click', function(){
// Get original comment and put it back
var orignComments = $(this).parent().find('textarea').text();
$(this).parent().find('textarea').val(orignComments);
// Hide cancel and save links
$(this).hide();
saveLnk.hide();
infoSpan.show();
});
// Show save link when comment is edited
txtArea.bind('click', function(){
saveLnk.show();
cancelLnk.show();
infoSpan.hide();
});
toolTip.append(txtArea);
toolTip.append(cancelLnk);
toolTip.append(saveLnk);
toolTip.append(infoSpan);
return toolTip;
// Create tooltip container
var toolTip = $('<div class="tooltip"></div>');
// Create textarea to hold comment
var txtArea = $('<textarea>' + comment + '</textarea>').css({
'font-size': '10px',
'height': '50px',
'width': '200px',
'background-color': '#000',
'color': '#fff',
'border': '0px',
'display': 'block'
});
// Create links to save and cancel changes
var lnkStyle = {
'color': '#58ACFA',
'font-size': '10px',
'display': 'inline-block',
'padding': '5px',
'float': 'right'
};
var saveLnk = $('<a>Save</a>').css(lnkStyle).hide();
var cancelLnk = $('<a>Cancel</a>').css(lnkStyle).hide();
var infoSpan = $('<span>Click to edit</span>').css(lnkStyle);
// Save changes onclick
saveLnk.bind('click', function(){
// Get node and comment
var node = $(this).parent().parent().find('img').attr('id').replace('Tip', '');
var comments = $(this).parent().find('textarea').val();
// Save comment
$.ajax( {
url : 'lib/srv_cmd.php',
dataType : 'json',
data : {
cmd : 'chdef',
tgt : '',
args : '-t;node;-o;' + node + ';usercomment=' + comments,
msg : 'out=manageTab;tgt=' + node
},
success: showChdefOutput
});
// Hide cancel and save links
$(this).hide();
cancelLnk.hide();
});
// Cancel changes onclick
cancelLnk.bind('click', function(){
// Get original comment and put it back
var orignComments = $(this).parent().find('textarea').text();
$(this).parent().find('textarea').val(orignComments);
// Hide cancel and save links
$(this).hide();
saveLnk.hide();
infoSpan.show();
});
// Show save link when comment is edited
txtArea.bind('click', function(){
saveLnk.show();
cancelLnk.show();
infoSpan.hide();
});
toolTip.append(txtArea);
toolTip.append(cancelLnk);
toolTip.append(saveLnk);
toolTip.append(infoSpan);
return toolTip;
}
/**
* Open a dialog and show given message
*
* @param type
* Type of dialog, i.e. warn or info
* @param msg
* Message to show
* @return Nothing
* @param type Type of dialog, i.e. warn or info
* @param msg Message to show
*/
function prompt(type, msg) {
var style = {
'display': 'inline-block',
'margin': '5px',
'vertical-align': 'middle'
};
msg.css({
'display': 'inline',
'margin': '5px',
'vertical-align': 'middle'
});
// Append icon
var icon;
var dialog = $('<div></div>');
if (type == "Warning") {
icon = $('<span class="ui-icon ui-icon-alert"></span>').css(style);
} else {
icon = $('<span class="ui-icon ui-icon-info"></span>').css(style);
}
dialog.append(icon);
dialog.append(msg);
// Open dialog
dialog.dialog({
title: type,
modal: true,
close: function(){
$(this).remove();
var style = {
'display': 'inline-block',
'margin': '5px',
'vertical-align': 'middle'
};
msg.css({
'display': 'inline',
'margin': '5px',
'vertical-align': 'middle'
});
// Append icon
var icon;
var dialog = $('<div></div>');
if (type == "Warning") {
icon = $('<span class="ui-icon ui-icon-alert"></span>').css(style);
} else {
icon = $('<span class="ui-icon ui-icon-info"></span>').css(style);
}
dialog.append(icon);
dialog.append(msg);
// Open dialog
dialog.dialog({
title: type,
modal: true,
close: function(){
$(this).remove();
},
width: 400,
buttons: {
"Ok": function(){
$(this).dialog("close");
}
}
});
width: 400,
buttons: {
"Ok": function(){
$(this).dialog("close");
}
}
});
}
/**
* Get nodes that are checked in a given datatable
*
* @param dTableId
* The datatable ID
* @param dTableId The datatable ID
* @return Nodes that were checked
*/
function getNodesChecked(dTableId) {
var tgts = '';
var tgts = '';
// Get nodes that were checked
var nodes = $('#' + dTableId + ' input[type=checkbox]:checked');
for (var i in nodes) {
var tgtNode = nodes.eq(i).attr('name');
if (tgtNode){
tgts += tgtNode;
// Add a comma at the end
if (i < nodes.length - 1) {
tgts += ',';
}
}
}
// Get nodes that were checked
var nodes = $('#' + dTableId + ' input[type=checkbox]:checked');
for (var i in nodes) {
var tgtNode = nodes.eq(i).attr('name');
if (tgtNode){
tgts += tgtNode;
// Add a comma at the end
if (i < nodes.length - 1) {
tgts += ',';
}
}
}
return tgts;
return tgts;
}
/**
* Show chdef output
*
* @param data
* Data returned from HTTP request
* @return Nothing
* @param data Data returned from HTTP request
*/
function showChdefOutput(data) {
// Get output
var out = data.rsp;
var args = data.msg.split(';');
var tabID = args[0].replace('out=', '');
var tgt = args[1].replace('tgt=', '');
// Find info bar on nodes tab, if any
var info = $('#' + tabID).find('.ui-state-highlight');
if (!info.length) {
// Create info bar if one does not exist
info = createInfoBar('');
$('#' + tabID).append(info);
}
// Go through output and append to paragraph
var prg = $('<p></p>');
for (var i in out) {
prg.append(tgt + ': ' + out[i] + '<br>');
}
info.append(prg);
// Get output
var out = data.rsp;
var args = data.msg.split(';');
var tabID = args[0].replace('out=', '');
var tgt = args[1].replace('tgt=', '');
// Find info bar on nodes tab, if any
var info = $('#' + tabID).find('.ui-state-highlight');
if (!info.length) {
// Create info bar if one does not exist
info = createInfoBar('');
$('#' + tabID).append(info);
}
// Go through output and append to paragraph
var prg = $('<p></p>');
for (var i in out) {
prg.append(tgt + ': ' + out[i] + '<br>');
}
info.append(prg);
}
/**
* Get an attribute of a given node
*
* @param node
* The node
* @param attrName
* The attribute
* @param node The node
* @param attrName The attribute
* @return The attribute of the node
*/
function getUserNodeAttr(node, attrName) {
// Get the row
var row = $('[id=' + node + ']').parents('tr');
// Get the row
var row = $('[id=' + node + ']').parents('tr');
// Search for the column containing the attribute
var attrCol;
var cols = row.parents('.dataTables_scroll').find('.dataTables_scrollHead thead tr:eq(0) th');
// Loop through each column
for (var i in cols) {
// Find column that matches the attribute
if (cols.eq(i).html() == attrName) {
attrCol = cols.eq(i);
break;
}
}
// If the column containing the attribute is found
if (attrCol) {
// Get the attribute column index
var attrIndex = attrCol.index();
// Search for the column containing the attribute
var attrCol = null;
var cols = row.parents('.dataTables_scroll').find('.dataTables_scrollHead thead tr:eq(0) th');
// Loop through each column
for (var i in cols) {
// Find column that matches the attribute
if (cols.eq(i).html() == attrName) {
attrCol = cols.eq(i);
break;
}
}
// If the column containing the attribute is found
if (attrCol) {
// Get the attribute column index
var attrIndex = attrCol.index();
// Get the attribute for the given node
var attr = row.find('td:eq(' + attrIndex + ')');
return attr.text();
} else {
return '';
}
// Get the attribute for the given node
var attr = row.find('td:eq(' + attrIndex + ')');
return attr.text();
} else {
return '';
}
}

View File

@ -13,78 +13,76 @@ $(document).ready(function() {
// The window's height is to small to show the dialog
var tmpHeight = 0;
if ((winHeight - 50) < diagHeight){
tmpHeight = 0;
tmpHeight = 0;
} else {
tmpHeight = parseInt((winHeight - diagHeight - 50) / 2);
tmpHeight = parseInt((winHeight - diagHeight - 50) / 2);
}
$('#login').css('margin', tmpHeight + 'px auto');
$('button').bind('click', function(){
authenticate();
authenticate();
}).button();
if (document.location.protocol == 'http:') {
$('#login-status').html('You are using an unencrypted session!');
$('#login-status').css('color', 'red');
}
if (!$("#login input[name='username']").val()) {
$("#login input[name='username']").focus();
} else {
$("#login input[name='password']").focus();
}
if (document.location.protocol == 'http:') {
$('#login-status').html('You are using an unencrypted session!');
$('#login-status').css('color', 'red');
}
if (!$("#login input[name='username']").val()) {
$("#login input[name='username']").focus();
} else {
$("#login input[name='password']").focus();
}
// When enter is hit while in username, advance to password
$("#login input[name='username']").keydown(function(event) {
if (event.keyCode == 13) {
$("#login input[name='password']").focus();
}
});
// When enter is hit while in username, advance to password
$("#login input[name='username']").keydown(function(event) {
if (event.keyCode == 13) {
$("#login input[name='password']").focus();
}
});
// Submit authentication if enter is pressed in password field
$("#login input[name='password']").keydown(function(event) {
if (event.keyCode == 13) {
authenticate();
}
});
// Submit authentication if enter is pressed in password field
$("#login input[name='password']").keydown(function(event) {
if (event.keyCode == 13) {
authenticate();
}
});
});
/**
* Update login dialog
*
* @param data
* Data returned from AJAX call
* @param txtStatus
* Status of login
* @param data Data returned from AJAX call
* @param txtStatus Status of login
*/
function onlogin(data, txtStatus) {
// Clear password field regardless of what happens
var usrName = $("#login input[name='username']").val();
$("#login input[name='password']").val('');
if (data.authenticated == 'yes') {
$('#login-status').text('Login successful');
window.location = 'service.php';
// Set user name cookie
var exDate = new Date();
exDate.setTime(exDate.getTime() + (240 * 60 * 1000));
$.cookie('xcat_username', usrName, { expires: exDate });
} else {
$('#login-status').text('Authentication failure');
$('#login-status').css('color', '#FF0000');
}
// Clear password field regardless of what happens
var usrName = $("#login input[name='username']").val();
$("#login input[name='password']").val('');
if (data.authenticated == 'yes') {
$('#login-status').text('Login successful');
window.location = 'service.php';
// Set user name cookie
var exDate = new Date();
exDate.setTime(exDate.getTime() + (240 * 60 * 1000));
$.cookie('xcat_username', usrName, { expires: exDate });
} else {
$('#login-status').text('Authentication failure');
$('#login-status').css('color', '#FF0000');
}
}
/**
* Authenticate user for new session
*/
function authenticate() {
$('#login-status').css('color', '#000000');
$('#login-status').html('Authenticating...');
var passwd = $("#login input[name='password']").val();
$.post('lib/srv_log.php', {
username : $("#login input[name='username']").val(),
password : passwd
}, onlogin, 'json');
$('#login-status').css('color', '#000000');
$('#login-status').html('Authenticating...');
var passwd = $("#login input[name='password']").val();
$.post('lib/srv_log.php', {
username : $("#login input[name='username']").val(),
password : passwd
}, onlogin, 'json');
}

File diff suppressed because it is too large Load Diff

View File

@ -13,95 +13,90 @@ $(document).ready(function() {
// The window's height is to small to show the dialog
var tempheight = 0;
if ((winheight - 50) < diaheight){
tempheight = 0;
tempheight = 0;
} else {
tempheight = parseInt((winheight - diaheight - 50) / 2);
tempheight = parseInt((winheight - diaheight - 50) / 2);
}
$('#login').css('margin', tempheight + 'px auto');
$('button').bind('click', function(){
authenticate();
authenticate();
});
$('#login button').button();
if (document.location.protocol == "http:") {
$("#login-status").html("You are using an unencrypted session!");
$("#login-status").css("color", "#ff0000");
}
if ($("#login input[name='username']").val() == "") {
$("#login input[name='username']").focus();
} else {
$("#login input[name='password']").focus();
}
if (document.location.protocol == "http:") {
$("#login-status").html("You are using an unencrypted session!");
$("#login-status").css("color", "#ff0000");
}
if ($("#login input[name='username']").val() == "") {
$("#login input[name='username']").focus();
} else {
$("#login input[name='password']").focus();
}
// When enter is hit while in username, advance to password
$("#login input[name='username']").keydown(function(event) {
if (event.keyCode == 13) {
$("#login input[name='password']").focus();
}
});
// When enter is hit while in username, advance to password
$("#login input[name='username']").keydown(function(event) {
if (event.keyCode == 13) {
$("#login input[name='password']").focus();
}
});
// Submit authentication if enter is pressed in password field
$("#login input[name='password']").keydown(function(event) {
if (event.keyCode == 13) {
authenticate();
}
});
// Submit authentication if enter is pressed in password field
$("#login input[name='password']").keydown(function(event) {
if (event.keyCode == 13) {
authenticate();
}
});
});
/**
* Update login dialog
*
* @param data
* Data returned from AJAX call
* @param txtStatus
* Status of login
* @return
* @param data Data returned from AJAX call
* @param txtStatus Status of login
*/
function onlogin(data, txtStatus) {
// Clear password field regardless of what happens
$("#login input[name='password']").val("");
if (data.authenticated == "yes") {
$("#login-status").text("Login successful");
// Clear password field regardless of what happens
$("#login input[name='password']").val("");
if (data.authenticated == "yes") {
$("#login-status").text("Login successful");
// Not the first time to log
if ($.cookie('logonflag')){
// Remembered what page they were trying to go to
window.location = window.location.pathname;
} else {
window.location = 'help.php';
}
// Set user name cookie
var usrName = $("#login input[name='username']").val();
var exDate = new Date();
exDate.setTime(exDate.getTime() + (240 * 60 * 1000));
$.cookie('xcat_username', usrName, { expires: exDate });
// Set the logonflag
$.cookie('logonflag', 'yes', {
path : '/xcat',
expires : 100
});
} else {
$("#login-status").text("Authentication failure").css("color", "#FF0000");
}
// Not the first time to log
if ($.cookie('logonflag')){
// Remembered what page they were trying to go to
window.location = window.location.pathname;
} else {
window.location = 'help.php';
}
// Set user name cookie
var usrName = $("#login input[name='username']").val();
var exDate = new Date();
exDate.setTime(exDate.getTime() + (240 * 60 * 1000));
$.cookie('xcat_username', usrName, { expires: exDate });
// Set the logonflag
$.cookie('logonflag', 'yes', {
path : '/xcat',
expires : 100
});
} else {
$("#login-status").text("Authentication failure").css("color", "#FF0000");
}
}
/**
* Authenticate user for new session
*
* @return Nothing
*/
function authenticate() {
$("#login-status").css("color", "#000000");
$("#login-status").html('Authenticating...');
var passwd = $("#login input[name='password']").val();
$.post("lib/log.php", {
username : $("#login input[name='username']").val(),
password : passwd
}, onlogin, "json");
$("#login-status").css("color", "#000000");
$("#login-status").html('Authenticating...');
var passwd = $("#login input[name='password']").val();
$.post("lib/log.php", {
username : $("#login input[name='username']").val(),
password : passwd
}, onlogin, "json");
}