Fixes to not log errors when there are no monitors to display in watch.

openbsd
Charlie Root 2023-09-13 11:19:16 -07:00
parent e11b700fbd
commit 41dc7c8f4e
3 changed files with 19 additions and 14 deletions

View File

@ -750,7 +750,7 @@ function initPage() {
settingsBtn.prop('disabled', false);
}
if (monitorType != 'WebSite') {
if ((monitorType != 'WebSite') && monitorData.length) {
monitorStream = new MonitorStream(monitorData[monIdx]);
monitorStream.setBottomElement(document.getElementById('dvrControls'));
@ -875,7 +875,7 @@ function initPage() {
bindButton('#cyclePrevBtn', 'click', null, cyclePrev);
bindButton('#cycleToggle', 'click', null, cycleToggle);
bindButton('#cyclePeriod', 'change', null, cyclePeriodChange);
if (cycle) {
if (monitorData.length && cycle) {
cycleStart();
} else {
cyclePause();

View File

@ -23,19 +23,18 @@ var showMode = "<?php echo ($showPtzControls && !empty($control))?"control":"eve
var cycle = <?php echo $cycle ? 'true' : 'false' ?>;
var maxDisplayEvents = <?php echo 2 * MAX_EVENTS ?>;
var monitorId = <?php echo $monitor->Id() ?>;
var monitorWidth = <?php echo $monitor->ViewWidth() ?>;
var monitorHeight = <?php echo $monitor->ViewHeight() ?>;
var monitorId = '<?php echo $monitor->Id() ?>';
var monitorWidth = '<?php echo $monitor->ViewWidth() ?>';
var monitorHeight = '<?php echo $monitor->ViewHeight() ?>';
var monitorUrl = '<?php echo $monitor->UrlToIndex() ?>';
var monitorType = '<?php echo $monitor->Type() ?>';
var monitorRefresh = '<?php echo $monitor->Refresh() ?>';
var monitorStreamReplayBuffer = <?php echo $monitor->StreamReplayBuffer() ?>;
var monitorStreamReplayBuffer = '<?php echo $monitor->StreamReplayBuffer() ?>';
var monitorControllable = <?php echo $monitor->Controllable()?'true':'false' ?>;
var monIdx = <?php echo $monitor_index; ?>;
var nextMid = "<?php echo isset($nextMid)?$nextMid:'' ?>";
var mode = "<?php echo $options['mode'] ?>";
var monIdx = '<?php echo $monitor_index; ?>';
var nextMid = '<?php echo isset($nextMid)?$nextMid:'' ?>';
var mode = '<?php echo $options['mode'] ?>';
var monitorData = new Array();
<?php

View File

@ -75,9 +75,10 @@ if ($mid and ($monitor_index == -1)) {
}
}
if (!$mid) {
if (!$mid and count($monitors)) {
$mid = $monitors[0]->Id();
$monitor_index = 0;
$nextMid = ($monitor_index == count($monitors)-1) ? $monitors[0]->Id() : $monitors[$monitor_index+1]->Id();
}
if (!visibleMonitor($mid)) {
@ -86,7 +87,6 @@ if (!visibleMonitor($mid)) {
}
$monitor = new ZM\Monitor($mid);
$nextMid = ($monitor_index == count($monitors)-1) ? $monitors[0]->Id() : $monitors[$monitor_index+1]->Id();
# cycle is wether to do the countdown/move to next monitor bit.
# showCycle is whether to show the cycle controls.
@ -257,6 +257,7 @@ echo htmlSelect('changeRate', $maxfps_options, $options['maxfps']);
</div><!--header-->
<div class="container-fluid h-100">
<div class="row flex-nowrap h-100" id="content">
<?php if (count($monitors)) { ?>
<nav id="sidebar" class="h-100"<?php echo $showCycle?'':' style="display:none;"'?>>
<div id="cycleButtons" class="buttons">
<?php
@ -442,5 +443,10 @@ if ( $monitor->RTSP2WebEnabled() and $monitor->RTSP2WebType == "HLS") {
<?php
}
?>
<script src="<?php echo cache_bust('js/MonitorStream.js') ?>"></script>
<?php xhtmlFooter() ?>
<?php
} else {
echo "There are no monitors to display\n";
}
echo '<script src="'.cache_bust('js/MonitorStream.js') .'"></script>'.PHP_EOL;
xhtmlFooter();
?>