From fa03ca5bc4317b34a30462c990b24451b59bd00b Mon Sep 17 00:00:00 2001 From: demvlad Date: Fri, 31 May 2024 00:10:17 +0300 Subject: [PATCH 1/9] resolved issue of load default workspace configuration --- src/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index d0d91c00..80dbce74 100644 --- a/src/main.js +++ b/src/main.js @@ -1084,7 +1084,7 @@ function BlackboxLogViewer() { }); workspaceSelection = new WorkspaceSelection($(".log-workspace-selection"), workspaceGraphConfigs, onSwitchWorkspace, onSaveWorkspace); - onSwitchWorkspace(workspaceGraphConfigs, workspaceSelection); + onSwitchWorkspace(workspaceGraphConfigs, activeWorkspace); prefs.get('log-legend-hidden', function(item) { if (item) { From d5897e3098077e660c5b8341d7014bfa2e8dbc50 Mon Sep 17 00:00:00 2001 From: Vladimir Demidov Date: Fri, 31 May 2024 16:14:14 +0300 Subject: [PATCH 2/9] The onSwitchWorkspace function call optimization --- src/main.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main.js b/src/main.js index 80dbce74..c507c3b5 100644 --- a/src/main.js +++ b/src/main.js @@ -2177,8 +2177,6 @@ function BlackboxLogViewer() { } else { workspaceGraphConfigs = defaultWorkspaceGraphConfigs; } - - onSwitchWorkspace(workspaceGraphConfigs, activeWorkspace); }); prefs.get('activeWorkspace', function (id){ @@ -2188,9 +2186,8 @@ function BlackboxLogViewer() { else { activeWorkspace = 1 } - - onSwitchWorkspace(workspaceGraphConfigs, activeWorkspace); }); + onSwitchWorkspace(workspaceGraphConfigs, activeWorkspace); // Get the offsetCache buffer prefs.get('offsetCache', function(item) { From b13d83e714d57b3ca64d5fa19c3cd3a425a03220 Mon Sep 17 00:00:00 2001 From: Vladimir Demidov Date: Fri, 31 May 2024 16:32:41 +0300 Subject: [PATCH 3/9] Resolved issue: GraphConfig load error by first programm run --- src/main.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.js b/src/main.js index c507c3b5..061f22dc 100644 --- a/src/main.js +++ b/src/main.js @@ -2163,11 +2163,11 @@ function BlackboxLogViewer() { }); prefs.get('graphConfig', function(item) { - graphConfig = GraphConfig.load(item); - - if (!graphConfig && flightLog) { + if (item) { + graphConfig = GraphConfig.load(item); + } else if (flightLog) { graphConfig = GraphConfig.getExampleGraphConfigs(flightLog, ["Motors", "Gyros"]); - } + } }); // New workspaces feature; local storage of user configurations From 4d28bf606e973e84e6fe1f344e11aeb9b50f7e04 Mon Sep 17 00:00:00 2001 From: demvlad Date: Fri, 31 May 2024 18:43:45 +0300 Subject: [PATCH 4/9] resolved error of loading undefined stored graph config data by first program run --- src/main.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main.js b/src/main.js index 061f22dc..d5b10813 100644 --- a/src/main.js +++ b/src/main.js @@ -90,7 +90,7 @@ function BlackboxLogViewer() { videoConfig = {}, // JSON graph configuration: - graphConfig = {}, + graphConfig = null, offsetCache = [], // Storage for the offset cache (last 20 files) currentOffsetCache = {log:null, index:null, video:null, offset:null}, @@ -782,6 +782,10 @@ function BlackboxLogViewer() { alert("Sorry, an error occurred while trying to open this log:\n\n" + err); return; } + + if (!graphConfig) { + graphConfig = GraphConfig.getExampleGraphConfigs(flightLog, ["Motors", "Gyros"]); + } renderLogFileInfo(file); renderSeekBarPicker(); @@ -2165,9 +2169,7 @@ function BlackboxLogViewer() { prefs.get('graphConfig', function(item) { if (item) { graphConfig = GraphConfig.load(item); - } else if (flightLog) { - graphConfig = GraphConfig.getExampleGraphConfigs(flightLog, ["Motors", "Gyros"]); - } + } }); // New workspaces feature; local storage of user configurations From 279163da167912e2a79c3717d3c921c715d3dc9d Mon Sep 17 00:00:00 2001 From: demvlad Date: Fri, 31 May 2024 19:14:19 +0300 Subject: [PATCH 5/9] Code style improvement --- src/main.js | 318 ++++++++++++++++++++++++++-------------------------- 1 file changed, 158 insertions(+), 160 deletions(-) diff --git a/src/main.js b/src/main.js index d5b10813..3484ea1a 100644 --- a/src/main.js +++ b/src/main.js @@ -59,7 +59,7 @@ function BlackboxLogViewer() { alert("Your browser does not support the APIs required for reading log files."); } - var + let GRAPH_STATE_PAUSED = 0, GRAPH_STATE_PLAY = 1, @@ -73,7 +73,7 @@ function BlackboxLogViewer() { GRAPH_DEFAULT_ZOOM = 100, GRAPH_ZOOM_STEP = 1; - var + let graphState = GRAPH_STATE_PAUSED, currentBlackboxTime = 0, lastRenderTime = false, @@ -196,7 +196,7 @@ function BlackboxLogViewer() { } function updateValuesChart() { - var + let table = $(".log-field-values table"), i, frame = flightLog.getSmoothedFrameAtTime(currentBlackboxTime), @@ -206,16 +206,16 @@ function BlackboxLogViewer() { if (frame) { - var currentFlightMode = frame[flightLog.getMainFieldIndexByName("flightModeFlags")]; + let currentFlightMode = frame[flightLog.getMainFieldIndexByName("flightModeFlags")]; - if(hasTable || hasTableOverlay) { // Only redraw the table if it is enabled + if (hasTable || hasTableOverlay) { // Only redraw the table if it is enabled - var + let rows = [], rowCount = Math.ceil(fieldNames.length / 2); for (i = 0; i < rowCount; i++) { - var + let row = "" + '' + fieldPresenter.fieldNameToFriendly(fieldNames[i], flightLog.getSysConfig().debug_mode) + '' + @@ -243,7 +243,7 @@ function BlackboxLogViewer() { $("tr:not(:first)", statsTable).remove(); const stats = SimpleStats(flightLog).calculate(); const tpl = _.template("<%= name %><%= min %> (<%= min_raw %>)<%= max %> (<%= max_raw %>)<%= mean %> (<%= mean_raw %>)"); - for (const field in stats) { + for (const field of stats) { const stat = stats[field]; if (stat === undefined) { continue; @@ -268,12 +268,12 @@ function BlackboxLogViewer() { // update time field on status bar $(".graph-time").val(formatTime((currentBlackboxTime-flightLog.getMinTime())/1000, true)); - if(hasMarker) { + if (hasMarker) { $(".marker-offset", statusBar).text('Marker Offset ' + formatTime((currentBlackboxTime-markerTime)/1000, true) + 'ms ' + (1000000/(currentBlackboxTime-markerTime)).toFixed(0) + "Hz"); } // Update the Legend Values - if(graphLegend) graphLegend.updateValues(flightLog, frame); + if (graphLegend) graphLegend.updateValues(flightLog, frame); } } @@ -282,7 +282,7 @@ function BlackboxLogViewer() { function animationLoop() { - var + let now = Date.now(); if (!graph) { @@ -293,7 +293,7 @@ function BlackboxLogViewer() { if (hasVideo) { currentBlackboxTime = blackboxTimeFromVideoTime(); } else if (graphState == GRAPH_STATE_PLAY) { - var + let delta; if (lastRenderTime === false) { @@ -344,14 +344,14 @@ function BlackboxLogViewer() { } function updateCanvasSize() { - var + let width = $(canvas).width(), height = $(canvas).height(); if (graph) { graph.resize(width, height); seekBar.resize(canvas.offsetWidth, 50); - if(flightLog.hasGpsData()) { + if (flightLog.hasGpsData()) { mapGrapher.resize(width, height); } @@ -360,7 +360,7 @@ function BlackboxLogViewer() { } function renderSeekBarPicker(){ - var + let seekBarContainer = $(".seekBar-selection"), seekBarPicker, seekBarItems = [ @@ -378,9 +378,8 @@ function BlackboxLogViewer() { seekBar.setActivity(activity.times, activity[displayItem], activity.hasEvent); seekBar.repaint(); }); - for (let item of seekBarItems) { - let option; - option = $(""); + for (const item of seekBarItems) { + const option = $(""); option.text(item[1]); option.attr("value", item[0]); seekBarPicker.append(option); @@ -392,11 +391,10 @@ function BlackboxLogViewer() { function renderLogFileInfo(file) { $(".log-filename").text(file.name); - var + let logIndexContainer = $(".log-index"), logIndexPicker, - logCount = flightLog.getLogCount(), - index; + logCount = flightLog.getLogCount(); logIndexContainer.empty(); @@ -405,14 +403,14 @@ function BlackboxLogViewer() { logIndexPicker.change(function() { selectLog(parseInt($(this).val(), 10)); - if(graph) { + if (graph) { (hasAnalyserFullscreen)?html.addClass("has-analyser-fullscreen"):html.removeClass("has-analyser-fullscreen"); graph.setAnalyser(hasAnalyserFullscreen); } }); } - for (index = 0; index < logCount; index++) { + for (let index = 0; index < logCount; index++) { let logLabel, option, holder, @@ -477,7 +475,7 @@ function BlackboxLogViewer() { **/ // Add log version information to status bar - var sysConfig = flightLog.getSysConfig(); + let sysConfig = flightLog.getSysConfig(); $('.version', statusBar).text( ((sysConfig['Craft name']!=null)?(sysConfig['Craft name'] + ' : '):'') + ((sysConfig['Firmware revision']!=null)?(sysConfig['Firmware revision']):'')); $('.looptime', statusBar).text( stringLoopTime(sysConfig.looptime, sysConfig.pid_process_denom, sysConfig.unsynced_fast_pwm, sysConfig.motor_pwm_rate)); @@ -486,7 +484,7 @@ function BlackboxLogViewer() { seekBar.setTimeRange(flightLog.getMinTime(), flightLog.getMaxTime(), currentBlackboxTime); seekBar.setActivityRange(flightLog.getSysConfig().motorOutput[0], flightLog.getSysConfig().motorOutput[1]); - var + let activity = flightLog.getActivitySummary(); seekBar.setActivity(activity.times, activity[seekBarMode], activity.hasEvent); @@ -494,7 +492,7 @@ function BlackboxLogViewer() { // Add flightLog to map html.toggleClass("has-gps", flightLog.hasGpsData()); - if(flightLog.hasGpsData()) { + if (flightLog.hasGpsData()) { mapGrapher.setUserSettings(userSettings); mapGrapher.setFlightLog(flightLog); } @@ -503,7 +501,7 @@ function BlackboxLogViewer() { function setGraphState(newState) { graphState = newState; - var btnLogPlayPause = $(".log-play-pause"); + let btnLogPlayPause = $(".log-play-pause"); lastRenderTime = false; @@ -607,8 +605,8 @@ function BlackboxLogViewer() { } function showConfigFile(state) { - if(hasConfig) { - if(state == null) { // no state specified, just toggle + if (hasConfig) { + if (state == null) { // no state specified, just toggle hasConfigOverlay = !hasConfigOverlay; } else { //state defined, just set item hasConfigOverlay = (state)?true:false; @@ -618,7 +616,7 @@ function BlackboxLogViewer() { } function showValueTable(state) { - if(state == null) { // no state specified, just toggle + if (state == null) { // no state specified, just toggle hasTableOverlay = !hasTableOverlay; } else { //state defined, just set item hasTableOverlay = (state)?true:false; @@ -632,12 +630,12 @@ function BlackboxLogViewer() { * available log. */ function selectLog(logIndex) { - var + let success = false; try { if (logIndex === null) { - for (var i = 0; i < flightLog.getLogCount(); i++) { + for (let i = 0; i < flightLog.getLogCount(); i++) { if (flightLog.openLog(i)) { success = true; currentOffsetCache.index = i; @@ -709,56 +707,56 @@ function BlackboxLogViewer() { } function loadFiles(files) { - for (var i = 0; i < files.length; i++) { - var - isLog = files[i].name.match(/\.(BBL|TXT|CFL|BFL|LOG)$/i), - isVideo = files[i].name.match(/\.(AVI|MOV|MP4|MPEG)$/i), - isWorkspaces = files[i].name.match(/\.(JSON)$/i); + for (const file of files) { + let + isLog = file.name.match(/\.(BBL|TXT|CFL|BFL|LOG)$/i), + isVideo = file.name.match(/\.(AVI|MOV|MP4|MPEG)$/i), + isWorkspaces = file.name.match(/\.(JSON)$/i); - loadFileMessage(files[i].name); + loadFileMessage(file.name); if (!isLog && !isVideo && !isWorkspaces) { - if (files[i].size < 10 * 1024 * 1024) + if (file.size < 10 * 1024 * 1024) isLog = true; //Assume small files are logs rather than videos else isVideo = true; } if (isLog) { - loadLogFile(files[i]); + loadLogFile(file); } else if (isVideo) { - loadVideo(files[i]); + loadVideo(file); } else if (isWorkspaces) { - loadWorkspaces(files[i]) + loadWorkspaces(file) } } // finally, see if there is an offsetCache value already, and auto set the offset - for(i=0; iStored defaults for all pens'; } - if(graph!=null && field!=null) { // restore single pen - if(graphConfig[parseInt(graph)].fields[parseInt(field)].default==null) { + if (graph!=null && field!=null) { // restore single pen + if (graphConfig[parseInt(graph)].fields[parseInt(field)].default==null) { graphConfig[parseInt(graph)].fields[parseInt(field)].default = []; graphConfig[parseInt(graph)].fields[parseInt(field)].default.smoothing = graphConfig[parseInt(graph)].fields[parseInt(field)].smoothing; graphConfig[parseInt(graph)].fields[parseInt(field)].default.power = graphConfig[parseInt(graph)].fields[parseInt(field)].curve.power; @@ -1591,19 +1589,19 @@ function BlackboxLogViewer() { * field is the actual pen to change, null means all pens within group */ - if(graph==null && field==null) return false; // no pen specified, just exit + if (graph==null && field==null) return false; // no pen specified, just exit - if(graph!=null && field==null) { // restore ALL pens within group - for(var i=0; iRestored defaults for all pens'; } - if(graph!=null && field!=null) { // restore single pen - if(graphConfig[parseInt(graph)].fields[parseInt(field)].default!=null) { + if (graph!=null && field!=null) { // restore single pen + if (graphConfig[parseInt(graph)].fields[parseInt(field)].default!=null) { graphConfig[parseInt(graph)].fields[parseInt(field)].smoothing = graphConfig[parseInt(graph)].fields[parseInt(field)].default.smoothing; graphConfig[parseInt(graph)].fields[parseInt(field)].curve.power = graphConfig[parseInt(graph)].fields[parseInt(field)].default.power; return '

Restored defaults for single pen

'; @@ -1623,20 +1621,20 @@ function BlackboxLogViewer() { const range = { min:0, max:10000 }; // actually in milliseconds! const scroll = 1000; // actually in milliseconds - if(graph==null && field==null) return false; // no pen specified, just exit + if (graph==null && field==null) return false; // no pen specified, just exit savePenDefaults(graphConfig, graph, field); // only updates defaults if they are not already set - var changedValue = '

Smoothing

'; - if(graph!=null && field==null) { // change ALL pens within group - for(var i=0; i=0)) @@ -1787,7 +1785,7 @@ function BlackboxLogViewer() { e.preventDefault(); } - if(refreshRequired) { + if (refreshRequired) { graph.refreshGraphConfig(); invalidateGraph(); mouseNotification.show($('.log-graph'), null, null, refreshRequired, 750, null, 'bottom-right', 0); @@ -1803,8 +1801,8 @@ function BlackboxLogViewer() { // Pressing any key hides dropdown menus //$(".dropdown-toggle").dropdown("toggle"); - var shifted = (e.altKey || e.shiftKey || e.ctrlKey || e.metaKey); - if(e.which === 13 && e.target.type === 'text' && $(e.target).parents('.modal').length == 0) { + let shifted = (e.altKey || e.shiftKey || e.ctrlKey || e.metaKey); + if (e.which === 13 && e.target.type === 'text' && $(e.target).parents('.modal').length == 0) { // pressing return on a text field clears the focus. $(e.target).blur(); } @@ -1854,7 +1852,7 @@ function BlackboxLogViewer() { case "A".charCodeAt(0): if(!(shifted)) { - if(activeGraphConfig.selectedFieldName != null) { + if (activeGraphConfig.selectedFieldName != null) { hasAnalyser = !hasAnalyser; } else hasAnalyser = false; graph.setDrawAnalyser(hasAnalyser); @@ -1863,7 +1861,7 @@ function BlackboxLogViewer() { invalidateGraph(); e.preventDefault(); } else { // Maximize - if(hasAnalyser) { + if (hasAnalyser) { hasAnalyserFullscreen = !hasAnalyserFullscreen; } else hasAnalyserFullscreen = false; (hasAnalyserFullscreen)?html.addClass("has-analyser-fullscreen"):html.removeClass("has-analyser-fullscreen"); @@ -1901,7 +1899,7 @@ function BlackboxLogViewer() { case "9".charCodeAt(0): try { if (!e.altKey) { // Workspaces feature - var id = e.which - 48; + let id = e.which - 48; if (!e.shiftKey) { // retrieve graph configuration from workspace if (workspaceGraphConfigs[id] != null) { onSwitchWorkspace(workspaceGraphConfigs, id) @@ -1923,22 +1921,22 @@ function BlackboxLogViewer() { } else {// store time to bookmark // Special Case : Shift Alt 0 clears all bookmarks - if(e.which==48) { + if (e.which==48) { bookmarkTimes = null; - for(var i=1; i<=9; i++) { + for (let i=1; i<=9; i++) { $('.bookmark-'+ i, statusBar).css('visibility', 'hidden' ); } $('.bookmark-clear', statusBar).css('visibility', 'hidden' ); } else { - if(bookmarkTimes==null) bookmarkTimes = new Array(); + if (bookmarkTimes==null) bookmarkTimes = new Array(); if (bookmarkTimes[e.which-48] == null) { bookmarkTimes[e.which-48] = currentBlackboxTime; // Save current time to bookmark } else { bookmarkTimes[e.which-48] = null; // clear the bookmark } $('.bookmark-'+(e.which-48), statusBar).css('visibility', ((bookmarkTimes[e.which-48]!=null)?('visible'):('hidden')) ); - var countBookmarks = 0; - for(var i=0; i<=9; i++) { + let countBookmarks = 0; + for (let i=0; i<=9; i++) { countBookmarks += (bookmarkTimes[i]!=null)?1:0; } $('.bookmark-clear', statusBar).css('visibility', ((countBookmarks>0)?('visible'):('hidden')) ); @@ -1959,7 +1957,7 @@ function BlackboxLogViewer() { break; case "Z".charCodeAt(0): // Ctrl-Z key to toggle between last graph config and current one - undo try { - if(e.ctrlKey) { + if (e.ctrlKey) { if (lastGraphConfig != null) { newGraphConfig(lastGraphConfig); } @@ -2060,7 +2058,7 @@ function BlackboxLogViewer() { loadeddata: videoLoaded }); - var percentageFormat = { + let percentageFormat = { to: function(value) { return value.toFixed(0) + "%"; }, @@ -2135,7 +2133,7 @@ function BlackboxLogViewer() { const item = e.dataTransfer.items[0]; const entry = item.webkitGetAsEntry(); if (entry.isFile) { - var file = e.dataTransfer.files[0]; + let file = e.dataTransfer.files[0]; loadFiles([file]); } return false; @@ -2169,12 +2167,12 @@ function BlackboxLogViewer() { prefs.get('graphConfig', function(item) { if (item) { graphConfig = GraphConfig.load(item); - } + } }); // New workspaces feature; local storage of user configurations prefs.get('workspaceGraphConfigs', function(item) { - if(item) { + if (item) { workspaceGraphConfigs = upgradeWorkspaceFormat(item); } else { workspaceGraphConfigs = defaultWorkspaceGraphConfigs; @@ -2193,7 +2191,7 @@ function BlackboxLogViewer() { // Get the offsetCache buffer prefs.get('offsetCache', function(item) { - if(item) { + if (item) { offsetCache = item; } }) @@ -2203,7 +2201,7 @@ function BlackboxLogViewer() { // Close the dropdowns if not clicking a descendant of the dropdown $(document).click(function (e) { - var p = $(e.target).closest(".dropdown"); + let p = $(e.target).closest(".dropdown"); if (!p.length) { $(".dropdown").removeClass("open"); } From 1fbdc3bc6349c6389156deb16a3c0d3d6d287bef Mon Sep 17 00:00:00 2001 From: demvlad Date: Fri, 31 May 2024 23:07:35 +0300 Subject: [PATCH 6/9] resolved issue of wrong curves colors by first application run --- src/graph_config.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/graph_config.js b/src/graph_config.js index fd57108c..aec8bc84 100644 --- a/src/graph_config.js +++ b/src/graph_config.js @@ -47,16 +47,18 @@ export function GraphConfig(graphConfig) { const matches = field.name.match(/^(.+)\[all\]$/); const logFieldNames = flightLog.getMainFieldNames(); const fields = []; + const setupColor = field.color == undefined ? false : (field.color === -1 ? true : false); if (matches) { const nameRoot = matches[1], nameRegex = new RegExp("^" + escapeRegExp(nameRoot) + "\[[0-9]+\]$"); - + let colorIndex = 0; for (const fieldName of logFieldNames) { if (fieldName.match(nameRegex)) { // forceNewCurve must be true for min max computing extended curves. const forceNewCurve = true; - field.color = undefined; + const color = GraphConfig.PALETTE[colorIndex++ % GraphConfig.PALETTE.length].color; + field.color = setupColor ? color : undefined; fields.push(adaptField(flightLog, $.extend({}, field, {curve: $.extend({}, field.curve), name: fieldName, friendlyName: FlightLogFieldPresenter.fieldNameToFriendly(fieldName, flightLog.getSysConfig().debug_mode)}), forceNewCurve)); } } @@ -1395,7 +1397,8 @@ GraphConfig.load = function(config) { for (const srcFieldName of srcGraph.fields) { const destField = { - name: srcFieldName + name: srcFieldName, + color: -1 }; destGraph.fields.push(destField); From 31eb2879155b20c88b90904ffe0e862966521b8c Mon Sep 17 00:00:00 2001 From: demvlad Date: Sat, 1 Jun 2024 00:38:32 +0300 Subject: [PATCH 7/9] The SonarCloud issue improvement --- src/graph_config.js | 4 ++-- src/main.js | 54 ++++++++++++++++++++++----------------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/graph_config.js b/src/graph_config.js index aec8bc84..57dfd537 100644 --- a/src/graph_config.js +++ b/src/graph_config.js @@ -47,7 +47,7 @@ export function GraphConfig(graphConfig) { const matches = field.name.match(/^(.+)\[all\]$/); const logFieldNames = flightLog.getMainFieldNames(); const fields = []; - const setupColor = field.color == undefined ? false : (field.color === -1 ? true : false); + const setupColor = field.color == undefined ? false : (field.color == -1 ? true : false); if (matches) { const nameRoot = matches[1], @@ -1398,7 +1398,7 @@ GraphConfig.load = function(config) { for (const srcFieldName of srcGraph.fields) { const destField = { name: srcFieldName, - color: -1 + color: -1, }; destGraph.fields.push(destField); diff --git a/src/main.js b/src/main.js index 3484ea1a..07207a47 100644 --- a/src/main.js +++ b/src/main.js @@ -727,7 +727,7 @@ function BlackboxLogViewer() { } else if (isVideo) { loadVideo(file); } else if (isWorkspaces) { - loadWorkspaces(file) + loadWorkspaces(file); } } @@ -1042,7 +1042,7 @@ function BlackboxLogViewer() { $('[data-toggle="tooltip"]').tooltip({trigger: "hover", placement: "auto bottom"}); // initialise tooltips $('[data-toggle="dropdown"]').dropdown(); // initialise menus $('a.auto-hide-menu').click(function() { - let test = $(this).closest('.dropdown').children().first().dropdown("toggle"); + $(this).closest('.dropdown').children().first().dropdown("toggle"); }); // Get Latest Version Information @@ -1078,10 +1078,10 @@ function BlackboxLogViewer() { prefs.get('activeWorkspace', function (id){ if (id) { - activeWorkspace = id + activeWorkspace = id; } else { - activeWorkspace = 1 + activeWorkspace = 1; } }); @@ -1561,11 +1561,11 @@ function BlackboxLogViewer() { if (graph==null && field==null) return false; // no pen specified, just exit if (graph!=null && field==null) { // save ALL pens within group - for (let i=0; iStored defaults for all pens'; @@ -1592,10 +1592,10 @@ function BlackboxLogViewer() { if (graph==null && field==null) return false; // no pen specified, just exit if (graph!=null && field==null) { // restore ALL pens within group - for (let i=0; iRestored defaults for all pens'; @@ -1627,10 +1627,10 @@ function BlackboxLogViewer() { let changedValue = '

Smoothing

'; if (graph!=null && field==null) { // change ALL pens within group - for (let i=0; i Date: Sat, 1 Jun 2024 00:51:28 +0300 Subject: [PATCH 8/9] The SonarCloud issue improvement --- src/graph_config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graph_config.js b/src/graph_config.js index 57dfd537..4b117cd7 100644 --- a/src/graph_config.js +++ b/src/graph_config.js @@ -47,7 +47,7 @@ export function GraphConfig(graphConfig) { const matches = field.name.match(/^(.+)\[all\]$/); const logFieldNames = flightLog.getMainFieldNames(); const fields = []; - const setupColor = field.color == undefined ? false : (field.color == -1 ? true : false); + const setupColor = field?.color == -1; if (matches) { const nameRoot = matches[1], From a86c4bf15d8406dc42d5f1c01c6cb31ff6bf80b2 Mon Sep 17 00:00:00 2001 From: demvlad Date: Sat, 1 Jun 2024 10:30:20 +0300 Subject: [PATCH 9/9] Resolved issue of color assign for combined (Gyro+PID) samples graphs --- src/graph_config_dialog.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/graph_config_dialog.js b/src/graph_config_dialog.js index eb5395a9..04b49230 100644 --- a/src/graph_config_dialog.js +++ b/src/graph_config_dialog.js @@ -291,12 +291,14 @@ export function GraphConfigurationDialog(dialog, onSave) { $('select.graph-height', graphElem).replaceWith(chooseHeight(graph.height?(graph.height):1)); // Add Field List + let colorIndex = 0; for (const field of graph.fields) { const extendedFields = activeGraphConfig.extendFields(activeFlightLog, field); - let colorIndex = 0; for (const extField of extendedFields) { - const color = extField.color ?? GraphConfig.PALETTE[colorIndex++ % GraphConfig.PALETTE.length].color; - const fieldElem = renderField(flightLog, extField, color); + if (!extField.color || extField.color == -1) { + extField.color = GraphConfig.PALETTE[colorIndex++ % GraphConfig.PALETTE.length].color; + } + const fieldElem = renderField(flightLog, extField, extField.color); fieldList.append(fieldElem); } }