add runtimeStatus function

This commit is contained in:
Andrew Bauer 2020-07-30 16:14:41 -05:00
parent 23596b142d
commit 561c44ece2
1 changed files with 25 additions and 31 deletions

View File

@ -267,14 +267,7 @@ function getNavBarHTML($reload = null) {
} }
if ( $reload === null ) { if ( $reload === null ) {
ob_start(); ob_start();
if ( $running == null ) $status = runtimeStatus($running);
$running = daemonCheck();
if ( $running ) {
$state = dbFetchOne('SELECT Name FROM States WHERE isActive=1', 'Name');
if ( $state == 'default' )
$state = '';
}
$status = $running ? ($state ? $state : translate('Running')) : translate('Stopped');
?> ?>
<div class="fixed-top container-fluid p-0 p-0"> <div class="fixed-top container-fluid p-0 p-0">
@ -302,12 +295,12 @@ function getNavBarHTML($reload = null) {
echo getOptionsHTML(); echo getOptionsHTML();
echo getLogHTML(); echo getLogHTML();
echo getDevicesHTML(); echo getDevicesHTML();
echo getGroupsHTML(); echo getGroupsHTML($view);
echo getFilterHTML(); echo getFilterHTML($view,$filterQuery,$sortQuery,$limitQuery);
echo getCycleHTML(); echo getCycleHTML($view);
echo getMontageHTML(); echo getMontageHTML($view);
echo getMontageReviewHTML(); echo getMontageReviewHTML($view);
echo getRprtEvntAuditHTML(); echo getRprtEvntAuditHTML($view);
echo getHeaderFlipHTML(); echo getHeaderFlipHTML();
echo '</ul>'; echo '</ul>';
@ -507,26 +500,19 @@ function getDevicesHTML() {
} }
// Returns the html representing the Groups menu item // Returns the html representing the Groups menu item
function getGroupsHTML() { function getGroupsHTML($view) {
global $view;
$class = $view == 'groups' ? 'selected' : ''; $class = $view == 'groups' ? 'selected' : '';
echo '<li class="nav-item"><a class="nav-link" href="?view=groups" class="' .$class. '">'. translate('Groups') .'</a></li>'.PHP_EOL; echo '<li class="nav-item"><a class="nav-link" href="?view=groups" class="' .$class. '">'. translate('Groups') .'</a></li>'.PHP_EOL;
} }
// Returns the html representing the Filter menu item // Returns the html representing the Filter menu item
function getFilterHTML() { function getFilterHTML($view,$filterQuery,$sortQuery,$limitQuery) {
global $view;
global $filterQuery;
global $sortQuery;
global $limitQuery;
$class = $view == 'filter' ? 'selected' : ''; $class = $view == 'filter' ? 'selected' : '';
echo '<li class="nav-item"><a class="nav-link" href="?view=filter'.$filterQuery.$sortQuery.$limitQuery.'" class="'.$class.'">'.translate('Filters').'</a></li>'.PHP_EOL; echo '<li class="nav-item"><a class="nav-link" href="?view=filter'.$filterQuery.$sortQuery.$limitQuery.'" class="'.$class.'">'.translate('Filters').'</a></li>'.PHP_EOL;
} }
// Returns the html representing the Cycle menu item // Returns the html representing the Cycle menu item
function getCycleHTML() { function getCycleHTML($view) {
global $view;
if ( canView('Stream') ) { if ( canView('Stream') ) {
$class = $view == 'cycle' ? 'selected' : ''; $class = $view == 'cycle' ? 'selected' : '';
echo '<li class="nav-item"><a class="nav-link" href="?view=cycle" class="' .$class. '">' .translate('Cycle'). '</a></li>'.PHP_EOL; echo '<li class="nav-item"><a class="nav-link" href="?view=cycle" class="' .$class. '">' .translate('Cycle'). '</a></li>'.PHP_EOL;
@ -534,8 +520,7 @@ function getCycleHTML() {
} }
// Returns the html representing the Montage menu item // Returns the html representing the Montage menu item
function getMontageHTML() { function getMontageHTML($view) {
global $view;
if ( canView('Stream') ) { if ( canView('Stream') ) {
$class = $view == 'cycle' ? 'selected' : ''; $class = $view == 'cycle' ? 'selected' : '';
echo '<li class="nav-item"><a class="nav-link" href="?view=montage" class="' .$class. '">' .translate('Montage'). '</a></li>'.PHP_EOL; echo '<li class="nav-item"><a class="nav-link" href="?view=montage" class="' .$class. '">' .translate('Montage'). '</a></li>'.PHP_EOL;
@ -543,8 +528,7 @@ function getMontageHTML() {
} }
// Returns the html representing the MontageReview menu item // Returns the html representing the MontageReview menu item
function getMontageReviewHTML() { function getMontageReviewHTML($view) {
global $view;
if ( canView('Events') ) { if ( canView('Events') ) {
if ( isset($_REQUEST['filter']['Query']['terms']['attr']) ) { if ( isset($_REQUEST['filter']['Query']['terms']['attr']) ) {
$terms = $_REQUEST['filter']['Query']['terms']; $terms = $_REQUEST['filter']['Query']['terms'];
@ -567,8 +551,7 @@ function getMontageReviewHTML() {
} }
// Returns the html representing the Audit Events Report menu item // Returns the html representing the Audit Events Report menu item
function getRprtEvntAuditHTML() { function getRprtEvntAuditHTML($view) {
global $view;
if ( canView('Events') ) { if ( canView('Events') ) {
$class = $view == 'report_event_audit' ? 'selected' : ''; $class = $view == 'report_event_audit' ? 'selected' : '';
echo '<li class="nav-item"><a class="nav-link" href="?view=report_event_audit" class="' .$class. '">' .translate('ReportEventAudit'). '</a></li>'.PHP_EOL; echo '<li class="nav-item"><a class="nav-link" href="?view=report_event_audit" class="' .$class. '">' .translate('ReportEventAudit'). '</a></li>'.PHP_EOL;
@ -613,11 +596,22 @@ function getStatusBtnHTML($status) {
} }
} }
function runtimeStatus($running=null) {
if ( $running == null )
$running = daemonCheck();
if ( $running ) {
$state = dbFetchOne('SELECT Name FROM States WHERE isActive=1', 'Name');
if ( $state == 'default' )
$state = '';
}
return $running ? ($state ? $state : translate('Running')) : translate('Stopped');
}
function xhtmlFooter() { function xhtmlFooter() {
global $cspNonce; global $cspNonce;
global $view; global $view;
global $skin; global $skin;
global $running;
if ( canEdit('System') ) { if ( canEdit('System') ) {
include("skins/$skin/views/state.php"); include("skins/$skin/views/state.php");
} }