From 231021cd811fa322a3377987a6db7f5b943d5378 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Tue, 8 Nov 2016 05:50:01 -0500 Subject: [PATCH] added initial code for scale saving, but commented out - doesn't work well - it zooms in, but need to think on zoom into what timespan. Need to think about it more. Will do it later. #361 --- www/js/DataModel.js | 10 +++++++- www/js/TimelineCtrl.js | 53 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/www/js/DataModel.js b/www/js/DataModel.js index 47e27c272..01b9ce8a9 100644 --- a/www/js/DataModel.js +++ b/www/js/DataModel.js @@ -120,7 +120,8 @@ angular.module('zmApp.controllers') 'disableAlarmCheckMontage': false, 'useLocalTimeZone': true, 'fastLogin': true, - 'followTimeLine': false + 'followTimeLine': false, + 'timelineScale': -1, @@ -828,6 +829,13 @@ angular.module('zmApp.controllers') } + if (typeof loginData.timelineScale == 'undefined') { + + loginData.timelineScale = -1; + + } + + if (typeof loginData.monSingleImageQuality == 'undefined') { diff --git a/www/js/TimelineCtrl.js b/www/js/TimelineCtrl.js index 9a4645c78..f23868338 100644 --- a/www/js/TimelineCtrl.js +++ b/www/js/TimelineCtrl.js @@ -1092,7 +1092,37 @@ angular.module('zmApp.controllers').controller('zmApp.TimelineCtrl', ['$ionicPla // console.log ("GROUPS"); timeline.setGroups(groups); - timeline.fit(); + if (NVRDataModel.getLogin().timelineScale == -1) + + { + // console.log ("SCALE NOT FOUND"); + + timeline.fit(); + } + else + { + timeline.fit(); + + /*var d = NVRDataModel.getLogin().timelineScale; + console.log ("SCALE FOUND "+d+" SECONDS"); + var w = timeline.getWindow(); + console.log ("Original s="+w.start+" e="+w.end); + + + var s = moment.tz(w.end, NVRDataModel.getTimeZoneNow()).subtract(d,'seconds').tz(moment.tz.guess()); + + //var s = moment(w.start).format("YYYY-MM-DD HH:mm:ss"); + // + //var e = moment(w.start).add(d,'seconds').format("YYYY-MM-DD HH:mm:ss"); + + var e = moment.tz(w.end, NVRDataModel.getTimeZoneNow()).tz(moment.tz.guess()); + + console.log ("Start="+s+" End="+e); + $timeout (function() {timeline.setWindow(s,e);},1000);*/ + + + } + lastTimeForEvent = moment(); updateInterval = $interval(function() { @@ -1120,6 +1150,27 @@ angular.module('zmApp.controllers').controller('zmApp.TimelineCtrl', ['$ionicPla });*/ + timeline.on('rangechanged', function(s) + { + ///console.log ("Range Changed:"+JSON.stringify(s)); + if (s.byUser) + { + + var w = timeline.getWindow(); + //console.log ("start:"+w.start+" end:"+w.end); + var a = moment(w.start); + var b = moment(w.end); + var d = b.diff(a,'seconds'); + var ld = NVRDataModel.getLogin(); + ld.timelineScale = d; + NVRDataModel.setLogin(ld); + //console.log ("Stored user scale of "+d+" seconds"); + } + + + + }); + timeline.on('click', function(prop) {