Skip to content

Commit 121ab41

Browse files
committed
Apply formatting, filter modes by tick source availability
1 parent fcd7ab9 commit 121ab41

File tree

1 file changed

+39
-29
lines changed

1 file changed

+39
-29
lines changed

platform/features/conductor-v2/conductor/src/ui/TimeConductorController.js

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ define(
4141

4242
this.conductor = conductor;
4343
// Construct the provided time system definitions
44-
this.timeSystems = timeSystems.map(function (timeSystemConstructor){
44+
this._timeSystems = timeSystems.map(function (timeSystemConstructor){
4545
return timeSystemConstructor();
4646
});
4747

@@ -51,20 +51,29 @@ define(
5151
label: 'Fixed',
5252
name: 'Fixed Timespan Mode',
5353
description: 'Query and explore data that falls between two fixed datetimes.'
54-
},
55-
'latest': {
56-
glyph: '\u0044',
57-
label: 'LAD',
58-
name: 'LAD Mode',
59-
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.'
60-
},
61-
'realtime': {
54+
}
55+
};
56+
57+
//Only show 'real-time mode' if a clock source is available
58+
if (this.timeSystemsForSourceType('clock').length > 0 ) {
59+
this.modes['realtime'] = {
6260
glyph: '\u0043',
6361
label: 'Real-time',
6462
name: 'Real-time Mode',
6563
description: 'Monitor real-time streaming data as it comes in. The Time Conductor and displays will automatically advance themselves based on a UTC clock.'
6664
}
67-
};
65+
}
66+
67+
//Only show 'real-time mode' if a clock source is available
68+
if (this.timeSystemsForSourceType('data').length > 0) {
69+
this.modes['latest'] = {
70+
glyph: '\u0044',
71+
label: 'LAD',
72+
name: 'LAD Mode',
73+
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.'
74+
}
75+
}
76+
6877
this.selectedMode = undefined;
6978

7079
this.validation = new TimeConductorValidation(conductor);
@@ -165,6 +174,21 @@ define(
165174
}
166175
};
167176

177+
/**
178+
* @private
179+
*/
180+
TimeConductorController.prototype.timeSystemsForSourceType = function(type){
181+
if (!type) {
182+
return this._timeSystems;
183+
} else {
184+
return this._timeSystems.filter(function (timeSystem){
185+
return timeSystem.tickSources().some(function (tickSource){
186+
return tickSource.type() === type;
187+
});
188+
});
189+
}
190+
};
191+
168192
/**
169193
* Change the selected Time Conductor mode. This will call destroy
170194
* and initialization functions on the relevant modes, setting
@@ -181,27 +205,17 @@ define(
181205
}
182206
switch (newMode) {
183207
case 'fixed':
184-
this.selectedMode = new FixedMode(this.conductor, this.timeSystems);
208+
this.selectedMode = new FixedMode(this.conductor, this._timeSystems);
185209
break;
186210
case 'realtime':
187211
// Filter time systems to only those with clock tick
188212
// sources
189-
var realtimeSystems = this.timeSystems.filter(function (timeSystem){
190-
return timeSystem.tickSources().some(function (tickSource){
191-
return tickSource.type() === 'clock';
192-
});
193-
});
194-
this.selectedMode = new FollowMode(this.conductor, realtimeSystems);
213+
this.selectedMode = new FollowMode(this.conductor, this.timeSystemsForSourceType('clock'));
195214
break;
196215
case 'latest':
197-
// Filter time systems to only those with clock tick
216+
// Filter time systems to only those with data tick
198217
// sources
199-
var ladSystems = this.timeSystems.filter(function (timeSystem){
200-
return timeSystem.tickSources().some(function (tickSource){
201-
return tickSource.type() === 'data';
202-
});
203-
});
204-
this.selectedMode = new FollowMode(this.conductor, ladSystems);
218+
this.selectedMode = new FollowMode(this.conductor, this.timeSystemsForSourceType('data'));
205219
break;
206220
}
207221
this.selectedMode.initialize();
@@ -214,10 +228,6 @@ define(
214228
});
215229

216230
this.setTimeSystem(timeSystem);
217-
/*this.$scope.timeSystemModel.selected = timeSystem;
218-
//Use default format
219-
this.$scope.timeSystemModel.format = timeSystem.formats()[0];
220-
this.setDeltasFromTimeSystem(timeSystem); */
221231
}
222232
};
223233

@@ -248,7 +258,7 @@ define(
248258
* @see TimeConductorController#setTimeSystem
249259
*/
250260
TimeConductorController.prototype.selectTimeSystem = function(key){
251-
var selected = this.timeSystems.find(function (timeSystem){
261+
var selected = this._timeSystems.find(function (timeSystem){
252262
return timeSystem.metadata.key === key;
253263
});
254264
this.setTimeSystem(selected);

0 commit comments

Comments
 (0)