diff --git a/xCAT-UI/js/monitor/xcatmon.js b/xCAT-UI/js/monitor/xcatmon.js index bd8b6a1ea..61bff5438 100644 --- a/xCAT-UI/js/monitor/xcatmon.js +++ b/xCAT-UI/js/monitor/xcatmon.js @@ -1,162 +1,507 @@ +/* +* Globle variable +* +*/ +var XcatmonTableId="XcatMonsettingTable"; +var dataTables=new Object(); + +/* +* set datatable +* +*/ +function setDatatable(id,obj){ + dataTables[id]=obj; +} +/* +* get datatable from the given id +* +* +*/ +function getDatatable(id){ + return dataTables[id]; +} +/* +* +* +*/ + function loadXcatMon(){ //find the xcat mon tab var xcatMonTab = $('#xcatmon'); - //add the stauts bar first. id = 'xcatMonStatus' - var StatusBar = createStatusBar('xcatMonStatus'); - StatusBar.append(createLoader()); - xcatMonTab.append(StatusBar); - - //add the configure button. - var configButton = createButton('Configure'); - configButton.click(function(){ - if ($('#xcatMonConfig').is(':hidden')){ - $('#xcatMonConfig').show(); - } - else{ - $('#xcatMonConfig').hide(); - } - }); - xcatMonTab.append(configButton); - - //add the configure div, id = 'xcatMonConfig' - xcatMonTab.append("
"); - $('#xcatMonConfig').hide(); - - //add button start, stop, cancel to the monconfig div - loadXcatMonConfigure(); - - //add the content of the xcat mon, id = 'xcatMonShow' - xcatMonTab.append(""); - - //show the content of the page. - $.ajax( { - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'monls', - tgt : '', - args : 'xcatmon', - msg : '' - }, - - success : loadXcatMonWorkStatus - }); -} - -function loadXcatMonWorkStatus(data){ - var xcatWorkStatus = data.rsp[0]; - - //the xcat mon did not run - if (-1 != xcatWorkStatus.indexOf('not-monitored')){ - $('#xcatMonStatus').empty().append('The xCAT Monitor is not working. Please start it first.'); - return; - } - - //the xcatmon is running, show the result - loadXcatMonShow(); -} - -function loadXcatMonConfigure(){ - //get the xcat mon configure div - var xcatMonConfigDiv = $('#xcatMonConfig'); - xcatMonConfigDiv.empty(); - - //add start button - var startButton = createButton('Start'); - xcatMonConfigDiv.append(startButton); - startButton.click(function(){ - $('#xcatMonStatus').empty().append(createLoader()); - $.ajax({ - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'monstart', - tgt : '', - args : 'xcatmon', - msg : '' - }, - - success : function(data){ - //update the status bar, update the xcatmon show - $('#xcatMonStatus').empty().append(data.rsp[0]); - loadXcatMonShow(); - } - }); - }); - - //add stop buttons - var stopButton = createButton('Stop'); - xcatMonConfigDiv.append(stopButton); - stopButton.click(function(){ - $('#xcatMonStatus').empty().append(createLoader()); - $.ajax({ - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'monstop', - tgt : '', - args : 'xcatmon', - msg : '' - }, - - success : function(data){ - $('#xcatMonStatus').empty().append(data.rsp[0]); - $('#xcatMonShow').empty(); - } - }); - }); - - //add cancel button - var cancelButton = createButton('Cancel'); - xcatMonConfigDiv.append(cancelButton); - cancelButton.click(function(){ - $('#xcatMonConfig').hide(); - }); -} - -function loadXcatMonShow(){ - //update the status bar into waiting - $('#xcatMonStatus').empty().append(createLoader()); - - //get the latest xcatmon information + xcatMonTab.append(""); + // show the content of the table monsetting $.ajax({ - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'nodestat', - tgt : 'lpar', - args : '', + url:'lib/cmd.php', + dataType: 'json', + data:{ + cmd : 'tabdump', + tgt :'', + args : 'monsetting', msg : '' }, - - success : updateXcatMonShow + 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; -function updateXcatMonShow(data){ - var temp = 0; - var nodeStatus = data.rsp; - var show = ""; - var tempArray; - //update the status bar - $('#xcatMonStatus').empty().append("Get nodes' status finished."); + + //create a infoBar + var infoBar=createInfoBar('Click on a cell to edit,Click outside the table to write to the cell.' + tempArray[0] + ':' + tempArray[1] + '
'; + //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