2010-08-26 05:27:11 +00:00
var globalErrNodes ;
var globalNodesDetail ;
var globalAllNodesNum = 0 ;
var globalFinishNodesNum = 0 ;
2010-12-01 06:14:44 +00:00
var globalSelectedAttributes = '' ;
2010-12-14 08:11:08 +00:00
var globalTimeStamp ;
2010-12-25 02:17:00 +00:00
var globalCondition = '' ;
var globalResponse = new Object ( ) ;
2010-08-26 05:27:11 +00:00
2010-08-04 08:49:20 +00:00
function loadRmcMon ( ) {
//find the rmcmon tab
var rmcMonTab = $ ( '#rmcmon' ) ;
//add the stauts bar first. id = 'rmcMonStatus'
var rmcStatusBar = createStatusBar ( 'rmcMonStatus' ) ;
rmcStatusBar . append ( createLoader ( ) ) ;
rmcMonTab . append ( rmcStatusBar ) ;
//add the configure button.
var configButton = createButton ( 'Configure' ) ;
2010-08-22 14:58:21 +00:00
configButton . hide ( ) ;
2010-08-04 08:49:20 +00:00
configButton . click ( function ( ) {
if ( $ ( '#rmcMonConfig' ) . is ( ':hidden' ) ) {
$ ( '#rmcMonConfig' ) . show ( ) ;
}
else {
$ ( '#rmcMonConfig' ) . hide ( ) ;
}
2010-09-14 08:06:50 +00:00
} ) ;
2010-08-04 08:49:20 +00:00
rmcMonTab . append ( configButton ) ;
//add configure div
rmcMonTab . append ( "<div id='rmcMonConfig'></div>" ) ;
$ ( '#rmcMonConfig' ) . hide ( ) ;
//load the configure div's content
loadRmcMonConfigure ( ) ;
//add the content of the rmcmon, id = 'rmcMonTab'
2010-09-14 08:06:50 +00:00
rmcMonTab . append ( "<div id='rmcMonShow'><div id='rmcmonSummary'></div><div id='rmcmonDetail'></div><div id='nodeDetail'></div></div>" ) ;
$ ( '#nodeDetail' ) . hide ( ) ;
2010-08-04 08:49:20 +00:00
//check the software work status by platform(linux and aix)
$ . ajax ( {
url : 'lib/systemcmd.php' ,
dataType : 'json' ,
data : {
cmd : 'ostype'
} ,
success : rsctRpmCheck
} ) ;
}
function loadRmcMonConfigure ( ) {
2010-08-22 14:58:21 +00:00
//get the configure div and clean its content.
var rmcmonCfgDiv = $ ( '#rmcMonConfig' ) ;
rmcmonCfgDiv . empty ( ) ;
//add the start button
var startButton = createButton ( 'Start' ) ;
rmcmonCfgDiv . append ( startButton ) ;
startButton . click ( function ( ) {
$ ( '#rmcMonStatus' ) . empty ( ) . append ( createLoader ( ) ) ;
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'webrun' ,
tgt : '' ,
args : 'rmcstart;lpar' ,
msg : ''
} ,
success : function ( data ) {
$ ( '#rmcMonStatus' ) . empty ( ) . append ( data . rsp [ 0 ] ) ;
}
} ) ;
} ) ;
//add the stop button
var stopButton = createButton ( 'Stop' ) ;
rmcmonCfgDiv . append ( stopButton ) ;
stopButton . click ( function ( ) {
$ ( '#rmcMonStatus' ) . empty ( ) . append ( createLoader ( ) ) ;
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'monstop' ,
tgt : '' ,
args : 'rmcmon' ,
msg : ''
} ,
success : function ( data ) {
$ ( '#rmcMonStatus' ) . empty ( ) . append ( data . rsp [ 0 ] ) ;
}
} ) ;
} ) ;
2010-12-01 06:14:44 +00:00
//add the attributes button
var attrButton = createButton ( 'Attribute Select' ) ;
rmcmonCfgDiv . append ( attrButton ) ;
attrButton . bind ( 'click' , function ( ) {
showConfigureDia ( ) ;
} ) ;
2010-08-22 14:58:21 +00:00
//add the cancel button
var cancelButton = createButton ( 'Cancel' ) ;
rmcmonCfgDiv . append ( cancelButton ) ;
cancelButton . click ( function ( ) {
$ ( '#rmcMonConfig' ) . hide ( ) ;
} ) ;
2010-08-04 08:49:20 +00:00
}
2010-08-26 05:27:11 +00:00
2010-08-04 08:49:20 +00:00
function rsctRpmCheck ( data ) {
//linux had to check the rscp first
if ( 'aix' != data . rsp ) {
$ . ajax ( {
url : 'lib/systemcmd.php' ,
dataType : 'json' ,
data : {
cmd : 'rpm -q rsct.core'
} ,
success : function ( data ) {
if ( - 1 != data . rsp . indexOf ( "not" ) ) {
2010-08-22 14:58:21 +00:00
$ ( '#rmcMonStatus' ) . empty ( ) . append (
'Please install the <a href="http://www14.software.ibm.com/webapp/set2/sas/f/rsct/rmc/download/home.html" target="install_window">RSCT</a> first.<br/>' +
2010-11-05 22:53:47 +00:00
'You can find more support from <a href="http://xcat.svn.sourceforge.net/viewvc/xcat/xcat-core/trunk/xCAT-client/share/doc/xCAT2-Monitoring.pdf" target="pdf_window">xCAT2-Monitoring.pdf</a>' ) ;
2010-08-04 08:49:20 +00:00
}
else {
xcatrmcRpmCheck ( ) ;
}
}
} ) ;
}
else {
xcatrmcRpmCheck ( ) ;
}
}
function xcatrmcRpmCheck ( ) {
$ . ajax ( {
url : 'lib/systemcmd.php' ,
dataType : 'json' ,
data : {
2010-08-22 14:58:21 +00:00
cmd : 'rpm -q xCAT-rmc rrdtool'
2010-08-04 08:49:20 +00:00
} ,
success : function ( data ) {
2010-08-22 14:58:21 +00:00
var softInstallStatus = data . rsp . split ( /\n/ ) ;
var needHelp = false ;
$ ( '#rmcMonStatus' ) . empty ( ) ;
//check the xcat-rmc
2011-04-16 14:40:15 +00:00
if ( - 1 != softInstallStatus [ 0 ] . indexOf ( "not" ) ) {
2010-08-22 14:58:21 +00:00
needHelp = true ;
$ ( '#rmcMonStatus' ) . append (
'Please install the <a href="http://xcat.sourceforge.net/#download" target="install_window">xCAT-rmc</a> first.<br/>' ) ;
}
//check the rrdtool
2011-04-16 14:40:15 +00:00
if ( - 1 != softInstallStatus [ 1 ] . indexOf ( "not" ) ) {
2010-08-22 14:58:21 +00:00
needHelp = true ;
$ ( '#rmcMonStatus' ) . append (
'Please install the <a href="http://oss.oetiker.ch/rrdtool/download.en.html" target="install_window">RRD-tool</a> first.<br/>' ) ;
}
//add help info or load the rmc show
if ( needHelp ) {
$ ( '#rmcMonStatus' ) . append (
'You can find more support form <a href="http://xcat.svn.sourceforge.net/viewvc/xcat/xcat-core/trunk/xCAT-client/share/doc/xCAT2-Monitoring.pdf" target="pdf_window">xCAT2-Monitoring.pdf</a>' ) ;
2010-08-04 08:49:20 +00:00
}
else {
2010-08-22 14:58:21 +00:00
rmcWorkingCheck ( ) ;
2010-08-04 08:49:20 +00:00
}
}
} ) ;
}
2010-08-22 14:58:21 +00:00
function rmcWorkingCheck ( ) {
$ ( '#rmcMonStatus' ) . empty ( ) . append ( "Checking RMC working status." ) ;
$ ( '#rmcMonStatus' ) . append ( createLoader ( ) ) ;
$ ( '#rmcmon button:first' ) . show ( ) ;
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'monls' ,
tgt : '' ,
args : 'rmcmon' ,
msg : ''
} ,
success : function ( data ) {
if ( - 1 != data . rsp [ 0 ] . indexOf ( "not-monitored" ) ) {
$ ( '#rmcMonStatus' ) . empty ( ) . append ( "Please start the RMC Monitoring first." ) ;
return ;
}
loadRmcMonShow ( ) ;
}
} ) ;
}
2010-09-24 02:27:04 +00:00
2010-08-04 08:49:20 +00:00
function loadRmcMonShow ( ) {
2010-12-03 22:09:36 +00:00
$ ( '#rmcMonStatus' ) . empty ( ) . append ( "Getting monitoring Data (This step may take a long time)." ) ;
2010-08-26 05:27:11 +00:00
$ ( '#rmcMonStatus' ) . append ( createLoader ( ) ) ;
2010-12-01 06:14:44 +00:00
//init the selected Attributes string
if ( $ . cookie ( 'rmcmonattr' ) ) {
globalSelectedAttributes = $ . cookie ( 'rmcmonattr' ) ;
}
else {
globalSelectedAttributes = 'PctTotalTimeIdle,PctTotalTimeWait,PctTotalTimeUser,PctTotalTimeKernel,PctRealMemFree' ;
}
2010-08-26 05:27:11 +00:00
//load the rmc status summary
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'webrun' ,
tgt : '' ,
2010-12-01 06:14:44 +00:00
args : 'rmcshow;summary;' + globalSelectedAttributes ,
2010-08-26 05:27:11 +00:00
msg : ''
} ,
success : function ( data ) {
showRmcSummary ( data . rsp [ 0 ] ) ;
}
} ) ;
2010-12-09 05:09:01 +00:00
}
function showRmcSummary ( returnData ) {
var attributes = returnData . split ( ';' ) ;
var attr ;
var attrName ;
var attrValues ;
var attrDiv ;
var summaryTable = $ ( '<table><tbody></tbody></table>' ) ;
var summaryRow ;
2010-12-14 08:11:08 +00:00
globalTimeStamp = new Array ( ) ;
2010-08-26 05:27:11 +00:00
//load each nodes' status
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'webrun' ,
tgt : '' ,
2010-12-01 06:14:44 +00:00
args : 'rmcshow;lpar;' + globalSelectedAttributes ,
2010-08-26 05:27:11 +00:00
msg : ''
} ,
success : function ( data ) {
parseRmcData ( data . rsp ) ;
}
} ) ;
2010-12-14 08:11:08 +00:00
//create the timestamp, the flot only use the UTC time, so had to change the value, to show the right time
var tempDate = new Date ( ) ;
var tempOffset = tempDate . getTimezoneOffset ( ) ;
var tempTime = tempDate . getTime ( ) - 3600000 - tempOffset * 60000 ;
for ( var i = 0 ; i < 60 ; i ++ ) {
globalTimeStamp . push ( tempTime + i * 60000 ) ;
}
2010-12-09 05:09:01 +00:00
//show the summary data
2010-08-26 05:27:11 +00:00
$ ( '#rmcmonSummary' ) . empty ( ) . append ( '<h3>Overview</h3><hr />' ) ;
$ ( '#rmcmonSummary' ) . append ( summaryTable ) ;
for ( attr in attributes ) {
var tempTd = $ ( '<td style="border:0px;padding:15px 5px;"></td>' ) ;
var tempArray = [ ] ;
var temp = attributes [ attr ] . indexOf ( ':' ) ;
attrName = attributes [ attr ] . substr ( 0 , temp ) ;
attrValues = attributes [ attr ] . substr ( temp + 1 ) . split ( ',' ) ;
for ( var i in attrValues ) {
2010-12-14 08:11:08 +00:00
tempArray . push ( [ globalTimeStamp [ i ] , attrValues [ i ] ] ) ;
2010-08-26 05:27:11 +00:00
}
if ( 0 == ( attr % 3 ) ) {
summaryRow = $ ( '<tr></tr>' ) ;
summaryTable . append ( summaryRow ) ;
}
summaryRow . append ( tempTd ) ;
attrDiv = $ ( '<div class="monitorsumdiv"></div>' ) ;
tempTd . append ( attrDiv ) ;
2010-12-14 08:11:08 +00:00
$ . plot ( attrDiv , [ tempArray ] , { xaxis : { mode : "time" } } ) ;
2010-08-26 05:27:11 +00:00
attrDiv . append ( '<center>' + attrName + '</center>' ) ;
}
}
function parseRmcData ( returnData ) {
var nodeName ;
var nodeStatus ;
var nodeChat ;
//clean all the history data, because all of the follow variables are global
globalAllNodesNum = returnData . length ;
globalFinishNodesNum = 0 ;
globalErrNodes = { } ;
globalNodesDetail = { } ;
for ( var i in returnData ) {
var temp = returnData [ i ] . indexOf ( ':' ) ; ;
nodeName = returnData [ i ] . substr ( 0 , temp ) ;
nodeStatus = returnData [ i ] . substr ( temp + 1 ) . replace ( /(^\s*)|(\s*$)/g , '' ) ;
//not active nodes
if ( 'OK' != nodeStatus ) {
globalErrNodes [ nodeName ] = nodeStatus ;
globalFinishNodesNum ++ ;
if ( globalFinishNodesNum == globalAllNodesNum ) {
2010-09-14 08:06:50 +00:00
showDetail ( ) ;
2010-08-26 05:27:11 +00:00
}
continue ;
}
//ok
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'webrun' ,
tgt : '' ,
2010-12-01 06:14:44 +00:00
args : 'rmcshow;' + nodeName + ';' + globalSelectedAttributes ,
2010-08-26 05:27:11 +00:00
msg : nodeName
} ,
success : function ( data ) {
var tempObject = { } ;
for ( var i in data . rsp ) {
var temp = data . rsp [ i ] . indexOf ( ':' ) ;
var attrName = data . rsp [ i ] . substr ( 0 , temp ) ;
tempObject [ attrName ] = data . rsp [ i ] . substr ( temp + 1 ) ;
}
globalNodesDetail [ data . msg ] = tempObject ;
globalFinishNodesNum ++ ;
if ( globalFinishNodesNum == globalAllNodesNum ) {
2010-09-14 08:06:50 +00:00
showDetail ( ) ;
2010-08-26 05:27:11 +00:00
}
}
} ) ;
}
}
2010-09-14 08:06:50 +00:00
function showDetail ( ) {
2010-08-26 05:27:11 +00:00
var nodeChat ;
2010-09-13 08:44:19 +00:00
var select ;
2010-08-26 05:27:11 +00:00
2010-09-13 08:44:19 +00:00
var detailFilter = $ ( '<div id="detailFilter"></div>' ) ;
2010-08-26 05:27:11 +00:00
$ ( '#rmcMonStatus' ) . empty ( ) . append ( "RMC Monitoring Show" ) ;
$ ( '#rmcmonDetail' ) . empty ( ) . append ( '<h3>Detail</h3><hr />' ) ;
2010-09-13 08:44:19 +00:00
$ ( '#rmcmonDetail' ) . append ( detailFilter ) ;
select = $ ( '<select id="metric"></select>' ) ;
2011-04-16 14:40:15 +00:00
for ( var node in globalNodesDetail ) {
for ( var attr in globalNodesDetail [ node ] ) {
2010-09-13 08:44:19 +00:00
select . append ( '<option value="' + attr + '">' + attr + '</option>' ) ;
}
break ;
}
detailFilter . append ( '<b>Metric: </b>' ) ;
detailFilter . append ( select ) ;
detailFilter . append ( ' ' ) ;
//sort type
select = $ ( '<select id="sortType"></select>' ) ;
select . append ( '<option value="1">ascend</option>' ) ;
select . append ( '<option value="2">descend</option>' ) ;
select . append ( '<option value="3">node name</option>' ) ;
detailFilter . append ( '<b>Sort: </b>' ) ;
detailFilter . append ( select ) ;
detailFilter . append ( ' ' ) ;
var filterButton = createButton ( 'Filter' ) ;
detailFilter . append ( filterButton ) ;
filterButton . bind ( 'click' , function ( ) {
var attr = $ ( '#metric' ) . val ( ) ;
var type = $ ( '#sortType' ) . val ( ) ;
showAllNodes ( attr , type ) ;
} ) ;
2010-09-14 08:06:50 +00:00
filterButton . trigger ( 'click' ) ;
2010-09-13 08:44:19 +00:00
}
function showAllNodes ( attrName , type ) {
$ ( '#rmcmonDetail table' ) . remove ( ) ;
var detailTable = $ ( '<table><tbody></tbody></table>' ) ;
//remember how many nodes parsed, used for adding new table row
var parseNum = 0 ;
var detailRow ;
var sortArray = new Array ( ) ;
2010-08-26 05:27:11 +00:00
$ ( '#rmcmonDetail' ) . append ( detailTable ) ;
for ( var nodeName in globalErrNodes ) {
var tempTd = $ ( '<td style="border:0px;padding:1px 1px;"></td>' ) ;
if ( 0 == ( parseNum % 4 ) ) {
detailRow = $ ( '<tr></tr>' ) ;
detailTable . append ( detailRow ) ;
}
detailRow . append ( tempTd ) ;
parseNum ++ ;
nodeChat = $ ( '<div class="monitornodediv"></div>' ) ;
if ( 'NA' == globalErrNodes [ nodeName ] ) {
nodeChat . css ( 'background-color' , '#f47a55' ) ;
nodeChat . append ( '<center><h4> Not Active</h4></center>' ) ;
}
else if ( 'NI' == globalErrNodes [ nodeName ] ) {
nodeChat . css ( 'background-color' , '#ffce7b' ) ;
nodeChat . append ( '<center><h4>' + nodeName + '\'s RSCT is not installed.</h4></center>' ) ;
}
else if ( 'NR' == globalErrNodes [ nodeName ] ) {
nodeChat . css ( 'background-color' , '#ffce7b' ) ;
nodeChat . append ( '<center><h4>' + nodeName + '\'s RSCT is not started.</h4></center>' ) ;
}
tempTd . append ( nodeChat ) ;
tempTd . append ( '<center>' + nodeName + '</center>' ) ;
}
2010-09-13 08:44:19 +00:00
filterSort ( attrName , type , sortArray ) ;
for ( var sortIndex in sortArray ) {
2010-08-26 05:27:11 +00:00
var tempTd = $ ( '<td style="border:0px;padding:1px 1px;"></td>' ) ;
if ( 0 == ( parseNum % 4 ) ) {
detailRow = $ ( '<tr></tr>' ) ;
detailTable . append ( detailRow ) ;
}
detailRow . append ( tempTd ) ;
parseNum ++ ;
nodeChat = $ ( '<div class="monitornodediv"></div>' ) ;
tempTd . append ( nodeChat ) ;
2010-09-13 08:44:19 +00:00
var tempData = sortArray [ sortIndex ] [ 'value' ] . split ( ',' ) ;
var tempArray = [ ] ;
for ( var i in tempData ) {
2010-12-14 08:11:08 +00:00
tempArray . push ( [ globalTimeStamp [ i ] , tempData [ i ] ] ) ;
2010-08-26 05:27:11 +00:00
}
2010-12-14 08:11:08 +00:00
$ . plot ( nodeChat , [ tempArray ] , { xaxis : { mode : "time" , tickSize : [ 20 , "minute" ] } } ) ;
2010-09-13 08:44:19 +00:00
tempTd . append ( '<center>' + sortArray [ sortIndex ] [ 'name' ] + '</center>' ) ;
2010-09-14 08:06:50 +00:00
tempTd . css ( 'cursor' , 'pointer' ) ;
tempTd . bind ( 'click' , function ( ) {
showNode ( $ ( 'center' , $ ( this ) ) . html ( ) ) ;
} ) ;
}
}
function showNode ( nodeName ) {
var nodeTable = $ ( '<table><tbody></tbody></table>' ) ;
var backButton = createButton ( 'Go back to all nodes' ) ;
var nodeRow ;
var parseNum = 0 ;
$ ( '#rmcmonDetail' ) . hide ( ) ;
$ ( '#nodeDetail' ) . empty ( ) . show ( ) ;
$ ( '#nodeDetail' ) . append ( '<h3>' + nodeName + ' Detail</h3><hr />' ) ;
$ ( '#nodeDetail' ) . append ( backButton ) ;
backButton . bind ( 'click' , function ( ) {
$ ( '#nodeDetail' ) . hide ( ) ;
$ ( '#rmcmonDetail' ) . show ( ) ;
} ) ;
$ ( '#nodeDetail' ) . append ( nodeTable ) ;
for ( var attr in globalNodesDetail [ nodeName ] ) {
var tempTd = $ ( '<td style="border:0px;padding:1px 1px;"></td>' ) ;
var attrChat = $ ( '<div class="monitornodediv"></div>' ) ;
if ( 0 == parseNum % 4 ) {
nodeRow = $ ( '<tr></tr>' ) ;
nodeTable . append ( nodeRow ) ;
}
nodeRow . append ( tempTd ) ;
parseNum ++ ;
//data
tempTd . append ( attrChat ) ;
var tempData = globalNodesDetail [ nodeName ] [ attr ] . split ( ',' ) ;
var tempArray = [ ] ;
for ( var i in tempData ) {
2010-12-14 08:11:08 +00:00
tempArray . push ( [ globalTimeStamp [ i ] , tempData [ i ] ] ) ;
2010-09-14 08:06:50 +00:00
}
2010-12-14 08:11:08 +00:00
$ . plot ( attrChat , [ tempArray ] , { xaxis : { mode : "time" , tickSize : [ 20 , "minute" ] } } ) ;
2010-09-14 08:06:50 +00:00
attrChat . append ( '<center>' + attr + '</center>' ) ;
2010-09-13 08:44:19 +00:00
}
}
function filterSort ( attrName , sortType , retArray ) {
var tempObj = { } ;
2011-04-16 14:40:15 +00:00
for ( var node in globalNodesDetail ) {
2010-09-13 08:44:19 +00:00
tempObj [ 'name' ] = node ;
tempObj [ 'value' ] = globalNodesDetail [ node ] [ attrName ] ;
retArray . push ( tempObj ) ;
}
//by node name
2011-04-16 14:40:15 +00:00
if ( 3 == sortType ) {
2010-09-13 08:44:19 +00:00
retArray . sort ( sortName ) ;
}
//desend
2011-04-16 14:40:15 +00:00
else if ( 2 == sortType ) {
2010-09-13 08:44:19 +00:00
retArray . sort ( sortDes ) ;
}
//ascend
else {
retArray . sort ( sortAsc ) ;
}
return ;
}
function sortAsc ( x , y ) {
2011-04-16 14:40:15 +00:00
if ( x [ 'value' ] > y [ 'value' ] ) {
2010-09-13 08:44:19 +00:00
return 1 ;
}
else {
return - 1 ;
}
}
function sortDes ( x , y ) {
2011-04-16 14:40:15 +00:00
if ( x [ 'value' ] > y [ 'value' ] ) {
2010-09-13 08:44:19 +00:00
return - 1 ;
}
else {
return 1 ;
}
}
function sortName ( x , y ) {
2011-04-16 14:40:15 +00:00
if ( x [ 'name' ] > y [ 'name' ] ) {
2010-09-13 08:44:19 +00:00
return 1 ;
}
else {
return - 1 ;
2010-08-26 05:27:11 +00:00
}
2010-12-01 06:14:44 +00:00
}
function showConfigureDia ( ) {
var diaDiv = $ ( '<div class="tab" title="Monitor Attributes Select"></div>' ) ;
var tempArray = globalSelectedAttributes . split ( ',' ) ;
var selectedAttrHash = new Object ( ) ;
var wholeAttrArray = new Array ( 'PctTotalTimeIdle' , 'PctTotalTimeWait' , 'PctTotalTimeUser' , 'PctTotalTimeKernel' , 'PctRealMemFree' ) ;
//init the selectedAttrHash
for ( var i in tempArray ) {
selectedAttrHash [ tempArray [ i ] ] = 1 ;
}
var attrTable = $ ( '<table id="rmcAttrTable"></table>' ) ;
for ( var i in wholeAttrArray ) {
var name = wholeAttrArray [ i ] ;
var tempString = '<tr>' ;
2011-04-16 14:40:15 +00:00
if ( selectedAttrHash [ name ] ) {
2010-12-01 06:14:44 +00:00
tempString += '<td><input type="checkbox" name="' + name + '" checked="checked"></td>' ;
}
else {
tempString += '<td><input type="checkbox" name="' + name + '"></td>' ;
}
tempString += '<td>' + name + '</td></tr>' ;
attrTable . append ( tempString ) ;
}
var selectAllButton = createButton ( 'Select All' ) ;
selectAllButton . bind ( 'click' , function ( ) {
$ ( '#rmcAttrTable input[type=checkbox]' ) . attr ( 'checked' , true ) ;
} ) ;
diaDiv . append ( selectAllButton ) ;
var unselectAllButton = createButton ( 'Unselect All' ) ;
unselectAllButton . bind ( 'click' , function ( ) {
$ ( '#rmcAttrTable input[type=checkbox]' ) . attr ( 'checked' , false ) ;
} ) ;
diaDiv . append ( unselectAllButton ) ;
diaDiv . append ( attrTable ) ;
diaDiv . dialog ( {
modal : true ,
width : 400 ,
close : function ( event , ui ) {
$ ( this ) . remove ( ) ;
} ,
buttons : {
cancel : function ( ) {
$ ( this ) . dialog ( 'close' ) ;
} ,
ok : function ( ) {
//collect all attibutes' name
var str = '' ;
$ ( '#rmcAttrTable input:checked' ) . each ( function ( ) {
2011-04-16 14:40:15 +00:00
if ( '' == str ) {
2010-12-01 06:14:44 +00:00
str += $ ( this ) . attr ( 'name' ) ;
}
else {
str += ',' + $ ( this ) . attr ( 'name' ) ;
}
} ) ;
//if no attribute is selected, alert the information.
if ( '' == str ) {
alert ( 'Please select one attribute at lease!' ) ;
return ;
}
//new selected attributes is different from the old, update the cookie and reload this tab
if ( $ . cookie ( 'rmcmonattr' ) != str ) {
$ . cookie ( 'rmcmonattr' , str , { path : '/xcat' , expires : 10 } ) ;
//todo reload the tab
$ ( '#rmcmon' ) . empty ( ) ;
loadRmcMon ( ) ;
}
$ ( this ) . dialog ( 'close' ) ;
}
}
} ) ;
2010-12-16 03:14:55 +00:00
}
2010-12-25 02:17:00 +00:00
/*===========RMC Event Tab============*/
2010-12-16 03:14:55 +00:00
/ * *
* load the rmc event tab .
*
* @ param
2011-04-16 14:40:15 +00:00
*
2010-12-16 03:14:55 +00:00
* @ return
*
* /
function loadRmcEvent ( ) {
//find the rmcevent tab
//add the stauts bar first. id = 'rmcMonStatus'
2010-12-16 14:28:49 +00:00
var rmcStatusBar = createStatusBar ( 'rmcEventStatus' ) ;
2010-12-16 03:14:55 +00:00
rmcStatusBar . append ( createLoader ( ) ) ;
$ ( '#rmcevent' ) . append ( rmcStatusBar ) ;
$ ( '#rmcevent' ) . append ( '<div id="rmcEventDiv"></div>' ) ;
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'webrun' ,
tgt : '' ,
2010-12-16 14:28:49 +00:00
args : 'lsevent;-O;1000' ,
2010-12-16 03:14:55 +00:00
msg : ''
} ,
success : showEventLog
} ) ;
}
2010-12-25 02:17:00 +00:00
/ * *
* get all conditions
*
* @ return
*
* /
function getConditions ( ) {
if ( '' == globalCondition ) {
2011-01-11 09:22:45 +00:00
$ ( '#rmcEventStatus' ) . empty ( ) . append ( 'Getting predefined conditions' ) . append ( createLoader ( ) ) ;
2010-12-25 02:17:00 +00:00
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'webrun' ,
tgt : '' ,
args : 'lscondition' ,
msg : ''
} ,
2011-04-16 14:40:15 +00:00
success : function ( data ) {
2011-01-11 09:22:45 +00:00
$ ( '#rmcEventStatus' ) . empty ( ) ;
$ ( '#rmcEventButtons' ) . show ( ) ;
2010-12-25 02:17:00 +00:00
globalCondition = data . rsp [ 0 ] ;
}
} ) ;
}
2011-01-11 09:22:45 +00:00
else {
$ ( '#rmcEventButtons' ) . show ( ) ;
}
2010-12-25 02:17:00 +00:00
}
/ * *
* get all response
*
* @ return
*
* /
function getResponse ( ) {
var tempFlag = false ;
//get all response first
for ( var i in globalResponse ) {
tempFlag = true ;
break ;
}
2011-04-16 14:40:15 +00:00
2010-12-25 02:17:00 +00:00
if ( ! tempFlag ) {
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'webrun' ,
tgt : '' ,
args : 'lsresponse' ,
msg : ''
} ,
success : function ( data ) {
var resps = data . rsp [ 0 ] . split ( ';' ) ;
2011-04-16 14:40:15 +00:00
for ( var i in resps ) {
2010-12-25 02:17:00 +00:00
var name = resps [ i ] ;
name = name . substr ( 1 , ( name . length - 2 ) ) ;
globalResponse [ name ] = 1 ;
}
}
} ) ;
}
}
2010-12-16 03:14:55 +00:00
/ * *
* show all the event in the rmc event tab
*
* @ param data response from the xcat server .
* @ return
*
* /
function showEventLog ( data ) {
2010-12-16 14:28:49 +00:00
$ ( '#rmcEventStatus' ) . empty ( ) ;
//rsct not installed.
if ( data . rsp [ 0 ] && ( - 1 != data . rsp [ 0 ] . indexOf ( 'lsevent' ) ) ) {
$ ( '#rmcEventStatus' ) . append ( 'Please install RSCT first!' ) ;
return ;
}
2010-12-16 03:14:55 +00:00
var eventDiv = $ ( '#rmcEventDiv' ) ;
eventDiv . empty ( ) ;
2010-12-16 14:28:49 +00:00
//add the configure button
loadRmcEventConfig ( ) ;
2010-12-25 02:17:00 +00:00
//get conditions and responses, save in the global
getConditions ( ) ;
getResponse ( ) ;
2010-12-16 03:14:55 +00:00
var eventTable = new DataTable ( 'lsEventTable' ) ;
eventTable . init ( [ 'Time' , 'Type' , 'Content' ] ) ;
2011-04-16 14:40:15 +00:00
for ( var i in data . rsp ) {
2010-12-16 03:14:55 +00:00
var row = data . rsp [ i ] . split ( ';' ) ;
eventTable . add ( row ) ;
}
eventDiv . append ( eventTable . object ( ) ) ;
$ ( '#lsEventTable' ) . dataTable ( {
'bFilter' : true ,
'bLengthChange' : true ,
'bSort' : true ,
'bPaginate' : true ,
'iDisplayLength' : 10
} ) ;
//unsort on the content column
$ ( '#lsEventTable thead tr th' ) . eq ( 2 ) . unbind ( 'click' ) ;
2010-12-16 14:28:49 +00:00
}
/ * *
* Add the configure button into rmc event tab
*
* @ param
* @ return
*
* /
function loadRmcEventConfig ( ) {
2011-01-11 09:22:45 +00:00
var buttons = $ ( '<div id="rmcEventButtons" style="display:none;"></div>' ) ;
2010-12-23 03:03:19 +00:00
var chCondScopeBut = createButton ( 'Change Condition Scope' ) ;
chCondScopeBut . bind ( 'click' , function ( ) {
chCondScopeDia ( ) ;
} ) ;
2011-01-11 09:22:45 +00:00
buttons . append ( chCondScopeBut ) ;
2010-12-23 03:03:19 +00:00
2010-12-28 09:34:44 +00:00
var mkCondRespBut = createButton ( 'Make/Remove Association' ) ;
mkCondRespBut . bind ( 'click' , function ( ) {
mkCondRespDia ( ) ;
2010-12-23 03:03:19 +00:00
} ) ;
2011-01-11 09:22:45 +00:00
buttons . append ( mkCondRespBut ) ;
2010-12-23 03:03:19 +00:00
2011-01-11 09:22:45 +00:00
var startCondRespBut = createButton ( 'Start/Stop Association' ) ;
2010-12-28 09:34:44 +00:00
startCondRespBut . bind ( 'click' , function ( ) {
2011-01-11 09:22:45 +00:00
startStopCondRespDia ( ) ;
2010-12-28 09:34:44 +00:00
} ) ;
2011-01-11 09:22:45 +00:00
buttons . append ( startCondRespBut ) ;
2010-12-28 09:34:44 +00:00
2011-01-11 09:22:45 +00:00
$ ( '#rmcEventDiv' ) . append ( buttons ) ;
2010-12-16 14:28:49 +00:00
}
/ * *
* show the make association dialogue
*
* @ param
* @ return
*
* /
function mkCondRespDia ( ) {
2011-01-11 09:22:45 +00:00
var diaDiv = $ ( '<div title="Configure Association" id="mkAssociation" class="tab"></div>' ) ;
var mkAssociationTable = '<center><table><thead><tr><th>Condition Name</th><th>Response Name</th></tr></thead>' ;
mkAssociationTable += '<tbody><tr><td id="mkAssCond">' ;
2010-12-25 02:17:00 +00:00
//add the conditions into fieldset
if ( '' == globalCondition ) {
2011-01-11 09:22:45 +00:00
mkAssociationTable += 'Getting predefined conditions, open this dislogue later.' ;
2010-12-25 02:17:00 +00:00
}
else {
2011-01-11 09:22:45 +00:00
mkAssociationTable += createConditionTd ( globalCondition ) ;
2010-12-25 02:17:00 +00:00
}
2011-01-11 09:22:45 +00:00
mkAssociationTable += '</td><td id="mkAssResp">Plase select condition first.</td></tr></tbody></table></center>' ;
diaDiv . append ( mkAssociationTable ) ;
diaDiv . append ( '<div id="selectedResp" style="display: none;" ><div>' ) ;
2010-12-25 02:17:00 +00:00
//change the response field when click the condition
diaDiv . find ( 'input:radio' ) . bind ( 'click' , function ( ) {
2011-01-11 09:22:45 +00:00
diaDiv . find ( '#mkAssResp' ) . empty ( ) . append ( 'Getting response' ) . append ( createLoader ( ) ) ;
2010-12-25 02:17:00 +00:00
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'webrun' ,
tgt : '' ,
args : 'lscondresp;"' + $ ( this ) . attr ( 'value' ) + '"' ,
msg : ''
} ,
2011-04-16 14:40:15 +00:00
success : function ( data ) {
2010-12-25 02:17:00 +00:00
var tempHash = new Object ( ) ;
2010-12-27 09:02:40 +00:00
var oldSelectedResp = '' ;
2010-12-25 02:17:00 +00:00
var showStr = '' ;
if ( data . rsp [ 0 ] ) {
var names = data . rsp [ 0 ] . split ( ';' ) ;
for ( var i in names ) {
var name = names [ i ] ;
name = name . substr ( 1 , name . length - 2 ) ;
tempHash [ name ] = 1 ;
}
}
2011-04-16 14:40:15 +00:00
for ( var name in globalResponse ) {
if ( tempHash [ name ] ) {
2011-01-11 09:22:45 +00:00
showStr += '<input type="checkbox" checked="checked" value="' + name + '">' + name + '<br/>' ;
2010-12-27 09:02:40 +00:00
oldSelectedResp += ';' + name ;
2010-12-25 02:17:00 +00:00
}
else {
2011-01-11 09:22:45 +00:00
showStr += '<input type="checkbox" value="' + name + '">' + name + '<br/>' ;
2010-12-25 02:17:00 +00:00
}
}
2011-01-11 09:22:45 +00:00
diaDiv . find ( '#mkAssResp' ) . empty ( ) . append ( showStr ) ;
2010-12-27 09:02:40 +00:00
diaDiv . find ( '#selectedResp' ) . empty ( ) . append ( oldSelectedResp ) ;
2010-12-25 02:17:00 +00:00
}
} ) ;
} ) ;
2010-12-16 14:28:49 +00:00
diaDiv . dialog ( {
modal : true ,
2011-01-11 09:22:45 +00:00
width : 620 ,
height : 600 ,
2010-12-16 14:28:49 +00:00
close : function ( event , ui ) {
$ ( this ) . remove ( ) ;
} ,
buttons : {
cancel : function ( ) {
$ ( this ) . dialog ( 'close' ) ;
} ,
ok : function ( ) {
2010-12-27 09:02:40 +00:00
var newResp = new Object ( ) ;
var oldResp = new Object ( ) ;
var oldString = '' ;
var newString = '' ;
//get the old seelected responses
var conditionName = $ ( this ) . find ( '#mkAssCond :checked' ) . attr ( 'value' ) ;
if ( ! conditionName ) {
return ;
}
var temp = $ ( this ) . find ( '#selectedResp' ) . html ( ) ;
if ( '' == temp ) {
return ;
}
var tempArray = temp . substr ( 1 ) . split ( ';' ) ;
for ( var i in tempArray ) {
oldResp [ tempArray [ i ] ] = 1 ;
}
//get the new selected responses
$ ( this ) . find ( '#mkAssResp input:checked' ) . each ( function ( ) {
var respName = $ ( this ) . attr ( 'value' ) ;
newResp [ respName ] = 1 ;
} ) ;
for ( var i in newResp ) {
2011-04-16 14:40:15 +00:00
if ( oldResp [ i ] ) {
2010-12-27 09:02:40 +00:00
delete oldResp [ i ] ;
delete newResp [ i ] ;
}
}
//add the response which are delete.
for ( var i in oldResp ) {
oldString += ',"' + i + '"' ;
}
2011-04-16 14:40:15 +00:00
if ( '' != oldString ) {
2010-12-27 09:02:40 +00:00
oldString = oldString . substr ( 1 ) ;
}
//add the response which are new add
for ( var i in newResp ) {
newString += ',"' + i + '"' ;
}
if ( '' != newString ) {
newString = newString . substr ( 1 ) ;
}
2011-04-16 14:40:15 +00:00
if ( ( '' != oldString ) || ( '' != newString ) ) {
2010-12-27 09:02:40 +00:00
$ ( '#rmcEventStatus' ) . empty ( ) . append ( 'Create/Remove associations' ) . append ( createLoader ( ) ) ;
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'webrun' ,
tgt : '' ,
args : 'mkcondresp;"' + conditionName + '";+' + newString + ':-' + oldString ,
msg : ''
} ,
success : function ( data ) {
$ ( '#rmcEventStatus' ) . empty ( ) . append ( data . rsp [ 0 ] ) ; ;
}
} ) ;
}
2010-12-16 14:28:49 +00:00
$ ( this ) . dialog ( 'close' ) ;
}
}
} ) ;
}
2010-12-23 03:03:19 +00:00
/ * *
* show the make condition dialogue
*
* @ param
* @ return
*
* /
function chCondScopeDia ( ) {
2011-01-11 09:22:45 +00:00
var diaDiv = $ ( '<div title="Change Condition Scope" id="chScopeDiaDiv" class="tab"></div>' ) ;
var tableContent = '<center><table id="changeScopeTable" ><thead><tr><th>Condition Name</th><th>Group Name</th></tr></thead>' ;
2010-12-25 02:17:00 +00:00
2011-01-11 09:22:45 +00:00
tableContent += '<tbody><tr><td id="changePreCond">' ;
2010-12-25 02:17:00 +00:00
//add the conditions into fieldset
if ( '' == globalCondition ) {
2011-01-11 09:22:45 +00:00
tableContent += 'Getting predefined conditions, open this dislogue later.' ;
2010-12-25 02:17:00 +00:00
}
else {
2011-01-11 09:22:45 +00:00
tableContent += createConditionTd ( globalCondition ) ;
}
tableContent += '</td><td id="changeGroup">' ;
//add the groups into table
var groups = $ . cookie ( 'groups' ) . split ( ',' ) ;
for ( var i in groups ) {
tableContent += '<input type="checkbox" value="' + groups [ i ] + '">' + groups [ i ] + '<br/>' ;
2010-12-25 02:17:00 +00:00
}
2011-01-11 09:22:45 +00:00
tableContent += '</td></tr></tbody></table></center>' ;
diaDiv . append ( tableContent ) ;
//fieldset to show status
diaDiv . append ( '<fieldset id="changeStatus"></fieldset>' ) ;
2010-12-25 02:17:00 +00:00
//create the dislogue
2010-12-23 03:03:19 +00:00
diaDiv . dialog ( {
2011-01-11 09:22:45 +00:00
modal : true ,
width : 500 ,
height : 600 ,
2010-12-25 02:17:00 +00:00
close : function ( event , ui ) {
2010-12-23 03:03:19 +00:00
$ ( this ) . remove ( ) ;
} ,
buttons : {
cancel : function ( ) {
$ ( this ) . dialog ( 'close' ) ;
} ,
ok : function ( ) {
$ ( '#changeStatus' ) . empty ( ) . append ( '<legend>Status</legend>' ) ;
var conditionName = $ ( '#changePreCond :checked' ) . attr ( 'value' ) ;
var groupName = '' ;
$ ( '#changeGroup :checked' ) . each ( function ( ) {
if ( '' == groupName ) {
groupName += $ ( this ) . attr ( 'value' ) ;
}
else {
groupName += ',' + $ ( this ) . attr ( 'value' ) ;
}
} ) ;
if ( undefined == conditionName ) {
$ ( '#changeStatus' ) . append ( 'Please select conditon.' ) ;
return ;
}
if ( '' == groupName ) {
$ ( '#changeStatus' ) . append ( 'Please select group.' ) ;
return ;
}
$ ( '#changeStatus' ) . append ( createLoader ( ) ) ;
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'webrun' ,
tgt : '' ,
args : 'mkcondition;change;' + conditionName + ';' + groupName ,
msg : ''
} ,
success : function ( data ) {
$ ( '#changeStatus img' ) . remove ( ) ;
if ( - 1 != data . rsp [ 0 ] . indexOf ( 'Error' ) ) {
$ ( '#changeStatus' ) . append ( data . rsp [ 0 ] ) ;
}
else {
$ ( '#rmcEventStatus' ) . empty ( ) . append ( data . rsp [ 0 ] ) ;
$ ( '#chScopeDiaDiv' ) . remove ( ) ;
}
}
} ) ;
}
}
} ) ;
}
/ * *
* show the make response dialogue
*
* @ param
* @ return
*
* /
function mkResponseDia ( ) {
var diaDiv = $ ( '<div title="Make Response"><div>' ) ;
diaDiv . append ( 'under construction.' ) ;
diaDiv . dialog ( {
modal : true ,
width : 400 ,
close : function ( event , ui ) {
$ ( this ) . remove ( ) ;
} ,
buttons : {
cancel : function ( ) {
$ ( this ) . dialog ( 'close' ) ;
} ,
ok : function ( ) {
$ ( this ) . dialog ( 'close' ) ;
}
}
} ) ;
2010-12-25 02:17:00 +00:00
}
2010-12-28 09:34:44 +00:00
/ * *
* start the condition and response associations
*
* @ param
* @ return
*
* /
2011-01-11 09:22:45 +00:00
function startStopCondRespDia ( ) {
var diaDiv = $ ( '<div title="Start/Stop Association" id="divStartStopAss" class="tab"><div>' ) ;
2010-12-28 09:34:44 +00:00
diaDiv . append ( 'Getting conditions' ) . append ( createLoader ( ) ) ;
2011-01-11 09:22:45 +00:00
if ( '' == globalCondition ) {
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'webrun' ,
tgt : '' ,
args : 'lscondition' ,
msg : ''
} ,
success : function ( data ) {
if ( data . rsp [ 0 ] ) {
globalcondition = data . rsp [ 0 ] ;
$ ( '#divStartStopAss' ) . empty ( ) . append ( createAssociationTable ( globalCondition ) ) ;
$ ( '#divStartStopAss' ) . dialog ( "option" , "position" , 'center' ) ;
}
else {
$ ( '#divStartStopAss' ) . empty ( ) . append ( 'There is not condition.' ) ;
}
2010-12-28 09:34:44 +00:00
}
2011-01-11 09:22:45 +00:00
} ) ;
}
else {
diaDiv . empty ( ) . append ( createAssociationTable ( globalCondition ) ) ;
}
2010-12-28 09:34:44 +00:00
diaDiv . dialog ( {
modal : true ,
width : 570 ,
2011-01-11 09:22:45 +00:00
height : 600 ,
2010-12-28 09:34:44 +00:00
close : function ( event , ui ) {
$ ( this ) . remove ( ) ;
} ,
buttons : {
2011-01-11 09:22:45 +00:00
close : function ( ) {
2010-12-28 09:34:44 +00:00
$ ( this ) . dialog ( 'close' ) ;
2011-01-12 05:54:46 +00:00
}
}
} ) ;
$ ( '#divStartStopAss button' ) . bind ( 'click' , function ( ) {
var operationType = '' ;
var conditionName = $ ( this ) . attr ( 'name' ) ;
if ( 'Start' == $ ( this ) . html ( ) ) {
operationType = 'start' ;
2010-12-28 09:34:44 +00:00
}
2011-01-12 05:54:46 +00:00
else {
operationType = 'stop' ;
}
$ ( this ) . parent ( ) . prev ( ) . empty ( ) . append ( createLoader ( ) ) ;
$ ( '#divStartStopAss' ) . dialog ( 'option' , 'disabled' , true ) ;
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'webrun' ,
tgt : '' ,
args : operationType + 'condresp;' + conditionName ,
msg : operationType + ';' + conditionName
} ,
success : function ( data ) {
var conditionName = '' ;
var newOperationType = '' ;
var associationStatus = '' ;
var backgroudColor = '' ;
if ( 'start' == data . msg . substr ( 0 , 5 ) ) {
newOperationType = 'Stop' ;
conditionName = data . msg . substr ( 6 ) ;
associationStatus = 'Monitored' ;
backgroudColor = '#ffffff' ;
}
else {
newOperationType = 'Start' ;
conditionName = data . msg . substr ( 5 ) ;
associationStatus = 'Not Monitored' ;
backgroudColor = '#fffacd' ;
}
var button = $ ( '#divStartStopAss button[name="' + conditionName + '"]' ) ;
if ( data . rsp [ 0 ] ) {
$ ( '#rmcEventStatus' ) . empty ( ) . append ( 'Getting associations\' status' ) . append ( createLoader ( ) ) ;
$ ( '#rmcEventButtons' ) . hide ( ) ;
button . html ( newOperationType ) ;
button . parent ( ) . prev ( ) . html ( associationStatus ) ;
button . parent ( ) . parent ( ) . css ( 'background-color' , backgroudColor ) ;
globalCondition = '' ;
getConditions ( ) ;
}
else {
button . html ( 'Error' ) ;
}
$ ( '#divStartStopAss' ) . dialog ( 'option' , 'disabled' , false ) ;
}
} ) ;
2010-12-28 09:34:44 +00:00
} ) ;
}
/ * *
* stop the condition and response associations
*
* @ param
* @ return
*
* /
function stopCondRespDia ( ) {
var diaDiv = $ ( '<div title="Stop Association" id="stopAss"><div>' ) ;
diaDiv . append ( 'Getting conditions' ) . append ( createLoader ( ) ) ;
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'webrun' ,
tgt : '' ,
args : 'lscondition;-m' ,
msg : ''
} ,
success : function ( data ) {
if ( data . rsp [ 0 ] ) {
$ ( '#stopAss' ) . empty ( ) . append ( createConditionTable ( data . rsp [ 0 ] ) ) ;
$ ( '#stopAss' ) . dialog ( "option" , "position" , 'center' ) ;
}
else {
$ ( '#stopAss' ) . empty ( ) . append ( 'There is not monitored condition.' ) ;
}
}
} ) ;
diaDiv . dialog ( {
modal : true ,
width : 570 ,
close : function ( event , ui ) {
$ ( this ) . remove ( ) ;
} ,
buttons : {
cancel : function ( ) {
$ ( this ) . dialog ( 'close' ) ;
} ,
stop : function ( ) {
var conditionName = $ ( '#stopAss :checked' ) . attr ( 'value' ) ;
if ( ! conditionName ) {
alert ( 'Select condition name please.' ) ;
return ;
}
$ ( '#rmcEventStatus' ) . empty ( ) . append ( 'Stoping monitor on ' + conditionName ) . append ( createLoader ( ) ) ;
$ . ajax ( {
url : 'lib/cmd.php' ,
dataType : 'json' ,
data : {
cmd : 'webrun' ,
tgt : '' ,
args : 'stopcondresp;' + conditionName ,
msg : ''
} ,
success : function ( data ) {
$ ( '#rmcEventStatus' ) . empty ( ) . append ( data . rsp [ 0 ] ) ;
}
} ) ;
$ ( this ) . dialog ( 'close' ) ;
}
}
} ) ;
}
2010-12-25 02:17:00 +00:00
/ * *
* create the condition table for dialogue
*
* @ param
* @ return
*
* /
2011-01-11 09:22:45 +00:00
function createConditionTd ( cond ) {
2010-12-25 02:17:00 +00:00
var conditions = cond . split ( ';' ) ;
var name = '' ;
2011-01-11 09:22:45 +00:00
var showStr = '' ;
2010-12-25 02:17:00 +00:00
for ( var i in conditions ) {
name = conditions [ i ] ;
2011-01-11 09:22:45 +00:00
//because there is status and quotation marks in name, so we must delete the status and quotation marks
name = name . substr ( 1 , name . length - 6 ) ;
showStr += '<input type="radio" name="preCond" value="' + name + '">' + name + '<br/>' ;
}
return showStr ;
}
/ * *
* create the association table for dialogue , which show the status
* and start / stop associations
*
* @ param
* @ return
*
* /
function createAssociationTable ( cond ) {
var conditions = cond . split ( ';' ) ;
var name = '' ;
var tempLength = '' ;
var tempStatus = '' ;
var showStr = '<center><table><thead><tr><th>Condition Name</th><th>Status</th><th>Start/Stop</th></tr></thead>' ;
showStr += '<tbody>' ;
2011-04-16 14:40:15 +00:00
for ( var i in conditions ) {
2011-01-11 09:22:45 +00:00
name = conditions [ i ] ;
tempLength = name . length ;
tempStatus = name . substr ( tempLength - 3 ) ;
name = name . substr ( 1 , tempLength - 6 ) ;
if ( 'Not' == tempStatus ) {
2011-01-12 05:54:46 +00:00
showStr += '<tr style="background-color:#fffacd;"><td>' + name + '</td><td>Not Monitored</td>' ;
showStr += '<td><button id="button" name="' + name + '">Start</button></td>' ;
2010-12-25 02:17:00 +00:00
}
else {
2011-01-12 05:54:46 +00:00
showStr += '<tr><td>' + name + '</td><td>Monitored</td>' ;
showStr += '<td><button id="button" name="' + name + '">Stop</button></td>' ;
2010-12-25 02:17:00 +00:00
}
2011-01-11 09:22:45 +00:00
showStr += '</tr>' ;
2010-12-25 02:17:00 +00:00
}
2011-01-11 09:22:45 +00:00
showStr += '<tbody></table></center>' ;
2010-12-25 02:17:00 +00:00
return showStr ;
2010-08-04 08:49:20 +00:00
}