Add navbar refresh to all pages that use it

This commit is contained in:
digital-gnome 2017-11-29 23:04:38 -05:00
parent cb70a3627f
commit 0a995aea78
7 changed files with 59 additions and 5 deletions

View File

@ -2933,6 +2933,16 @@ our @options = (
type => $types{integer},
category => 'highband',
},
{
name => 'ZM_WEB_H_REFRESH_NAVBAR',
default => '5',
description => 'How often (in seconds) the navigation header should refresh itself',
help => q`
The navigation header contains the general status information about server load and storage space.
`,
type => $types{integer},
category => 'highband',
},
{
name => 'ZM_WEB_H_REFRESH_CYCLE',
default => '10',
@ -3196,6 +3206,16 @@ our @options = (
`,
category => 'medband',
},
{
name => 'ZM_WEB_M_REFRESH_NAVBAR',
default => '15',
description => 'How often (in seconds) the navigation header should refresh itself',
help => q`
The navigation header contains the general status information about server load and storage space.
`,
type => $types{integer},
category => 'medband',
},
{
name => 'ZM_WEB_M_REFRESH_CYCLE',
default => '20',
@ -3459,6 +3479,16 @@ our @options = (
type => $types{integer},
category => 'lowband',
},
{
name => 'ZM_WEB_L_REFRESH_NAVBAR',
default => '35',
description => 'How often (in seconds) the navigation header should refresh itself',
help => q`
The navigation header contains the general status information about server load and storage space.
`,
type => $types{integer},
category => 'lowband',
},
{
name => 'ZM_WEB_L_REFRESH_CYCLE',
default => '30',

View File

@ -1,4 +1,8 @@
<?php
if ($_REQUEST['entity'] == "navBar") {
ajaxResponse(getNavBarHtml('reload'));
return;
}
$statusData = array(
'system' => array(

View File

@ -56,6 +56,7 @@ $bandwidth_options = array(
switch ( $_COOKIE['zmBandwidth'] ) {
case 'high' : {
define( 'ZM_WEB_REFRESH_MAIN', ZM_WEB_H_REFRESH_MAIN ); // How often (in seconds) the main console window refreshes
define( 'ZM_WEB_REFRESH_NAVBAR', ZM_WEB_H_REFRESH_NAVBAR ); // How often (in seconds) the nav header refreshes
define( 'ZM_WEB_REFRESH_CYCLE', ZM_WEB_H_REFRESH_CYCLE ); // How often the cycle watch windows swaps to the next monitor
define( 'ZM_WEB_REFRESH_IMAGE', ZM_WEB_H_REFRESH_IMAGE ); // How often the watched image is refreshed (if not streaming)
define( 'ZM_WEB_REFRESH_STATUS', ZM_WEB_H_REFRESH_STATUS ); // How often the little status frame refreshes itself in the watch window
@ -73,6 +74,7 @@ switch ( $_COOKIE['zmBandwidth'] ) {
break;
} case 'medium' : {
define( 'ZM_WEB_REFRESH_MAIN', ZM_WEB_M_REFRESH_MAIN ); // How often (in seconds) the main console window refreshes
define( 'ZM_WEB_REFRESH_NAVBAR', ZM_WEB_M_REFRESH_NAVBAR ); // How often (in seconds) the nav header refreshes
define( 'ZM_WEB_REFRESH_CYCLE', ZM_WEB_M_REFRESH_CYCLE ); // How often the cycle watch windows swaps to the next monitor
define( 'ZM_WEB_REFRESH_IMAGE', ZM_WEB_M_REFRESH_IMAGE ); // How often the watched image is refreshed (if not streaming)
define( 'ZM_WEB_REFRESH_STATUS', ZM_WEB_M_REFRESH_STATUS ); // How often the little status frame refreshes itself in the watch window
@ -90,6 +92,7 @@ switch ( $_COOKIE['zmBandwidth'] ) {
break;
} case 'low' : {
define( 'ZM_WEB_REFRESH_MAIN', ZM_WEB_L_REFRESH_MAIN ); // How often (in seconds) the main console window refreshes
define( 'ZM_WEB_REFRESH_NAVBAR', ZM_WEB_L_REFRESH_NAVBAR ); // How often (in seconds) the nav header refreshes
define( 'ZM_WEB_REFRESH_CYCLE', ZM_WEB_L_REFRESH_CYCLE ); // How often the cycle watch windows swaps to the next monitor
define( 'ZM_WEB_REFRESH_IMAGE', ZM_WEB_L_REFRESH_IMAGE ); // How often the watched image is refreshed (if not streaming)
define( 'ZM_WEB_REFRESH_STATUS', ZM_WEB_L_REFRESH_STATUS ); // How often the little status frame refreshes itself in the watch window

View File

@ -159,7 +159,7 @@ if ( file_exists( "skins/$skin/css/$css/graphics/favicon.ico" ) ) {
<?php
} // end function xhtmlHeaders( $file, $title )
function getNavBarHTML() {
function getNavBarHTML($reload = null) {
$versionClass = (ZM_DYN_DB_VERSION&&(ZM_DYN_DB_VERSION!=ZM_VERSION))?'errorText':'';
@ -172,13 +172,16 @@ function getNavBarHTML() {
global $user;
global $bandwidth_options;
global $view;
if ($reload === null) {
?>
<noscript>
<div style="background-color:red;color:white;font-size:x-large;">
ZoneMinder requires Javascript. Please enable Javascript in your browser for this site.
</div>
</noscript>
<?php
}
?>
<div class="navbar navbar-inverse navbar-static-top">
<div class="container-fluid">
<div class="navbar-header">
@ -279,7 +282,7 @@ if ( ZM_OPT_X10 && canView( 'Devices' ) ) { ?>
</ul>
</div> <!-- End .footer -->
</div> <!-- End .navbar .navbar-default -->
<!-- End .navbar .navbar-default --></div>
<?php
return( ob_get_clean() );
} // end function getNavBarHTML()

View File

@ -182,6 +182,20 @@ function refreshParentWindow() {
}
}
$j.ajaxSetup ({timeout: AJAX_TIMEOUT }); //sets timeout for all getJSON.
$j(document).ready(function() {
if ($j('.navbar').length) setInterval(getNavBar, navBarRefresh)
});
function getNavBar () {
$j.getJSON(thisUrl + '?view=request&request=status&entity=navBar', setNavBar);
}
function setNavBar (data) {
$j('.navbar').replaceWith(data.message);
}
//Shows a message if there is an error in the streamObj or the stream doesn't exist. Returns true if error, false otherwise.
function checkStreamForErrors( funcName, streamObj ) {
if ( !streamObj ) {

View File

@ -26,6 +26,8 @@
?>
var AJAX_TIMEOUT = <?php echo ZM_WEB_AJAX_TIMEOUT ?>;
var navBarRefresh = <?php echo 1000*ZM_WEB_REFRESH_NAVBAR ?>;
var currentView = '<?php echo $view ?>';
var thisUrl = "<?php echo ZM_BASE_URL.$_SERVER['PHP_SELF'] ?>";
var skinPath = "<?php echo ZM_SKIN_PATH ?>";

View File

@ -40,8 +40,6 @@ function vjsReplay() {
}
}
$j.ajaxSetup ({timeout: AJAX_TIMEOUT }); //sets timeout for all getJSON.
var cueFrames = null; //make cueFrames availaible even if we don't send another ajax query
function initialAlarmCues (eventId) {