diff options
| -rw-r--r-- | www/js/DataModel.js | 176 | ||||
| -rw-r--r-- | www/js/EventCtrl.js | 25 | ||||
| -rw-r--r-- | www/js/MontageCtrl.js | 64 | ||||
| -rw-r--r-- | www/js/TimelineCtrl.js | 10 | ||||
| -rw-r--r-- | www/templates/devoptions.html | 8 | ||||
| -rw-r--r-- | www/templates/reorder-modal.html | 2 |
6 files changed, 125 insertions, 160 deletions
diff --git a/www/js/DataModel.js b/www/js/DataModel.js index 538c3009..59fca7b4 100644 --- a/www/js/DataModel.js +++ b/www/js/DataModel.js @@ -231,6 +231,32 @@ angular.module('zmApp.controllers') } + function reloadMonitorDisplayStatus() + { + debug ("Loading hidden/unhidden status..."); + var positionsStr = loginData.packeryPositions; + //console.log ("positionStr="+positionsStr); + var positions = {}; + if (loginData.packeryPositions != '') + { + positions = JSON.parse(positionsStr); + for (var m = 0; m < monitors.length; m++) + { + for (var p = 0; p < positions.length; p++) + { + if (monitors[m].Monitor.Id == positions[p].attr) + { + monitors[m].Monitor.listDisplay = positions[p].display; + debug ("DataModel: Setting MID:"+monitors[m].Monitor.Id+" to " + monitors[m].Monitor.listDisplay); + } + + + } + } + + + } + } function setLogin(newLogin) { @@ -500,6 +526,7 @@ angular.module('zmApp.controllers') + log("ZMData init: checking for stored variables & setting up log file"); @@ -574,6 +601,10 @@ angular.module('zmApp.controllers') loginData = loadedData; // old version hacks for new variables + + // always true Oct 27 2016 + loginData.persistMontageOrder = true; + loginData.enableh264 = true; if (typeof loginData.enableAlarmCount === 'undefined') { debug("enableAlarmCount does not exist, setting to true"); @@ -813,6 +844,7 @@ angular.module('zmApp.controllers') + // FIXME: HACK: This is the latest entry point into dataModel init, so start portal login after this // not the neatest way $rootScope.$emit('init-complete'); @@ -902,7 +934,10 @@ angular.module('zmApp.controllers') //return window.localStorage.getItem("defaultLang"); }, - + + reloadMonitorDisplayStatus: function() { + return reloadMonitorDisplayStatus(); + }, getLogin: function () { @@ -1182,113 +1217,7 @@ angular.module('zmApp.controllers') return getBandwidth(); }, - //-------------------------------------------------------------------------- - // This is really a hack for now & is very ugly. I need to clean this up a lot - // it re-arranges monitors based on montage and hidden order so that - // I can reuse this from events and timeline view if persist monitor states - // is on - //-------------------------------------------------------------------------- - applyMontageMonitorPrefs: function (mon, doOrder) { - var montageOrder = []; // This array will keep the ordering in montage view - var hiddenOrder = []; // 1 = hide, 0 = don't hide - var monitors = mon; - var orderedMonitors = []; - - - // First let's check if the user already has a saved monitor order - var i; - if (loginData.montageOrder == '') { - //if (window.localStorage.getItem("montageOrder") == undefined) { - - for (i = 0; i < monitors.length; i++) { - montageOrder[i] = i; // order to show is order ZM returns - hiddenOrder[i] = 0; // don't hide them - } - //console.log("Order string is " + montageOrder.toString()); - //console.log("Hiddent string is " + hiddenOrder.toString()); - - log("Stored montage order does not exist"); - } else - // there is a saved order - { - var myorder = loginData.montageOrder; - var myhiddenorder = loginData.montageHiddenOrder; - - - debug("MontageCtrl: Montage order is " + myorder); - debug("MontageCtrl: Hidden order is " + myhiddenorder); - if (myorder) montageOrder = myorder.split(","); - if (myhiddenorder) hiddenOrder = myhiddenorder.split(","); - - // handle add/delete monitors after the array has been - // saved - - if (monitors.length != montageOrder.length) { - log("Monitors array length different from stored hidden/order array. It's possible monitors were added/removed. Resetting..."); - montageOrder = []; - hiddenOrder = []; - for (i = 0; i < monitors.length; i++) { - montageOrder[i] = i; // order to show is order ZM returns - hiddenOrder[i] = 0; // don't hide them - } - - loginData.montageOrder = montageOrder.toString(); - loginData.montageHiddenOrder = hiddenOrder.toString(); - setLogin(loginData); - //window.localStorage.setItem("montageOrder", - // montageOrder.toString()); - // window.localStorage.setItem("montageHiddenOrder", - // hiddenOrder.toString()); - - - } - - } // at this stage, the monitor arrangement is not matching - // the montage order. Its in true order. Let us first process the hiddenOrder part - // now - - for (i = 0; i < montageOrder.length; i++) { - montageOrder[i] = parseInt(montageOrder[i]); - hiddenOrder[i] = parseInt(hiddenOrder[i]); - // $scope.monitors[i].Monitor.sortOrder = montageOrder[i]; - // FIXME: This will briefly show and then hide - // disabled monitors - if (hiddenOrder[i] == 1) { - // $scope.monitors[i].Monitor.listDisplay='noshow'; - - if (monitors[i] !== undefined) - monitors[i].Monitor.listDisplay = 'noshow'; - log("Monitor " + i + " is marked as hidden in montage"); - } else { - if (monitors[i] !== undefined) - monitors[i].Monitor.listDisplay = 'show'; - } - } - - - if (doOrder) { - for (i = 0; i < montageOrder.length; i++) { - for (var j = 0; j < montageOrder.length; j++) { - if (montageOrder[j] == i) { - // if 2 is passed, hidden elements are not recorded - if (doOrder == 2) { - if (monitors[j].Monitor.listDisplay != 'noshow') - orderedMonitors.push(monitors[j]); - } else - orderedMonitors.push(monitors[j]); - } - } - } - } else { - orderedMonitors = monitors; - } - - - - return ([orderedMonitors, montageOrder, hiddenOrder]); - - }, - + //----------------------------------------------------------------------------- // This function returns a list of monitors // if forceReload == 1 then it will force an HTTP API request to get a list of monitors @@ -1332,6 +1261,11 @@ angular.module('zmApp.controllers') }); //console.log("promise resolved inside HTTP success"); monitorsLoaded = 1; + + reloadMonitorDisplayStatus(); + + + debug("Now trying to get multi-server data, if present"); $http.get(apiurl + "/servers.json") .success(function (data) { @@ -1342,7 +1276,7 @@ angular.module('zmApp.controllers') for (var i = 0; i < monitors.length; i++) { - monitors[i].Monitor.listDisplay = 'show'; + //monitors[i].Monitor.listDisplay = 'show'; monitors[i].Monitor.isAlarmed = false; monitors[i].Monitor.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); @@ -1392,6 +1326,9 @@ angular.module('zmApp.controllers') baseurl = st; st += (s.path ? s.path : p.path); + + //console.log ("----------STREAMING URL PARSED AS " + st); + monitors[i].Monitor.streamingURL = st; monitors[i].Monitor.baseURL = baseurl; // starting 1.30 we have fid=xxx mode to return images @@ -1403,7 +1340,7 @@ angular.module('zmApp.controllers') } else { - monitors[i].Monitor.listDisplay = 'show'; + //monitors[i].Monitor.listDisplay = 'show'; monitors[i].Monitor.isAlarmed = false; monitors[i].Monitor.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); monitors[i].Monitor.streamingURL = loginData.streamingurl; @@ -1427,7 +1364,7 @@ angular.module('zmApp.controllers') multiservers = []; for (var i = 0; i < monitors.length; i++) { - monitors[i].Monitor.listDisplay = 'show'; + //monitors[i].Monitor.listDisplay = 'show'; monitors[i].Monitor.isAlarmed = false; monitors[i].Monitor.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); monitors[i].Monitor.streamingURL = loginData.streamingurl; @@ -1535,6 +1472,23 @@ angular.module('zmApp.controllers') return d.promise; }, + // returns if this mid is hidden or not + isNotHidden: function(mid) + { + var notHidden = true; + for (var i=0; i<monitors.length; i++) + { + if (monitors[i].Monitor.Id == mid) + { + notHidden = (monitors[i].Monitor.listDisplay =='show') ? true:false; + break; + } + + } + return notHidden; + + }, + //returns TZ value immediately (sync) getTimeZoneNow: function() diff --git a/www/js/EventCtrl.js b/www/js/EventCtrl.js index 7b471457..611cef17 100644 --- a/www/js/EventCtrl.js +++ b/www/js/EventCtrl.js @@ -283,10 +283,10 @@ angular.module('zmApp.controllers') var stackState = $ionicHistory.backTitle(); // If you came from Monitors, disregard hidden monitors in montage - if (lData.persistMontageOrder && stackState != "Monitors") { + /* if (lData.persistMontageOrder && stackState != "Monitors") { var tempMon = message; $scope.monitors = NVRDataModel.applyMontageMonitorPrefs(tempMon, 2)[0]; - } else + } else*/ $scope.monitors = message; @@ -345,7 +345,7 @@ angular.module('zmApp.controllers') if (loginData.persistMontageOrder) { idfound = false; for (var ii = 0; ii < $scope.monitors.length; ii++) { - if ($scope.monitors[ii].Monitor.Id == myevents[i].Event.MonitorId) { + if ($scope.monitors[ii].Monitor.Id == myevents[i].Event.MonitorId && NVRDataModel.isNotHidden(myevents[i].Event.MonitorId)) { idfound = true; break; @@ -842,10 +842,12 @@ angular.module('zmApp.controllers') if (p.hasOwnProperty(key)) { var idfound = true; + //console.log ("PERSIST IS " + ld.persistMontageOrder); if (ld.persistMontageOrder) { idfound = false; for (var ii = 0; ii < $scope.monitors.length; ii++) { - if ($scope.monitors[ii].Monitor.Id == key) { + if ($scope.monitors[ii].Monitor.Id == key && NVRDataModel.isNotHidden(key) ) { + // console.log ("Authorizing "+$scope.monitors[ii].Monitor.Name); idfound = true; break; } @@ -877,7 +879,7 @@ angular.module('zmApp.controllers') if (ld.persistMontageOrder) { idfound = false; for (var ii = 0; ii < $scope.monitors.length; ii++) { - if ($scope.monitors[ii].Monitor.Id == key) { + if ($scope.monitors[ii].Monitor.Id == key && NVRDataModel.isNotHidden(key)) { idfound = true; break; } @@ -912,7 +914,7 @@ angular.module('zmApp.controllers') if (ld.persistMontageOrder) { idfound = false; for (var ii = 0; ii < $scope.monitors.length; ii++) { - if ($scope.monitors[ii].Monitor.Id == key) { + if ($scope.monitors[ii].Monitor.Id == key && NVRDataModel.isNotHidden(key)) { idfound = true; break; } @@ -947,7 +949,7 @@ angular.module('zmApp.controllers') if (ld.persistMontageOrder) { idfound = false; for (var ii = 0; ii < $scope.monitors.length; ii++) { - if ($scope.monitors[ii].Monitor.Id == key) { + if ($scope.monitors[ii].Monitor.Id == key && NVRDataModel.isNotHidden(key)) { idfound = true; break; } @@ -1710,7 +1712,7 @@ angular.module('zmApp.controllers') if (ld.persistMontageOrder) { idfound = false; for (var ii = 0; ii < $scope.monitors.length; ii++) { - if ($scope.monitors[ii].Monitor.Id == myevents[i].Event.MonitorId) { + if ($scope.monitors[ii].Monitor.Id == myevents[i].Event.MonitorId && NVRDataModel.isNotHidden(myevents[i].Event.MonitorId)) { //console.log ( $scope.monitors[ii].Monitor.Id + " MATCHES " + myevents[i].Event.MonitorId); idfound = true; @@ -1842,14 +1844,15 @@ angular.module('zmApp.controllers') NVRDataModel.debug("Reloading monitors"); var refresh = NVRDataModel.getMonitors(1); refresh.then(function (data) { - - var ld = NVRDataModel.getLogin(); + $scope.monitors = data; + + /* var ld = NVRDataModel.getLogin(); if (ld.persistMontageOrder) { var tempMon = data; $scope.monitors = NVRDataModel.applyMontageMonitorPrefs(tempMon, 2)[0]; } else { $scope.monitors = data; - } + }*/ getInitialEvents(); diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js index 5714ffa0..8a76b646 100644 --- a/www/js/MontageCtrl.js +++ b/www/js/MontageCtrl.js @@ -410,53 +410,63 @@ angular.module('zmApp.controllers') $scope.modal.remove(); }; + + + $scope.saveReorder = function () { - NVRDataModel.debug("Saving monitor hide/unhide and sizes"); - + NVRDataModel.debug("Saving monitor hide/unhide"); + // redo packery as monitor status has changed + // DOM may need reloading if you've hidden/unhidden stuff $scope.MontageMonitors = $scope.copyMontage; $scope.modal.remove(); + $timeout(function () { - pckry.reloadItems(); - }, 400); - $timeout(function () { - + draggies.forEach(function (drag) { drag.destroy(); }); - + + pckry.reloadItems(); draggies = []; - - pckry.once('layoutComplete', function () { - //console.log('Saving packery order now, layout rendered'); - $timeout(function () { + pckry.once ('layoutComplete', savePackeryOrder); + pckry.layout(); + + + + }, 400); + + function savePackeryOrder () + { + $timeout(function () { var positions = pckry.getShiftPositions('data-item-id'); NVRDataModel.debug("POSITIONS MAP " + JSON.stringify(positions)); var ld = NVRDataModel.getLogin(); ld.packeryPositions = JSON.stringify(positions); - //console.log ("Saving " + ld.packeryPositions); + //console.log ("Savtogging " + ld.packeryPositions); NVRDataModel.setLogin(ld); + + pckry.getItemElements().forEach(function (itemElem) { + draggie = new Draggabilly(itemElem); + pckry.bindDraggabillyEvents(draggie); + draggies.push(draggie); + draggie.disable(); + }); + + $ionicScrollDelegate.$getByHandle("montage-delegate").scrollTop(); + + // Now also ask DataModel to update its monitor display status + NVRDataModel.reloadMonitorDisplayStatus(); }); - }); - - pckry.getItemElements().forEach(function (itemElem) { - draggie = new Draggabilly(itemElem); - pckry.bindDraggabillyEvents(draggie); - draggies.push(draggie); - draggie.disable(); - }); - pckry.layout(); - - }, 800); - - $ionicScrollDelegate.$getByHandle("montage-delegate").scrollTop(); + } + }; - $scope.toggleDelete = function (i) { + $scope.toggleHide = function (i) { if ($scope.copyMontage[i].Monitor.listDisplay == 'show') $scope.copyMontage[i].Monitor.listDisplay = 'noshow'; @@ -470,6 +480,8 @@ angular.module('zmApp.controllers') if ($scope.isDragabillyOn) { dragToggle(); } + // make a copy of the current list and work on that + // this is to avoid packery screw ups while you are hiding/unhiding $scope.copyMontage = angular.copy($scope.MontageMonitors); $ionicModal.fromTemplateUrl('templates/reorder-modal.html', { scope: $scope, diff --git a/www/js/TimelineCtrl.js b/www/js/TimelineCtrl.js index 9da3ad37..16b809b9 100644 --- a/www/js/TimelineCtrl.js +++ b/www/js/TimelineCtrl.js @@ -320,11 +320,13 @@ angular.module('zmApp.controllers').controller('zmApp.TimelineCtrl', ['$ionicPla var ld = NVRDataModel.getLogin(); $scope.loginData = NVRDataModel.getLogin(); - if (ld.persistMontageOrder) { + /* if (ld.persistMontageOrder) { var iMon = NVRDataModel.applyMontageMonitorPrefs(tempMon, 2); $scope.monitors = iMon[0]; - } else - $scope.monitors = message; + } else*/ + + + $scope.monitors = message; if ($rootScope.customTimelineRange) { // console.log("***** CUSTOM RANGE"); if (moment($rootScope.fromString).isValid() && @@ -657,7 +659,7 @@ angular.module('zmApp.controllers').controller('zmApp.TimelineCtrl', ['$ionicPla idfound = false; for (var ii = 0; ii < $scope.monitors.length; ii++) { - if ($scope.monitors[ii].Monitor.Id == myevents[i].Event.MonitorId) { + if ($scope.monitors[ii].Monitor.Id == myevents[i].Event.MonitorId && NVRDataModel.isNotHidden(myevents[i].Event.MonitorId) ) { idfound = true; //console.log ("****************** ID MATCH " + graphIndex); diff --git a/www/templates/devoptions.html b/www/templates/devoptions.html index b0884da2..ceca335c 100644 --- a/www/templates/devoptions.html +++ b/www/templates/devoptions.html @@ -162,16 +162,10 @@ </label> <label> - <ion-toggle ng-model="loginData.persistMontageOrder" ng-checked="{{loginData.persistMontageOrder}}" toggle-class="toggle-calm">{{'kPersistHidden' | translate}}</ion-toggle> - </label> - - <label> <ion-toggle ng-model="loginData.forceImageModePath" ng-checked="{{loginData.forceImageModePath}}" toggle-class="toggle-calm"> {{'kForceImagePath' | translate}}</ion-toggle> </label> - <label> - <ion-toggle ng-model="loginData.enableh264" ng-checked="{{loginData.enableh264}}" toggle-class="toggle-calm"> {{'kH264VideoSupport' | translate}}</ion-toggle> - </label> + <!-- <label> diff --git a/www/templates/reorder-modal.html b/www/templates/reorder-modal.html index 4e3ce82d..f58d567c 100644 --- a/www/templates/reorder-modal.html +++ b/www/templates/reorder-modal.html @@ -19,7 +19,7 @@ <ion-content > <div class="list"> <span ng-repeat="item in copyMontage"> - <a class="item item-icon-left" ng-click="toggleDelete($index)" href=""> + <a class="item item-icon-left" ng-click="toggleHide($index)" href=""> <i ng-class="{'icon ion-eye':item.Monitor.listDisplay=='show','icon ion-eye-disabled':item.Monitor.listDisplay!='show'}"> </i> {{item.Monitor.Name}} </a> |
