Merge pull request #557 from laf/issue-552

Adds a jquery refresh / pause option to the System menu so you can pause pages
This commit is contained in:
Paul Gear
2015-03-09 08:39:10 +10:00
2 changed files with 66 additions and 4 deletions
+7
View File
@@ -452,12 +452,19 @@ if ($_SESSION['userlevel'] >= '10')
<li><a href="api-access/"><img src="images/16/script.png" /> API Settings</a></li>
<li><a href="https://github.com/librenms/librenms/wiki/API-Docs" target="_blank"><img src="images/16/report.png" /> API Documentation</a></li>
</ul>
</li>
<li role="presentation" class="divider"></li>');
} ?>
<?php
if ($_SESSION['authenticated'])
{
echo('
<li class="dropdown-submenu">
<a href="#"><span class="countdown_timer" id="countdown_timer"></span></a>
<ul class="dropdown-menu scrollable-menu">
<li><a href="#"><span class="countdown_timer_status" id="countdown_timer_status"></span></a></li>
</ul>
</li>
<li><a href="logout/"><img src="images/16/lock_go.png" with="16" height="16" alt="Logout"> Logout</a></li>
');
}
+59 -4
View File
@@ -142,9 +142,6 @@ if (isset($config['page_title'])) { $config['page_title_prefix'] = $config['page
<base href="<?php echo($config['base_url']); ?>" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<?php
if ($config['page_refresh']) { echo(' <meta http-equiv="refresh" content="'.$config['page_refresh'].'" />' . "\n"); }
?>
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="css/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css" />
<link href="css/bootstrap-switch.min.css" rel="stylesheet" type="text/css" />
@@ -340,6 +337,64 @@ if (is_array($sql_debug) && is_array($php_debug)) {
}
?>
</body>
<?php
if ($no_refresh !== TRUE && $config['page_refresh'] != 0) {
$refresh = $config['page_refresh'] * 1000;
echo('<script type="text/javascript">
$(document).ready(function() {
$("#countdown_timer_status").html("<img src=\"images/16/clock_pause.png\"> Pause");
var Countdown = {
sec: '. $config['page_refresh'] .',
Start: function() {
var cur = this;
this.interval = setInterval(function() {
$("#countdown_timer_status").html("<img src=\"images/16/clock_pause.png\"> Pause");
cur.sec -= 1;
display_time = cur.sec;
if (display_time == 0) {
location.reload();
}
if (display_time % 1 === 0 && display_time <= 300) {
$("#countdown_timer").html("<img src=\"images/16/clock.png\"> Refresh in " + display_time);
}
}, 1000);
},
Pause: function() {
clearInterval(this.interval);
$("#countdown_timer_status").html("<img src=\"images/16/clock_play.png\"> Resume");
delete this.interval;
},
Resume: function() {
if (!this.interval) this.Start();
}
};
Countdown.Start();
$("#countdown_timer_status").click("", function(event) {
event.preventDefault();
if (Countdown.interval) {
Countdown.Pause();
} else {
Countdown.Resume();
}
});
$("#countdown_timer").click("", function(event) {
event.preventDefault();
});
});
</script>');
}
?>
</html>