P1: - utils/storage.ts、theme.ts、validate.ts + index 统一出口 - request/store/useTheme 接入 storage;清零 confirm/alert - PipelineManager、TerminalAuditTab 拆分子模块(<700行红线) P2: - api/monitor、api/deploy 子目录化 - hooks/api 扩展:servers/pipelines/alerts/audit/sessionCommands - PipelineManager、AuditOperationsTab 接入 TanStack Query
4 lines
84 KiB
JavaScript
4 lines
84 KiB
JavaScript
import{i as Ya,j as a,r as o,A as J,B as D,L as aa,T as Na,S as Q,w as Qa,p as za,a3 as ka,D as oa,a as ra,b as na,c as da,d as Wa,H as xa,O as Xa,v as as,z as ss,t as u,aW as _a,f as es,m as ts,au as os,I as rs,e as va,K as $a,E as Za}from"./index-HuRw9UhJ.js";import{I as X}from"./input-C9Xfv8um.js";import{B}from"./badge-CeS-g-Od.js";import{C as U,b as ya,c as Ga,a as H}from"./card-B2Wqa0sK.js";import{S as pa,a as ba,b as ua,c as ga,d as I}from"./select-KDzbUQs3.js";import{L}from"./label-DvRDtaMA.js";import{s as Ta}from"./server-BQNr9a-x.js";import{d as fa}from"./grafana-DTc3taUi.js";import{z as ns,p as ds}from"./datasource-CLdSbgtw.js";import{a as ja}from"./agent-CTqsAA8l.js";import{T as cs}from"./trending-up-C97I6AeO.js";import{z as hs,p as Pa}from"./metrics-Q051aLdz.js";import{R as ca}from"./refresh-cw-CSycAyA2.js";import{W as Fa}from"./wifi-DF9mrE-Q.js";import{A as Ma}from"./arrow-up-down-C2LsDqn8.js";import{A as Ia,a as Ba}from"./arrow-up-CmLz9pAr.js";import{S as Oa}from"./stat-strip-CVviXwc6.js";import{T as Ea,a as Ua,b as R,c as K}from"./tabs-XYsjnHzX.js";import{Z as ta}from"./zap-CS68N0Jd.js";import{C as ms}from"./copy-Ci4WwJkK.js";import{D as is}from"./download-CjFatm64.js";import{P as ls}from"./play-BXdOitsb.js";import{C as Da}from"./checkbox-B7nWBaO4.js";import{M as xs,a as ps}from"./minimize-2-UErWMOt6.js";import{P as Aa}from"./package-open-DtPFmjqV.js";import{T as bs}from"./trash-2-Cf9-88KL.js";import{E as Ha}from"./external-link-JBfQbjOd.js";import{P as Sa}from"./plus-BVwIGPvl.js";import"./index-DwvHXNyF.js";import"./chevron-up-GXrRy2ul.js";const us=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],gs=Ya("wifi-off",us);function fs(s){const e=[];for(let c=0;c<24;c++)e.push({time:new Date(Date.now()-(24-c)*36e5).toLocaleTimeString(),value:Math.random()*100});return e}function js({panel:s}){const r=fs();switch(s.type){case"stat":return a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:24:9",className:"flex flex-col items-center justify-center h-full",children:[a.jsx("span",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:25:11",className:"text-4xl font-bold text-blue-500",children:Math.floor(Math.random()*1e3)}),a.jsx("span",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:26:11",className:"text-sm text-muted-foreground mt-2",children:s.options?.unit||"requests/s"}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:27:11",className:"flex items-center gap-1 mt-2 text-green-500 text-sm",children:[a.jsx(cs,{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:28:13",className:"w-4 h-4"}),a.jsx("span",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:29:13",children:"+12.5%"})]})]});case"gauge":return a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:35:9",className:"flex flex-col items-center justify-center h-full",children:[a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:36:11",className:"relative w-24 h-24",children:[a.jsxs("svg",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:37:13",className:"w-full h-full",viewBox:"0 0 100 100",children:[a.jsx("circle",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:38:15",cx:"50",cy:"50",r:"40",fill:"none",stroke:"#e5e7eb",strokeWidth:"10"}),a.jsx("circle",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:39:15",cx:"50",cy:"50",r:"40",fill:"none",stroke:"#3b82f6",strokeWidth:"10",strokeDasharray:`${Math.random()*251} 251`,transform:"rotate(-90 50 50)"})]}),a.jsx("div",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:50:13",className:"absolute inset-0 flex items-center justify-center",children:a.jsxs("span",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:51:15",className:"text-xl font-bold",children:[Math.floor(Math.random()*100),"%"]})})]}),a.jsx("span",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:54:11",className:"text-sm text-muted-foreground mt-2",children:"CPU使用率"})]});default:return a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:60:9",className:"h-full flex flex-col",children:[a.jsx("div",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:61:11",className:"flex-1 flex items-end gap-1 px-2",children:r.map((e,c)=>a.jsx("div",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:63:15",className:"flex-1 bg-blue-500 rounded-t",style:{height:`${e.value}%`,opacity:.3+c/r.length*.7}},c))}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:70:11",className:"flex justify-between text-xs text-muted-foreground px-2 pt-2",children:[a.jsx("span",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:71:13",children:r[0].time}),a.jsx("span",{"code-path":"src/components/monitor/dashboard/GrafanaPanelContent.tsx:72:13",children:r[r.length-1].time})]})]})}}const Ds=({dsUrl:s,dsUsername:r,dsPassword:e})=>{const[c,i]=o.useState(!1),[x,b]=o.useState(!1),[g,N]=o.useState([]),[w,m]=o.useState(""),[P,y]=o.useState(""),[z,v]=o.useState("cpu_usage"),[h,A]=o.useState("desc");o.useEffect(()=>{s&&r&&e&&W(s,r,e)},[s,r,e]);const W=async(n,l,S)=>{b(!0),y("");try{const j=await hs.connect(n,l,S);N(j.hosts||[]),m(j.version||""),i(!0)}catch(j){i(!1),y(j.message||"连接失败")}finally{b(!1)}},Z=()=>{s&&r&&e&&W(s,r,e)},T=n=>{z===n?A(l=>l==="asc"?"desc":"asc"):(v(n),A("desc"))},F=[...g].sort((n,l)=>{const S=n[z]??"",j=l[z]??"";return typeof S=="number"?h==="asc"?S-j:j-S:h==="asc"?String(S).localeCompare(String(j)):String(j).localeCompare(String(S))}),$=({f:n})=>z!==n?a.jsx(Ma,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:68:33",className:"w-3 h-3 text-slate-500"}):h==="asc"?a.jsx(Ia,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:69:32",className:"w-3 h-3 text-blue-400"}):a.jsx(Ba,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:69:80",className:"w-3 h-3 text-blue-400"}),p=(n,l)=>a.jsxs("div",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:73:5",className:"flex items-center gap-2 min-w-[90px]",children:[a.jsx("div",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:74:7",className:"flex-1 h-2.5 rounded-full bg-[var(--dg-bg-tertiary)] overflow-hidden",children:a.jsx("div",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:75:9",className:`h-full rounded-full transition-all duration-500 ${n>=80?"bg-orange-500":"bg-blue-500"}`,style:{width:`${Math.min(n,100)}%`}})}),a.jsx("span",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:77:7",className:`w-14 text-right text-xs font-mono tabular-nums ${n>=80?"text-orange-400":""}`,children:l})]}),f=n=>!n||n===0?"—":n>1e9?`${(n/1e9).toFixed(1)} GB/s`:n>1e6?`${(n/1e6).toFixed(1)} MB/s`:n>1e3?`${(n/1e3).toFixed(1)} KB/s`:`${n.toFixed(1)} B/s`;return!c&&!x&&!P?null:a.jsxs(U,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:92:5",className:"bg-[var(--dg-bg-secondary)] border-blue-500/20",children:[a.jsx(ya,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:93:7",className:"py-3 px-4 pb-2",children:a.jsxs("div",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:94:9",className:"flex items-center gap-2",children:[a.jsx(J,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:95:11",className:"h-4 w-4 text-blue-400"}),a.jsx(Ga,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:96:11",className:"text-sm font-medium",children:"Zabbix 主机监控"}),w&&a.jsxs(B,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:97:23",className:"text-[10px] bg-blue-500/10 text-blue-400",children:["v",w]}),c&&a.jsxs("span",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:98:25",className:"text-[10px] text-[var(--dg-text-muted)] ml-2",children:[g.length," 台"]}),c&&a.jsx("div",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:99:25",className:"ml-auto flex gap-1",children:a.jsxs(D,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:99:61",variant:"ghost",size:"sm",className:"h-6 px-2 text-[10px]",onClick:Z,children:[a.jsx(ca,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:99:146",className:"w-3 h-3 mr-1"}),"刷新"]})})]})}),a.jsx(H,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:102:7",className:"px-4 pb-3 pt-0",children:x?a.jsxs("div",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:103:21",className:"text-center py-12",children:[a.jsx(aa,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:103:56",className:"h-6 w-6 mx-auto mb-2 animate-spin text-blue-400"}),a.jsx("p",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:103:127",className:"text-xs text-[var(--dg-text-muted)]",children:"连接中…"})]}):P?a.jsxs("div",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:104:20",className:"p-3 rounded-lg bg-red-500/10 border border-red-500/20 text-xs text-red-400 flex items-start gap-2",children:[a.jsx(Na,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:104:135",className:"h-4 w-4 mt-0.5"}),a.jsx("span",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:104:179",children:P})]}):g.length===0?a.jsxs("div",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:105:33",className:"text-center py-8 text-[var(--dg-text-muted)]",children:[a.jsx(Q,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:105:95",className:"h-8 w-8 mx-auto mb-2 text-slate-600"}),a.jsx("p",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:105:153",className:"text-sm",children:"未找到被监控的 Zabbix 主机"})]}):a.jsx("div",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:107:11",className:"overflow-x-auto rounded-lg border border-[var(--dg-border)]",children:a.jsxs("table",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:108:13",className:"w-full text-xs",children:[a.jsx("thead",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:109:15",className:"bg-[var(--dg-bg-tertiary)] border-b border-[var(--dg-border)]",children:a.jsx("tr",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:109:96",children:[{f:"hostname",l:"主机名"},{f:"cpu_usage",l:"CPU"},{f:"memory_usage",l:"内存"},{f:"disk_usage",l:"磁盘"},{f:"load5",l:"Load5"},{f:"net_in_bps",l:"流入"},{f:"net_out_bps",l:"流出"},{f:"problem_count",l:"问题"},{f:"uptime_days",l:"运行"}].map(({f:n,l})=>a.jsx("th",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:115:19",className:"px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)] cursor-pointer hover:text-[var(--dg-text-primary)] select-none whitespace-nowrap",onClick:()=>T(n),children:a.jsxs("div",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:116:21",className:"flex items-center gap-1",children:[l,a.jsx($,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:116:65",f:n})]})},n))})}),a.jsx("tbody",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:118:15",children:F.map((n,l)=>a.jsxs("tr",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:120:19",className:"border-b border-[var(--dg-border)] last:border-0 hover:bg-[var(--dg-bg-tertiary)]/50",children:[a.jsxs("td",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:121:21",className:"px-3 py-2.5 whitespace-nowrap",children:[a.jsxs(B,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:121:67",className:`text-[10px] ${n.available==="1"?"bg-emerald-500/20 text-emerald-400":"bg-red-500/20 text-red-400"}`,children:[a.jsx(Fa,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:121:193",className:"w-3 h-3 mr-1"}),n.available==="1"?"UP":"DOWN"]})," ",a.jsx("span",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:121:272",className:"font-medium text-[var(--dg-text-primary)] ml-1",children:n.name||n.hostname})]}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:122:21",className:"px-3 py-2.5",children:p(Number(n.cpu_usage||0),`${Number(n.cpu_usage||0).toFixed(1)}%`)}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:123:21",className:"px-3 py-2.5",children:p(Number(n.memory_usage||0),`${Number(n.memory_usage||0).toFixed(1)}%`)}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:124:21",className:"px-3 py-2.5",children:p(Number(n.disk_usage||0),`${Number(n.disk_usage||0).toFixed(1)}%`)}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:125:21",className:"px-3 py-2.5 text-[var(--dg-text-secondary)]",children:n.load5>0?n.load5.toFixed(1):"—"}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:126:21",className:"px-3 py-2.5 font-mono text-[var(--dg-text-secondary)]",children:f(n.net_in_bps)}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:127:21",className:"px-3 py-2.5 font-mono text-[var(--dg-text-secondary)]",children:f(n.net_out_bps)}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:128:21",className:"px-3 py-2.5 text-center",children:a.jsx("span",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:128:61",className:`font-mono font-bold ${n.problem_count>0?n.problem_count>2?"text-red-400":"text-amber-400":"text-emerald-400"}`,children:n.problem_count>0?a.jsxs(a.Fragment,{children:[a.jsx(Na,{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:128:230",className:"w-3 h-3 inline mr-1"}),n.problem_count]}):"0"})}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/ZabbixDashboard.tsx:129:21",className:"px-3 py-2.5 text-[var(--dg-text-secondary)]",children:n.uptime_days>0?`${n.uptime_days}d`:"—"})]},n.hostid||l))})]})})})]})},V=({val:s,label:r,color:e})=>{const c=Math.min(s,100);return a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:16:5",className:"flex items-center gap-1.5 min-w-[80px]",children:[a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:17:7",className:"flex-1 h-2 rounded-full bg-[var(--dg-bg-tertiary)] overflow-hidden",children:a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:18:9",className:`h-full rounded-full ${e||"bg-purple-500"}`,style:{width:`${c}%`}})}),a.jsx("span",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:20:7",className:"w-14 text-right text-[11px] font-mono text-[var(--dg-text-secondary)]",children:r})]})},Ns=s=>s?s>1e9?`${(s/1e9).toFixed(1)} GB`:s>1e6?`${(s/1e6).toFixed(1)} MB`:`${(s/1e3).toFixed(1)} KB`:"—",Ca=s=>s?s>1e9?`${(s/1e9).toFixed(1)} GB/s`:s>1e6?`${(s/1e6).toFixed(1)} MB/s`:s>1e3?`${(s/1e3).toFixed(1)} KB/s`:`${s.toFixed(1)} B/s`:"—";function vs(s){return(s||[]).map(r=>{const e={...r.metric||{}};return r.value&&(e.value=r.value[1]),e})}const ys=s=>a.jsx("svg",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:47:26",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...s,children:a.jsx("path",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:47:211",d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"})}),Gs=({d:s})=>a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:50:3",className:"space-y-4",children:[a.jsx(Oa,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:51:5",items:[{label:"Pods",value:s.podCount?.[0]?.value||0,color:"purple"},{label:"Deployments",value:s.deployCount?.[0]?.value||0,color:"blue"},{label:"Nodes",value:s.nodeCount?.[0]?.value||0,color:"emerald"},{label:"Namespaces",value:s.nsPods?.length||0,color:"amber"}]}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:59:5",className:"rounded-lg bg-[var(--dg-bg-primary)] border border-[var(--dg-border)] p-3 max-h-60 overflow-y-auto",children:[a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:60:7",className:"text-xs font-medium mb-2 flex items-center gap-1",children:[a.jsx(za,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:60:73",className:"w-3 h-3 text-purple-400"}),"节点 CPU / 内存利用率"]}),(s.nodeCPU||[]).map((r,e)=>{const c=(s.nodeMem||[]).find(i=>i.node===r.node);return a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:63:16",className:"flex items-center gap-3 text-[11px] mb-1.5",children:[a.jsx("span",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:63:84",className:"w-28 truncate",title:r.node,children:r.node}),a.jsx(V,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:63:146",val:Number(r.value||0),label:`${Number(r.value||0).toFixed(1)}%`}),a.jsx(V,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:63:226",val:Number(c?.value||0),label:`${Number(c?.value||0).toFixed(1)}%`,color:"bg-blue-500"})]},e)})]})]}),ws=({d:s})=>a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:70:3",className:"overflow-x-auto rounded-lg border border-[var(--dg-border)]",children:a.jsxs("table",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:71:5",className:"w-full text-xs",children:[a.jsx("thead",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:72:7",className:"bg-[var(--dg-bg-tertiary)]",children:a.jsxs("tr",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:72:53",children:[a.jsx("th",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:72:57",className:"px-3 py-2 text-left",children:"节点"}),a.jsx("th",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:72:100",className:"px-3 py-2 text-left",children:"状态"}),a.jsx("th",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:72:143",className:"px-3 py-2 text-left",children:"CPU"}),a.jsx("th",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:72:187",className:"px-3 py-2 text-left",children:"内存"}),a.jsx("th",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:72:230",className:"px-3 py-2 text-left",children:"磁盘"}),a.jsx("th",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:72:273",className:"px-3 py-2 text-left",children:"流入"}),a.jsx("th",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:72:316",className:"px-3 py-2 text-left",children:"流出"})]})}),a.jsx("tbody",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:73:7",children:(s.nodes||[]).map((r,e)=>{const c=r.instance||r.exported_instance||"",i=(s.cpuUsage||[]).find(m=>m.instance===c),x=(s.memUsage||[]).find(m=>m.instance===c),b=(s.diskUsage||[]).find(m=>m.instance===c),g=(s.up||[]).find(m=>m.instance===c),N=(s.netRx||[]).find(m=>m.instance===c),w=(s.netTx||[]).find(m=>m.instance===c);return a.jsxs("tr",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:82:18",className:"border-b border-[var(--dg-border)] hover:bg-[var(--dg-bg-tertiary)]/50",children:[a.jsx("td",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:83:13",className:"px-3 py-2 font-medium",children:r.nodename||c}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:84:13",className:"px-3 py-2",children:a.jsx(B,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:84:39",className:`text-[10px] ${g?.value===1?"bg-emerald-500/20 text-emerald-400":"bg-red-500/20 text-red-400"}`,children:g?.value===1?"UP":"DOWN"})}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:85:13",className:"px-3 py-2",children:a.jsx(V,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:85:39",val:Number(i?.value||0),label:`${Number(i?.value||0).toFixed(1)}%`})}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:86:13",className:"px-3 py-2",children:a.jsx(V,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:86:39",val:Number(x?.value||0),label:`${Number(x?.value||0).toFixed(1)}%`,color:"bg-blue-500"})}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:87:13",className:"px-3 py-2",children:a.jsx(V,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:87:39",val:Number(b?.value||0),label:`${Number(b?.value||0).toFixed(1)}%`,color:"bg-amber-500"})}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:88:13",className:"px-3 py-2 font-mono text-[var(--dg-text-secondary)]",children:Ca(Number(N?.value||0))}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:89:13",className:"px-3 py-2 font-mono text-[var(--dg-text-secondary)]",children:Ca(Number(w?.value||0))})]},e)})})]})}),Ps=({d:s})=>a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:98:3",className:"space-y-4",children:[a.jsx(Oa,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:99:5",items:[{label:"Running",value:s.running?.[0]?.value||0,color:"emerald"},{label:"Pending",value:s.pending?.[0]?.value||0,color:"amber"}]}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:105:5",className:"rounded-lg bg-[var(--dg-bg-primary)] p-3 max-h-40 overflow-y-auto",children:[a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:105:88",className:"text-xs font-medium mb-2",children:"CPU Top 10"}),(s.cpuTop||[]).map((r,e)=>a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:105:186",className:"flex items-center gap-2 text-[11px] mb-1",children:[a.jsx("span",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:105:252",className:"w-10 text-right text-[var(--dg-text-muted)]",children:e+1}),a.jsx("span",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:105:326",className:"w-32 truncate",title:r.pod,children:r.pod}),a.jsx(V,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:105:386",val:Number(r.value||0)*100,label:`${Number(r.value||0).toFixed(2)}c`,color:"bg-purple-500"})]},e))]}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:106:5",className:"rounded-lg bg-[var(--dg-bg-primary)] p-3 max-h-40 overflow-y-auto",children:[a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:106:88",className:"text-xs font-medium mb-2",children:"内存 Top 10"}),(s.memTop||[]).map((r,e)=>a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:106:185",className:"flex items-center gap-2 text-[11px] mb-1",children:[a.jsx("span",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:106:251",className:"w-10 text-right text-[var(--dg-text-muted)]",children:e+1}),a.jsx("span",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:106:325",className:"w-32 truncate",title:r.pod,children:r.pod}),a.jsx("span",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:106:385",className:"ml-auto",children:Ns(Number(r.value||0))})]},e))]})]}),As=({d:s})=>{const r=Number(s.heapUsed?.[0]?.value||0),e=Number(s.uptime?.[0]?.value||0);return a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:114:5",className:"grid grid-cols-5 gap-3",children:[a.jsx(U,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:115:7",className:"bg-[var(--dg-bg-primary)]",children:a.jsxs(H,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:115:51",className:"p-3 text-center",children:[a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:115:92",className:"text-lg font-bold",children:e>86400?`${(e/86400).toFixed(1)}d`:`${(e/3600).toFixed(1)}h`}),a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:115:210",className:"text-[10px] text-[var(--dg-text-muted)]",children:"Uptime"})]})}),a.jsx(U,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:116:7",className:"bg-[var(--dg-bg-primary)]",children:a.jsxs(H,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:116:51",className:"p-3 text-center",children:[a.jsx(V,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:116:92",val:r,label:`${r.toFixed(1)}%`,color:r>80?"bg-orange-500":"bg-purple-500"}),a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:116:183",className:"text-[10px] text-[var(--dg-text-muted)] mt-1",children:"Heap"})]})}),a.jsx(U,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:117:7",className:"bg-[var(--dg-bg-primary)]",children:a.jsxs(H,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:117:51",className:"p-3 text-center",children:[a.jsx(V,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:117:92",val:Number(s.nonHeapUsed?.[0]?.value||0),label:`${Number(s.nonHeapUsed?.[0]?.value||0).toFixed(1)}%`,color:"bg-blue-500"}),a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:117:228",className:"text-[10px] text-[var(--dg-text-muted)] mt-1",children:"Non-Heap"})]})}),a.jsx(U,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:118:7",className:"bg-[var(--dg-bg-primary)]",children:a.jsxs(H,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:118:51",className:"p-3 text-center",children:[a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:118:92",className:"text-lg font-bold text-emerald-400",children:s.threadCount?.[0]?.value||0}),a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:118:180",className:"text-[10px] text-[var(--dg-text-muted)]",children:"Threads"})]})}),a.jsx(U,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:119:7",className:"bg-[var(--dg-bg-primary)]",children:a.jsxs(H,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:119:51",className:"p-3 text-center",children:[a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:119:92",className:"text-lg font-bold text-amber-400",children:Number(s.gcPause?.[0]?.value||0).toFixed(3)}),a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:119:193",className:"text-[10px] text-[var(--dg-text-muted)]",children:"GC Pause (s)"})]})})]})},Ss=({dsUrl:s})=>{const[r,e]=o.useState(!1),[c,i]=o.useState(!1),[x,b]=o.useState(0),[g,N]=o.useState(""),[w,m]=o.useState("kubernetes"),[P,y]=o.useState({}),[z,v]=o.useState({}),[h,A]=o.useState({}),[W,Z]=o.useState({});o.useEffect(()=>{s&&T(s)},[s]);const T=async p=>{i(!0),N("");try{const f=await Pa.connect(p);e(!0),b(f.targets||0),F(p)}catch(f){e(!1),N(f.message||"连接失败")}finally{i(!1)}},F=async p=>{for(const f of["kubernetes","node","pod","jvm"])try{const n=await Pa.dashboard(p,f),l={};for(const[S,j]of Object.entries(n||{}))l[S]=Array.isArray(j)?j:j?.data?.result?vs(j.data.result):j;f==="kubernetes"&&y(l),f==="node"&&v(l),f==="pod"&&A(l),f==="jvm"&&Z(l)}catch{}},$=()=>{s&&T(s)};return!r&&!g?null:a.jsxs(U,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:167:5",className:"bg-[var(--dg-bg-secondary)] border-purple-500/20",children:[a.jsx(ya,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:168:7",className:"py-3 px-4 pb-2",children:a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:169:9",className:"flex items-center gap-2",children:[a.jsx(J,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:170:11",className:"h-4 w-4 text-purple-400"}),a.jsx(Ga,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:171:11",className:"text-sm font-medium",children:"Prometheus 监控"}),r&&a.jsxs(B,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:172:25",className:"text-[10px] bg-purple-500/10 text-purple-400",children:[x," targets"]}),r&&a.jsx("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:173:25",className:"ml-auto",children:a.jsxs(D,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:173:50",variant:"ghost",size:"sm",className:"h-6 px-2 text-[10px]",onClick:$,children:[a.jsx(ca,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:173:135",className:"w-3 h-3 mr-1"}),"刷新"]})})]})}),a.jsx(H,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:176:7",className:"px-4 pb-3 pt-0",children:c?a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:177:21",className:"text-center py-12",children:[a.jsx(aa,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:177:56",className:"h-6 w-6 mx-auto mb-2 animate-spin text-purple-400"}),a.jsx("p",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:177:129",className:"text-xs text-[var(--dg-text-muted)]",children:"连接中…"})]}):g?a.jsxs("div",{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:178:20",className:"p-3 rounded-lg bg-red-500/10 border border-red-500/20 text-xs text-red-400",children:[a.jsx(Na,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:178:112",className:"h-4 w-4 inline mr-1"}),g]}):a.jsxs(Ea,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:180:11",value:w,onValueChange:m,children:[a.jsxs(Ua,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:181:13",className:"bg-[var(--dg-bg-tertiary)] mb-3",children:[a.jsxs(R,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:182:15",value:"kubernetes",className:"text-xs",children:[a.jsx(Qa,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:182:67",className:"w-3 h-3 mr-1"}),"Kubernetes"]}),a.jsxs(R,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:183:15",value:"node",className:"text-xs",children:[a.jsx(Q,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:183:61",className:"w-3 h-3 mr-1"}),"Node"]}),a.jsxs(R,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:184:15",value:"pod",className:"text-xs",children:[a.jsx(ys,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:184:60",className:"w-3 h-3 mr-1"}),"Pod"]}),a.jsxs(R,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:185:15",value:"jvm",className:"text-xs",children:[a.jsx(ta,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:185:60",className:"w-3 h-3 mr-1"}),"JVM"]})]}),a.jsx(K,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:187:13",value:"kubernetes",children:a.jsx(Gs,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:187:45",d:P})}),a.jsx(K,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:188:13",value:"node",children:a.jsx(ws,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:188:39",d:z})}),a.jsx(K,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:189:13",value:"pod",children:a.jsx(Ps,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:189:38",d:h})}),a.jsx(K,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:190:13",value:"jvm",children:a.jsx(As,{"code-path":"src/components/monitor/dashboard/PrometheusDashboard.tsx:190:38",d:W})})]})})]})};function Cs(s){return s?Array.isArray(s)?s:Array.isArray(s.list)?s.list:Array.isArray(s.items)?s.items:Array.isArray(s.data)?s.data:[]:[]}function zs(){return typeof window<"u"&&window.location?{origin:window.location.origin,backend:`${window.location.protocol}//${window.location.hostname}:8080`}:{origin:"http://127.0.0.1",backend:"http://127.0.0.1:8080"}}function ks({open:s,onOpenChange:r,server:e,onInstalled:c,onFailed:i}){const x=ka(d=>d.token)||"<YOUR_TOKEN>",{origin:b,backend:g}=zs(),[N,w]=o.useState(!1),[m,P]=o.useState(!1),[y,z]=o.useState(!1),[v,h]=o.useState("auto"),[A,W]=o.useState("root"),[Z,T]=o.useState(""),[F,$]=o.useState(""),[p,f]=o.useState("password"),n=e&&!e.has_auth,l=`curl -fsSL ${b}/agent/install.sh | bash -s -- --server ${g} --token ${x}`,S=()=>{const d=document.createElement("textarea");d.value=l,d.style.position="fixed",d.style.top="0",d.style.left="0",d.style.width="2em",d.style.height="2em",d.style.padding="0",d.style.border="none",d.style.outline="none",d.style.boxShadow="none",d.style.background="transparent",d.style.opacity="0",d.style.pointerEvents="none",d.style.zIndex="-1",d.style.fontSize="16px",d.contentEditable="true",d.readOnly=!0,document.body.appendChild(d),d.focus(),d.select(),d.setSelectionRange&&d.setSelectionRange(0,999999);let _=!1;try{_=document.execCommand("copy")}catch{}document.body.removeChild(d),_?(w(!0),u.success("安装命令已复制到剪贴板,粘贴到目标主机执行"),setTimeout(()=>w(!1),3e3)):(u.error("自动复制失败,请在下方手动全选复制 (Ctrl+A → Ctrl+C)"),P(!0))},j=`${b}/agent/aiops-agent-linux-amd64`,ha=[{icon:is,title:"1. 下载二进制",commands:[`curl -fsSL ${j} -o /usr/local/bin/aiops-agent`]},{icon:ss,title:"2. 赋予执行权限",commands:["chmod +x /usr/local/bin/aiops-agent"]},{icon:za,title:"3. 创建 systemd 服务",commands:["cat > /etc/systemd/system/aiops-agent.service << 'EOF'","[Unit]","Description=AIOps Agent","After=network.target","","[Service]","Type=simple",`ExecStart=/usr/local/bin/aiops-agent --server ${g} --token ${x}`,"Restart=always","RestartSec=5","","[Install]","WantedBy=multi-user.target","EOF"]},{icon:ls,title:"4. 启动并设置开机自启",commands:["systemctl daemon-reload","systemctl enable --now aiops-agent","systemctl status aiops-agent"]}],M=async()=>{if(!(!e||!x)){if(n&&!Z&&!F){u.error("请填写 SSH 登录凭据(密码或密钥)");return}z(!0);try{const d=n?{username:A,password:Z,ssh_key:F,auth_type:p}:void 0;(await Ta.installAgent(e.id,x,d))?.installed||!1?(u.success(`${e.hostname} Agent 安装成功`),c?.(e.id),r(!1)):(u.warning(`${e.hostname}: Agent 安装命令已执行,但服务未检测到运行`),c?.(e.id),r(!1))}catch(d){const _=d?.message||"安装失败";u.error(`${e.hostname} ${_}`),i?.(e.id,_)}finally{z(!1)}}};return a.jsx(oa,{"code-path":"src/components/agent/AgentWizard.tsx:190:5",open:s,onOpenChange:r,children:a.jsxs(ra,{"code-path":"src/components/agent/AgentWizard.tsx:191:7",className:"max-w-2xl bg-slate-900 border-slate-800 text-slate-100",children:[a.jsxs(na,{"code-path":"src/components/agent/AgentWizard.tsx:192:9",children:[a.jsx(da,{"code-path":"src/components/agent/AgentWizard.tsx:193:11",className:"text-slate-100",children:e?`部署 Agent → ${e.hostname}`:"部署 Agent"}),a.jsx(Wa,{"code-path":"src/components/agent/AgentWizard.tsx:196:11",className:"text-slate-400",children:e?`目标主机 ${e.hostname} (${e.ip}),选择安装方式:`:"在目标主机上执行以下命令即可完成 Agent 安装与注册"})]}),a.jsxs(Ea,{"code-path":"src/components/agent/AgentWizard.tsx:204:9",value:v,onValueChange:h,className:"w-full",children:[a.jsxs(Ua,{"code-path":"src/components/agent/AgentWizard.tsx:205:11",className:"bg-slate-800 border border-slate-700",children:[a.jsxs(R,{"code-path":"src/components/agent/AgentWizard.tsx:206:13",value:"auto",className:"data-[state=active]:bg-slate-700",children:[a.jsx(xa,{"code-path":"src/components/agent/AgentWizard.tsx:207:15",className:"h-4 w-4 mr-1.5"}),"安装Agent"]}),e&&a.jsxs(R,{"code-path":"src/components/agent/AgentWizard.tsx:211:15",value:"ssh",className:"data-[state=active]:bg-slate-700",children:[a.jsx(ta,{"code-path":"src/components/agent/AgentWizard.tsx:212:17",className:"h-4 w-4 mr-1.5"}),"SSH一键安装"]}),!e&&a.jsxs(R,{"code-path":"src/components/agent/AgentWizard.tsx:217:15",value:"ssh",className:"data-[state=active]:bg-slate-700 opacity-50 cursor-not-allowed",disabled:!0,children:[a.jsx(ta,{"code-path":"src/components/agent/AgentWizard.tsx:218:17",className:"h-4 w-4 mr-1.5"}),"SSH一键安装"]}),a.jsx(R,{"code-path":"src/components/agent/AgentWizard.tsx:222:13",value:"manual",className:"data-[state=active]:bg-slate-700",children:"手动安装"})]}),a.jsxs(K,{"code-path":"src/components/agent/AgentWizard.tsx:228:11",value:"auto",className:"mt-4 space-y-3",children:[a.jsx("p",{"code-path":"src/components/agent/AgentWizard.tsx:229:13",className:"text-sm text-slate-400",children:"在目标主机执行以下命令,Agent 将自动下载、安装并启动:"}),a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:232:13",className:"relative rounded-lg bg-slate-950 border border-slate-800 p-4",children:[a.jsx("pre",{"code-path":"src/components/agent/AgentWizard.tsx:233:15",className:"text-xs text-emerald-400 font-mono whitespace-pre-wrap break-all pr-10",children:l}),a.jsx(D,{"code-path":"src/components/agent/AgentWizard.tsx:236:15",size:"icon",variant:"ghost",onClick:S,className:"absolute top-2 right-2 h-8 w-8 text-slate-400 hover:text-slate-100 hover:bg-slate-800",title:"复制到剪贴板",children:N?a.jsx(Xa,{"code-path":"src/components/agent/AgentWizard.tsx:243:27",className:"h-4 w-4 text-emerald-400"}):a.jsx(ms,{"code-path":"src/components/agent/AgentWizard.tsx:243:76",className:"h-4 w-4"})})]}),m&&a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:249:15",className:"rounded-lg bg-amber-950/30 border border-amber-800/50 p-4",children:[a.jsx("p",{"code-path":"src/components/agent/AgentWizard.tsx:250:17",className:"text-xs text-amber-400 mb-2",children:"⚠️ 自动复制失败。请点击下方输入框全选 (Ctrl+A) 后复制 (Ctrl+C):"}),a.jsx("textarea",{"code-path":"src/components/agent/AgentWizard.tsx:253:17",readOnly:!0,value:l,className:"w-full h-24 bg-slate-950 border border-amber-800/30 text-emerald-400 font-mono text-xs p-3 rounded resize-none focus:outline-none focus:border-amber-600",onClick:d=>d.target.select()})]}),a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:261:13",className:"flex items-start gap-2 text-xs text-slate-500",children:[a.jsx(xa,{"code-path":"src/components/agent/AgentWizard.tsx:262:15",className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),a.jsxs("span",{"code-path":"src/components/agent/AgentWizard.tsx:263:15",children:["服务器地址已自动检测 — 安装脚本通过 Nginx 代理 (",b,"),Agent 直连后端 (",g,")。安装成功后将自动连接并开始上报指标。"]})]})]}),!e&&a.jsx(K,{"code-path":"src/components/agent/AgentWizard.tsx:271:13",value:"ssh",className:"mt-4 space-y-4",children:a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:272:15",className:"text-center py-12 text-slate-400",children:[a.jsx(Q,{"code-path":"src/components/agent/AgentWizard.tsx:273:17",className:"h-10 w-10 mx-auto mb-3 opacity-50"}),a.jsx("p",{"code-path":"src/components/agent/AgentWizard.tsx:274:17",className:"text-sm font-medium mb-1",children:"未选择目标主机"}),a.jsx("p",{"code-path":"src/components/agent/AgentWizard.tsx:275:17",className:"text-xs",children:"请先在主机列表中勾选一台主机,再点击「安装 Agent」打开此页面"})]})}),e&&a.jsxs(K,{"code-path":"src/components/agent/AgentWizard.tsx:281:13",value:"ssh",className:"mt-4 space-y-4",children:[a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:282:15",className:"rounded-lg bg-slate-950 border border-slate-800 p-4",children:[a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:283:17",className:"flex items-center gap-3 mb-3",children:[a.jsx(Q,{"code-path":"src/components/agent/AgentWizard.tsx:284:19",className:"h-5 w-5 text-blue-400"}),a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:285:19",children:[a.jsx("p",{"code-path":"src/components/agent/AgentWizard.tsx:286:21",className:"text-sm font-medium text-slate-200",children:e.hostname}),a.jsx("code",{"code-path":"src/components/agent/AgentWizard.tsx:287:21",className:"text-xs text-slate-400",children:e.ip})]})]}),n&&a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:293:19",className:"mb-4 p-3 rounded-lg bg-amber-950/30 border border-amber-800/40 space-y-3",children:[a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:294:21",className:"flex items-center gap-2 text-xs text-amber-300/80",children:[a.jsx(as,{"code-path":"src/components/agent/AgentWizard.tsx:295:23",className:"h-3.5 w-3.5"}),a.jsx("span",{"code-path":"src/components/agent/AgentWizard.tsx:296:23",children:"该服务器未配置 SSH 凭据,请填写以下信息(首次连接成功后自动保存)"})]}),a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:298:21",className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:299:23",children:[a.jsx(L,{"code-path":"src/components/agent/AgentWizard.tsx:300:25",className:"text-xs text-slate-400",children:"用户名"}),a.jsx(X,{"code-path":"src/components/agent/AgentWizard.tsx:301:25",value:A,onChange:d=>W(d.target.value),placeholder:"root",className:"h-8 text-sm bg-slate-900 border-slate-700 text-slate-200 mt-1"})]}),a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:308:23",className:"flex items-end gap-1",children:[a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:309:25",className:"flex-1",children:[a.jsx(L,{"code-path":"src/components/agent/AgentWizard.tsx:310:27",className:"text-xs text-slate-400",children:"密码"}),a.jsx(X,{"code-path":"src/components/agent/AgentWizard.tsx:311:27",type:"password",value:Z,onChange:d=>{T(d.target.value),f("password")},placeholder:"******",className:"h-8 text-sm bg-slate-900 border-slate-700 text-slate-200 mt-1"})]}),a.jsx("span",{"code-path":"src/components/agent/AgentWizard.tsx:319:25",className:"text-xs text-slate-500 px-1 pb-1",children:"或"}),a.jsx(D,{"code-path":"src/components/agent/AgentWizard.tsx:320:25",variant:"ghost",size:"sm",onClick:()=>{f("key"),T("")},className:`text-xs h-7 px-2 ${p==="key"?"text-blue-400":"text-slate-500"}`,children:"密钥"})]})]}),p==="key"&&a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:328:23",children:[a.jsx(L,{"code-path":"src/components/agent/AgentWizard.tsx:329:25",className:"text-xs text-slate-400",children:"SSH 私钥(PEM 格式)"}),a.jsx("textarea",{"code-path":"src/components/agent/AgentWizard.tsx:330:25",value:F,onChange:d=>$(d.target.value),placeholder:`-----BEGIN OPENSSH PRIVATE KEY-----
|
||
...
|
||
-----END OPENSSH PRIVATE KEY-----`,rows:3,className:"w-full mt-1 bg-slate-900 border border-slate-700 text-slate-200 font-mono text-xs p-2 rounded-md resize-none"})]})]}),a.jsx("p",{"code-path":"src/components/agent/AgentWizard.tsx:342:17",className:"text-sm text-slate-400 mb-4",children:"通过 SSH 远程连接到目标主机,自动下载并安装 Agent,完成后立即启动运行。"}),a.jsx(D,{"code-path":"src/components/agent/AgentWizard.tsx:345:17",onClick:M,disabled:y,className:"w-full bg-blue-600 hover:bg-blue-700 text-white",children:y?a.jsxs(a.Fragment,{children:[a.jsx(aa,{"code-path":"src/components/agent/AgentWizard.tsx:352:23",className:"h-4 w-4 mr-2 animate-spin"}),"SSH 连接中,正在安装..."]}):a.jsxs(a.Fragment,{children:[a.jsx(ta,{"code-path":"src/components/agent/AgentWizard.tsx:357:23",className:"h-4 w-4 mr-2"}),n?"连接并安装 Agent(凭据将自动保存)":"一键安装 Agent"]})})]}),a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:363:15",className:"flex items-start gap-2 text-xs text-slate-500",children:[a.jsx(xa,{"code-path":"src/components/agent/AgentWizard.tsx:364:17",className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),a.jsxs("span",{"code-path":"src/components/agent/AgentWizard.tsx:365:17",children:["系统将通过 SSH 连接 ",e.ip,",执行安装脚本。请确保服务器 SSH 凭据已正确配置(编辑服务器可修改密码/密钥)。"]})]})]}),a.jsxs(K,{"code-path":"src/components/agent/AgentWizard.tsx:373:11",value:"manual",className:"mt-4 space-y-4",children:[a.jsx("div",{"code-path":"src/components/agent/AgentWizard.tsx:374:13",className:"max-h-[420px] overflow-y-auto space-y-3 pr-1",children:ha.map(d=>a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:376:17",className:"rounded-lg bg-slate-950 border border-slate-800 overflow-hidden",children:[a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:377:19",className:"flex items-center gap-2 px-4 py-2.5 bg-slate-800/50",children:[a.jsx(d.icon,{"code-path":"src/components/agent/AgentWizard.tsx:378:21",className:"h-4 w-4 text-blue-400"}),a.jsx("span",{"code-path":"src/components/agent/AgentWizard.tsx:379:21",className:"text-sm font-medium text-slate-200",children:d.title})]}),a.jsx("div",{"code-path":"src/components/agent/AgentWizard.tsx:381:19",className:"p-3 space-y-1",children:d.commands.map((_,sa)=>a.jsxs("div",{"code-path":"src/components/agent/AgentWizard.tsx:383:23",className:"flex items-start gap-2",children:[a.jsx("span",{"code-path":"src/components/agent/AgentWizard.tsx:384:25",className:"text-slate-600 font-mono text-xs select-none mt-0.5",children:"$"}),a.jsx("code",{"code-path":"src/components/agent/AgentWizard.tsx:385:25",className:"text-xs text-slate-300 font-mono whitespace-pre-wrap break-all flex-1",children:_})]},sa))})]},d.title))}),a.jsx("p",{"code-path":"src/components/agent/AgentWizard.tsx:394:13",className:"text-xs text-slate-500",children:"完成上述步骤后,Agent 将作为 systemd 服务运行并自动上报指标。"})]})]})]})})}const Ws=[{id:"agent",label:"Agent 主机",icon:a.jsx(Q,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:51:43",className:"w-3.5 h-3.5"})},{id:"zabbix",label:"Zabbix",icon:a.jsx(J,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:52:42",className:"w-3.5 h-3.5"})},{id:"prometheus",label:"Prometheus",icon:a.jsx(J,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:53:50",className:"w-3.5 h-3.5"})},{id:"dashboard",label:"自定义",icon:a.jsx(_a,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:54:42",className:"w-3.5 h-3.5"})}],_s=()=>{const s=es(),r=ts(),[e,c]=o.useState([]),[i,x]=o.useState(!0),[b,g]=o.useState("cpu_usage"),[N,w]=o.useState("desc"),[m,P]=o.useState(1),[y,z]=o.useState(10),[v,h]=o.useState(new Set),[A,W]=o.useState(!1),[Z,T]=o.useState(null),[F,$]=o.useState(!1),[p,f]=o.useState("install"),[n,l]=o.useState(!1),[S,j]=o.useState(!1),[ha,M]=o.useState(new Set),[d,_]=o.useState(!1),sa=async()=>{if(await s({title:"批量卸载 Agent",description:`确定卸载选中的 ${ea.length} 台主机的 AIOps Agent?卸载将在后台异步执行。`,confirmText:"卸载",variant:"destructive"})){_(!0),M(new Set(ea));try{await ja.batchUninstall(ea),u.success(`已提交:批量卸载 ${ea.length} 台主机的 Agent,后台执行中,30秒后自动刷新`),h(new Set),setTimeout(()=>{q(),M(new Set)},3e4)}catch{u.error("提交失败"),M(new Set)}finally{_(!1)}}},wa=Math.max(1,Math.ceil(e.length/y)),q=async()=>{try{c(Cs(await ja.getLatest()))}catch{}finally{x(!1)}};o.useEffect(()=>{q();const t=setInterval(q,3e4);return()=>clearInterval(t)},[]);const La=t=>{b===t?w(C=>C==="asc"?"desc":"asc"):(g(t),w("desc"))},Ra=[...e].sort((t,C)=>{let G=t[b]??"",k=C[b]??"";return b==="agent_status"&&(G=t.agent_status||"",k=C.agent_status||""),typeof G=="number"?N==="asc"?G-k:k-G:N==="asc"?String(G).localeCompare(String(k)):String(k).localeCompare(String(G))}).slice((m-1)*y,m*y),Ka=({f:t})=>b!==t?a.jsx(Ma,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:106:54",className:"w-3 h-3 text-slate-500"}):N==="asc"?a.jsx(Ia,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:106:122",className:"w-3 h-3 text-emerald-400"}):a.jsx(Ba,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:106:173",className:"w-3 h-3 text-emerald-400"}),ma=(t,C)=>a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:108:5",className:"flex items-center gap-2 min-w-[90px]",children:[a.jsx("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:108:59",className:"flex-1 h-2.5 rounded-full bg-[var(--dg-bg-tertiary)] overflow-hidden",children:a.jsx("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:108:145",className:`h-full rounded-full transition-all duration-500 ${t>=80?"bg-orange-500":"bg-emerald-500"}`,style:{width:`${Math.min(t,100)}%`}})}),a.jsx("span",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:108:310",className:`w-14 text-right text-xs font-mono tabular-nums ${t>=80?"text-orange-400":""}`,children:C})]}),Va=v.size===e.length&&e.length>0,ia=v.size>0,ea=[...v].map(Number).filter(t=>!isNaN(t)),Y=o.useMemo(()=>e.filter(t=>v.has(String(t.server_id))),[e,v]),O=o.useMemo(()=>Y.filter(t=>t.agent_status!=="online"),[Y]),E=o.useMemo(()=>Y.filter(t=>t.agent_status==="online"),[Y]),qa=()=>{l(!1),O.length>0&&E.length===0?f("install"):O.length===0&&E.length>0?f("upgrade"):f("install"),$(!0)},Ja=async()=>{if(!n){u.error("请先确认并勾选「我已知悉」");return}j(!0);const t=ka.getState().token,C=Y.map(G=>G.server_id);M(new Set(C));try{if(p==="install"){if(!t){u.error("未登录");return}const G=O.map(la=>la.server_id);if(G.length===0){u.warning("所选主机均已安装 Agent,无需安装");return}const k=await Ta.batchInstallAgent(G,t);u.success(`已提交:批量安装 ${k?.total??G.length} 台主机的 Agent,后台执行中,30秒后自动刷新`),h(new Set),setTimeout(()=>{q(),M(new Set)},3e4)}else{const G=E.map(la=>la.server_id);if(G.length===0){u.warning("所选主机中没有在线 Agent,无法升级");return}const k=await ja.batchUpgrade(G);u.success(k?.message||`已提交:批量升级 ${G.length} 台主机的 Agent,后台执行中,30秒后自动刷新`),h(new Set),setTimeout(()=>{q(),M(new Set)},3e4)}$(!1)}catch{u.error("提交失败"),M(new Set)}finally{j(!1)}};return i?a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:163:23",className:"text-center py-20 text-[var(--dg-text-muted)]",children:[a.jsx(J,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:163:86",className:"h-6 w-6 mx-auto mb-2 animate-spin"}),a.jsx("p",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:163:144",className:"text-xs",children:"加载中…"})]}):e.length?a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:166:5",children:[a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:168:7",className:"flex items-center gap-2 mb-3 flex-wrap",children:[ia&&a.jsxs("span",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:169:20",className:"text-xs text-[var(--dg-text-secondary)]",children:["已选 ",v.size," 项"]}),a.jsx("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:170:9",className:"flex-1"}),a.jsxs(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:171:9",size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:()=>{const t=ia?e.find(C=>v.has(String(C.server_id))):null;T(t?{id:t.server_id,hostname:t.hostname,ip:t.ip,has_auth:t.has_auth}:null),W(!0)},children:[a.jsx(os,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:176:11",className:"w-3 h-3"}),"安装 Agent"]}),ia&&a.jsxs(a.Fragment,{children:[a.jsxs(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:180:13",size:"sm",variant:"outline",className:"h-7 text-xs gap-1 border-blue-500/30 text-blue-400 hover:bg-blue-500/10",onClick:qa,children:[a.jsx(Aa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:181:15",className:"w-3 h-3"}),"批量部署 (",v.size,")"]}),a.jsxs(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:183:13",size:"sm",variant:"outline",className:"h-7 text-xs gap-1 border-red-500/30 text-red-400 hover:bg-red-500/10",onClick:sa,disabled:d,children:[a.jsx(bs,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:184:15",className:"w-3 h-3"}),"批量卸载 (",v.size,")"]})]}),a.jsxs(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:188:9",size:"sm",variant:"ghost",className:"h-7 text-xs gap-1",onClick:q,children:[a.jsx(ca,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:188:89",className:"w-3 h-3"}),"刷新"]})]}),a.jsx(ks,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:191:7",open:A,onOpenChange:W,server:Z,onInstalled:()=>{u.success("Agent 安装成功"),W(!1),q()},onFailed:()=>u.error("安装失败")}),a.jsx(oa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:196:7",open:F,onOpenChange:t=>{t||($(!1),l(!1))},children:a.jsxs(ra,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:197:9",className:"max-w-2xl max-h-[85vh] overflow-auto bg-slate-900 border-slate-700 text-slate-100",children:[a.jsxs(na,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:198:11",children:[a.jsxs(da,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:199:13",className:"flex items-center gap-2 text-base",children:[a.jsx(Aa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:200:15",className:"w-5 h-5 text-blue-400"}),"批量部署 Agent"]}),a.jsxs(Wa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:203:13",className:"text-slate-400 text-xs",children:["选中 ",Y.length," 台主机(需安装: ",O.length,",待升级: ",E.length,")"]})]}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:208:11",className:"space-y-4",children:[a.jsx("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:210:13",className:"flex items-center gap-2 p-1 rounded-lg bg-slate-800 border border-slate-700 w-fit",children:["install","upgrade"].map(t=>a.jsx("button",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:212:17",disabled:t==="install"?O.length===0:E.length===0,onClick:()=>f(t),className:`px-4 py-1.5 rounded text-xs font-medium transition-colors disabled:opacity-30 disabled:cursor-not-allowed ${p===t?"bg-blue-600 text-white shadow-sm":"text-slate-400 hover:text-slate-200"}`,children:t==="install"?`⚡ 安装 (${O.length})`:`🔄 升级到最新版 (${E.length})`},t))}),a.jsx("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:226:13",className:"rounded-md border border-slate-700 overflow-hidden",children:a.jsxs("table",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:227:15",className:"w-full text-xs",children:[a.jsx("thead",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:228:17",className:"bg-slate-800",children:a.jsxs("tr",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:229:19",children:[a.jsx("th",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:230:21",className:"px-3 py-2 text-left font-medium text-slate-400",children:"主机名"}),a.jsx("th",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:231:21",className:"px-3 py-2 text-left font-medium text-slate-400",children:"IP"}),a.jsx("th",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:232:21",className:"px-3 py-2 text-left font-medium text-slate-400",children:"状态"}),a.jsx("th",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:233:21",className:"px-3 py-2 text-left font-medium text-slate-400",children:"当前版本"}),a.jsx("th",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:234:21",className:"px-3 py-2 text-left font-medium text-slate-400",children:"操作"})]})}),a.jsx("tbody",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:237:17",children:(p==="install"?O:E).map(t=>a.jsxs("tr",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:239:21",className:"border-t border-slate-800 hover:bg-slate-800/50",children:[a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:240:23",className:"px-3 py-2 font-medium text-slate-200",children:t.hostname}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:241:23",className:"px-3 py-2 font-mono text-slate-400",children:t.ip}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:242:23",className:"px-3 py-2",children:t.agent_status==="online"?a.jsx(B,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:244:29",className:"text-[10px] bg-emerald-500/20 text-emerald-400",children:"在线"}):a.jsx(B,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:245:29",className:"text-[10px] bg-slate-500/20 text-slate-400",children:t.agent_status==="not_installed"?"未安装":t.agent_status||"离线"})}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:249:23",className:"px-3 py-2 font-mono text-slate-400",children:t.agent_version||"—"}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:250:23",className:"px-3 py-2",children:a.jsx("span",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:251:25",className:"text-blue-400 text-[11px]",children:p==="install"?"即将安装":"即将升级"})})]},t.server_id))})]})}),a.jsx("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:262:13",className:"rounded-md border border-amber-500/30 bg-amber-500/5 p-3 space-y-2",children:a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:263:15",className:"flex items-start gap-2",children:[a.jsx(rs,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:264:17",className:"w-4 h-4 text-amber-400 mt-0.5 shrink-0"}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:265:17",children:[a.jsxs("p",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:266:19",className:"text-xs font-medium text-amber-300 mb-1",children:[p==="install"?"本次安装":"本次升级",",主机监控探针将部署 AIOps Agent。AIOps Agent 是 AIOps 平台推出的新一代数据采集器,提供主机监控指标采集和可观测数据采集能力。"]}),a.jsxs("p",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:269:19",className:"text-[11px] text-amber-400/80 leading-relaxed",children:[p==="upgrade"&&"升级前请注意以下事项:",p==="install"&&"安装前请注意以下事项:"]}),a.jsxs("ul",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:273:19",className:"mt-1 space-y-0.5 text-[11px] text-slate-400 list-disc list-inside",children:[p==="upgrade"&&a.jsxs(a.Fragment,{children:[a.jsx("li",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:276:25",children:"如果您的机器已经安装旧版 Agent,升级操作将停止旧版并替换为最新版本。"}),a.jsx("li",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:277:25",children:"如果您的机器之前安装过 Agent 但已卸载,遗留有相关采集配置,本次升级可能导致配置重新生效。升级前请确保存量废弃配置已经移除。"}),a.jsx("li",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:278:25",children:"如果您的机器采用自定义安装的 Agent(非 AIOps 提供的一键安装脚本),请不要直接使用批量升级。"}),a.jsx("li",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:279:25",children:"批量升级前,请务必先单机灰度升级,确保升级成功且不影响业务后再操作。"})]}),p==="install"&&a.jsxs(a.Fragment,{children:[a.jsx("li",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:284:25",children:"安装将自动检测目标主机架构(amd64/arm64),下载对应版本的 Agent 二进制并启动服务。"}),a.jsx("li",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:285:25",children:"请确保目标主机的 SSH 端口(默认 22)可访问,且已关联有效的 SSH 凭据。"}),a.jsx("li",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:286:25",children:"安装过程约 30-60 秒,期间目标主机 CPU 负载会短暂升高。"}),a.jsx("li",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:287:25",children:"若安装失败,请检查目标主机的防火墙规则和 SSH 服务状态后重试。"})]}),a.jsx("li",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:290:21",children:"操作不可回滚,请在操作前确认已备份关键配置。"}),a.jsx("li",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:291:21",children:"操作将在后台异步执行,您可以在「任务执行记录」中查看详细进度。"})]})]})]})}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:298:13",className:"flex items-center gap-2",children:[a.jsx(Da,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:299:15",id:"batch-ack",checked:n,onCheckedChange:t=>l(!!t)}),a.jsx("label",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:300:15",htmlFor:"batch-ack",className:"text-xs text-slate-300 cursor-pointer select-none",children:"我已知悉以上风险和注意事项"})]})]}),a.jsxs(va,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:304:11",className:"gap-2",children:[a.jsx(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:305:13",variant:"outline",className:"border-slate-700 text-slate-300 h-8 text-xs",onClick:()=>{$(!1),l(!1)},children:"取消"}),a.jsxs(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:308:13",className:"bg-blue-600 hover:bg-blue-700 text-white h-8 text-xs gap-1",disabled:S||!n||(p==="install"?O.length===0:E.length===0),onClick:Ja,children:[S&&a.jsx(aa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:313:35",className:"w-3 h-3 animate-spin"}),p==="install"?"确认安装":"确认升级"]})]})]})}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:320:7",className:"overflow-x-auto rounded-lg border border-[var(--dg-border)]",children:[a.jsxs("table",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:321:9",className:"w-full text-xs",children:[a.jsx("thead",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:322:11",className:"bg-[var(--dg-bg-tertiary)] border-b",children:a.jsxs("tr",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:322:66",children:[a.jsx("th",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:323:13",className:"px-2 py-2 w-8",children:a.jsx(Da,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:324:15",checked:Va,onCheckedChange:t=>h(t?new Set(e.map(C=>String(C.server_id))):new Set)})}),["hostname","agent_version","agent_status","cpu_usage","mem_usage","disk_usage","region","ip"].map(t=>a.jsx("th",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:327:15",className:"px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)] cursor-pointer hover:text-[var(--dg-text-primary)] select-none whitespace-nowrap",onClick:()=>La(t),children:a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:328:17",className:"flex items-center gap-1",children:[{hostname:"主机名",agent_version:"Agent版本",agent_status:"状态",cpu_usage:"CPU",mem_usage:"内存",disk_usage:"磁盘",region:"区域",ip:"IP"}[t],a.jsx(Ka,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:328:188",f:t})]})},t)),a.jsx("th",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:331:13",className:"px-3 py-2 text-left font-medium text-[var(--dg-text-secondary)] whitespace-nowrap",children:"操作"})]})}),a.jsx("tbody",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:332:11",children:Ra.map((t,C)=>a.jsxs("tr",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:334:15",className:"border-b border-[var(--dg-border)] last:border-0 hover:bg-[var(--dg-bg-tertiary)]/50",children:[a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:335:17",className:"px-2 py-2.5",children:a.jsx(Da,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:336:19",checked:v.has(String(t.server_id)),onCheckedChange:G=>{const k=new Set(v);G?k.add(String(t.server_id)):k.delete(String(t.server_id)),h(k)}})}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:342:17",className:"px-3 py-2.5 font-medium text-[var(--dg-text-primary)]",children:t.hostname}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:343:17",className:"px-3 py-2.5 font-mono text-[var(--dg-text-secondary)]",children:ha.has(t.server_id)?a.jsxs("span",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:345:21",className:"inline-flex items-center gap-1 text-blue-400",children:[a.jsx(aa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:346:23",className:"w-3 h-3 animate-spin"}),a.jsx("span",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:347:23",className:"text-[10px]",children:"部署中"})]}):t.agent_version||"—"}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:353:17",className:"px-3 py-2.5",children:t.agent_status==="online"?a.jsxs(B,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:353:72",className:"text-[10px] bg-emerald-500/20 text-emerald-400",children:[a.jsx(Fa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:353:138",className:"w-3 h-3 mr-1"}),"在线"]}):t.agent_status==="not_installed"?a.jsx(B,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:353:214",className:"text-[10px] bg-amber-500/20 text-amber-400",children:"未安装"}):a.jsxs(B,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:353:288",className:"text-[10px] bg-slate-500/10 text-slate-400",children:[a.jsx(gs,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:353:350",className:"w-3 h-3 mr-1"}),"离线"]})}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:354:17",className:"px-3 py-2.5",children:ma(Number(t.cpu_usage||0),`${Number(t.cpu_usage||0).toFixed(1)}%`)}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:355:17",className:"px-3 py-2.5",children:ma(Number(t.mem_usage||0),`${Number(t.mem_usage||0).toFixed(1)}%`)}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:356:17",className:"px-3 py-2.5",children:ma(Number(t.disk_usage||0),`${Number(t.disk_usage||0).toFixed(1)}%`)}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:357:17",className:"px-3 py-2.5 text-[var(--dg-text-secondary)]",children:t.region||"—"}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:358:17",className:"px-3 py-2.5 font-mono text-[var(--dg-text-secondary)]",children:t.ip||"—"}),a.jsx("td",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:359:17",className:"px-3 py-2.5",children:a.jsxs(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:360:19",variant:"ghost",size:"sm",className:"h-7 text-xs text-blue-400 hover:text-blue-300 hover:bg-blue-500/10 px-2",onClick:()=>r(`/host-monitor?host=${encodeURIComponent(t.hostname)}`),children:[a.jsx($a,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:362:21",className:"w-3.5 h-3.5 mr-1"}),"图表"]})})]},t.hostname+C))})]}),e.length>y&&a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:370:11",className:"flex items-center justify-between px-3 py-2 bg-[var(--dg-bg-tertiary)] border-t border-[var(--dg-border)] text-xs",children:[a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:371:13",className:"flex items-center gap-2 text-[var(--dg-text-muted)]",children:[a.jsxs("span",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:372:15",children:["共 ",e.length," 条"]}),a.jsxs("select",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:373:15",className:"bg-[var(--dg-bg-primary)] border border-[var(--dg-border)] rounded px-2 py-0.5 text-xs",value:y,onChange:t=>{z(Number(t.target.value)),P(1)},children:[a.jsx("option",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:374:17",value:10,children:"10/页"}),a.jsx("option",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:375:17",value:20,children:"20/页"}),a.jsx("option",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:376:17",value:30,children:"30/页"})]})]}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:379:13",className:"flex items-center gap-1",children:[a.jsx("button",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:380:15",className:"px-2 py-0.5 rounded hover:bg-[var(--dg-bg-primary)] disabled:opacity-30",disabled:m<=1,onClick:()=>P(t=>t-1),children:"上一页"}),a.jsxs("span",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:381:15",className:"px-2 text-[var(--dg-text-primary)]",children:[m," / ",wa]}),a.jsx("button",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:382:15",className:"px-2 py-0.5 rounded hover:bg-[var(--dg-bg-primary)] disabled:opacity-30",disabled:m>=wa,onClick:()=>P(t=>t+1),children:"下一页"})]})]})]})]}):a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:164:29",className:"text-center py-20 text-[var(--dg-text-muted)]",children:[a.jsx(Q,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:164:92",className:"h-8 w-8 mx-auto mb-2"}),a.jsx("p",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:164:135",className:"text-sm",children:"暂无服务器资产"}),a.jsx("p",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:164:169",className:"text-xs mt-1",children:"请先在「服务器管理」中添加主机,然后在此安装 Agent"})]})},$s=()=>{const[s,r]=o.useState(null),[e,c]=o.useState(!0);return o.useEffect(()=>{ns.list().then(i=>{const x=i?.data||i||[];r(x.find(b=>b.is_default)||x[0]||null)}).catch(()=>{}).finally(()=>c(!1))},[]),e?a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:401:23",className:"text-center py-20 text-[var(--dg-text-muted)]",children:[a.jsx(J,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:401:86",className:"h-6 w-6 mx-auto mb-2 animate-spin"}),a.jsx("p",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:401:144",className:"text-xs",children:"加载数据源…"})]}):s?a.jsx(Ds,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:403:10",dsUrl:s.url,dsUsername:s.username,dsPassword:s.password}):a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:402:19",className:"text-center py-20 text-[var(--dg-text-muted)]",children:[a.jsx(Za,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:402:82",className:"h-8 w-8 mx-auto mb-2"}),a.jsx("p",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:402:127",className:"text-sm",children:"未配置 Zabbix 数据源"}),a.jsxs("a",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:402:168",href:"/datasources",className:"text-xs text-blue-400 hover:underline inline-flex items-center gap-1",children:["前往配置 ",a.jsx(Ha,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:402:277",className:"w-3 h-3"})]})]})},Zs=()=>{const[s,r]=o.useState(null),[e,c]=o.useState(!0);return o.useEffect(()=>{ds.list().then(i=>{const x=i?.data||i||[];r(x.find(b=>b.is_default)||x[0]||null)}).catch(()=>{}).finally(()=>c(!1))},[]),e?a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:415:23",className:"text-center py-20 text-[var(--dg-text-muted)]",children:[a.jsx(J,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:415:86",className:"h-6 w-6 mx-auto mb-2 animate-spin"}),a.jsx("p",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:415:144",className:"text-xs",children:"加载数据源…"})]}):s?a.jsx(Ss,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:417:10",dsUrl:s.url}):a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:416:19",className:"text-center py-20 text-[var(--dg-text-muted)]",children:[a.jsx(Za,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:416:82",className:"h-8 w-8 mx-auto mb-2"}),a.jsx("p",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:416:127",className:"text-sm",children:"未配置 Prometheus 数据源"}),a.jsxs("a",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:416:172",href:"/datasources",className:"text-xs text-blue-400 hover:underline inline-flex items-center gap-1",children:["前往配置 ",a.jsx(Ha,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:416:281",className:"w-3 h-3"})]})]})},Ts=()=>{const[s,r]=o.useState([]),[e,c]=o.useState(null),[i,x]=o.useState(!1),[b,g]=o.useState(!1),[N,w]=o.useState({name:"",description:"",datasource:"prometheus",datasourceUrl:""}),[m,P]=o.useState({title:"",type:"graph",query:"",width:6,height:4}),y=async()=>{try{const A=(await fa.getDashboards()).data||[];r(A),A.length>0&&!e&&c(A[0])}catch{}};o.useEffect(()=>{y()},[]);const z=async()=>{if(!N.name){u.error("请输入名称");return}try{await fa.createDashboard({...N,panels:[]}),u.success("创建成功"),x(!1),w({name:"",description:"",datasource:"prometheus",datasourceUrl:""}),y()}catch{u.error("创建失败")}},v=async()=>{if(!(!m.title||!m.query||!e))try{const h={id:Date.now().toString(),...m,datasource:e.datasource,x:0,y:0,options:{legend:!0,tooltip:!0,refreshInterval:30}};await fa.updateDashboard(e.id,{...e,panels:[...e.panels,h]}),u.success("面板添加成功"),g(!1),P({title:"",type:"graph",query:"",width:6,height:4}),y()}catch{u.error("添加失败")}};return a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:451:5",className:"space-y-4",children:[a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:452:7",className:"flex items-center gap-2",children:[a.jsxs(pa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:453:9",value:e?.id,onValueChange:h=>{const A=s.find(W=>W.id===h);A&&c(A)},children:[a.jsx(ba,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:454:11",className:"w-[240px] h-8 text-xs",children:a.jsx(ua,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:454:60",placeholder:"选择仪表盘"})}),a.jsx(ga,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:455:11",children:s.map(h=>a.jsxs(I,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:455:47",value:h.id,children:[h.name,h.isDefault?" (默认)":""]},h.id))})]}),a.jsxs(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:457:9",variant:"outline",size:"sm",className:"h-8 text-[10px]",onClick:y,children:[a.jsx(ca,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:457:89",className:"w-3 h-3 mr-1"}),"刷新"]}),e&&a.jsxs(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:458:20",variant:"outline",size:"sm",className:"h-8 text-[10px]",onClick:()=>g(!0),children:[a.jsx(Sa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:458:117",className:"w-3 h-3 mr-1"}),"添加面板"]}),a.jsxs(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:459:9",variant:"outline",size:"sm",className:"h-8 text-[10px]",onClick:()=>x(!0),children:[a.jsx(Sa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:459:109",className:"w-3 h-3 mr-1"}),"新建"]})]}),e?e.panels.length===0?a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:464:11",className:"text-center py-16 text-[var(--dg-text-muted)]",children:[a.jsx($a,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:464:74",className:"w-10 h-10 mx-auto mb-2 opacity-50"}),a.jsx("p",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:464:133",className:"text-xs",children:"暂无面板"})]}):a.jsx("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:466:11",className:"grid grid-cols-12 gap-3",children:e.panels.map(h=>a.jsxs(U,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:468:15",style:{gridColumn:`span ${h.width}`,minHeight:`${h.height*80}px`},children:[a.jsx(ya,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:469:17",className:"py-2 px-3",children:a.jsx(Ga,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:469:51",className:"text-[11px] font-medium",children:h.title})}),a.jsx(H,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:470:17",className:"p-3 pt-0",children:a.jsx(js,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:470:51",panel:h})})]},h.id))}):a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:476:9",className:"text-center py-16 text-[var(--dg-text-muted)]",children:[a.jsx(_a,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:476:72",className:"w-10 h-10 mx-auto mb-2 opacity-50"}),a.jsx("p",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:476:129",className:"text-xs",children:"暂无仪表盘"})]}),a.jsx(oa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:479:7",open:i,onOpenChange:x,children:a.jsxs(ra,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:479:62",children:[a.jsx(na,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:479:77",children:a.jsx(da,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:479:91",children:"新建仪表盘"})}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:480:9",className:"space-y-3",children:[a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:480:36",children:[a.jsx(L,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:480:41",children:"名称"}),a.jsx(X,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:480:58",value:N.name,onChange:h=>w({...N,name:h.target.value})})]}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:481:11",children:[a.jsx(L,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:481:16",children:"数据源"}),a.jsxs(pa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:481:34",value:N.datasource,onValueChange:h=>w({...N,datasource:h}),children:[a.jsx(ba,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:481:124",children:a.jsx(ua,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:481:139"})}),a.jsxs(ga,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:481:170",children:[a.jsx(I,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:481:185",value:"prometheus",children:"Prometheus"}),a.jsx(I,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:481:239",value:"zabbix",children:"Zabbix"}),a.jsx(I,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:481:285",value:"skywalking",children:"SkyWalking"}),a.jsx(I,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:481:339",value:"custom",children:"自定义"})]})]})]})]}),a.jsxs(va,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:482:9",children:[a.jsx(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:482:23",variant:"outline",onClick:()=>x(!1),children:"取消"}),a.jsx(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:482:97",onClick:z,children:"创建"})]})]})}),a.jsx(oa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:484:7",open:b,onOpenChange:g,children:a.jsxs(ra,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:484:56",children:[a.jsx(na,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:484:71",children:a.jsx(da,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:484:85",children:"添加面板"})}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:485:9",className:"space-y-3",children:[a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:485:36",children:[a.jsx(L,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:485:41",children:"标题"}),a.jsx(X,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:485:58",value:m.title,onChange:h=>P({...m,title:h.target.value})})]}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:486:11",children:[a.jsx(L,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:486:16",children:"类型"}),a.jsxs(pa,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:486:33",value:m.type,onValueChange:h=>P({...m,type:h}),children:[a.jsx(ba,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:486:111",children:a.jsx(ua,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:486:126"})}),a.jsxs(ga,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:486:157",children:[a.jsx(I,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:486:172",value:"graph",children:"折线图"}),a.jsx(I,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:486:214",value:"stat",children:"数值"}),a.jsx(I,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:486:254",value:"gauge",children:"仪表盘"}),a.jsx(I,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:486:296",value:"table",children:"表格"})]})]})]}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:487:11",children:[a.jsx(L,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:487:16",children:"查询"}),a.jsx(X,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:487:33",value:m.query,onChange:h=>P({...m,query:h.target.value})})]})]}),a.jsxs(va,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:488:9",children:[a.jsx(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:488:23",variant:"outline",onClick:()=>g(!1),children:"取消"}),a.jsx(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:488:94",onClick:v,children:"添加"})]})]})})]})},pe=()=>{const[s,r]=o.useState("agent"),[e,c]=o.useState(!1);return a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:499:5",className:`space-y-4 ${e?"fixed inset-0 z-50 bg-background p-4 overflow-auto":""}`,children:[a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:502:7",className:"flex items-center gap-1 p-1 rounded-lg bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)]",children:[Ws.map(i=>a.jsxs("button",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:504:11",onClick:()=>r(i.id),className:`flex items-center gap-1.5 px-4 py-2 rounded-md text-xs font-medium transition-colors ${s===i.id?"bg-[var(--dg-bg-primary)] text-[var(--dg-text-primary)] shadow-sm":"text-[var(--dg-text-muted)] hover:text-[var(--dg-text-secondary)]"}`,children:[i.icon,i.label]},i.id)),a.jsx("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:517:9",className:"ml-auto",children:a.jsx(D,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:518:11",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>c(!e),children:e?a.jsx(xs,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:519:27",className:"w-3.5 h-3.5"}):a.jsx(ps,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:519:67",className:"w-3.5 h-3.5"})})})]}),a.jsxs("div",{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:525:7",className:"min-h-[50vh]",children:[s==="agent"&&a.jsx(_s,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:526:29"}),s==="zabbix"&&a.jsx($s,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:527:30"}),s==="prometheus"&&a.jsx(Zs,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:528:34"}),s==="dashboard"&&a.jsx(Ts,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:529:33"})]})]})};export{pe as default};
|