source: lan-frontend/src/components/SankeyPanel.jsx@ e4c61dd

Last change on this file since e4c61dd was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago

Prototype 1.1

  • Property mode set to 100644
File size: 1.3 KB
Line 
1// src/components/SankeyPanel.jsx
2import { useMemo } from "react";
3
4export default function SankeyPanel({
5 env = "office1",
6 computers = [], // ✅ празно значи All
7 ips = [], // ✅ празно значи All
8 from = "now-24h",
9 to = "now",
10}) {
11 const dashboardUid = "adt9v8k";
12 const grafanaBase = "http://localhost:3000";
13
14 const src = useMemo(() => {
15 const params = new URLSearchParams();
16 params.set("orgId", "1");
17 params.set("kiosk", "tv");
18 params.set("from", from);
19 params.set("to", to);
20
21 params.set("var-env", env);
22
23 // ✅ НЕ праќај "All"
24 const cleanComputers = (computers || []).filter((c) => c && c !== "All");
25 const cleanIps = (ips || []).filter((ip) => ip && ip !== "All");
26
27 // ✅ додавај само ако има конкретни вредности
28 cleanComputers.forEach((c) => params.append("var-computers", c));
29 cleanIps.forEach((ip) => params.append("var-ips", ip));
30
31 return `${grafanaBase}/d/${dashboardUid}/sankey-panel?${params.toString()}`;
32 }, [env, computers, ips, from, to]);
33
34 return (
35 <div style={{ width: "100%", height: "85vh", overflow: "hidden", borderRadius: 12 }}>
36 <iframe
37 src={src}
38 title="Network Sankey"
39 width="100%"
40 height="100%"
41 frameBorder="0"
42 />
43 </div>
44 );
45}
Note: See TracBrowser for help on using the repository browser.