From 3f62d1e24d691f530f1160bf3a1808f184777d7f Mon Sep 17 00:00:00 2001 From: digital-gnome <31593470+digital-gnome@users.noreply.github.com> Date: Sun, 3 Dec 2017 22:25:17 -0500 Subject: [PATCH 1/4] Montagereview filter respect groups setting --- web/skins/classic/views/download.php | 8 +++-- web/skins/classic/views/js/montagereview.js | 6 ++-- .../classic/views/js/montagereview.js.php | 2 -- web/skins/classic/views/montagereview.php | 32 ++++++++++++++++--- 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/web/skins/classic/views/download.php b/web/skins/classic/views/download.php index cccac537e..272b1f751 100644 --- a/web/skins/classic/views/download.php +++ b/web/skins/classic/views/download.php @@ -23,16 +23,18 @@ if ( !canView( 'Events' ) ) { return; } -if (isset($_REQUEST['filter'])) { //Handles montageReview filter +if (isset($_SESSION['montageReviewFilter'])) { //Handles montageReview filter $eventsSql = 'SELECT E.Id FROM Events as E WHERE 1'; - parseFilter($_REQUEST['filter']); - $eventsSql .= $_REQUEST['filter']['sql']; + $eventsSql .= $_SESSION['montageReviewFilter']['sql']; $results = dbQuery($eventsSql); $eids = []; while ( $event_row = dbFetchNext( $results ) ) { array_push($eids, 'eids[]='.$event_row['Id']); } $_REQUEST['eids'] = $eids; + session_start(); + unset($_SESSION['montageReviewFilter']); + session_write_close(); } $focusWindow = true; diff --git a/web/skins/classic/views/js/montagereview.js b/web/skins/classic/views/js/montagereview.js index 07262c3a0..0ffde9b5f 100644 --- a/web/skins/classic/views/js/montagereview.js +++ b/web/skins/classic/views/js/montagereview.js @@ -335,7 +335,7 @@ function redrawScreen() { $('zoomout').style.display="none"; $('panleft').style.display="none"; $('panright').style.display="none"; - $('downloadVideo').style.display="none"; + if ($('downloadVideo')) $('downloadVideo').style.display="none"; } else { // switch out of liveview mode @@ -352,7 +352,7 @@ function redrawScreen() { $('panleft').style.display="inline-flex"; $('panright').style.display="inline"; $('panright').style.display="inline-flex"; - $('downloadVideo').style.display="inline"; + if ($('downloadVideo')) $('downloadVideo').style.display="inline"; } if ( fitMode == 1 ) { @@ -556,7 +556,7 @@ function click_panright() { clicknav(minTimeSecs,maxTimeSecs,0); } function click_download() { - createPopup( '?view=download'+filterQuery, 'zmDownload', 'download' ); + createPopup( '?view=download', 'zmDownload', 'download' ); } function click_all_events() { clicknav(0,0,0); diff --git a/web/skins/classic/views/js/montagereview.js.php b/web/skins/classic/views/js/montagereview.js.php index e8ac13ff5..69d9c3d22 100644 --- a/web/skins/classic/views/js/montagereview.js.php +++ b/web/skins/classic/views/js/montagereview.js.php @@ -1,6 +1,4 @@ -var filterQuery = ''; - var server_utc_offset = array( 'terms' => array( - array('attr' => 'StartDateTime', 'op' => '>=', 'val' => $_REQUEST['minTime']), - array('attr' => 'StartDateTime', 'op' => '<=', 'val' => $_REQUEST['maxTime'], 'cnj' => 'and'), + array('attr' => 'StartDateTime', 'op' => '>=', 'val' => $_REQUEST['minTime'], 'obr' => '1'), + array('attr' => 'StartDateTime', 'op' => '<=', 'val' => $_REQUEST['maxTime'], 'cnj' => 'and', 'cbr' => '1'), ) ), ); + if (isset($_SESSION['MonitorId'])) { + $filter['Query']['terms'][] = (array('attr' => 'MonitorId', 'op' => '=', 'val' => $_SESSION['MonitorId'], 'cnj' => 'and')); + } + if (( $group_id != 0 || isset($_SESSION['ServerFilter']) || isset($_SESSION['StorageFilter']) || isset($_SESSION['StatusFilter']) ) && !isset($_SESSION['MonitorId'])) { + for ($i=0; $i < count($displayMonitors); $i++) { + if ($i == '0') { + $filter['Query']['terms'][] = array('attr' => 'MonitorId', 'op' => '=', 'val' => $displayMonitors[$i]['Id'], 'cnj' => 'and', 'obr' => '1'); + } else if ($i == (count($displayMonitors)-1)) { + $filter['Query']['terms'][] = array('attr' => 'MonitorId', 'op' => '=', 'val' => $displayMonitors[$i]['Id'], 'cnj' => 'or', 'cbr' => '1'); + } else { + $filter['Query']['terms'][] = array('attr' => 'MonitorId', 'op' => '=', 'val' => $displayMonitors[$i]['Id'], 'cnj' => 'or'); + } + } + } parseFilter( $filter ); - $filterQuery = $filter['query']; + session_start(); + $_SESSION['montageReviewFilter'] = $filter; + session_write_close(); } // Note that this finds incomplete events as well, and any frame records written, but still cannot "see" to the end frame @@ -224,7 +240,13 @@ xhtmlHeaders(__FILE__, translate('MontageReview') ); - + + +
From ab08769adb800c65b60809b76ff29266a5cb559f Mon Sep 17 00:00:00 2001 From: digital-gnome <31593470+digital-gnome@users.noreply.github.com> Date: Mon, 4 Dec 2017 14:48:17 -0500 Subject: [PATCH 2/4] Add nice to archive commands Archiving could hammer io/cpu on the server. Big archives would cause problems. --- web/skins/classic/includes/export_functions.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/skins/classic/includes/export_functions.php b/web/skins/classic/includes/export_functions.php index 604dcba4e..f384594da 100644 --- a/web/skins/classic/includes/export_functions.php +++ b/web/skins/classic/includes/export_functions.php @@ -908,9 +908,9 @@ function exportEvents( $eids, $exportDetail, $exportFrames, $exportImages, $expo $archive = ZM_DIR_EXPORTS."/".$export_root.".tar.gz"; @unlink( $archive ); if ($exportStructure == 'flat') { //strip file paths if we choose - $command = "tar --create --gzip --file=".escapeshellarg($archive)." --files-from=".escapeshellarg($listFile)." --xform='s#^.+/##x'"; + $command = "nice -10 tar --create --gzip --file=".escapeshellarg($archive)." --files-from=".escapeshellarg($listFile)." --xform='s#^.+/##x'"; } else { - $command = "tar --create --gzip --file=".escapeshellarg($archive)." --files-from=".escapeshellarg($listFile); + $command = "nice -10 tar --create --gzip --file=".escapeshellarg($archive)." --files-from=".escapeshellarg($listFile); } exec( $command, $output, $status ); if ( $status ) @@ -926,9 +926,9 @@ function exportEvents( $eids, $exportDetail, $exportFrames, $exportImages, $expo $archive = ZM_DIR_EXPORTS."/".$export_root.".zip"; @unlink( $archive ); if ($exportStructure == 'flat') { - $command = "cat ".escapeshellarg($listFile)." | zip -q -j ".escapeshellarg($archive)." -@"; + $command = "cat ".escapeshellarg($listFile)." | nice -10 zip -q -j ".escapeshellarg($archive)." -@"; } else { - $command = "cat ".escapeshellarg($listFile)." | zip -q ".escapeshellarg($archive)." -@"; + $command = "cat ".escapeshellarg($listFile)." | nice -10 zip -q ".escapeshellarg($archive)." -@"; } //cat zmFileList.txt | zip -q zm_export.zip -@ //-bash: zip: command not found From c72b1f3acf8f001fe08c17a29c87013b18578964 Mon Sep 17 00:00:00 2001 From: digital-gnome <31593470+digital-gnome@users.noreply.github.com> Date: Mon, 4 Dec 2017 17:04:53 -0500 Subject: [PATCH 3/4] Fix refreshParent on some popups Some popups wouldn't refresh the parent because after submit the none view page does not include jquery. This angers javascript and prevents the close function from working. Only fire header refresh code if there is a view. --- web/skins/classic/js/skin.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/web/skins/classic/js/skin.js b/web/skins/classic/js/skin.js index b9afd8503..97041bd65 100644 --- a/web/skins/classic/js/skin.js +++ b/web/skins/classic/js/skin.js @@ -182,18 +182,20 @@ function refreshParentWindow() { } } -$j.ajaxSetup ({timeout: AJAX_TIMEOUT }); //sets timeout for all getJSON. +if (currentView !='none') { + $j.ajaxSetup ({timeout: AJAX_TIMEOUT }); //sets timeout for all getJSON. -$j(document).ready(function() { - if ($j('.navbar').length) setInterval(getNavBar, navBarRefresh) -}); + $j(document).ready(function() { + if ($j('.navbar').length) setInterval(getNavBar, navBarRefresh) + }); -function getNavBar () { - $j.getJSON(thisUrl + '?view=request&request=status&entity=navBar', setNavBar); -} + function getNavBar () { + $j.getJSON(thisUrl + '?view=request&request=status&entity=navBar', setNavBar); + } -function setNavBar (data) { - $j('#reload').replaceWith(data.message); + function setNavBar (data) { + $j('#reload').replaceWith(data.message); + } } //Shows a message if there is an error in the streamObj or the stream doesn't exist. Returns true if error, false otherwise. From 4f40b0464cce1248affa79ce4a60d20c9d5fda52 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 4 Dec 2017 17:11:16 -0500 Subject: [PATCH 4/4] Don't remove MonitorIds column.. just to support downgrading --- db/zm_update-1.31.16.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/zm_update-1.31.16.sql b/db/zm_update-1.31.16.sql index eedd60119..26cdfe317 100644 --- a/db/zm_update-1.31.16.sql +++ b/db/zm_update-1.31.16.sql @@ -80,7 +80,7 @@ SET @s = (SELECT IF( "REPLACE INTO Groups_Monitors (GroupId,MonitorId) SELECT Id,SUBSTRING_INDEX(SUBSTRING_INDEX(t.MonitorIds, ',', n.n), ',', -1) value FROM Groups t CROSS JOIN ( SELECT a.N + b.N * 10 + 1 n FROM (SELECT 0 AS N UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) a ,(SELECT 0 AS N UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) b ORDER BY n ) n WHERE t.MonitorIds != '' AND n.n <= 1 + (LENGTH(t.MonitorIds) - LENGTH(REPLACE(t.MonitorIds, ',', ''))) ORDER BY value;", "SELECT 'MonitorIds has already been removed.'" )); - +/* PREPARE stmt FROM @s; EXECUTE stmt; SET @s = (SELECT IF( @@ -93,3 +93,4 @@ SET @s = (SELECT IF( )); PREPARE stmt FROM @s; EXECUTE stmt; +*/