2010-07-28 20:24:29 +00:00
|
|
|
/**
|
|
|
|
* Execute when the DOM is fully loaded
|
|
|
|
*/
|
|
|
|
$(document).ready(function() {
|
|
|
|
// Load utility scripts
|
2010-07-20 18:49:31 +00:00
|
|
|
});
|
|
|
|
|
2010-07-22 19:56:09 +00:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2010-07-23 18:47:54 +00:00
|
|
|
var bladePlugin = function() {
|
2010-07-28 20:24:29 +00:00
|
|
|
|
2010-07-22 19:56:09 +00:00
|
|
|
};
|
|
|
|
|
2010-07-20 18:49:31 +00:00
|
|
|
/**
|
|
|
|
* Load node inventory
|
|
|
|
*
|
|
|
|
* @param data
|
|
|
|
* Data from HTTP request
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2010-07-23 18:47:54 +00:00
|
|
|
bladePlugin.prototype.loadInventory = function(data) {
|
2010-10-07 14:15:56 +00:00
|
|
|
var args = data.msg.split(',');
|
|
|
|
var tabId = args[0].replace('out=', '');
|
|
|
|
var node = args[1].replace('node=', '');
|
2011-08-23 03:53:52 +00:00
|
|
|
|
2010-10-07 14:15:56 +00:00
|
|
|
// Get node inventory
|
|
|
|
var inv = data.rsp;
|
|
|
|
|
|
|
|
// Remove loader
|
2011-01-19 15:56:43 +00:00
|
|
|
$('#' + tabId).find('img').remove();
|
2010-10-07 14:15:56 +00:00
|
|
|
|
|
|
|
// Create division to hold inventory
|
|
|
|
var invDivId = tabId + 'Inventory';
|
2011-08-23 03:53:52 +00:00
|
|
|
var invDiv = $('<div></div>');
|
2010-10-07 14:15:56 +00:00
|
|
|
|
2011-08-23 03:53:52 +00:00
|
|
|
// Create a fieldset
|
|
|
|
var fieldSet = $('<fieldset></fieldset>');
|
|
|
|
var legend = $('<legend>Hardware</legend>');
|
|
|
|
fieldSet.append(legend);
|
|
|
|
var oList = $('<ol></ol>');
|
|
|
|
fieldSet.append(oList);
|
|
|
|
invDiv.append(fieldSet);
|
|
|
|
|
|
|
|
// Loop through each line
|
|
|
|
var item;
|
|
|
|
for (var k = 0; k < inv.length; k++) {
|
|
|
|
// Remove node name in front
|
|
|
|
var str = inv[k].replace(node + ': ', '');
|
|
|
|
str = jQuery.trim(str);
|
|
|
|
|
|
|
|
// Append the string to a list
|
|
|
|
item = $('<li></li>');
|
|
|
|
item.append(str);
|
|
|
|
oList.append(item);
|
|
|
|
}
|
|
|
|
|
2010-10-07 14:15:56 +00:00
|
|
|
// Append to inventory form
|
|
|
|
$('#' + tabId).append(invDiv);
|
2010-07-22 19:56:09 +00:00
|
|
|
};
|
2010-07-20 18:49:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Load clone page
|
|
|
|
*
|
|
|
|
* @param node
|
|
|
|
* Source node to clone
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2010-07-23 18:47:54 +00:00
|
|
|
bladePlugin.prototype.loadClonePage = function(node) {
|
2010-10-07 14:15:56 +00:00
|
|
|
// Get nodes tab
|
|
|
|
var tab = getNodesTab();
|
|
|
|
var newTabId = node + 'CloneTab';
|
|
|
|
|
|
|
|
// If there is no existing clone tab
|
|
|
|
if (!$('#' + newTabId).length) {
|
|
|
|
// Create info bar
|
2011-08-23 03:53:52 +00:00
|
|
|
var infoBar = createInfoBar('Not supported');
|
2010-10-07 14:15:56 +00:00
|
|
|
|
|
|
|
// Create clone form
|
|
|
|
var cloneForm = $('<div class="form"></div>');
|
|
|
|
cloneForm.append(infoBar);
|
|
|
|
|
|
|
|
// Add clone tab
|
|
|
|
tab.add(newTabId, 'Clone', cloneForm, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
tab.select(newTabId);
|
2010-07-22 19:56:09 +00:00
|
|
|
};
|
2010-07-20 18:49:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Load provision page
|
|
|
|
*
|
|
|
|
* @param tabId
|
|
|
|
* The provision tab ID
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2010-07-23 18:47:54 +00:00
|
|
|
bladePlugin.prototype.loadProvisionPage = function(tabId) {
|
2011-08-24 10:30:30 +00:00
|
|
|
// Create provision form
|
|
|
|
var provForm = $('<div class="form"></div>');
|
2010-07-20 18:49:31 +00:00
|
|
|
|
2011-08-24 10:30:30 +00:00
|
|
|
// Create info bar
|
|
|
|
var infoBar = createInfoBar('Provision a node on Blade.');
|
|
|
|
provForm.append(infoBar);
|
2010-07-20 18:49:31 +00:00
|
|
|
|
2011-08-24 10:30:30 +00:00
|
|
|
// Append to provision tab
|
|
|
|
$('#' + tabId).append(provForm);
|
2010-07-20 18:49:31 +00:00
|
|
|
|
2011-08-24 10:30:30 +00:00
|
|
|
/**
|
|
|
|
* Create provision new node division
|
|
|
|
*/
|
|
|
|
// You should copy whatever is in this function, put it here, and customize it
|
|
|
|
createProvision('blade', provForm);
|
2010-07-22 19:56:09 +00:00
|
|
|
};
|
2010-07-20 18:49:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Load resources
|
|
|
|
*
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2010-10-08 03:03:42 +00:00
|
|
|
bladePlugin.prototype.loadResources = function() {
|
|
|
|
// Get resource tab ID
|
2011-01-19 15:56:43 +00:00
|
|
|
var tabId = 'bladeResourceTab';
|
|
|
|
// Remove loader
|
|
|
|
$('#' + tabId).find('img').remove();
|
2010-10-07 17:40:24 +00:00
|
|
|
|
|
|
|
// Create info bar
|
|
|
|
var infoBar = createInfoBar('Under construction');
|
2010-07-28 20:24:29 +00:00
|
|
|
|
2010-10-07 17:40:24 +00:00
|
|
|
// Create resource form
|
|
|
|
var resrcForm = $('<div class="form"></div>');
|
|
|
|
resrcForm.append(infoBar);
|
|
|
|
|
2011-02-24 19:49:11 +00:00
|
|
|
$('#' + tabId).append(resrcForm);
|
2010-09-22 16:52:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2010-09-24 02:27:04 +00:00
|
|
|
* Add node range
|
2010-09-22 16:52:41 +00:00
|
|
|
*
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2010-09-23 20:43:10 +00:00
|
|
|
bladePlugin.prototype.addNode = function() {
|
2011-07-04 09:26:00 +00:00
|
|
|
var nodeTypeSelectDia = $('<div id="nodeTypeSelectDia" class="form"></div>');
|
|
|
|
nodeTypeSelectDia.append('<div><label for="mgt">Node Type :</label><select id="nodeTypeSelect">' +
|
2011-07-20 21:13:09 +00:00
|
|
|
'<option value="mm">AMM Node</option><option value="blade">Blade Node</option></select></div>');
|
2011-07-04 09:26:00 +00:00
|
|
|
//append the mm div
|
|
|
|
var mmStr = '<div id="mmNode">' +
|
2011-07-20 21:13:09 +00:00
|
|
|
'<label>AMM Name: </label><input id="ammName" type="text"></input><br/><br/>' +
|
|
|
|
'<label>AMM IP: </label><input id="ammIp" type="text"></input>' +
|
2011-07-04 09:26:00 +00:00
|
|
|
'</div>';
|
|
|
|
|
|
|
|
//append the blade div
|
|
|
|
var bladeStr = '<div id="bladeNode" style="display:none;">' +
|
2011-07-20 21:13:09 +00:00
|
|
|
'<label>Blade Name: </label><input id="bladeName" type="text"></input><br/><br/>' +
|
|
|
|
'<label>Blade Group: </label><input id="bladeGroup" type="text"></input><br/><br/>' +
|
|
|
|
'<label>Blade ID: </label><input id="bladeId" type="text"></input><br/><br/>' +
|
|
|
|
'<label>Blade Series: </label><input type="radio" name="series" value="js"/>JS<input type="radio" name="series" value="ls"/>LS<br/><br/>' +
|
|
|
|
'<label>Blade MPA: </label><select id="mpaSelect"></select>';
|
2011-07-04 09:26:00 +00:00
|
|
|
nodeTypeSelectDia.append(mmStr);
|
|
|
|
nodeTypeSelectDia.append(bladeStr);
|
|
|
|
|
|
|
|
nodeTypeSelectDia.find('#nodeTypeSelect').bind('change', function(){
|
|
|
|
$('#nodeTypeSelectDia .ui-state-error').remove();
|
|
|
|
$('#mmNode').toggle();
|
|
|
|
$('#bladeNode').toggle();
|
|
|
|
if ('mm' == $(this).val()){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//get all mm nodes from the server side
|
|
|
|
$('#bladeNode select').empty();
|
|
|
|
$('#bladeNode').append(createLoader());
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'lsdef',
|
|
|
|
tgt : '',
|
|
|
|
args : '-t;node;-w;mgt==blade;-w;id==0',
|
|
|
|
msg : ''
|
|
|
|
},
|
|
|
|
success : function(data){
|
|
|
|
var position = 0;
|
|
|
|
var tempStr = '';
|
|
|
|
var options = '';
|
|
|
|
//remove the loading image
|
|
|
|
$('#bladeNode img').remove();
|
|
|
|
|
|
|
|
//check return result
|
|
|
|
if (1 > data.rsp.length){
|
|
|
|
$('#nodeTypeSelectDia').prepend(createWarnBar('Please define MM node first!'));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//add all mm nodes to select
|
|
|
|
for (var i in data.rsp){
|
|
|
|
tempStr = data.rsp[i];
|
|
|
|
position = tempStr.indexOf(' ');
|
|
|
|
tempStr = tempStr.substring(0, position);
|
|
|
|
options += '<option value="' + tempStr + '">' + tempStr + '</option>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#bladeNode select').append(options);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
nodeTypeSelectDia.dialog( {
|
|
|
|
modal : true,
|
|
|
|
width : 400,
|
|
|
|
title : 'Select Node Type',
|
|
|
|
open : function(event, ui) {
|
|
|
|
$(".ui-dialog-titlebar-close").hide();
|
|
|
|
},
|
|
|
|
buttons : {
|
|
|
|
'Ok' : function() {
|
|
|
|
//remove all error bar
|
|
|
|
$('#nodeTypeSelectDia .ui-state-error').remove();
|
|
|
|
|
|
|
|
if ($('#nodeTypeSelect').attr('value') == "mm") {
|
|
|
|
addMmNode();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
addBladeNode();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'Cancel' : function() {
|
|
|
|
$(this).remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
function addMmNode(){
|
|
|
|
var name = $('#ammName').val();
|
|
|
|
var ip = $('#ammIp').val();
|
|
|
|
|
|
|
|
if ((!name) || (!ip)){
|
2011-07-20 21:13:09 +00:00
|
|
|
$('#nodeTypeSelectDia').prepend(createWarnBar("You are missing some inputs!"));
|
2011-07-04 09:26:00 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//add the loader
|
|
|
|
$('#nodeTypeSelectDia').prepend(createLoader());
|
|
|
|
$('.ui-dialog-buttonpane .ui-button').attr('disabled', true);
|
|
|
|
var argsTmp = '-t;node;-o;' + name +
|
|
|
|
';id=0;nodetype=mm;groups=mm;mgt=blade;mpa=' + name + ';ip=' + ip;
|
|
|
|
$.ajax( {
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'chdef',
|
|
|
|
tgt : '',
|
|
|
|
args : argsTmp,
|
|
|
|
msg : ''
|
|
|
|
},
|
|
|
|
success : function(data) {
|
|
|
|
$('#nodeTypeSelectDia').find('img').remove();
|
|
|
|
var messages = data.rsp;
|
|
|
|
var notes = "";
|
|
|
|
for ( var i = 0; i < messages.length; i++) {
|
|
|
|
notes += messages[i];
|
|
|
|
}
|
|
|
|
var info = createInfoBar(notes);
|
|
|
|
$('#nodeTypeSelectDia').prepend(info);
|
|
|
|
$('#nodeTypeSelectDia').dialog("option", "buttons", {
|
|
|
|
"close" : function() {
|
|
|
|
$('#nodeTypeSelectDia').remove();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function addBladeNode(){
|
|
|
|
var name = $('#bladeName').val();
|
|
|
|
var group = $('#bladeGroup').val();
|
|
|
|
var id = $('#bladeId').val();
|
|
|
|
var series = $("#bladeNode :checked").val();
|
|
|
|
var mpa = $('#mpaSelect').val();
|
|
|
|
|
|
|
|
var argsTmp = '-t;node;-o;' + name + ';id=' + id +
|
|
|
|
';nodetype=osi;groups=' + group + ';mgt=blade;mpa=' + mpa + ';serialflow=hard';
|
|
|
|
if (series != 'js') {
|
|
|
|
argsTmp += ';serialspeed=19200;serialport=1';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((!name) || (!group) || (!id) || (!mpa)){
|
|
|
|
$('#nodeTypeSelectDia').prepend(createWarnBar("You miss some inputs."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//add loader and disable buttons
|
|
|
|
$('#nodeTypeSelectDia').prepend(createLoader());
|
|
|
|
$('.ui-dialog-buttonpane .ui-button').attr('disabled', true);
|
|
|
|
$.ajax( {
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'chdef',
|
|
|
|
tgt : '',
|
|
|
|
args : argsTmp,
|
|
|
|
msg : ''
|
|
|
|
},
|
|
|
|
success : function(data) {
|
|
|
|
$('#nodeTypeSelectDia').find('img').remove();
|
|
|
|
var messages = data.rsp;
|
|
|
|
var notes = "";
|
|
|
|
for ( var i = 0; i < messages.length; i++) {
|
|
|
|
notes += messages[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#nodeTypeSelectDia').prepend(createInfoBar(notes));
|
|
|
|
$('#nodeTypeSelectDia').dialog("option", "buttons", {
|
|
|
|
"close" : function() {
|
|
|
|
$('#nodeTypeSelectDia').remove();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2011-08-23 03:53:52 +00:00
|
|
|
}
|