Merge branch 'master' of github.com:ZoneMinder/zoneminder

This commit is contained in:
Isaac Connor 2020-08-28 09:52:34 -04:00
commit 079d1be3b3
13 changed files with 70 additions and 26 deletions

View File

@ -203,11 +203,10 @@ sub Sql {
$self->{Sql} .= "weekday( E.EndTime )"; $self->{Sql} .= "weekday( E.EndTime )";
# #
} elsif ( $term->{attr} eq 'EventExists' ) { } elsif ( $term->{attr} eq 'ExistsInFileSystem' ) {
push @{$self->{PreConditions}}, $term; push @{$self->{PostSQLConditions}}, $term;
} elsif ( $term->{attr} eq 'DiskSpace' ) { } elsif ( $term->{attr} eq 'DiskSpace' ) {
$self->{Sql} .= 'E.DiskSpace'; $self->{Sql} .= 'E.DiskSpace';
push @{$self->{PostConditions}}, $term;
} elsif ( $term->{attr} eq 'DiskPercent' ) { } elsif ( $term->{attr} eq 'DiskPercent' ) {
$self->{Sql} .= 'zmDiskPercent'; $self->{Sql} .= 'zmDiskPercent';
$self->{HasDiskPercent} = !undef; $self->{HasDiskPercent} = !undef;

View File

@ -50,6 +50,9 @@ class Event extends ZM_Object {
public static function clear_cache() { public static function clear_cache() {
return ZM_Object::_clear_cache(get_class()); return ZM_Object::_clear_cache(get_class());
} }
public function remove_from_cache() {
return ZM_Object::_remove_from_cache(get_class(), $this);
}
public function Storage( $new = null ) { public function Storage( $new = null ) {
if ( $new ) { if ( $new ) {

View File

@ -40,8 +40,11 @@ class Filter extends ZM_Object {
public function sql() { public function sql() {
if ( ! isset($this->_sql) ) { if ( ! isset($this->_sql) ) {
foreach ( $this->FilterTerms() as $term ) { foreach ( $this->FilterTerms() as $term ) {
if ( ! ($term->is_pre_sql() or $term->is_post_sql()) ) if ( ! ($term->is_pre_sql() or $term->is_post_sql()) ) {
$this->_sql .= $term->sql(); $this->_sql .= $term->sql();
} else {
$this->_sql .= '1';
}
} # end foreach term } # end foreach term
} }
return $this->_sql; return $this->_sql;

View File

@ -164,13 +164,13 @@ class FilterTerm {
case 'IS' : case 'IS' :
# Odd will be replaced with 1 # Odd will be replaced with 1
# Even will be replaced with 0 # Even will be replaced with 0
if ( $this->value == 'Odd' or $this->value == 'Even' ) { if ( $this->val == 'Odd' or $this->val == 'Even' ) {
return ' % 2 = '; return ' % 2 = ';
} else { } else {
return ' IS '; return ' IS ';
} }
case 'IS NOT' : case 'IS NOT' :
if ( $this->value == 'Odd' or $this->value == 'Even' ) { if ( $this->val == 'Odd' or $this->val == 'Even' ) {
return ' % 2 = '; return ' % 2 = ';
} }
return ' IS NOT '; return ' IS NOT ';
@ -182,7 +182,7 @@ class FilterTerm {
/* Some terms don't have related SQL */ /* Some terms don't have related SQL */
public function sql() { public function sql() {
if ( $this->attr == 'ExistsInFileSystem' ) { if ( $this->attr == 'ExistsInFileSystem' ) {
return ''; return '1';
} }
$sql = ''; $sql = '';

View File

@ -141,6 +141,11 @@ class ZM_Object {
global $object_cache; global $object_cache;
$object_cache[$class] = array(); $object_cache[$class] = array();
} }
public function _remove_from_cache($class, $object) {
global $object_cache;
unset($object_cache[$class][$object->Id()]);
Logger::Debug("Unsset $class " . $object->Id() . " " . count($object_cache[$class]));
}
public static function Objects_Indexed_By_Id($class) { public static function Objects_Indexed_By_Id($class) {
$results = array(); $results = array();

View File

@ -95,6 +95,7 @@ if ( isset($_REQUEST['object']) and ( $_REQUEST['object'] == 'filter' ) ) {
} else if ( $filter->Background() ) { } else if ( $filter->Background() ) {
$filter->control('start'); $filter->control('start');
} }
$redirect = '?view=filter&Id='.$filter->Id();
} else if ( $action == 'control' ) { } else if ( $action == 'control' ) {
if ( $_REQUEST['command'] == 'start' if ( $_REQUEST['command'] == 'start'

View File

@ -286,10 +286,10 @@ for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) {
$imgHTML=''; $imgHTML='';
if ( ZM_WEB_LIST_THUMBS && ($monitor['Status'] == 'Connected') && $running ) { if ( ZM_WEB_LIST_THUMBS && ($monitor['Status'] == 'Connected') && $running ) {
$options = array(); $options = array();
$ratio_factor = $Monitor->Height() / $Monitor->Width(); $ratio_factor = $Monitor->ViewHeight() / $Monitor->ViewWidth();
$options['width'] = ZM_WEB_LIST_THUMB_WIDTH; $options['width'] = ZM_WEB_LIST_THUMB_WIDTH;
$options['height'] = ZM_WEB_LIST_THUMB_HEIGHT ? ZM_WEB_LIST_THUMB_HEIGHT : ZM_WEB_LIST_THUMB_WIDTH*$ratio_factor; $options['height'] = ZM_WEB_LIST_THUMB_HEIGHT ? ZM_WEB_LIST_THUMB_HEIGHT : ZM_WEB_LIST_THUMB_WIDTH*$ratio_factor;
$options['scale'] = intval(100*ZM_WEB_LIST_THUMB_WIDTH / $Monitor->Width()); $options['scale'] = intval(100*ZM_WEB_LIST_THUMB_WIDTH / $Monitor->ViewWidth());
$options['mode'] = 'single'; $options['mode'] = 'single';
$stillSrc = $Monitor->getStreamSrc($options); $stillSrc = $Monitor->getStreamSrc($options);

View File

@ -58,7 +58,7 @@ if ( $_POST ) {
$failed = !$filter->test_pre_sql_conditions(); $failed = !$filter->test_pre_sql_conditions();
if ( $failed ) { if ( $failed ) {
ZM\Logger::Debug("Pre conditions failed, not doing sql"); ZM\Logger::Debug('Pre conditions failed, not doing sql');
} }
$results = $failed ? null : dbQuery($eventsSql); $results = $failed ? null : dbQuery($eventsSql);
@ -189,14 +189,22 @@ xhtmlHeaders(__FILE__, translate('Events'));
$count = 0; $count = 0;
$disk_space_total = 0; $disk_space_total = 0;
if ( $results ) { if ( $results ) {
$events = array();
while ( $event_row = dbFetchNext($results) ) { while ( $event_row = dbFetchNext($results) ) {
$event = new ZM\Event($event_row); $event = new ZM\Event($event_row);
if ( !$filter->test_post_sql_conditions($event) ) { if ( !$filter->test_post_sql_conditions($event) ) {
ZM\Logger::Debug("Failed post conditions"); $event->remove_from_cache();
continue; continue;
} }
$events[] = $event;
if ( $limit and (count($events) > $limit) ) {
break;
}
ZM\Logger::Debug("Have " . count($events) . " events, limit $limit");
}
foreach ( $events as $event ) {
$scale = max(reScale(SCALE_BASE, $event->DefaultScale(), ZM_WEB_DEFAULT_SCALE), SCALE_BASE); $scale = max(reScale(SCALE_BASE, $event->DefaultScale(), ZM_WEB_DEFAULT_SCALE), SCALE_BASE);
?> ?>
@ -280,7 +288,7 @@ if ( $results ) {
?> ?>
</tr> </tr>
<?php <?php
} } # end foreach row
?> ?>
</tbody> </tbody>
<?php <?php

View File

@ -142,6 +142,7 @@ xhtmlHeaders(__FILE__, translate('Frames').' - '.$Event->Id());
data-detail-view="true" data-detail-view="true"
data-detail-formatter="detailFormatter" data-detail-formatter="detailFormatter"
data-show-toggle="true" data-show-toggle="true"
data-show-jump-to="true"
class="table-sm table-borderless"> class="table-sm table-borderless">
<thead> <thead>

View File

@ -53,7 +53,7 @@ function setButtonStates( element ) {
} }
function addMonitor(element) { function addMonitor(element) {
createPopup( '?view=monitor', 'zmMonitor0', 'monitor' ); window.location.assign('?view=monitor');
} }
function cloneMonitor(element) { function cloneMonitor(element) {
@ -73,7 +73,7 @@ function cloneMonitor(element) {
} }
} // end foreach element } // end foreach element
if ( monitorId != -1 ) { if ( monitorId != -1 ) {
createPopup( '?view=monitor&dupId='+monitorId, 'zmMonitor0', 'monitor' ); window.location.assign('?view=monitor&dupId='+monitorId);
} }
} }
@ -97,11 +97,11 @@ function editMonitor( element ) {
} }
} // end foreach checkboxes } // end foreach checkboxes
if ( monitorIds.length == 1 ) { if ( monitorIds.length == 1 ) {
createPopup( '?view=monitor&mid='+monitorIds[0], 'zmMonitor'+monitorIds[0], 'monitor' ); window.location.assign('?view=monitor&mid='+monitorIds[0]);
} else if ( monitorIds.length > 1 ) { } else if ( monitorIds.length > 1 ) {
createPopup( '?view=monitors&'+(monitorIds.map(function(mid) { window.location.assign( '?view=monitors&'+(monitorIds.map(function(mid) {
return 'mids[]='+mid; return 'mids[]='+mid;
}).join('&')), 'zmMonitors', 'monitors' ); }).join('&')));
} }
} }
@ -147,7 +147,7 @@ function initPage() {
reloadWindow.periodical(consoleRefreshTimeout); reloadWindow.periodical(consoleRefreshTimeout);
if ( showVersionPopup ) { if ( showVersionPopup ) {
createPopup('?view=version', 'zmVersion', 'version'); window.location.assign('?view=version');
} }
if ( showDonatePopup ) { if ( showDonatePopup ) {
$j('#donate').modal('show'); $j('#donate').modal('show');

View File

@ -68,6 +68,8 @@ function loadLocations( element ) {
} }
function initPage() { function initPage() {
var backBtn = $j('#backBtn');
//var protocolSelector = $('contentForm').elements['newMonitor[Protocol]']; //var protocolSelector = $('contentForm').elements['newMonitor[Protocol]'];
//if ( $(protocolSelector).getTag() == 'select' ) //if ( $(protocolSelector).getTag() == 'select' )
//updateMethods( $(protocolSelector) ); //updateMethods( $(protocolSelector) );
@ -135,8 +137,22 @@ function initPage() {
el.onchange = window['change_WebColour'].bind(el); el.onchange = window['change_WebColour'].bind(el);
}); });
$j('.chosen').chosen(); $j('.chosen').chosen();
// Don't enable the back button if there is no previous zm page to go back to
backBtn.prop('disabled', !document.referrer.length);
// Manage the BACK button
document.getElementById("backBtn").addEventListener("click", function onBackClick(evt) {
evt.preventDefault();
window.history.back();
});
// Manage the REFRESH Button
document.getElementById("refreshBtn").addEventListener("click", function onRefreshClick(evt) {
evt.preventDefault();
window.location.reload(true);
});
} // end function initPage() } // end function initPage()
function change_WebColour() { function change_WebColour() {

View File

@ -32,7 +32,7 @@ global $CLANG;
<p><?php echo sprintf( $CLANG['CurrentLogin'], $user['Username'] ) ?></p> <p><?php echo sprintf( $CLANG['CurrentLogin'], $user['Username'] ) ?></p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<form name="contentForm" id="contentForm" method="post" action="?"> <form name="logoutForm" id="logoutForm" method="post" action="?">
<input type="hidden" name="view" value="logout"/> <input type="hidden" name="view" value="logout"/>
<button type="submit" name="action" value="logout"><?php echo translate('Logout') ?></button> <button type="submit" name="action" value="logout"><?php echo translate('Logout') ?></button>
<?php if ( ZM_USER_SELF_EDIT ) echo '<button type="submit" name="action" value="config">'.translate('Config').'</button>'.PHP_EOL; ?> <?php if ( ZM_USER_SELF_EDIT ) echo '<button type="submit" name="action" value="config">'.translate('Config').'</button>'.PHP_EOL; ?>

View File

@ -381,9 +381,17 @@ $codecs = array(
xhtmlHeaders(__FILE__, translate('Monitor').' - '.validHtmlStr($monitor->Name())); xhtmlHeaders(__FILE__, translate('Monitor').' - '.validHtmlStr($monitor->Name()));
getBodyTopHTML(); getBodyTopHTML();
echo getNavBarHTML();
?> ?>
<div id="page"> <div id="page">
<div id="header"> <div class="d-flex flex-row justify-content-between px-3 py-1">
<div class="" id="toolbar" >
<button id="backBtn" class="btn btn-normal" data-toggle="tooltip" data-placement="top" title="<?php echo translate('Back') ?>" disabled><i class="fa fa-arrow-left"></i></button>
<button id="refreshBtn" class="btn btn-normal" data-toggle="tooltip" data-placement="top" title="<?php echo translate('Refresh') ?>" ><i class="fa fa-refresh"></i></button>
</div>
<h2><?php echo translate('Monitor') ?> - <?php echo validHtmlStr($monitor->Name()) ?><?php if ( $monitor->Id() ) { ?> (<?php echo $monitor->Id()?>)<?php } ?></h2>
<?php <?php
if ( canEdit('Monitors') ) { if ( canEdit('Monitors') ) {
if ( isset($_REQUEST['dupId']) ) { if ( isset($_REQUEST['dupId']) ) {
@ -394,19 +402,19 @@ if ( canEdit('Monitors') ) {
<?php <?php
} }
?> ?>
<div id="headerButtons"> <div id="">
<?php echo makePopupLink('?view=monitorprobe&mid='.$monitor->Id(), 'zmMonitorProbe'.$monitor->Id(), 'monitorprobe', translate('Probe')); ?> <?php echo makeLink('?view=monitorprobe&mid='.$monitor->Id(), translate('Probe')); ?>
<?php <?php
if ( ZM_HAS_ONVIF ) { if ( ZM_HAS_ONVIF ) {
echo makePopupLink('?view=onvifprobe&mid='.$monitor->Id(), 'zmOnvifProbe'.$monitor->Id(), 'onvifprobe', translate('OnvifProbe')); echo makeLink('?view=onvifprobe&mid='.$monitor->Id(), translate('OnvifProbe'));
} }
?> ?>
<?php echo makePopupLink('?view=monitorpreset&mid=' . $monitor->Id(), 'zmMonitorPreset' . $monitor->Id(), 'monitorpreset', translate('Presets')); ?> <?php echo makeLink('?view=monitorpreset&mid=' . $monitor->Id(), translate('Presets')); ?>
</div> </div>
<?php <?php
} // end if canEdit('Monitors') } // end if canEdit('Monitors')
?> ?>
<h2><?php echo translate('Monitor') ?> - <?php echo validHtmlStr($monitor->Name()) ?><?php if ( $monitor->Id() ) { ?> (<?php echo $monitor->Id()?>)<?php } ?></h2>
</div> </div>
<div id="content"> <div id="content">
<ul class="tabList"> <ul class="tabList">