Skip to content

Commit 56ef5af

Browse files
author
Gary Keeble
committed
Open/View Configuration File
Ability to open and view the configuration text file dump.
1 parent c4bc5a2 commit 56ef5af

File tree

4 files changed

+135
-6
lines changed

4 files changed

+135
-6
lines changed

css/main.css

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ html.has-log .log-graph-config {
242242
max-width: 30px;
243243
}
244244

245-
246245
.setup-parameters {
247246
margin:0.5em 0;
248247
}
@@ -332,6 +331,33 @@ html.has-table-overlay .log-field-values {
332331
z-index: 10;
333332
}
334333

334+
html:not(.has-config-overlay) .configuration-file,
335+
html:not(.has-marker) .marker-offset {
336+
display:none;
337+
}
338+
339+
.configuration-file h3 {
340+
background-color: #d9edf7;
341+
margin-top: 2px;
342+
padding: 5px;
343+
}
344+
345+
html.has-config .configuration-file {
346+
position:absolute;
347+
top: 10%;
348+
left: 10%;
349+
width: 78.5%;
350+
padding:10px;
351+
height:580px;
352+
overflow:hidden;
353+
overflow-y:scroll;
354+
background-color: white;
355+
border: #337ab7;
356+
border-style: groove;
357+
z-index: 11;
358+
}
359+
360+
335361
.graph-legend-field {
336362
padding-bottom:0.1em;
337363
margin-bottom:0.3em;
@@ -602,3 +628,13 @@ html:not(.has-log) #status-bar {
602628
visibility: hidden;
603629
cursor: pointer;
604630
}
631+
632+
#status-bar .configuration-file-name {
633+
cursor: pointer;
634+
}
635+
636+
html:not(.has-config) #status-bar .configuration-file-name {
637+
display: none;
638+
}
639+
640+

index.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,9 @@ <h2>Legend <span class="log-close-legend-dialog glyphicon glyphicon-remove"></sp
291291
</table>
292292
</div>
293293

294-
294+
<div class="configuration-file" id="configuration-file">
295+
<!-- auto filled bu configuration function -->
296+
</div>
295297

296298
</div>
297299
<!-- /container -->
@@ -345,6 +347,9 @@ <h2>Legend <span class="log-close-legend-dialog glyphicon glyphicon-remove"></sp
345347
<div class="bookmark-clear">
346348
<span>Clear All</span>
347349
</div>
350+
<div>
351+
<span class="configuration-file-name">-</span>
352+
</div>
348353
</div>
349354

350355
<div class="modal fade" id="dlgGraphConfiguration">
@@ -1121,6 +1126,7 @@ <h4 class="modal-title">Export video</h4>
11211126
<script src="js/video_export_dialog.js"></script>
11221127
<script src="js/flightlog_video_renderer.js"></script>
11231128
<script src="js/graph_config.js"></script>
1129+
<script src="js/configuration.js"></script>
11241130
<script src="js/main.js"></script>
11251131
</body>
11261132
</html>

js/configuration.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
'use strict';
2+
3+
/**
4+
* Configuration
5+
*
6+
* Handle loading and display of configuration file
7+
*
8+
*/
9+
10+
11+
function Configuration(file) {
12+
13+
// Private Variables
14+
var that = this; // generic pointer back to this function
15+
var fileData; // configuration file information
16+
17+
function loadFile(file) {
18+
19+
var reader = new FileReader();
20+
fileData = file; // Store the data locally;
21+
22+
reader.onload = function(e) {
23+
24+
var
25+
configurationElem = ('.configuration-file'), // point to the actual element in index.html
26+
configurationDiv = $('<div class="configuration-file"><h3></h3><ul class="list-unstyled configuration-list"></ul></div>'),
27+
configurationTitle = $('h3', configurationDiv),
28+
configurationList = $('ul', configurationDiv),
29+
li;
30+
31+
var data = e.target.result; // all the data
32+
var lines = data.split('\n'); // separate into lines
33+
34+
for(var i=0; i<lines.length; i++) {
35+
li = $('<li class="configuration-row">' + lines[i] + '</li>');
36+
configurationList.append(li);
37+
}
38+
39+
configurationTitle.text(file.name);
40+
$("#status-bar .configuration-file-name").text(file.name);
41+
42+
// now replace the element in the index.html with the loaded file information
43+
$(configurationElem).replaceWith(configurationDiv);
44+
45+
46+
};
47+
48+
reader.readAsText(file);
49+
}
50+
51+
// Public variables and functions
52+
this.getFile = function() {
53+
return fileData;
54+
};
55+
56+
loadFile(file); // configuration file loaded
57+
58+
}

