mirror of
https://github.com/nasa/openmct.git
synced 2025-01-19 19:27:07 +00:00
[Time Conductor] Show domain options
This commit is contained in:
parent
5d5a7c26c5
commit
d238b669a5
@ -21,7 +21,13 @@
|
||||
"depends": [ "now", "TIME_CONDUCTOR_DOMAINS" ]
|
||||
}
|
||||
],
|
||||
"contants": [
|
||||
"templates": [
|
||||
{
|
||||
"key": "time-conductor",
|
||||
"templateUrl": "templates/time-conductor.html"
|
||||
}
|
||||
],
|
||||
"constants": [
|
||||
{
|
||||
"key": "TIME_CONDUCTOR_DOMAINS",
|
||||
"value": [
|
||||
|
@ -0,0 +1,8 @@
|
||||
<mct-control key="'select'"
|
||||
ng-model='ngModel'
|
||||
field="'domain'"
|
||||
options="ngModel.options">
|
||||
</mct-control>
|
||||
<mct-include key="'time-controller'"
|
||||
ng-model='ngModel.conductor'>
|
||||
</mct-include>
|
@ -32,7 +32,7 @@ define(
|
||||
'"position: absolute; bottom: 0; width: 100%; ',
|
||||
'overflow: hidden; ',
|
||||
'height: ' + CONDUCTOR_HEIGHT + '">',
|
||||
"<mct-include key=\"'time-controller'\" ng-model='conductor'>",
|
||||
"<mct-include key=\"'time-conductor'\" ng-model='ngModel'>",
|
||||
"</mct-include>",
|
||||
'</div>'
|
||||
].join(''),
|
||||
@ -68,8 +68,8 @@ define(
|
||||
// Update the time conductor from the scope
|
||||
function wireScope(conductor, conductorScope, repScope) {
|
||||
function updateConductorOuter() {
|
||||
conductor.queryStart(conductorScope.conductor.outer.start);
|
||||
conductor.queryEnd(conductorScope.conductor.outer.end);
|
||||
conductor.queryStart(conductorScope.ngModel.conductor.outer.start);
|
||||
conductor.queryEnd(conductorScope.ngModel.conductor.outer.end);
|
||||
repScope.$broadcast(
|
||||
'telemetry:query:bounds',
|
||||
bounds(conductor.queryStart(), conductor.queryEnd())
|
||||
@ -77,27 +77,49 @@ define(
|
||||
}
|
||||
|
||||
function updateConductorInner() {
|
||||
conductor.displayStart(conductorScope.conductor.inner.start);
|
||||
conductor.displayEnd(conductorScope.conductor.inner.end);
|
||||
conductor.displayStart(conductorScope.ngModel.conductor.inner.start);
|
||||
conductor.displayEnd(conductorScope.ngModel.conductor.inner.end);
|
||||
repScope.$broadcast(
|
||||
'telemetry:display:bounds',
|
||||
bounds(conductor.displayStart(), conductor.displayEnd())
|
||||
);
|
||||
}
|
||||
|
||||
conductorScope.conductor = {
|
||||
function updateDomain(value) {
|
||||
conductor.activeDomain(value);
|
||||
repScope.$broadcast(
|
||||
'telemetry:query:bounds',
|
||||
bounds(conductor.queryStart(), conductor.queryEnd())
|
||||
);
|
||||
}
|
||||
|
||||
// telemetry domain metadata -> option for a select control
|
||||
function makeOption(domainOption) {
|
||||
return {
|
||||
name: domainOption.name,
|
||||
value: domainOption.key
|
||||
};
|
||||
}
|
||||
|
||||
conductorScope.ngModel = {};
|
||||
conductorScope.ngModel.conductor = {
|
||||
outer: bounds(conductor.queryStart(), conductor.queryEnd()),
|
||||
inner: bounds(conductor.displayStart(), conductor.displayEnd())
|
||||
};
|
||||
conductorScope.ngModel.options =
|
||||
conductor.domainOptions().map(makeOption);
|
||||
conductorScope.ngModel.domain = conductor.activeDomain();
|
||||
|
||||
conductorScope
|
||||
.$watch('conductor.outer.start', updateConductorOuter);
|
||||
.$watch('ngModel.conductor.outer.start', updateConductorOuter);
|
||||
conductorScope
|
||||
.$watch('conductor.outer.end', updateConductorOuter);
|
||||
.$watch('ngModel.conductor.outer.end', updateConductorOuter);
|
||||
conductorScope
|
||||
.$watch('conductor.inner.start', updateConductorInner);
|
||||
.$watch('ngModel.conductor.inner.start', updateConductorInner);
|
||||
conductorScope
|
||||
.$watch('conductor.inner.end', updateConductorInner);
|
||||
.$watch('ngModel.conductor.inner.end', updateConductorInner);
|
||||
conductorScope
|
||||
.$watch('ngModel.domain', updateDomain);
|
||||
|
||||
repScope.$on('telemetry:view', updateConductorInner);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ define(
|
||||
this.inner = { start: start, end: end };
|
||||
this.outer = { start: start, end: end };
|
||||
this.domains = domains;
|
||||
this.domain = domains[0];
|
||||
this.domain = domains[0].key;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,13 +111,15 @@ define(
|
||||
* @returns {TelemetryDomain} the active telemetry domain
|
||||
*/
|
||||
TimeConductor.prototype.activeDomain = function (key) {
|
||||
var i;
|
||||
function matchesKey(domain) {
|
||||
return domain.key === key;
|
||||
}
|
||||
|
||||
if (arguments.length > 0) {
|
||||
for (i = 0; i < this.domains.length; i += 1) {
|
||||
if (this.domains[i].key === key) {
|
||||
this.domain = this.domains[i];
|
||||
}
|
||||
if (!this.domains.some(matchesKey)) {
|
||||
throw new Error("Unknown domain " + key);
|
||||
}
|
||||
this.domain = key;
|
||||
}
|
||||
return this.domain;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user