diff --git a/xCAT-UI/css/monitor.css b/xCAT-UI/css/monitor.css index e69de29bb..3b01e044c 100644 --- a/xCAT-UI/css/monitor.css +++ b/xCAT-UI/css/monitor.css @@ -0,0 +1,128 @@ +/*The css style for the new monlist web page*/ +.pluginstat +{ + position: relative; + width: 170px; + height: 48px; + float: left; + padding: 5px; +} + +.pluginstat .lef +{ + padding: 8px 0px 8px 0px; + width: 16px; + height: 16px; + position: relative; + float: left; + display: inline; +} +.pluginstat .mid +{ + font-size: 1em; + float: left; + position: relative; + display: block; + color: black; +} + +.pluginstat .rig +{ + width: 32px; + height: 32px; + float: right; + background-image: url("../img/monplugin.png"); +} + +/*The list of monitor plugins*/ +#plist +{ + float: left; + width: 180px; + padding-left: 15px; +} + +#settings +{ + display: block; + width: 725px; + float: left; + text-align: left; + font-size: 1em; +} + +.fg-button { + outline: 0; + margin: 0 4px 0 0; + padding: .4em 1em; + text-decoration:none !important; + cursor:pointer; + position: relative; + text-align: center; +} + +.fg-buttonset {float: left;} +.fg-buttonset-single .fg-button {margin-right: -3px} + +#nrtree-input { + float: left; + width: 25%; + min-width: 125px; + min-height: 255px; + border-right: 1px solid orange; + z-index: 1; +} + +#stat1 { + padding-left: 10px; + padding-right: 10px; + width: 65%; + float: right; +} + +fieldset { + padding: 0 15px 3em; + border: 0; +} + +.custom-radio { position: relative;} + +/* input, label positioning */ +.custom-radio input { + position: absolute; + left: 2px; + top: 3px; + margin: 0; + z-index: 0; +} +.custom-radio label { + display: block; + position: relative; + z-index: 1; + font-size: 1.3em; + padding-right: 1em; + line-height: 1; + padding: .5em 0 .5em 30px; + margin: 0 0 .3em; + cursor: pointer; +} + +.custom-radio label {background: url(../img/radiobutton.gif) no-repeat;} + +.custom-radio label { + background-position: -10px -14px; +} + +.custom-radio label.hover, +.custom-radio label.focus { + background-position: -10px -114px; +} + +.custom-radio label.checked { + background-position: -10px -214px; +} + +.custom-radio label.focus { + outline: 1px dotted #ccc; +} + diff --git a/xCAT-UI/js/loading.js b/xCAT-UI/js/loading.js index 1b2d74e80..28e44837c 100644 --- a/xCAT-UI/js/loading.js +++ b/xCAT-UI/js/loading.js @@ -79,7 +79,7 @@ LoadBar.prototype.loaded = function(file) { //load the reset button to try one more time! //$(document).ready(function () { injs(); - document.getElementById("wrapper").style.display = "none"; + //document.getElementById("wrapper").style.display = "none"; //}); } }; @@ -105,7 +105,8 @@ var xStart = function(){ myBar.addScript("jquery.tablesorter.js"); myBar.addScript("jquery.flot.js"); myBar.addScript("excanvas.js"); - myBar.addScript("noderangetree.js"); + myBar.addScript("noderangetree.js"); + myBar.addScript("monitor.js"); myBar.addScript("xcat.js"); myBar.addScript("xcatauth.js"); myBar.addScript("config.js"); diff --git a/xCAT-UI/js/monitor.js b/xCAT-UI/js/monitor.js new file mode 100644 index 000000000..3e2fc9937 --- /dev/null +++ b/xCAT-UI/js/monitor.js @@ -0,0 +1,134 @@ + + +jQuery.fn.customInput = function(){//from http://www.filamentgroup.com/examples/customInput/customInput.jquery.js + $(this).each(function(i){ + if($(this).is('[type=checkbox],[type=radio]')){ + var input = $(this); + + // get the associated label using the input's id + var label = $('label[for='+input.attr('id')+']'); + + //get type, for classname suffix + var inputType = (input.is('[type=checkbox]')) ? 'checkbox' : 'radio'; + + // wrap the input + label in a div + $('
').insertBefore(input).append(input, label); + + // find all inputs in this set using the shared name attribute + var allInputs = $('input[name='+input.attr('name')+']'); + + // necessary for browsers that don't support the :hover pseudo class on labels + label.hover( + function(){ + $(this).addClass('hover'); + if(inputType == 'checkbox' && input.is(':checked')){ + $(this).addClass('checkedHover'); + } + }, + function(){ $(this).removeClass('hover checkedHover'); } + ); + + //bind custom event, trigger it, bind click,focus,blur events + input.bind('updateState', function(){ + if (input.is(':checked')) { + if (input.is(':radio')) { + allInputs.each(function(){ + $('label[for='+$(this).attr('id')+']').removeClass('checked'); + }); + }; + label.addClass('checked'); + } + else { label.removeClass('checked checkedHover checkedFocus'); } + + }) + .trigger('updateState') + .click(function(){ + $(this).trigger('updateState'); + }) + .focus(function(){ + label.addClass('focus'); + if(inputType == 'checkbox' && input.is(':checked')){ + $(this).addClass('checkedFocus'); + } + }) + .blur(function(){ label.removeClass('focus checkedFocus'); }); + } + }); +}; + +function monPluginSetStat() +{ + $('.fg-button:not(.ui-state-disabled)') + .hover( + function() { + $(this).addClass('ui-state-hover'); + }, + function() { + $(this).removeClass('ui-state-hover'); + } + ) + .click( + function() { +// if($(this).hasClass("ui-state-active")) { + var plugin=$('.pluginstat.ui-state-active').attr('id'); + var todo = $(this).html(); + //$("#settings").tabs('select',2); + //for the noderange, we have to check the",implode(' ',$errors), "
"; + $xml = docmd("monls", "", array('-a')); + if(getXmlErrors($xml, $errors)) { + echo "", implode(' ', $errors), "
"; exit; } - #then, parse the xml data - foreach($xml->children() as $response) foreach($response->children() as $data) { - list($n, $stat, $nodemonstatus) = preg_split("/\s+/",$data); - if(isset($nodemonstatus)) { - $ns = "Enabled"; - }else { - $ns = "Disabled"; - } + + foreach($xml->children() as $response) foreach ($response->children() as $data) { + list($name, $stat, $nodemon) = preg_split("/\s+/", $data); + //create .pluginstat class for each plugin + echo "",implode(' ', $errors), "
"; - exit; - } -} - -echo "successful"; -?> diff --git a/xCAT-UI/monitor/monlist.php b/xCAT-UI/monitor/monlist.php index 8247318a8..432f6c506 100644 --- a/xCAT-UI/monitor/monlist.php +++ b/xCAT-UI/monitor/monlist.php @@ -1,22 +1,83 @@ 'main.php', 'monitor' =>'')); +displayMapper(array('home'=>'main.php', 'new_monitor' =>'')); -displayTips(array("Click the name of each plugin, you can get the plugin's description.", - "Select one plugin, choose the options for set up monitoring ", - "Click the button \"Start\", \"Stop\" or \"Restart\" to setup monitoring plugin")); +?> + -?> \ No newline at end of file +All the options for configuration are here.
+//choose the options to update them
+// +// +//TOS11; + echo "Press the following buttons to enable/disable the settings
+In order to make it effect, turn to the "Enable/Disable" tab for the plugin
+monls failed: ", implode(' ',$errors), "
\n"; + exit; + } + + + $information = ""; + foreach ($xml->children() as $response) foreach ($response->children() as $data) { + $information .="$data
"; + } + echo $information; +} + +/* + * changePluginStat($name) + * which is used to enable/disable the selected plugin, + * and which return whether they're sucessful or not + */ +function showPluginStat($name, $opt) +{ + //display the nrtree here + //let the user choose node/noderange to enable/disable monitor plugin + echo "The $name Plugin is in Disabled status
"; + echo "You can Press the Following button to change its status
"; + echo "Select the noderange from the right tree
"; + echo "OR: you can type the noderange in the following area
"; + echo "When you are trying to enable the plugin
would you like to support node status monitoring?
"; + insertRadioBtn(); + insertButtonSet("Enable","Disable", 0); + }else if($opt == 'disable') { + //monstop + //mondecfg + echo "The $name Plugin is in Enabled status
"; + echo "You can Press the Following button to change its status
"; + echo "Select the noderange from the right tree
"; + echo "OR: you can type the noderange in the following area
"; + echo "When you are trying to enable the plugin
would you like to support node status monitoring?
"; + insertRadioBtn(); + insertButtonSet("Enable","Disable", 1); + } + echo ""; +} + +function insertRadioBtn() +{ + //to provide the choose to support "-n"(node status monitoring) +echo <<"; -echo $information; -echo "
"; -?> - diff --git a/xCAT-UI/monitor/setup.php b/xCAT-UI/monitor/setup.php index 0702d1e71..7a5391e85 100644 --- a/xCAT-UI/monitor/setup.php +++ b/xCAT-UI/monitor/setup.php @@ -2,7 +2,7 @@ /* * setup.php - * perform the "monstart", "monadd" and "monstop" actions for selected monitoring plugins + * to perform the "monstart" and "monstop" actions for the monitoring plugins */ if(!isset($TOPDIR)) { $TOPDIR="..";} @@ -14,82 +14,119 @@ require_once "$TOPDIR/lib/monitor_display.php"; $name = $_REQUEST['name']; $action = $_REQUEST['action']; -//read the "monitoring" table to see whether node status monitoring is enable or not -//$xml = docmd("webrun", "", array("gettab name=$name monitoring.nodestatmon")); -//if(getXmlErrors($xml, $errors)) { -// echo "",implode(' ', $errors), "
"; -// exit; -//} -// -//foreach($xml->children() as $response) foreach($response->children() as $data) -//{ -// $nodemonstat = $data; -//} -switch($action) { - case "stop": - monstop($name); - break; - case "restart": - monrestart($name); - break; - case "start": - monstart($name); - break; - default: - break; -} +$nm = $_REQUEST['nm'];//node status monitoring: yes or no +$noderange = $_REQUEST['nr']; -function monstop($plugin) -{ - $xml = docmd("monstop", "", array("$plugin","-r")); - return 0; -} - -function monrestart($plugin) -{ - $xml = docmd("monstop", "", array("$plugin", "-r")); +if($action == "Disable") { + //FIXIT: it seems rmcmon has sth wrong with monstop + //The var $noderange can't work + $xml = docmd("monstop", " ", array("$name", "$noderange" , "-r")); if(getXmlErrors($xml, $errors)) { echo "",implode(' ', $errors), "
"; exit; } - $xml = docmd("moncfg", "", array("$plugin", "-r")); + $xml = docmd("mondecfg", " ", array("$name", "$noderange")); if(getXmlErrors($xml, $errors)) { - echo "",implode(' ', $errors), "
"; + echo "", implode(' ', $errors), "
"; exit; } - - $xml = docmd("monstart", "", array("$plugin", "-r")); - return 0; -} - -function monstart($plugin) -{ - //Before running "monstart", the command "monls" is used to check - $xml = docmd("monls","", NULL); + echo "successful"; +}else if($action == "Enable") { + //at first, check "-n" + if($nm == "yes") { + $xml=docmd("monrm", "", array("$name")); + $xml = docmd("monadd", "", array("$name", "-n")); + } else if($nm == "no") { + $xml = docmd("monrm", "", array("$name")); + $xml = docmd("monadd", "", array("$name")); + } + //then, moncfg + $xml = docmd("moncfg", " ", array("$name", "$noderange")); if(getXmlErrors($xml, $errors)) { - echo "",implode(' ', $errors), "
"; + echo "", implode(' ', $errors), "
"; exit; } - $has_plugin = false; - if(count($xml->children()) != 0) { - foreach($xml->children() as $response) foreach($response->children() as $data) { - $arr = preg_split("/\s+/", $data); - if($arr[0] == $plugin) { - $has_plugin = true; - } - } - } - if($has_plugin == false) { - //if $has_plugin == false, that means the plugin is not added into the monitoring table - $xml = docmd("monadd",'', array("$plugin")); + //special case for rmcmon + if($name == "rmcmon") { + $xml = docmd("moncfg", " ", array("$name", "$noderange", "-r")); if(getXmlErrors($xml, $errors)) { - echo "",implode(' ', $errors), "
"; + echo "", implode(' ', $errors), "
"; exit; } } - //we have to make sure that the plugin is added in the "monitoring" table - $xml = docmd("monstart", "", array("$plugin", "-r")); - return 0; + $xml = docmd("monstart", " ", array("$name", "$noderange", "-r")); + if(getXmlErrors($xml, $errors)) { + echo "", implode(' ', $errors), "
"; + exit; + } + echo "successful"; } -?> +//switch($action) { +// case "stop": +// monstop($name); +// break; +// case "restart": +// monrestart($name); +// break; +// case "start": +// monstart($name); +// break; +// default: +// break; +//} +// +//function monstop($plugin) +//{ +// $xml = docmd("monstop", "", array("$plugin","-r")); +// return 0; +//} +// +//function monrestart($plugin) +//{ +// $xml = docmd("monstop", "", array("$plugin", "-r")); +// if(getXmlErrors($xml, $errors)) { +// echo "",implode(' ', $errors), "
"; +// exit; +// } +// $xml = docmd("moncfg", "", array("$plugin", "-r")); +// if(getXmlErrors($xml, $errors)) { +// echo "",implode(' ', $errors), "
"; +// exit; +// } +// +// $xml = docmd("monstart", "", array("$plugin", "-r")); +// return 0; +//} +// +//function monstart($plugin) +//{ +// //Before running "monstart", the command "monls" is used to check +// $xml = docmd("monls","", NULL); +// if(getXmlErrors($xml, $errors)) { +// echo "",implode(' ', $errors), "
"; +// exit; +// } +// $has_plugin = false; +// if(count($xml->children()) != 0) { +// foreach($xml->children() as $response) foreach($response->children() as $data) { +// $arr = preg_split("/\s+/", $data); +// if($arr[0] == $plugin) { +// $has_plugin = true; +// } +// } +// } +// if($has_plugin == false) { +// //if $has_plugin == false, that means the plugin is not added into the monitoring table +// $xml = docmd("monadd",'', array("$plugin")); +// if(getXmlErrors($xml, $errors)) { +// echo "",implode(' ', $errors), "
"; +// exit; +// } +// } +// //we have to make sure that the plugin is added in the "monitoring" table +// $xml = docmd("monstart", "", array("$plugin", "-r")); +// return 0; +//} +// +//?> diff --git a/xCAT-UI/monitor/stat_mon.php b/xCAT-UI/monitor/stat_mon.php deleted file mode 100644 index 01c5c033e..000000000 --- a/xCAT-UI/monitor/stat_mon.php +++ /dev/null @@ -1,20 +0,0 @@ -