This repository has been archived by the owner on Jul 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex_fb.html
428 lines (360 loc) · 20.5 KB
/
index_fb.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
<!-- @authors: Michail Vougioukas and Philipp Brummer -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<title>DAQView</title>
<link rel="icon" type="image/png" href="dist/img/cms_logo.png">
<link rel="StyleSheet" href="dist/css/daqview.css" type="text/css"/>
<link rel="StyleSheet" href="dist/css/components/metadata/metadata-table.css" type="text/css"/>
<link rel="StyleSheet" href="dist/css/components/fed-builder/fb-table.css" type="text/css"/>
<link rel="StyleSheet" href="dist/css/components/filter-farm/fff-table.css" type="text/css"/>
<link rel="StyleSheet" href="dist/css/components/metadata/about-table.css" type="text/css"/>
<link rel="StyleSheet" href="dist/css/components/metadata/loader.css" type="text/css"/>
<link rel="StyleSheet" href="dist/css/components/common/snapshot-modal.css" type="text/css"/>
<link rel="StyleSheet" href="dist/lib/daterangepicker/daterangepicker.css" type="text/css"/>
<script type="text/javascript" src="dist/lib/jquery/jquery.min.js"></script>
<script type="text/javascript" src="dist/lib/classnames/index.js"></script>
<script type="text/javascript" src="dist/lib/react/react.min.js"></script>
<script type="text/javascript" src="dist/lib/react/react-dom.min.js"></script>
<script type="text/javascript" src="dist/lib/clipboard/clipboard.min.js"></script>
<script type="text/javascript" src="dist/lib/moment/moment.min.js"></script>
<script type="text/javascript" src="dist/lib/bootstrap/bootstrap.min.js"></script>
<script type="text/javascript" src="dist/lib/daterangepicker/daterangepicker.js"></script>
<script type="text/javascript" src="dist/js/structures/daq-aggregator/daq-snapshot.js"></script>
<script type="text/javascript" src="dist/js/utilities/snapshot-provider.js"></script>
<script type="text/javascript" src="dist/js/utilities/daqview-util.js"></script>
<script type="text/javascript" src="dist/js/utilities/format-util.js"></script>
<script type="text/javascript" src="dist/js/utilities/gui-util.js"></script>
<script type="text/javascript" src="dist/js/utilities/snapshot-randomizer.js"></script>
<script type="text/javascript" src="dist/js/utilities/parser.js"></script>
<script type="text/javascript" src="dist/js/components/common/sorting.js"></script>
<script type="text/javascript" src="dist/js/components/metadata/metadata-table.js"></script>
<script type="text/javascript" src="dist/js/components/metadata/about-table.js"></script>
<script type="text/javascript" src="dist/js/components/metadata/loader-replacement.js"></script>
<script type="text/javascript" src="dist/js/components/common/snapshot-modal.js"></script>
<script type="text/javascript" src="dist/js/components/fed-builder/fb-table.js"></script>
<script type="text/javascript" src="dist/js/components/filter-farm/fff-table.js"></script>
<script type="text/javascript" src="dist/js/daqview.js"></script>
<script type="text/javascript" src="configuration.js"></script>
<script type="text/javascript">
var daqView; //daqView is an object containing an array of the created views (page components)
$(document).ready(function () {
try {
// HACK: to avoid browser errors when loading local JSON
$.ajaxSetup({
beforeSend: function (xhr) {
if (xhr.overrideMimeType) {
xhr.overrideMimeType("application/json");
}
}
});
var parser = new DAQAggregator.SnapshotParser();
var ruWarningsResolver = new DAQAggregator.RUWarnMessageAggregator();
var ruMaskedCounter = new DAQAggregator.RUMaskedCounter();
var buNoRateCounter = new DAQAggregator.BUNoRateCounter();
//URL query part parser, to be used for the first page load URL
var queryString = function () {
// This function is anonymous, is executed immediately and
// the return value is assigned to QueryString!
var query_string = {};
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
// If first entry with this name
if (typeof query_string[pair[0]] === "undefined") {
query_string[pair[0]] = decodeURIComponent(pair[1]);
// If second entry with this name
} else if (typeof query_string[pair[0]] === "string") {
var arr = [ query_string[pair[0]],decodeURIComponent(pair[1]) ];
query_string[pair[0]] = arr;
// If third or later entry with this name
} else {
query_string[pair[0]].push(decodeURIComponent(pair[1]));
}
}
return query_string;
}();
//if setup parameter is found, set data source accordingly
var daqSetup = queryString.setup;
if (typeof queryString.setup != 'undefined'){
console.log("page loaded with 'setup' parameter(s): "+queryString.setup);
daqSetup = queryString.setup;
}else{
daqSetup = 'cdaq'; //default value for setup
}
var counter = 0;
var timeStampAtDec2 = 1480678707956;
// var debugSnapshotSource = false;
var developmentPlayback = false;
if (daqSetup == "playbackcdaq"){
//debugSnapshotSource = false;
daqSetup = 'cdaq'; //revert to cdaq, but in dev eyets 16 playback mode (only real-time)
developmentPlayback = true;
}
var daqViewConfiguration = {
snapshotSource: snapshotSources,
daqviewLinks: daqviewLinks,
externalLinks: externalLinks,
expertSetups: expertSetups,
setupName: daqSetup
};
daqView = new DAQView.DAQViewReact(daqViewConfiguration);
daqView.createMetadataTable('daqview-react-metadata-table');
daqView.createFBTable('daqview-react-fb-table');
daqView.createAboutTable('daqview-react-about-table');
daqView.createSnapshotModal('daqview-react-snapshot-modal');
//daqView.createReplacementForLoader('loaderWrapper'); //implement a blank div to replace the loader when react has finished
var snapshotSource = {
updateInterval: 1500,
getSourceURL: function () {
var baseURL = snapshotSources.url+'?setup='+daqSetup; //data source URL
var timestampDelim = '"';
//production timestamp
var currentTime = new Date(new Date().getTime()).toISOString();
//simulated timestamp that counts from Dec 2 2016 for development in EYETS (3 days of aggregated data)
if (developmentPlayback) {
currentTime = new Date(timeStampAtDec2 + (counter * this.updateInterval)).toISOString();
counter++;
}
var ret = baseURL; //+ timestampDelim + currentTime + timestampDelim;
return ret;
},
getSourceURLForGotoRequests: function () {
var baseURL = snapshotSources.url+'?setup='+daqSetup+'&time=';
var timestampDelim = '"';
var currentLocalTime = goToTimeInput.val();
var timestamp = moment(currentLocalTime);
var currentTime = '';
if (timestamp.isValid()){
currentTime = timestamp.toISOString();
}
var ret = baseURL + timestampDelim + currentTime + timestampDelim;
return ret;
},
getRequestSetup: function() {
return daqSetup;
},
currentSnapshotTimestamp: -1,
runInfoTimelineLink: function(){
return externalLinks.runInfoTimeline;
},
parseSnapshot: (function (snapshot) {
console.log(snapshot);
//parse original snapshot
snapshot = parser.parse.bind(parser)(snapshot);
if (snapshot == null){
return null;
}
//pass it through chain of preprocessors
snapshot = ruWarningsResolver.resolveRUWarnings.bind(ruWarningsResolver)(snapshot);
snapshot = ruMaskedCounter.countMaskedRUs.bind(ruMaskedCounter)(snapshot);
snapshot = buNoRateCounter.countNoRateBUs.bind(buNoRateCounter)(snapshot);
//DAQAggregator.randomizeSnapshot(snapshot, 20); //randomizes snapshot values
return snapshot;
}).bind(window)
};
var snapshotProvider = new DAQAggregator.SnapshotProvider(snapshotSource);
snapshotProvider.addView(daqView);
snapshotProvider.start();
var controlPauseResume = $('.daqview-control-pause-resume');
controlPauseResume.on('click', function () {
//the provider will also stop itself if a go-to-time request is received
//this button's appearance is set accordingly (displays 'play') by the event handler of the go-to-time button
if (snapshotProvider.isRunning()) {
snapshotProvider.provideOneMoreSnapshotAndStop(0); //calling with arg 0 will just redraw previous snapshot with the paused_page color scheme, then stop updating
$(this).prop('src', 'dist/img/play.png');
} else {
//if pause was due to a go-to-time request, then restarting also resets mode to realtime
if (!snapshotProvider.inRealTimePolling){
snapshotProvider.switchToRealTime();
}
snapshotProvider.start();
$(this).prop('src', 'dist/img/pause.png');
}
});
var goToTime = function () {
snapshotProvider.switchToGotoTimeRequests();
snapshotProvider.provideOneMoreSnapshotAndStop(1); //calling with arg 1 will draw the requested snapshot with the paused_page color scheme, then stop updating
//useful when requesting a go-to-time timestamp in daqview=paused state
if (!snapshotProvider.isRunning()){
snapshotProvider.start();
}
//updating play/pause button, because point queries essentially stop real-time monitoring
//the provider will stop itself once a gototime request is received (after providing this last snapshot)
$('.daqview-control-pause-resume').prop('src', 'dist/img/play.png');
};
var goToTimeInput = $('#daqview-go-to-time-input');
goToTimeInput.val(moment().format("YYYY-MM-DD HH:mm:ss"));
goToTimeInput.daterangepicker({
"singleDatePicker": true,
"timePicker": true,
"timePicker24Hour": true,
"timePickerSeconds": true,
"autoUpdateInput": false,
"locale": {
"format": "YYYY-MM-DD HH:mm:ss",
"applyLabel": "Load"
},
"parentEl": $('.daqview-top-row'),
startDate: moment(),
endDate: moment()
});
goToTimeInput.on('apply.daterangepicker', function(ev, picker) {
goToTimeInput.val(picker.startDate.format("YYYY-MM-DD HH:mm:ss"));
goToTime();
});
goToTimeInput.keypress(function(e) {
if(e.which === 13) {
goToTime();
}
});
var controlGoToTime = $('.daqview-go-to-time');
controlGoToTime.on('click', goToTime);
var mapOfMonths =
{
"Jan" : "01",
"Feb" : "02",
"Mar" : "03",
"Apr" : "04",
"May" : "05",
"Jun" : "06",
"Jul" : "07",
"Aug" : "08",
"Sep" : "09",
"Oct" : "10",
"Nov" : "11",
"Dec" : "12"
};
var formatLocalDate = function(newDateTargetInMillis){
var localTimestampElements = (new Date(newDateTargetInMillis).toString()).split(" ");
//keep Month, Day, Year, Time (discard Weekday and timezone info)
var formattedLocalTimestamp = localTimestampElements[3]+"-"+mapOfMonths[localTimestampElements[1]]+"-"+localTimestampElements[2]+" "+localTimestampElements[4];
return formattedLocalTimestamp;
};
//if time parameter is found, then this request should return a static display at the requested timestamp
if (typeof queryString.time != 'undefined'){
console.log("page loaded with 'time' parameter(s): "+queryString.time);
var newDateTargetInMillis = moment(queryString.time, "YYYY-MM-DD-HH-mm-ss").valueOf();
var newDateTargetFormatted = formatLocalDate(newDateTargetInMillis);
goToTimeInput.val(newDateTargetFormatted);
goToTimeInput.data('daterangepicker').setStartDate(newDateTargetFormatted);
goToTimeInput.data('daterangepicker').setEndDate(newDateTargetFormatted);
goToTime();
}
var controlPlus = $('.daqview-go-to-time-add');
var controlMinus = $('.daqview-go-to-time-subtract');
controlPlus.on('click', function(){
var newDateTargetInMillis = snapshotSource.currentSnapshotTimestamp + 1000*($('#daqview-nav-step-input').val());
var newDateTargetFormatted = formatLocalDate(newDateTargetInMillis);
goToTimeInput.val(newDateTargetFormatted);
goToTimeInput.data('daterangepicker').setStartDate(newDateTargetFormatted);
goToTimeInput.data('daterangepicker').setEndDate(newDateTargetFormatted);
goToTime();
});
controlMinus.on('click', function(){
var newDateTargetInMillis = snapshotSource.currentSnapshotTimestamp - 1000*($('#daqview-nav-step-input').val());
var newDateTargetFormatted = formatLocalDate(newDateTargetInMillis);
goToTimeInput.val(newDateTargetFormatted);
goToTimeInput.data('daterangepicker').setStartDate(newDateTargetFormatted);
goToTimeInput.data('daterangepicker').setEndDate(newDateTargetFormatted);
goToTime();
});
// setting values in links of the upper left corner
var getCurrentLinkParameters = function() {
var parameters = "?setup=" + daqSetup;
if (!snapshotProvider.isInRealTimePolling() || !snapshotProvider.isRunning()) {
parameters += "&time=" + formatLocalDate(snapshotSource.currentSnapshotTimestamp);
}
return parameters;
};
$('#dvhomelink').attr("href", daqviewLinks.controller);
$('#dvalllink').on('click', function () {
$(this).attr("href", daqviewLinks.base_all + getCurrentLinkParameters());
});
$('#dvffflink').on('click', function () {
$(this).attr("href", daqviewLinks.base_fff + getCurrentLinkParameters());
});
$('#dvfbdtlink').on('click', function () {
$(this).attr("href", daqviewLinks.base_fbdt + getCurrentLinkParameters());
});
}
catch (exception) {
console ? (console.debug ? console.debug(exception) : console.log(exception)) : alert(exception);
}
var clipboard = new Clipboard('.button-share', {
text : function() {
return DAQViewGUIUtility.getSharableLink();
}
});
clipboard.on('success', function(e) {
setTooltip(e.trigger, 'Link copied!');
hideTooltip(e.trigger);
});
clipboard.on('error', function(e) {
setTooltip(e.trigger, 'Failed!');
hideTooltip(e.trigger);
});
function setTooltip(btn, message) {
$(btn).html(message);
}
function hideTooltip(btn) {
setTimeout(function() {
$(btn).html("Share");
}, 1000);
}
});
</script>
</head>
<body>
<div id="daqview-react">
<br/><br/>
<table style="width:100%" class="daqview-top-row">
<tr>
<td width="20%" align="left" valign="center">
<a href="" id="dvhomelink" target="_blank"><button class="daqview-external-link">DAQView Home</button></a>
<a href="" id="dvalllink" target="_blank"><button class="daqview-external-link">All Tables</button></a>
<a href="" id="dvffflink" target="_blank"><button class="daqview-external-link">FFF Table</button></a>
<a href="" id="dvfbdtlink" target="_blank"><button class="daqview-external-link">FB+DT Table</button></a>
</td>
<td width="20%" align="right" valign="center">
<div id="daqview-control">
<input type="image" class="daqview-control-pause-resume" src="dist/img/pause.png" alt="pause/resume"
title="pause/resume"/>
</div>
</td>
<td width="20%" align="center" valign="center">
<div id="daqview-time-navigation-prevnext">
<input type="image" class="daqview-go-to-time-subtract" src="dist/img/previous.png" alt="minus-time"
title="minus-time"/>
<input type="text" placeholder="sec" value="3" id="daqview-nav-step-input" class="daqview-nav-step-input-class">
<input type="image" class="daqview-go-to-time-add" src="dist/img/next.png" alt="plus-time"
title="plus-time"/>
</div>
</td>
<td width="20%" align="center" valign="center">
<div id="daqview-time-navigation-goto">
<input type="text" placeholder="click to select" id="daqview-go-to-time-input">
<input type="submit" value="Go to time" class="daqview-go-to-time">
</div>
</td>
<td width="20%" align="right" valign="bottom"/>
</tr>
</table>
<table style="width:100%">
<tr>
<td width="20%" align="right" valign="bottom"><div id="daqview-react-snapshot-modal"></div></td>
</tr>
</table>
<div id="daqview-react-metadata-table"></div>
<p></p>
<div id="daqview-react-fb-table"></div>
<br/><br/>
<div id="daqview-react-about-table"><div class="loader"></div></div>
<br/><br/>
<div class="daqview-version-id">Version {[DAQVIEW_VERSION]}</div>
</div>
</body>
</html>