From b87e328f48f17ea86a1a432d48e02a94d50a6981 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Mon, 10 Oct 2016 11:56:34 -0400 Subject: added mageia cgi path Former-commit-id: fd35dce5edb5a2eb830b42c2d6e5bc88cac9718c --- www/js/WizardCtrl.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'www') diff --git a/www/js/WizardCtrl.js b/www/js/WizardCtrl.js index 0b39b431..bb283460 100644 --- a/www/js/WizardCtrl.js +++ b/www/js/WizardCtrl.js @@ -178,13 +178,14 @@ angular.module('zmApp.controllers').controller('zmApp.WizardCtrl', ['$scope', '$ NVRDataModel.log("zmWizard CGI: baseURL is " + baseUri); + var a5 = baseUri + "/zmcgi"; // mageia var a4 = baseUri + "/cgi-bin/zm"; // another one I found with a CentOS 6 guy var a3 = baseUri + "/zm/cgi-bin"; // ubuntu/debian var a2 = baseUri + "/cgi-bin-zm"; //fedora/centos/rhel var a1 = baseUri + "/cgi-bin"; // doofus - var urls = [a1, a2, a3, a4]; + var urls = [a1, a2, a3, a4,a5]; NVRDataModel.getPathZms() // what does ZM have stored in PATH_ZMS? -- cgit v1.2.3 From f9e03227e62d7f6c5c0cc381a897888c5efc3759 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Mon, 10 Oct 2016 17:28:23 -0400 Subject: initial event montage jazz Former-commit-id: 2f061e5e198abdc0dcbc92b85193b6a96cc82d37 --- www/css/style.css | 17 ++ www/index.html | 3 +- www/js/DevOptionsCtrl.js | 3 +- www/js/EventCtrl.js | 44 +++- www/js/EventDateTimeFilterCtrl.js | 6 +- www/js/EventServerSettingsCtrl.js | 3 +- www/js/EventsGraphsCtrl.js | 3 +- www/js/HelpCtrl.js | 3 +- www/js/LogCtrl.js | 3 +- www/js/LoginCtrl.js | 3 +- www/js/MonitorCtrl.js | 3 +- www/js/MontageCtrl.js | 10 +- www/js/MontageHistoryCtrl.js | 493 ++++++++++++++++++++----------------- www/js/NewsCtrl.js | 3 +- www/js/PortalLoginCtrl.js | 3 +- www/js/StateCtrl.js | 3 +- www/js/TimelineCtrl.js | 3 +- www/js/TimelineModalCtrl.js | 3 +- www/js/app.js | 68 ++++- www/lang/locale-en.json | 5 +- www/templates/events-modal.html | 3 + www/templates/montage-history.html | 372 +++++++++++----------------- 22 files changed, 571 insertions(+), 486 deletions(-) (limited to 'www') diff --git a/www/css/style.css b/www/css/style.css index 96dd7aee..09acc566 100644 --- a/www/css/style.css +++ b/www/css/style.css @@ -866,6 +866,10 @@ body { background: rgba(108, 122, 137, 0.7); z-index: -1; } + +#flyoutmenu li:active { + background:#3498db; +} #flyoutmenu a { text-decoration: none; color: white; @@ -890,6 +894,19 @@ body { opacity: 1; z-index: 99; } + +#history_canvas_video { + position: absolute; + width: 95%; + top:10%; + height: 20px; + + opacity: 1; + z-index: 99; +} + + + #event_slider { position: absolute; width: 80%; diff --git a/www/index.html b/www/index.html index df6cdf13..35c4405b 100644 --- a/www/index.html +++ b/www/index.html @@ -69,6 +69,7 @@ + @@ -164,7 +165,7 @@ {{'kMenuTimeline'|translate}} - + {{'kMenuEvents'|translate}} diff --git a/www/js/DevOptionsCtrl.js b/www/js/DevOptionsCtrl.js index 7ca09068..5e75df04 100644 --- a/www/js/DevOptionsCtrl.js +++ b/www/js/DevOptionsCtrl.js @@ -22,7 +22,8 @@ angular.module('zmApp.controllers').controller('zmApp.DevOptionsCtrl', ['$scope' disableBack: true }); $state.go("events", { - "id": 0 + "id": 0, + "playEvent":false }, { reload: true }); diff --git a/www/js/EventCtrl.js b/www/js/EventCtrl.js index 627b8fff..3aa4b6a2 100644 --- a/www/js/EventCtrl.js +++ b/www/js/EventCtrl.js @@ -84,6 +84,13 @@ angular.module('zmApp.controllers') document.addEventListener("pause", onPause, false); //console.log("I got STATE PARAM " + $stateParams.id); $scope.id = parseInt($stateParams.id, 10); + $scope.showEvent = $stateParams.playEvent || false; + + console.log (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + + + NVRDataModel.log ("EventCtrl called with: EID=" + $scope.id + " playEvent = "+$scope.showEvent); + // This is the only view that hardcodes row size due to // collection repeat, so lets re-get the text size if it has changed // note that there may be a delay as its a callback - so might involve @@ -154,6 +161,34 @@ angular.module('zmApp.controllers') + function getEventObject(eid) + { + + var apiurl = NVRDataModel.getLogin().apiurl + '/events/'+eid+'.json'; + + $http.get (apiurl) + .success (function (data) { + }) + .error (function (err) { + }); + /* + myevents[i].Event.humanizeTime = humanizeTime(myevents[i].Event.StartTime); + myevents[i].Event.MonitorName = NVRDataModel.getMonitorName(myevents[i].Event.MonitorId); + // now construct base path + + myevents[i].Event.streamingURL = NVRDataModel.getStreamingURL(myevents[i].Event.MonitorId); + myevents[i].Event.baseURL = NVRDataModel.getBaseURL(myevents[i].Event.MonitorId); + myevents[i].Event.imageMode = NVRDataModel.getImageMode(myevents[i].Event.MonitorId); + // console.log ("***** MULTISERVER STREAMING URL FOR EVENTS " + myevents[i].Event.streamingURL); + + // console.log ("***** MULTISERVER BASE URL FOR EVENTS " + myevents[i].Event.baseURL); + + myevents[i].Event.ShowScrub = false; + myevents[i].Event.BasePath = computeBasePath(myevents[i]); + myevents[i].Event.relativePath = computeRelativePath(myevents[i]); + */ + } + function getTextZoomCallback(tz) { @@ -667,7 +702,8 @@ angular.module('zmApp.controllers') // reloading - may solve https://github.com/pliablepixels/zmNinja/issues/36 // if you are in the same mid event page $state.go won't work $state.go("events", { - "id": monitorId + "id": monitorId, + "playEvent":false }, { reload: true }); @@ -684,7 +720,8 @@ angular.module('zmApp.controllers') disableBack: true }); $state.go("events", { - "id": 0 + "id": 0, + "playEvent":false }, { reload: true }); @@ -754,7 +791,8 @@ angular.module('zmApp.controllers') disableBack: true }); $state.go("events", { - "id": 0 + "id": 0, + "playEvent":false }); } else { NVRDataModel.log("Filter reset cancelled in popup"); diff --git a/www/js/EventDateTimeFilterCtrl.js b/www/js/EventDateTimeFilterCtrl.js index f9e982f5..4047fa1e 100644 --- a/www/js/EventDateTimeFilterCtrl.js +++ b/www/js/EventDateTimeFilterCtrl.js @@ -18,7 +18,8 @@ angular.module('zmApp.controllers') disableBack: true }); $state.go("events", { - "id": 0 + "id": 0, + "playEvent":false }, { reload: true }); @@ -50,7 +51,8 @@ angular.module('zmApp.controllers') disableBack: true }); $state.go("events", { - "id": 0 + "id": 0, + "playEvent":false }); //$ionicHistory.goBack(); diff --git a/www/js/EventServerSettingsCtrl.js b/www/js/EventServerSettingsCtrl.js index 298d9aa4..48417420 100644 --- a/www/js/EventServerSettingsCtrl.js +++ b/www/js/EventServerSettingsCtrl.js @@ -26,7 +26,8 @@ $state.go("events", { - "id": 0 + "id": 0, + "playEvent":false }, { reload: true }); diff --git a/www/js/EventsGraphsCtrl.js b/www/js/EventsGraphsCtrl.js index 98859649..2273598e 100644 --- a/www/js/EventsGraphsCtrl.js +++ b/www/js/EventsGraphsCtrl.js @@ -30,7 +30,8 @@ angular.module('zmApp.controllers').controller('zmApp.EventsGraphsCtrl', ['$ioni disableBack: true }); $state.go("events", { - "id": 0 + "id": 0, + "playEvent":false }, { reload: true }); diff --git a/www/js/HelpCtrl.js b/www/js/HelpCtrl.js index 53dc91b0..328fbfda 100644 --- a/www/js/HelpCtrl.js +++ b/www/js/HelpCtrl.js @@ -19,7 +19,8 @@ angular.module('zmApp.controllers').controller('zmApp.HelpCtrl', ['$scope', '$ro disableBack: true }); $state.go("events", { - "id": 0 + "id": 0, + "playEvent":false }, { reload: true }); diff --git a/www/js/LogCtrl.js b/www/js/LogCtrl.js index 67f2d185..388af6a7 100644 --- a/www/js/LogCtrl.js +++ b/www/js/LogCtrl.js @@ -63,7 +63,8 @@ angular.module('zmApp.controllers').controller('zmApp.LogCtrl', ['$scope', '$roo disableBack: true }); $state.go("events", { - "id": 0 + "id": 0, + "playEvent":false }, { reload: true }); diff --git a/www/js/LoginCtrl.js b/www/js/LoginCtrl.js index a13941c6..e076cc18 100644 --- a/www/js/LoginCtrl.js +++ b/www/js/LoginCtrl.js @@ -51,7 +51,8 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r disableBack: true }); $state.go("events", { - "id": 0 + "id": 0, + "playEvent":false }, { reload: true }); diff --git a/www/js/MonitorCtrl.js b/www/js/MonitorCtrl.js index fd0c2780..865e0e3a 100644 --- a/www/js/MonitorCtrl.js +++ b/www/js/MonitorCtrl.js @@ -66,7 +66,8 @@ angular.module('zmApp.controllers') $state.go("events", { - "id": 0 + "id": 0, + "playEvent":false }, { reload: true }); diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js index 6910f148..6b48897d 100644 --- a/www/js/MontageCtrl.js +++ b/www/js/MontageCtrl.js @@ -222,9 +222,9 @@ angular.module('zmApp.controllers') } - + pckry.shiftLayout(); $timeout (function () { - pckry.layout();},300); + pckry.shiftLayout();},300); @@ -512,7 +512,8 @@ angular.module('zmApp.controllers') disableBack: true }); $state.go("events", { - "id": 0 + "id": 0, + "playEvent":false }, { reload: true }); @@ -535,7 +536,8 @@ angular.module('zmApp.controllers') disableBack: true }); $state.go("events", { - "id": 0 + "id": 0, + "playEvent":false }, { reload: true }); diff --git a/www/js/MontageHistoryCtrl.js b/www/js/MontageHistoryCtrl.js index c0188d2d..c27e1c44 100644 --- a/www/js/MontageHistoryCtrl.js +++ b/www/js/MontageHistoryCtrl.js @@ -1,12 +1,12 @@ // Controller for the montage view -/* jshint -W041 */ +/* jshint -W041, -W093 */ /* jslint browser: true*/ -/* global cordova,StatusBar,angular,console,ionic,Masonry,moment,Packery, Draggabilly, imagesLoaded */ +/* global cordova,StatusBar,angular,console,ionic,Masonry,moment,Packery, Draggabilly, imagesLoaded, Chart */ // FIXME: This is a copy of montageCtrl - needs a lot of code cleanup -angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$scope', '$rootScope', 'NVRDataModel', 'message', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$ionicPopup', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$ionicPlatform', 'zm', '$ionicPopover', '$controller', 'imageLoadingDataShare', '$window', '$translate', function ($scope, $rootScope, NVRDataModel, message, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $ionicPopup, $stateParams, $ionicHistory, $ionicScrollDelegate, $ionicPlatform, zm, $ionicPopover, $controller, imageLoadingDataShare, $window, $translate) { +angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$scope', '$rootScope', 'NVRDataModel', 'message', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$ionicPopup', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$ionicPlatform', 'zm', '$ionicPopover', '$controller', 'imageLoadingDataShare', '$window', '$translate', 'qHttp', function ($scope, $rootScope, NVRDataModel, message, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $ionicPopup, $stateParams, $ionicHistory, $ionicScrollDelegate, $ionicPlatform, zm, $ionicPopover, $controller, imageLoadingDataShare, $window, $translate, qHttp) { @@ -49,13 +49,19 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc return moment(str).format(NVRDataModel.getTimeFormat() + ' on MMMM Do YYYY'); }; + $scope.humanizeTime = function (str) { + return moment(str).fromNow(); + + }; + // if you change date in footer, change hrs $scope.dateChanged = function() { - console.log ("DATE CHANGED"); + $scope.datetimeValueFrom.hrs = Math.round(moment.duration(moment().diff(moment($scope.datetimeValueFrom.value))).asHours()); }; + // if you change hrs in footer, change date $scope.hrsChanged = function() { $scope.datetimeValueFrom.value = moment().subtract($scope.datetimeValueFrom.hrs,'hours').toDate(); @@ -71,13 +77,9 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc }); } - $scope.toggleSizeButtons = function () { - - $scope.showSizeButtons = !$scope.showSizeButtons; - - NVRDataModel.debug("toggling size buttons:" + $scope.showSizeButtons); - if ($scope.showSizeButtons) $ionicScrollDelegate.$getByHandle("montage-delegate").scrollTop(); - }; + + + //-------------------------------------- // pause/unpause nph-zms @@ -101,12 +103,54 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc controlEventStream(cmd, "", $scope.MontageMonitors[m].Monitor.connKey, -1); } }; + + + function sendCmd (mid, cmd, extra) + { + var m = -1; + for (var i = 0; i < $scope.MontageMonitors.length; i++) { + if ($scope.MontageMonitors[i].Monitor.Id == mid) { + m = i; + break; + } + } + if (m != -1) { - $scope.humanizeTime = function (str) { - return moment(str).fromNow(); - + NVRDataModel.debug("Sending CMD:" + cmd + " for monitor " + $scope.MontageMonitors[m].Monitor.Name); + controlEventStream(cmd, "", $scope.MontageMonitors[m].Monitor.connKey, -1, extra); + + } + } + + + $scope.seek = function (mid, p) + { + console.log ("SLIDER CALLED WITH MID="+mid+" progress="+p); + sendCmd (mid, '14', "&offset="+p); + + }; + + $scope.moveFaster = function (mid) + { + sendCmd (mid,4); + }; + + $scope.moveSlower = function (mid) + { + sendCmd (mid,5); }; + + + $scope.movePlay = function (mid) + { + sendCmd (mid,2); + }; + + + + + //-------------------------------------- // Called when ion-footer collapses @@ -120,23 +164,18 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc $scope.footerCollapse = function () { - footerCollapse(); - - }; /* Note this is also called when the view is first loaded */ function footerCollapse() { - // console.log ("**************** COLLAPSE CALLED ***************"); + if (readyToRun == false) { NVRDataModel.debug("fake call to footerCollapse - ignoring"); return; } - - $scope.dragBorder = ""; $scope.isDragabillyOn = false; $ionicSideMenuDelegate.canDragContent(true); @@ -145,22 +184,15 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc var ld = NVRDataModel.getLogin(); $scope.sliderVal.realRate = $scope.sliderVal.rate * 100; - //NVRDataModel.debug ("Playback rate is:" + $scope.sliderVal.realRate); - var TimeObjectFrom = moment($scope.datetimeValueFrom.value).format("YYYY-MM-DD HH:mm"); - - //var TimeObjectTo = moment($scope.datetimeValueTo.value).format('YYYY-MM-DD HH:mm'); var TimeObjectTo = moment().format('YYYY-MM-DD HH:mm'); - // console.log ("TIME START: " + TimeObjectFrom + " " + TimeObjectTo); - //console.log ("TIME START: " + TimeObjectFrom + " " + TimeObjectTo); - - var apiurl; // release all active streams for (var i = 0; i < $scope.MontageMonitors.length; i++) { $scope.MontageMonitors[i].Monitor.selectStyle = ""; + $scope.MontageMonitors[i].Monitor.eid = "-1"; // generate new connKeys if timeline changes if ($scope.MontageMonitors[i].Monitor.eventUrl != 'img/noevent.png') { // this means this mid was showing a message, now we need to change it @@ -169,17 +201,16 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc var tmpCK = angular.copy($scope.MontageMonitors[i].Monitor.connKey); timedControlEventStream(2500, 17, "", tmpCK, -1); $scope.MontageMonitors[i].Monitor.eventUrl = "img/noevent.png"; + $scope.MontageMonitors[i].Monitor.eid = "-1"; $scope.MontageMonitors[i].Monitor.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); //console.log ("Generating connkey: " +$scope.MontageMonitors[i].Monitor.connKey); - } else { - //console.log ("footerCollapse: Skipped kill: connkey:"+$scope.MontageMonitors[i].Monitor.connKey + " function " + $scope.MontageMonitors[i].Monitor.Function + " listDisplay " + $scope.MontageMonitors[i].Monitor.lisDisplay + " enabled " + $scope.MontageMonitors[i].Monitor.Enabled + " eventURL " + $scope.MontageMonitors[i].Monitor.eventUrl); - } + } } // grab events that start on or before the time and end on or after the time // this should only bring up events that span that time - //apiurl = ld.apiurl + "/events/index/StartTime >=:" + TimeObjectFrom + "/EndTime <=:" + TimeObjectTo + ".json"; + apiurl = ld.apiurl + "/events/index/StartTime >=:" + TimeObjectFrom + "/AlarmFrames >=:" + (ld.enableAlarmCount ? ld.minAlarmCount : 0)+ ".json"; @@ -187,9 +218,10 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc // make sure there are no more than 5 active streams (noevent is ok) $scope.currentLimit = $scope.monLimit; - $http.get(apiurl) - .success(function (data) { - + //qHttp.get(apiurl) + qHttp({method:'get', url:apiurl}) + .then(function (succ) { + var data = succ.data; var ld = NVRDataModel.getLogin(); NVRDataModel.debug("Got " + data.events.length + "new history events..."); var eid, mid, stime; @@ -218,6 +250,11 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc $scope.MontageMonitors[j].Monitor.eventUrlTime = stime; + $scope.MontageMonitors[j].Monitor.eid = eid; + $scope.MontageMonitors[j].Monitor.eventDuration = data.events[i].Event.Length; + $scope.MontageMonitors[j].Monitor.sliderProgress = {progress:0}; + + console.log (">>> Setting Event for " + $scope.MontageMonitors[j].Monitor.Name+" to " +eid); } } @@ -255,29 +292,23 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc draggies = []; // destroy existing packery object pckry.destroy(); - initPackery(); - - - - - + } - }) - .error(function (data) { - NVRDataModel.debug("history ERROR:" + JSON.stringify(data)); - - }); - + }, + function (err) {NVRDataModel.debug("history ERROR:" + JSON.stringify(err));} ); + + function getExpandedEvents(i, indivGrab) { var ld = NVRDataModel.getLogin(); // console.log ("EXPANDED EVENT " + i + " " + indivGrab); - $http.get(indivGrab) - .success(function (data) { + qHttp({method:'get', url:indivGrab}) + .then(function (succ) { + var data = succ.data; // console.log ("EXPANDED DATA FOR MONITOR " + i + JSON.stringify(data)); if (data.events.length > 0) { @@ -292,6 +323,11 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc //console.log ("SWITCHING TO " + $scope.MontageMonitors[i].eventUrl); $scope.MontageMonitors[i].Monitor.eventUrlTime = data.events[0].Event.StartTime; + $scope.MontageMonitors[i].Monitor.eid = data.events[0].Event.Id; + $scope.MontageMonitors[i].Monitor.sliderProgress = {progress:0}; + + $scope.MontageMonitors[i].Monitor.eventDuration = data.events[0].Event.Length; + console.log (">>> Setting Event for " + $scope.MontageMonitors[i].Monitor.Name+" to " +data.events[0].Event.Id); NVRDataModel.log("Found expanded event " + data.events[0].Event.Id + " for monitor " + $scope.MontageMonitors[i].Monitor.Id); } else { @@ -301,8 +337,8 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc } } - }) - .error(function (data) {}); + }); + } } @@ -315,7 +351,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc function checkAllEvents() { - //console.log ("Events are checked...."); + console.log ("Timer:Events are checked...."); for (var i = 0; i < $scope.MontageMonitors.length; i++) { // don't check for monitors that are not shown @@ -325,7 +361,8 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc $scope.MontageMonitors[i].Monitor.Function != 'None' && $scope.MontageMonitors[i].Monitor.listDisplay != 'noshow' && $scope.MontageMonitors[i].Monitor.Enabled != '0') { - NVRDataModel.debug("Checking event status for " + $scope.MontageMonitors[i].Monitor.Name + ":" + $scope.MontageMonitors[i].Monitor.eventUrl + ":" + $scope.MontageMonitors[i].Monitor.Function + ":" + $scope.MontageMonitors[i].Monitor.listDisplay); + // NVRDataModel.debug("Checking event status for " + $scope.MontageMonitors[i].Monitor.Name + ":" + $scope.MontageMonitors[i].Monitor.eventUrl + ":" + $scope.MontageMonitors[i].Monitor.Function + ":" + $scope.MontageMonitors[i].Monitor.listDisplay); + // console.log ("Sending query 99 for " + $scope.MontageMonitors[i].Monitor.Name + " with ck="+$scope.MontageMonitors[i].Monitor.connKey); controlEventStream('99', '', $scope.MontageMonitors[i].Monitor.connKey, i); } @@ -357,7 +394,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc var loginData = NVRDataModel.getLogin(); var myauthtoken = $rootScope.authSession.replace("&auth=", ""); //&auth= - var req = $http({ + var req = qHttp({ method: 'POST', /*timeout: 15000,*/ url: loginData.url + '/index.php', @@ -386,18 +423,16 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc } }); - req.success(function (resp) { - NVRDataModel.debug("subControl success:" + JSON.stringify(resp)); - }); + req.then(function (succ) { + NVRDataModel.debug("subControl success:" + JSON.stringify(succ)); + }, + function (err) {NVRDataModel.debug("subControl error:" + JSON.stringify(err));}); - req.error(function (resp) { - NVRDataModel.debug("subControl error:" + JSON.stringify(resp)); - }); } - function controlEventStream(cmd, disp, connkey, ndx) { + function controlEventStream(cmd, disp, connkey, ndx, extras) { // console.log("Command value " + cmd); if (disp) { @@ -409,6 +444,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc }); } var loginData = NVRDataModel.getLogin(); + /* var CMD_NONE = 0; @@ -442,7 +478,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc var myauthtoken = $rootScope.authSession.replace("&auth=", ""); //&auth= - var req = $http({ + var req = qHttp({ method: 'POST', /*timeout: 15000,*/ url: loginData.url + '/index.php', @@ -456,7 +492,9 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); var foo = str.join("&"); - // console.log("****RETURNING " + foo); + if (extras) + foo = foo + extras; + //console.log("****RETURNING " + foo); return foo; }, @@ -470,22 +508,65 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc // pass: loginData.password } }); - req.success(function (resp) { + req.then(function (succ) { - // console.log("SUCCESS FOR: " + JSON.stringify(resp)); + var resp = succ.data; + //console.log("SUCCESS FOR: " + JSON.stringify(resp)); - if (resp.result == "Ok" && ndx != -1) { + //SUCCESS FOR: {"result":"Ok","status":{"type":3,"event":29621,"progress":1,"rate":1,"zoom":"1.0","paused":0}} + //$scope.MontageMonitors[ndx].Monitor.eid = data.event.Event.Id; + + if (resp.result == "Ok" && ndx != -1 && (resp.status.event == $scope.MontageMonitors[ndx].Monitor.eid)) + $scope.MontageMonitors[ndx].Monitor.sliderProgress.progress = resp.status.progress; + + if (resp.result == "Ok" && ndx != -1 && (resp.status.event != $scope.MontageMonitors[ndx].Monitor.eid) ) { + // $scope.MontageMonitors[ndx].Monitor.sliderProgress.progress = 0; + NVRDataModel.debug ("Fetching details, as event changed for " + $scope.MontageMonitors[ndx].Monitor.Name+" from " + $scope.MontageMonitors[ndx].Monitor.eid + " to " +resp.status.event); var ld = NVRDataModel.getLogin(); var apiurl = ld.apiurl + "/events/" + resp.status.event + ".json"; //console.log ("API " + apiurl); - $http.get(apiurl) - .success(function (data) { + qHttp({method:'get', url:apiurl}) + .then(function (succ) { + var data = succ.data; var currentEventTime = moment(data.event.Event.StartTime); var maxTime = moment(); //NVRDataModel.debug ("Monitor: " + $scope.MontageMonitors[ndx].Monitor.Id + " max time="+maxTime + "("+$scope.datetimeValueTo.value+")"+ " current="+currentEventTime + "("+data.event.Event.StartTime+")"); if ($scope.MontageMonitors[ndx].Monitor.eventUrlTime != data.event.Event.StartTime && currentEventTime.diff(maxTime) <= 0) { + + var framearray = { + + labels: [], + datasets: [{ + + backgroundColor: 'rgba(242, 12, 12, 0.5)', + borderColor: 'rgba(242, 12, 12, 0.5)', + data: [], + }] + }; + + + framearray.labels = []; var ld = NVRDataModel.getLogin(); + console.log (">>>>> GRAPH"); + for (i=0; i>> Setting Event for " + $scope.MontageMonitors[ndx].Monitor.Name+" to " +data.event.Event.Id); + + }, 700); } else if (currentEventTime.diff(maxTime) > 0) { @@ -505,18 +593,18 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc } - }) - .error(function (data) { - $scope.MontageMonitors[ndx].Monitor.eventUrlTime = "-"; - }); + }, + function (err) {$scope.MontageMonitors[ndx].Monitor.eventUrlTime = "-"; } + ); + } - }); + }, + function (err) { NVRDataModel.log("Error sending event command " + JSON.stringify(err), "error");} + + ); - req.error(function (resp) { - //console.log("ERROR: " + JSON.stringify(resp)); - NVRDataModel.log("Error sending event command " + JSON.stringify(resp), "error"); - }); + } @@ -537,7 +625,8 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc disableBack: true }); $state.go("events", { - "id": 0 + "id": 0, + "playEvent":false }, { reload: true }); @@ -559,7 +648,8 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc disableBack: true }); $state.go("events", { - "id": 0 + "id": 0, + "playEvent":false, }, { reload: true }); @@ -583,26 +673,15 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc - //--------------------------------------------------------------------- - // Triggered when you enter/exit full screen - //--------------------------------------------------------------------- - $scope.switchMinimal = function () { - $scope.minimal = !$scope.minimal; - NVRDataModel.debug("MontageHistoryCtrl: switch minimal is " + $scope.minimal); - //console.log("Hide Statusbar"); - ionic.Platform.fullScreen($scope.minimal, !$scope.minimal); - $interval.cancel(intervalHandle); //we will renew on reload - // We are reloading this view, so we don't want entry animations - $ionicHistory.nextViewOptions({ - disableAnimate: true, - disableBack: true - }); - $state.go("montage", { - minimal: $scope.minimal, - isRefresh: true - }); - }; + + + + $scope.toggleControls = function() + { + $scope.showControls = !$scope.showControls; + }; + $scope.toggleSelectItem = function (ndx) { @@ -681,10 +760,10 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc $scope.onDropComplete = function (index, obj, event) { //console.log("dragged"); - var otherObj = $scope.monitors[index]; - var otherIndex = $scope.monitors.indexOf(obj); - $scope.monitors[index] = obj; - $scope.monitors[otherIndex] = otherObj; + var otherObj = $scope.MontageMonitors[index]; + var otherIndex = $scope.MontageMonitors.indexOf(obj); + $scope.MontageMonitors[index] = obj; + $scope.MontageMonitors[otherIndex] = otherObj; }; @@ -777,11 +856,12 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc //console.log("Setting Awake to " + NVRDataModel.getKeepAwake()); NVRDataModel.setAwake(NVRDataModel.getKeepAwake()); + NVRDataModel.debug ("query timer started"); $interval.cancel($rootScope.eventQueryInterval); //console.log ("****************** TIMER STARTED INSIDE ENTER"); $rootScope.eventQueryInterval = $interval(function () { checkAllEvents(); - // console.log ("Refreshing Image..."); + }.bind(this), zm.eventHistoryTimer); @@ -987,38 +1067,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc }; - //--------------------------------------------------------- - // This function readjusts montage size - // and stores current size to persistent memory - //--------------------------------------------------------- - - function processSliderChanged(val) { - if (sizeInProgress) return; - - sizeInProgress = true; - //console.log('Size has changed'); - NVRDataModel.setMontageSize(val); - //console.log("ZMData Montage is " + NVRDataModel.getMontageSize() + - // " and slider montage is " + $scope.slider.monsize); - // Now go ahead and reset sizes of entire monitor array - var monsizestring = ""; - var i; - for (i = 0; i < $scope.monitors.length; i++) { - - $scope.monitorSize[i] = parseInt(NVRDataModel.getMontageSize()); - //console.log("Resetting Monitor " + i + " size to " + $scope.monitorSize[i]); - $scope.scaleDirection[i] = 1; - monsizestring = monsizestring + $scope.monitorSize[i] + ':'; - } - monsizestring = monsizestring.slice(0, -1); // kill last : - //console.log("Setting monsize string:" + monsizestring); - loginData.montageArraySize = monsizestring; - NVRDataModel.setLogin(loginData); - //window.localStorage.setItem("montageArraySize", monsizestring); - sizeInProgress = false; - } - - function isEmpty(obj) { + function isEmpty(obj) { for (var prop in obj) { return false; } @@ -1028,7 +1077,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc // called by afterEnter to load Packery function initPackery() { - console.log(">>>>>>>>>>>>>>>>> HIT INIT"); + $ionicLoading.show({ template: $translate.instant('kArrangingImages'), noBackdrop: true, @@ -1097,7 +1146,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc $ionicLoading.hide(); - + $timeout(function () { pckry = new Packery('.grid', { itemSelector: '.grid-item', percentPosition: true, @@ -1112,11 +1161,10 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc } - $timeout(function () { + var cnt = 0; pckry.getItemElements().forEach(function (itemElem) { - console.log("DRAG ADD " + cnt++); draggie = new Draggabilly(itemElem); pckry.bindDraggabillyEvents(draggie); draggies.push(draggie); @@ -1164,16 +1212,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc function itemDragged(item) { NVRDataModel.debug("drag complete"); - //pckry.getItemElements().forEach(function (itemElem) { - - //console.log (itemElem.attributes['data-item-id'].value+" size "+itemElem.attributes['data-item-size'].value ); - // }); - - /* var positions = pckry.EHgetShiftPositions('eh-data-item-id'); - //console.log ("POSITIONS MAP " + JSON.stringify(positions)); - var ld = NVRDataModel.getLogin(); - ld.EHpackeryPositions = JSON.stringify(positions); - NVRDataModel.setLogin(ld);*/ + } @@ -1186,6 +1225,8 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc // I don't think I am using this anymore FIXME: check and delete if needed // $rootScope.rand = Math.floor((Math.random() * 100000) + 1); + + $scope.showControls = false; $timeout(function () { initPackery(); }, zm.packeryTimer); @@ -1203,24 +1244,83 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc //console.log("***Pull to Refresh, recomputing Rand"); NVRDataModel.log("Reloading view for montage view, recomputing rand"); $rootScope.rand = Math.floor((Math.random() * 100000) + 1); - $scope.monitors = []; + $scope.MontageMonitors = []; imageLoadingDataShare.set(0); var refresh = NVRDataModel.getMonitors(1); refresh.then(function (data) { - $scope.monitors = data; + $scope.MontageMonitors = data.data; $scope.$broadcast('scroll.refreshComplete'); }); }; + + + function drawGraph(f,mid) { + + + console.log ("Graphing on " + "eventchart-"+mid); + var cv = document.getElementById("eventchart-"+mid); + var ctx = cv.getContext("2d"); + + + frameoptions = { + responsive: true, + legend: false, + title: { + display: false, + text: "" + }, + scales: { + yAxes: [{ + display: false, + scaleLabel: { + display: false, + labelString: 'value', + } + + }], + xAxes: [{ + type: 'time', + display: false, + time: { + + format: timeFormat, + tooltipFormat: 'll HH:mm', + min: f.datasets[0].data[0].x, + max: f.datasets[0].data[f.datasets[0].data.length - 1].x, + displayFormats: { + + } + }, + scaleLabel: { + display: false, + labelString: '' + } + + }] + } + }; + + + $timeout(function () { + + + var myChart = new Chart(ctx, { + type: 'line', + data: f, + options: frameoptions, + }); + + }); + } + //--------------------------------------------------------------------- // Controller main //--------------------------------------------------------------------- - - var intervalHandle; $scope.isModalActive = false; var modalIntervalHandle; @@ -1235,6 +1335,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc $scope.displayDateTimeSliders = true; $scope.showtimers = true; $scope.loginData = NVRDataModel.getLogin(); + var timeFormat = 'MM/DD/YYYY HH:mm:ss'; var curYear = new Date().getFullYear(); @@ -1252,6 +1353,8 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc }; + + var frameoptions = []; // default = start of day @@ -1262,10 +1365,6 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc $scope.sliderVal.realRate = $scope.sliderVal.rate * 100; - - //var tdatetimeValueFrom = new Date(); - //tdatetimeValueFrom.setDate(tdatetimeValueFrom.getDate()-1); - $scope.datetimeValueFrom = { value: "", hrs:"" @@ -1319,22 +1418,11 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc }; - - var isLongPressActive = false; - $scope.isReorder = false; - var intervalHandleMontage; // will hold image resize timer on long press - var montageIndex = 0; // will hold monitor ID to scale in timer - var gridcontainer, pckry, draggie, draggies; $scope.monitorSize = []; // array with montage sizes per monitor $scope.scaleDirection = []; // 1 = increase -1 = decrease - $scope.slider = {}; - - //console.log ("************ HISTORY " + NVRDataModel.getMontageSize()); - $scope.slider.monsize = NVRDataModel.getMontageSize(); - $scope.revMonSize = 11 - parseInt($scope.slider.monsize); // The difference between old and original is this: // old will have a copy of the last re-arranged monitor list @@ -1363,33 +1451,31 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc return; } - // console.log ("TEMP MONITORS IS " + JSON.stringify(tempMonitors)); - - $scope.monitors = tempMonitors; - - NVRDataModel.log("Inside MontageHistoryCtrl:We found " + $scope.monitors.length + " monitors"); + + $scope.MontageMonitors = message; + NVRDataModel.log("Inside MontageHistoryCtrl:We found " + $scope.MontageMonitors.length + " monitors"); // $scope.MontageMonitors = NVRDataModel.applyMontageMonitorPrefs(message, 1)[0]; - $scope.MontageMonitors = message; + var loginData = NVRDataModel.getLogin(); - $scope.packMontage = loginData.packMontage; - - // init monitors NVRDataModel.debug(">>Initializing connkeys and images..."); for (i = 0; i < $scope.MontageMonitors.length; i++) { //$scope.MontageMonitors[i].Monitor.connKey=''; + $scope.MontageMonitors[i].Monitor.eid = "-1"; $scope.MontageMonitors[i].Monitor.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); $scope.MontageMonitors[i].Monitor.eventUrl = 'img/noevent.png'; + $scope.MontageMonitors[i].Monitor.eid = "-1"; $scope.MontageMonitors[i].Monitor.eventUrlTime = ""; $scope.MontageMonitors[i].Monitor.isPaused = false; $scope.MontageMonitors[i].Monitor.gridScale = "50"; $scope.MontageMonitors[i].Monitor.selectStyle = ""; $scope.MontageMonitors[i].Monitor.alarmState = 'color:rgba(0,0,0,0);'; + $scope.MontageMonitors[i].Monitor.sliderProgress = {progress:0}; } readyToRun = true; @@ -1423,54 +1509,14 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc }, 1000); - - - $scope.showSizeButtons = false; - $ionicPopover.fromTemplateUrl('templates/help/montage-help.html', { - scope: $scope, - }).then(function (popover) { - $scope.popover = popover; - }); - - var timestamp = new Date().getUTCMilliseconds(); - $scope.minimal = $stateParams.minimal; - $scope.zmMarginTop = $scope.minimal ? 0 : 15; - //console.log ("********* MARGIN IS " + $scope.zmMarginTop); - + + $scope.isRefresh = $stateParams.isRefresh; var sizeInProgress = false; - $scope.imageStyle = true; - $ionicSideMenuDelegate.canDragContent(true); - // Do we have a saved montage array size? No? - // if (window.localStorage.getItem("montageArraySize") == undefined) { - if (loginData.montageArraySize == '0') { - - for (i = 0; i < $scope.monitors.length; i++) { - $scope.monitorSize.push(NVRDataModel.getMontageSize()); - $scope.scaleDirection.push(1); - } - } else // recover previous settings - { - var msize = loginData.montageArraySize; - //console.log("MontageArrayString is=>" + msize); - $scope.monitorSize = msize.split(":"); - var j; - - for (j = 0; j < $scope.monitorSize.length; j++) { - // convert to number other wise adding to it concatenates :-) - $scope.monitorSize[j] = parseInt($scope.monitorSize[j]); - $scope.scaleDirection.push(1); - //console.log("Montage size for monitor " + j + " is " + $scope.monitorSize[j]); - - } - - } - // $scope.monitorSize = monitorSize; - // $scope.scaleDirection = scaleDirection; $scope.LoginData = NVRDataModel.getLogin(); $scope.monLimit = $scope.LoginData.maxMontage; @@ -1478,13 +1524,12 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc if ($rootScope.platformOS != 'ios') { NVRDataModel.log("Limiting montage to 5, thanks to Chrome's stupid connection limit"); - $scope.monLimit = 5; $scope.currentLimit = 5; + $scope.monLimit = 5; + } - //console.log("********* Inside MontageHistoryCtrl, MAX LIMIT=" + $scope.monLimit); - - + $rootScope.authSession = "undefined"; $ionicLoading.show({ template: $translate.instant('kNegotiatingStreamAuth'), @@ -1499,7 +1544,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc var ld = NVRDataModel.getLogin(); //console.log ("MONITORS " + JSON.stringify($scope.monitors)); - $rootScope.validMonitorId = $scope.monitors[0].Monitor.Id; + $rootScope.validMonitorId = $scope.MontageMonitors[0].Monitor.Id; NVRDataModel.getAuthKey($rootScope.validMonitorId) .then(function (success) { $ionicLoading.hide(); diff --git a/www/js/NewsCtrl.js b/www/js/NewsCtrl.js index c8bf78b4..8305fa6b 100644 --- a/www/js/NewsCtrl.js +++ b/www/js/NewsCtrl.js @@ -19,7 +19,8 @@ angular.module('zmApp.controllers').controller('zmApp.NewsCtrl', ['$scope', '$ro disableBack: true }); $state.go("events", { - "id": 0 + "id": 0, + "playEvent":false }, { reload: true }); diff --git a/www/js/PortalLoginCtrl.js b/www/js/PortalLoginCtrl.js index 7e874fa4..541af937 100644 --- a/www/js/PortalLoginCtrl.js +++ b/www/js/PortalLoginCtrl.js @@ -281,7 +281,8 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic } else if (ld.onTapScreen == $translate.instant('kTapEvents')) { NVRDataModel.debug("Going to events"); $state.go("events", { - "id": 0 + "id": 0, + "playEvent":false }, { reload: true }); diff --git a/www/js/StateCtrl.js b/www/js/StateCtrl.js index 76c11543..58f13c4b 100644 --- a/www/js/StateCtrl.js +++ b/www/js/StateCtrl.js @@ -112,7 +112,8 @@ angular.module('zmApp.controllers').controller('zmApp.StateCtrl', ['$ionicPopup' disableBack: true }); $state.go("events", { - "id": 0 + "id": 0, + "playEvent":false }, { reload: true }); diff --git a/www/js/TimelineCtrl.js b/www/js/TimelineCtrl.js index 1bbd6dee..90ecf37e 100644 --- a/www/js/TimelineCtrl.js +++ b/www/js/TimelineCtrl.js @@ -31,7 +31,8 @@ angular.module('zmApp.controllers').controller('zmApp.TimelineCtrl', ['$ionicPla disableBack: true }); $state.go("events", { - "id": 0 + "id": 0, + "playEvent":false }, { reload: true }); diff --git a/www/js/TimelineModalCtrl.js b/www/js/TimelineModalCtrl.js index f92aff26..4c3b7ea7 100644 --- a/www/js/TimelineModalCtrl.js +++ b/www/js/TimelineModalCtrl.js @@ -42,7 +42,8 @@ angular.module('zmApp.controllers').controller('TimelineModalCtrl', ['$scope', ' disableBack: true }); $state.go("events", { - "id": 0 + "id": 0, + "playEvent":false }, { reload: true }); diff --git a/www/js/app.js b/www/js/app.js index 99b635b9..6badb37f 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -1,4 +1,4 @@ -/* jshint -W041 */ +/* jshint -W041, -W093 */ /* jslint browser: true*/ /* global cordova,StatusBar,angular,console,alert,PushNotification, moment ,ionic, URI,Packery, ConnectSDK, CryptoJS, ContactFindOptions, localforage,$, Connection, MobileAccessibility */ @@ -83,7 +83,7 @@ angular.module('zmApp', [ latestRelease: "https://api.github.com/repos/pliablepixels/zmNinja/releases/latest", blogUrl: "http://pliablepixels.github.io/feed.json", nphSwitchTimer: 3000, - eventHistoryTimer: 10000, + eventHistoryTimer: 5000, eventPlaybackQuery: 3000, packeryTimer: 500, @@ -257,6 +257,52 @@ angular.module('zmApp', [ }) +/*.factory('qHttp', function($q, $http) { + //credit: http://stackoverflow.com/a/29719693 + var queue = $q.when(); + + return function queuedHttp(httpConf) { + var f = function(data) { + return $http(httpConf); + }; + return queue = queue.then(f, f); + }; +})*/ + + +//credit: http://stackoverflow.com/a/14468276 +.factory('qHttp', function($q,$http) { + + var queue=[]; + var execNext = function() { + var task = queue[0]; + //console.log ("qHTTP>>> Executing:"+JSON.stringify(task.c)+">>> pending:"+queue.length); + + $http(task.c).then(function(data) { + queue.shift(); + task.d.resolve(data); + if (queue.length>0) execNext(); + }, function(err) { + queue.shift(); + task.d.reject(err); + if (queue.length>0) execNext(); + }) + ; + }; + return function(config) { + var d = $q.defer(); + //config.headers.push({'X-qHttp':'enabled'}); + queue.push({c:config,d:d}); + if (queue.length===1) + { + execNext(); + } + //else + //console.log ("qHTTP>>> Queuing:"+JSON.stringify(config)); + return d.promise; + }; +}) + //credit: https://github.com/driftyco/ionic/issues/3131 .factory('SecuredPopups', [ '$ionicPopup', @@ -461,7 +507,11 @@ angular.module('zmApp', [ 'request': function (config) { - + // NOTE ON TIMEOUTS: As of Oct 10 2016, it seems + // the Http queue often gets messed up when there is a timeout + // and the # of requests are plentiful. I'm going to disable it and see + + // console.log (">>>>"+config.url); // handle basic auth properly if (config.url.indexOf("@") > -1) { @@ -476,6 +526,7 @@ angular.module('zmApp', [ } + //console.log (">>>>>>>>>>>>> INTERCEPT OBJECT " + JSON.stringify(config)); if ($rootScope.zmCookie) { config.headers.Cookie = "ZMSESSID=" + $rootScope.zmCookie; @@ -486,18 +537,21 @@ angular.module('zmApp', [ if ((config.url.indexOf("/api/states/change/") > -1) || (config.url.indexOf("getDiskPercent.json") > -1) || (config.url.indexOf("daemonCheck.json") > -1) || - (config.url.indexOf("getLoad.json") > -1)) + (config.url.indexOf("getLoad.json") > -1) ) { + // these can take time, so lets bump up timeout config.timeout = zm.largeHttpTimeout; } else if ((config.url.indexOf("view=view_video") > -1) || config.url.indexOf(".mp4") > -1) { // console.log(">>> skipping timers for MP4"); - } else { - config.timeout = zm.httpTimeout; + // put a timeout for zms urls + } else if (config.url.indexOf("zms?") > -1) { + // config.timeout = zm.httpTimeout; + } return config; }, @@ -1629,7 +1683,7 @@ angular.module('zmApp', [ return NVRDataModel.getMonitors(0); } }, - url: "/events/:id", + url: "/events/:id/:playEvent", templateUrl: "templates/events.html", controller: 'zmApp.EventCtrl', diff --git a/www/lang/locale-en.json b/www/lang/locale-en.json index 8557256c..156756d7 100644 --- a/www/lang/locale-en.json +++ b/www/lang/locale-en.json @@ -357,6 +357,9 @@ "kZMUndetermined" :"undetermined", "kZMUpgradeNeeded" :"ZoneMinder upgrade needed", "kEventHistShowFrom" :"Show from", - "kEventHistHrs" :"hours ago" + "kEventHistHrs" :"hours ago", + "kEventHistSlower" : "slower", + "kEventHistFaster" : "faster", + "kEventHistPlay" : "play" } diff --git a/www/templates/events-modal.html b/www/templates/events-modal.html index e6211aab..2c1c38c7 100644 --- a/www/templates/events-modal.html +++ b/www/templates/events-modal.html @@ -113,6 +113,9 @@ + + + diff --git a/www/templates/montage-history.html b/www/templates/montage-history.html index 3a4cbd86..aa38df16 100644 --- a/www/templates/montage-history.html +++ b/www/templates/montage-history.html @@ -1,240 +1,148 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- {{'kFrom' | translate}}:{{prettifyDateTimeFirst(datetimeValueFrom.value)}} ({{humanizeTime(datetimeValueFrom.value)}}) - -
({{'kChromeMax' | translate}})
-
- - -
-
- - - - - - - - - - -
-
- - + +
+
+ -
-
- - - - -
+
+
+ +
-   +   + {{monitor.Monitor.Name}}  -
- - - -
-
-
- -
- -
-
- - - - -
- -      {{monitor.Monitor.Name}}  - -
- {{prettifyDateTimeFirst(monitor.Monitor.eventUrlTime)}} ({{humanizeTime(monitor.Monitor.eventUrlTime)}})  -
- -
- - - -
-
- - - - - - - - - - - -
-
- - -
- - -
- -
- - - {{'kNoMonitors' | translate }} - - - - - - -
- {{ 'kLowBWDisplay' | translate }} -
- -
- - - - + +
+
+ +
+ +
+ +
+
+
+ {{'kNoMonitors' | translate }} +
+
{{ 'kLowBWDisplay' | translate }}
+
+ + + - - -
- - - - - - -

