-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsampleVisualiser.js
42 lines (30 loc) · 1.37 KB
/
sampleVisualiser.js
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
var SampleVisualiser = function(rubikVisualiser) {
var MAX_COLUMNS = 1;
var sampleInfoDiv = rubikVisualiser.createNewColumn();
sampleInfoDiv.addClass('small'); // add small or medium to indicate how wide the column for this is
sampleInfoDiv.hide();
// This will be called every time the 'sample' websocket receives data
function processNewDataSample(data) {
if(data.warning) {
return;
}
sampleInfoDiv.show();
sampleInfoDiv.empty();
$('<div class="category horizontal"><div>SAMPLE INFO</div></div>').appendTo(sampleInfoDiv);
// Example: What to do if your server data is organised by environment keys
// { test: { ... }, qa: { ... }
_.each(_.keys(data), function(envIdentifier) {
function createSampleInfoBox(outerBox, environmentData, environmentDataKey) {
var environmentValue = environmentData[environmentDataKey];
$('<div>' + environmentValue + '</div>').appendTo(outerBox);
outerBox.addClass('blue');
}
rubikVisualiser.createRowsOfBoxesForEnvironment(sampleInfoDiv, data, envIdentifier, createSampleInfoBox, MAX_COLUMNS);
});
}
// Add visualisation to main.js like this, and it will be connected to sampleReader data:
// new DataSource('sample', SampleVisualiser(rubikVis).processNewData, onConnectionLost, onDataError);
return {
processNewData: processNewDataSample
};
};