mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-02 18:39:05 +01:00
feat: allow multiple plots at once with checkmarks
This commit is contained in:
parent
bae31cc438
commit
f196656f43
@ -750,6 +750,7 @@ function convertMenuDefArrToMenu(menuDefArr: ElectronContextMenuItem[]): electro
|
||||
click: (_, window) => {
|
||||
(window as electron.BrowserWindow)?.webContents?.send("contextmenu-click", menuDef.id);
|
||||
},
|
||||
checked: menuDef.checked,
|
||||
};
|
||||
if (menuDef.submenu != null) {
|
||||
menuItemTemplate.submenu = convertMenuDefArrToMenu(menuDef.submenu);
|
||||
|
@ -25,6 +25,7 @@ class ContextMenuModelType {
|
||||
type: item.type,
|
||||
label: item.label,
|
||||
id: crypto.randomUUID(),
|
||||
checked: item.checked,
|
||||
};
|
||||
if (item.click) {
|
||||
this.handlers.set(electronItem.id, item.click);
|
||||
|
@ -205,18 +205,23 @@ class CpuPlotViewModel {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
const plotData = globalStore.get(this.dataAtom);
|
||||
const metrics = globalStore.get(this.metrics);
|
||||
if (plotData.length == 0) {
|
||||
return;
|
||||
}
|
||||
const menu = Object.keys(plotData[plotData.length - 1])
|
||||
.filter((dataType) => dataType !== "ts")
|
||||
.map((dataType) => {
|
||||
const inMetrics = metrics.includes(dataType);
|
||||
const newMetrics = inMetrics ? metrics.filter((dt) => dt !== dataType) : [...metrics, dataType];
|
||||
const menuItem: ContextMenuItem = {
|
||||
label: dataType,
|
||||
type: "checkbox",
|
||||
checked: inMetrics,
|
||||
click: async () => {
|
||||
await RpcApi.SetMetaCommand(WindowRpcClient, {
|
||||
oref: WOS.makeORef("block", this.blockId),
|
||||
meta: { "graph:metrics": [dataType] },
|
||||
meta: { "graph:metrics": newMetrics },
|
||||
});
|
||||
},
|
||||
};
|
||||
|
6
frontend/types/custom.d.ts
vendored
6
frontend/types/custom.d.ts
vendored
@ -81,16 +81,18 @@ declare global {
|
||||
id: string; // unique id, used for communication
|
||||
label: string;
|
||||
role?: string; // electron role (optional)
|
||||
type?: "separator" | "normal" | "submenu";
|
||||
type?: "separator" | "normal" | "submenu" | "checkbox";
|
||||
submenu?: ElectronContextMenuItem[];
|
||||
checked?: boolean;
|
||||
};
|
||||
|
||||
type ContextMenuItem = {
|
||||
label?: string;
|
||||
type?: "separator" | "normal" | "submenu";
|
||||
type?: "separator" | "normal" | "submenu" | "checkbox";
|
||||
role?: string; // electron role (optional)
|
||||
click?: () => void; // not required if role is set
|
||||
submenu?: ContextMenuItem[];
|
||||
checked?: boolean;
|
||||
};
|
||||
|
||||
type KeyPressDecl = {
|
||||
|
Loading…
Reference in New Issue
Block a user