Commit d105cce2 authored by Jonathon Duerig's avatar Jonathon Duerig

Export CalculateWirelessStatus to AJAX frontend

parent 88e3c293
......@@ -39,6 +39,15 @@ function Do_GetHealthStatus()
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:
# mode:php
# End:
......
......@@ -1097,15 +1097,13 @@ function CalculateAggregateStatus(&$amlist, &$fedlist, &$status,
}
}
function CalculateWirelessStatus() {
$result = array();
function CalculateWirelessStatus(&$result) {
$query_result =
DBQueryFatal( "SELECT COUNT(DISTINCT w.node_id1) AS c FROM wires AS w " .
"LEFT OUTER JOIN reserved AS r1 ON " .
"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%' " .
"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=''" );
$row = mysql_fetch_array( $query_result );
$radiated1 = $row[ 'c' ];
......@@ -1115,7 +1113,7 @@ function CalculateWirelessStatus() {
"LEFT OUTER JOIN reserved AS r1 ON " .
"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%' " .
"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=''" );
$row = mysql_fetch_array( $query_result );
$radiated2 = $row[ 'c' ];
......@@ -1138,10 +1136,8 @@ function CalculateWirelessStatus() {
$row = mysql_fetch_array( $query_result );
$controlled2 = $row[ 'c' ];
return array(
"radiated" => $radiated1 + $radiated2;
"controlled" => $controlled1 + $controlled2;
);
$result["radiated"] = $radiated1 + $radiated2;
$result["controlled"] = $controlled1 + $controlled2;
}
function SpitAggregateStatus($extended = false) {
......
......@@ -411,7 +411,9 @@ $routing = array("geni-login" =>
array("file" => "frontpage.ajax",
"guest" => true,
"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