diff --git a/xCAT-UI/js/custom/blade.js b/xCAT-UI/js/custom/blade.js
index 1176c9627..c55b0ce08 100644
--- a/xCAT-UI/js/custom/blade.js
+++ b/xCAT-UI/js/custom/blade.js
@@ -201,5 +201,184 @@ bladePlugin.prototype.loadResources = function() {
* @return Nothing
*/
bladePlugin.prototype.addNode = function() {
- openDialog('info', 'Under construction');
-};
\ No newline at end of file
+ var nodeTypeSelectDia = $('
' +
+ '
' +
+ '
' +
+ '
' +
+ '
JS
LS
' +
+ '
';
+ 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 += '
';
+ }
+
+ $('#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)){
+ $('#nodeTypeSelectDia').prepend(createWarnBar("You miss some inputs."));
+ 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();
+ }
+ });
+ }
+ });
+
+}
\ No newline at end of file
diff --git a/xCAT-UI/js/nodes/nodes.js b/xCAT-UI/js/nodes/nodes.js
index 41b19a741..3cebc96b5 100644
--- a/xCAT-UI/js/nodes/nodes.js
+++ b/xCAT-UI/js/nodes/nodes.js
@@ -385,7 +385,7 @@ function mkAddNodeLink() {
addNodeForm.append('
'
+ ''
@@ -434,6 +434,8 @@ function mkAddNodeLink() {
addNodeForm.dialog({
modal: true,
width: 400,
+ title:'Add Node',
+ close: function(){$(this).remove();},
buttons: {
'Ok': function(){
// Get hardware management