From 3b11258fbc26f4c0ca12d7b94a9c1a066abe84fe Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sun, 26 Apr 2020 15:22:29 -0400 Subject: [PATCH 01/11] Make checkEventLoaded return true if a new event was loaded, false otherwise. The idea is to give more information back to whoever calls it --- src/zm_eventstream.cpp | 7 ++++--- src/zm_eventstream.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/zm_eventstream.cpp b/src/zm_eventstream.cpp index 4e2eeb1b7..fbd236cc2 100644 --- a/src/zm_eventstream.cpp +++ b/src/zm_eventstream.cpp @@ -543,7 +543,7 @@ void EventStream::processCommand(const CmdMsg *msg) { updateFrameRate((double)event_data->frame_count/event_data->duration); } // void EventStream::processCommand(const CmdMsg *msg) -void EventStream::checkEventLoaded() { +bool EventStream::checkEventLoaded() { static char sql[ZM_SQL_SML_BUFSIZ]; if ( curr_frame_id <= 0 ) { @@ -558,7 +558,7 @@ void EventStream::checkEventLoaded() { // No event change required Debug(3, "No event change required, as curr frame %d <=> event frames %d", curr_frame_id, event_data->frame_count); - return; + return false; } // Event change required. @@ -586,12 +586,12 @@ void EventStream::checkEventLoaded() { loadEventData(event_id); - Debug(2, "Current frame id = %d", curr_frame_id); if ( replay_rate < 0 ) // rewind curr_frame_id = event_data->frame_count; else curr_frame_id = 1; Debug(2, "New frame id = %d", curr_frame_id); + return true; } else { Debug(2, "No next event loaded using %s. Pausing", sql); if ( curr_frame_id <= 0 ) @@ -611,6 +611,7 @@ void EventStream::checkEventLoaded() { curr_frame_id = event_data->frame_count; paused = true; } + return false; } // void EventStream::checkEventLoaded() Image * EventStream::getImage( ) { diff --git a/src/zm_eventstream.h b/src/zm_eventstream.h index d0b5827e7..6850a3d11 100644 --- a/src/zm_eventstream.h +++ b/src/zm_eventstream.h @@ -90,7 +90,7 @@ class EventStream : public StreamBase { bool loadInitialEventData( uint64_t init_event_id, unsigned int init_frame_id ); bool loadInitialEventData( int monitor_id, time_t event_time ); - void checkEventLoaded(); + bool checkEventLoaded(); void processCommand( const CmdMsg *msg ); bool sendFrame( int delta_us ); From 830929a85fda8de888b86567462e7b04db1b3ec0 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 1 May 2020 10:06:41 -0400 Subject: [PATCH 02/11] Remove extra value='s from PTZ buttons. Fix remaining on-click-this on numbered presets --- web/skins/classic/includes/control_functions.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/web/skins/classic/includes/control_functions.php b/web/skins/classic/includes/control_functions.php index 6f1399786..58b2853c5 100644 --- a/web/skins/classic/includes/control_functions.php +++ b/web/skins/classic/includes/control_functions.php @@ -55,8 +55,8 @@ function controlZoom($monitor, $cmds) { CanAutoZoom() ) { ?> - - + + @@ -77,8 +77,8 @@ function controlIris($monitor, $cmds) { CanAutoIris() ) { ?> - - + + @@ -100,8 +100,8 @@ function controlWhite($monitor, $cmds) { CanAutoWhite() ) { ?> - - + + @@ -162,7 +162,7 @@ function controlPresets($monitor, $cmds) { NumPresets(); $i++ ) { ?> - + @@ -223,9 +223,7 @@ function controlPower($monitor, $cmds) { function ptzControls($monitor) { $control = $monitor->Control(); - //ZM\Error("Control: " . print_r($control,true)); $cmds = $control->commands(); - //ZM\Error("Cmds: " . print_r($cmds, true)); ob_start(); ?>
From 62ddc02d52170c83c5b8ebeee8d063121fdb5a90 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 1 May 2020 13:01:34 -0400 Subject: [PATCH 03/11] quotes to match master --- web/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/index.php b/web/index.php index 18da56e63..29316efc3 100644 --- a/web/index.php +++ b/web/index.php @@ -71,7 +71,7 @@ define('ZM_BASE_URL', ''); require_once('includes/functions.php'); if ( $_SERVER['REQUEST_METHOD'] == 'OPTIONS' ) { - ZM\Logger::Debug("OPTIONS Method, only doing CORS"); + ZM\Logger::Debug('OPTIONS Method, only doing CORS'); # Add Cross domain access headers CORSHeaders(); return; From daa08e874068b01de5c88530be45a9fdca7cbdaa Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 29 Apr 2020 16:35:20 -0400 Subject: [PATCH 04/11] Always just default to scale from monitor --- web/skins/classic/views/watch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/skins/classic/views/watch.php b/web/skins/classic/views/watch.php index fa540557e..bcf40d855 100644 --- a/web/skins/classic/views/watch.php +++ b/web/skins/classic/views/watch.php @@ -46,7 +46,7 @@ if ( isset($_REQUEST['scale']) ) { } else if ( isset($_COOKIE['zmWatchScale'.$mid]) ) { $scale = $_COOKIE['zmWatchScale'.$mid]; } else { - $scale = reScale(SCALE_BASE, $monitor->DefaultScale(), ZM_WEB_DEFAULT_SCALE); + $scale = $monitor->DefaultScale(); } $connkey = generateConnKey(); From 289045500b7ff580c18023c03d1ba785cb01c1ff Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 29 Apr 2020 16:35:04 -0400 Subject: [PATCH 05/11] Don't use event as a variable name unless we are talking about window evnt. Change controlCmd to take the event and get the button from event.target --- web/skins/classic/views/js/watch.js | 91 ++++++++++++++++++----------- 1 file changed, 56 insertions(+), 35 deletions(-) diff --git a/web/skins/classic/views/js/watch.js b/web/skins/classic/views/js/watch.js index e8977ddd6..633d507a5 100644 --- a/web/skins/classic/views/js/watch.js +++ b/web/skins/classic/views/js/watch.js @@ -546,42 +546,62 @@ function getEventCmdResponse( respObj, respText ) { } ); for ( var i = 0; i < dbEvents.length; i++ ) { - var event = dbEvents[i]; - var row = $('event'+event.Id); + var zm_event = dbEvents[i]; + var row = $('event'+zm_event.Id); var newEvent = (row == null ? true : false); if ( newEvent ) { - row = new Element( 'tr', {'id': 'event'+event.Id} ); - new Element( 'td', {'class': 'colId'} ).inject( row ); - new Element( 'td', {'class': 'colName'} ).inject( row ); - new Element( 'td', {'class': 'colTime'} ).inject( row ); - new Element( 'td', {'class': 'colSecs'} ).inject( row ); - new Element( 'td', {'class': 'colFrames'} ).inject( row ); - new Element( 'td', {'class': 'colScore'} ).inject( row ); - new Element( 'td', {'class': 'colDelete'} ).inject( row ); + row = new Element('tr', {'id': 'event'+zm_event.Id}); + new Element('td', {'class': 'colId'}).inject(row); + new Element('td', {'class': 'colName'}).inject(row); + new Element('td', {'class': 'colTime'}).inject(row); + new Element('td', {'class': 'colSecs'}).inject(row); + new Element('td', {'class': 'colFrames'}).inject(row); + new Element('td', {'class': 'colScore'}).inject(row); + new Element('td', {'class': 'colDelete'}).inject(row); - var link = new Element( 'a', {'href': '#', 'events': {'click': createEventPopup.pass( [event.Id, '&filter[Query][terms][0][attr]=MonitorId&filter[Query][terms][0][op]=%3d&filter[Query][terms][0][val]='+monitorId+'&page=1&popup=1', event.Width, event.Height] )}}); - link.set( 'text', event.Id ); - link.inject( row.getElement( 'td.colId' ) ); + var link = new Element('a', { + 'href': '#', + 'events': { + 'click': createEventPopup.pass( [ + zm_event.Id, + '&filter[Query][terms][0][attr]=MonitorId&filter[Query][terms][0][op]=%3d&filter[Query][terms][0][val]='+monitorId+'&page=1&popup=1', + zm_event.Width, + zm_event.Height + ] ) + } + }); + link.set('text', zm_event.Id); + link.inject(row.getElement('td.colId')); - link = new Element( 'a', {'href': '#', 'events': {'click': createEventPopup.pass( [event.Id, '&filter[Query][terms][0][attr]=MonitorId&filter[Query][terms][0][op]=%3d&filter[Query][terms][0][val]='+monitorId+'&page=1&popup=1', event.Width, event.Height] )}}); - link.set( 'text', event.Name ); - link.inject( row.getElement( 'td.colName' ) ); + link = new Element('a', { + 'href': '#', + 'events': { + 'click': createEventPopup.pass( [ + zm_event.Id, + '&filter[Query][terms][0][attr]=MonitorId&filter[Query][terms][0][op]=%3d&filter[Query][terms][0][val]='+monitorId+'&page=1&popup=1', + zm_event.Width, + zm_event.Height + ] ) + } + }); + link.set('text', zm_event.Name); + link.inject(row.getElement('td.colName')); - row.getElement( 'td.colTime' ).set( 'text', event.StartTime ); - row.getElement( 'td.colSecs' ).set( 'text', event.Length ); + row.getElement('td.colTime').set('text', zm_event.StartTime); + row.getElement('td.colSecs').set('text', zm_event.Length); - link = new Element( 'a', {'href': '#', 'events': {'click': createFramesPopup.pass( [event.Id, event.Width, event.Height] )}}); - link.set( 'text', event.Frames+'/'+event.AlarmFrames ); - link.inject( row.getElement( 'td.colFrames' ) ); + link = new Element('a', {'href': '#', 'events': {'click': createFramesPopup.pass( [zm_event.Id, zm_event.Width, zm_event.Height] )}}); + link.set('text', zm_event.Frames+'/'+zm_event.AlarmFrames); + link.inject(row.getElement('td.colFrames')); - link = new Element( 'a', {'href': '#', 'events': {'click': createFramePopup.pass( [event.Id, '0', event.Width, event.Height] )}}); - link.set( 'text', event.AvgScore+'/'+event.MaxScore ); - link.inject( row.getElement( 'td.colScore' ) ); + link = new Element('a', {'href': '#', 'events': {'click': createFramePopup.pass( [zm_event.Id, '0', zm_event.Width, zm_event.Height] )}}); + link.set('text', zm_event.AvgScore+'/'+zm_event.MaxScore); + link.inject(row.getElement('td.colScore')); - link = new Element( 'button', { + link = new Element('button', { 'type': 'button', 'title': deleteString, - 'data-event-id': event.Id, + 'data-event-id': zm_event.Id, 'events': { 'click': function(e) { var event_id = e.target.getAttribute('data-event-id'); @@ -608,14 +628,14 @@ function getEventCmdResponse( respObj, respText ) { } } } else { - row.getElement('td.colName a').set('text', event.Name); - row.getElement('td.colSecs').set('text', event.Length); - row.getElement('td.colFrames a').set('text', event.Frames+'/'+event.AlarmFrames); - row.getElement('td.colScore a').set('text', event.AvgScore+'/'+event.MaxScore); + row.getElement('td.colName a').set('text', zm_event.Name); + row.getElement('td.colSecs').set('text', zm_event.Length); + row.getElement('td.colFrames a').set('text', zm_event.Frames+'/'+zm_event.AlarmFrames); + row.getElement('td.colScore a').set('text', zm_event.AvgScore+'/'+zm_event.MaxScore); row.removeClass('recent'); } row.addClass('updated'); - } + } // end foreach event var rows = $(eventListBody).getElements('tr'); for ( var i = 0; i < rows.length; i++ ) { @@ -631,7 +651,7 @@ function getEventCmdResponse( respObj, respText ) { } } else { checkStreamForErrors('getEventCmdResponse', respObj); - } + } // end if objresult == ok var eventCmdTimeout = eventsRefreshTimeout; if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT ) { @@ -672,7 +692,8 @@ function getControlResponse(respObj, respText) { } } -function controlCmd(button) { +function controlCmd(event) { + button = event.target; control = button.getAttribute('value'); xtell = button.getAttribute('xtell'); ytell = button.getAttribute('ytell'); @@ -687,7 +708,7 @@ function controlCmd(button) { var y = event.pageY - coords.top; if ( xtell ) { - var xge = parseInt( (x*100)/coords.width ); + var xge = parseInt((x*100)/coords.width); if ( xtell == -1 ) { xge = 100 - xge; } else if ( xtell == 2 ) { @@ -696,7 +717,7 @@ function controlCmd(button) { locParms += '&xge='+xge; } if ( ytell ) { - var yge = parseInt( (y*100)/coords.height ); + var yge = parseInt((y*100)/coords.height); if ( ytell == -1 ) { yge = 100 - yge; } else if ( ytell == 2 ) { From 4c9f67eb5a4127b16f031ae5b24bc55e350a0461 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 29 Apr 2020 16:34:27 -0400 Subject: [PATCH 06/11] Fix no redirect on login with palemoon browser --- web/skins/classic/views/js/postlogin.js.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/skins/classic/views/js/postlogin.js.php b/web/skins/classic/views/js/postlogin.js.php index 75c241a91..a062b4c52 100644 --- a/web/skins/classic/views/js/postlogin.js.php +++ b/web/skins/classic/views/js/postlogin.js.php @@ -21,13 +21,13 @@ } ?>'; - if ( querySuffix == '?view=login' ) { + if ( querySuffix == '?view=login' || querySuffix == '' ) { // If we didn't redirect elsewhere, then don't show login page, go to console querySuffix = '?view=console'; } var newUrl = querySuffix; - -console.log("Redirecting to" + newUrl + ' ' + thisUrl); +console.log("Current location: " + window.location); +console.log("Redirecting to (" + newUrl + ') from :' + thisUrl); window.location.replace(newUrl); } ).delay( 500 ); From 2da88be307df2fcbbc85e3b9443dd4222b84837e Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 29 Apr 2020 16:34:07 -0400 Subject: [PATCH 07/11] Use auth_relay instead of auth_hash if AUTH_RELAY==plain or none. --- web/skins/classic/views/js/montage.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/skins/classic/views/js/montage.js b/web/skins/classic/views/js/montage.js index b88833db0..d0e0c348c 100644 --- a/web/skins/classic/views/js/montage.js +++ b/web/skins/classic/views/js/montage.js @@ -13,6 +13,8 @@ function Monitor(monitorData) { this.streamCmdParms = 'view=request&request=stream&connkey='+this.connKey; if ( auth_hash ) { this.streamCmdParms += '&auth='+auth_hash; + } else if ( auth_relay ) { + this.streamCmdParms += '&'+auth_relay; } this.streamCmdTimer = null; this.type = monitorData.type; From 89245e0d46aca69ae989df1f41c920f9d4d164ec Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 29 Apr 2020 16:33:41 -0400 Subject: [PATCH 08/11] Add auth relay information when auth_relay is something other than hashed. --- web/skins/classic/js/skin.js.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/web/skins/classic/js/skin.js.php b/web/skins/classic/js/skin.js.php index a9f6b85af..5250e654f 100644 --- a/web/skins/classic/js/skin.js.php +++ b/web/skins/classic/js/skin.js.php @@ -71,6 +71,22 @@ var focusWindow = ; var imagePrefix = ""; var auth_hash; - -auth_hash = ''; - +var auth_relay; + From e29c426f04b803f1b96a5d5cf59242885714b123 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 29 Apr 2020 16:32:55 -0400 Subject: [PATCH 09/11] Pass event object to data-on-click events --- web/skins/classic/js/skin.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/skins/classic/js/skin.js b/web/skins/classic/js/skin.js index dd965a39f..2012837e8 100644 --- a/web/skins/classic/js/skin.js +++ b/web/skins/classic/js/skin.js @@ -182,8 +182,8 @@ window.addEventListener("DOMContentLoaded", function onSkinDCL() { return; } - el.onclick = function() { - window[fnName](); + el.onclick = function(ev) { + window[fnName](ev); }; }); From bd7475a450dd6dde63715bf0cedd7f7416c7b3d8 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 29 Apr 2020 16:32:26 -0400 Subject: [PATCH 10/11] use on-click instead of on-click-this. We can get the button from event.target. The palemoon browser doesn't have a global event object so this wasn't working --- .../classic/includes/control_functions.php | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/web/skins/classic/includes/control_functions.php b/web/skins/classic/includes/control_functions.php index 58b2853c5..ac66c6f3f 100644 --- a/web/skins/classic/includes/control_functions.php +++ b/web/skins/classic/includes/control_functions.php @@ -25,15 +25,15 @@ function controlFocus($monitor, $cmds) { ?>
- - - + + +
CanAutoFocus() ) { ?> - - + + @@ -48,15 +48,15 @@ function controlZoom($monitor, $cmds) { ?>
- - - + + +
CanAutoZoom() ) { ?> - - + + @@ -70,15 +70,15 @@ function controlIris($monitor, $cmds) { ?>
- - - + + +
CanAutoIris() ) { ?> - - + + @@ -93,15 +93,15 @@ function controlWhite($monitor, $cmds) { ?>
- - - + + +
CanAutoWhite() ) { ?> - - + + @@ -122,19 +122,19 @@ function controlPanTilt($monitor, $cmds) { $hasTilt = $control->CanTilt(); $hasDiag = $hasPan && $hasTilt && $control->CanMoveDiag(); ?> - - - - + + + + - + - - - - + + + +
NumPresets(); $i++ ) { ?> - + @@ -171,7 +171,7 @@ function controlPresets($monitor, $cmds) { HasHomePreset() ) { ?> - + CanSetPresets() ) { @@ -196,22 +196,22 @@ function controlPower($monitor, $cmds) { CanWake() ) { ?> - + CanSleep() ) { ?> - + CanReset() ) { ?> - + CanReboot() ) { ?> - + From e960e638b33197e462737dc1c23f7b7fe5a79e41 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 1 May 2020 10:06:41 -0400 Subject: [PATCH 11/11] Remove extra value='s from PTZ buttons. Fix remaining on-click-this on numbered presets --- web/skins/classic/includes/control_functions.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/web/skins/classic/includes/control_functions.php b/web/skins/classic/includes/control_functions.php index ac66c6f3f..61138612f 100644 --- a/web/skins/classic/includes/control_functions.php +++ b/web/skins/classic/includes/control_functions.php @@ -55,8 +55,8 @@ function controlZoom($monitor, $cmds) { CanAutoZoom() ) { ?> - - + + @@ -77,8 +77,8 @@ function controlIris($monitor, $cmds) { CanAutoIris() ) { ?> - - + + @@ -100,8 +100,8 @@ function controlWhite($monitor, $cmds) { CanAutoWhite() ) { ?> - - + + @@ -162,7 +162,7 @@ function controlPresets($monitor, $cmds) { NumPresets(); $i++ ) { ?> - +