/** * global variable */ var XcatmonTableId="XcatMonsettingTable"; /** * load xCAT monitor */ function loadXcatMon(){ //find the xcat mon tab var xcatMonTab = $('#xcatmon'); xcatMonTab.append("
"); //show the content of the table monsetting $.ajax({ url:'lib/cmd.php', dataType: 'json', data:{ cmd : 'tabdump', tgt :'', args : 'monsetting', msg : '' }, success: loadXcatMonSetting }); } function loadXcatMonSetting(data){ var apps; //contain the xcatmon apps config var rsp = data.rsp; var apps_flag = 0; //is the apps is stored? var ping; //contain the xcatmon ping-interval setting var ping_flag = 0; //create a infoBar 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 xcatmonTable var XcatmonTable= new DataTable(XcatmonTableId); //create Datatable var dTable; //create the xcatmonTable header var header=rsp[0].split(","); header.splice(3,2); header.splice(0,1); header[0]="apps name"; header[1]="configure"; header.push(''); header.unshift(''); XcatmonTable.init(header); //create the table header //create container of original table contents var origCont= new Array(); origCont[0]=header; //table header //create contariner for new contents use for update the monsetting table var newCont =new Object(); newCont[0]=rsp[0].split(","); //table header //create container for other monsetting lines not xcatmon var otherCont =new Array(); $('#xcatmonTable').append(XcatmonTable.object()); //add table object var m = 1; //the count for origCont var n = 0; for (var i=1; i'); cols.unshift(''); //add the column tho the table XcatmonTable.add(cols); origCont[m++] = cols; } else { if (!apps_flag) { //check the apps setting if (rsp[i].indexOf("apps") > -1) { //check for is apps or not apps=rsp[i].split(','); for (var j=0; j -1) { ping=rsp[i].split(','); //pair the semicolon for (var j=0; j'); } } } $(":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' } ); //save the datatable dTable = $('#' + XcatmonTableId).dataTable({ 'iDisplayLength': 50, 'bLengthChange': false, "sScrollX": "100%", "bAutoWidth": true }); //create action bar var actionBar = $('
'); var addRowLnk = $('Add row'); addRowLnk.bind('click', function(event) { //create the container of the new row var row = new Array(); //add the delete button to the row row.push(''); //add the xcatmon //add the contain of the setting for (var i=0; i'); //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' } ); }); /** * apply button * * the Apply button is used to store the contain of the table in the page to * the monsetting table on the MN. */ var applyLnk = $('Apply'); applyLnk.bind('click', function(event){ //get the datatable of the page var dTable = $('#' + XcatmonTableId).dataTable(); //get the rows of the datatable var dRows = dTable.fnGetNodes(); var count = 0; //create the new container of the apps' value. var appValue = ''; var tableName = 'monsetting'; var tmp; var tmp1; var closeBtn = createButton('close'); //get the contain of the rows for (var i=0; i'); } else { vals_orig.push(''); } //push the delete button to the row vals_orig.unshift(''); //add the row to the orignCont origCont[i+1] = vals_orig; count = i+1; //check the checkbox fo everyrow for merging the appName to the apps values if (cols.item(cols.length-1).firstChild.checked) { //the new value for the apps.get the name fo every app. appValue = appValue.concat(cols.item(2).firstChild.nodeValue+","); } } } count++; //delete the last "," of the apps value appValue = appValue.substring(0,(appValue.length-1)); apps[2] = appValue; //newCont add the apps row newCont[count++] = apps; //newCont add the ping-interval row newCont[count++] = ping; //add the other monitor setting of the mosetting for (var j=0; jsaving the configuration '); dialogSave.append(createLoader()); $('#xcatmon').append(dialogSave); //open the dialog..modal is true $("#saveDialog").dialog({modal: true}); //hide the cross... $('.ui-dialog-titlebar-close').hide(); //put the table name and the contain to the tabRestore.php $.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('

The Configure has saved!

'); $("#saveDialog").append(closeBtn); } }); //close button function closeBtn.bind('click', function(event){ $("#saveDialog").dialog("distroy"); $("#saveDialog").remove(); }); //clear the newCont newCont = null; newCont = new Object(); //just for tmp=newCont; newCont[0] = rsp[0].split(","); }); var cancelLnk = $('Cancel'); cancelLnk.bind('click', function(event){ //get the datatable of the page var dTable = $('#' + XcatmonTableId).dataTable(); //clear the datatable dTable.fnClearTable(); //add the contain of the origCont to the datatable for (var i=1; i'); $('#' + XcatmonTableId + '_wrapper').prepend(menuDiv); menuDiv.append(actionBar); $('#' + XcatmonTableId + '_filter').appendTo(menuDiv); } /** * delete a row from the table */ function deleteRow1(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; } } }