[Time Conductor] Use time systems from time conductor

This commit is contained in:
Victor Woeltjen 2015-10-22 13:07:04 -07:00
parent 9bc4327c59
commit e8d7093eb5
7 changed files with 42 additions and 24 deletions

View File

@ -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."
}
]
}
}

View File

@ -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) + "%";
}

View File

@ -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."
}
]

View File

@ -1,4 +1,5 @@
<mct-include key="'time-controller'"
parameters='parameters'
ng-model='ngModel.conductor'>
</mct-include>
<mct-control key="'select'"

View File

@ -27,7 +27,10 @@ define(
"use strict";
var TEMPLATE = [
"<mct-include key=\"'time-conductor'\" ng-model='ngModel' class='l-time-controller'>",
"<mct-include key=\"'time-conductor'\" ",
"ng-model='ngModel' ",
"parameters='parameters' ",
"class='l-time-controller'>",
"</mct-include>"
].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);

View File

@ -51,7 +51,7 @@ define(
request = request || {};
request.start = start;
request.end = end;
request.domain = domain;
request.domain = domain && domain.key;
return request;
}

View File

@ -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;
};