Commit d105cce2 authored by Jonathon Duerig's avatar Jonathon Duerig

Export CalculateWirelessStatus to AJAX frontend

parent 88e3c293
...@@ -39,6 +39,15 @@ function Do_GetHealthStatus() ...@@ -39,6 +39,15 @@ function Do_GetHealthStatus()
SPITAJAX_RESPONSE($status); SPITAJAX_RESPONSE($status);
} }
# Fetch wireless health status.
# Can be done without logging in (for front page status).
function Do_GetWirelessStatus()
{
$status = array();
CalculateWirelessStatus($status);
SPITAJAX_RESPONSE($status);
}
# Local Variables: # Local Variables:
# mode:php # mode:php
# End: # End:
......
...@@ -1097,15 +1097,13 @@ function CalculateAggregateStatus(&$amlist, &$fedlist, &$status, ...@@ -1097,15 +1097,13 @@ function CalculateAggregateStatus(&$amlist, &$fedlist, &$status,
} }
} }
function CalculateWirelessStatus() { function CalculateWirelessStatus(&$result) {
$result = array();
$query_result = $query_result =
DBQueryFatal( "SELECT COUNT(DISTINCT w.node_id1) AS c FROM wires AS w " . DBQueryFatal( "SELECT COUNT(DISTINCT w.node_id1) AS c FROM wires AS w " .
"LEFT OUTER JOIN reserved AS r1 ON " . "LEFT OUTER JOIN reserved AS r1 ON " .
"w.node_id1=r1.node_id LEFT OUTER JOIN reserved AS r2 " . "w.node_id1=r1.node_id LEFT OUTER JOIN reserved AS r2 " .
"ON w.node_id2=r2.node_id WHERE w.node_id1 LIKE 'nuc%' " . "ON w.node_id2=r2.node_id WHERE w.node_id1 LIKE 'nuc%' " .
"AND w.node_id2 LIKE 'ue%' AND w.external_wire IS NULL" . "AND w.node_id2 LIKE 'ue%' AND w.external_wire IS NULL " .
"OR w.external_wire=''" ); "OR w.external_wire=''" );
$row = mysql_fetch_array( $query_result ); $row = mysql_fetch_array( $query_result );
$radiated1 = $row[ 'c' ]; $radiated1 = $row[ 'c' ];
...@@ -1115,7 +1113,7 @@ function CalculateWirelessStatus() { ...@@ -1115,7 +1113,7 @@ function CalculateWirelessStatus() {
"LEFT OUTER JOIN reserved AS r1 ON " . "LEFT OUTER JOIN reserved AS r1 ON " .
"w.node_id1=r1.node_id LEFT OUTER JOIN reserved AS r2 " . "w.node_id1=r1.node_id LEFT OUTER JOIN reserved AS r2 " .
"ON w.node_id2=r2.node_id WHERE w.node_id2 LIKE 'nuc%' " . "ON w.node_id2=r2.node_id WHERE w.node_id2 LIKE 'nuc%' " .
"AND w.node_id1 LIKE 'ue%' AND w.external_wire IS NULL" . "AND w.node_id1 LIKE 'ue%' AND w.external_wire IS NULL " .
"OR w.external_wire=''" ); "OR w.external_wire=''" );
$row = mysql_fetch_array( $query_result ); $row = mysql_fetch_array( $query_result );
$radiated2 = $row[ 'c' ]; $radiated2 = $row[ 'c' ];
...@@ -1138,10 +1136,8 @@ function CalculateWirelessStatus() { ...@@ -1138,10 +1136,8 @@ function CalculateWirelessStatus() {
$row = mysql_fetch_array( $query_result ); $row = mysql_fetch_array( $query_result );
$controlled2 = $row[ 'c' ]; $controlled2 = $row[ 'c' ];
return array( $result["radiated"] = $radiated1 + $radiated2;
"radiated" => $radiated1 + $radiated2; $result["controlled"] = $controlled1 + $controlled2;
"controlled" => $controlled1 + $controlled2;
);
} }
function SpitAggregateStatus($extended = false) { function SpitAggregateStatus($extended = false) {
......
...@@ -411,7 +411,9 @@ $routing = array("geni-login" => ...@@ -411,7 +411,9 @@ $routing = array("geni-login" =>
array("file" => "frontpage.ajax", array("file" => "frontpage.ajax",
"guest" => true, "guest" => true,
"methods" => array("GetHealthStatus" => "methods" => array("GetHealthStatus" =>
"Do_GetHealthStatus")), "Do_GetHealthStatus",
"GetWirelessStatus" =>
"Do_GetWirelessStatus")),
); );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment