mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-10-31 11:22:27 +00:00 
			
		
		
		
	Follow Vallard's advice, I moved all the <html> codes to the new file" lib/monitor_display.php"; now, the file "monitor.php" only contains <?php ?> and jQuery code.
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3893 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		
							
								
								
									
										101
									
								
								xCAT-UI/lib/monitor_display.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										101
									
								
								xCAT-UI/lib/monitor_display.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,101 @@ | ||||
| <?php | ||||
| /*  | ||||
|  * All the <html> code related with monitor interface is put here. | ||||
|  */ | ||||
| function displayMapper_mon($mapper) | ||||
| { | ||||
|     //display the Mapper for monitoring interface; | ||||
|     //the argument $mapper is an array | ||||
|     //$mapper = { | ||||
|     //  "home" => "main.php", | ||||
|     //  "Monitor" => "monitor/monlist.php", | ||||
|     //}; | ||||
|     echo "<div class='mapper' align='left'>"; | ||||
|     echo "<span>"; | ||||
|     foreach ($mapper as $key => $value) { | ||||
|         echo "<a href='#' onclick='loadMainPage(\"$value\")'>$key</a>"; | ||||
|         echo "/"; | ||||
|     } | ||||
|     echo "</span></div>"; | ||||
| } | ||||
|  | ||||
| #displayMonitorLists() will generate all the monitoring plug-ins, | ||||
| #the user can select the plug-ins he wants to operate on, | ||||
| #and press the "Next" button; | ||||
|  function displayMonitorLists() { | ||||
|      #The command "monls -a" is used to get the monitoring plug-ins list | ||||
|      $xml = docmd("monls"," ", array('-a')); | ||||
|      if(getXmlErrors($xml,$errors)) { | ||||
|          echo "<p class=Error>",implode(' ', $errors), "</p>"; | ||||
|          exit; | ||||
|      } | ||||
|      #then, parse the xml data | ||||
|      $ooe = 0; | ||||
|      $line = 0; | ||||
|      foreach($xml->children() as $response) foreach($response->children() as $data) { | ||||
|          list($name, $stat, $nodemonstatus) = preg_split("/\s+/", $data); | ||||
|          $ooe = $ooe%2; | ||||
|          echo "<tr class='ListLine$ooe' id='row$line'>"; | ||||
|          echo "<td><input type='radio' name='plugins' value='$name' /></td>"; | ||||
|          echo "<td id='$line-0'><a class='description' href='#'>$name</a></td>"; | ||||
|          echo "<td id='$line-1'>$stat</td>"; | ||||
|          if(isset($nodemonstatus)) { echo "<td id='$line-2'>Yes</td>";}else {echo "<td id='$line-2'>No</td>";} | ||||
|          echo "   </tr>"; | ||||
|          $ooe++; | ||||
|          $line++; | ||||
|          //echo "<tr><td><input type='checkbox' />$name</td><td>$stat</td><td><a onclick='LoadMainPage("main.php")'>$name</a></td></tr>"; | ||||
|      } | ||||
|      return 0; | ||||
|  } | ||||
|  | ||||
| function displayTips($tips) | ||||
| { | ||||
|     //to tell the user how to operate on the current web page | ||||
|     //the argument $tips is an array like this: | ||||
|     //{ | ||||
|     //  "Click the name of each plugin, you can get the plugin's description.", | ||||
|     //  "You can also select one plugin, then you can set node/application status monitoring for the selected plugin.", | ||||
|     //} | ||||
|     echo '<div><ul align="left" id="tips"><h3>Tips:</h3>'; | ||||
|     foreach ($tips as $tip) { | ||||
|         echo "<li>$tip</li>"; | ||||
|         echo "\n"; | ||||
|     } | ||||
|     echo '</ul></div>'; | ||||
|     return 0; | ||||
| } | ||||
|  | ||||
| function displayDialog($id, $title) | ||||
| { | ||||
|     //add one new <div> to display jQuery dialog; | ||||
|     echo "<div id=$id title=\"$title\"></div>"; | ||||
|     return 0; | ||||
| } | ||||
|  | ||||
| function displayMonTable() | ||||
| { | ||||
|     //create one table to display the monitoring plugins' list | ||||
|     echo '<div style="margin-right:30px;width:auto;margin-left:30px;">'; | ||||
|     echo <<<TOS1 | ||||
| <table id="tabTable" class="tabTable" cellspacing="1"> | ||||
|     <thead> | ||||
|         <tr class="colHeaders"> | ||||
|             <td></td> | ||||
|             <td>Plug-in Name</td> | ||||
|             <td>Status</td> | ||||
|             <td>Node Status Monitoring</td> | ||||
|         </tr> | ||||
|     </thead> | ||||
| TOS1; | ||||
|     echo '<tbody id="monlist">'; | ||||
|     displayMonitorLists(); | ||||
|     echo "</tbody></table></div>"; | ||||
|     return 0; | ||||
| } | ||||
|  | ||||
| function displayStatus() | ||||
| { | ||||
|     //tell the user that the current interface is not done yet... | ||||
|     echo "<div><p>This interface is still under development -use accordingly.</p></div>"; | ||||
| } | ||||
| ?> | ||||
| @@ -3,35 +3,8 @@ if(!isset($TOPDIR)) { $TOPDIR="/opt/xcat/ui";} | ||||
|  require_once "$TOPDIR/lib/security.php"; | ||||
|  require_once "$TOPDIR/lib/functions.php"; | ||||
|  require_once "$TOPDIR/lib/display.php"; | ||||
|  require_once "$TOPDIR/lib/monitor_display.php"; | ||||
|  | ||||
| #displayMonitorLists() will generate all the monitoring plug-ins, | ||||
| #the user can select the plug-ins he wants to operate on, | ||||
| #and press the "Next" button; | ||||
|  function displayMonitorLists() { | ||||
|      #The command "monls -a" is used to get the monitoring plug-ins list | ||||
|      $xml = docmd("monls"," ", array('-a')); | ||||
|      if(getXmlErrors($xml,$errors)) { | ||||
|          echo "<p class=Error>",implode(' ', $errors), "</p>"; | ||||
|          exit; | ||||
|      } | ||||
|      #then, parse the xml data | ||||
|      $ooe = 0; | ||||
|      $line = 0; | ||||
|      foreach($xml->children() as $response) foreach($response->children() as $data) { | ||||
|          list($name, $stat, $nodemonstatus) = preg_split("/\s+/", $data); | ||||
|          $ooe = $ooe%2; | ||||
|          echo "<tr class='ListLine$ooe' id='row$line'>"; | ||||
|          echo "<td><input type='radio' name='radio' id='radio_$name' class='r_plugin' /></td>"; | ||||
|          echo "<td id='$line-0'><a class='description' href='#'>$name</a></td>"; | ||||
|          echo "<td id='$line-1'>$stat</td>"; | ||||
|          if(isset($nodemonstatus)) { echo "<td id='$line-2'>Yes</td>";}else {echo "<td id='$line-2'>No</td>";} | ||||
|          echo "   </tr>"; | ||||
|          $ooe++; | ||||
|          $line++; | ||||
|          //echo "<tr><td><input type='checkbox' />$name</td><td>$stat</td><td><a onclick='LoadMainPage("main.php")'>$name</a></td></tr>"; | ||||
|      } | ||||
|      return 0; | ||||
|  } | ||||
| ?> | ||||
| <script type="text/javascript"> | ||||
| $(function(){ | ||||
| @@ -45,36 +18,23 @@ $(function(){ | ||||
|         }) | ||||
|     }); | ||||
| }); | ||||
| function clickNext() | ||||
| { | ||||
|     //get the user's selection, and load the web page named "stat_mon.php"; | ||||
|     var item = $('input[@name=plugins][@checked]').val(); | ||||
|     if(item){ | ||||
|         loadMainPage('monitor/stat_mon.php?name='+item); | ||||
|     } | ||||
| } | ||||
| </script> | ||||
| <div class='mapper' align="left"> | ||||
| 	<span> | ||||
| 		<a href='#' onclick='loadMainPage("main.php")'>home</a> / | ||||
| 		<a href='#' onclick='loadMainPage("monitor/monlist.php")'>Monitor</a> | ||||
| 	</span> | ||||
| </div> | ||||
| <div> | ||||
| <ul align="left" id="tips"> | ||||
|     <h3>Tips:</h3> | ||||
| <li>Click the name of each plugin, you can get the plugin's description.</li> | ||||
| <li>You can also select one plugin, then you can set node/application status monitoring for the selected plugin</li> | ||||
| </ul> | ||||
| </div> | ||||
| <div style="margin-right:30px;width:auto;margin-left:30px;"> | ||||
|     <table id="tabTable" class="tabTable" cellspacing="1"> | ||||
|     <thead> | ||||
|         <tr class="colHeaders"> | ||||
|             <td></td> | ||||
|             <td>Plug-in Name</td> | ||||
|             <td>Status</td> | ||||
|             <td>Node Status Monitoring</td> | ||||
|         </tr> | ||||
|     </thead> | ||||
|     <tbody id="monlist"> | ||||
|     <?php displayMonitorLists();?> | ||||
|     </tbody> | ||||
| </table> | ||||
|     <div id="status_mon" display="none"></div> | ||||
| </div> | ||||
| <div id="dialog" title="Plug-in Description"></div> | ||||
| <?php | ||||
| displayMapper_mon(array('home'=>'main.php', 'monitor'=>'monitor/monlist.php')); | ||||
|  | ||||
| <div><?php insertButtons(array('label' => 'Next', 'id'=> 'next', 'onclick' => 'loadMainPage("monitor/stat_mon.php")'))?></div> | ||||
| displayTips(array("Click the name of each plugin, you can get the plugin's description.", | ||||
|         "You can also select one plugin, then you can set node/application status monitoring for the selected plugin")); | ||||
|  | ||||
| displayMonTable(); | ||||
|  | ||||
| displayDialog("dialog", "Plug-in Description"); | ||||
| insertButtons(array('label' => 'Next', 'id'=> 'next', 'onclick'=>'clickNext()')); | ||||
| ?> | ||||
|   | ||||
| @@ -3,5 +3,14 @@ | ||||
|  * This web page is for "Node status Monitoring" and "Application Status Monitioring", | ||||
|  * The user can enable/disable "Node/Application Status Monitoring" from this page. | ||||
|  */ | ||||
| echo "<p>This page is under development.</p>"; | ||||
| if(!isset($TOPDIR)) { $TOPDIR="/opt/xcat/ui";} | ||||
|  | ||||
| require_once "$TOPDIR/lib/security.php"; | ||||
| require_once "$TOPDIR/lib/functions.php"; | ||||
| require_once "$TOPDIR/lib/display.php"; | ||||
| require_once "$TOPDIR/lib/monitor_display.php"; | ||||
|  | ||||
|  | ||||
| displayStatus(); | ||||
|  | ||||
| ?> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user