diff --git a/rollup.config.mjs b/rollup.config.mjs index 84074cfe0..9120a5522 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -132,6 +132,7 @@ const mainBundles = isLite ]; const largeRendererBundles = [ bundle("hub/hub.ts", "hub.js", false, false), + bundle("hub/controllers/LineGraphController.ts", "LineGraphController.js", false, false), ...(isLite ? [] : [bundle("satellite.ts", "satellite.js", false, false)]) ]; const smallRendererBundles = [ @@ -182,17 +183,44 @@ const runOwletDownload = { }; export default (cliArgs) => { - if (cliArgs.configMain === true) return mainBundles; - if (cliArgs.configLargeRenderers === true) return largeRendererBundles; - if (cliArgs.configSmallRenderers === true) return smallRendererBundles; - if (cliArgs.configWorkers === true) return workerBundles; - if (cliArgs.configXR === true) { - if (isLite) process.exit(); - return xrBundles; + let bundles = []; + + if (cliArgs.configMain) { + bundles.push(...mainBundles); + } + + if (cliArgs.oren) { + bundles.push(...oren); + } + + if (cliArgs.configLargeRenderers) { + bundles.push(...largeRendererBundles); + } + + if (cliArgs.configSmallRenderers) { + bundles.push(...smallRendererBundles); + } + + if (cliArgs.configWorkers) { + bundles.push(...workerBundles); + } + + if (cliArgs.configXR) { + if (!isLite) { + bundles.push(...xrBundles); + } + } + + if (cliArgs.configRunOwletDownload) { + return runOwletDownload; // assuming this should stay exclusive + } + + // If no flags were passed, return default behavior + if (bundles.length === 0) { + return isLite + ? [...mainBundles, ...largeRendererBundles, ...smallRendererBundles, ...workerBundles] + : [...mainBundles, ...largeRendererBundles, ...smallRendererBundles, ...workerBundles, ...xrBundles]; } - if (cliArgs.configRunOwletDownload === true) return runOwletDownload; - return isLite - ? [...mainBundles, ...largeRendererBundles, ...smallRendererBundles, ...workerBundles] - : [...mainBundles, ...largeRendererBundles, ...smallRendererBundles, ...workerBundles, ...xrBundles]; + return bundles; }; diff --git a/src/hub/SourceList.ts b/src/hub/SourceList.ts index b320053a4..d419ca49d 100644 --- a/src/hub/SourceList.ts +++ b/src/hub/SourceList.ts @@ -1267,4 +1267,8 @@ export default class SourceList { valueText.innerText = text; } } + + public getUUID() { + return this.UUID; + } } diff --git a/src/hub/Tabs.ts b/src/hub/Tabs.ts index 702b9b4b4..d3159530f 100644 --- a/src/hub/Tabs.ts +++ b/src/hub/Tabs.ts @@ -693,6 +693,13 @@ export default class Tabs { } } + /** Runs the "Add from all logs" action on the selected line graph. */ + addFromAllLogs(data?: any) { + if (this.tabList[this.selectedTab].type === TabType.LineGraph) { + (this.tabList[this.selectedTab].controller as LineGraphController).addFromAllLogs(data); + } + } + /** Switches the selected camera for the selected 3D field. */ set3DCamera(index: number) { if (this.tabList[this.selectedTab].type === TabType.Field3d) { diff --git a/src/hub/controllers/LineGraphController.ts b/src/hub/controllers/LineGraphController.ts index d7b014724..d2fcf28d1 100644 --- a/src/hub/controllers/LineGraphController.ts +++ b/src/hub/controllers/LineGraphController.ts @@ -9,7 +9,7 @@ import { ensureThemeContrast } from "../../shared/Colors"; import LineGraphFilter from "../../shared/LineGraphFilter"; import { SelectionMode } from "../../shared/Selection"; import { SourceListState } from "../../shared/SourceListConfig"; -import { AKIT_TIMESTAMP_KEYS, getEnabledKey, getLogValueText } from "../../shared/log/LogUtil"; +import { AKIT_TIMESTAMP_KEYS, getEnabledKey, getLogValueText, keyPresent } from "../../shared/log/LogUtil"; import { LogValueSetNumber } from "../../shared/log/LogValueSets"; import { LineGraphRendererCommand, @@ -340,6 +340,35 @@ export default class LineGraphController implements TabController { return false; } + addFromAllLogs(data?: any) { + let uuid = typeof data.uuid === "string" ? (data.uuid as string) : ""; + let sourceList: SourceList; + if (uuid.match(this.rightSourceList.getUUID())) { + sourceList = this.rightSourceList; + } else if (uuid.match(this.leftSourceList.getUUID())) { + sourceList = this.leftSourceList; + } else if (uuid.match(this.discreteSourceList.getUUID())) { + sourceList = this.discreteSourceList; + } else { + return; + } + + let logKey = typeof data.logKey === "string" ? data.logKey : ""; + logKey = logKey.replace(/^\/Log[^/]+/, ""); + let newLogKey = logKey; + let existingKeys = sourceList + .getState() + .filter((source) => source.logKey.includes(logKey)) + .map((source) => source.logKey); + let logNum = 1; + newLogKey = "/Log" + logNum + logKey; + while (keyPresent(window.log, [newLogKey])) { + if (!existingKeys.includes(newLogKey)) sourceList.addField(newLogKey); + logNum++; + newLogKey = "/Log" + logNum + logKey; + } + } + private getPreview( key: string, time: number, diff --git a/src/hub/controllers/LineGraphController_Config.ts b/src/hub/controllers/LineGraphController_Config.ts index ef472be54..3bd4043c5 100644 --- a/src/hub/controllers/LineGraphController_Config.ts +++ b/src/hub/controllers/LineGraphController_Config.ts @@ -37,6 +37,15 @@ export const LineGraphController_NumericConfig: SourceListConfig = { { key: "bold", display: "Bold" }, { key: "verybold", display: "Very Bold" } ] + }, + { + key: "AddFromLogs", + display: "Add from all logs ", + showInTypeName: false, + values: [ + { key: "off", display: "Off" }, + { key: "on", display: "On" } + ] } ] }, @@ -64,6 +73,16 @@ export const LineGraphController_NumericConfig: SourceListConfig = { { key: "bold", display: "Bold" }, { key: "verybold", display: "Very Bold" } ] + }, + + { + key: "AddFromLogs", + display: "Add from all logs ", + showInTypeName: false, + values: [ + { key: "off", display: "Off" }, + { key: "on", display: "On" } + ] } ] }, @@ -90,6 +109,16 @@ export const LineGraphController_NumericConfig: SourceListConfig = { { key: "normal", display: "Normal" }, { key: "bold", display: "Large" } ] + }, + + { + key: "AddFromLogs", + display: "Add from all logs ", + showInTypeName: false, + values: [ + { key: "off", display: "Off" }, + { key: "on", display: "On" } + ] } ] } @@ -115,6 +144,15 @@ export const LineGraphController_DiscreteConfig: SourceListConfig = { display: "Color", showInTypeName: false, values: GraphColors + }, + { + key: "AddFromLogs", + display: "Add from all logs ", + showInTypeName: false, + values: [ + { key: "off", display: "Off" }, + { key: "on", display: "On" } + ] } ] }, @@ -132,6 +170,15 @@ export const LineGraphController_DiscreteConfig: SourceListConfig = { display: "Color", showInTypeName: false, values: GraphColors + }, + { + key: "AddFromLogs", + display: "Add from all logs ", + showInTypeName: false, + values: [ + { key: "off", display: "Off" }, + { key: "on", display: "On" } + ] } ] }, diff --git a/src/hub/hub.ts b/src/hub/hub.ts index 006c11c2a..2c9791a3f 100644 --- a/src/hub/hub.ts +++ b/src/hub/hub.ts @@ -882,6 +882,10 @@ async function handleMainMessage(message: NamedMessage) { window.tabs.addDiscreteEnabled(); break; + case "add-from-all-logs": + window.tabs.addFromAllLogs(message.data); + break; + case "edit-axis": window.tabs.editAxis( message.data.legend, diff --git a/src/main/electron/main.ts b/src/main/electron/main.ts index 08a81be2c..033907f05 100644 --- a/src/main/electron/main.ts +++ b/src/main/electron/main.ts @@ -738,6 +738,48 @@ async function handleHubMessage(window: BrowserWindow, message: NamedMessage) { // Add options let currentTypeConfig = config.types.find((typeConfig) => typeConfig.key === state.type)!; + let addLogsOptionConfig = currentTypeConfig.options.find((optionConfig) => optionConfig.key === "AddFromLogs"); + if (addLogsOptionConfig !== undefined && addLogsOptionConfig.values.length > 0) { + menu.append( + new MenuItem({ + label: "Add from all logs", + click() { + sendMessage(window, "add-from-all-logs", { + logKey: state.logKey, + uuid: message.data.uuid + }); + respond(); + } + }) + ); + menu.append( + new MenuItem({ + type: "separator" + }) + ); + } + let appendOptionItem = (optionConfig: SourceListConfig["types"][number]["options"][number]) => { + if (optionConfig.key === "AddFromLogs") { + return; + } + menu.append( + new MenuItem({ + label: optionConfig.display, + submenu: optionConfig.values.map((optionValue) => { + return { + label: optionValue.display, + type: "checkbox", + checked: optionValue.key === state.options[optionConfig.key], + icon: getIcon(optionValue.key), + click() { + state.options[optionConfig.key] = optionValue.key; + respond(); + } + }; + }) + }) + ); + }; if (currentTypeConfig.options.length === 1) { let optionConfig = currentTypeConfig.options[0]; optionConfig.values.forEach((optionValue) => { @@ -756,23 +798,7 @@ async function handleHubMessage(window: BrowserWindow, message: NamedMessage) { }); } else { currentTypeConfig.options.forEach((optionConfig) => { - menu.append( - new MenuItem({ - label: optionConfig.display, - submenu: optionConfig.values.map((optionValue) => { - return { - label: optionValue.display, - type: "checkbox", - checked: optionValue.key === state.options[optionConfig.key], - icon: getIcon(optionValue.key), - click() { - state.options[optionConfig.key] = optionValue.key; - respond(); - } - }; - }) - }) - ); + appendOptionItem(optionConfig); }); } diff --git a/src/main/lite/main.ts b/src/main/lite/main.ts index f8e6a0d95..a61acc5f3 100644 --- a/src/main/lite/main.ts +++ b/src/main/lite/main.ts @@ -655,6 +655,17 @@ async function handleHubMessage(message: NamedMessage) { // Add options let currentTypeConfig = config.types.find((typeConfig) => typeConfig.key === state.type)!; + let addLogsOptionConfig = currentTypeConfig.options.find((optionConfig) => optionConfig.key === "AddFromLogs"); + if (addLogsOptionConfig !== undefined && addLogsOptionConfig.values.length > 0) { + menuItems.push({ + content: "Add from all logs", + callback() { + sendMessage(hubPort, "add-from-all-logs"); + respond(); + } + }); + menuItems.push("-"); + } if (currentTypeConfig.options.length === 1) { let optionConfig = currentTypeConfig.options[0]; optionConfig.values.forEach((optionValue) => { @@ -669,6 +680,9 @@ async function handleHubMessage(message: NamedMessage) { }); } else { currentTypeConfig.options.forEach((optionConfig) => { + if (optionConfig.key === "AddFromLogs") { + return; + } menuItems.push({ content: optionConfig.display, items: optionConfig.values.map((optionValue) => { diff --git a/src/shared/log/LogUtil.ts b/src/shared/log/LogUtil.ts index 874fcf6c7..3e5b2a89a 100644 --- a/src/shared/log/LogUtil.ts +++ b/src/shared/log/LogUtil.ts @@ -112,6 +112,16 @@ export function findKey(log: Log, search: string[]): string | undefined { return bestKey; } +export function keyPresent(log: Log, search: string[]): boolean { + let fieldKeys = log.getFieldKeys(); + let found = false; + for (const key of search) { + found = fieldKeys.includes(key); + if (found) break; + } + return found; +} + /** Adds a prefix to a log key. */ export function applyKeyPrefix(prefix: string, key: string): string { if (prefix.length === 0) {