feat(workbench): expand SCADA monitoring and investigation presentation
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
let order: string[] = [];
|
||||
const listeners = new Set<() => void>();
|
||||
let host: HTMLDivElement | undefined;
|
||||
|
||||
export const floatingWindowOrder = () => order;
|
||||
export const subscribeFloatingWindows = (listener: () => void) => {
|
||||
listeners.add(listener);
|
||||
return () => { listeners.delete(listener); };
|
||||
};
|
||||
|
||||
export function raiseFloatingWindow(id: string) {
|
||||
if (order.at(-1) === id) return;
|
||||
order = [...order.filter((item) => item !== id), id];
|
||||
listeners.forEach((listener) => listener());
|
||||
}
|
||||
|
||||
export function removeFloatingWindow(id: string) {
|
||||
if (!order.includes(id)) return;
|
||||
order = order.filter((item) => item !== id);
|
||||
listeners.forEach((listener) => listener());
|
||||
}
|
||||
|
||||
export function floatingWindowHost() {
|
||||
if (!host?.isConnected) {
|
||||
host = document.createElement("div");
|
||||
// One stacking context keeps windows below dialogs and newly opened menus.
|
||||
host.className = "pointer-events-none fixed inset-0 z-50";
|
||||
host.dataset.floatingWindowLayer = "";
|
||||
document.body.appendChild(host);
|
||||
}
|
||||
return host;
|
||||
}
|
||||
Reference in New Issue
Block a user