diff options
| author | pliablepixels <pliablepixels@gmail.com> | 2016-03-26 14:28:08 -0400 |
|---|---|---|
| committer | pliablepixels <pliablepixels@gmail.com> | 2016-03-26 14:28:08 -0400 |
| commit | b7ecc30ef6a7781e6681accdabfe63cea7a9e9a2 (patch) | |
| tree | bd407d6c7224d61c7372dabe449e019ffac8a02d /www/js/TimelineModalCtrl.js | |
| parent | 277899e84b1c68ededdfb6676898643c43f7fa88 (diff) | |
#209 - more fixes
Former-commit-id: ae01def03cfa6198c0a1515590596d3b847964a4
Diffstat (limited to 'www/js/TimelineModalCtrl.js')
| -rw-r--r-- | www/js/TimelineModalCtrl.js | 102 |
1 files changed, 61 insertions, 41 deletions
diff --git a/www/js/TimelineModalCtrl.js b/www/js/TimelineModalCtrl.js index 6bde9672..d127cbca 100644 --- a/www/js/TimelineModalCtrl.js +++ b/www/js/TimelineModalCtrl.js @@ -6,13 +6,14 @@ -angular.module('zmApp.controllers').controller('TimelineModalCtrl', ['$scope', '$rootScope', 'zm', 'ZMDataModel', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$q', '$sce', 'carouselUtils', '$ionicPopup', 'Hello', function ($scope, $rootScope, zm, ZMDataModel, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $q, $sce, carouselUtils, $ionicPopup,Hello) { +angular.module('zmApp.controllers').controller('TimelineModalCtrl', ['$scope', '$rootScope', 'zm', 'ZMDataModel', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$q', '$sce', 'carouselUtils', '$ionicPopup', function ($scope, $rootScope, zm, ZMDataModel, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $q, $sce, carouselUtils, $ionicPopup) { var Graph2d; var eventImageDigits=5; + $scope.errorDetails=""; //---------------------------------------------------------------- // Alarm notification handling //---------------------------------------------------------------- @@ -46,6 +47,10 @@ angular.module('zmApp.controllers').controller('TimelineModalCtrl', ['$scope', ' }); + //------------------------------------------------------- + // Tapping on a frame shows this image + //------------------------------------------------------ + $scope.showImage = function (p,r,f, fid) { var img = "<img width='100%' ng-src='"+p+"/index.php?view=image&path="+r+f+"'>"; @@ -59,6 +64,10 @@ angular.module('zmApp.controllers').controller('TimelineModalCtrl', ['$scope', ' // Execute action }); + //------------------------------------------------------- + // init drawing here + //------------------------------------------------------ + $scope.$on('modal.shown', function () { $scope.dataReady = false; @@ -76,6 +85,10 @@ angular.module('zmApp.controllers').controller('TimelineModalCtrl', ['$scope', ' }); + //------------------------------------------------------- + // okay, really init drawing here + //------------------------------------------------------ + function processEvent() { var eid = $scope.event.Event.Id; @@ -85,16 +98,22 @@ angular.module('zmApp.controllers').controller('TimelineModalCtrl', ['$scope', ' $http.get (apiurl) .then (function (success) { - $scope.eventdetails = JSON.stringify(success); + //$scope.eventdetails = JSON.stringify(success); drawGraph(success.data); }, function (error) { - $scope.eventdetails = JSON.stringify(error); + $scope.errorDetails = "there was an error rendering the graph. Please see logs"; + ZMDataModel.zmLog ("Error in timeline frames " + JSON.stringify(error)); }); } + //------------------------------------------------------- + // I was kidding, this is where it really is drawn + // scout's promise + //------------------------------------------------------ + function drawGraph(event) { console.log ("EVENT IS " + JSON.stringify(event)); @@ -121,33 +140,38 @@ angular.module('zmApp.controllers').controller('TimelineModalCtrl', ['$scope', ' var dataset = new vis.DataSet(items); - var options = { - autoResize:true, - height: Math.floor($rootScope.devHeight/2), - - style:'bar', - start: event.event.Frame[0].TimeStamp, - end: event.event.Frame[event.event.Frame.length-1].TimeStamp, - max: event.event.Frame[event.event.Frame.length-1].TimeStamp, - min: event.event.Frame[0].TimeStamp, - - barChart: - { - width: 50, - sideBySide:false, - align:'center' - }, - dataAxis: - { - left: {title: {text:'score'}}, - } - }; + var options = { + autoResize:true, + height: Math.floor($rootScope.devHeight/2), + //clickToUse:true, + + style:'bar', + start: event.event.Frame[0].TimeStamp, + end: event.event.Frame[event.event.Frame.length-1].TimeStamp, + max: event.event.Frame[event.event.Frame.length-1].TimeStamp, + min: event.event.Frame[0].TimeStamp, + + barChart: + { + width: 50, + sideBySide:false, + align:'center' + }, + dataAxis: + { + left: {title: {text:'score'}}, + } + }; var container = document.getElementById('timeline-alarm-vis'); Graph2d = new vis.Graph2d(container, dataset, groups, options); $scope.dataReady = true; - $scope.alarm_data = Hello.get(); + + //------------------------------------------------------- + // When you tap on a data node + //------------------------------------------------------ + Graph2d.on('click',function (prop) { $timeout( function() { @@ -155,22 +179,27 @@ angular.module('zmApp.controllers').controller('TimelineModalCtrl', ['$scope', ' $scope.playbackURL = ZMDataModel.getLogin().url; var t = moment(prop.time); - //console.log ("x="+prop.x); - // console.log ("val="+JSON.stringify(prop.value)); + console.log ("date="+t.format("YYYY-MM-DD HH:mm:ss")); var tformat = t.format ("YYYY-MM-DD HH:mm:ss"); - //console.log ("event="+JSON.stringify(prop.event)); + for (var i=0; i<items.length; i++) { if (items[i].x == tformat) { - //console.log ("ITEM " + i + " matches, relative path=" + items[i].relativePath); - $scope.alarm_images.push({relativePath:items[i].relativePath, fid:items[i].fid, fname:items[i].fname, score:items[i].score, eid:items[i].eid}); + + $scope.alarm_images.push({ + relativePath:items[i].relativePath, + fid:items[i].fid, + fname:items[i].fname, + score:items[i].score, + time:moment(items[i].x).format("MMM D,"+ZMDataModel.getTimeFormat()), + eid:items[i].eid}); } } - //console.log ("I PUSHED " + $scope.alarm_images.length); + }); }); @@ -252,13 +281,4 @@ angular.module('zmApp.controllers').controller('TimelineModalCtrl', ['$scope', ' }]); -angular.module('zmApp.controllers') -.factory('Hello', function() -{ - var data = 12; - return { - 'set': function(val) {data=val;}, - 'get': function() {return data;} - }; - -}); + |
