From e8d7093eb57393f2c9e58925fa3c48b29987e54e Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Thu, 22 Oct 2015 13:07:04 -0700 Subject: [PATCH] [Time Conductor] Use time systems from time conductor --- example/generator/bundle.json | 12 ++++++++++ .../src/controllers/TimeRangeController.js | 4 ++-- platform/features/conductor/bundle.json | 4 ++-- .../res/templates/time-conductor.html | 1 + .../conductor/src/ConductorRepresenter.js | 23 +++++++++++-------- .../src/ConductorTelemetryDecorator.js | 2 +- .../features/conductor/src/TimeConductor.js | 20 ++++++++-------- 7 files changed, 42 insertions(+), 24 deletions(-) diff --git a/example/generator/bundle.json b/example/generator/bundle.json index fc18f31193..b2050e07e9 100644 --- a/example/generator/bundle.json +++ b/example/generator/bundle.json @@ -73,6 +73,18 @@ } ] } + ], + "constants": [ + { + "key": "TIME_CONDUCTOR_DOMAINS", + "value": [ + { "key": "time", "name": "Time" }, + { "key": "yesterday", "name": "Yesterday" }, + { "key": "index", "name": "Index", "system": "generator.index" } + ], + "priority": -1, + "comment": "Placeholder; to be replaced by inspection of available domains." + } ] } } diff --git a/platform/commonUI/general/src/controllers/TimeRangeController.js b/platform/commonUI/general/src/controllers/TimeRangeController.js index 9ec95bac23..5f2f0fa3e6 100644 --- a/platform/commonUI/general/src/controllers/TimeRangeController.js +++ b/platform/commonUI/general/src/controllers/TimeRangeController.js @@ -41,7 +41,7 @@ define( initialDragValue; function timeSystemKey() { - return ($scope.parameters || {}).domain; + return ($scope.parameters || {}).system; } function formatTimestamp(ts) { @@ -57,7 +57,7 @@ define( } } - // From 0.0-1.0 to "0%"-"1%" + // From 0.0-1.0 to "0%"-"100%" function toPercent(p) { return (100 * p) + "%"; } diff --git a/platform/features/conductor/bundle.json b/platform/features/conductor/bundle.json index de903cfb93..10d3f32665 100644 --- a/platform/features/conductor/bundle.json +++ b/platform/features/conductor/bundle.json @@ -36,9 +36,9 @@ { "key": "TIME_CONDUCTOR_DOMAINS", "value": [ - { "key": "time", "name": "Time" }, - { "key": "yesterday", "name": "Yesterday" } + { "key": "time", "name": "Time" } ], + "priority": "fallback", "comment": "Placeholder; to be replaced by inspection of available domains." } ] diff --git a/platform/features/conductor/res/templates/time-conductor.html b/platform/features/conductor/res/templates/time-conductor.html index 4126652d5b..16cc6296c8 100644 --- a/platform/features/conductor/res/templates/time-conductor.html +++ b/platform/features/conductor/res/templates/time-conductor.html @@ -1,4 +1,5 @@ ", + "", "" ].join(''), THROTTLE_MS = 200, @@ -74,11 +77,12 @@ define( broadcastBounds; // Combine start/end times into a single object - function bounds(start, end) { + function bounds() { + var domain = conductor.domain(); return { start: conductor.displayStart(), end: conductor.displayEnd(), - domain: conductor.domain() + domain: domain && domain.key }; } @@ -97,12 +101,10 @@ define( } function updateDomain(value) { - conductor.domain(value); - repScope.$broadcast('telemetry:display:bounds', bounds( - conductor.displayStart(), - conductor.displayEnd(), - conductor.domain() - )); + var newDomain = conductor.domain(value); + conductorScope.parameters.system = + newDomain && newDomain.system; + repScope.$broadcast('telemetry:display:bounds', bounds()); } // telemetry domain metadata -> option for a select control @@ -130,7 +132,8 @@ define( { outer: bounds(), inner: bounds() }; conductorScope.ngModel.options = conductor.domainOptions().map(makeOption); - conductorScope.ngModel.domain = conductor.domain(); + conductorScope.ngModel.domain = (conductor.domain() || {}).key; + conductorScope.parameters = {}; conductorScope .$watch('ngModel.conductor.inner.start', updateConductorInner); diff --git a/platform/features/conductor/src/ConductorTelemetryDecorator.js b/platform/features/conductor/src/ConductorTelemetryDecorator.js index ab2d958d7e..f359199ce2 100644 --- a/platform/features/conductor/src/ConductorTelemetryDecorator.js +++ b/platform/features/conductor/src/ConductorTelemetryDecorator.js @@ -51,7 +51,7 @@ define( request = request || {}; request.start = start; request.end = end; - request.domain = domain; + request.domain = domain && domain.key; return request; } diff --git a/platform/features/conductor/src/TimeConductor.js b/platform/features/conductor/src/TimeConductor.js index 0fa0403fd9..400cb06f97 100644 --- a/platform/features/conductor/src/TimeConductor.js +++ b/platform/features/conductor/src/TimeConductor.js @@ -43,7 +43,7 @@ define( function TimeConductor(start, end, domains) { this.range = { start: start, end: end }; this.domains = domains; - this.activeDomain = domains[0].key; + this.activeDomain = domains[0]; } /** @@ -73,7 +73,7 @@ define( /** * Get available domain options which can be used to bound time * selection. - * @returns {TelemetryDomain[]} available domains + * @returns {TelemetryDomainMetadata[]} available domains */ TimeConductor.prototype.domainOptions = function () { return this.domains; @@ -82,19 +82,21 @@ define( /** * Get or set (if called with an argument) the active domain. * @param {string} [key] the key identifying the domain choice - * @returns {TelemetryDomain} the active telemetry domain + * @returns {TelemetryDomainMetadata} the active telemetry domain */ TimeConductor.prototype.domain = function (key) { - function matchesKey(domain) { - return domain.key === key; - } + var i; if (arguments.length > 0) { - if (!this.domains.some(matchesKey)) { - throw new Error("Unknown domain " + key); + for (i = 0; i < this.domains.length; i += 1) { + if (this.domains[i].key === key) { + return (this.activeDomain = this.domains[i]); + } } - this.activeDomain = key; + + throw new Error("Unknown domain " + key); } + return this.activeDomain; };