Skip to content

Commit

Permalink
Add merged filenames to sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
jwbonner committed Sep 20, 2024
1 parent d4aab98 commit 9c02b6f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
22 changes: 19 additions & 3 deletions src/hub/Sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import LogFieldTree from "../shared/log/LogFieldTree";
import LoggableType from "../shared/log/LoggableType";
import { getOrDefault, searchFields, TYPE_KEY } from "../shared/log/LogUtil";
import { SelectionMode } from "../shared/Selection";
import { arraysEqual, setsEqual } from "../shared/util";
import { arraysEqual, htmlEncode, setsEqual } from "../shared/util";
import { ZEBRA_LOG_KEY } from "./dataSources/LoadZebra";
import CustomSchemas from "./dataSources/schema/CustomSchemas";

Expand Down Expand Up @@ -47,6 +47,7 @@ export default class Sidebar {
private FIELD_DRAG_THRESHOLD_PX = 3;
private VALUE_WIDTH_MARGIN_PX = 12;

private getFilenames: () => string[];
private sidebarHandleActive = false;
private sidebarWidth = this.DEFAULT_SIDEBAR_WIDTH;
private fieldCount = 0;
Expand All @@ -69,7 +70,9 @@ export default class Sidebar {
private updateMetadataCallbacks: (() => void)[] = [];
private updateLoadingCallbacks: (() => void)[] = [];

constructor() {
constructor(getFilenames: () => string[]) {
this.getFilenames = getFilenames;

// Set up handle for resizing
this.SIDEBAR_HANDLE.addEventListener("mousedown", () => {
this.sidebarHandleActive = true;
Expand Down Expand Up @@ -568,7 +571,20 @@ export default class Sidebar {
let typeLabel = document.createElement("span");
typeLabel.classList.add("field-item-type-label");
label.appendChild(typeLabel);
typeLabel.innerHTML = " – " + structuredType;
typeLabel.innerHTML = " – " + htmlEncode(structuredType);
}
} else {
if (title.startsWith(this.MERGED_KEY) && indent === 0) {
let mergeIndex = Number(title.slice(this.MERGED_KEY.length));
let mergedFilenames = this.getFilenames();
if (mergeIndex < mergedFilenames.length) {
let filename = mergedFilenames[mergeIndex];

let typeLabel = document.createElement("span");
typeLabel.classList.add("field-item-type-label");
label.appendChild(typeLabel);
typeLabel.innerHTML = " &ndash; " + htmlEncode(filename);
}
}
}

Expand Down
7 changes: 6 additions & 1 deletion src/hub/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ window.isBattery = false;
window.fps = false;

window.selection = new SelectionImpl();
window.sidebar = new Sidebar();
window.sidebar = new Sidebar(() =>
historicalSources.map(entry => {
let components = entry.path.split(window.platform === "win32" ? "\\" : "/");
return components[components.length - 1];
})
);
window.tabs = new Tabs();
window.tuner = null;
window.messagePort = null;
Expand Down

0 comments on commit 9c02b6f

Please sign in to comment.