From a154c9c8708580cc376adceb3777ef312858b6ac Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Thu, 22 Oct 2015 15:51:12 -0700 Subject: [PATCH] [Time Conductor] Use timeService from control --- bundles.json | 1 + example/generator/src/SinewaveTimeSystem.js | 4 +- platform/commonUI/general/bundle.json | 2 +- .../templates/controls/time-controller.html | 2 +- .../src/controllers/TimeRangeController.js | 41 ++++++++++++++----- 5 files changed, 36 insertions(+), 14 deletions(-) diff --git a/bundles.json b/bundles.json index a0f7edd7a8..3c2eb90340 100644 --- a/bundles.json +++ b/bundles.json @@ -26,6 +26,7 @@ "platform/policy", "platform/entanglement", "platform/search", + "platform/time", "example/imagery", "example/eventGenerator", diff --git a/example/generator/src/SinewaveTimeSystem.js b/example/generator/src/SinewaveTimeSystem.js index c248de4bfd..24a9e35e62 100644 --- a/example/generator/src/SinewaveTimeSystem.js +++ b/example/generator/src/SinewaveTimeSystem.js @@ -44,11 +44,11 @@ define([ }; SinewaveTimeSystem.prototype.now = function () { - return new SinewaveTelemetrySeries().getPointCount(); + return new SinewaveTelemetrySeries({}).getPointCount(); }; SinewaveTimeSystem.prototype.increment = function (scale) { - return Math.pow(10, (scale || 0) + 1); + return Math.max(Math.pow(10, (scale || 0) + 1), 1); }; return SinewaveTimeSystem; diff --git a/platform/commonUI/general/bundle.json b/platform/commonUI/general/bundle.json index 05c86cbcf7..c0f5141694 100644 --- a/platform/commonUI/general/bundle.json +++ b/platform/commonUI/general/bundle.json @@ -66,7 +66,7 @@ { "key": "TimeRangeController", "implementation": "controllers/TimeRangeController.js", - "depends": [ "$scope", "dateService", "now" ] + "depends": [ "$scope", "timeService", "now" ] }, { "key": "DateTimePickerController", diff --git a/platform/commonUI/general/res/templates/controls/time-controller.html b/platform/commonUI/general/res/templates/controls/time-controller.html index 87b6c682b2..5b41beeebf 100644 --- a/platform/commonUI/general/res/templates/controls/time-controller.html +++ b/platform/commonUI/general/res/templates/controls/time-controller.html @@ -102,7 +102,7 @@
diff --git a/platform/commonUI/general/src/controllers/TimeRangeController.js b/platform/commonUI/general/src/controllers/TimeRangeController.js index 5f2f0fa3e6..27efeeb3fc 100644 --- a/platform/commonUI/general/src/controllers/TimeRangeController.js +++ b/platform/commonUI/general/src/controllers/TimeRangeController.js @@ -34,24 +34,20 @@ define( * @memberof platform/commonUI/general * @constructor */ - function TimeRangeController($scope, dateService, now) { + function TimeRangeController($scope, timeService, now) { var tickCount = 2, innerMinimumSpan = 1000, // 1 second outerMinimumSpan = 1000 * 60 * 60, // 1 hour - initialDragValue; - - function timeSystemKey() { - return ($scope.parameters || {}).system; - } + initialDragValue, + timeSystem = timeService.system(); // Start with default function formatTimestamp(ts) { - return dateService.format(ts, timeSystemKey()); + return timeSystem.format(ts); } function parseTimestamp(text) { - var key = timeSystemKey(); - if (dateService.validate(text, key)) { - return dateService.parse(text, key); + if (timeSystem.validate(text)) { + return timeSystem.parse(text); } else { throw new Error("Could not parse " + text); } @@ -270,6 +266,30 @@ define( } } + function reinitializeBounds(now, increment) { + var end = Math.ceil(now / increment) * increment, + start = end - increment; + $scope.ngModel.outer.start = start; + $scope.ngModel.outer.end = end; + $scope.ngModel.inner.start = start; + $scope.ngModel.inner.end = end; + $scope.boundsModel = {}; + updateViewFromModel(); + } + + function updateTimeSystem(key) { + timeSystem = timeService.system(key) || timeService.system(); + + // One second / one hour in UTC; should be + // similarly useful in other time systems. + innerMinimumSpan = timeSystem.increment(-3); + outerMinimumSpan = timeSystem.increment(-1); + reinitializeBounds( + timeSystem.now(), + timeSystem.increment() + ); + } + function updateStartFromPicker(value) { updateOuterStart(value); updateBoundsText($scope.ngModel); @@ -300,6 +320,7 @@ define( $scope.$watch("ngModel.outer.end", updateEndFromPicker); $scope.$watch("boundsModel.start", updateStartFromText); $scope.$watch("boundsModel.end", updateEndFromText); + $scope.$watch("parameters.system", updateTimeSystem); } return TimeRangeController;