mirror of
https://github.com/nasa/openmct.git
synced 2025-02-20 17:33:23 +00:00
Time Conductor state retained on navigation
This commit is contained in:
parent
34c62ba405
commit
b9c41107c1
@ -39,7 +39,7 @@ define([
|
||||
"key": "conductorService",
|
||||
"implementation": ConductorService,
|
||||
"depends": [
|
||||
"timeConductor"
|
||||
"timeConductorService"
|
||||
]
|
||||
}
|
||||
],
|
||||
@ -47,7 +47,7 @@ define([
|
||||
{
|
||||
"implementation": ConductorRepresenter,
|
||||
"depends": [
|
||||
"timeConductor"
|
||||
"timeConductorService"
|
||||
]
|
||||
}
|
||||
],
|
||||
@ -57,7 +57,7 @@ define([
|
||||
"provides": "telemetryService",
|
||||
"implementation": ConductorTelemetryDecorator,
|
||||
"depends": [
|
||||
"timeConductor"
|
||||
"timeConductorService"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -37,11 +37,11 @@ define(
|
||||
* @constructor
|
||||
*/
|
||||
function ConductorRepresenter(
|
||||
conductor,
|
||||
conductorService,
|
||||
scope,
|
||||
element
|
||||
) {
|
||||
this.conductor = conductor;
|
||||
this.conductor = conductorService.conductor();
|
||||
this.scope = scope;
|
||||
this.element = element;
|
||||
|
||||
|
@ -26,8 +26,8 @@ define([
|
||||
|
||||
) {
|
||||
|
||||
function Conductor(timeConductor) {
|
||||
this.timeConductor = timeConductor;
|
||||
function Conductor(timeConductorService) {
|
||||
this.timeConductor = timeConductorService.conductor();
|
||||
}
|
||||
|
||||
Conductor.prototype.displayStart = function () {
|
||||
|
@ -36,8 +36,8 @@ define(
|
||||
* the service which exposes the global time conductor
|
||||
* @param {TelemetryService} telemetryService the decorated service
|
||||
*/
|
||||
function ConductorTelemetryDecorator(conductor, telemetryService) {
|
||||
this.conductor = conductor;
|
||||
function ConductorTelemetryDecorator(conductorService, telemetryService) {
|
||||
this.conductor = conductorService.conductor();
|
||||
this.telemetryService = telemetryService;
|
||||
|
||||
this.amendRequests = ConductorTelemetryDecorator.prototype.amendRequests.bind(this);
|
||||
|
@ -21,7 +21,7 @@
|
||||
*****************************************************************************/
|
||||
|
||||
define([
|
||||
"./src/TimeConductor",
|
||||
"./src/ui/TimeConductorService",
|
||||
"./src/ui/TimeConductorController",
|
||||
"./src/ui/MCTConductorAxis",
|
||||
"text!./res/templates/time-conductor.html",
|
||||
@ -29,7 +29,7 @@ define([
|
||||
"text!./res/templates/mode-selector/mode-menu.html",
|
||||
'legacyRegistry'
|
||||
], function (
|
||||
TimeConductor,
|
||||
TimeConductorService,
|
||||
TimeConductorController,
|
||||
MCTConductorAxis,
|
||||
timeConductorTemplate,
|
||||
@ -42,8 +42,8 @@ define([
|
||||
"extensions": {
|
||||
"services": [
|
||||
{
|
||||
"key": "timeConductor",
|
||||
"implementation": TimeConductor
|
||||
"key": "timeConductorService",
|
||||
"implementation": TimeConductorService
|
||||
}
|
||||
],
|
||||
"controllers": [
|
||||
@ -52,7 +52,7 @@ define([
|
||||
"implementation": TimeConductorController,
|
||||
"depends": [
|
||||
"$scope",
|
||||
"timeConductor",
|
||||
"timeConductorService",
|
||||
"timeSystems[]"
|
||||
]
|
||||
}
|
||||
@ -62,7 +62,7 @@ define([
|
||||
"key": "mctConductorAxis",
|
||||
"implementation": MCTConductorAxis,
|
||||
"depends": [
|
||||
"timeConductor",
|
||||
"timeConductorService",
|
||||
"formatService"
|
||||
]
|
||||
}
|
||||
|
@ -94,7 +94,7 @@
|
||||
class="holder flex-elem menus-up time-system"
|
||||
structure="{
|
||||
text: timeSystemModel.selected.metadata.name,
|
||||
click: tcController.selectTimeSystem,
|
||||
click: tcController.selectTimeSystemByKey,
|
||||
options: timeSystemModel.options
|
||||
}">
|
||||
</mct-control>
|
||||
|
@ -32,7 +32,8 @@ define(
|
||||
* labelled 'ticks'. It requires 'start' and 'end' integer values to
|
||||
* be specified as attributes.
|
||||
*/
|
||||
function MCTConductorAxis(conductor, formatService) {
|
||||
function MCTConductorAxis(conductorService, formatService) {
|
||||
var conductor = conductorService.conductor();
|
||||
|
||||
function link(scope, element, attrs, ngModelController) {
|
||||
var target = element[0].firstChild,
|
||||
|
@ -28,7 +28,7 @@ define(
|
||||
],
|
||||
function (FixedMode, FollowMode, TimeConductorValidation) {
|
||||
|
||||
function TimeConductorController($scope, conductor, timeSystems) {
|
||||
function TimeConductorController($scope, conductorService, timeSystems) {
|
||||
|
||||
var self = this;
|
||||
|
||||
@ -39,7 +39,14 @@ define(
|
||||
self[key] = self[key].bind(self);
|
||||
});
|
||||
|
||||
this.conductor = conductor;
|
||||
this.conductorService = conductorService;
|
||||
this.conductor = conductorService.conductor();
|
||||
|
||||
this.conductor.on('bounds', this.setBounds);
|
||||
this.conductor.on('follow', function (follow){
|
||||
$scope.followMode = follow;
|
||||
});
|
||||
|
||||
// Construct the provided time system definitions
|
||||
this._timeSystems = timeSystems.map(function (timeSystemConstructor){
|
||||
return timeSystemConstructor();
|
||||
@ -61,7 +68,7 @@ define(
|
||||
label: 'Real-time',
|
||||
name: 'Real-time Mode',
|
||||
description: 'Monitor real-time streaming data as it comes in. The Time Conductor and displays will automatically advance themselves based on a UTC clock.'
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
//Only show 'real-time mode' if a clock source is available
|
||||
@ -71,66 +78,54 @@ define(
|
||||
label: 'LAD',
|
||||
name: 'LAD Mode',
|
||||
description: 'Latest Available Data mode monitors real-time streaming data as it comes in. The Time Conductor and displays will only advance when data becomes available.'
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
this.selectedMode = undefined;
|
||||
|
||||
this.validation = new TimeConductorValidation(conductor);
|
||||
this.validation = new TimeConductorValidation(this.conductor);
|
||||
this.$scope = $scope;
|
||||
this.initializeScope($scope);
|
||||
|
||||
conductor.on('bounds', this.setBounds);
|
||||
conductor.on('follow', function (follow){
|
||||
$scope.followMode = follow;
|
||||
});
|
||||
|
||||
//Set the time conductor mode to the first one in the list,
|
||||
// effectively initializing the time conductor
|
||||
this.setMode('fixed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
TimeConductorController.prototype.initializeScope = function ($scope) {
|
||||
var self = this;
|
||||
/*
|
||||
Represents the various time system options, and the currently
|
||||
selected time system in the view. Additionally holds the
|
||||
default format from the selected time system for convenience
|
||||
of access from the template.
|
||||
Set time Conductor bounds in the form
|
||||
*/
|
||||
$scope.timeSystemModel = {
|
||||
selected: undefined,
|
||||
format: undefined,
|
||||
options: []
|
||||
};
|
||||
$scope.formModel = this.conductor.bounds();
|
||||
|
||||
/*
|
||||
Represents the various time system options, and the currently
|
||||
selected time system in the view. Additionally holds the
|
||||
default format from the selected time system for convenience
|
||||
of access from the template.
|
||||
*/
|
||||
$scope.timeSystemModel = {};
|
||||
if (this.conductor.timeSystem()) {
|
||||
$scope.timeSystemModel.selected = this.conductor.timeSystem();
|
||||
$scope.timeSystemModel.format = this.conductor.timeSystem().formats()[0];
|
||||
}
|
||||
|
||||
/*
|
||||
Represents the various modes, and the currently
|
||||
selected mode in the view
|
||||
*/
|
||||
$scope.modeModel = {
|
||||
selectedKey: undefined,
|
||||
options: this.modes
|
||||
};
|
||||
/*
|
||||
Time Conductor bounds in the form
|
||||
*/
|
||||
$scope.formModel = {
|
||||
start: 0,
|
||||
end: 0
|
||||
};
|
||||
|
||||
var mode = conductorService.mode();
|
||||
if (mode) {
|
||||
$scope.modeModel.selectedKey = mode.key();
|
||||
var deltas = mode.deltas && mode.deltas();
|
||||
if (deltas) {
|
||||
$scope.formModel.startDelta = deltas.start;
|
||||
$scope.formModel.endDelta = deltas.end;
|
||||
}
|
||||
} else {
|
||||
// Default to fixed mode
|
||||
this.setMode('fixed');
|
||||
}
|
||||
|
||||
$scope.$watch('modeModel.selectedKey', this.setMode);
|
||||
$scope.$watch('timeSystem', this.setTimeSystem);
|
||||
|
||||
$scope.$on('$destroy', function() {
|
||||
if (self.selectedMode) {
|
||||
self.selectedMode.destroy();
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the bounds change in the time conductor. Synchronizes
|
||||
@ -165,7 +160,7 @@ define(
|
||||
* @see TimeConductorMode
|
||||
*/
|
||||
TimeConductorController.prototype.updateDeltasFromForm = function (formModel) {
|
||||
var mode = this.selectedMode,
|
||||
var mode = this.conductorService.mode(),
|
||||
deltas = mode.deltas();
|
||||
|
||||
if (deltas !== undefined && this.validation.validateDeltas(formModel)) {
|
||||
@ -193,37 +188,39 @@ define(
|
||||
* Change the selected Time Conductor mode. This will call destroy
|
||||
* and initialization functions on the relevant modes, setting
|
||||
* default values for bound and deltas in the form.
|
||||
* @param newMode
|
||||
* @param oldMode
|
||||
* @param newModeKey
|
||||
* @param oldModeKey
|
||||
*/
|
||||
TimeConductorController.prototype.setMode = function (newMode, oldMode) {
|
||||
if (newMode !== oldMode) {
|
||||
this.$scope.modeModel.selectedKey = newMode;
|
||||
TimeConductorController.prototype.setMode = function (newModeKey, oldModeKey) {
|
||||
if (newModeKey !== oldModeKey) {
|
||||
var newMode = undefined;
|
||||
this.$scope.modeModel.selectedKey = newModeKey;
|
||||
|
||||
if (this.selectedMode) {
|
||||
this.selectedMode.destroy();
|
||||
if (this.conductorService.mode()) {
|
||||
this.conductorService.mode().destroy();
|
||||
}
|
||||
switch (newMode) {
|
||||
|
||||
switch (newModeKey) {
|
||||
case 'fixed':
|
||||
this.selectedMode = new FixedMode(this.conductor, this._timeSystems);
|
||||
newMode = new FixedMode(this.conductor, this._timeSystems, newModeKey);
|
||||
break;
|
||||
case 'realtime':
|
||||
// Filter time systems to only those with clock tick
|
||||
// sources
|
||||
this.selectedMode = new FollowMode(this.conductor, this.timeSystemsForSourceType('clock'));
|
||||
newMode = new FollowMode(this.conductor, this.timeSystemsForSourceType('clock'), newModeKey);
|
||||
break;
|
||||
case 'latest':
|
||||
// Filter time systems to only those with data tick
|
||||
// sources
|
||||
this.selectedMode = new FollowMode(this.conductor, this.timeSystemsForSourceType('data'));
|
||||
newMode = new FollowMode(this.conductor, this.timeSystemsForSourceType('data'), newModeKey);
|
||||
break;
|
||||
}
|
||||
this.selectedMode.initialize();
|
||||
|
||||
var timeSystem = this.selectedMode.selectedTimeSystem();
|
||||
newMode.initialize();
|
||||
this.conductorService.mode(newMode);
|
||||
var timeSystem = newMode.selectedTimeSystem();
|
||||
|
||||
//Synchronize scope with time system on mode
|
||||
this.$scope.timeSystemModel.options = this.selectedMode.timeSystems().map(function (timeSystem) {
|
||||
this.$scope.timeSystemModel.options = newMode.timeSystems().map(function (timeSystem) {
|
||||
return timeSystem.metadata;
|
||||
});
|
||||
|
||||
@ -257,7 +254,7 @@ define(
|
||||
* @param key
|
||||
* @see TimeConductorController#setTimeSystem
|
||||
*/
|
||||
TimeConductorController.prototype.selectTimeSystem = function(key){
|
||||
TimeConductorController.prototype.selectTimeSystemByKey = function(key){
|
||||
var selected = this._timeSystems.find(function (timeSystem){
|
||||
return timeSystem.metadata.key === key;
|
||||
});
|
||||
@ -273,7 +270,7 @@ define(
|
||||
if (newTimeSystem && newTimeSystem !== this.$scope.timeSystemModel.selected) {
|
||||
this.$scope.timeSystemModel.selected = newTimeSystem;
|
||||
this.$scope.timeSystemModel.format = newTimeSystem.formats()[0];
|
||||
var mode = this.selectedMode;
|
||||
var mode = this.conductorService.mode();
|
||||
mode.selectedTimeSystem(newTimeSystem);
|
||||
this.setDeltasFromTimeSystem(newTimeSystem);
|
||||
}
|
||||
|
@ -0,0 +1,45 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT Web includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
define(
|
||||
['../TimeConductor'],
|
||||
function (TimeConductor) {
|
||||
|
||||
function TimeConductorService() {
|
||||
this._conductor = new TimeConductor();
|
||||
this._mode = undefined;
|
||||
}
|
||||
|
||||
TimeConductorService.prototype.mode = function (mode) {
|
||||
if (arguments.length === 1) {
|
||||
this._mode = mode;
|
||||
}
|
||||
return this._mode;
|
||||
};
|
||||
|
||||
TimeConductorService.prototype.conductor = function () {
|
||||
return this._conductor;
|
||||
};
|
||||
|
||||
return TimeConductorService;
|
||||
}
|
||||
);
|
@ -32,8 +32,8 @@ define(
|
||||
* @param timeSystems
|
||||
* @constructor
|
||||
*/
|
||||
function FixedMode(conductor, timeSystems) {
|
||||
TimeConductorMode.call(this, conductor, timeSystems);
|
||||
function FixedMode(conductor, timeSystems, key) {
|
||||
TimeConductorMode.call(this, conductor, timeSystems, key);
|
||||
}
|
||||
|
||||
FixedMode.prototype = Object.create(TimeConductorMode.prototype);
|
||||
|
@ -33,8 +33,8 @@ define(
|
||||
* the mode relevant, with both offsets defined relative to it.
|
||||
* @constructor
|
||||
*/
|
||||
function FollowMode(conductor, timeSystems) {
|
||||
TimeConductorMode.call(this, conductor, timeSystems);
|
||||
function FollowMode(conductor, timeSystems, key) {
|
||||
TimeConductorMode.call(this, conductor, timeSystems, key);
|
||||
|
||||
this._deltas = undefined;
|
||||
}
|
||||
|
@ -33,9 +33,10 @@ define(
|
||||
* @constructor
|
||||
* @param {TimeConductorMetadata} metadata
|
||||
*/
|
||||
function TimeConductorMode(conductor, timeSystems) {
|
||||
function TimeConductorMode(conductor, timeSystems, key) {
|
||||
this.conductor = conductor;
|
||||
this._timeSystems = timeSystems;
|
||||
this._key = key;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,6 +73,10 @@ define(
|
||||
return this._selectedTimeSystem;
|
||||
};
|
||||
|
||||
TimeConductorMode.prototype.key = function () {
|
||||
return this._key;
|
||||
};
|
||||
|
||||
TimeConductorMode.prototype.destroy = function () {
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user