mirror of
https://github.com/nasa/openmct.git
synced 2025-06-14 05:08:15 +00:00
[Time Conductor] #933 Fixed code style errors
This commit is contained in:
@ -65,19 +65,31 @@ define([
|
|||||||
* Licensed
|
* Licensed
|
||||||
*/
|
*/
|
||||||
return [
|
return [
|
||||||
[".SSS", function(m) { return m.milliseconds(); }],
|
[".SSS", function (m) {
|
||||||
[":ss", function(m) { return m.seconds(); }],
|
return m.milliseconds();
|
||||||
["HH:mm", function(m) { return m.minutes(); }],
|
}],
|
||||||
["HH", function(m) { return m.hours(); }],
|
[":ss", function (m) {
|
||||||
|
return m.seconds();
|
||||||
|
}],
|
||||||
|
["HH:mm", function (m) {
|
||||||
|
return m.minutes();
|
||||||
|
}],
|
||||||
|
["HH", function (m) {
|
||||||
|
return m.hours();
|
||||||
|
}],
|
||||||
["ddd DD", function (m) {
|
["ddd DD", function (m) {
|
||||||
return m.days() &&
|
return m.days() &&
|
||||||
m.date() !== 1;
|
m.date() !== 1;
|
||||||
}],
|
}],
|
||||||
["MMM DD", function(m) { return m.date() !== 1; }],
|
["MMM DD", function (m) {
|
||||||
|
return m.date() !== 1;
|
||||||
|
}],
|
||||||
["MMMM", function (m) {
|
["MMMM", function (m) {
|
||||||
return m.month();
|
return m.month();
|
||||||
}],
|
}],
|
||||||
["YYYY", function() { return true; }]
|
["YYYY", function () {
|
||||||
|
return true;
|
||||||
|
}]
|
||||||
].filter(function (row) {
|
].filter(function (row) {
|
||||||
return row[1](momentified);
|
return row[1](momentified);
|
||||||
})[0][0];
|
})[0][0];
|
||||||
|
@ -35,7 +35,6 @@ define([], function () {
|
|||||||
* @type {TimeSystemMetadata}
|
* @type {TimeSystemMetadata}
|
||||||
*/
|
*/
|
||||||
this.metadata = undefined;
|
this.metadata = undefined;
|
||||||
this._tickSources = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,13 +30,13 @@ define(['./NumberFormat'], function (NumberFormat) {
|
|||||||
it("The format function takes a string and produces a number", function () {
|
it("The format function takes a string and produces a number", function () {
|
||||||
var text = format.format(1);
|
var text = format.format(1);
|
||||||
expect(text).toBe("1");
|
expect(text).toBe("1");
|
||||||
expect(typeof(text)).toBe("string");
|
expect(typeof text).toBe("string");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("The parse function takes a string and produces a number", function () {
|
it("The parse function takes a string and produces a number", function () {
|
||||||
var number = format.parse("1");
|
var number = format.parse("1");
|
||||||
expect(number).toBe(1);
|
expect(number).toBe(1);
|
||||||
expect(typeof(number)).toBe("number");
|
expect(typeof number).toBe("number");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("validates that the input is a number", function () {
|
it("validates that the input is a number", function () {
|
||||||
|
@ -126,7 +126,8 @@ define(
|
|||||||
TimeConductorController.prototype.setFormFromMode = function (mode) {
|
TimeConductorController.prototype.setFormFromMode = function (mode) {
|
||||||
this.$scope.modeModel.selectedKey = mode;
|
this.$scope.modeModel.selectedKey = mode;
|
||||||
//Synchronize scope with time system on mode
|
//Synchronize scope with time system on mode
|
||||||
this.$scope.timeSystemModel.options = this.conductorViewService.availableTimeSystems()
|
this.$scope.timeSystemModel.options =
|
||||||
|
this.conductorViewService.availableTimeSystems()
|
||||||
.map(function (t) {
|
.map(function (t) {
|
||||||
return t.metadata;
|
return t.metadata;
|
||||||
});
|
});
|
||||||
|
@ -33,12 +33,12 @@ define(
|
|||||||
function TimeConductorMode(metadata, conductor, timeSystems) {
|
function TimeConductorMode(metadata, conductor, timeSystems) {
|
||||||
this.conductor = conductor;
|
this.conductor = conductor;
|
||||||
|
|
||||||
this._metadata = metadata;
|
this.mdata = metadata;
|
||||||
this._deltas = undefined;
|
this.dlts = undefined;
|
||||||
this._tickSource = undefined;
|
this.source = undefined;
|
||||||
this._tickSourceUnlisten = undefined;
|
this.sourceUnlisten = undefined;
|
||||||
this._timeSystems = timeSystems;
|
this.systems = timeSystems;
|
||||||
this._availableTickSources = undefined;
|
this.availableSources = undefined;
|
||||||
this.changeTimeSystem = this.changeTimeSystem.bind(this);
|
this.changeTimeSystem = this.changeTimeSystem.bind(this);
|
||||||
this.tick = this.tick.bind(this);
|
this.tick = this.tick.bind(this);
|
||||||
|
|
||||||
@ -52,9 +52,9 @@ define(
|
|||||||
|
|
||||||
if (metadata.key === 'fixed') {
|
if (metadata.key === 'fixed') {
|
||||||
//Fixed automatically supports all time systems
|
//Fixed automatically supports all time systems
|
||||||
this._availableTimeSystems = timeSystems;
|
this.availableSystems = timeSystems;
|
||||||
} else {
|
} else {
|
||||||
this._availableTimeSystems = timeSystems.filter(function (timeSystem) {
|
this.availableSystems = timeSystems.filter(function (timeSystem) {
|
||||||
//Only include time systems that have tick sources that
|
//Only include time systems that have tick sources that
|
||||||
// support the current mode
|
// support the current mode
|
||||||
return timeSystem.tickSources().some(function (tickSource) {
|
return timeSystem.tickSources().some(function (tickSource) {
|
||||||
@ -86,10 +86,10 @@ define(
|
|||||||
this.deltas(defaults.deltas);
|
this.deltas(defaults.deltas);
|
||||||
|
|
||||||
// Tick sources are mode-specific, so restrict tick sources to only those supported by the current mode.
|
// Tick sources are mode-specific, so restrict tick sources to only those supported by the current mode.
|
||||||
var key = this._metadata.key;
|
var key = this.mdata.key;
|
||||||
var tickSources = timeSystem.tickSources();
|
var tickSources = timeSystem.tickSources();
|
||||||
if (tickSources) {
|
if (tickSources) {
|
||||||
this._availableTickSources = tickSources.filter(function (source){
|
this.availableSources = tickSources.filter(function (source) {
|
||||||
return source.metadata.mode === key;
|
return source.metadata.mode === key;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -102,11 +102,11 @@ define(
|
|||||||
* @returns {ModeMetadata}
|
* @returns {ModeMetadata}
|
||||||
*/
|
*/
|
||||||
TimeConductorMode.prototype.metadata = function () {
|
TimeConductorMode.prototype.metadata = function () {
|
||||||
return this._metadata;
|
return this.mdata;
|
||||||
};
|
};
|
||||||
|
|
||||||
TimeConductorMode.prototype.availableTimeSystems = function () {
|
TimeConductorMode.prototype.availableTimeSystems = function () {
|
||||||
return this._availableTimeSystems;
|
return this.availableSystems;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -115,7 +115,7 @@ define(
|
|||||||
* @returns {Array.<T>}
|
* @returns {Array.<T>}
|
||||||
*/
|
*/
|
||||||
TimeConductorMode.prototype.availableTickSources = function (timeSystem) {
|
TimeConductorMode.prototype.availableTickSources = function (timeSystem) {
|
||||||
return this._availableTickSources;
|
return this.availableSources;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -126,26 +126,26 @@ define(
|
|||||||
*/
|
*/
|
||||||
TimeConductorMode.prototype.tickSource = function (tickSource) {
|
TimeConductorMode.prototype.tickSource = function (tickSource) {
|
||||||
if (arguments.length > 0) {
|
if (arguments.length > 0) {
|
||||||
if (this._tickSourceUnlisten) {
|
if (this.sourceUnlisten) {
|
||||||
this._tickSourceUnlisten();
|
this.sourceUnlisten();
|
||||||
}
|
}
|
||||||
this._tickSource = tickSource;
|
this.source = tickSource;
|
||||||
if (tickSource) {
|
if (tickSource) {
|
||||||
this._tickSourceUnlisten = tickSource.listen(this.tick);
|
this.sourceUnlisten = tickSource.listen(this.tick);
|
||||||
//Now following a tick source
|
//Now following a tick source
|
||||||
this.conductor.follow(true);
|
this.conductor.follow(true);
|
||||||
} else {
|
} else {
|
||||||
this.conductor.follow(false);
|
this.conductor.follow(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this._tickSource;
|
return this.source;
|
||||||
};
|
};
|
||||||
|
|
||||||
TimeConductorMode.prototype.destroy = function () {
|
TimeConductorMode.prototype.destroy = function () {
|
||||||
this.conductor.off('timeSystem', this.changeTimeSystem);
|
this.conductor.off('timeSystem', this.changeTimeSystem);
|
||||||
|
|
||||||
if (this._tickSourceUnlisten) {
|
if (this.sourceUnlisten) {
|
||||||
this._tickSourceUnlisten();
|
this.sourceUnlisten();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -179,21 +179,21 @@ define(
|
|||||||
if (arguments.length !== 0) {
|
if (arguments.length !== 0) {
|
||||||
var oldEnd = this.conductor.bounds().end;
|
var oldEnd = this.conductor.bounds().end;
|
||||||
|
|
||||||
if (this._deltas && this._deltas.end !== undefined){
|
if (this.dlts && this.dlts.end !== undefined) {
|
||||||
//Calculate the previous raw end value (without delta)
|
//Calculate the previous raw end value (without delta)
|
||||||
oldEnd = oldEnd - this._deltas.end;
|
oldEnd = oldEnd - this.dlts.end;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._deltas = deltas;
|
this.dlts = deltas;
|
||||||
|
|
||||||
var newBounds = {
|
var newBounds = {
|
||||||
start: oldEnd - this._deltas.start,
|
start: oldEnd - this.dlts.start,
|
||||||
end: oldEnd + this._deltas.end
|
end: oldEnd + this.dlts.end
|
||||||
};
|
};
|
||||||
|
|
||||||
this.conductor.bounds(newBounds);
|
this.conductor.bounds(newBounds);
|
||||||
}
|
}
|
||||||
return this._deltas;
|
return this.dlts;
|
||||||
};
|
};
|
||||||
|
|
||||||
return TimeConductorMode;
|
return TimeConductorMode;
|
||||||
|
@ -36,13 +36,12 @@ define(
|
|||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function TimeConductorViewService(conductor, timeSystems) {
|
function TimeConductorViewService(conductor, timeSystems) {
|
||||||
this._timeSystems = timeSystems.map(
|
this.systems = timeSystems.map(function (timeSystemConstructor) {
|
||||||
function (timeSystemConstructor) {
|
|
||||||
return timeSystemConstructor();
|
return timeSystemConstructor();
|
||||||
});
|
});
|
||||||
|
|
||||||
this._conductor = conductor;
|
this.conductor = conductor;
|
||||||
this._mode = undefined;
|
this.currentMode = undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {object} ModeMetadata
|
* @typedef {object} ModeMetadata
|
||||||
@ -53,7 +52,7 @@ define(
|
|||||||
* @property {string} name A longer name for the mode
|
* @property {string} name A longer name for the mode
|
||||||
* @property {string} description A description of the mode
|
* @property {string} description A description of the mode
|
||||||
*/
|
*/
|
||||||
this._availableModes = {
|
this.availModes = {
|
||||||
'fixed': {
|
'fixed': {
|
||||||
key: 'fixed',
|
key: 'fixed',
|
||||||
cssclass: 'icon-calendar',
|
cssclass: 'icon-calendar',
|
||||||
@ -70,7 +69,7 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
var timeSystemsForMode = function (sourceType) {
|
var timeSystemsForMode = function (sourceType) {
|
||||||
return this._timeSystems.filter(hasTickSource.bind(this, sourceType));
|
return this.systems.filter(hasTickSource.bind(this, sourceType));
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
//Only show 'real-time mode' if appropriate time systems available
|
//Only show 'real-time mode' if appropriate time systems available
|
||||||
@ -82,7 +81,7 @@ define(
|
|||||||
name: 'Real-time Mode',
|
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.'
|
description: 'Monitor real-time streaming data as it comes in. The Time Conductor and displays will automatically advance themselves based on a UTC clock.'
|
||||||
};
|
};
|
||||||
this._availableModes[realtimeMode.key] = realtimeMode;
|
this.availModes[realtimeMode.key] = realtimeMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Only show 'LAD mode' if appropriate time systems available
|
//Only show 'LAD mode' if appropriate time systems available
|
||||||
@ -94,7 +93,7 @@ define(
|
|||||||
name: 'LAD Mode',
|
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.'
|
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._availableModes[ladMode.key] = ladMode;
|
this.availModes[ladMode.key] = ladMode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,23 +124,23 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (arguments.length === 1) {
|
if (arguments.length === 1) {
|
||||||
var timeSystem = this._conductor.timeSystem();
|
var timeSystem = this.conductor.timeSystem();
|
||||||
var modes = this.availableModes();
|
var modes = this.availableModes();
|
||||||
var modeMetaData = modes[newModeKey];
|
var modeMetaData = modes[newModeKey];
|
||||||
|
|
||||||
if (this._mode) {
|
if (this.currentMode) {
|
||||||
this._mode.destroy();
|
this.currentMode.destroy();
|
||||||
}
|
}
|
||||||
this._mode = new TimeConductorMode(modeMetaData, this._conductor, this._timeSystems);
|
this.currentMode = new TimeConductorMode(modeMetaData, this.conductor, this.systems);
|
||||||
|
|
||||||
// If no time system set on time conductor, or the currently selected time system is not available in
|
// If no time system set on time conductor, or the currently selected time system is not available in
|
||||||
// the new mode, default to first available time system
|
// the new mode, default to first available time system
|
||||||
if (!timeSystem || !contains(this._mode.availableTimeSystems(), timeSystem)) {
|
if (!timeSystem || !contains(this.currentMode.availableTimeSystems(), timeSystem)) {
|
||||||
timeSystem = this._mode.availableTimeSystems()[0];
|
timeSystem = this.currentMode.availableTimeSystems()[0];
|
||||||
this._conductor.timeSystem(timeSystem, timeSystem.defaults().bounds);
|
this.conductor.timeSystem(timeSystem, timeSystem.defaults().bounds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this._mode ? this._mode.metadata().key : undefined;
|
return this.currentMode ? this.currentMode.metadata().key : undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -176,7 +175,7 @@ define(
|
|||||||
*/
|
*/
|
||||||
TimeConductorViewService.prototype.deltas = function () {
|
TimeConductorViewService.prototype.deltas = function () {
|
||||||
//Deltas stored on mode. Use .apply to preserve arguments
|
//Deltas stored on mode. Use .apply to preserve arguments
|
||||||
return this._mode.deltas.apply(this._mode, arguments);
|
return this.currentMode.deltas.apply(this.currentMode, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -187,7 +186,7 @@ define(
|
|||||||
* @returns {ModeMetadata[]}
|
* @returns {ModeMetadata[]}
|
||||||
*/
|
*/
|
||||||
TimeConductorViewService.prototype.availableModes = function () {
|
TimeConductorViewService.prototype.availableModes = function () {
|
||||||
return this._availableModes;
|
return this.availModes;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -195,7 +194,7 @@ define(
|
|||||||
* mode. Time systems and tick sources are mode dependent
|
* mode. Time systems and tick sources are mode dependent
|
||||||
*/
|
*/
|
||||||
TimeConductorViewService.prototype.availableTimeSystems = function () {
|
TimeConductorViewService.prototype.availableTimeSystems = function () {
|
||||||
return this._mode.availableTimeSystems();
|
return this.currentMode.availableTimeSystems();
|
||||||
};
|
};
|
||||||
|
|
||||||
return TimeConductorViewService;
|
return TimeConductorViewService;
|
||||||
|
@ -133,7 +133,7 @@ define(['./TimeConductorViewService'], function (TimeConductorViewService) {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
viewService = new TimeConductorViewService(mockTimeConductor, mockTimeSystems);
|
viewService = new TimeConductorViewService(mockTimeConductor, mockTimeSystems);
|
||||||
viewService._mode = oldMode;
|
viewService.currentMode = oldMode;
|
||||||
viewService.mode('fixed');
|
viewService.mode('fixed');
|
||||||
expect(oldMode.destroy).toHaveBeenCalled();
|
expect(oldMode.destroy).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
@ -46,14 +46,14 @@ define([
|
|||||||
'cssclass': 'icon-clock'
|
'cssclass': 'icon-clock'
|
||||||
};
|
};
|
||||||
|
|
||||||
this._formats = ['utc'];
|
this.fmts = ['utc'];
|
||||||
this._tickSources = [new LocalClock($timeout, DEFAULT_PERIOD)];
|
this.sources = [new LocalClock($timeout, DEFAULT_PERIOD)];
|
||||||
}
|
}
|
||||||
|
|
||||||
UTCTimeSystem.prototype = Object.create(TimeSystem.prototype);
|
UTCTimeSystem.prototype = Object.create(TimeSystem.prototype);
|
||||||
|
|
||||||
UTCTimeSystem.prototype.formats = function () {
|
UTCTimeSystem.prototype.formats = function () {
|
||||||
return this._formats;
|
return this.fmts;
|
||||||
};
|
};
|
||||||
|
|
||||||
UTCTimeSystem.prototype.deltaFormat = function () {
|
UTCTimeSystem.prototype.deltaFormat = function () {
|
||||||
@ -61,7 +61,7 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
UTCTimeSystem.prototype.tickSources = function () {
|
UTCTimeSystem.prototype.tickSources = function () {
|
||||||
return this._tickSources;
|
return this.sources;
|
||||||
};
|
};
|
||||||
|
|
||||||
UTCTimeSystem.prototype.defaults = function (key) {
|
UTCTimeSystem.prototype.defaults = function (key) {
|
||||||
|
Reference in New Issue
Block a user