diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm b/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm index 852a05e9b..b48946d1f 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm @@ -203,11 +203,10 @@ sub Sql { $self->{Sql} .= "weekday( E.EndTime )"; # - } elsif ( $term->{attr} eq 'EventExists' ) { - push @{$self->{PreConditions}}, $term; + } elsif ( $term->{attr} eq 'ExistsInFileSystem' ) { + push @{$self->{PostSQLConditions}}, $term; } elsif ( $term->{attr} eq 'DiskSpace' ) { $self->{Sql} .= 'E.DiskSpace'; - push @{$self->{PostConditions}}, $term; } elsif ( $term->{attr} eq 'DiskPercent' ) { $self->{Sql} .= 'zmDiskPercent'; $self->{HasDiskPercent} = !undef; diff --git a/web/includes/Event.php b/web/includes/Event.php index a9eb99d59..a2f4f47c9 100644 --- a/web/includes/Event.php +++ b/web/includes/Event.php @@ -50,6 +50,9 @@ class Event extends ZM_Object { public static function clear_cache() { 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 ) { if ( $new ) { diff --git a/web/includes/Filter.php b/web/includes/Filter.php index 5a441b2ac..d9ca02f0c 100644 --- a/web/includes/Filter.php +++ b/web/includes/Filter.php @@ -40,8 +40,11 @@ class Filter extends ZM_Object { public function sql() { if ( ! isset($this->_sql) ) { 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(); + } else { + $this->_sql .= '1'; + } } # end foreach term } return $this->_sql; diff --git a/web/includes/FilterTerm.php b/web/includes/FilterTerm.php index 63eac2890..1cb720a24 100644 --- a/web/includes/FilterTerm.php +++ b/web/includes/FilterTerm.php @@ -164,13 +164,13 @@ class FilterTerm { case 'IS' : # Odd will be replaced with 1 # Even will be replaced with 0 - if ( $this->value == 'Odd' or $this->value == 'Even' ) { + if ( $this->val == 'Odd' or $this->val == 'Even' ) { return ' % 2 = '; } else { return ' IS '; } case 'IS NOT' : - if ( $this->value == 'Odd' or $this->value == 'Even' ) { + if ( $this->val == 'Odd' or $this->val == 'Even' ) { return ' % 2 = '; } return ' IS NOT '; @@ -182,7 +182,7 @@ class FilterTerm { /* Some terms don't have related SQL */ public function sql() { if ( $this->attr == 'ExistsInFileSystem' ) { - return ''; + return '1'; } $sql = ''; diff --git a/web/includes/Object.php b/web/includes/Object.php index f49497276..d7fa8c654 100644 --- a/web/includes/Object.php +++ b/web/includes/Object.php @@ -141,6 +141,11 @@ class ZM_Object { global $object_cache; $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) { $results = array(); diff --git a/web/includes/actions/filter.php b/web/includes/actions/filter.php index a2e272025..2725c70fc 100644 --- a/web/includes/actions/filter.php +++ b/web/includes/actions/filter.php @@ -95,6 +95,7 @@ if ( isset($_REQUEST['object']) and ( $_REQUEST['object'] == 'filter' ) ) { } else if ( $filter->Background() ) { $filter->control('start'); } + $redirect = '?view=filter&Id='.$filter->Id(); } else if ( $action == 'control' ) { if ( $_REQUEST['command'] == 'start' diff --git a/web/skins/classic/views/console.php b/web/skins/classic/views/console.php index 0a8ce2905..20be7eeeb 100644 --- a/web/skins/classic/views/console.php +++ b/web/skins/classic/views/console.php @@ -286,10 +286,10 @@ for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) { $imgHTML=''; if ( ZM_WEB_LIST_THUMBS && ($monitor['Status'] == 'Connected') && $running ) { $options = array(); - $ratio_factor = $Monitor->Height() / $Monitor->Width(); + $ratio_factor = $Monitor->ViewHeight() / $Monitor->ViewWidth(); $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['scale'] = intval(100*ZM_WEB_LIST_THUMB_WIDTH / $Monitor->Width()); + $options['scale'] = intval(100*ZM_WEB_LIST_THUMB_WIDTH / $Monitor->ViewWidth()); $options['mode'] = 'single'; $stillSrc = $Monitor->getStreamSrc($options); diff --git a/web/skins/classic/views/events.php b/web/skins/classic/views/events.php index 6e85ad3ee..08e0a51a1 100644 --- a/web/skins/classic/views/events.php +++ b/web/skins/classic/views/events.php @@ -58,7 +58,7 @@ if ( $_POST ) { $failed = !$filter->test_pre_sql_conditions(); 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); @@ -189,14 +189,22 @@ xhtmlHeaders(__FILE__, translate('Events')); $count = 0; $disk_space_total = 0; if ( $results ) { + $events = array(); while ( $event_row = dbFetchNext($results) ) { $event = new ZM\Event($event_row); if ( !$filter->test_post_sql_conditions($event) ) { - ZM\Logger::Debug("Failed post conditions"); + $event->remove_from_cache(); 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); ?> @@ -280,7 +288,7 @@ if ( $results ) { ?> Id()); data-detail-view="true" data-detail-formatter="detailFormatter" data-show-toggle="true" + data-show-jump-to="true" class="table-sm table-borderless"> diff --git a/web/skins/classic/views/js/console.js b/web/skins/classic/views/js/console.js index 10b78dce2..4b804a437 100644 --- a/web/skins/classic/views/js/console.js +++ b/web/skins/classic/views/js/console.js @@ -53,7 +53,7 @@ function setButtonStates( element ) { } function addMonitor(element) { - createPopup( '?view=monitor', 'zmMonitor0', 'monitor' ); + window.location.assign('?view=monitor'); } function cloneMonitor(element) { @@ -73,7 +73,7 @@ function cloneMonitor(element) { } } // end foreach element 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 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 ) { - createPopup( '?view=monitors&'+(monitorIds.map(function(mid) { + window.location.assign( '?view=monitors&'+(monitorIds.map(function(mid) { return 'mids[]='+mid; - }).join('&')), 'zmMonitors', 'monitors' ); + }).join('&'))); } } @@ -147,7 +147,7 @@ function initPage() { reloadWindow.periodical(consoleRefreshTimeout); if ( showVersionPopup ) { - createPopup('?view=version', 'zmVersion', 'version'); + window.location.assign('?view=version'); } if ( showDonatePopup ) { $j('#donate').modal('show'); diff --git a/web/skins/classic/views/js/monitor.js b/web/skins/classic/views/js/monitor.js index 3f962ebfb..23e9ec577 100644 --- a/web/skins/classic/views/js/monitor.js +++ b/web/skins/classic/views/js/monitor.js @@ -68,6 +68,8 @@ function loadLocations( element ) { } function initPage() { + var backBtn = $j('#backBtn'); + //var protocolSelector = $('contentForm').elements['newMonitor[Protocol]']; //if ( $(protocolSelector).getTag() == 'select' ) //updateMethods( $(protocolSelector) ); @@ -135,8 +137,22 @@ function initPage() { el.onchange = window['change_WebColour'].bind(el); }); - $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() function change_WebColour() { diff --git a/web/skins/classic/views/logout.php b/web/skins/classic/views/logout.php index e51182064..86e07605a 100644 --- a/web/skins/classic/views/logout.php +++ b/web/skins/classic/views/logout.php @@ -32,7 +32,7 @@ global $CLANG;