23
23
define (
24
24
[
25
25
'./modes/FixedMode' ,
26
- './modes/RealtimeMode' ,
27
- './modes/LADMode' ,
26
+ './modes/FollowMode' ,
28
27
'./TimeConductorValidation'
29
28
] ,
30
- function ( FixedMode , RealtimeMode , LADMode , TimeConductorValidation ) {
29
+ function ( FixedMode , FollowMode , TimeConductorValidation ) {
31
30
32
31
function TimeConductorController ( $scope , conductor , timeSystems ) {
33
32
@@ -45,12 +44,28 @@ define(
45
44
this . timeSystems = timeSystems . map ( function ( timeSystemConstructor ) {
46
45
return timeSystemConstructor ( ) ;
47
46
} ) ;
48
- // Populate a list of modes supported by the time conductor
49
- this . modes = [
50
- new FixedMode ( this . conductor , this . timeSystems ) ,
51
- new RealtimeMode ( this . conductor , this . timeSystems ) ,
52
- new LADMode ( this . conductor , this . timeSystems )
53
- ] ;
47
+
48
+ this . modes = {
49
+ 'fixed' : {
50
+ glyph : '\ue604' ,
51
+ label : 'Fixed' ,
52
+ name : 'Fixed Timespan Mode' ,
53
+ 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' : {
62
+ glyph : '\u0043' ,
63
+ label : 'Real-time' ,
64
+ name : 'Real-time Mode' ,
65
+ description : 'Monitor real-time streaming data as it comes in. The Time Conductor and displays will automatically advance themselves based on a UTC clock.'
66
+ }
67
+ } ;
68
+ this . selectedMode = undefined ;
54
69
55
70
this . validation = new TimeConductorValidation ( conductor ) ;
56
71
this . $scope = $scope ;
@@ -63,14 +78,14 @@ define(
63
78
64
79
//Set the time conductor mode to the first one in the list,
65
80
// effectively initializing the time conductor
66
- this . setMode ( this . modes [ 0 ] ) ;
81
+ this . setMode ( 'fixed' ) ;
67
82
}
68
83
69
84
/**
70
85
* @private
71
86
*/
72
87
TimeConductorController . prototype . initializeScope = function ( $scope ) {
73
-
88
+ var self = this ;
74
89
/*
75
90
Represents the various time system options, and the currently
76
91
selected time system in the view. Additionally holds the
@@ -87,7 +102,7 @@ define(
87
102
selected mode in the view
88
103
*/
89
104
$scope . modeModel = {
90
- selected : undefined ,
105
+ selectedKey : undefined ,
91
106
options : this . modes
92
107
} ;
93
108
/*
@@ -98,13 +113,12 @@ define(
98
113
end : 0
99
114
} ;
100
115
101
- $scope . $watch ( 'modeModel.selected ' , this . setMode ) ;
116
+ $scope . $watch ( 'modeModel.selectedKey ' , this . setMode ) ;
102
117
$scope . $watch ( 'timeSystem' , this . setTimeSystem ) ;
103
118
104
119
$scope . $on ( '$destroy' , function ( ) {
105
- var mode = $scope . modeModel . selected ;
106
- if ( mode && mode . destroy ) {
107
- mode . destroy ( ) ;
120
+ if ( self . selectedMode ) {
121
+ self . selectedMode . destroy ( ) ;
108
122
}
109
123
} ) ;
110
124
} ;
@@ -142,7 +156,7 @@ define(
142
156
* @see TimeConductorMode
143
157
*/
144
158
TimeConductorController . prototype . updateDeltasFromForm = function ( formModel ) {
145
- var mode = this . $scope . modeModel . selected ,
159
+ var mode = this . selectedMode ,
146
160
deltas = mode . deltas ( ) ;
147
161
148
162
if ( deltas !== undefined && this . validation . validateDeltas ( formModel ) ) {
@@ -160,17 +174,42 @@ define(
160
174
*/
161
175
TimeConductorController . prototype . setMode = function ( newMode , oldMode ) {
162
176
if ( newMode !== oldMode ) {
163
- if ( oldMode ) {
164
- oldMode . destroy ( ) ;
165
- }
166
- newMode . initialize ( ) ;
177
+ this . $scope . modeModel . selectedKey = newMode ;
167
178
168
- var timeSystem = newMode . selectedTimeSystem ( ) ;
179
+ if ( this . selectedMode ) {
180
+ this . selectedMode . destroy ( ) ;
181
+ }
182
+ switch ( newMode ) {
183
+ case 'fixed' :
184
+ this . selectedMode = new FixedMode ( this . conductor , this . timeSystems ) ;
185
+ break ;
186
+ case 'realtime' :
187
+ // Filter time systems to only those with clock tick
188
+ // 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 ) ;
195
+ break ;
196
+ case 'latest' :
197
+ // Filter time systems to only those with clock tick
198
+ // 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 ) ;
205
+ break ;
206
+ }
207
+ this . selectedMode . initialize ( ) ;
169
208
170
- this . $scope . modeModel . selected = newMode ;
209
+ var timeSystem = this . selectedMode . selectedTimeSystem ( ) ;
171
210
172
211
//Synchronize scope with time system on mode
173
- this . $scope . timeSystemModel . options = newMode . timeSystems ( ) . map ( function ( timeSystem ) {
212
+ this . $scope . timeSystemModel . options = this . selectedMode . timeSystems ( ) . map ( function ( timeSystem ) {
174
213
return timeSystem . metadata ;
175
214
} ) ;
176
215
this . $scope . timeSystemModel . selected = timeSystem ;
@@ -221,7 +260,7 @@ define(
221
260
TimeConductorController . prototype . setTimeSystem = function ( newTimeSystem ) {
222
261
if ( newTimeSystem && newTimeSystem !== this . $scope . timeSystemModel . selected ) {
223
262
this . $scope . timeSystemModel . selected = newTimeSystem ;
224
- var mode = this . $scope . modeModel . selected ;
263
+ var mode = this . selectedMode ;
225
264
mode . selectedTimeSystem ( newTimeSystem ) ;
226
265
this . setDeltasFromTimeSystem ( newTimeSystem ) ;
227
266
}
0 commit comments