Changeset 1209
- Timestamp:
- 12/15/06 08:53:06 (7 years ago)
- Location:
- ccsweb/trunk/ccs_mods/graphs
- Files:
-
- 4 deleted
- 5 edited
-
graph.tpl (deleted)
-
graphs-list.tpl (modified) (1 diff)
-
graphs.js (modified) (2 diffs)
-
graphs.php (modified) (4 diffs)
-
graphs.tpl (deleted)
-
graphs2.tpl (deleted)
-
index.php (modified) (1 diff)
-
index.tpl (modified) (1 diff)
-
num-list.tpl (deleted)
Legend:
- Unmodified
- Added
- Removed
-
ccsweb/trunk/ccs_mods/graphs/graphs-list.tpl
r1183 r1209 21 21 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 22 *} 23 <select id="graph_id" name="graph_id" >23 <select id="graph_id" name="graph_id" {if $main == "target"}disabled{/if}> 24 24 <option value=-1>All graphs</option> 25 25 {foreach from=$graphs item=graph} -
ccsweb/trunk/ccs_mods/graphs/graphs.js
r1183 r1209 22 22 */ 23 23 24 errCount=0;25 24 url = "https://" + site + "/mods/graphs/graphs.php"; 26 25 … … 29 28 '#host_id' : function(element){ 30 29 element.onchange = host_selected; 31 }, 32 '#graph_id' : function(element){ 33 element.onchange = graph_selected; 34 }, 35 '#draw' : function(element){ 36 element.onclick = draw; 37 } 30 } 38 31 }; 39 32 40 33 Behaviour.register(myrules); 41 //Behaviour.addLoadEvent(onload);42 34 43 function draw() 35 // When a new host is selected update the available graphs 36 function host_selected() 44 37 { 45 graph_id = host_id = num = -1; 46 host_ido = $("host_id"); 47 if (host_ido) 48 host_id = $F("host_id"); 38 if (document.getElementById('graph_id').disabled == true) 39 return; 40 host_id = graph_id = -1; 41 if (document.getElementById('host_id').disabled == false) 42 { 43 host_ido = $("host_id"); 44 if (host_ido) 45 host_id = $F("host_id"); 46 } 49 47 graph_ido = $("graph_id"); 50 48 if (graph_ido) 51 graph_id = $F("graph_id"); 52 numo = $("num"); 53 if (numo) 54 num = $F("num"); 55 56 // Retrieve the data for the graphs 57 pars = "do=getgraph&host_id=" + host_id + "&graph_id=" + graph_id + "&num=" + num; 58 myAjax = new Ajax.Updater({success: 'graph'}, url, 49 graph_id = $F("graph_id") 50 // Retrieve the list of available graphs for this host 51 pars = "do=listgraphs&host_id=" + host_id + "&graph_id=" + graph_id; 52 myAjax = new Ajax.Updater({success: 'graph_id-cell'}, url, 59 53 {method: 'get', parameters: pars, onFailure: reportError, 60 insertion: insertAssetList}); 61 54 insertion: insertList}); 62 55 } 63 56 64 function host_selected() 65 { 66 host_id = -1; 67 host_ido = $("host_id"); 68 if (host_ido) 69 host_id = $F("host_id"); 70 if (host_id != -1){ 71 // Retrieve the list of available graphs for this host 72 pars = "do=listgraphs&host_id=" + host_id; 73 myAjax = new Ajax.Updater({success: 'graph_id-cell'}, url, 74 {method: 'get', parameters: pars, onFailure: reportError, 75 insertion: insertAssetList}); 76 } 77 } 78 function insertAssetList(object, string) 57 // Insert new infomation into a list 58 function insertList(object, string) 79 59 { 80 60 object.innerHTML = string; 81 61 Behaviour.apply(); 82 62 } 83 function graph_selected() 84 { 85 graph_id = host_id = -1; 86 host_ido = $("host_id"); 87 if (host_ido) 88 host_id = $F("host_id"); 89 graph_ido = $("graph_id"); 90 if (graph_ido) 91 graph_id = $F("graph_id"); 92 numo = $("num"); 93 if (numo) 94 num = $F("num"); 95 if(graph_id != -1){ 96 // Retrieve the list of available numbers for this graph and host 97 pars = "do=getnumbers&host_id=" + host_id + "&graph_id=" + graph_id; 98 myAjax = new Ajax.Updater({success: 'num-cell'}, url, 99 {method: 'get', parameters: pars, onFailure: reportError, 100 insertion: insertAssetList}); 63 64 // This is done to change an image when its time has changed 65 function change_img(host, time_idel, graph_id, num, imgel) { 66 image = document.getElementById(imgel); 67 time_id = document.getElementById(time_idel).value; 68 image.src = "http://puck.crc.net.nz:6061/graphs/" + host + "/" + time_id + "/" + graph_id + "?number=" + num; 69 } 70 71 // This handles enableing and disabling of elements when radio's are changed 72 function toggle() { 73 // First fetch elements 74 mhost = document.getElementById('host'); 75 mlink = document.getElementById('link'); 76 mtarget = document.getElementById('target'); 77 mirror = document.getElementById('mirror'); 78 host = document.getElementById('host_id'); 79 link = document.getElementById('link_id'); 80 type = document.getElementById('graph_id'); 81 target = document.getElementById('target_id'); 82 if(mhost.checked) { //host is checked 83 mirror.disabled = false; 84 type.disabled = false; 85 host.disabled = false; 86 link.disabled = true; 87 target.disabled = true; 88 } else if(mlink.checked) { //link is checked 89 mirror.disabled = true; 90 mirror.checked = false; 91 type.disabled = false; 92 host.disabled = true; 93 link.disabled = false; 94 target.disabled = true; 95 96 } else if(mtarget.checked) { //target is checked 97 mirror.disabled = true; 98 mirror.checked = false; 99 type.disabled = true; 100 host.disabled = true; 101 link.disabled = true; 102 target.disabled = false; 103 101 104 } 105 // Update the graphs list 106 host_selected(); 102 107 } 103 //function onload()104 //{105 // host_selected();106 // graph_selected();107 //} -
ccsweb/trunk/ccs_mods/graphs/graphs.php
r1183 r1209 24 24 require_once("lib/ccs_init.php"); 25 25 /* Setup the bottom menu */ 26 ccs_menu_bottom_add(array(mk_menu_item("Sites", "/mods/host/site.php"), 27 mk_menu_item("Hosts", "/mods/host/host.php"), 28 mk_menu_item("Links", "/mods/host/link.php"), 29 mk_menu_item("Network Map", "/mods/host/host.php?do=map") 26 ccs_menu_bottom_add(array(mk_menu_item("Graph Viewer", "/mods/graphs/graphs.php") 30 27 )); 28 29 //This function fetches and manipulates all data for the interface 30 //but the graphs themselves which is done before this is call. 31 //It also displays the page 31 32 function display_select_graph() 32 33 { 33 34 global $smarty, $xmlrpc_conn; 34 35 35 $hosts = do_xmlrpc("getHostList", array(), $xmlrpc_conn, TRUE, FALSE); 36 if (xmlrpc_has_error($hosts)) { 37 ccs_notice("Could not retrieve host list: " . 38 xmlrpc_error_string($hosts)); 39 $hosts = array(); 36 $host_id = $host["host_id"]; 37 if ($_REQUEST["main"] != "host") 38 $host_id = -1; 39 40 $e = do_xmlrpc("getEveryThing", array($host_id), $xmlrpc_conn, TRUE, FALSE); 41 if (xmlrpc_has_error($e)) { 42 ccs_notice("Could not data from server: " . 43 xmlrpc_error_string($e)); 44 $e = array(); 40 45 } 46 $hosts = $e[0]; 47 $links = $e[1]; 48 $graphs = $e[2]; 49 $targets = $e[3]; 50 $times = $e[4]; 41 51 52 //Create arrays for host list 42 53 $ids = array(); 43 54 $names = array(); 44 55 $c = 0; 45 $ids[$i] = -1;46 $names[$c] = "Choose One";47 $c++;48 56 foreach ($hosts as $idx=>$host) { 49 57 $ids[$c] = $host["host_id"]; … … 51 59 $c++; 52 60 } 53 if ($_REQUEST["host_id"] != -1) 54 { 55 $p = array($_REQUEST["host_id"]); 56 $graphs = do_xmlrpc("getHostGraphs", $p, $xmlrpc_conn, TRUE, FALSE); 57 if (xmlrpc_has_error($graphs)) { 58 ccs_notice("Could not retrieve host's graphs: " . 59 xmlrpc_error_string($graphs)); 60 $graphs = array(); 61 } 61 62 //Create arrays for link list 63 $lids = array(); 64 $lnames = array(); 65 $c = 0; 66 foreach ($links as $idx=>$link) { 67 $lids[$c] = $link["link_id"]; 68 $lnames[$c] = $link["description"]; 69 $c++; 70 } 71 62 72 63 $smarty->assign("graphs", $graphs); 64 73 //Create arrays for target list 74 $tids = array(); 75 $tnames = array(); 76 $c = 0; 77 foreach ($targets as $idx=>$target) { 78 $tids[$c] = "{$target["host_name"]}-{$target["graph_id"]}-{$target["num"]}-{$target["ip_address"]}-{$target["description"]}"; 79 $tnames[$c] = "{$target["host_name"]} - {$target["title"]} - {$target["description"]} - {$target["ip_address"]}"; 80 $c++; 65 81 } 66 if ($_REQUEST["graph_id"] != -1) 67 { 68 $p = array($_REQUEST["host_id"], $_REQUEST["graph_id"]); 69 $nums = do_xmlrpc("getNumbers", $p, $xmlrpc_conn, TRUE, FALSE); 70 if (xmlrpc_has_error($nums)) { 71 ccs_notice("Could not retrieve numbers: " . 72 xmlrpc_error_string($nums)); 73 $nums = array(); 74 } 75 $smarty->assign("nums", $nums); 76 77 } 82 $smarty->assign("times", $times); 83 $smarty->assign("graphs", $graphs); 84 $smarty->assign("target_ids", $tids); 78 85 $smarty->assign("host_ids", $ids); 86 $smarty->assign("link_ids", $lids); 87 $smarty->assign("target_names", $tnames); 79 88 $smarty->assign("host_names", $names); 89 $smarty->assign("link_names", $lnames); 80 90 $smarty->assign("scripts", array("graphs.js")); 81 91 display_page("mods/graphs/index.tpl"); 82 92 } 93 94 /******************************************************************** 95 * Get a list graphs that is valid for a host 96 * do=listgraphs 97 * Required Parameters 98 * host_id 99 ********************************************************************/ 83 100 if ($_REQUEST["do"] == "listgraphs") { 84 101 $p = array($_REQUEST["host_id"]); … … 97 114 $smarty->assign("scripts", array("host.js")); 98 115 display_page("mods/graphs/graphs-list.tpl"); 99 116 /******************************************************************** 117 * Get the graphs for display 118 * do=listgraphs 119 * Required Parameters 120 * main 121 * Optional Parameters 122 * mirror 123 * link_id 124 * host_id 125 * graph_id 126 * target_id 127 ********************************************************************/ 100 128 }else if ($_REQUEST["do"] == "getgraph") { 101 $p = array($_REQUEST["host_id"], $_REQUEST["graph_id"]); 102 $vgraphs = do_xmlrpc("getGraphs", $p, $xmlrpc_conn, TRUE, FALSE); 103 if (xmlrpc_has_error($vgraphs)) { 104 ccs_notice("Could not retrieve host: " . 105 xmlrpc_error_string($vgraphs)); 129 if ($_REQUEST["main"] == "host"){ 130 $mirror = 'f'; 131 if ($_REQUEST["mirror"] == "on") 132 $mirror = 't'; 133 $p = array($_REQUEST["host_id"], $_REQUEST["graph_id"], $mirror); 134 $vgraphs = do_xmlrpc("getGraphs", $p, $xmlrpc_conn, TRUE, FALSE); 135 if (xmlrpc_has_error($vgraphs)) { 136 ccs_notice("Could not retrieve host: " . 137 xmlrpc_error_string($vgraphs)); 138 $vgraphs = array(); 139 } 140 }else if ($_REQUEST["main"] == "link"){ 141 $p = array($_REQUEST["link_id"], $_REQUEST["graph_id"]); 142 $vgraphs = do_xmlrpc("getLinkGraphs", $p, $xmlrpc_conn, TRUE, FALSE); 143 if (xmlrpc_has_error($vgraphs)) { 144 ccs_notice("Could not retrieve host: " . 145 xmlrpc_error_string($vgraphs)); 146 $vgraphs = array(); 147 } 148 }else if ($_REQUEST["main"] == "target"){ 149 if ($_REQUEST["target_id"] != ''){ 150 list($host_name, $graph_id, $num, $ip_address,$description) = split("-",$_REQUEST["target_id"],5); 151 $vgraphs = array(array("host_name"=>$host_name, "graph_id"=>$graph_id, "num"=>$num, "ip_address"=>$ip_address, "description"=>$description)); 152 }else 153 $vgraphs = array(); 154 155 }else{ 106 156 $vgraphs = array(); 107 157 } 108 158 159 $smarty->assign("mirror", $_REQUEST["mirror"]); 160 $smarty->assign("main", $_REQUEST["main"]); 109 161 $smarty->assign("host_id", $_REQUEST["host_id"]); 110 162 $smarty->assign("graph_id", $_REQUEST["graph_id"]); 163 $smarty->assign("link_id", $_REQUEST["link_id"]); 164 $smarty->assign("target_id", $_REQUEST["target_id"]); 165 $smarty->assign("time_id", $_REQUEST["time_id"]); 111 166 $smarty->assign("vgraphs", $vgraphs); 112 167 $smarty->assign("num", $_REQUEST["num"]); … … 114 169 $smarty->assign("scripts", array("graphs.js")); 115 170 display_select_graph(); 116 //display_page("mods/graphs/graphs.tpl"); 117 118 }else if ($_REQUEST["do"] == "getnumbers") { 119 $p = array($_REQUEST["host_id"], $_REQUEST["graph_id"]); 120 $nums = do_xmlrpc("getNumbers", $p, $xmlrpc_conn, TRUE, FALSE); 121 if (xmlrpc_has_error($nums)) { 122 ccs_notice("Could not retrieve numbers: " . 123 xmlrpc_error_string($nums)); 124 $nums = array(); 125 } 126 $smarty->assign("nums", $nums); 127 /* Show the form */ 128 $smarty->assign("sheets", array("host.css")); 129 $smarty->assign("scripts", array("host.js")); 130 display_page("mods/graphs/num-list.tpl"); 171 172 }else{ 173 display_select_graph(); 131 174 } 132 175 ?> -
ccsweb/trunk/ccs_mods/graphs/index.php
r1174 r1209 4 4 * This file is part of ccsweb - CRCnet Configuration System Web Interface 5 5 * 6 * Host configuration7 * 8 * Author: Matt Brown <matt@crc.net.nz>9 * Version: $Id: index.php 502 2006-02-14 05:08:09Z mglb1 $6 * Graph manipulation user interface 7 * 8 * Author: Chris Browning <ckb6@cs.waikato.ac.nz> 9 * Version: $Id: hosteditform.tpl 1067 2006-10-05 22:55:17Z mglb1 $ 10 10 * 11 11 * ccsweb is free software; you can redistribute it and/or modify it under the -
ccsweb/trunk/ccs_mods/graphs/index.tpl
r1183 r1209 21 21 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 22 *} 23 {debug} 24 {include file="header.tpl" title="Host Configuration"} 25 Select a host and graph from below. 23 {include file="header.tpl" title="Graphs"} 24 <h3>Select a from the options below and click Refresh to view graphs.</h3> 26 25 <form method="get" action="graphs.php" id="selectgraphForm"> 27 26 <input type="hidden" name="do" value="getgraph"/> 28 <table id = "selectgraph"> 29 <tr><th>Hostname</th><td>{html_options values=$host_ids output=$host_names selected=$host_id name="host_id" id="host_id"}</td></tr> 30 <tr><th>Graph</th><td id = 'graph_id-cell'>{include file="mods/graphs/graphs-list.tpl"}</td></tr> 31 <tr><th>Number</th><td id = 'num-cell'>{include file="mods/graphs/num-list.tpl"}</td></tr> 27 <form name="filter" method="get" action="graph.php"> 28 <table> 29 <tr><td class="bodyText"><input type="radio" name="main" value="host" id="host" onClick="toggle();" {if $main=="host" || $main==""}checked{/if} /> Host:</td><td> 30 {if $main=="host" || $main==""} 31 {html_options values=$host_ids output=$host_names selected=$host_id name="host_id" id="host_id"} 32 {else} 33 {html_options values=$host_ids output=$host_names selected=$host_id name="host_id" id="host_id" disabled=true} 34 {/if} 35 </td> 36 <tr><td class="bodyText"><input type="radio" name="main" value="link" id="link" onClick="toggle();" {if $main=="link"}checked{/if}/> Link:</td><td> 37 {if $main=="link"} 38 {html_options values=$link_ids output=$link_names selected=$link_id name="link_id" id="link_id"} 39 {else} 40 {html_options values=$link_ids output=$link_names selected=$link_id name="link_id" id="link_id" disabled=true} 41 {/if} 42 </td></tr> 43 <tr><td class="bodyText"><input type="radio" name="main" value="target" id="target" onClick="toggle();" {if $main=="target"}checked{/if}/> Target:</td><td> 44 {if $main=="target"} 45 {html_options values=$target_ids output=$target_names selected=$target_id name="target_id" id="target_id"} 46 {else} 47 {html_options values=$target_ids output=$target_names selected=$target_id name="target_id" id="target_id" disabled=true} 48 {/if} 49 50 </td></tr> 51 <tr><td class="bodyText">Type:</td><td id = 'graph_id-cell'>{include file="mods/graphs/graphs-list.tpl"} 52 </td></tr> 53 <tr><td class="bodyText">Period: </td><td> 54 <select id="time_id" name="time_id" /> 55 {foreach from=$times item=time} 56 <option value="{$time.time_id}" {if $time.time_id == $time_id}selected="selected"{/if}>{$time.name}</option> 57 {/foreach} 58 </select> 59 </td></tr> 60 <tr><td class="bodyText">Mirror:</td><td><input type="checkbox" name="mirror" id="mirror" {if $mirror=="on"}checked{/if} {if $main!="host" && $main!=''}disabled{/if}/></td></tr> 32 61 </table> 33 <input type="submit" name="draw" id="draw" value="Get Graphs"> 34 </form> 35 {if $num != -1} 36 Graph of {$vgraphs[$num].host_name}/{$vgraphs[$num].graph_id}?number={$num}<br /> 37 <img src="http://puck.crc.net.nz:6061/graphs/{$vgraphs[$num].host_name}/{$vgraphs[$num].graph_id}?number={$num}"><br /> 38 {else} 39 {foreach from=$vgraphs item=graph} 40 Graph of {$graph.host_name}/{$graph.graph_id}?number={$graph.num}<br /> 41 <img src="http://puck.crc.net.nz:6061/graphs/{$graph.host_name}/{$graph.graph_id}?number={$graph.num}"><br /> 42 {/foreach} 43 {/if} 62 <input type="submit" value="Refresh" class="inputbox"/> 63 </form> 64 <table> 65 {assign var='i' value=0} 66 {foreach from=$vgraphs item=graph} 67 <tr><td> 68 <select id="time_id{$i}" onChange="change_img('{$graph.host_name}','time_id{$i}','{$graph.graph_id}','{$graph.num}','img{$i}')"> 69 {foreach from=$times item=time} 70 <option value="{$time.time_id}" {if $time.time_id == $time_id}selected="selected"{/if}>{$time.name}</option> 71 {/foreach} 72 </select> 73 Graph of {$graph.host_name} - {if $graph.description != ''}{$graph.description}-{$graph.ip_address}{else}{$graph.ip_address}{/if}<br /> 74 <img id="img{$i++}" src="http://puck.crc.net.nz:6061/graphs/{$graph.host_name}/{$time_id}/{$graph.graph_id}?number={$graph.num}"><br /> 75 </td><td> 76 {if $graph.num2 != ''} 77 Graph of {$graph.host_name2} - {if $graph.description != ''}{$graph.description}-{$graph.ip_address2}{else}{$graph.ip_address2}{/if}<br /> 78 <img src="http://puck.crc.net.nz:6061/graphs/{$graph.host_name2}/{$time_id}/{$graph.graph_id}?number={$graph.num2}"><br /> 79 {/if} 80 </td></tr> 81 {/foreach} 82 </table> 44 83 {include file="footer.tpl"}
Note: See TracChangeset
for help on using the changeset viewer.
