Apply formatting, filter modes by tick source availability

This commit is contained in:
Henry 2016-08-01 17:51:15 -07:00
parent fcd7ab93e5
commit 121ab413ff

View File

@ -41,7 +41,7 @@ define(
this.conductor = conductor; this.conductor = conductor;
// Construct the provided time system definitions // Construct the provided time system definitions
this.timeSystems = timeSystems.map(function (timeSystemConstructor){ this._timeSystems = timeSystems.map(function (timeSystemConstructor){
return timeSystemConstructor(); return timeSystemConstructor();
}); });
@ -51,20 +51,29 @@ define(
label: 'Fixed', label: 'Fixed',
name: 'Fixed Timespan Mode', name: 'Fixed Timespan Mode',
description: 'Query and explore data that falls between two fixed datetimes.' description: 'Query and explore data that falls between two fixed datetimes.'
}, }
'latest': { };
glyph: '\u0044',
label: 'LAD', //Only show 'real-time mode' if a clock source is available
name: 'LAD Mode', if (this.timeSystemsForSourceType('clock').length > 0 ) {
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.modes['realtime'] = {
},
'realtime': {
glyph: '\u0043', glyph: '\u0043',
label: 'Real-time', label: 'Real-time',
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.'
} }
}; }
//Only show 'real-time mode' if a clock source is available
if (this.timeSystemsForSourceType('data').length > 0) {
this.modes['latest'] = {
glyph: '\u0044',
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.selectedMode = undefined;
this.validation = new TimeConductorValidation(conductor); this.validation = new TimeConductorValidation(conductor);
@ -165,6 +174,21 @@ define(
} }
}; };
/**
* @private
*/
TimeConductorController.prototype.timeSystemsForSourceType = function(type){
if (!type) {
return this._timeSystems;
} else {
return this._timeSystems.filter(function (timeSystem){
return timeSystem.tickSources().some(function (tickSource){
return tickSource.type() === type;
});
});
}
};
/** /**
* Change the selected Time Conductor mode. This will call destroy * Change the selected Time Conductor mode. This will call destroy
* and initialization functions on the relevant modes, setting * and initialization functions on the relevant modes, setting
@ -181,27 +205,17 @@ define(
} }
switch (newMode) { switch (newMode) {
case 'fixed': case 'fixed':
this.selectedMode = new FixedMode(this.conductor, this.timeSystems); this.selectedMode = new FixedMode(this.conductor, this._timeSystems);
break; break;
case 'realtime': case 'realtime':
// Filter time systems to only those with clock tick // Filter time systems to only those with clock tick
// sources // sources
var realtimeSystems = this.timeSystems.filter(function (timeSystem){ this.selectedMode = new FollowMode(this.conductor, this.timeSystemsForSourceType('clock'));
return timeSystem.tickSources().some(function (tickSource){
return tickSource.type() === 'clock';
});
});
this.selectedMode = new FollowMode(this.conductor, realtimeSystems);
break; break;
case 'latest': case 'latest':
// Filter time systems to only those with clock tick // Filter time systems to only those with data tick
// sources // sources
var ladSystems = this.timeSystems.filter(function (timeSystem){ this.selectedMode = new FollowMode(this.conductor, this.timeSystemsForSourceType('data'));
return timeSystem.tickSources().some(function (tickSource){
return tickSource.type() === 'data';
});
});
this.selectedMode = new FollowMode(this.conductor, ladSystems);
break; break;
} }
this.selectedMode.initialize(); this.selectedMode.initialize();
@ -214,10 +228,6 @@ define(
}); });
this.setTimeSystem(timeSystem); this.setTimeSystem(timeSystem);
/*this.$scope.timeSystemModel.selected = timeSystem;
//Use default format
this.$scope.timeSystemModel.format = timeSystem.formats()[0];
this.setDeltasFromTimeSystem(timeSystem); */
} }
}; };
@ -248,7 +258,7 @@ define(
* @see TimeConductorController#setTimeSystem * @see TimeConductorController#setTimeSystem
*/ */
TimeConductorController.prototype.selectTimeSystem = function(key){ TimeConductorController.prototype.selectTimeSystem = function(key){
var selected = this.timeSystems.find(function (timeSystem){ var selected = this._timeSystems.find(function (timeSystem){
return timeSystem.metadata.key === key; return timeSystem.metadata.key === key;
}); });
this.setTimeSystem(selected); this.setTimeSystem(selected);