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) => {
|
click: (_, window) => {
|
||||||
(window as electron.BrowserWindow)?.webContents?.send("contextmenu-click", menuDef.id);
|
(window as electron.BrowserWindow)?.webContents?.send("contextmenu-click", menuDef.id);
|
||||||
},
|
},
|
||||||
|
checked: menuDef.checked,
|
||||||
};
|
};
|
||||||
if (menuDef.submenu != null) {
|
if (menuDef.submenu != null) {
|
||||||
menuItemTemplate.submenu = convertMenuDefArrToMenu(menuDef.submenu);
|
menuItemTemplate.submenu = convertMenuDefArrToMenu(menuDef.submenu);
|
||||||
|
@ -25,6 +25,7 @@ class ContextMenuModelType {
|
|||||||
type: item.type,
|
type: item.type,
|
||||||
label: item.label,
|
label: item.label,
|
||||||
id: crypto.randomUUID(),
|
id: crypto.randomUUID(),
|
||||||
|
checked: item.checked,
|
||||||
};
|
};
|
||||||
if (item.click) {
|
if (item.click) {
|
||||||
this.handlers.set(electronItem.id, item.click);
|
this.handlers.set(electronItem.id, item.click);
|
||||||
|
@ -205,18 +205,23 @@ class CpuPlotViewModel {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const plotData = globalStore.get(this.dataAtom);
|
const plotData = globalStore.get(this.dataAtom);
|
||||||
|
const metrics = globalStore.get(this.metrics);
|
||||||
if (plotData.length == 0) {
|
if (plotData.length == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const menu = Object.keys(plotData[plotData.length - 1])
|
const menu = Object.keys(plotData[plotData.length - 1])
|
||||||
.filter((dataType) => dataType !== "ts")
|
.filter((dataType) => dataType !== "ts")
|
||||||
.map((dataType) => {
|
.map((dataType) => {
|
||||||
|
const inMetrics = metrics.includes(dataType);
|
||||||
|
const newMetrics = inMetrics ? metrics.filter((dt) => dt !== dataType) : [...metrics, dataType];
|
||||||
const menuItem: ContextMenuItem = {
|
const menuItem: ContextMenuItem = {
|
||||||
label: dataType,
|
label: dataType,
|
||||||
|
type: "checkbox",
|
||||||
|
checked: inMetrics,
|
||||||
click: async () => {
|
click: async () => {
|
||||||
await RpcApi.SetMetaCommand(WindowRpcClient, {
|
await RpcApi.SetMetaCommand(WindowRpcClient, {
|
||||||
oref: WOS.makeORef("block", this.blockId),
|
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
|
id: string; // unique id, used for communication
|
||||||
label: string;
|
label: string;
|
||||||
role?: string; // electron role (optional)
|
role?: string; // electron role (optional)
|
||||||
type?: "separator" | "normal" | "submenu";
|
type?: "separator" | "normal" | "submenu" | "checkbox";
|
||||||
submenu?: ElectronContextMenuItem[];
|
submenu?: ElectronContextMenuItem[];
|
||||||
|
checked?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ContextMenuItem = {
|
type ContextMenuItem = {
|
||||||
label?: string;
|
label?: string;
|
||||||
type?: "separator" | "normal" | "submenu";
|
type?: "separator" | "normal" | "submenu" | "checkbox";
|
||||||
role?: string; // electron role (optional)
|
role?: string; // electron role (optional)
|
||||||
click?: () => void; // not required if role is set
|
click?: () => void; // not required if role is set
|
||||||
submenu?: ContextMenuItem[];
|
submenu?: ContextMenuItem[];
|
||||||
|
checked?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type KeyPressDecl = {
|
type KeyPressDecl = {
|
||||||
|
Loading…
Reference in New Issue
Block a user