Skip to content

Commit

Permalink
feat: fix delete workspace on reload (#723)
Browse files Browse the repository at this point in the history
* feat: fix delete workspace on reload

* Update src/main.js

---------

Co-authored-by: Mark Haslinghuis <mark@numloq.nl>
  • Loading branch information
chmelevskij and haslinghuis committed Mar 27, 2024
1 parent 386f6c8 commit 79334ae
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
18 changes: 18 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,24 @@ function BlackboxLogViewer() {
}

graphLegend = new GraphLegend($(".log-graph-legend"), activeGraphConfig, onLegendVisbilityChange, onLegendSelectionChange, onLegendHighlightChange, zoomGraphConfig, expandGraphConfig, newGraphConfig);

// initial load of the configuration defaults if we have them
prefs.get('workspaceGraphConfigs', function(item) {
if (item) {
workspaceGraphConfigs = upgradeWorkspaceFormat(item);
} else {
workspaceGraphConfigs = [];
}
});

prefs.get('activeWorkspace', function (id){
if (id) {
activeWorkspace = id
}
else {
activeWorkspace = 1
}
});

workspaceSelection = new WorkspaceSelection($(".log-workspace-selection"), workspaceGraphConfigs, onSwitchWorkspace, onSaveWorkspace);
onSwitchWorkspace(workspaceGraphConfigs, workspaceSelection);
Expand Down
6 changes: 4 additions & 2 deletions src/workspace_selection.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const UNTITLED = "Untitled";

export function WorkspaceSelection(targetElem, workspaces, onSelectionChange, onSaveWorkspace) {
var
numberSpan = null,
Expand Down Expand Up @@ -39,7 +41,7 @@ export function WorkspaceSelection(targetElem, workspaces, onSelectionChange, on
var inputElem = $('<input type="text" onkeyup="event.preventDefault()">');
inputElem.click((e) => e.stopPropagation()); // Stop click from closing
titleSpan.replaceWith(inputElem);
inputElem.val(workspaces[activeId].title)
inputElem.val(workspaces[activeId]?.title)
inputElem.focus();
inputElem.on('focusout', () => {
inputElem.replaceWith(titleSpan);
Expand Down Expand Up @@ -88,7 +90,7 @@ export function WorkspaceSelection(targetElem, workspaces, onSelectionChange, on
var saveButton = $('<span class="glyphicon glyphicon-floppy-disk" aria-hidden="true" data-toggle="tooltip" title="Save current graph setup to this Workspace"></span>');
saveButton.click((e) => {
if (!element) {
onSaveWorkspace(id, "Unnamed");
onSaveWorkspace(id, UNTITLED);
}
else {
onSaveWorkspace(id, element.title);
Expand Down

0 comments on commit 79334ae

Please sign in to comment.