diff options
Diffstat (limited to 'www/js')
| -rw-r--r-- | www/js/EventModalCtrl.js | 3 | ||||
| -rw-r--r-- | www/js/MontageCtrl.js | 126 | ||||
| -rw-r--r-- | www/js/NVR.js | 8 | ||||
| -rw-r--r-- | www/js/TimelineCtrl.js | 81 |
4 files changed, 134 insertions, 84 deletions
diff --git a/www/js/EventModalCtrl.js b/www/js/EventModalCtrl.js index 92eae748..6741eecf 100644 --- a/www/js/EventModalCtrl.js +++ b/www/js/EventModalCtrl.js @@ -1257,7 +1257,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.$on('modal.removed', function (e, m) { - $ionicSideMenuDelegate.canDragContent(true); + if (!m.disableDrag ) + $ionicSideMenuDelegate.canDragContent(true); if ($rootScope.platformOS == 'desktop') { NVR.debug("Removing keyboard handler"); window.removeEventListener('keydown', keyboardHandler, true); diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js index edca6dbb..7f978447 100644 --- a/www/js/MontageCtrl.js +++ b/www/js/MontageCtrl.js @@ -36,12 +36,13 @@ angular.module('zmApp.controllers') var streamState = { SNAPSHOT: 1, - ACTIVE: 2, - STOPPED: 3, - PAUSED: 4 + SNAPSHOT_LOWQUALITY:2, + ACTIVE: 3, + STOPPED: 4, + PAUSED: 5 }; - var currentStreamState = streamState.SNAPSHOT; // first load snapshot + var currentStreamState = streamState.SNAPSHOT_LOWQUALITY; // first load snapshot $scope.isModalStreamPaused = false; // used in Monitor Modal //var reloadPage = 30; @@ -148,7 +149,7 @@ angular.module('zmApp.controllers') function jiggleMontage() { if ($scope.reOrderActive) return; NVR.debug ('window resized'); - initPackery(); + //initPackery(); } @@ -212,7 +213,7 @@ angular.module('zmApp.controllers') duration: zm.loadingTimeout });*/ - currentStreamState = streamState.SNAPSHOT; + currentStreamState = streamState.SNAPSHOT_LOWQUALITY; $scope.areImagesLoading = true; var progressCalled = false; @@ -330,38 +331,31 @@ angular.module('zmApp.controllers') NVR.debug("All images loaded, but some broke, switching to snapshot..."); //console.log ("******** ALL IMAGES LOADED"); // $scope.$digest(); - allImagesLoadedOrFailed(); + $timeout (function () { + allImagesLoadedOrFailed(); + },100); + }); function allImagesLoadedOrFailed() { - - $timeout(function () { - $scope.areImagesLoading = false; - }); - + $scope.areImagesLoading = false; currentStreamState = streamState.SNAPSHOT; - if (simulStreaming) { - - $timeout(function () { - NVR.debug("Switching mode to active..."); + $timeout (function () { + NVR.debug("Switching mode to streaming as multi-port on..."); + //NVR.regenConnKeys(); + //randEachTime(); currentStreamState = streamState.ACTIVE; - }, 100); - } + },300); + + } + - $ionicLoading.hide(); - - if (!progressCalled) { - NVR.log("*** PROGRESS WAS NOT CALLED"); - // pckry.reloadItems(); - } - - $timeout(function () { + $ionicLoading.hide(); pckry.getItemElements().forEach(function (itemElem) { - draggie = new Draggabilly(itemElem); pckry.bindDraggabillyEvents(draggie); draggies.push(draggie); @@ -409,7 +403,6 @@ angular.module('zmApp.controllers') //pckry.onresize(); - }, 20); } @@ -596,7 +589,7 @@ angular.module('zmApp.controllers') apiurl += '.json?sort=StartTime&direction=desc&limit=1'+$rootScope.authSession; - NVR.debug ("Getting event count "+apiurl); + NVR.debug ("Getting event count "); $http.get(apiurl) .then (function (data) { // console.log ("EVENTS GOT: "+JSON.stringify(data)); @@ -730,8 +723,9 @@ angular.module('zmApp.controllers') } function randEachTime() { + randToAvoidCacheMem = new Date().getTime(); - + //$scope.randToAvoidCacheMem = "1"; //console.log ("Generating:"+$scope.randToAvoidCacheMem); } @@ -808,7 +802,7 @@ angular.module('zmApp.controllers') } // before reorder array } // montage monitors - // console.log ("AFTER REORDER="+JSON.stringify(beforeReorderPositions)); + console.log ("AFTER REORDER="+JSON.stringify(beforeReorderPositions)); for (var n = 0; i < $scope.MontageMonitors.length; i++) { $scope.MontageMonitors[n].Monitor.connKey = NVR.regenConnKeys($scope.MontageMonitors[i]); @@ -1283,11 +1277,16 @@ angular.module('zmApp.controllers') if (simulStreaming) { - NVR.debug("Pausing all streams in montage to save memory/nw..."); + var ld = NVR.getLogin(); + if (ld.pauseStreams) { + NVR.debug("Pausing all streams in montage to save memory/nw..."); + for (var i = 0; i < $scope.MontageMonitors.length; i++) { + if ($scope.MontageMonitors[i].Monitor.listDisplay == 'show') NVR.pauseLiveStream($scope.MontageMonitors[i].Monitor.connKey, $scope.MontageMonitors[i].Monitor.controlURL, $scope.MontageMonitors[i].Monitor.Name); + } - for (var i = 0; i < $scope.MontageMonitors.length; i++) { - if ($scope.MontageMonitors[i].Monitor.listDisplay == 'show') NVR.pauseLiveStream($scope.MontageMonitors[i].Monitor.connKey, $scope.MontageMonitors[i].Monitor.controlURL, $scope.MontageMonitors[i].Monitor.Name); + } else { + NVR.debug ("Not pausing streams as pauseStreams is off"); } } @@ -1378,7 +1377,11 @@ angular.module('zmApp.controllers') function cleanupOnCloseModal() { - + if (simulStreaming){ + randEachTime(); + NVR.debug ('rand each time:'+randToAvoidCacheMem); + } + NVR.log("Restarting montage timers..."); var ld = NVR.getLogin(); // console.log ("closeModal: Cancelling timer"); @@ -1426,11 +1429,16 @@ angular.module('zmApp.controllers') // once regenerated if (simulStreaming) { - NVR.debug("Resuming all stream connkeys in montage ..."); + if (ld.pauseStreams) { + NVR.debug("Resuming all stream connkeys in montage ..."); - for (var i = 0; i < $scope.MontageMonitors.length; i++) { - if ($scope.MontageMonitors[i].Monitor.listDisplay == 'show') NVR.resumeLiveStream($scope.MontageMonitors[i].Monitor.connKey, $scope.MontageMonitors[i].Monitor.controlURL, $scope.MontageMonitors[i].Monitor.Name); + for (var i = 0; i < $scope.MontageMonitors.length; i++) { + if ($scope.MontageMonitors[i].Monitor.listDisplay == 'show') NVR.resumeLiveStream($scope.MontageMonitors[i].Monitor.connKey, $scope.MontageMonitors[i].Monitor.controlURL, $scope.MontageMonitors[i].Monitor.Name); + } + } else { + NVR.debug ("Not resuming streams as pauseStreams is off"); } + } @@ -1671,7 +1679,7 @@ angular.module('zmApp.controllers') // in timeout for iOS as we call stopNetwork $timeout(function () { - + console.log ("SIMUL SWITCH MONTAGE CALLING REGEN"); NVR.regenConnKeys(); $scope.monitors = NVR.getMonitorsNow(); $scope.MontageMonitors = angular.copy($scope.monitors); @@ -1683,7 +1691,9 @@ angular.module('zmApp.controllers') } else { + console.log ("NOT SIMUL SWITCH MONTAGE CALLING REGEN"); NVR.regenConnKeys(); + $scope.monitors = NVR.getMonitorsNow(); $scope.MontageMonitors = angular.copy($scope.monitors); $timeout(function () { @@ -1883,16 +1893,23 @@ angular.module('zmApp.controllers') $scope.processImageError = function(monitor) { + // if (1) return; + + if (currentStreamState != streamState.ACTIVE) return; var mintimesec = 10; var nowt = moment(); var thent = monitor.Monitor.regenTime || moment(); if (nowt.diff(thent, 'seconds') >=mintimesec) { + console.log ('IMAGE ERROR CALLING REGEN'); NVR.regenConnKeys(monitor); NVR.debug ("Image load error for: "+monitor.Monitor.Id+" regenerated connKey is:"+monitor.Monitor.connKey); } else { dur = mintimesec - nowt.diff(thent, 'seconds'); NVR.debug ("Image load error for Monitor: "+monitor.Monitor.Id+" scheduling for connkey regen in "+dur+"s"); - monitor.Monitor.regenHandle = $timeout ( function() {NVR.regenConnKeys(monitor);}, dur*1000 ); + monitor.Monitor.regenHandle = $timeout ( function() { + NVR.debug ('deferred image error, calling regen'); + //console.log ('DEFERRED IMAGE ERROR CALLING REGEN'); + NVR.regenConnKeys(monitor);}, dur*1000 ); } @@ -2039,27 +2056,35 @@ angular.module('zmApp.controllers') var fps = NVR.getLogin().montageliveFPS; if (currentStreamState == streamState.STOPPED || monitor.Monitor.listDisplay == 'noshow' ) { //console.log ("STREAM=empty and auth="+$rootScope.authSession); + //sconsole.log ('EMPTY STREAM'); return ""; } - //console.log ("STREAMING="+monitor.Monitor.streamingURL); - stream = monitor.Monitor.streamingURL + + if (currentStreamState == streamState.SNAPSHOT_LOWQUALITY) { + stream = monitor.Monitor.streamingURL + + "/nph-zms?mode=single&scale=10&monitor="+ monitor.Monitor.Id + "&rand=" + randToAvoidCacheMem + monitor.Monitor.Id ; + // console.log(stream); + + } else { + stream = monitor.Monitor.streamingURL + "/nph-zms?mode=" + getMode() + "&monitor=" + monitor.Monitor.Id + "&scale=" + $scope.LoginData.montageQuality + - "&rand=" + randToAvoidCacheMem + monitor.Monitor.Id + - "&buffer=1000"; + "&buffer=1000"+ + "&rand=" + randToAvoidCacheMem + monitor.Monitor.Id; if (fps) { stream +='&maxfps='+fps; } - - stream += $rootScope.authSession + - appendConnKey(monitor.Monitor.connKey); - if (stream) stream += NVR.insertBasicAuthToken(); + } + + stream += $rootScope.authSession; + stream += appendConnKey(monitor.Monitor.connKey); + if (stream) stream += NVR.insertBasicAuthToken(); + //randEachTime(); //"&rand=" + randToAvoidCacheMem; @@ -2072,10 +2097,7 @@ angular.module('zmApp.controllers') }; function appendConnKey(ck) { - if (simulStreaming && currentStreamState != streamState.SNAPSHOT) return "&connkey=" + ck; - else - return ""; } @@ -2123,7 +2145,7 @@ angular.module('zmApp.controllers') timeInMontage = new Date(); broadcastHandles = []; randToAvoidCacheMem = new Date().getTime(); - currentStreamState = streamState.SNAPSHOT; + $scope.monitors = NVR.getMonitorsNow(); //console.log ("MONITORS:"+JSON.stringify($scope.monitors)); diff --git a/www/js/NVR.js b/www/js/NVR.js index 0d1a9bd2..fed774f4 100644 --- a/www/js/NVR.js +++ b/www/js/NVR.js @@ -207,7 +207,8 @@ angular.module('zmApp.controllers') 'refreshToken': '', 'isKiosk': false, 'kioskPassword': '', - 'useHTTPCaching': true + 'useHTTPCaching': true, + 'pauseStreams': false, }; @@ -1590,6 +1591,11 @@ angular.module('zmApp.controllers') } + if (typeof loginData.pauseStreams == 'undefined') { + loginData.pauseStreams = false; + + } + loginData.canSwipeMonitors = true; loginData.forceImageModePath = false; loginData.enableBlog = true; diff --git a/www/js/TimelineCtrl.js b/www/js/TimelineCtrl.js index e2305e6f..450f5a6e 100644 --- a/www/js/TimelineCtrl.js +++ b/www/js/TimelineCtrl.js @@ -196,7 +196,8 @@ angular.module('zmApp.controllers').controller('zmApp.TimelineCtrl', ['$ionicPla scope: $scope, // give ModalCtrl access to this scope animation: 'slide-in-up', id: 'footage', - showLive: sl + showLive: sl, + disableDrag: true }) .then(function (modal) { $scope.modal = modal; @@ -227,6 +228,7 @@ angular.module('zmApp.controllers').controller('zmApp.TimelineCtrl', ['$ionicPla NVR.debug("TimelineCtrl:Close & Destroy Modal"); NVR.stopNetwork("TimelineCtrl: closeModal"); NVR.setAwake(false); + if ($scope.modal !== undefined) { $scope.modal.remove(); } @@ -235,6 +237,7 @@ angular.module('zmApp.controllers').controller('zmApp.TimelineCtrl', ['$ionicPla $timeout(function () { drawGraph($scope.fromDate, $scope.toDate, maxItems); + }, 500); } @@ -324,18 +327,18 @@ angular.module('zmApp.controllers').controller('zmApp.TimelineCtrl', ['$ionicPla });*/ $scope.$on('$ionicView.beforeEnter', function () { - - $scope.$on ( "process-push", function () { - NVR.debug (">> TimelineCtrl: push handler"); - var s = NVR.evaluateTappedNotification(); - NVR.debug("tapped Notification evaluation:"+ JSON.stringify(s)); - $ionicHistory.nextViewOptions({ - disableAnimate:true, - disableBack: true + $ionicSideMenuDelegate.canDragContent(false); + $scope.$on ( "process-push", function () { + NVR.debug (">> TimelineCtrl: push handler"); + var s = NVR.evaluateTappedNotification(); + NVR.debug("tapped Notification evaluation:"+ JSON.stringify(s)); + $ionicHistory.nextViewOptions({ + disableAnimate:true, + disableBack: true + }); + $state.go(s[0],s[1],s[2]); }); - $state.go(s[0],s[1],s[2]); - }); - + //$ionicHistory.clearCache(); //$ionicHistory.clearHistory(); timeline_instance = ''; @@ -448,7 +451,7 @@ angular.module('zmApp.controllers').controller('zmApp.TimelineCtrl', ['$ionicPla // Make sure sliding for menu is disabled so it // does not interfere with graph panning - $ionicSideMenuDelegate.canDragContent(false); + var ld = NVR.getLogin(); maxItemsConf = ($rootScope.platformOS == 'desktop') ? zm.graphDesktopItemMax : zm.graphItemMax; maxItems = ld.graphSize || maxItemsConf; @@ -564,7 +567,7 @@ angular.module('zmApp.controllers').controller('zmApp.TimelineCtrl', ['$ionicPla var groups, graphData; var isProcessNewEventsWaiting = false; var options; - var dblclick = false; + var lastClicked = moment(); $scope.mycarousel = { index: 0 @@ -1100,10 +1103,17 @@ angular.module('zmApp.controllers').controller('zmApp.TimelineCtrl', ['$ionicPla //tzs = tzs.format("YYYY-MM-DD HH:mm:ss"); //tze = tze.format("YYYY-MM-DD HH:mm:ss"); + // var th = Math.round( window.height() * 0.85 ) + 'px'; options = { showCurrentTime: true, editable: false, + verticalScroll: true, + height: '100%', + //zoomKey: 'ctrlKey', + + //groupHeightMode:'fixed', + //height:$rootScope.devHeight - 10, moment: function (date) { //var t; @@ -1116,6 +1126,7 @@ angular.module('zmApp.controllers').controller('zmApp.TimelineCtrl', ['$ionicPla }, //throttleRedraw: 100, moveable: true, + // height:100, zoomable: true, selectable: true, // multiselect: true, @@ -1309,7 +1320,7 @@ angular.module('zmApp.controllers').controller('zmApp.TimelineCtrl', ['$ionicPla $scope.graphLoaded = true; NVR.debug("graph loaded: " + $scope.graphLoaded); $scope.navControls = false; - dblclick = false; + @@ -1329,18 +1340,20 @@ angular.module('zmApp.controllers').controller('zmApp.TimelineCtrl', ['$ionicPla }); // different handlers for mobile and desktop - // due to how they seem to react to touch differently + // due to how they seeem to react to touch differently if ($rootScope.platformOS == 'desktop') { NVR.debug ("setting up desktop handlers"); timeline_instance.on('click', function (prop) { NVR.debug ("click handler called"); - timelineShowEvent(prop); + timelineShowHover(prop); + }); timeline_instance.on('doubleClick', function (prop) { NVR.debug ("double click handler called"); - timelineAnalyzeFrames(prop); + timelineShowEvent(prop); + //timelineAnalyzeFrames(prop); }); } // mobile handlers @@ -1348,23 +1361,31 @@ angular.module('zmApp.controllers').controller('zmApp.TimelineCtrl', ['$ionicPla // click doesn't seem to work on mobile (iOS at least. wuh?) // this is called for both tap and double tap NVR.debug ("setting up mobile handlers"); - timeline_instance.on('click', function (prop) { - NVR.debug ("click handler called"); - if (dblclick) { - NVR.debug ("Double click detected <= 300ms"); - timelineAnalyzeFrames(prop); + + timeline_instance.on('touchstart', function (prop) { + $timeout (function () { + var now = moment(); + var diff = now.diff(lastClicked); + NVR.debug ('Touch Start called with ms since last clicked:'+diff); + lastClicked = now; + //NVR.debug ('lastClick set to:'+lastClicked); + if (diff <= 500) { + NVR.debug ("Double tap detected <= 500ms"); + //timelineAnalyzeFrames(prop); + timelineShowEvent(prop); } // differntiate between dbl click and click - if (!dblclick) { - dblclick = true; - $timeout (function () { - dblclick = false; - NVR.debug ("Timeout for double click >300ms, single click assumed"); + else { + NVR.debug ("single tap assumed (double tap timeout)"); timelineShowHover(prop); - },300); + } + }); + + + }); } @@ -1442,7 +1463,7 @@ angular.module('zmApp.controllers').controller('zmApp.TimelineCtrl', ['$ionicPla for (var x = 0; x < visible.length; x++) { _item = graphData.get(visible[x]); if (_item.group != prop.group) continue; - console.log ("ITEM start/end is:"+_item.start+'/'+_item.end); + //console.log ("ITEM start/end is:"+_item.start+'/'+_item.end); var dist = Math.min( Math.abs(_item.start - target), Math.abs(_item.end - target)); if (dist < minDist ) { closestId = _item.id; |