{{'kEventMontage' | translate}}

-
- - - -
- - - - - - - - + - - - - - - - -
{{'kTimeline' | translate}}
- -
- {{'kEventHistShowFrom'|translate}}:  - -  {{'kEventHistHrs' | translate}} -
- - -
- {{'kFrom' | translate }}: {{datetimeValueFrom.value | date: timeFormat}} -
({{humanizeTime(datetimeValueFrom.value)}}) -
- -
-
-
-
- -
-
-
-
- {{'kSpeed' | translate }} -
-
- - -
-
-
- - - - - -
\ No newline at end of file +
{{'kTimeline' | translate}}
+
{{'kEventHistShowFrom'|translate}}:  + +  {{'kEventHistHrs' | translate}} +
+ +
+ {{'kFrom' | translate }}: {{datetimeValueFrom.value | date: timeFormat}} +
({{humanizeTime(datetimeValueFrom.value)}}) +
+
+
+
+
+ +
+
+
+
{{'kSpeed' | translate }}
+
+ + + + + \ No newline at end of file -- cgit v1.2.3 From 07654b2eaaba4890cbbc45dec70e5995fd36a655 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Tue, 11 Oct 2016 12:32:45 -0400 Subject: cleanup and fixes to montage history Former-commit-id: 440b7c8a70e4085afcdc7ed8e9b14eb979198177 --- www/js/MontageCtrl.js | 30 +- www/js/MontageHistoryCtrl.js | 945 ++++++++++--------------------------- www/templates/events-modal.html | 2 +- www/templates/montage-history.html | 19 +- 4 files changed, 271 insertions(+), 725 deletions(-) (limited to 'www') diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js index 6b48897d..0681d832 100644 --- a/www/js/MontageCtrl.js +++ b/www/js/MontageCtrl.js @@ -169,7 +169,7 @@ angular.module('zmApp.controllers') imagesLoaded(elem).on('always', function () { //console.log ("******** ALL IMAGES LOADED"); NVRDataModel.debug("All images loaded"); - + $scope.areImagesLoading = false; $ionicLoading.hide(); @@ -182,15 +182,13 @@ angular.module('zmApp.controllers') }); if (!progressCalled) { - NVRDataModel.log("*** BUG PROGRESS WAS NOT CALLED"); + NVRDataModel.log("*** PROGRESS WAS NOT CALLED"); + pckry.reloadItems(); } - NVRDataModel.debug("All images loaded, doing image layout"); - $scope.areImagesLoading = false; // outside timeout so images show before next line - $timeout(function () { - pckry.initShiftLayout(positions, 'data-item-id'); - //pckry.reloadItems(); + - + $timeout(function () { + pckry.getItemElements().forEach(function (itemElem) { draggie = new Draggabilly(itemElem); pckry.bindDraggabillyEvents(draggie); @@ -218,13 +216,15 @@ angular.module('zmApp.controllers') } - + NVRDataModel.debug("All images loaded, doing image layout"); + $timeout(function () { + pckry.initShiftLayout(positions, 'data-item-id'); + }, 0); } - - - pckry.shiftLayout(); - $timeout (function () { - pckry.shiftLayout();},300); + $timeout(function () { + NVRDataModel.log("Force calling resize"); + pckry.shiftLayout(); + }, zm.packeryTimer); // don't ask @@ -232,6 +232,8 @@ angular.module('zmApp.controllers') }); + + function itemDragged(item) { NVRDataModel.debug("drag complete"); diff --git a/www/js/MontageHistoryCtrl.js b/www/js/MontageHistoryCtrl.js index c27e1c44..33e099fe 100644 --- a/www/js/MontageHistoryCtrl.js +++ b/www/js/MontageHistoryCtrl.js @@ -1,35 +1,22 @@ // Controller for the montage view -/* jshint -W041, -W093 */ +/* jshint -W041, -W093, -W083 */ /* jslint browser: true*/ /* global cordova,StatusBar,angular,console,ionic,Masonry,moment,Packery, Draggabilly, imagesLoaded, Chart */ - - // FIXME: This is a copy of montageCtrl - needs a lot of code cleanup - angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$scope', '$rootScope', 'NVRDataModel', 'message', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$ionicPopup', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$ionicPlatform', 'zm', '$ionicPopover', '$controller', 'imageLoadingDataShare', '$window', '$translate', 'qHttp', function ($scope, $rootScope, NVRDataModel, message, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $ionicPopup, $stateParams, $ionicHistory, $ionicScrollDelegate, $ionicPlatform, zm, $ionicPopover, $controller, imageLoadingDataShare, $window, $translate, qHttp) { - - - - //-------------------------------------------------------------------------------------- // Handles bandwidth change, if required // //-------------------------------------------------------------------------------------- - $rootScope.$on("bandwidth-change", function (e, data) { // nothing to do for now // eventUrl will use lower BW in next query cycle }); - - - //-------------------------------------- // formats events dates in a nice way //--------------------------------------- - $scope.prettifyDateTimeFirst = function (str) { return moment(str).format(NVRDataModel.getTimeFormat() + '/MMM Do'); - }; $scope.prettifyDate = function (str) { return moment(str).format('MMM Do, YYYY ' + NVRDataModel.getTimeFormat()); @@ -38,37 +25,24 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc function prettifyDate(str) { return moment(str).format('MMM Do'); } - $scope.prettifyTime = function (str) { - return moment(str).format('h:mm a'); }; - - $scope.prettify = function (str) { return moment(str).format(NVRDataModel.getTimeFormat() + ' on MMMM Do YYYY'); }; - $scope.humanizeTime = function (str) { return moment(str).fromNow(); - }; // if you change date in footer, change hrs - $scope.dateChanged = function() - { - + $scope.dateChanged = function () { $scope.datetimeValueFrom.hrs = Math.round(moment.duration(moment().diff(moment($scope.datetimeValueFrom.value))).asHours()); }; - - - // if you change hrs in footer, change date - $scope.hrsChanged = function() - { - $scope.datetimeValueFrom.value = moment().subtract($scope.datetimeValueFrom.hrs,'hours').toDate(); + // if you change hrs in footer, change date + $scope.hrsChanged = function () { + $scope.datetimeValueFrom.value = moment().subtract($scope.datetimeValueFrom.hrs, 'hours').toDate(); timefrom.toDate(); - }; - function orientationChanged() { NVRDataModel.debug("Detected orientation change, redoing packery resize"); @@ -76,11 +50,6 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc pckry.onresize(); }); } - - - - - //-------------------------------------- // pause/unpause nph-zms //--------------------------------------- @@ -88,7 +57,6 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc //console.log ("TOGGLE PAUSE " + mid); var m = -1; for (var i = 0; i < $scope.MontageMonitors.length; i++) { - if ($scope.MontageMonitors[i].Monitor.Id == mid) { m = i; break; @@ -96,99 +64,65 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc } if (m != -1) { $scope.MontageMonitors[m].Monitor.isPaused = !$scope.MontageMonitors[m].Monitor.isPaused; - var cmd = $scope.MontageMonitors[m].Monitor.isPaused ? 1 : 2; - NVRDataModel.debug("Sending CMD:" + cmd + " for monitor " + $scope.MontageMonitors[m].Monitor.Name); controlEventStream(cmd, "", $scope.MontageMonitors[m].Monitor.connKey, -1); } }; - - - function sendCmd (mid, cmd, extra) - { + + function sendCmd(mid, cmd, extra) { var m = -1; for (var i = 0; i < $scope.MontageMonitors.length; i++) { - if ($scope.MontageMonitors[i].Monitor.Id == mid) { m = i; break; } } if (m != -1) { - NVRDataModel.debug("Sending CMD:" + cmd + " for monitor " + $scope.MontageMonitors[m].Monitor.Name); controlEventStream(cmd, "", $scope.MontageMonitors[m].Monitor.connKey, -1, extra); - } } - - - $scope.seek = function (mid, p) - { - console.log ("SLIDER CALLED WITH MID="+mid+" progress="+p); - sendCmd (mid, '14', "&offset="+p); - + $scope.seek = function (mid, p) { + console.log("SLIDER CALLED WITH MID=" + mid + " progress=" + p); + sendCmd(mid, '14', "&offset=" + p); }; - - $scope.moveFaster = function (mid) - { - sendCmd (mid,4); + $scope.moveFaster = function (mid) { + sendCmd(mid, 4); }; - - $scope.moveSlower = function (mid) - { - sendCmd (mid,5); + $scope.moveSlower = function (mid) { + sendCmd(mid, 5); }; - - - $scope.movePlay = function (mid) - { - sendCmd (mid,2); + $scope.movePlay = function (mid) { + sendCmd(mid, 2); }; - - - - - - //-------------------------------------- // Called when ion-footer collapses // note that on init it is also called //--------------------------------------- - $scope.footerExpand = function () { // console.log ("**************** EXPAND CALLED ***************"); $ionicSideMenuDelegate.canDragContent(false); }; - $scope.footerCollapse = function () { - footerCollapse(); }; - - /* Note this is also called when the view is first loaded */ function footerCollapse() { - if (readyToRun == false) { NVRDataModel.debug("fake call to footerCollapse - ignoring"); return; } - $scope.dragBorder = ""; $scope.isDragabillyOn = false; $ionicSideMenuDelegate.canDragContent(true); - NVRDataModel.stopNetwork("MontageHistory-footerCollapse"); var ld = NVRDataModel.getLogin(); - $scope.sliderVal.realRate = $scope.sliderVal.rate * 100; var TimeObjectFrom = moment($scope.datetimeValueFrom.value).format("YYYY-MM-DD HH:mm"); var TimeObjectTo = moment().format('YYYY-MM-DD HH:mm'); - var apiurl; - + // release all active streams for (var i = 0; i < $scope.MontageMonitors.length; i++) { $scope.MontageMonitors[i].Monitor.selectStyle = ""; @@ -197,181 +131,141 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc if ($scope.MontageMonitors[i].Monitor.eventUrl != 'img/noevent.png') { // this means this mid was showing a message, now we need to change it // so kill prev. stream first - NVRDataModel.log("footerCollapse: Calling kill with " + $scope.MontageMonitors[i].Monitor.connKey + " for Monitor:"+$scope.MontageMonitors[i].Monitor.Name); + NVRDataModel.log("footerCollapse: Calling kill with " + $scope.MontageMonitors[i].Monitor.connKey + " for Monitor:" + $scope.MontageMonitors[i].Monitor.Name); var tmpCK = angular.copy($scope.MontageMonitors[i].Monitor.connKey); timedControlEventStream(2500, 17, "", tmpCK, -1); $scope.MontageMonitors[i].Monitor.eventUrl = "img/noevent.png"; $scope.MontageMonitors[i].Monitor.eid = "-1"; $scope.MontageMonitors[i].Monitor.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); + $scope.MontageMonitors[i].Monitor.noGraph = true; //console.log ("Generating connkey: " +$scope.MontageMonitors[i].Monitor.connKey); - } - + } } - - // grab events that start on or before the time and end on or after the time - // this should only bring up events that span that time - - apiurl = ld.apiurl + "/events/index/StartTime >=:" + TimeObjectFrom + "/AlarmFrames >=:" + (ld.enableAlarmCount ? ld.minAlarmCount : 0)+ ".json"; - - + // grab events that start on or after the time + apiurl = ld.apiurl + "/events/index/StartTime >=:" + TimeObjectFrom + "/AlarmFrames >=:" + (ld.enableAlarmCount ? ld.minAlarmCount : 0) + ".json"; NVRDataModel.log("Event timeline API is " + apiurl); - // make sure there are no more than 5 active streams (noevent is ok) $scope.currentLimit = $scope.monLimit; //qHttp.get(apiurl) - qHttp({method:'get', url:apiurl}) - .then(function (succ) { - var data = succ.data; - var ld = NVRDataModel.getLogin(); - NVRDataModel.debug("Got " + data.events.length + "new history events..."); - var eid, mid, stime; - for (i = 0; i < data.events.length; i++) { - mid = data.events[i].Event.MonitorId; - eid = data.events[i].Event.Id; - stime = data.events[i].Event.StartTime; - - // only take the first one for each monitor - for (var j = 0; j < $scope.MontageMonitors.length; j++) { - $scope.MontageMonitors[j].Monitor.isPaused = false; - // that's the earliest match and play gapless from there - if ($scope.MontageMonitors[j].Monitor.Id == mid) { - - if ($scope.MontageMonitors[j].Monitor.eventUrl == 'img/noevent.png') { - - // console.log ("Old value of event url " + $scope.MontageMonitors[j].eventUrl); - //console.log ("ldurl is " + ld.streamingurl); - - var bw = NVRDataModel.getBandwidth() == "lowbw" ? zm.eventMontageQualityLowBW : ld.montageHistoryQuality; - $scope.MontageMonitors[j].Monitor.eventUrl = ld.streamingurl + "/nph-zms?source=event&mode=jpeg&event=" + eid + "&frame=1&replay=gapless&rate=" + $scope.sliderVal.realRate + "&connkey=" + $scope.MontageMonitors[j].Monitor.connKey + "&scale=" + bw + "&rand=" + $rootScope.rand; - - //console.log ("Setting event URL to " +$scope.MontageMonitors[j].Monitor.eventUrl); - - // console.log ("SWITCHING TO " + $scope.MontageMonitors[j].eventUrl); - - - $scope.MontageMonitors[j].Monitor.eventUrlTime = stime; - $scope.MontageMonitors[j].Monitor.eid = eid; - $scope.MontageMonitors[j].Monitor.eventDuration = data.events[i].Event.Length; - $scope.MontageMonitors[j].Monitor.sliderProgress = {progress:0}; - - console.log (">>> Setting Event for " + $scope.MontageMonitors[j].Monitor.Name+" to " +eid); - } - - } - } - } - - // make sure we do our best to get that duration for all monitors - // in the above call, is possible some did not make the cut in the first page - - NVRDataModel.log("Making sure all monitors have a fair chance..."); - for (i = 0; i < $scope.MontageMonitors.length; i++) { - - console.log ("Fair chance check for " + $scope.MontageMonitors[i].Monitor.Name); - - if ($scope.MontageMonitors[i].Monitor.eventUrl == 'img/noevent.png') { - - - var indivGrab = ld.apiurl + "/events/index/MonitorId:" + $scope.MontageMonitors[i].Monitor.Id + "/StartTime >=:" + TimeObjectFrom + "/AlarmFrames >=:" + (ld.enableAlarmCount ? ld.minAlarmCount : 0) + ".json"; - - NVRDataModel.debug("Monitor " + $scope.MontageMonitors[i].Monitor.Id + ":" + $scope.MontageMonitors[i].Monitor.Name + " does not have events, trying " + indivGrab); - - getExpandedEvents(i, indivGrab); - + qHttp({ + method: 'get', + url: apiurl + }).then(function (succ) { + var data = succ.data; + var ld = NVRDataModel.getLogin(); + NVRDataModel.debug("Got " + data.events.length + "new history events..."); + var eid, mid, stime; + for (i = 0; i < data.events.length; i++) { + mid = data.events[i].Event.MonitorId; + eid = data.events[i].Event.Id; + stime = data.events[i].Event.StartTime; + // only take the first one for each monitor + for (var j = 0; j < $scope.MontageMonitors.length; j++) { + $scope.MontageMonitors[j].Monitor.isPaused = false; + // that's the earliest match and play gapless from there + if ($scope.MontageMonitors[j].Monitor.Id == mid) { + if ($scope.MontageMonitors[j].Monitor.eventUrl == 'img/noevent.png') { + // console.log ("Old value of event url " + $scope.MontageMonitors[j].eventUrl); + //console.log ("ldurl is " + ld.streamingurl); + var bw = NVRDataModel.getBandwidth() == "lowbw" ? zm.eventMontageQualityLowBW : ld.montageHistoryQuality; + $scope.MontageMonitors[j].Monitor.eventUrl = ld.streamingurl + "/nph-zms?source=event&mode=jpeg&event=" + eid + "&frame=1&replay=gapless&rate=" + $scope.sliderVal.realRate + "&connkey=" + $scope.MontageMonitors[j].Monitor.connKey + "&scale=" + bw + "&rand=" + $rootScope.rand; + //console.log ("Setting event URL to " +$scope.MontageMonitors[j].Monitor.eventUrl); + // console.log ("SWITCHING TO " + $scope.MontageMonitors[j].eventUrl); + $scope.MontageMonitors[j].Monitor.eventUrlTime = stime; + $scope.MontageMonitors[j].Monitor.eid = eid; + $scope.MontageMonitors[j].Monitor.eventDuration = data.events[i].Event.Length; + $scope.MontageMonitors[j].Monitor.sliderProgress = { + progress: 0 + }; + //console.log(">>> Setting Event for " + $scope.MontageMonitors[j].Monitor.Name + " to " + eid); + // now lets get the API for that event for graphing + $scope.MontageMonitors[j].Monitor.noGraph = true; + + + } } } - console.log("REDOING PACKERY & DRAG"); - if (pckry !== undefined) - { - - // remove current draggies - draggies.forEach(function (drag) { - drag.destroy(); - }); - - draggies = []; - // destroy existing packery object - pckry.destroy(); - initPackery(); - - + } + // make sure we do our best to get that duration for all monitors + // in the above call, is possible some did not make the cut in the first page + NVRDataModel.log("Making sure all monitors have a fair chance..."); + for (i = 0; i < $scope.MontageMonitors.length; i++) { + console.log("Fair chance check for " + $scope.MontageMonitors[i].Monitor.Name); + if ($scope.MontageMonitors[i].Monitor.eventUrl == 'img/noevent.png') { + var indivGrab = ld.apiurl + "/events/index/MonitorId:" + $scope.MontageMonitors[i].Monitor.Id + "/StartTime >=:" + TimeObjectFrom + "/AlarmFrames >=:" + (ld.enableAlarmCount ? ld.minAlarmCount : 0) + ".json"; + NVRDataModel.debug("Monitor " + $scope.MontageMonitors[i].Monitor.Id + ":" + $scope.MontageMonitors[i].Monitor.Name + " does not have events, trying " + indivGrab); + getExpandedEvents(i, indivGrab); } - - - }, - function (err) {NVRDataModel.debug("history ERROR:" + JSON.stringify(err));} ); - + } + + // At this stage, we have both a general events grab, and specific event grabs for MIDS that were empty + console.log("REDOING PACKERY & DRAG"); + if (pckry !== undefined) { + // remove current draggies + draggies.forEach(function (drag) { + drag.destroy(); + }); + draggies = []; + // destroy existing packery object + pckry.destroy(); + initPackery(); + } + }, function (err) { + NVRDataModel.debug("history ERROR:" + JSON.stringify(err)); + }); function getExpandedEvents(i, indivGrab) { var ld = NVRDataModel.getLogin(); // console.log ("EXPANDED EVENT " + i + " " + indivGrab); - qHttp({method:'get', url:indivGrab}) - .then(function (succ) { - var data = succ.data; - // console.log ("EXPANDED DATA FOR MONITOR " + i + JSON.stringify(data)); - if (data.events.length > 0) { - - if (!NVRDataModel.isBackground()) { - - var bw = NVRDataModel.getBandwidth() == "lowbw" ? zm.eventMontageQualityLowBW : ld.montageHistoryQuality; - - $scope.MontageMonitors[i].Monitor.eventUrl = ld.streamingurl + "/nph-zms?source=event&mode=jpeg&event=" + data.events[0].Event.Id + "&frame=1&replay=gapless&rate=" + $scope.sliderVal.realRate + "&connkey=" + $scope.MontageMonitors[i].Monitor.connKey + "&scale=" + bw + "&rand=" + $rootScope.rand; - - - - //console.log ("SWITCHING TO " + $scope.MontageMonitors[i].eventUrl); - - $scope.MontageMonitors[i].Monitor.eventUrlTime = data.events[0].Event.StartTime; - $scope.MontageMonitors[i].Monitor.eid = data.events[0].Event.Id; - $scope.MontageMonitors[i].Monitor.sliderProgress = {progress:0}; - - $scope.MontageMonitors[i].Monitor.eventDuration = data.events[0].Event.Length; - console.log (">>> Setting Event for " + $scope.MontageMonitors[i].Monitor.Name+" to " +data.events[0].Event.Id); - - NVRDataModel.log("Found expanded event " + data.events[0].Event.Id + " for monitor " + $scope.MontageMonitors[i].Monitor.Id); - } else { - // $scope.MontageMonitors[i].eventUrl="img/noevent.png"; - // $scope.MontageMonitors[i].eventUrlTime = ""; - // NVRDataModel.log ("Setting img src to null as data received in background"); - } + qHttp({ + method: 'get', + url: indivGrab + }).then(function (succ) { + var data = succ.data; + // console.log ("EXPANDED DATA FOR MONITOR " + i + JSON.stringify(data)); + if (data.events.length > 0) { + if (!NVRDataModel.isBackground()) { + var bw = NVRDataModel.getBandwidth() == "lowbw" ? zm.eventMontageQualityLowBW : ld.montageHistoryQuality; + $scope.MontageMonitors[i].Monitor.eventUrl = ld.streamingurl + "/nph-zms?source=event&mode=jpeg&event=" + data.events[0].Event.Id + "&frame=1&replay=gapless&rate=" + $scope.sliderVal.realRate + "&connkey=" + $scope.MontageMonitors[i].Monitor.connKey + "&scale=" + bw + "&rand=" + $rootScope.rand; + //console.log ("SWITCHING TO " + $scope.MontageMonitors[i].eventUrl); + $scope.MontageMonitors[i].Monitor.eventUrlTime = data.events[0].Event.StartTime; + $scope.MontageMonitors[i].Monitor.eid = data.events[0].Event.Id; + $scope.MontageMonitors[i].Monitor.noGraph = true; + $scope.MontageMonitors[i].Monitor.sliderProgress = { + progress: 0 + }; + $scope.MontageMonitors[i].Monitor.eventDuration = data.events[0].Event.Length; + console.log(">>> Setting Event for " + $scope.MontageMonitors[i].Monitor.Name + " to " + data.events[0].Event.Id); + NVRDataModel.log("Found expanded event " + data.events[0].Event.Id + " for monitor " + $scope.MontageMonitors[i].Monitor.Id); + } else { + // $scope.MontageMonitors[i].eventUrl="img/noevent.png"; + // $scope.MontageMonitors[i].eventUrlTime = ""; + // NVRDataModel.log ("Setting img src to null as data received in background"); } - - }); - + } + }); } } - //--------------------------------------------------------- // This is periodically called to get the current playing // event by zms. I use this to display a timestamp // Its a 2 step process - get event Id then go a Event // API call to get time stamp. Sucks //--------------------------------------------------------- - function checkAllEvents() { - - console.log ("Timer:Events are checked...."); - + console.log("Timer:Events are checked...."); for (var i = 0; i < $scope.MontageMonitors.length; i++) { // don't check for monitors that are not shown // because nph connkey won't exist and the response // will fail - if ($scope.MontageMonitors[i].Monitor.eventUrl != "" && $scope.MontageMonitors[i].Monitor.eventUrl != 'img/noevent.png' && $scope.MontageMonitors[i].Monitor.connKey != '' && - $scope.MontageMonitors[i].Monitor.Function != 'None' && - $scope.MontageMonitors[i].Monitor.listDisplay != 'noshow' && - $scope.MontageMonitors[i].Monitor.Enabled != '0') { - // NVRDataModel.debug("Checking event status for " + $scope.MontageMonitors[i].Monitor.Name + ":" + $scope.MontageMonitors[i].Monitor.eventUrl + ":" + $scope.MontageMonitors[i].Monitor.Function + ":" + $scope.MontageMonitors[i].Monitor.listDisplay); - // console.log ("Sending query 99 for " + $scope.MontageMonitors[i].Monitor.Name + " with ck="+$scope.MontageMonitors[i].Monitor.connKey); + if ($scope.MontageMonitors[i].Monitor.eventUrl != "" && $scope.MontageMonitors[i].Monitor.eventUrl != 'img/noevent.png' && $scope.MontageMonitors[i].Monitor.connKey != '' && $scope.MontageMonitors[i].Monitor.Function != 'None' && $scope.MontageMonitors[i].Monitor.listDisplay != 'noshow' && $scope.MontageMonitors[i].Monitor.Enabled != '0') { + // NVRDataModel.debug("Checking event status for " + $scope.MontageMonitors[i].Monitor.Name + ":" + $scope.MontageMonitors[i].Monitor.eventUrl + ":" + $scope.MontageMonitors[i].Monitor.Function + ":" + $scope.MontageMonitors[i].Monitor.listDisplay); + // console.log ("Sending query 99 for " + $scope.MontageMonitors[i].Monitor.Name + " with ck="+$scope.MontageMonitors[i].Monitor.connKey); controlEventStream('99', '', $scope.MontageMonitors[i].Monitor.connKey, i); - } } } - - - - //-------------------------------------------------------------- // Used to control zms for a connkey. If ndx is not -1, // then it also calls an event API for the returned eid @@ -386,7 +280,6 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc NVRDataModel.debug("Deferring control " + cmd + " by " + mMtime); $timeout(function () { subControlStream(cmd, connkey); - }, mMtime); } @@ -399,42 +292,33 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc /*timeout: 15000,*/ url: loginData.url + '/index.php', headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - //'Accept': '*/*', + 'Content-Type': 'application/x-www-form-urlencoded', //'Accept': '*/*', }, transformRequest: function (obj) { var str = []; - for (var p in obj) - str.push(encodeURIComponent(p) + "=" + - encodeURIComponent(obj[p])); + for (var p in obj) str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); var foo = str.join("&"); //console.log("****SUB RETURNING " + foo); return foo; }, - data: { view: "request", request: "stream", connkey: connkey, command: cmd, - auth: myauthtoken, - // user: loginData.username, + auth: myauthtoken, // user: loginData.username, // pass: loginData.password } }); - req.then(function (succ) { NVRDataModel.debug("subControl success:" + JSON.stringify(succ)); - }, - function (err) {NVRDataModel.debug("subControl error:" + JSON.stringify(err));}); - - + }, function (err) { + NVRDataModel.debug("subControl error:" + JSON.stringify(err)); + }); } - function controlEventStream(cmd, disp, connkey, ndx, extras) { // console.log("Command value " + cmd); - if (disp) { $ionicLoading.hide(); $ionicLoading.show({ @@ -444,8 +328,6 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc }); } var loginData = NVRDataModel.getLogin(); - - /* var CMD_NONE = 0; var CMD_PAUSE = 1; @@ -464,18 +346,12 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc var CMD_SEEK = 14; var CMD_QUERY = 99; */ - - - // You need to POST commands to control zms // Note that I am url encoding the parameters into the URL // If I leave it as JSON, it gets converted to OPTONS due // to CORS behaviour and ZM/Apache don't seem to handle it - //console.log("POST: " + loginData.url + '/index.php'); - //console.log ("AUTH IS " + $rootScope.authSession); - var myauthtoken = $rootScope.authSession.replace("&auth=", ""); //&auth= var req = qHttp({ @@ -483,137 +359,103 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc /*timeout: 15000,*/ url: loginData.url + '/index.php', headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - //'Accept': '*/*', + 'Content-Type': 'application/x-www-form-urlencoded', //'Accept': '*/*', }, transformRequest: function (obj) { var str = []; - for (var p in obj) - str.push(encodeURIComponent(p) + "=" + - encodeURIComponent(obj[p])); + for (var p in obj) str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); var foo = str.join("&"); - if (extras) - foo = foo + extras; - //console.log("****RETURNING " + foo); + if (extras) foo = foo + extras; + //console.log("****RETURNING " + foo); return foo; }, - data: { view: "request", request: "stream", connkey: connkey, command: cmd, - auth: myauthtoken, - // user: loginData.username, + auth: myauthtoken, // user: loginData.username, // pass: loginData.password } }); req.then(function (succ) { - var resp = succ.data; - //console.log("SUCCESS FOR: " + JSON.stringify(resp)); - - //SUCCESS FOR: {"result":"Ok","status":{"type":3,"event":29621,"progress":1,"rate":1,"zoom":"1.0","paused":0}} - //$scope.MontageMonitors[ndx].Monitor.eid = data.event.Event.Id; - if (resp.result == "Ok" && ndx != -1 && (resp.status.event == $scope.MontageMonitors[ndx].Monitor.eid)) + console.log ("zms response: " + JSON.stringify(resp)); + + // move progress bar if event id is the same + if (resp.result == "Ok" && ndx != -1 && (resp.status.event == $scope.MontageMonitors[ndx].Monitor.eid)) $scope.MontageMonitors[ndx].Monitor.sliderProgress.progress = resp.status.progress; - if (resp.result == "Ok" && ndx != -1 && (resp.status.event != $scope.MontageMonitors[ndx].Monitor.eid) ) { - // $scope.MontageMonitors[ndx].Monitor.sliderProgress.progress = 0; - NVRDataModel.debug ("Fetching details, as event changed for " + $scope.MontageMonitors[ndx].Monitor.Name+" from " + $scope.MontageMonitors[ndx].Monitor.eid + " to " +resp.status.event); + + if (resp.result == "Ok" && ndx != -1 && ((resp.status.event != $scope.MontageMonitors[ndx].Monitor.eid) || $scope.MontageMonitors[ndx].Monitor.noGraph == true)) { + $scope.MontageMonitors[ndx].Monitor.noGraph = false; + // $scope.MontageMonitors[ndx].Monitor.sliderProgress.progress = 0; + NVRDataModel.debug("Fetching details, as event changed for " + $scope.MontageMonitors[ndx].Monitor.Name + " from " + $scope.MontageMonitors[ndx].Monitor.eid + " to " + resp.status.event); var ld = NVRDataModel.getLogin(); var apiurl = ld.apiurl + "/events/" + resp.status.event + ".json"; //console.log ("API " + apiurl); - qHttp({method:'get', url:apiurl}) - .then(function (succ) { - var data = succ.data; - var currentEventTime = moment(data.event.Event.StartTime); - var maxTime = moment(); - //NVRDataModel.debug ("Monitor: " + $scope.MontageMonitors[ndx].Monitor.Id + " max time="+maxTime + "("+$scope.datetimeValueTo.value+")"+ " current="+currentEventTime + "("+data.event.Event.StartTime+")"); - if ($scope.MontageMonitors[ndx].Monitor.eventUrlTime != data.event.Event.StartTime && currentEventTime.diff(maxTime) <= 0) { - - - var framearray = { - + qHttp({ + method: 'get', + url: apiurl + }).then(function (succ) { + var data = succ.data; + var currentEventTime = moment(data.event.Event.StartTime); + var maxTime = moment(); + //NVRDataModel.debug ("Monitor: " + $scope.MontageMonitors[ndx].Monitor.Id + " max time="+maxTime + "("+$scope.datetimeValueTo.value+")"+ " current="+currentEventTime + "("+data.event.Event.StartTime+")"); + + var framearray = { labels: [], datasets: [{ - backgroundColor: 'rgba(242, 12, 12, 0.5)', borderColor: 'rgba(242, 12, 12, 0.5)', data: [], - }] + }] }; - - - framearray.labels = []; - var ld = NVRDataModel.getLogin(); - console.log (">>>>> GRAPH"); - for (i=0; i>> Setting Event for " + $scope.MontageMonitors[ndx].Monitor.Name+" to " +data.event.Event.Id); - - - }, 700); - - } else if (currentEventTime.diff(maxTime) > 0) { - NVRDataModel.debug(">>>>>>>>Monitor " + $scope.MontageMonitors[ndx].Monitor.Id + " event time of " + data.event.Event.StartTime + " exceeds " + $scope.datetimeValueTo.value + " stopping..."); - subControlStream(17, connkey); - - + framearray.labels = []; + var ld = NVRDataModel.getLogin(); + console.log(">>>>> GRAPH"); + for (i = 0; i < data.event.Frame.length; i++) { + var ts = moment(data.event.Frame[i].TimeStamp).format(timeFormat); + //console.log ("pushing s:" + event.Frame[i].Score+" t:"+ts); + framearray.datasets[0].data.push({ + x: ts, + y: data.event.Frame[i].Score + }); + framearray.labels.push(""); } - - }, - function (err) {$scope.MontageMonitors[ndx].Monitor.eventUrlTime = "-"; } - ); + $timeout(function () { + drawGraph(framearray, $scope.MontageMonitors[ndx].Monitor.Id); + }, 500); + var element = angular.element(document.getElementById($scope.MontageMonitors[ndx].Monitor.Id + "-timeline")); + element.removeClass('animated flipInX'); + element.addClass('animated flipOutX'); + $timeout(function () { + element.removeClass('animated flipOutX'); + element.addClass('animated flipInX'); + $scope.MontageMonitors[ndx].Monitor.eventUrlTime = data.event.Event.StartTime; + var bw = NVRDataModel.getBandwidth() == "lowbw" ? zm.eventMontageQualityLowBW : ld.montageHistoryQuality; + $scope.MontageMonitors[ndx].Monitor.eventUrl = ld.streamingurl + "/nph-zms?source=event&mode=jpeg&event=" + data.event.Event.Id + "&frame=1&replay=gapless&rate=" + $scope.sliderVal.realRate + "&connkey=" + $scope.MontageMonitors[ndx].Monitor.connKey + "&scale=" + bw + "&rand=" + $rootScope.rand; + $scope.MontageMonitors[ndx].Monitor.eid = data.event.Event.Id; + $scope.MontageMonitors[ndx].Monitor.sliderProgress = { + progress: 0 + }; + $scope.MontageMonitors[ndx].Monitor.eventDuration = data.event.Event.Length; + console.log(">>> Setting Event for " + $scope.MontageMonitors[ndx].Monitor.Name + " to " + data.event.Event.Id); + }, 700); + - + }, function (err) { + $scope.MontageMonitors[ndx].Monitor.eventUrlTime = "-"; + }); } - }, - function (err) { NVRDataModel.log("Error sending event command " + JSON.stringify(err), "error");} - - ); - - + }, function (err) { + NVRDataModel.log("Error sending event command " + JSON.stringify(err), "error"); + }); } - - - $scope.isBackground = function () { return NVRDataModel.isBackground(); }; - - //---------------------------------------------------------------- // Alarm notification handling //---------------------------------------------------------------- @@ -626,22 +468,19 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc }); $state.go("events", { "id": 0, - "playEvent":false + "playEvent": false }, { reload: true }); } }; - $scope.handleAlarmsWhileMinimized = function () { $rootScope.isAlarm = !$rootScope.isAlarm; - $scope.minimal = !$scope.minimal; NVRDataModel.debug("MontageHistoryCtrl: switch minimal is " + $scope.minimal); ionic.Platform.fullScreen($scope.minimal, !$scope.minimal); $interval.cancel(intervalHandle); $interval.cancel($rootScope.eventQueryInterval); - if (!$rootScope.isAlarm) { $rootScope.alarmCount = "0"; $ionicHistory.nextViewOptions({ @@ -649,42 +488,26 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc }); $state.go("events", { "id": 0, - "playEvent":false, + "playEvent": false, }, { reload: true }); } }; - - //------------------------------------------------------------- // this is checked to make sure we are not pulling images // when app is in background. This is a problem with Android, // for example //------------------------------------------------------------- - $scope.isBackground = function () { //console.log ("Is background called from Montage and returned " + //NVRDataModel.isBackground()); return NVRDataModel.isBackground(); }; - - - - - - - - - $scope.toggleControls = function() - { - $scope.showControls = !$scope.showControls; - }; - - - + $scope.toggleControls = function () { + $scope.showControls = !$scope.showControls; + }; $scope.toggleSelectItem = function (ndx) { - if ($scope.MontageMonitors[ndx].Monitor.selectStyle !== "undefined" && $scope.MontageMonitors[ndx].Monitor.selectStyle == "dragborder-selected") { $scope.MontageMonitors[ndx].Monitor.selectStyle = ""; } else { @@ -695,31 +518,24 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc //--------------------------------------------------------------------- // Called when you enable/disable dragging //--------------------------------------------------------------------- - $scope.dragToggle = function () { dragToggle(); - - }; function dragToggle() { var i; $scope.isDragabillyOn = !$scope.isDragabillyOn; - $ionicSideMenuDelegate.canDragContent($scope.isDragabillyOn ? false : true); - //$timeout(function(){pckry.reloadItems();},10); NVRDataModel.debug("setting dragabilly to " + $scope.isDragabillyOn); if ($scope.isDragabillyOn) { $scope.showSizeButtons = true; - $scope.dragBorder = "dragborder"; NVRDataModel.debug("Enabling drag for " + draggies.length + " items"); for (i = 0; i < draggies.length; i++) { draggies[i].enable(); draggies[i].bindHandles(); } - // reflow and reload as some may be hidden // $timeout(function(){pckry.reloadItems();$timeout(function(){pckry.layout();},300);},100); } else { @@ -743,7 +559,6 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc NVRDataModel.setLogin(ld);*/ }, 300); }, 100); - } } //--------------------------------------------------------------------- @@ -752,12 +567,9 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc $scope.togglePTZ = function () { $scope.showPTZ = !$scope.showPTZ; }; - $scope.callback = function () { // console.log("dragging"); }; - - $scope.onDropComplete = function (index, obj, event) { //console.log("dragged"); var otherObj = $scope.MontageMonitors[index]; @@ -765,134 +577,66 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc $scope.MontageMonitors[index] = obj; $scope.MontageMonitors[otherIndex] = otherObj; }; - - - - //--------------------------------------------------------------------- // changes order of montage display //--------------------------------------------------------------------- - $scope.toggleMontageDisplayOrder = function () { $scope.packMontage = !$scope.packMontage; loginData.packMontage = $scope.packMontage; NVRDataModel.setLogin(loginData); //console.log ("Switching orientation"); }; - - //--------------------------------------------------------------------- // In Android, the app runs full steam while in background mode // while in iOS it gets suspended unless you ask for specific resources // So while this view, we DON'T want Android to keep sending 1 second // refreshes to the server for images we are not seeing //--------------------------------------------------------------------- - function onPause() { NVRDataModel.debug("MontageHistoryCtrl: onpause called"); $interval.cancel($rootScope.eventQueryInterval); $interval.cancel(intervalHandle); - // $interval.cancel(modalIntervalHandle); - // FIXME: Do I need to setAwake(false) here? } - - function onResume() { - - // FIXME: Do we need to resume timers? when you resume, you go to portal and then here - /* - if (!$scope.isModalActive) { - var ld = NVRDataModel.getLogin(); - - - NVRDataModel.debug("MontageHistoryCtrl: onresume called"); - NVRDataModel.log("Restarting eventQuery timer on resume"); - - console.log ("************** TIMER STARTED INSIDE RESUME ***************"); - - //$rootScope.rand = Math.floor((Math.random() * 100000) + 1); - $interval.cancel($rootScope.eventQueryInterval); - $rootScope.eventQueryInterval = $interval(function () { - checkAllEvents(); - // console.log ("Refreshing Image..."); - }.bind(this),zm.eventHistoryTimer); - } else // modal is active - { - // $rootScope.modalRand = Math.floor((Math.random() * 100000) + 1); - }*/ - - - - - } - + function onResume() {} $scope.openMenu = function () { $timeout(function () { $rootScope.stateofSlide = $ionicSideMenuDelegate.isOpen(); }, 500); - $ionicSideMenuDelegate.toggleLeft(); }; - $scope.$on('$destroy', function () { NVRDataModel.debug("Cancelling eventQueryInterval"); $interval.cancel($rootScope.eventQueryInterval); - - - - }); - - $scope.$on('$ionicView.loaded', function () { //console.log("**VIEW ** MontageHistoryCtrl Loaded"); }); - $scope.$on('$ionicView.enter', function () { NVRDataModel.debug("**VIEW ** MontageHistory Ctrl Entered"); var ld = NVRDataModel.getLogin(); //console.log("Setting Awake to " + NVRDataModel.getKeepAwake()); NVRDataModel.setAwake(NVRDataModel.getKeepAwake()); - - NVRDataModel.debug ("query timer started"); + NVRDataModel.debug("query timer started"); $interval.cancel($rootScope.eventQueryInterval); //console.log ("****************** TIMER STARTED INSIDE ENTER"); $rootScope.eventQueryInterval = $interval(function () { checkAllEvents(); - }.bind(this), zm.eventHistoryTimer); - - - - - }); - /*$scope.$on ('$ionicView.unloaded', function() { console.log ("******** HISTORY UNLOADED KILLING WINDOW ************"); window.stop(); });*/ - - $scope.$on('$ionicView.beforeEnter', function () { - // NVRDataModel.log ("Before Enter History: initing connkeys"); - - - - - }); - $scope.$on('$ionicView.beforeLeave', function () { //console.log("**VIEW ** Event History Ctrl Left, force removing modal"); if ($scope.modal) $scope.modal.remove(); - - NVRDataModel.log("BeforeLeave: Nullifying the streams..."); - for (i = 0; i < $scope.MontageMonitors.length; i++) { var element = document.getElementById("img-" + i); /*if (element) @@ -904,46 +648,25 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc //$scope.$apply(nullify(element)); //element.src=""; }*/ - } - - - NVRDataModel.log("Cancelling event query timer"); $interval.cancel($rootScope.eventQueryInterval); - NVRDataModel.log("MontageHistory:Stopping network pull..."); // make sure this is applied in scope digest to stop network pull // thats why we are doing it beforeLeave - for (i = 0; i < $scope.MontageMonitors.length; i++) { - if ($scope.MontageMonitors[i].Monitor.connKey != '' && - $scope.MontageMonitors[i].Monitor.eventUrl != 'img/noevent.png' && - $scope.MontageMonitors[i].Monitor.Function != 'None' && - $scope.MontageMonitors[i].Monitor.lisDisplay != 'noshow' && - $scope.MontageMonitors[i].Monitor.Enabled != '0') { + if ($scope.MontageMonitors[i].Monitor.connKey != '' && $scope.MontageMonitors[i].Monitor.eventUrl != 'img/noevent.png' && $scope.MontageMonitors[i].Monitor.Function != 'None' && $scope.MontageMonitors[i].Monitor.lisDisplay != 'noshow' && $scope.MontageMonitors[i].Monitor.Enabled != '0') { NVRDataModel.log("Before leave: Calling kill with " + $scope.MontageMonitors[i].Monitor.connKey); var tmpCK = angular.copy($scope.MontageMonitors[i].Monitor.connKey); timedControlEventStream(2500, 17, "", tmpCK, -1); } } - pckry.destroy(); window.removeEventListener("resize", orientationChanged, false); - NVRDataModel.log("Forcing a window.stop() here"); NVRDataModel.stopNetwork("MontageHistory-beforeLeave"); - - - - - }); - - $scope.$on('$ionicView.unloaded', function () { - }); - - + $scope.$on('$ionicView.unloaded', function () {}); $scope.sliderChanged = function (dirn) { console.log("SLIDER CHANGED"); if ($scope.sliderChanging) { @@ -951,35 +674,26 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc //$scope.slider.monsize = oldSliderVal; // return; } - $scope.sliderChanging = true; - var somethingReset = false; - // this only changes items that are selected for (var i = 0; i < $scope.MontageMonitors.length; i++) { - var curVal = parseInt($scope.MontageMonitors[i].Monitor.gridScale); curVal = curVal + (10 * dirn); if (curVal < 10) curVal = 10; if (curVal > 100) curVal = 100; //console.log ("For Index: " + i + " From: " + $scope.MontageMonitors[i].Monitor.gridScale + " To: " + curVal); - if ($scope.isDragabillyOn) { // only do this for selected monitors if ($scope.MontageMonitors[i].Monitor.selectStyle == "dragborder-selected") { - $scope.MontageMonitors[i].Monitor.gridScale = curVal; somethingReset = true; } } else { $scope.MontageMonitors[i].Monitor.gridScale = curVal; //somethingReset = true; - } - } - // this changes all items if none were selected if (!somethingReset && $scope.isDragabillyOn) // nothing was selected { @@ -991,10 +705,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc $scope.MontageMonitors[i].Monitor.gridScale = cv; } } - - //pckry.reloadItems(); - pckry.once('layoutComplete', function () { /* $timeout(function () { var positions = pckry.EHgetShiftPositions('eh-data-item-id'); @@ -1006,33 +717,22 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc $scope.sliderChanging = false; }, zm.packeryTimer);*/ }); - - - if (!somethingReset) { //console.log (">>>SOMETHING NOT RESET"); $timeout(function () { pckry.layout(); }, zm.packeryTimer); } else { - //console.log (">>>SOMETHING RESET"); $timeout(function () { layout(pckry); }, zm.packeryTimer); } - - - - }; function layout(pckry) { pckry.shiftLayout(); } - - - $scope.resetSizes = function () { var somethingReset = false; for (var i = 0; i < $scope.MontageMonitors.length; i++) { @@ -1052,101 +752,44 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc $scope.MontageMonitors[i].Monitor.gridScale = "50"; } } - $timeout(function () { pckry.reloadItems(); - - $timeout(function () { pckry.layout(); }, zm.packeryTimer); // force here - no shiftlayout - - }, 100); - }; - - function isEmpty(obj) { + function isEmpty(obj) { for (var prop in obj) { return false; } return true; } - // called by afterEnter to load Packery function initPackery() { - - $ionicLoading.show({ template: $translate.instant('kArrangingImages'), noBackdrop: true, duration: zm.loadingTimeout }); - var progressCalled = false; draggies = []; var layouttype = true; var ld = NVRDataModel.getLogin(); - - - var positionsStr = ld.packeryPositions; - var positions = {}; - - // if (positionsStr == '') { - if (1) { - - NVRDataModel.log("Did NOT find a EHpackery layout"); - layouttype = true; - } else { - - //console.log ("POSITION STR IS " + positionsStr); - positions = JSON.parse(positionsStr); - NVRDataModel.log("found a EHpackery layout"); - console.log(positionsStr); - layouttype = false; - } - - - var cnt = 0; - $scope.MontageMonitors.forEach(function (elem) { - - if ((elem.Monitor.Enabled != '0') && (elem.Monitor.Function != 'None')) - cnt++; - }); - - NVRDataModel.log("Monitors that are active and not DOM hidden: " + cnt + " while grid has " + positions.length); - - if (cnt > NVRDataModel.getLogin().maxMontage) { - cnt = NVRDataModel.getLogin().maxMontage; - NVRDataModel.log("restricting monitor count to " + cnt + " due to max-montage setting"); - } - - /*if (cnt != positions.length) { - - NVRDataModel.log("Whoops!! Monitors have changed. I'm resetting layouts, sorry!"); - layouttype = true; - positions = {}; - }*/ - + var elem = angular.element(document.getElementById("mygrid")); - //console.log ("**** mygrid is " + JSON.stringify(elem)); - imagesLoaded(elem).on('progress', function (instance, img) { - progressCalled = true; - // if (layouttype) $timeout (function(){layout(pckry);},100); }); - imagesLoaded(elem).once('always', function () { console.log("******** ALL IMAGES LOADED"); NVRDataModel.debug("All images loaded"); - - $ionicLoading.hide(); - $timeout(function () { + + layouttype = true; pckry = new Packery('.grid', { itemSelector: '.grid-item', percentPosition: true, @@ -1155,16 +798,16 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc initLayout: layouttype }); + pckry.reloadItems(); if (!progressCalled) { - NVRDataModel.log("*** BUG PROGRESS WAS NOT CALLED"); - pckry.reloadItems(); - + NVRDataModel.log("*** PROGRESS WAS NOT CALLED"); + } + + + $timeout(function () { - - var cnt = 0; pckry.getItemElements().forEach(function (itemElem) { - draggie = new Draggabilly(itemElem); pckry.bindDraggabillyEvents(draggie); draggies.push(draggie); @@ -1176,7 +819,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc - if (!isEmpty(positions)) { + /*if (!isEmpty(positions)) { NVRDataModel.log("Arranging as per packery grid"); for (var i = 0; i < $scope.MontageMonitors.length; i++) { @@ -1192,79 +835,65 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc NVRDataModel.debug("All images loaded, doing image layout"); - /* $timeout(function () { - pckry.initShiftLayout(positions, 'eh-data-item-id'); - }, 0);*/ - } - $scope.allImagesLoaded = true; + $timeout(function () { + pckry.initShiftLayout(positions, 'data-item-id'); + }, 0); + }*/ + + + $timeout(function () { NVRDataModel.log("Force calling resize"); pckry.layout(); - }, zm.packeryTimer); // don't ask }, zm.packeryTimer); + }); function itemDragged(item) { NVRDataModel.debug("drag complete"); - - } - - } - - $scope.$on('$ionicView.afterEnter', function () { // This rand is really used to reload the monitor image in img-src so it is not cached // I am making sure the image in montage view is always fresh // I don't think I am using this anymore FIXME: check and delete if needed // $rootScope.rand = Math.floor((Math.random() * 100000) + 1); - - - $scope.showControls = false; + $scope.showControls = false; + readyToRun = false; $timeout(function () { + initPackery(); + readyToRun = true; + footerCollapse(); + }, zm.packeryTimer); }); - $scope.reloadView = function () { $rootScope.rand = Math.floor((Math.random() * 100000) + 1); NVRDataModel.log("User action: image reload " + $rootScope.rand); }; - $scope.doRefresh = function () { - - - //console.log("***Pull to Refresh, recomputing Rand"); NVRDataModel.log("Reloading view for montage view, recomputing rand"); $rootScope.rand = Math.floor((Math.random() * 100000) + 1); $scope.MontageMonitors = []; imageLoadingDataShare.set(0); - - var refresh = NVRDataModel.getMonitors(1); - refresh.then(function (data) { $scope.MontageMonitors = data.data; $scope.$broadcast('scroll.refreshComplete'); }); }; - - - function drawGraph(f,mid) { - - console.log ("Graphing on " + "eventchart-"+mid); - var cv = document.getElementById("eventchart-"+mid); + function drawGraph(f, mid) { + console.log("Graphing on " + "eventchart-" + mid); + var cv = document.getElementById("eventchart-" + mid); var ctx = cv.getContext("2d"); - - frameoptions = { responsive: true, legend: false, @@ -1279,110 +908,76 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc display: false, labelString: 'value', } - }], xAxes: [{ type: 'time', display: false, time: { - format: timeFormat, tooltipFormat: 'll HH:mm', min: f.datasets[0].data[0].x, max: f.datasets[0].data[f.datasets[0].data.length - 1].x, - displayFormats: { - - } + displayFormats: {} }, scaleLabel: { display: false, labelString: '' } - }] } }; - - $timeout(function () { - - var myChart = new Chart(ctx, { type: 'line', data: f, options: frameoptions, }); - }); } - - //--------------------------------------------------------------------- // Controller main //--------------------------------------------------------------------- - var intervalHandle; $scope.isModalActive = false; var modalIntervalHandle; $scope.hrsAgo = 4; - window.addEventListener("resize", orientationChanged, false); - document.addEventListener("pause", onPause, false); document.addEventListener("resume", onResume, false); - $scope.timeFormat = "yyyy-MM-dd " + NVRDataModel.getTimeFormat(); $scope.displayDateTimeSliders = true; $scope.showtimers = true; $scope.loginData = NVRDataModel.getLogin(); var timeFormat = 'MM/DD/YYYY HH:mm:ss'; - var curYear = new Date().getFullYear(); - var readyToRun = false; var i; - $scope.sliderVal = { - - rate: 1, - realRate: 100, + rate: 2, + realRate: 200, hideNoEvents: false, enableGapless: true, exactMatch: false, showTimeline: true - }; - - var frameoptions = []; - - // default = start of day var timeto = moment(); var timefrom = moment().startOf('day'); - - $scope.sliderVal.rate = 1; + $scope.sliderVal.rate = 2; $scope.sliderVal.realRate = $scope.sliderVal.rate * 100; - - $scope.datetimeValueFrom = { value: "", - hrs:"" + hrs: "" }; $scope.datetimeValueTo = { value: "" }; - $scope.datetimeValueFrom.value = timefrom.toDate(); $scope.datetimeValueFrom.hrs = Math.round(moment.duration(moment().diff(moment($scope.datetimeValueFrom.value))).asHours()); - $scope.datetimeValueTo.value = timeto.toDate(); - $rootScope.eventQueryInterval = ""; - - var commonCss = { - background: { "background-color": "silver" }, @@ -1402,42 +997,29 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc "background-color": "red" } // use it if double value }; - - $scope.slider_modal_options_rate = { from: 1, to: 10, realtime: true, step: 1, - className: "mySliderClass", - //modelLabels:function(val) {return "";}, + className: "mySliderClass", //modelLabels:function(val) {return "";}, smooth: false, css: commonCss, dimension: 'X' - }; - - var gridcontainer, pckry, draggie, draggies; - $scope.monitorSize = []; // array with montage sizes per monitor $scope.scaleDirection = []; // 1 = increase -1 = decrease - - // The difference between old and original is this: // old will have a copy of the last re-arranged monitor list // while original will have a copy of the order returned by ZM - var oldMonitors = []; // To keep old order if user cancels after sort; - // Montage display order may be different so don't // mangle monitors as it will affect other screens // in Montage screen we will work with this local copy //$scope.MontageMonitors = angular.copy ($scope.monitors); - var montageOrder = []; // This array will keep the ordering in montage view var hiddenOrder = []; // 1 = hide, 0 = don't hide - var tempMonitors = message; if (tempMonitors.length == 0) { $rootScope.zmPopup = $ionicPopup.alert({ @@ -1450,22 +1032,14 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc $state.go("login"); return; } - - - $scope.MontageMonitors = message; + $scope.MontageMonitors = message; NVRDataModel.log("Inside MontageHistoryCtrl:We found " + $scope.MontageMonitors.length + " monitors"); - - // $scope.MontageMonitors = NVRDataModel.applyMontageMonitorPrefs(message, 1)[0]; - - + // $scope.MontageMonitors = NVRDataModel.applyMontageMonitorPrefs(message, 1)[0]; var loginData = NVRDataModel.getLogin(); - // init monitors NVRDataModel.debug(">>Initializing connkeys and images..."); for (i = 0; i < $scope.MontageMonitors.length; i++) { //$scope.MontageMonitors[i].Monitor.connKey=''; - - $scope.MontageMonitors[i].Monitor.eid = "-1"; $scope.MontageMonitors[i].Monitor.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); $scope.MontageMonitors[i].Monitor.eventUrl = 'img/noevent.png'; @@ -1475,18 +1049,15 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc $scope.MontageMonitors[i].Monitor.gridScale = "50"; $scope.MontageMonitors[i].Monitor.selectStyle = ""; $scope.MontageMonitors[i].Monitor.alarmState = 'color:rgba(0,0,0,0);'; - $scope.MontageMonitors[i].Monitor.sliderProgress = {progress:0}; - + $scope.MontageMonitors[i].Monitor.sliderProgress = { + progress: 0 + }; } - readyToRun = true; - - - + // -------------------------------------------------------- // Handling of back button in case modal is open should // close the modal // -------------------------------------------------------- - $ionicPlatform.registerBackButtonAction(function (e) { e.preventDefault(); if ($scope.modal && $scope.modal.isShown()) { @@ -1499,37 +1070,22 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc NVRDataModel.debug("Modal is closed, so toggling or exiting"); if (!$ionicSideMenuDelegate.isOpenLeft()) { $ionicSideMenuDelegate.toggleLeft(); - } else { navigator.app.exitApp(); } - } - }, 1000); - - - - $scope.isRefresh = $stateParams.isRefresh; var sizeInProgress = false; $ionicSideMenuDelegate.canDragContent(true); - - - - $scope.LoginData = NVRDataModel.getLogin(); $scope.monLimit = $scope.LoginData.maxMontage; $scope.currentLimit = $scope.LoginData.maxMontage; - if ($rootScope.platformOS != 'ios') { NVRDataModel.log("Limiting montage to 5, thanks to Chrome's stupid connection limit"); $scope.currentLimit = 5; $scope.monLimit = 5; - } - - $rootScope.authSession = "undefined"; $ionicLoading.show({ template: $translate.instant('kNegotiatingStreamAuth'), @@ -1539,33 +1095,18 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc maxWidth: 300, showDelay: 0 }); - - var ld = NVRDataModel.getLogin(); - //console.log ("MONITORS " + JSON.stringify($scope.monitors)); $rootScope.validMonitorId = $scope.MontageMonitors[0].Monitor.Id; - NVRDataModel.getAuthKey($rootScope.validMonitorId) - .then(function (success) { - $ionicLoading.hide(); - //console.log(success); - $rootScope.authSession = success; - NVRDataModel.log("Stream authentication construction: " + - $rootScope.authSession); - - }, - function (error) { - - $ionicLoading.hide(); - NVRDataModel.debug("MontageHistoryCtrl: Error in authkey retrieval " + error); - //$rootScope.authSession=""; - NVRDataModel.log("MontageHistoryCtrl: Error returned Stream authentication construction. Retaining old value of: " + $rootScope.authSession); - }); - - - - - - - + NVRDataModel.getAuthKey($rootScope.validMonitorId).then(function (success) { + $ionicLoading.hide(); + //console.log(success); + $rootScope.authSession = success; + NVRDataModel.log("Stream authentication construction: " + $rootScope.authSession); + }, function (error) { + $ionicLoading.hide(); + NVRDataModel.debug("MontageHistoryCtrl: Error in authkey retrieval " + error); + //$rootScope.authSession=""; + NVRDataModel.log("MontageHistoryCtrl: Error returned Stream authentication construction. Retaining old value of: " + $rootScope.authSession); + }); }]); \ No newline at end of file diff --git a/www/templates/events-modal.html b/www/templates/events-modal.html index 2c1c38c7..b71cf751 100644 --- a/www/templates/events-modal.html +++ b/www/templates/events-modal.html @@ -78,7 +78,7 @@
+ padding-right:23px;" id="eventchart" width="auto" height="20">
diff --git a/www/templates/montage-history.html b/www/templates/montage-history.html index aa38df16..98426dc1 100644 --- a/www/templates/montage-history.html +++ b/www/templates/montage-history.html @@ -21,7 +21,7 @@
-
+
@@ -41,7 +41,7 @@
- +
  @@ -50,12 +50,12 @@   {{monitor.Monitor.Name}}  -
+
[{{monitor.Monitor.eid}}] {{prettifyDateTimeFirst(monitor.Monitor.eventUrlTime)}} ({{humanizeTime(monitor.Monitor.eventUrlTime)}}) 
-
+
@@ -63,12 +63,13 @@
- eventchart-{{monitor.Monitor.Id}} - -
+ + +
- +
-- cgit v1.2.3 From 19c26c350efb1b008ee9806fbf73d64cfba864f5 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Tue, 11 Oct 2016 16:14:33 -0400 Subject: removed my math.ceil hack, added PR hack Former-commit-id: f142c72ea69ca11eae8d3a37ec933754e833eabe --- www/external/ion-pullup.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'www') diff --git a/www/external/ion-pullup.js b/www/external/ion-pullup.js index 9bd5ab56..798d25ee 100755 --- a/www/external/ion-pullup.js +++ b/www/external/ion-pullup.js @@ -43,8 +43,8 @@ angular.module('ionic-pullup', []) tabs = document.querySelector('.tabs'); hasBottomTabs = document.querySelector('.tabs-bottom'); header = document.querySelector('.bar-header'); - tabsHeight = tabs ? tabs.offsetHeight : 0; - headerHeight = header ? header.offsetHeight : 0; + tabsHeight = tabs ? tabs.offsetHeight : 80; + headerHeight = header ? header.offsetHeight : 80; } function computeHeights() { -- cgit v1.2.3 From eaa579a83719520d73d8a316ef6af9450bd59129 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Tue, 11 Oct 2016 16:14:46 -0400 Subject: make sure graph is always below range Former-commit-id: 7b0684171c457551f3ccbeb58d4f713235594fb0 --- www/css/style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'www') diff --git a/www/css/style.css b/www/css/style.css index 09acc566..2d2a6d35 100644 --- a/www/css/style.css +++ b/www/css/style.css @@ -902,7 +902,7 @@ body { height: 20px; opacity: 1; - z-index: 99; + z-index: 998; } -- cgit v1.2.3 From 0202d7298986ab02cb1571751d7261ab8afc5f42 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Tue, 11 Oct 2016 16:15:06 -0400 Subject: removed my ceil hack, added PR hack for round Former-commit-id: f470f17b8c96ea755d2551d925209e448506a70b --- www/external/packery.pkgd.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'www') diff --git a/www/external/packery.pkgd.js b/www/external/packery.pkgd.js index 86cb6932..7576576b 100644 --- a/www/external/packery.pkgd.js +++ b/www/external/packery.pkgd.js @@ -285,7 +285,8 @@ function setup() { body.appendChild( div ); var style = getStyle( div ); - getSize.isBoxSizeOuter = isBoxSizeOuter = getStyleSize( style.width ) == 200; + //PP https://github.com/metafizzy/packery/pull/382/commits/ea595864bfc161e992bcb28cbce132df9eac57b9 + getSize.isBoxSizeOuter = isBoxSizeOuter = Math.round(getStyleSize( style.width )) == 200; body.removeChild( div ); } @@ -2797,8 +2798,8 @@ Packery.prototype.initShiftLayout = function( positions, attr ) { var selector = '[' + attr + '="' + itemPosition.attr + '"]' var itemElem = this.element.querySelector( selector ); var item = this.getItem( itemElem ); - //item.rect.x = itemPosition.x * this.packer.width; - item.rect.x = Math.ceil(itemPosition.x * this.packer.width); + item.rect.x = itemPosition.x * this.packer.width; + //item.rect.x = Math.ceil(itemPosition.x * this.packer.width); item.rect.y = itemPosition.y * this.packer.height; //console.log ("X computed as " + item.rect.x); return item; -- cgit v1.2.3 From 0daca364349874a56712cf1b0a6281b1ff893bed Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Tue, 11 Oct 2016 16:15:21 -0400 Subject: wait for sendCmd using promise value Former-commit-id: f1304de74f911c2e876b06f115877a03270fde1f --- www/js/EventModalCtrl.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'www') diff --git a/www/js/EventModalCtrl.js b/www/js/EventModalCtrl.js index ce745716..d91986aa 100644 --- a/www/js/EventModalCtrl.js +++ b/www/js/EventModalCtrl.js @@ -389,14 +389,10 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro //console.log("YOU changed " + $scope.sliderProgress.progress); $scope.currentProgress.progress = $scope.sliderProgress.progress; - $timeout(function () { - sendCommand('14', $scope.connKey, '&offset=' + $scope.currentProgress.progress); - }, 500); - // give this command some time to complete - $timeout(function () { - $scope.blockSlider = false; - }, 1500); - + sendCommand('14', $scope.connKey, '&offset=' + $scope.currentProgress.progress) + .then (function (s) { $scope.blockSlider = false; }, function (e) {$scope.blockSlider = false;}); + + }; -- cgit v1.2.3 From 150c7063094985cdd24a2c2a1e5b472f1b5df37e Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Tue, 11 Oct 2016 16:16:01 -0400 Subject: nothing of material value Former-commit-id: a1ae7726d147fb48f053bc3b56b6f65074d9cec8 --- www/js/MontageCtrl.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'www') diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js index 0681d832..1e13dd80 100644 --- a/www/js/MontageCtrl.js +++ b/www/js/MontageCtrl.js @@ -162,12 +162,14 @@ angular.module('zmApp.controllers') imagesLoaded(elem).on('progress', function (instance, img) { progressCalled = true; + // if (layouttype) $timeout (function(){layout(pckry);},100); }); imagesLoaded(elem).on('always', function () { //console.log ("******** ALL IMAGES LOADED"); + // $scope.$digest(); NVRDataModel.debug("All images loaded"); $scope.areImagesLoading = false; @@ -219,6 +221,7 @@ angular.module('zmApp.controllers') NVRDataModel.debug("All images loaded, doing image layout"); $timeout(function () { pckry.initShiftLayout(positions, 'data-item-id'); + //$scope.$digest(); }, 0); } $timeout(function () { @@ -226,7 +229,7 @@ angular.module('zmApp.controllers') pckry.shiftLayout(); }, zm.packeryTimer); // don't ask - + pckry.onresize(); }, zm.packeryTimer); -- cgit v1.2.3 From 7ca28db34c79f59c9143baf2116250379593f66b Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Tue, 11 Oct 2016 16:16:35 -0400 Subject: make sure we don't move bar if user moved it and waiting for response Former-commit-id: 4c8c47aa648e5e409715e0ed97eac071d59bccb6 --- www/js/MontageHistoryCtrl.js | 88 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 73 insertions(+), 15 deletions(-) (limited to 'www') diff --git a/www/js/MontageHistoryCtrl.js b/www/js/MontageHistoryCtrl.js index 33e099fe..62d41af0 100644 --- a/www/js/MontageHistoryCtrl.js +++ b/www/js/MontageHistoryCtrl.js @@ -3,7 +3,7 @@ /* jslint browser: true*/ /* global cordova,StatusBar,angular,console,ionic,Masonry,moment,Packery, Draggabilly, imagesLoaded, Chart */ // FIXME: This is a copy of montageCtrl - needs a lot of code cleanup -angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$scope', '$rootScope', 'NVRDataModel', 'message', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$ionicPopup', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$ionicPlatform', 'zm', '$ionicPopover', '$controller', 'imageLoadingDataShare', '$window', '$translate', 'qHttp', function ($scope, $rootScope, NVRDataModel, message, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $ionicPopup, $stateParams, $ionicHistory, $ionicScrollDelegate, $ionicPlatform, zm, $ionicPopover, $controller, imageLoadingDataShare, $window, $translate, qHttp) { +angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$scope', '$rootScope', 'NVRDataModel', 'message', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$ionicPopup', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$ionicPlatform', 'zm', '$ionicPopover', '$controller', 'imageLoadingDataShare', '$window', '$translate', 'qHttp', '$q', function ($scope, $rootScope, NVRDataModel, message, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $ionicPopup, $stateParams, $ionicHistory, $ionicScrollDelegate, $ionicPlatform, zm, $ionicPopover, $controller, imageLoadingDataShare, $window, $translate, qHttp, $q) { //-------------------------------------------------------------------------------------- // Handles bandwidth change, if required // @@ -53,7 +53,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc //-------------------------------------- // pause/unpause nph-zms //--------------------------------------- - $scope.togglePause = function (mid) { + $scope.monitorPause = function (mid) { //console.log ("TOGGLE PAUSE " + mid); var m = -1; for (var i = 0; i < $scope.MontageMonitors.length; i++) { @@ -63,14 +63,17 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc } } if (m != -1) { - $scope.MontageMonitors[m].Monitor.isPaused = !$scope.MontageMonitors[m].Monitor.isPaused; - var cmd = $scope.MontageMonitors[m].Monitor.isPaused ? 1 : 2; + $scope.MontageMonitors[m].Monitor.isPaused = true; + var cmd = 1; NVRDataModel.debug("Sending CMD:" + cmd + " for monitor " + $scope.MontageMonitors[m].Monitor.Name); controlEventStream(cmd, "", $scope.MontageMonitors[m].Monitor.connKey, -1); } }; function sendCmd(mid, cmd, extra) { + + + var m = -1; for (var i = 0; i < $scope.MontageMonitors.length; i++) { if ($scope.MontageMonitors[i].Monitor.Id == mid) { @@ -80,12 +83,38 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc } if (m != -1) { NVRDataModel.debug("Sending CMD:" + cmd + " for monitor " + $scope.MontageMonitors[m].Monitor.Name); - controlEventStream(cmd, "", $scope.MontageMonitors[m].Monitor.connKey, -1, extra); + return controlEventStream(cmd, "", $scope.MontageMonitors[m].Monitor.connKey, -1, extra); } + } $scope.seek = function (mid, p) { console.log("SLIDER CALLED WITH MID=" + mid + " progress=" + p); - sendCmd(mid, '14', "&offset=" + p); + + var m = -1; + for (var i = 0; i < $scope.MontageMonitors.length; i++) { + if ($scope.MontageMonitors[i].Monitor.Id == mid) { + m = i; + break; + } + } + if (m!= -1) + { + $scope.MontageMonitors[i].Monitor.seek = true; + } + + sendCmd(mid, '14', "&offset=" + p) + .then (function(success) + { + console.log ("Removing seek status from " + $scope.MontageMonitors[i].Monitor.Name); + $scope.MontageMonitors[i].Monitor.seek = false; + + }, + function (err) + { + console.log ("Removing seek status from " + $scope.MontageMonitors[i].Monitor.Name); + $scope.MontageMonitors[i].Monitor.seek = false; + }); + }; $scope.moveFaster = function (mid) { sendCmd(mid, 4); @@ -94,7 +123,20 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc sendCmd(mid, 5); }; $scope.movePlay = function (mid) { - sendCmd(mid, 2); + + var m = -1; + for (var i = 0; i < $scope.MontageMonitors.length; i++) { + if ($scope.MontageMonitors[i].Monitor.Id == mid) { + m = i; + break; + } + } + if (m != -1) { + $scope.MontageMonitors[m].Monitor.isPaused = false; + var cmd = 2; + NVRDataModel.debug("Sending CMD:" + cmd + " for monitor " + $scope.MontageMonitors[m].Monitor.Name); + controlEventStream(cmd, "", $scope.MontageMonitors[m].Monitor.connKey, -1); + } }; //-------------------------------------- // Called when ion-footer collapses @@ -115,7 +157,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc } $scope.dragBorder = ""; $scope.isDragabillyOn = false; - $ionicSideMenuDelegate.canDragContent(true); + $ionicSideMenuDelegate.canDragContent(false); NVRDataModel.stopNetwork("MontageHistory-footerCollapse"); var ld = NVRDataModel.getLogin(); $scope.sliderVal.realRate = $scope.sliderVal.rate * 100; @@ -217,7 +259,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc function getExpandedEvents(i, indivGrab) { var ld = NVRDataModel.getLogin(); - // console.log ("EXPANDED EVENT " + i + " " + indivGrab); + console.log ("Expanded API: " + indivGrab); qHttp({ method: 'get', url: indivGrab @@ -319,6 +361,8 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc function controlEventStream(cmd, disp, connkey, ndx, extras) { // console.log("Command value " + cmd); + + var d = $q.defer(); if (disp) { $ionicLoading.hide(); $ionicLoading.show({ @@ -384,9 +428,17 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc console.log ("zms response: " + JSON.stringify(resp)); // move progress bar if event id is the same - if (resp.result == "Ok" && ndx != -1 && (resp.status.event == $scope.MontageMonitors[ndx].Monitor.eid)) - $scope.MontageMonitors[ndx].Monitor.sliderProgress.progress = resp.status.progress; - + if (resp.result == "Ok" && ndx != -1 && (resp.status.event == $scope.MontageMonitors[ndx].Monitor.eid)) + { + if (!$scope.MontageMonitors[ndx].Monitor.seek) + { + $scope.MontageMonitors[ndx].Monitor.sliderProgress.progress = resp.status.progress; + } + else + { + NVRDataModel.debug ("Skipping progress as seek is active for " + $scope.MontageMonitors[ndx].Monitor.Name); + } + } if (resp.result == "Ok" && ndx != -1 && ((resp.status.event != $scope.MontageMonitors[ndx].Monitor.eid) || $scope.MontageMonitors[ndx].Monitor.noGraph == true)) { $scope.MontageMonitors[ndx].Monitor.noGraph = false; @@ -449,9 +501,14 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc $scope.MontageMonitors[ndx].Monitor.eventUrlTime = "-"; }); } + d.resolve(true); + return d.promise; }, function (err) { + d.reject(false); NVRDataModel.log("Error sending event command " + JSON.stringify(err), "error"); + return d.promise; }); + return d.promise; } $scope.isBackground = function () { return NVRDataModel.isBackground(); @@ -785,7 +842,8 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc // if (layouttype) $timeout (function(){layout(pckry);},100); }); imagesLoaded(elem).once('always', function () { - console.log("******** ALL IMAGES LOADED"); + //console.log("******** ALL IMAGES LOADED"); + $scope.$digest(); NVRDataModel.debug("All images loaded"); $ionicLoading.hide(); @@ -863,7 +921,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc // I am making sure the image in montage view is always fresh // I don't think I am using this anymore FIXME: check and delete if needed // $rootScope.rand = Math.floor((Math.random() * 100000) + 1); - $scope.showControls = false; + $scope.showControls = true; readyToRun = false; $timeout(function () { @@ -1077,7 +1135,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc }, 1000); $scope.isRefresh = $stateParams.isRefresh; var sizeInProgress = false; - $ionicSideMenuDelegate.canDragContent(true); + $ionicSideMenuDelegate.canDragContent(false); $scope.LoginData = NVRDataModel.getLogin(); $scope.monLimit = $scope.LoginData.maxMontage; $scope.currentLimit = $scope.LoginData.maxMontage; -- cgit v1.2.3 From 64730278cbe692eeef3c88443245eec8741b5ab3 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Tue, 11 Oct 2016 16:16:50 -0400 Subject: mostly formatting Former-commit-id: ba14b8f316a4897d912591a9606c80db554f2db6 --- www/templates/montage-history.html | 239 +++++++++++++++++++------------------ 1 file changed, 124 insertions(+), 115 deletions(-) (limited to 'www') diff --git a/www/templates/montage-history.html b/www/templates/montage-history.html index 98426dc1..25eb9aa6 100644 --- a/www/templates/montage-history.html +++ b/www/templates/montage-history.html @@ -1,25 +1,25 @@ - - - - - - - - - - - - - - -
{{'kFrom' | translate}}:{{prettifyDateTimeFirst(datetimeValueFrom.value)}} ({{humanizeTime(datetimeValueFrom.value)}}) -
({{'kChromeMax' | translate}})
-
-
-
- - + + + + + + + + + + + + + + +
{{'kFrom' | translate}}:{{prettifyDateTimeFirst(datetimeValueFrom.value)}} ({{humanizeTime(datetimeValueFrom.value)}}) +
({{'kChromeMax' | translate}})
+
+
+
+ +
- {{'kNoMonitors' | translate }} - -
{{ 'kLowBWDisplay' | translate }}
-
- - + --> + +
+
+ +
+
+
+ +
+ +
+ +
+ {{'kNoMonitors' | translate }} + +
{{ 'kLowBWDisplay' | translate }}
+
+ + -
- - - - - -

{{'kEventMontage' | translate}}

-
- -
- - -
{{'kTimeline' | translate}}
-
{{'kEventHistShowFrom'|translate}}:  +
+ + + + + +

{{'kEventMontage' | translate}}

+
+ +
+ +
{{'kTimeline' | translate}}
+ + +
{{'kFrom'|translate}}:  +
+
+ +
+
+  {{'kEventHistHrs' | translate}} +
+
-  {{'kEventHistHrs' | translate}} -
- -
- {{'kFrom' | translate }}: {{datetimeValueFrom.value | date: timeFormat}} -
({{humanizeTime(datetimeValueFrom.value)}}) -
-
-
-
-
- -
-
-
-
{{'kSpeed' | translate }}
-
- -
-
-
- \ No newline at end of file +
+
+
+ \ No newline at end of file -- cgit v1.2.3 From 7cb5b070f032b5de9f017f2f074a14f90da75c45 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Tue, 11 Oct 2016 16:17:00 -0400 Subject: keys Former-commit-id: 8db6fc5947dc87dd76ee8ddf17a1bb807f64c67b --- www/lang/locale-en.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'www') diff --git a/www/lang/locale-en.json b/www/lang/locale-en.json index 156756d7..fe43f7b2 100644 --- a/www/lang/locale-en.json +++ b/www/lang/locale-en.json @@ -360,6 +360,7 @@ "kEventHistHrs" :"hours ago", "kEventHistSlower" : "slower", "kEventHistFaster" : "faster", - "kEventHistPlay" : "play" + "kEventHistPlay" : "play", + "kEventHistPause" : "pause" } -- cgit v1.2.3 From 9d22cfa117ea0e50ffaef4330d899c27aa59349f Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Wed, 12 Oct 2016 10:44:46 -0400 Subject: adjusted heights for android and ios Former-commit-id: 4e0b91761388501c5fb88c332712f6917d827961 --- www/external/ion-pullup.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'www') diff --git a/www/external/ion-pullup.js b/www/external/ion-pullup.js index 798d25ee..ae9109a8 100755 --- a/www/external/ion-pullup.js +++ b/www/external/ion-pullup.js @@ -43,12 +43,20 @@ angular.module('ionic-pullup', []) tabs = document.querySelector('.tabs'); hasBottomTabs = document.querySelector('.tabs-bottom'); header = document.querySelector('.bar-header'); - tabsHeight = tabs ? tabs.offsetHeight : 80; - headerHeight = header ? header.offsetHeight : 80; + tabsHeight = tabs ? tabs.offsetHeight : 0; + headerHeight = header ? header.offsetHeight : 0; + + /*if ($rootScope.platformOS == 'ios') + { + tabsHeight +=40; + headerHeight +=40; + }*/ } function computeHeights() { footer.height = footer.maxHeight > 0 ? footer.maxHeight : $window.innerHeight - headerHeight - handleHeight - tabsHeight; + if ($rootScope.platformOS == 'ios') footer.height -=60; + if ($rootScope.platformOS == 'android') footer.height -=40; $element.css({'height': footer.height + 'px'}); if (footer.initialState == FooterState.MINIMIZED) { @@ -69,6 +77,8 @@ angular.module('ionic-pullup', []) function recomputeAllHeights() { computeDefaultHeights(); footer.height = footer.maxHeight > 0 ? footer.maxHeight : $window.innerHeight - headerHeight - handleHeight - tabsHeight; + if ($rootScope.platformOS == 'ios') footer.height -=60; + if ($rootScope.platformOS == 'android') footer.height -=40; } function expand() { -- cgit v1.2.3 From ce9a725349b08cb469e7345372f484d4bf19039c Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Wed, 12 Oct 2016 10:45:27 -0400 Subject: temporarily disabled #337 - causing iOS issues. Former-commit-id: b65b4150679063108a92b653e58e1669e1a50cc8 --- www/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'www') diff --git a/www/index.html b/www/index.html index 35c4405b..a6a9ae8f 100644 --- a/www/index.html +++ b/www/index.html @@ -141,7 +141,7 @@ - + @@ -261,7 +261,7 @@ - + -- cgit v1.2.3 From 7fd694672eb6049b9622c4fc779e4e264af43d49 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Wed, 12 Oct 2016 10:45:43 -0400 Subject: removed http queing for collapse Former-commit-id: 127c21ab90a6a51cb36187b244732b2decb9f9f1 --- www/js/MontageHistoryCtrl.js | 68 +++++++++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 19 deletions(-) (limited to 'www') diff --git a/www/js/MontageHistoryCtrl.js b/www/js/MontageHistoryCtrl.js index 62d41af0..3800157a 100644 --- a/www/js/MontageHistoryCtrl.js +++ b/www/js/MontageHistoryCtrl.js @@ -53,7 +53,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc //-------------------------------------- // pause/unpause nph-zms //--------------------------------------- - $scope.monitorPause = function (mid) { + $scope.togglePause = function (mid) { //console.log ("TOGGLE PAUSE " + mid); var m = -1; for (var i = 0; i < $scope.MontageMonitors.length; i++) { @@ -63,7 +63,8 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc } } if (m != -1) { - $scope.MontageMonitors[m].Monitor.isPaused = true; + + $scope.MontageMonitors[m].Monitor.isPaused = !$scope.MontageMonitors[m].Monitor.isPaused; var cmd = 1; NVRDataModel.debug("Sending CMD:" + cmd + " for monitor " + $scope.MontageMonitors[m].Monitor.Name); controlEventStream(cmd, "", $scope.MontageMonitors[m].Monitor.connKey, -1); @@ -155,6 +156,14 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc NVRDataModel.debug("fake call to footerCollapse - ignoring"); return; } + + $interval.cancel($rootScope.eventQueryInterval); + $ionicLoading.show({ + template: $translate.instant('kPleaseWait'), + noBackdrop: true, + duration: zm.httpTimeout + }); + $scope.dragBorder = ""; $scope.isDragabillyOn = false; $ionicSideMenuDelegate.canDragContent(false); @@ -174,8 +183,9 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc // this means this mid was showing a message, now we need to change it // so kill prev. stream first NVRDataModel.log("footerCollapse: Calling kill with " + $scope.MontageMonitors[i].Monitor.connKey + " for Monitor:" + $scope.MontageMonitors[i].Monitor.Name); - var tmpCK = angular.copy($scope.MontageMonitors[i].Monitor.connKey); - timedControlEventStream(2500, 17, "", tmpCK, -1); + //var tmpCK = angular.copy($scope.MontageMonitors[i].Monitor.connKey); + //timedControlEventStream(2500, 17, "", tmpCK, -1); + controlEventStream(17, "", $scope.MontageMonitors[i].Monitor.connKey, -1); $scope.MontageMonitors[i].Monitor.eventUrl = "img/noevent.png"; $scope.MontageMonitors[i].Monitor.eid = "-1"; $scope.MontageMonitors[i].Monitor.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); @@ -189,7 +199,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc // make sure there are no more than 5 active streams (noevent is ok) $scope.currentLimit = $scope.monLimit; //qHttp.get(apiurl) - qHttp({ + $http({ method: 'get', url: apiurl }).then(function (succ) { @@ -231,36 +241,50 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc // make sure we do our best to get that duration for all monitors // in the above call, is possible some did not make the cut in the first page NVRDataModel.log("Making sure all monitors have a fair chance..."); + var promises = []; for (i = 0; i < $scope.MontageMonitors.length; i++) { console.log("Fair chance check for " + $scope.MontageMonitors[i].Monitor.Name); if ($scope.MontageMonitors[i].Monitor.eventUrl == 'img/noevent.png') { var indivGrab = ld.apiurl + "/events/index/MonitorId:" + $scope.MontageMonitors[i].Monitor.Id + "/StartTime >=:" + TimeObjectFrom + "/AlarmFrames >=:" + (ld.enableAlarmCount ? ld.minAlarmCount : 0) + ".json"; NVRDataModel.debug("Monitor " + $scope.MontageMonitors[i].Monitor.Id + ":" + $scope.MontageMonitors[i].Monitor.Name + " does not have events, trying " + indivGrab); - getExpandedEvents(i, indivGrab); + var p = getExpandedEvents(i, indivGrab); + promises.push(p); + } + } + $q.all(promises).then( doPackery ); // At this stage, we have both a general events grab, and specific event grabs for MIDS that were empty - console.log("REDOING PACKERY & DRAG"); - if (pckry !== undefined) { - // remove current draggies - draggies.forEach(function (drag) { - drag.destroy(); - }); - draggies = []; - // destroy existing packery object - pckry.destroy(); - initPackery(); + function doPackery() + { + // $ionicLoading.hide(); + console.log("REDOING PACKERY & DRAG"); + if (pckry !== undefined) { + // remove current draggies + draggies.forEach(function (drag) { + drag.destroy(); + }); + draggies = []; + // destroy existing packery object + pckry.destroy(); + initPackery(); + + $rootScope.eventQueryInterval = $interval(function () { + checkAllEvents(); + }.bind(this), zm.eventHistoryTimer); + } } }, function (err) { NVRDataModel.debug("history ERROR:" + JSON.stringify(err)); }); function getExpandedEvents(i, indivGrab) { + var d = $q.defer(); var ld = NVRDataModel.getLogin(); console.log ("Expanded API: " + indivGrab); - qHttp({ + $http({ method: 'get', url: indivGrab }).then(function (succ) { @@ -286,7 +310,13 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc // NVRDataModel.log ("Setting img src to null as data received in background"); } } - }); + d.resolve(true); + return d.promise; + }, + function (err) { d.resolve(true);return d.promise; } + + ); + return d.promise; } } //--------------------------------------------------------- @@ -478,7 +508,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc } $timeout(function () { drawGraph(framearray, $scope.MontageMonitors[ndx].Monitor.Id); - }, 500); + }, 100); var element = angular.element(document.getElementById($scope.MontageMonitors[ndx].Monitor.Id + "-timeline")); element.removeClass('animated flipInX'); element.addClass('animated flipOutX'); -- cgit v1.2.3 From 77670b3180515076ba19febd0cdff4d7ecb4da69 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Wed, 12 Oct 2016 10:45:56 -0400 Subject: removed pause button - causing layout issues on small montages Former-commit-id: 3a2e9eca4f0fad298022e3a583b64dc955e8fc57 --- www/templates/montage-history.html | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'www') diff --git a/www/templates/montage-history.html b/www/templates/montage-history.html index 25eb9aa6..ff7ab175 100644 --- a/www/templates/montage-history.html +++ b/www/templates/montage-history.html @@ -41,7 +41,7 @@
@@ -94,6 +81,9 @@
+ + +
{{'kNoMonitors' | translate }} -- cgit v1.2.3