-
-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c58199d
commit 554a5e6
Showing
4 changed files
with
335 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,239 @@ | ||
// Common Controller for the montage view | ||
/* jshint -W041 */ | ||
/* jslint browser: true*/ | ||
/* global saveAs, cordova,StatusBar,angular,console,ionic, moment */ | ||
|
||
|
||
|
||
|
||
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) { | ||
|
||
|
||
//---------------------------------------------------------------- | ||
// Alarm notification handling | ||
//---------------------------------------------------------------- | ||
$scope.handleAlarms = function () { | ||
$rootScope.isAlarm = !$rootScope.isAlarm; | ||
if (!$rootScope.isAlarm) { | ||
$rootScope.alarmCount = "0"; | ||
$ionicHistory.nextViewOptions({ | ||
disableBack: true | ||
}); | ||
$state.go("events", { | ||
"id": 0 | ||
}, { | ||
reload: true | ||
}); | ||
} | ||
}; | ||
|
||
|
||
|
||
//------------------------------------------------------- | ||
// we use this to reload the connkey if authkey changed | ||
//------------------------------------------------------ | ||
|
||
|
||
$rootScope.$on("auth-success", function () { | ||
|
||
ZMDataModel.zmDebug("EventModalCtrl: Re-login detected, resetting everything & re-generating connkey"); | ||
|
||
|
||
}); | ||
|
||
|
||
|
||
$scope.$on('modal.removed', function () { | ||
|
||
|
||
// Execute action | ||
}); | ||
|
||
$scope.$on('modal.shown', function () { | ||
|
||
$scope.dataReady = false; | ||
|
||
$scope.eventdetails = "loading..."; | ||
processEvent(); | ||
//$scope.eventdetails = JSON.stringify($scope.event); | ||
}); | ||
|
||
|
||
function processEvent() | ||
{ | ||
var eid = $scope.event.Event.Id; | ||
var ld = ZMDataModel.getLogin(); | ||
var apiurl = ld.apiurl + "/events/"+eid+".json"; | ||
ZMDataModel.zmLog ("Getting " + apiurl); | ||
$http.get (apiurl) | ||
.then (function (success) | ||
{ | ||
$scope.eventdetails = JSON.stringify(success); | ||
drawGraph(success); | ||
}, | ||
function (error) | ||
{ | ||
$scope.eventdetails = JSON.stringify(error); | ||
}); | ||
} | ||
|
||
|
||
function drawGraph(event) | ||
{ | ||
// Chart.js Data | ||
$scope.data = { | ||
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], | ||
datasets: [ | ||
{ | ||
label: 'My First dataset', | ||
fillColor: 'rgba(220,220,220,0.2)', | ||
strokeColor: 'rgba(220,220,220,1)', | ||
pointColor: 'rgba(220,220,220,1)', | ||
pointStrokeColor: '#fff', | ||
pointHighlightFill: '#fff', | ||
pointHighlightStroke: 'rgba(220,220,220,1)', | ||
data: [65, 59, 80, 81, 56, 55, 40] | ||
}, | ||
{ | ||
label: 'My Second dataset', | ||
fillColor: 'rgba(151,187,205,0.2)', | ||
strokeColor: 'rgba(151,187,205,1)', | ||
pointColor: 'rgba(151,187,205,1)', | ||
pointStrokeColor: '#fff', | ||
pointHighlightFill: '#fff', | ||
pointHighlightStroke: 'rgba(151,187,205,1)', | ||
data: [28, 48, 40, 19, 86, 27, 90] | ||
} | ||
] | ||
}; | ||
|
||
// Chart.js Options | ||
$scope.options = { | ||
|
||
// Sets the chart to be responsive | ||
responsive: true, | ||
|
||
///Boolean - Whether grid lines are shown across the chart | ||
scaleShowGridLines : true, | ||
|
||
//String - Colour of the grid lines | ||
scaleGridLineColor : "rgba(0,0,0,.05)", | ||
|
||
//Number - Width of the grid lines | ||
scaleGridLineWidth : 1, | ||
|
||
//Boolean - Whether the line is curved between points | ||
bezierCurve : true, | ||
|
||
//Number - Tension of the bezier curve between points | ||
bezierCurveTension : 0.4, | ||
|
||
//Boolean - Whether to show a dot for each point | ||
pointDot : true, | ||
|
||
//Number - Radius of each point dot in pixels | ||
pointDotRadius : 4, | ||
|
||
//Number - Pixel width of point dot stroke | ||
pointDotStrokeWidth : 1, | ||
|
||
//Number - amount extra to add to the radius to cater for hit detection outside the drawn point | ||
pointHitDetectionRadius : 20, | ||
|
||
//Boolean - Whether to show a stroke for datasets | ||
datasetStroke : true, | ||
|
||
//Number - Pixel width of dataset stroke | ||
datasetStrokeWidth : 2, | ||
|
||
//Boolean - Whether to fill the dataset with a colour | ||
datasetFill : true, | ||
|
||
// Function - on animation progress | ||
onAnimationProgress: function(){}, | ||
|
||
// Function - on animation complete | ||
onAnimationComplete: function(){}, | ||
|
||
//String - A legend template | ||
legendTemplate : '<ul class="tc-chart-js-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].strokeColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>' | ||
}; | ||
$scope.json_data = JSON.stringify($scope.data); | ||
$scope.dataReady = true; | ||
|
||
} | ||
|
||
//-------------------------------------------------------- | ||
// utility function | ||
//-------------------------------------------------------- | ||
|
||
function computeRelativePath(event) { | ||
var relativePath = ""; | ||
var loginData = ZMDataModel.getLogin(); | ||
var str = event.Event.StartTime; | ||
var yy = moment(str).format('YY'); | ||
var mm = moment(str).format('MM'); | ||
var dd = moment(str).format('DD'); | ||
var hh = moment(str).format('HH'); | ||
var min = moment(str).format('mm'); | ||
var sec = moment(str).format('ss'); | ||
relativePath = event.Event.MonitorId + "/" + | ||
yy + "/" + | ||
mm + "/" + | ||
dd + "/" + | ||
hh + "/" + | ||
min + "/" + | ||
sec + "/"; | ||
return relativePath; | ||
|
||
} | ||
|
||
//-------------------------------------------------------- | ||
// utility function | ||
//-------------------------------------------------------- | ||
|
||
function computeBasePath(event) { | ||
var basePath = ""; | ||
var loginData = ZMDataModel.getLogin(); | ||
var str = event.Event.StartTime; | ||
var yy = moment(str).format('YY'); | ||
var mm = moment(str).format('MM'); | ||
var dd = moment(str).format('DD'); | ||
var hh = moment(str).format('HH'); | ||
var min = moment(str).format('mm'); | ||
var sec = moment(str).format('ss'); | ||
|
||
basePath = loginData.url + "/events/" + | ||
event.Event.MonitorId + "/" + | ||
yy + "/" + | ||
mm + "/" + | ||
dd + "/" + | ||
hh + "/" + | ||
min + "/" + | ||
sec + "/"; | ||
return basePath; | ||
} | ||
|
||
|
||
|
||
function padToN(number, digits) { | ||
|
||
var i; | ||
var stringMax = ""; | ||
var stringLeading = ""; | ||
for (i = 1; i <= digits; i++) { | ||
stringMax = stringMax + "9"; | ||
if (i != digits) stringLeading = stringLeading + "0"; | ||
} | ||
var numMax = parseInt(stringMax); | ||
|
||
if (number <= numMax) { | ||
number = (stringLeading + number).slice(-digits); | ||
} | ||
//console.log ("PADTON: returning " + number); | ||
return number; | ||
} | ||
|
||
|
||
|
||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<div ng-controller="TimelineModalCtrl"> | ||
<!-- style="width: 90%; height: 90%; top: 5%; left: 5%; right: 5%; bottom: 5%;"--> | ||
<ion-modal-view cache-view="false"> | ||
<ion-content ng-cloak on-double-tap="closeModal()"> | ||
<div ng-if="dataReady"> | ||
<canvas tc-chartjs-line chart-options="options" chart-data="data" auto-legend></canvas> | ||
{{json_data}} | ||
</div> | ||
<div ng-if = "!dataReady"> | ||
Waiting for data... | ||
</div> | ||
</ion-content> | ||
|
||
</ion-modal-view> | ||
|
||
|
||
|
||
</div> |