Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 39 additions & 11 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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;
};
4 changes: 4 additions & 0 deletions src/hub/SourceList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1267,4 +1267,8 @@ export default class SourceList {
valueText.innerText = text;
}
}

public getUUID() {
return this.UUID;
}
}
7 changes: 7 additions & 0 deletions src/hub/Tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
31 changes: 30 additions & 1 deletion src/hub/controllers/LineGraphController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
47 changes: 47 additions & 0 deletions src/hub/controllers/LineGraphController_Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
]
}
]
},
Expand Down Expand Up @@ -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" }
]
}
]
},
Expand All @@ -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" }
]
}
]
}
Expand All @@ -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" }
]
}
]
},
Expand All @@ -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" }
]
}
]
},
Expand Down
4 changes: 4 additions & 0 deletions src/hub/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
60 changes: 43 additions & 17 deletions src/main/electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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);
});
}

Expand Down
14 changes: 14 additions & 0 deletions src/main/lite/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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) => {
Expand Down
10 changes: 10 additions & 0 deletions src/shared/log/LogUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down