Commit 745f8d33 authored by Adam Wujek's avatar Adam Wujek 💬

Merge branch 'ben-150805'

parents 584ec43d ae50473c
This diff is collapsed.
......@@ -104,14 +104,14 @@ function wrs_header_ports(){
echo '<tr class="status">';
for($i=1; $i<18*3; $i=$i+3){
if (!strstr($ports[($i+1)],"NoLock")){
if (strstr($ports[($i+1)],"Locked")){
$mode="locked";
}else{
$mode="unlocked";
}
echo '<th>'."<img class='syntonization ".$mode."' SRC='img/".$mode.".png' alt='syntonization: ".$mode."', title = 'syntonization: ".$mode."'>";
if (!strstr($ports[($i+2)],"Uncalibrated")){
if (strstr($ports[($i+2)],"Calibrated")){
$mode="calibrated";
$img="check.png";
}else{
......@@ -168,25 +168,33 @@ function wrs_main_info(){
$Monitor = check_monit_status() ? '[on] ' : '[off] ';
$WRSmode = check_switch_mode();
if(!strcmp($WRSmode, "GM"))
$WRSmode_xtra="";
if(!strcmp($WRSmode, "GM")) {
$WRSmode="GrandMaster";
$ports = shell_exec("cat /tmp/ports.conf");
if(empty($ports)) $WRSmode_xtra="<br>Waiting PPS/10MHz ...";
}
else if (!strcmp($WRSmode, "BC"))
$WRSmode="Boundary Clock";
else if (!strcmp($WRSmode, "FM"))
$WRSmode="Free-Running Master";
else
$WRSmode="GrandMaster";
$WRSmode="Unknown";
#Obtain the temperatures using the last line of (wr-mon -w)
$temperatures=shell_exec("cat /tmp/ports.conf 2>/dev/null | tail -1");
// Print services table
echo '<br><table class="'.$class.'" id="'.$formatID.'" width="100%">';
echo '<tr><th>'.$infoname.'</th></tr>';
echo '<tr><td>PTP Mode</td><td> <a href="ptp.php">'.$WRSmode.'</td></tr>';
echo '<tr><td>PTP Mode</td><td> <a href="ptp.php">'.$WRSmode.'</a>'.$WRSmode_xtra.'</td></tr>';
echo '<tr><td>NTP Server</td><td> <a href="management.php">'.$NTP.'</td></tr>';
echo '<tr><td>White-Rabbit Date</td><td>'.$wr_date.'</td></tr>';
echo '<tr><td>PPSi</td><td>'.$PPSi.'</td></tr>';
echo '<tr><td>System Monitor</td><td> <a href="management.php">'.$Monitor.'</td></tr>';
echo '<tr><td>Net-SNMP Server</td><td>'.$SNMP.'( port '.$SNMP_port.")</td></tr>";
echo '<tr><td>NTP Server</td><td> <a href="management.php">'.$NTP.'</td></tr>';
if(!empty($temperatures)) echo '<tr><td>Temperature (ºC)</td><td>'.$temperatures.'</td></tr>';
echo '</table>';
}
......@@ -677,7 +685,7 @@ function wrs_management(){
unlink($uploadfile);
//Reboot switch
sleep(1);
wrs_reboot();
wrs_reboot(90); //Updating only one part of the firmware take ~90s.
}
else if(substr($uploadfname,0,14)=="wr-switch-sw-v" && substr($uploadfname,-13)=="_binaries.tar")
{
......@@ -685,7 +693,7 @@ function wrs_management(){
unlink($uploadfile);
//Reboot switch
sleep(1);
wrs_reboot();
wrs_reboot(150); //120s should be enough but we prefer to keep safe
}
else
{
......@@ -1250,9 +1258,9 @@ function echoSelectedClassIfRequestMatches($requestUri)
return 'class="selected"';
}
function wrs_reboot(){
function wrs_reboot($timeout=40){
sleep(1);
header ('Location: reboot.php');
header ('Location: reboot.php?timeout='.$timeout);
}
/*
......
......@@ -55,6 +55,7 @@ function showPopup(url) {
* Reboots the switch
*
* @author José Luis Gutiérrez <jlgutierrez@ugr.es>
* @author Benoit Rat <benoit@sevensols.com>
*
* Reboots the switch using the rebooter.php file.
* This has been done to display the "rebooting" message after any
......@@ -64,10 +65,19 @@ function showPopup(url) {
$(document).ready(
function() {
setTimeout(function() {
var path = window.location.pathname;
var page = path.split("/").pop();
if (page == "reboot.php"){
$('#rebootingtext').text("Rebooting WRS. The web interface will refresh automatically after 50s.");
var pageid=$('body').attr('id');
if (pageid=="reboot")
{
//Obtain timeout from the hidden input (#reboot_to) or set it by default to 40s
tout=$('#reboot_to').val()
if($.isNumeric(tout)==false || tout < 30) tout=40
//Improve how to print the timeout when more than 1 minute
if(tout>60) tout_str=Math.floor(tout/60)+"m "+(tout%60)+"s."
else tout_str=tout+"s."
//Update the HTML and call the rebooter.
$('#rebootingtext').text("Rebooting WRS. The web interface will refresh automatically after "+tout_str);
$('#rebooting').load('rebooter.php');
}
}, 1500);
......@@ -77,18 +87,24 @@ $(document).ready(
* Redirects users to index.php
*
* @author José Luis Gutiérrez <jlgutierrez@ugr.es>
* @author Benoit Rat <benoit@sevensols.com>
*
* 50 seconds after the execution of the reboot cmd, the web browser
* tout seconds after the execution of the reboot cmd, the web browser
* reloads automatically the web interface.
*
*/
$(document).ready(
function() {
var pageid=$('body').attr('id');
if (pageid=="reboot")
{
//Obtain timeout from the hidden input (#reboot_to) or set it by default to 40s
tout=$('#reboot_to').val()
if($.isNumeric(tout)==false || tout < 30) tout=40
//Main timeout to refresh the webpage
setTimeout(function() {
var path = window.location.pathname;
var page = path.split("/").pop();
if (page == "reboot.php"){
window.location.href = "index.php";
}
}, 50000);
window.location.href = "index.php";
}, tout*1000);
}
});
......@@ -16,7 +16,7 @@
</div>
<div class="rightpanel">
<div class="rightbody">
<h1 class="title">PPSi Configuration <a href='help.php?help_id=ptp' onClick='showPopup(this.href);return(false);'><img align=right src="./img/question.png"></a></h1>
<h1 class="title">WR-PPSi Configuration <a href='help.php?help_id=ptp' onClick='showPopup(this.href);return(false);'><img align=right src="./img/question.png"></a></h1>
<?php session_is_started() ?>
<?php $_SESSION['advance']=""; ?>
......
<?php include 'functions.php'; include 'head.php'; ?>
<body id="management">
<body id="reboot">
<div class="main">
<div class="page">
<div class="header" >
......@@ -27,6 +27,7 @@
<div id="rebootingtext" align=center>...Saving changes...</div>
</div>
<form><input hidden id="reboot_to" value="<?php echo $_GET['timeout']?>"></form>
<div id="rebooting"></div>
<div id="rebootwrlogo">
......
......@@ -516,6 +516,7 @@ int main(int argc, char *argv[])
case 'w': /* for the web interface */
read_hal();
show_unadorned_ports();
show_temperatures();
exit(0);
case 'q': break; /* done in wrs_msg_init() */
case 'v': break; /* done in wrs_msg_init() */
......
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