From 9c02b6f1595bfab9def78a3debd8cc6430a6aeb5 Mon Sep 17 00:00:00 2001 From: Jonah <47046556+jwbonner@users.noreply.github.com> Date: Fri, 20 Sep 2024 18:24:52 -0400 Subject: [PATCH] Add merged filenames to sidebar --- src/hub/Sidebar.ts | 22 +++++++++++++++++++--- src/hub/hub.ts | 7 ++++++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/hub/Sidebar.ts b/src/hub/Sidebar.ts index 833d4297..4b9b9f5f 100644 --- a/src/hub/Sidebar.ts +++ b/src/hub/Sidebar.ts @@ -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"; @@ -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; @@ -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; @@ -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 = " – " + htmlEncode(filename); + } } } diff --git a/src/hub/hub.ts b/src/hub/hub.ts index 81ae33f1..525e18e4 100644 --- a/src/hub/hub.ts +++ b/src/hub/hub.ts @@ -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;