js/main.js

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ function BlackboxLogViewer() {
2929
currentBlackboxTime = 0,
3030
lastRenderTime = false,
3131
flightLog, flightLogDataArray,
32-
graph = null,
32+
graph = null,
33+
configuration = null, // is their an associated dump file ?
3334

3435
prefs = new PrefStorage(),
3536

@@ -56,6 +57,7 @@ function BlackboxLogViewer() {
5657
hasVideo = false, hasLog = false, hasMarker = false, // add measure feature
5758
hasTable = true, hasCraft = true, hasSticks = true, hasAnalyser, hasAnalyserFullscreen,
5859
hasAnalyserSticks = false, viewVideo = true, hasTableOverlay = false,
60+
hasConfig = false, hasConfigOverlay = false,
5961

6062
isFullscreen = false, // New fullscreen feature (to hide table)
6163

@@ -532,6 +534,20 @@ function BlackboxLogViewer() {
532534
reader.onload = function(e) {
533535
var bytes = e.target.result;
534536

537+
var fileContents = String.fromCharCode.apply(null, new Uint8Array(bytes, 0,100));
538+
539+
if(fileContents.match(/# dump/i)) { // this is actually a configuration file
540+
try{
541+
configuration = new Configuration(file); // the configuration class will actually re-open the file as a text object.
542+
hasConfig = true;
543+
(hasConfig)?$("html").addClass("has-config"):$("html").removeClass("has-config");
544+
} catch(e) {
545+
configuration = null;
546+
hasConfig = false;
547+
}
548+
return;
549+
}
550+
535551
flightLogDataArray = new Uint8Array(bytes);
536552

537553
try {
@@ -691,7 +707,9 @@ function BlackboxLogViewer() {
691707
reader.onload = function(e) {
692708

693709
var data = e.target.result;
694-
workspaceGraphConfigs = JSON.parse(data);
710+
workspaceGraphConfigs = JSON.parse(data);
711+
prefs.set('workspaceGraphConfigs', workspaceGraphConfigs); // Store to local cache
712+
695713
window.alert('Workspaces Loaded')
696714
};
697715

@@ -1113,6 +1131,14 @@ function BlackboxLogViewer() {
11131131
$('#status-bar .bookmark-clear').css('visibility', 'hidden' );
11141132
invalidateGraph();
11151133
});
1134+
1135+
$('#status-bar .configuration-file-name').click(function(e) {
1136+
if(hasConfig) {
1137+
hasConfigOverlay = !hasConfigOverlay;
1138+
(hasConfigOverlay)?$("html").addClass("has-config-overlay"):$("html").removeClass("has-config-overlay");
1139+
}
1140+
e.preventDefault();
1141+
});
11161142

11171143
$(".btn-workspaces-export").click(function(e) {
11181144
setGraphState(GRAPH_STATE_PAUSED);
@@ -1219,8 +1245,11 @@ function BlackboxLogViewer() {
12191245
e.preventDefault();
12201246
break;
12211247

1222-
case "S".charCodeAt(0):
1223-
saveWorkspaces();
1248+
case "C".charCodeAt(0):
1249+
if(hasConfig) {
1250+
hasConfigOverlay = !hasConfigOverlay;
1251+
(hasConfigOverlay)?$("html").addClass("has-config-overlay"):$("html").removeClass("has-config-overlay");
1252+
}
12241253
e.preventDefault();
12251254
break;
12261255

0 commit comments

Comments
 (0)