2010-06-16 18:21:58 +00:00
|
|
|
/**
|
|
|
|
* Tab constructor
|
|
|
|
*
|
|
|
|
* @param tabId
|
|
|
|
* Tab ID
|
|
|
|
* @param tabName
|
|
|
|
* Tab name
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
var Tab = function(tabId) {
|
|
|
|
this.tabId = tabId;
|
|
|
|
this.tabName = null;
|
|
|
|
this.tab = null;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the tab
|
|
|
|
*
|
|
|
|
* @param tabName
|
|
|
|
* Tab name to initialize
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
Tab.prototype.init = function() {
|
|
|
|
// Create a division containing the tab
|
|
|
|
this.tab = $('<div class="tab" id="' + this.tabId + '"></div>');
|
|
|
|
var tabList = $('<ul></ul>');
|
|
|
|
var tabItem = $('<li><a href="#">Dummy tab item</a></li>');
|
|
|
|
tabList.append(tabItem);
|
|
|
|
this.tab.append(tabList);
|
|
|
|
|
2010-07-15 22:57:48 +00:00
|
|
|
// Create a template with close button
|
2010-08-03 14:58:08 +00:00
|
|
|
var tabs = this.tab.tabs();
|
2010-06-16 18:21:58 +00:00
|
|
|
|
|
|
|
// Remove dummy tab
|
|
|
|
this.tab.tabs("remove", 0);
|
|
|
|
|
|
|
|
// Hide tab
|
|
|
|
this.tab.hide();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the tab object
|
|
|
|
*
|
|
|
|
* @param Nothing
|
|
|
|
* @return Object representing the tab
|
|
|
|
*/
|
|
|
|
Tab.prototype.object = function() {
|
|
|
|
return this.tab;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a new tab
|
|
|
|
*
|
2010-12-03 22:09:36 +00:00
|
|
|
* @param tabId
|
|
|
|
* Tab ID
|
|
|
|
* @param tabName
|
|
|
|
* Tab name
|
|
|
|
* @param tabCont
|
|
|
|
* Tab content
|
2010-08-03 14:58:08 +00:00
|
|
|
* @param closeable
|
2010-12-03 22:09:36 +00:00
|
|
|
* Is tab closeable
|
2010-06-16 18:21:58 +00:00
|
|
|
* @return Nothing
|
|
|
|
*/
|
2010-12-03 22:09:36 +00:00
|
|
|
Tab.prototype.add = function(tabId, tabName, tabCont, closeable) {
|
2010-06-16 18:21:58 +00:00
|
|
|
// Show tab
|
|
|
|
if (this.tab.css("display") == "none") {
|
|
|
|
this.tab.show();
|
|
|
|
}
|
|
|
|
|
2010-12-03 22:09:36 +00:00
|
|
|
var newTab = $('<div class="tab" id="' + tabId + '"></div>');
|
|
|
|
newTab.append(tabCont);
|
2010-06-16 18:21:58 +00:00
|
|
|
this.tab.append(newTab);
|
2010-12-03 22:09:36 +00:00
|
|
|
this.tab.tabs("add", "#" + tabId, tabName);
|
2010-08-03 14:58:08 +00:00
|
|
|
|
|
|
|
// Append close button
|
|
|
|
if (closeable) {
|
2010-12-03 22:09:36 +00:00
|
|
|
var header = this.tab.find('ul.ui-tabs-nav a[href="#' + tabId +'"]').parent();
|
2010-08-03 14:58:08 +00:00
|
|
|
header.append('<span class=\"tab-close ui-icon ui-icon-close\"></span>');
|
2010-10-11 20:35:04 +00:00
|
|
|
|
|
|
|
// Get this tab
|
|
|
|
var tabs = this.tab;
|
2010-12-03 22:09:36 +00:00
|
|
|
var tabLink = 'a[href="\#' + tabId + '"]';
|
2010-10-11 20:35:04 +00:00
|
|
|
var thisTab = $(tabLink, tabs).parent();
|
|
|
|
|
|
|
|
// Close tab when close button is clicked
|
|
|
|
thisTab.find('span.tab-close').bind('click', function(event) {
|
|
|
|
var tabIndex = ($('li', tabs).index(thisTab));
|
|
|
|
|
|
|
|
// Do not remove first tab
|
2011-09-12 19:47:26 +00:00
|
|
|
if (tabIndex != 0) {
|
2011-01-19 15:56:43 +00:00
|
|
|
tabs.tabs('select', 0);
|
2011-09-12 19:47:26 +00:00
|
|
|
tabs.tabs('remove', tabIndex);
|
2010-10-11 20:35:04 +00:00
|
|
|
}
|
|
|
|
});
|
2010-08-03 14:58:08 +00:00
|
|
|
}
|
2010-06-16 18:21:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Select a tab
|
|
|
|
*
|
|
|
|
* @param id
|
|
|
|
* Tab ID to select
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
Tab.prototype.select = function(id) {
|
|
|
|
this.tab.tabs("select", "#" + id);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove a tab
|
|
|
|
*
|
|
|
|
* @param id
|
|
|
|
* Tab ID to remove
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
Tab.prototype.remove = function(id) {
|
2010-07-25 07:41:49 +00:00
|
|
|
var selectorStr = 'a[href="\#' + id + '"]';
|
|
|
|
var selectTab = $(selectorStr, this.tab).parent();
|
|
|
|
var index = ($('li', this.tab).index(selectTab));
|
|
|
|
this.tab.tabs("remove", index);
|
2010-06-16 18:21:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Table constructor
|
|
|
|
*
|
|
|
|
* @param tabId
|
|
|
|
* Tab ID
|
|
|
|
* @param tabName
|
|
|
|
* Tab name
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
var Table = function(tableId) {
|
|
|
|
if ($('#' + tableId).length) {
|
|
|
|
this.tableId = tableId;
|
|
|
|
this.table = $('#' + tableId);
|
|
|
|
} else {
|
|
|
|
this.tableId = tableId;
|
|
|
|
this.table = null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the table
|
|
|
|
*
|
|
|
|
* @param Headers
|
|
|
|
* Array of table headers
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
Table.prototype.init = function(headers) {
|
|
|
|
// Create a table
|
|
|
|
this.table = $('<table id="' + this.tableId + '"></table>');
|
2011-09-28 20:01:24 +00:00
|
|
|
var thead = $('<thead class="ui-widget-header"></thead>');
|
2010-06-16 18:21:58 +00:00
|
|
|
var headRow = $('<tr></tr>');
|
|
|
|
|
|
|
|
// Append headers
|
|
|
|
for ( var i in headers) {
|
|
|
|
headRow.append('<th>' + headers[i] + '</th>');
|
|
|
|
}
|
|
|
|
|
|
|
|
thead.append(headRow);
|
|
|
|
this.table.append(thead);
|
|
|
|
|
|
|
|
// Append table body
|
|
|
|
var tableBody = $('<tbody></tbody>');
|
|
|
|
this.table.append(tableBody);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the table object
|
|
|
|
*
|
|
|
|
* @param Nothing
|
|
|
|
* @return Object representing the table
|
|
|
|
*/
|
|
|
|
Table.prototype.object = function() {
|
|
|
|
return this.table;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a row to the table
|
|
|
|
*
|
|
|
|
* @param rowCont
|
|
|
|
* Array of table row contents
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
Table.prototype.add = function(rowCont) {
|
|
|
|
// Create table row
|
|
|
|
var tableRow = $('<tr></tr>');
|
|
|
|
|
|
|
|
// Create a column for each content
|
|
|
|
var tableCol;
|
|
|
|
for ( var i in rowCont) {
|
|
|
|
tableCol = $('<td></td>');
|
|
|
|
tableCol.append(rowCont[i]);
|
|
|
|
tableRow.append(tableCol);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Append table row to table
|
|
|
|
this.table.find('tbody').append(tableRow);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a footer to the table
|
|
|
|
*
|
|
|
|
* @param rowCont
|
|
|
|
* Array of table row contents
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
Table.prototype.addFooter = function(rowCont) {
|
|
|
|
// Create table row
|
|
|
|
var tableFoot = $('<tfoot></tfoot>');
|
|
|
|
tableFoot.append(rowCont);
|
|
|
|
|
|
|
|
// Append table row to table
|
|
|
|
this.table.append(tableFoot);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove a row from the table
|
|
|
|
*
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
Table.prototype.remove = function(id) {
|
|
|
|
// To be continued
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Datatable class constructor
|
|
|
|
*
|
|
|
|
* @param tabId
|
|
|
|
* Tab ID
|
|
|
|
* @param tabName
|
|
|
|
* Tab name
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
var DataTable = function(tableId) {
|
|
|
|
this.dataTableId = tableId;
|
|
|
|
this.dataTable = null;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the datatable
|
|
|
|
*
|
|
|
|
* @param Headers
|
|
|
|
* Array of table headers
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
DataTable.prototype.init = function(headers) {
|
|
|
|
// Create a table
|
|
|
|
this.dataTable = $('<table class="datatable" id="' + this.dataTableId + '"></table>');
|
2011-09-28 20:01:24 +00:00
|
|
|
var thead = $('<thead class="ui-widget-header"></thead>');
|
2010-06-16 18:21:58 +00:00
|
|
|
var headRow = $('<tr></tr>');
|
|
|
|
|
|
|
|
// Append headers
|
|
|
|
for ( var i in headers) {
|
|
|
|
headRow.append('<th>' + headers[i] + '</th>');
|
|
|
|
}
|
|
|
|
|
|
|
|
thead.append(headRow);
|
|
|
|
this.dataTable.append(thead);
|
|
|
|
|
|
|
|
// Append table body
|
|
|
|
var tableBody = $('<tbody></tbody>');
|
|
|
|
this.dataTable.append(tableBody);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the datatable object
|
|
|
|
*
|
|
|
|
* @param Nothing
|
|
|
|
* @return Object representing the table
|
|
|
|
*/
|
|
|
|
DataTable.prototype.object = function() {
|
|
|
|
return this.dataTable;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a row to the datatable
|
|
|
|
*
|
|
|
|
* @param rowCont
|
|
|
|
* Array of table row contents
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
DataTable.prototype.add = function(rowCont) {
|
|
|
|
// Create table row
|
|
|
|
var tableRow = $('<tr></tr>');
|
|
|
|
|
|
|
|
// Create a column for each content
|
|
|
|
var tableCol;
|
|
|
|
for ( var i in rowCont) {
|
|
|
|
tableCol = $('<td></td>');
|
|
|
|
tableCol.append(rowCont[i]);
|
|
|
|
tableRow.append(tableCol);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Append table row to table
|
|
|
|
this.dataTable.find('tbody').append(tableRow);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create status bar
|
|
|
|
*
|
|
|
|
* @param barId
|
|
|
|
* Status bar ID
|
|
|
|
* @return Status bar
|
|
|
|
*/
|
|
|
|
function createStatusBar(barId) {
|
2011-04-27 20:28:00 +00:00
|
|
|
var statusBar = $('<div class="ui-state-highlight ui-corner-all" id="' + barId + '"></div>').css({
|
|
|
|
'margin-bottom': '5px',
|
|
|
|
'min-height': '30px'
|
|
|
|
});
|
|
|
|
|
|
|
|
// Create info icon
|
|
|
|
var icon = $('<span class="ui-icon ui-icon-circle-check"></span>').css({
|
|
|
|
'display': 'inline-block',
|
2011-08-23 03:53:52 +00:00
|
|
|
'margin': '10px 5px',
|
|
|
|
'vertical-align': 'top'
|
2011-04-27 20:28:00 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Create message section
|
|
|
|
var msg = $('<div></div>').css({
|
|
|
|
'display': 'inline-block',
|
|
|
|
'margin': '10px 0px',
|
|
|
|
'width': '90%'
|
|
|
|
});
|
|
|
|
|
|
|
|
// Create hide button
|
|
|
|
var hide = $('<span class="ui-icon ui-icon-minus"></span>').css({
|
|
|
|
'display': 'inline-block',
|
|
|
|
'float': 'right',
|
|
|
|
'margin': '10px 5px',
|
|
|
|
'cursor': 'pointer'
|
|
|
|
}).click(function() {
|
|
|
|
// Remove info box on-click
|
|
|
|
$(this).parent().hide();
|
|
|
|
});
|
|
|
|
|
|
|
|
statusBar.append(icon);
|
|
|
|
statusBar.append(msg);
|
|
|
|
statusBar.append(hide);
|
2010-06-16 18:21:58 +00:00
|
|
|
return statusBar;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create info bar
|
|
|
|
*
|
|
|
|
* @param msg
|
|
|
|
* Info message
|
|
|
|
* @return Info bar
|
|
|
|
*/
|
|
|
|
function createInfoBar(msg) {
|
2010-09-24 12:27:54 +00:00
|
|
|
var infoBar = $('<div class="ui-state-highlight ui-corner-all"></div>');
|
2011-04-12 19:46:01 +00:00
|
|
|
var icon = $('<span class="ui-icon ui-icon-info"></span>').css({
|
|
|
|
'display': 'inline-block',
|
|
|
|
'margin': '10px 5px'
|
|
|
|
});
|
|
|
|
var msg = $('<p>' + msg + '</p>').css({
|
|
|
|
'display': 'inline-block',
|
2011-04-16 14:40:15 +00:00
|
|
|
'width': '90%'
|
2011-04-12 19:46:01 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
infoBar.append(icon);
|
2010-06-16 18:21:58 +00:00
|
|
|
infoBar.append(msg);
|
|
|
|
return infoBar;
|
|
|
|
}
|
|
|
|
|
2010-09-23 20:43:10 +00:00
|
|
|
/**
|
|
|
|
* Create warning bar
|
|
|
|
*
|
|
|
|
* @param msg
|
|
|
|
* Warning message
|
|
|
|
* @return Warning bar
|
|
|
|
*/
|
|
|
|
function createWarnBar(msg) {
|
2010-09-24 12:27:54 +00:00
|
|
|
var warnBar = $('<div class="ui-state-error ui-corner-all"></div>');
|
2011-04-16 14:40:15 +00:00
|
|
|
var icon = $('<span class="ui-icon ui-icon-alert"></span>').css({
|
|
|
|
'display': 'inline-block',
|
|
|
|
'margin': '10px 5px'
|
|
|
|
});
|
|
|
|
var msg = $('<p>' + msg + '</p>').css({
|
|
|
|
'display': 'inline-block',
|
|
|
|
'width': '90%'
|
|
|
|
});
|
|
|
|
|
|
|
|
warnBar.append(icon);
|
2010-09-23 20:43:10 +00:00
|
|
|
warnBar.append(msg);
|
|
|
|
return warnBar;
|
|
|
|
}
|
|
|
|
|
2010-06-16 18:21:58 +00:00
|
|
|
/**
|
|
|
|
* Create a loader
|
|
|
|
*
|
|
|
|
* @param loaderId
|
|
|
|
* Loader ID
|
2011-01-19 15:56:43 +00:00
|
|
|
* @return Loader
|
2010-06-16 18:21:58 +00:00
|
|
|
*/
|
|
|
|
function createLoader(loaderId) {
|
|
|
|
var loader = $('<img id="' + loaderId + '" src="images/loader.gif"></img>');
|
|
|
|
return loader;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a button
|
|
|
|
*
|
|
|
|
* @param name
|
|
|
|
* Name of the button
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
function createButton(name) {
|
2011-04-16 14:40:15 +00:00
|
|
|
var button = $('<button>' + name + '</button>').button();
|
2010-06-16 18:21:58 +00:00
|
|
|
return button;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a menu
|
|
|
|
*
|
|
|
|
* @param items
|
|
|
|
* An array of items to go into the menu
|
|
|
|
* @return A division containing the menu
|
|
|
|
*/
|
|
|
|
function createMenu(items) {
|
2011-09-28 20:01:24 +00:00
|
|
|
var menu = $('<ul class="sf-menu ui-state-default"></ul>');
|
2010-06-16 18:21:58 +00:00
|
|
|
|
|
|
|
// Loop through each item
|
|
|
|
for ( var i in items) {
|
|
|
|
// Append item to menu
|
|
|
|
var item = $('<li></li>');
|
|
|
|
|
|
|
|
// If it is a sub menu
|
|
|
|
if (items[i] instanceof Array) {
|
|
|
|
// 1st index = Sub menu title
|
|
|
|
item.append(items[i][0]);
|
|
|
|
// 2nd index = Sub menu
|
|
|
|
item.append(items[i][1]);
|
|
|
|
} else {
|
|
|
|
item.append(items[i]);
|
|
|
|
}
|
2011-09-28 20:01:24 +00:00
|
|
|
|
2010-06-16 18:21:58 +00:00
|
|
|
menu.append(item);
|
|
|
|
}
|
2011-09-28 20:01:24 +00:00
|
|
|
|
2010-06-16 18:21:58 +00:00
|
|
|
return menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the page
|
|
|
|
*
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2011-09-21 20:38:15 +00:00
|
|
|
function initPage() {
|
|
|
|
// Load theme
|
|
|
|
var theme = $.cookie('xcat_theme');
|
|
|
|
if (theme) {
|
|
|
|
switch (theme) {
|
|
|
|
case 'cupertino':
|
2011-09-22 18:09:04 +00:00
|
|
|
includeCss("css/themes/jquery-ui-cupertino.css");
|
2011-09-21 20:38:15 +00:00
|
|
|
break;
|
|
|
|
case 'dark_hive':
|
2011-09-22 18:09:04 +00:00
|
|
|
includeCss("css/themes/jquery-ui-dark_hive.css");
|
2011-09-21 20:38:15 +00:00
|
|
|
break;
|
|
|
|
case 'redmond':
|
2011-09-22 18:09:04 +00:00
|
|
|
includeCss("css/themes/jquery-ui-redmond.css");
|
2011-09-21 20:38:15 +00:00
|
|
|
break;
|
|
|
|
case 'start':
|
2011-09-22 18:09:04 +00:00
|
|
|
includeCss("css/themes/jquery-ui-start.css");
|
2011-09-21 20:38:15 +00:00
|
|
|
break;
|
|
|
|
case 'sunny':
|
2011-09-22 18:09:04 +00:00
|
|
|
includeCss("css/themes/jquery-ui-sunny.css");
|
2011-09-21 20:38:15 +00:00
|
|
|
break;
|
|
|
|
case 'ui_dark':
|
2011-09-22 18:09:04 +00:00
|
|
|
includeCss("css/themes/jquery-ui-ui_darkness.css");
|
2011-09-21 20:38:15 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-09-22 18:09:04 +00:00
|
|
|
includeCss("css/themes/jquery-ui-start.css");
|
2011-09-21 20:38:15 +00:00
|
|
|
}
|
2011-09-22 00:26:12 +00:00
|
|
|
} else {
|
2011-09-22 18:09:04 +00:00
|
|
|
includeCss("css/themes/jquery-ui-start.css");
|
2011-09-21 20:38:15 +00:00
|
|
|
}
|
|
|
|
|
2011-09-22 18:09:04 +00:00
|
|
|
// Load jQuery stylesheets
|
2011-09-26 20:38:29 +00:00
|
|
|
includeCss("css/jquery.dataTables.css");
|
2011-09-21 20:38:15 +00:00
|
|
|
includeCss("css/superfish.css");
|
|
|
|
includeCss("css/jstree.css");
|
|
|
|
includeCss("css/jquery.jqplot.css");
|
2011-09-22 18:09:04 +00:00
|
|
|
|
|
|
|
// Load custom stylesheet
|
2011-09-21 20:38:15 +00:00
|
|
|
includeCss("css/style.css");
|
|
|
|
|
2010-11-01 14:06:53 +00:00
|
|
|
// JQuery plugins
|
2010-07-14 20:11:07 +00:00
|
|
|
includeJs("js/jquery/jquery.dataTables.min.js");
|
2011-01-14 16:17:41 +00:00
|
|
|
includeJs("js/jquery/jquery.form.min.js");
|
|
|
|
includeJs("js/jquery/jquery.jeditable.min.js");
|
|
|
|
includeJs("js/jquery/jquery.contextmenu.min.js");
|
|
|
|
includeJs("js/jquery/superfish.min.js");
|
|
|
|
includeJs("js/jquery/hoverIntent.min.js");
|
|
|
|
includeJs("js/jquery/jquery.jstree.min.js");
|
2010-11-01 14:06:53 +00:00
|
|
|
includeJs("js/jquery/tooltip.min.js");
|
2011-01-14 16:17:41 +00:00
|
|
|
includeJs("js/jquery/jquery.serverBrowser.min.js");
|
2011-06-16 02:48:34 +00:00
|
|
|
includeJs("js/jquery/jquery.jqplot.min.js");
|
|
|
|
includeJs("js/jquery/jqplot.pieRenderer.min.js");
|
|
|
|
includeJs("js/jquery/jqplot.dateAxisRenderer.min.js");
|
|
|
|
|
2010-11-01 14:06:53 +00:00
|
|
|
// Page plugins
|
2010-08-04 15:47:41 +00:00
|
|
|
includeJs("js/configure/configure.js");
|
2010-07-14 20:11:07 +00:00
|
|
|
includeJs("js/monitor/monitor.js");
|
|
|
|
includeJs("js/nodes/nodes.js");
|
|
|
|
includeJs("js/provision/provision.js");
|
2010-07-22 19:56:09 +00:00
|
|
|
|
|
|
|
// Custom plugins
|
|
|
|
includeJs("js/custom/blade.js");
|
|
|
|
includeJs("js/custom/ipmi.js");
|
|
|
|
includeJs("js/custom/zvm.js");
|
2011-04-20 08:55:33 +00:00
|
|
|
includeJs("js/custom/hmc.js");
|
2011-08-24 10:30:30 +00:00
|
|
|
includeJs("js/custom/customUtils.js");
|
2010-07-14 20:11:07 +00:00
|
|
|
|
2011-09-21 20:38:15 +00:00
|
|
|
// Enable settings link
|
|
|
|
$('#xcat_settings').click(function() {
|
|
|
|
openSettings();
|
|
|
|
});
|
2011-09-28 20:01:24 +00:00
|
|
|
|
|
|
|
// Set header to theme
|
|
|
|
var background = '', color = '';
|
|
|
|
var theme = $.cookie('xcat_theme');
|
|
|
|
if (theme) {
|
|
|
|
switch (theme) {
|
|
|
|
case 'cupertino':
|
|
|
|
background = '#3BAAE3';
|
|
|
|
color = 'white';
|
|
|
|
break;
|
|
|
|
case 'dark_hive':
|
|
|
|
background = '#0972A5';
|
|
|
|
break;
|
|
|
|
case 'redmond':
|
|
|
|
background = '#F5F8F9';
|
|
|
|
color = '#E17009';
|
|
|
|
break;
|
|
|
|
case 'start':
|
|
|
|
background = '#6EAC2C';
|
|
|
|
break;
|
|
|
|
case 'sunny':
|
|
|
|
background = 'white';
|
|
|
|
color = '#0074C7';
|
|
|
|
break;
|
|
|
|
case 'ui_dark':
|
|
|
|
background = '#F58400';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
background = '#6EAC2C';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
background = '#6EAC2C';
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#header').addClass('ui-state-default');
|
|
|
|
$('#header').css('border', '0px');
|
|
|
|
|
|
|
|
// Set theme to user span
|
|
|
|
$('#login_user').css('color', color);
|
|
|
|
|
|
|
|
// Style for selected page
|
|
|
|
var style = {
|
|
|
|
'background-color': background,
|
|
|
|
'color': color
|
|
|
|
};
|
2011-09-21 20:38:15 +00:00
|
|
|
|
2010-06-16 18:21:58 +00:00
|
|
|
// Get the page being loaded
|
|
|
|
var url = window.location.pathname;
|
|
|
|
var page = url.replace('/xcat/', '');
|
|
|
|
var headers = $('#header ul li a');
|
2011-09-28 20:01:24 +00:00
|
|
|
|
2010-06-16 18:21:58 +00:00
|
|
|
// Show the page
|
2010-07-14 20:11:07 +00:00
|
|
|
$("#content").children().remove();
|
2011-07-20 21:13:09 +00:00
|
|
|
if (page == 'configure.php') {
|
2010-08-04 15:47:41 +00:00
|
|
|
includeJs("js/configure/update.js");
|
2010-12-03 03:25:33 +00:00
|
|
|
includeJs("js/configure/discover.js");
|
2011-09-28 20:01:24 +00:00
|
|
|
headers.eq(1).css(style);
|
2010-06-16 18:21:58 +00:00
|
|
|
loadConfigPage();
|
|
|
|
} else if (page == 'provision.php') {
|
2010-12-01 01:54:05 +00:00
|
|
|
includeJs("js/provision/images.js");
|
2011-09-28 20:01:24 +00:00
|
|
|
headers.eq(2).css(style);
|
2010-06-16 18:21:58 +00:00
|
|
|
loadProvisionPage();
|
|
|
|
} else if (page == 'monitor.php') {
|
2010-08-04 15:47:41 +00:00
|
|
|
includeJs("js/monitor/xcatmon.js");
|
|
|
|
includeJs("js/monitor/rmcmon.js");
|
2010-09-17 08:39:17 +00:00
|
|
|
includeJs("js/monitor/gangliamon.js");
|
2011-09-28 20:01:24 +00:00
|
|
|
headers.eq(3).css(style);
|
2010-06-16 18:21:58 +00:00
|
|
|
loadMonitorPage();
|
2011-05-12 06:00:04 +00:00
|
|
|
} else if (page == 'guide.php') {
|
|
|
|
includeJs("js/guide/guide.js");
|
2011-09-28 20:01:24 +00:00
|
|
|
headers.eq(4).css(style);
|
2011-05-12 15:00:38 +00:00
|
|
|
loadGuidePage();
|
2011-05-02 20:33:25 +00:00
|
|
|
} else {
|
2011-07-20 21:13:09 +00:00
|
|
|
// Load nodes page by default
|
2011-04-28 08:00:00 +00:00
|
|
|
includeJs("js/jquery/jquery.topzindex.min.js");
|
|
|
|
includeJs("js/nodes/nodeset.js");
|
|
|
|
includeJs("js/nodes/rnetboot.js");
|
|
|
|
includeJs("js/nodes/updatenode.js");
|
|
|
|
includeJs("js/nodes/physical.js");
|
|
|
|
includeJs("js/nodes/mtm.js");
|
2011-09-28 20:01:24 +00:00
|
|
|
headers.eq(0).css(style);
|
2010-06-16 18:21:58 +00:00
|
|
|
loadNodesPage();
|
|
|
|
}
|
2010-07-14 20:11:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-07-15 13:41:29 +00:00
|
|
|
* Include javascript file in <head>
|
2010-07-14 20:11:07 +00:00
|
|
|
*
|
|
|
|
* @param file
|
|
|
|
* File to include
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
function includeJs(file) {
|
2010-07-15 13:41:29 +00:00
|
|
|
var script = $("head script[src='" + file + "']");
|
2010-07-15 22:57:48 +00:00
|
|
|
|
|
|
|
// If <head> does not contain the javascript
|
2010-07-15 13:41:29 +00:00
|
|
|
if (!script.length) {
|
2010-07-15 22:57:48 +00:00
|
|
|
// Append the javascript to <head>
|
2010-07-15 13:41:29 +00:00
|
|
|
var script = $('<script></script>');
|
|
|
|
script.attr( {
|
|
|
|
type : 'text/javascript',
|
|
|
|
src : file
|
2010-07-22 19:56:09 +00:00
|
|
|
});
|
2010-07-15 13:41:29 +00:00
|
|
|
|
|
|
|
$('head').append(script);
|
|
|
|
}
|
2010-07-27 19:50:01 +00:00
|
|
|
}
|
|
|
|
|
2011-09-21 20:38:15 +00:00
|
|
|
/**
|
|
|
|
* Include CSS link in <head>
|
|
|
|
*
|
|
|
|
* @param file
|
|
|
|
* File to include
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
function includeCss(file) {
|
|
|
|
var link = $("head link[href='" + file + "']");
|
|
|
|
|
|
|
|
// If <head> does not contain the link
|
|
|
|
if (!link.length) {
|
|
|
|
// Append the CSS link to <head>
|
|
|
|
var link = $('<link>');
|
|
|
|
link.attr( {
|
|
|
|
type : 'text/css',
|
|
|
|
rel : 'stylesheet',
|
|
|
|
href : file
|
|
|
|
});
|
|
|
|
|
|
|
|
$('head').append(link);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-27 19:50:01 +00:00
|
|
|
/**
|
|
|
|
* Write ajax response to a paragraph
|
|
|
|
*
|
|
|
|
* @param rsp
|
|
|
|
* Ajax response
|
2010-07-27 22:56:42 +00:00
|
|
|
* @param pattern
|
2010-07-29 17:32:24 +00:00
|
|
|
* Pattern to replace with a break
|
2010-07-27 19:50:01 +00:00
|
|
|
* @return Paragraph containing ajax response
|
|
|
|
*/
|
2010-07-27 22:56:42 +00:00
|
|
|
function writeRsp(rsp, pattern) {
|
2010-07-27 19:50:01 +00:00
|
|
|
// Create paragraph to hold ajax response
|
2011-04-27 20:28:00 +00:00
|
|
|
var prg = $('<pre></pre>');
|
|
|
|
|
2010-07-27 19:50:01 +00:00
|
|
|
for ( var i in rsp) {
|
2010-07-27 22:56:42 +00:00
|
|
|
if (rsp[i]) {
|
2010-07-29 17:32:24 +00:00
|
|
|
// Create regular expression for given pattern
|
|
|
|
// Replace pattern with break
|
2010-07-27 22:56:42 +00:00
|
|
|
if (pattern) {
|
2011-04-27 20:28:00 +00:00
|
|
|
rsp[i] = rsp[i].replace(new RegExp(pattern, 'g'), '<br/>');
|
2010-12-03 22:09:36 +00:00
|
|
|
prg.append(rsp[i]);
|
|
|
|
} else {
|
|
|
|
prg.append(rsp[i]);
|
2011-04-27 20:28:00 +00:00
|
|
|
prg.append('<br/>');
|
2010-12-03 22:09:36 +00:00
|
|
|
}
|
2010-07-27 19:50:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return prg;
|
2010-09-23 20:43:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Open a dialog and show given message
|
|
|
|
*
|
2010-09-24 12:27:54 +00:00
|
|
|
* @param type
|
|
|
|
* Type of dialog, i.e. warn or info
|
2010-09-23 20:43:10 +00:00
|
|
|
* @param msg
|
|
|
|
* Message to show
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2010-09-24 12:27:54 +00:00
|
|
|
function openDialog(type, msg) {
|
|
|
|
var msgDialog;
|
|
|
|
if (type == "warn") {
|
|
|
|
// Create warning message
|
|
|
|
msgDialog = $('<div class="ui-state-error ui-corner-all">'
|
|
|
|
+ '<p><span class="ui-icon ui-icon-alert"></span>' + msg + '</p>'
|
|
|
|
+ '</div>');
|
|
|
|
} else {
|
|
|
|
// Create info message
|
|
|
|
msgDialog = $('<div class="ui-state-highlight ui-corner-all">'
|
|
|
|
+ '<p><span class="ui-icon ui-icon-info"></span>' + msg + '</p>'
|
|
|
|
+'</div>');
|
|
|
|
}
|
|
|
|
|
2010-09-24 02:27:04 +00:00
|
|
|
// Open dialog
|
2010-09-24 12:27:54 +00:00
|
|
|
msgDialog.dialog({
|
2010-09-23 20:43:10 +00:00
|
|
|
modal: true,
|
2010-12-02 21:28:24 +00:00
|
|
|
width: 500,
|
2010-09-23 20:43:10 +00:00
|
|
|
buttons: {
|
|
|
|
"Ok": function(){
|
|
|
|
$(this).dialog("close");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2011-04-12 19:46:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create an iframe to hold the output of an xCAT command
|
|
|
|
*
|
|
|
|
* @param src
|
|
|
|
* The URL of the document to show in the iframe
|
|
|
|
* @return Info box containing the iframe
|
|
|
|
*/
|
|
|
|
function createIFrame(src) {
|
|
|
|
// Put an iframe inside an info box
|
2011-04-27 20:28:00 +00:00
|
|
|
var infoBar = $('<div class="ui-state-highlight ui-corner-all"></div>').css({
|
|
|
|
'margin-bottom': '5px'
|
|
|
|
});
|
2011-04-26 16:39:08 +00:00
|
|
|
|
|
|
|
// Create info and close icons
|
2011-04-12 19:46:01 +00:00
|
|
|
var icon = $('<span class="ui-icon ui-icon-info"></span>').css({
|
|
|
|
'display': 'inline-block',
|
|
|
|
'margin': '10px 5px'
|
|
|
|
});
|
2011-04-26 16:39:08 +00:00
|
|
|
var close = $('<span class="ui-icon ui-icon-close"></span>').css({
|
|
|
|
'display': 'inline-block',
|
|
|
|
'float': 'right',
|
|
|
|
'margin': '10px 5px'
|
|
|
|
}).click(function() {
|
|
|
|
// Remove info box on-click
|
|
|
|
$(this).parent().remove();
|
|
|
|
});
|
|
|
|
|
2011-04-12 19:46:01 +00:00
|
|
|
var iframe = $('<iframe></iframe>').attr('src', src).css({
|
|
|
|
'display': 'inline-block',
|
|
|
|
'border': '0px',
|
|
|
|
'margin': '10px 0px',
|
2011-04-26 16:39:08 +00:00
|
|
|
'width': '90%'
|
2011-04-12 19:46:01 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
infoBar.append(icon);
|
|
|
|
infoBar.append(iframe);
|
2011-04-26 16:39:08 +00:00
|
|
|
infoBar.append(close);
|
|
|
|
|
2011-04-12 19:46:01 +00:00
|
|
|
return infoBar;
|
|
|
|
}
|
2011-09-21 20:38:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Open dialog to set xCAT UI settings
|
|
|
|
*
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
function openSettings() {
|
|
|
|
// Create form to add node range
|
|
|
|
var settingsForm = $('<div class="form"></div>');
|
|
|
|
var info = createInfoBar('Select the settings you desire');
|
|
|
|
settingsForm.append(info);
|
|
|
|
|
|
|
|
// Create select drop down for themes
|
|
|
|
var themeFS = $('<fieldset></fieldset>');
|
|
|
|
settingsForm.append(themeFS);
|
|
|
|
var legend = $('<legend>Theme</legend>');
|
|
|
|
themeFS.append(legend);
|
|
|
|
var oList = $('<ol></ol>');
|
|
|
|
oList.append($('<li><input type="radio" name="theme" value="cupertino">Cupertino</li>'));
|
|
|
|
oList.append($('<li><input type="radio" name="theme" value="dark_hive">Dark Hive</li>'));
|
|
|
|
oList.append($('<li><input type="radio" name="theme" value="redmond">Redmond</li>'));
|
2011-09-21 20:42:07 +00:00
|
|
|
oList.append($('<li><input type="radio" name="theme" value="start">Start (default)</li>'));
|
2011-09-21 20:38:15 +00:00
|
|
|
oList.append($('<li><input type="radio" name="theme" value="sunny">Sunny</li>'));
|
|
|
|
oList.append($('<li><input type="radio" name="theme" value="ui_dark">UI Darkness</li>'));
|
|
|
|
themeFS.append(oList);
|
|
|
|
|
|
|
|
if ($.cookie('xcat_theme')) {
|
|
|
|
// Select theme
|
|
|
|
oList.find('input[value="' + $.cookie('xcat_theme') + '"]').attr('checked', true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Open form as a dialog
|
|
|
|
settingsForm.dialog({
|
|
|
|
modal: true,
|
|
|
|
title: 'Settings',
|
|
|
|
width: 400,
|
|
|
|
buttons: {
|
|
|
|
"Ok": function(){
|
|
|
|
// Save selected theme
|
|
|
|
var theme = $(this).find('input[name="theme"]:checked').val();
|
2011-09-26 20:38:29 +00:00
|
|
|
$.cookie('xcat_theme', theme); // Do not expire cookie, keep it as long as possible
|
2011-09-21 20:38:15 +00:00
|
|
|
|
|
|
|
// Show instructions to apply theme
|
|
|
|
$(this).empty();
|
|
|
|
var info = createInfoBar('You will need to reload this page in order for changes to take effect');
|
|
|
|
$(this).append(info);
|
|
|
|
|
|
|
|
// Only show close button
|
|
|
|
$(this).dialog("option", "buttons", {
|
|
|
|
"Close" : function() {
|
|
|
|
$(this).dialog( "close" );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
"Cancel": function(){
|
|
|
|
$(this).dialog( "close" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2011-09-28 21:38:12 +00:00
|
|
|
}
|
|
|
|
|
2011-09-28 22:22:13 +00:00
|
|
|
/**
|
|
|
|
* Adjust datatable column size
|
|
|
|
*
|
|
|
|
* @param tableId
|
|
|
|
* Table ID
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
function adjustColumnSize(tableId) {
|
|
|
|
var cols = $('#' + tableId).find('tbody tr:eq(0) td');
|
|
|
|
|
|
|
|
// If the column size is zero, wait until table is initialized
|
|
|
|
if (!cols.eq(1).outerWidth()) {
|
|
|
|
adjustColumnSize(tableId);
|
|
|
|
} else {
|
|
|
|
for (var i in cols) {
|
|
|
|
var headers = $('#' + tableId + '_wrapper .dataTables_scrollHead .datatable thead tr th').eq(i);
|
|
|
|
headers.css('width', cols.eq(i).outerWidth());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-28 21:38:12 +00:00
|
|
|
/**
|
|
|
|
* Set menu theme
|
|
|
|
*
|
|
|
|
* @param menu
|
|
|
|
* Menu object
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
function setMenu2Theme(menu) {
|
|
|
|
// On hover
|
|
|
|
var background = '', color = '';
|
|
|
|
var theme = $.cookie('xcat_theme');
|
|
|
|
if (theme) {
|
|
|
|
switch (theme) {
|
|
|
|
case 'cupertino':
|
|
|
|
background = '#3BAAE3';
|
|
|
|
color = 'white';
|
|
|
|
break;
|
|
|
|
case 'dark_hive':
|
|
|
|
background = '#0972A5';
|
|
|
|
break;
|
|
|
|
case 'redmond':
|
|
|
|
background = '#F5F8F9';
|
|
|
|
color = '#E17009';
|
|
|
|
break;
|
|
|
|
case 'start':
|
|
|
|
background = '#6EAC2C';
|
|
|
|
break;
|
|
|
|
case 'sunny':
|
|
|
|
background = 'white';
|
|
|
|
color = '#0074C7';
|
|
|
|
break;
|
|
|
|
case 'ui_dark':
|
|
|
|
background = '#F58400';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
background = '#6EAC2C';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
background = '#6EAC2C';
|
|
|
|
}
|
|
|
|
|
|
|
|
menu.css('background', background);
|
|
|
|
menu.find('a:eq(0)').css('color', color);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set menu back to normal before applying theme
|
|
|
|
*
|
|
|
|
* @param menu
|
|
|
|
* Menu object
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
function setMenu2Normal(menu) {
|
|
|
|
// Change back to normal
|
|
|
|
menu.css('background', '');
|
|
|
|
menu.find('a:eq(0)').css('color', '');
|
2011-09-21 20:38:15 +00:00
|
|
|
}
|