From 3df8d24e33ce48af2ae15f62491616eb9a0d8cc5 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Tue, 4 Dec 2018 05:31:56 +0100 Subject: [PATCH] dashboard: rename CountdownController to TimerController --- dashboard/static/index.html | 2 +- dashboard/static/js/dashboard.js | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/dashboard/static/index.html b/dashboard/static/index.html index f1010d7a..f22244cb 100644 --- a/dashboard/static/index.html +++ b/dashboard/static/index.html @@ -46,7 +46,7 @@

-
+
{{ duration / 60 | time }} : {{ duration % 60 | time }}
{{ s.params.lead }}
diff --git a/dashboard/static/js/dashboard.js b/dashboard/static/js/dashboard.js index bce24bcd..7f3dcaf3 100644 --- a/dashboard/static/js/dashboard.js +++ b/dashboard/static/js/dashboard.js @@ -118,16 +118,22 @@ angular.module("FICApp") refreshEvents() $interval(refreshEvents, 2100); }) - .controller("CountdownController", function($scope, $interval) { + .controller("TimerController", function($scope, $rootScope, $interval) { $scope.duration = 0; $scope.init = function(end) { - $scope.initT(Date.parse(end)/1000); + $scope.initT(Date.parse(end)); + } + $scope.initStart = function() { + $scope.$watch("settings", function(settings){ + if (settings) + $scope.initT(settings.start); + }) } $scope.initT = function(end) { var time = angular.fromJson(sessionStorage.userService); - var srv_cur = (Date.now() + (time.cu * 1000 - time.he)) / 1000; - $scope.duration += Math.floor(end - srv_cur); + var srv_cur = new Date(Date.now() + (time.cu - time.he)); + $scope.duration = Math.floor((end - srv_cur)/1000); } var stop = $interval(function() {