mirror of
https://github.com/nasa/openmct.git
synced 2025-04-15 06:56:43 +00:00
Code cleanup
This commit is contained in:
parent
aa4a5e56f9
commit
c1bbc4f01d
@ -34,13 +34,6 @@ define([
|
||||
"YYYY-MM-DD"
|
||||
];
|
||||
|
||||
var MS = 1,
|
||||
SECONDS = 1000 * MS,
|
||||
MINUTES = 60 * SECONDS,
|
||||
HOURS = 60 * MINUTES,
|
||||
DAYS = 24 * HOURS,
|
||||
MONTHS = (365 / 12) * DAYS;
|
||||
|
||||
/**
|
||||
* @typedef Scale
|
||||
* @property {number} min the minimum scale value, in ms
|
||||
|
@ -24,6 +24,18 @@ define(
|
||||
[],
|
||||
function () {
|
||||
|
||||
/**
|
||||
* Representer that provides a compatibility layer between the new
|
||||
* time conductor and existing representations / views. Listens to
|
||||
* the v2 time conductor API and generates v1 style events using the
|
||||
* Angular event bus. This is transitional code code and will be
|
||||
* removed.
|
||||
*
|
||||
* Deprecated immediately as this is temporary code
|
||||
*
|
||||
* @deprecated
|
||||
* @constructor
|
||||
*/
|
||||
function ConductorRepresenter(
|
||||
conductor,
|
||||
scope,
|
||||
|
@ -21,8 +21,7 @@
|
||||
validate: tcController.validation.validateStart
|
||||
}"
|
||||
ng-model="formModel"
|
||||
ng-mouseup="changing['start'] = true"
|
||||
ng-blur="changing['start'] = false; tcController.updateBoundsFromForm(formModel)"
|
||||
ng-blur="tcController.updateBoundsFromForm(formModel)"
|
||||
field="'start'"
|
||||
class="time-range-input">
|
||||
</mct-control>
|
||||
@ -52,8 +51,7 @@
|
||||
validate: tcController.validation.validateEnd
|
||||
}"
|
||||
ng-model="formModel"
|
||||
ng-mouseup="changing['end'] = true"
|
||||
ng-blur="changing['end'] = false; tcController.updateBoundsFromForm(formModel)"
|
||||
ng-blur="tcController.updateBoundsFromForm(formModel)"
|
||||
field="'end'"
|
||||
class="time-range-input">
|
||||
</mct-control>
|
||||
|
@ -72,12 +72,6 @@ define(['EventEmitter'], function (EventEmitter) {
|
||||
return true;
|
||||
};
|
||||
|
||||
function throwOnError(validationResult) {
|
||||
if (validationResult !== true) {
|
||||
throw new Error(validationResult);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or set the follow mode of the time conductor. In follow mode the
|
||||
* time conductor ticks, regularly updating the bounds from a timing
|
||||
@ -117,7 +111,10 @@ define(['EventEmitter'], function (EventEmitter) {
|
||||
*/
|
||||
TimeConductor.prototype.bounds = function (newBounds) {
|
||||
if (arguments.length > 0) {
|
||||
throwOnError(this.validateBounds(newBounds));
|
||||
var validationResult = this.validateBounds(newBounds);
|
||||
if (validationResult !== true){
|
||||
throw new Error(validationResult);
|
||||
}
|
||||
//Create a copy to avoid direct mutation of conductor bounds
|
||||
this.boundsVal = JSON.parse(JSON.stringify(newBounds));
|
||||
/**
|
||||
|
@ -70,23 +70,33 @@ define(
|
||||
* @private
|
||||
*/
|
||||
TimeConductorController.prototype.initializeScope = function ($scope) {
|
||||
|
||||
/*
|
||||
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 = {
|
||||
selected: undefined,
|
||||
format: undefined,
|
||||
options: []
|
||||
};
|
||||
/*
|
||||
Represents the various modes, and the currently
|
||||
selected mode in the view
|
||||
*/
|
||||
$scope.modeModel = {
|
||||
selected: undefined,
|
||||
options: this.modes
|
||||
};
|
||||
/*
|
||||
Time Conductor bounds in the form
|
||||
*/
|
||||
$scope.formModel = {
|
||||
start: 0,
|
||||
end: 0
|
||||
};
|
||||
$scope.changing = {
|
||||
'start': false,
|
||||
'end': false
|
||||
};
|
||||
|
||||
$scope.$watch('modeModel.selected', this.setMode);
|
||||
$scope.$watch('timeSystem', this.setTimeSystem);
|
||||
@ -105,12 +115,8 @@ define(
|
||||
* @param bounds
|
||||
*/
|
||||
TimeConductorController.prototype.setBounds = function (bounds) {
|
||||
if (!this.$scope.changing['start']) {
|
||||
this.$scope.formModel.start = bounds.start;
|
||||
}
|
||||
if (!this.$scope.changing['end']) {
|
||||
this.$scope.formModel.end = bounds.end;
|
||||
}
|
||||
this.$scope.formModel.start = bounds.start;
|
||||
this.$scope.formModel.end = bounds.end;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -119,7 +125,10 @@ define(
|
||||
* @param formModel
|
||||
*/
|
||||
TimeConductorController.prototype.updateBoundsFromForm = function (formModel) {
|
||||
var newBounds = {start: formModel.start, end: formModel.end};
|
||||
var newBounds = {
|
||||
start: formModel.start,
|
||||
end: formModel.end
|
||||
};
|
||||
|
||||
if (this.conductor.validateBounds(newBounds) === true) {
|
||||
this.conductor.bounds(newBounds);
|
||||
@ -151,7 +160,7 @@ define(
|
||||
*/
|
||||
TimeConductorController.prototype.setMode = function (newMode, oldMode) {
|
||||
if (newMode !== oldMode) {
|
||||
if (oldMode && oldMode.destroy) {
|
||||
if (oldMode) {
|
||||
oldMode.destroy();
|
||||
}
|
||||
newMode.initialize();
|
||||
@ -167,14 +176,14 @@ define(
|
||||
this.$scope.timeSystemModel.selected = timeSystem;
|
||||
//Use default format
|
||||
this.$scope.timeSystemModel.format = timeSystem.formats()[0];
|
||||
this.setDefaultsFromTimeSystem(newMode.selectedTimeSystem());
|
||||
this.setDeltasFromTimeSystem(timeSystem);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
TimeConductorController.prototype.setDefaultsFromTimeSystem = function (timeSystem) {
|
||||
TimeConductorController.prototype.setDeltasFromTimeSystem = function (timeSystem) {
|
||||
var defaults = timeSystem.defaults()[0];
|
||||
var deltas = defaults.deltas;
|
||||
|
||||
@ -214,7 +223,7 @@ define(
|
||||
this.$scope.timeSystemModel.selected = newTimeSystem;
|
||||
var mode = this.$scope.modeModel.selected;
|
||||
mode.selectedTimeSystem(newTimeSystem);
|
||||
this.setDefaultsFromTimeSystem(newTimeSystem);
|
||||
this.setDeltasFromTimeSystem(newTimeSystem);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user