refactor(frontend): API 子模块化、大组件拆分与 TanStack Query hooks
P1: kubernetes/system API 拆为子目录模块,导出工具下沉到 lib/export-utils,
http 统一 buildApiUrl/getWsBase;HostMonitor、DeploymentEdit* 拆至子组件。
P2: 新增 hooks/api(queryKeys、useTerminalSessions、useHostMonitor),
TerminalSessionsTab 与 HostMonitor 接入 TanStack Query。
P3: 保留 services/api 路径,未迁移至 api/ 目录。
This commit is contained in:
1 parent
7fb2236b4d
commit
0b404b4611
226 files changed
+3040
-2596
No files matched your search
+3
-3
@@ -1,4 +1,4 @@
|
||||
import{j as s,a2 as b,aJ as f,L as v,$ as w,a3 as g,H as C,B as A,r as l,D as O,b as U,c as J,d as B,e as E,a9 as L,T as R,q as G,x as H}from"./index-DfyorCky.js";import{C as z,b as $,c as D,a as F}from"./card-C55cvSHg.js";import{B as y}from"./badge-xNW8x0G1.js";import{a as K}from"./monitor-BAaBXIsC.js";import{a as q}from"./ai-BTgmlP5Q.js";import{S}from"./sparkles-Bld4NX5y.js";import{T as P}from"./trending-up-CdusV6gc.js";import{F as X}from"./file-text-C9G5abwR.js";import{P as _}from"./play-cdPayOtJ.js";import{C as Q}from"./copy-DXW4LnkN.js";import{C as W}from"./circle-x-DK79Dhg2.js";function Y(e){const c=(e.metric||"").toLowerCase(),t=e.source||"目标主机",a=e.severity==="critical";return c.includes("cpu")?{rootCause:`检测到 ${t} 上 CPU 使用率达到 ${e.currentValue},持续超过阈值 ${e.threshold}。可能原因:1) 某进程存在死循环或高计算负载;2) GC 频繁触发(Java/Go 应用);3) 业务流量突增导致处理能力不足。`,impact:a?"CPU 持续高负载将导致服务响应延迟显著增加,严重时可能触发雪崩效应,影响全部依赖该节点的业务。":"CPU 使用率偏高,可能导致部分请求处理变慢,建议及时排查避免进一步恶化。",recommendations:[`登录 ${t} 执行 top/htop 定位高 CPU 进程`,"检查是否有异常定时任务或批处理任务在运行","考虑临时扩容或将部分流量调度到其他节点","优化应用代码,排查是否存在低效算法或资源泄漏"],autoFixScript:`#!/bin/bash
|
||||
import{j as s,a5 as b,aI as f,L as v,a6 as w,P as g,E as C,B as A,r as l,D as O,a as U,b as B,c as E,d as J,K as L,T as R,S as G,C as K}from"./index-Dmami9WE.js";import{C as z,b as $,c as D,a as F}from"./card-CIfC-8Rh.js";import{B as y}from"./badge-3UzCvU7L.js";import{a as H}from"./monitor-CicbJUrQ.js";import{a as X}from"./ai-2t1T1OeI.js";import{S}from"./sparkles-rPZivnlW.js";import{T as P}from"./trending-up-d1DKmRom.js";import{F as q}from"./file-text-CebshSV-.js";import{P as _}from"./play-0EwQQJX_.js";import{C as Q}from"./copy-CE_T92Lk.js";import{C as W}from"./circle-x-BBQeW1R3.js";function Y(e){const c=(e.metric||"").toLowerCase(),t=e.source||"目标主机",a=e.severity==="critical";return c.includes("cpu")?{rootCause:`检测到 ${t} 上 CPU 使用率达到 ${e.currentValue},持续超过阈值 ${e.threshold}。可能原因:1) 某进程存在死循环或高计算负载;2) GC 频繁触发(Java/Go 应用);3) 业务流量突增导致处理能力不足。`,impact:a?"CPU 持续高负载将导致服务响应延迟显著增加,严重时可能触发雪崩效应,影响全部依赖该节点的业务。":"CPU 使用率偏高,可能导致部分请求处理变慢,建议及时排查避免进一步恶化。",recommendations:[`登录 ${t} 执行 top/htop 定位高 CPU 进程`,"检查是否有异常定时任务或批处理任务在运行","考虑临时扩容或将部分流量调度到其他节点","优化应用代码,排查是否存在低效算法或资源泄漏"],autoFixScript:`#!/bin/bash
|
||||
# CPU 高负载诊断脚本 - ${t}
|
||||
echo "===== CPU TOP 10 进程 ====="
|
||||
ps aux --sort=-%cpu | head -11
|
||||
@@ -37,7 +37,7 @@ ss -tlnp | grep -E ':(80|443|8080|3306|6379|9090)'
|
||||
echo ""
|
||||
echo "===== 重启失败服务 ====="
|
||||
systemctl reset-failed
|
||||
`,similarCases:0,confidence:0}:{rootCause:`检测到 ${t} 触发告警「${e.name}」,当前指标值 ${e.currentValue} 超过阈值 ${e.threshold}。建议进一步排查具体指标数据和相关日志以确定根因。`,impact:a?"该告警级别为严重,可能影响业务正常运行,建议优先处理。":"该告警需要关注,持续恶化可能影响系统稳定性。",recommendations:[`查看 ${t} 的监控仪表盘,确认指标趋势`,"检查对应时间段的系统日志和应用日志","关联同时间段的其他告警,排查是否有连锁反应","若确认误报,调整告警规则阈值或持续时间"],similarCases:0,confidence:0}}function Z(e){const c=e.rule?.expression||"",t=c.match(/([\w_]+)\s*[><=!]+\s*([\d.]+)/),a=t?t[1]:c||"unknown",n=t?t[2]+"%":"-",r=e.value??0,d=a.includes("usage")||a.includes("cpu")||a.includes("disk")||a.includes("mem")?r.toFixed(1)+"%":r.toFixed(2),x=e.resolved_at?new Date(e.resolved_at):new Date,i=new Date(e.started_at),p=Math.max(1,Math.round((x.getTime()-i.getTime())/6e4)),h=p>=60?`${Math.floor(p/60)}小时${p%60}分钟`:`${p}分钟`,u=i.toLocaleString("zh-CN",{hour12:!1});return{id:String(e.id),name:e.rule_name||e.rule?.name||"未知告警",severity:e.severity==="critical"?"critical":e.severity==="warning"?"warning":"info",status:e.status==="firing"?"active":"resolved",source:e.target||"未知目标",metric:a,threshold:n,currentValue:d,duration:h,startedAt:u,description:e.message&&e.message!==`告警事件 ${e.id}`?e.message:e.rule?.description||`${e.rule_name||"告警"}: ${e.target} 当前值 ${d}`}}function ss(e){switch(e){case"critical":return"bg-red-500/10 text-red-400 border-red-500/30";case"warning":return"bg-amber-500/10 text-amber-400 border-amber-500/30";default:return"bg-blue-500/10 text-blue-400 border-blue-500/30"}}function es({selectedAlert:e,isAnalyzing:c,analysis:t,onAutoFix:a}){return s.jsxs(z,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:18:5",className:"bg-slate-800 border-slate-700 flex flex-col",children:[s.jsx($,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:19:7",className:"border-b border-slate-700 pb-3",children:s.jsxs(D,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:20:9",className:"text-slate-100 flex items-center gap-2",children:[s.jsx(S,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:21:11",className:"h-5 w-5 text-purple-400"}),"AI 分析结果"]})}),s.jsx(b,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:25:7",className:"flex-1",children:s.jsx(F,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:26:9",className:"p-4",children:e?c?s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:33:13",className:"flex flex-col items-center justify-center h-64",children:[s.jsx(v,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:34:15",className:"h-8 w-8 animate-spin text-purple-400 mb-4"}),s.jsx("p",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:35:15",className:"text-slate-400",children:"AI正在分析告警根因..."}),s.jsx("p",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:36:15",className:"text-xs text-slate-500 mt-2",children:"正在关联日志、指标和历史案例"})]}):t?s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:39:13",className:"space-y-4",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:41:15",className:"flex items-center justify-between p-3 bg-purple-500/10 rounded-lg border border-purple-500/30",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:42:17",className:"flex items-center gap-2",children:[s.jsx(f,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:43:19",className:"h-5 w-5 text-purple-400"}),s.jsx("span",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:44:19",className:"text-slate-300",children:"分析置信度"})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:46:17",className:"flex items-center gap-2",children:[s.jsx("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:47:19",className:"w-32 h-2 bg-slate-700 rounded-full overflow-hidden",children:s.jsx("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:48:21",className:"h-full bg-gradient-to-r from-purple-500 to-pink-500",style:{width:`${t.confidence}%`}})}),s.jsxs("span",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:53:19",className:"text-purple-400 font-bold",children:[t.confidence,"%"]})]})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:58:15",className:"space-y-2",children:[s.jsxs("h4",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:59:17",className:"text-sm font-medium text-slate-300 flex items-center gap-2",children:[s.jsx(w,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:60:19",className:"h-4 w-4 text-red-400"}),"根因分析"]}),s.jsx("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:63:17",className:"p-3 bg-slate-900 rounded-lg border border-slate-700",childre
Line truncated
|
||||
`,similarCases:0,confidence:0}:{rootCause:`检测到 ${t} 触发告警「${e.name}」,当前指标值 ${e.currentValue} 超过阈值 ${e.threshold}。建议进一步排查具体指标数据和相关日志以确定根因。`,impact:a?"该告警级别为严重,可能影响业务正常运行,建议优先处理。":"该告警需要关注,持续恶化可能影响系统稳定性。",recommendations:[`查看 ${t} 的监控仪表盘,确认指标趋势`,"检查对应时间段的系统日志和应用日志","关联同时间段的其他告警,排查是否有连锁反应","若确认误报,调整告警规则阈值或持续时间"],similarCases:0,confidence:0}}function Z(e){const c=e.rule?.expression||"",t=c.match(/([\w_]+)\s*[><=!]+\s*([\d.]+)/),a=t?t[1]:c||"unknown",n=t?t[2]+"%":"-",r=e.value??0,d=a.includes("usage")||a.includes("cpu")||a.includes("disk")||a.includes("mem")?r.toFixed(1)+"%":r.toFixed(2),x=e.resolved_at?new Date(e.resolved_at):new Date,i=new Date(e.started_at),p=Math.max(1,Math.round((x.getTime()-i.getTime())/6e4)),h=p>=60?`${Math.floor(p/60)}小时${p%60}分钟`:`${p}分钟`,u=i.toLocaleString("zh-CN",{hour12:!1});return{id:String(e.id),name:e.rule_name||e.rule?.name||"未知告警",severity:e.severity==="critical"?"critical":e.severity==="warning"?"warning":"info",status:e.status==="firing"?"active":"resolved",source:e.target||"未知目标",metric:a,threshold:n,currentValue:d,duration:h,startedAt:u,description:e.message&&e.message!==`告警事件 ${e.id}`?e.message:e.rule?.description||`${e.rule_name||"告警"}: ${e.target} 当前值 ${d}`}}function ss(e){switch(e){case"critical":return"bg-red-500/10 text-red-400 border-red-500/30";case"warning":return"bg-amber-500/10 text-amber-400 border-amber-500/30";default:return"bg-blue-500/10 text-blue-400 border-blue-500/30"}}function es({selectedAlert:e,isAnalyzing:c,analysis:t,onAutoFix:a}){return s.jsxs(z,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:18:5",className:"bg-slate-800 border-slate-700 flex flex-col",children:[s.jsx($,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:19:7",className:"border-b border-slate-700 pb-3",children:s.jsxs(D,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:20:9",className:"text-slate-100 flex items-center gap-2",children:[s.jsx(S,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:21:11",className:"h-5 w-5 text-purple-400"}),"AI 分析结果"]})}),s.jsx(b,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:25:7",className:"flex-1",children:s.jsx(F,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:26:9",className:"p-4",children:e?c?s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:33:13",className:"flex flex-col items-center justify-center h-64",children:[s.jsx(v,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:34:15",className:"h-8 w-8 animate-spin text-purple-400 mb-4"}),s.jsx("p",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:35:15",className:"text-slate-400",children:"AI正在分析告警根因..."}),s.jsx("p",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:36:15",className:"text-xs text-slate-500 mt-2",children:"正在关联日志、指标和历史案例"})]}):t?s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:39:13",className:"space-y-4",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:41:15",className:"flex items-center justify-between p-3 bg-purple-500/10 rounded-lg border border-purple-500/30",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:42:17",className:"flex items-center gap-2",children:[s.jsx(f,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:43:19",className:"h-5 w-5 text-purple-400"}),s.jsx("span",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:44:19",className:"text-slate-300",children:"分析置信度"})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:46:17",className:"flex items-center gap-2",children:[s.jsx("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:47:19",className:"w-32 h-2 bg-slate-700 rounded-full overflow-hidden",children:s.jsx("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:48:21",className:"h-full bg-gradient-to-r from-purple-500 to-pink-500",style:{width:`${t.confidence}%`}})}),s.jsxs("span",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:53:19",className:"text-purple-400 font-bold",children:[t.confidence,"%"]})]})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:58:15",className:"space-y-2",children:[s.jsxs("h4",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:59:17",className:"text-sm font-medium text-slate-300 flex items-center gap-2",children:[s.jsx(w,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:60:19",className:"h-4 w-4 text-red-400"}),"根因分析"]}),s.jsx("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:63:17",className:"p-3 bg-slate-900 rounded-lg border border-slate-700",childre
Line truncated
|
||||
|
||||
告警名称:${o.name}
|
||||
严重程度:${o.severity}
|
||||
@@ -54,4 +54,4 @@ systemctl reset-failed
|
||||
"auto_fix_script": "#!/bin/bash\\n...\\n(可选的自动修复脚本,无则 null)",
|
||||
"similar_cases": 数字(类似案例数预估),
|
||||
"confidence": 数字(0-100 置信度)
|
||||
}`,N=await q.chat([{role:"user",content:M}]),I=N?.content||N?.message?.content||"";i(I?as(I,m):m)}catch{i(m)}finally{d(!1)}},k=()=>{h(!0)},V=o=>{switch(o){case"critical":return s.jsx(W,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:127:16",className:"h-4 w-4 text-red-400"});case"warning":return s.jsx(w,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:129:16",className:"h-4 w-4 text-amber-400"});default:return s.jsx(g,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:131:16",className:"h-4 w-4 text-blue-400"})}};return s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:136:5",className:"space-y-6",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:138:7",className:"flex items-center justify-between",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:139:9",className:"flex items-center gap-3",children:[s.jsx("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:140:11",className:"w-10 h-10 rounded-lg bg-gradient-to-br from-amber-500 to-orange-500 flex items-center justify-center",children:s.jsx(f,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:141:13",className:"h-5 w-5 text-white"})}),s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:143:11",children:[s.jsx("h1",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:144:13",className:"text-2xl font-bold text-slate-100",children:"AI 告警智能分析"}),s.jsx("p",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:145:13",className:"text-sm text-slate-500",children:"基于大模型的告警根因分析和自动修复建议"})]})]}),s.jsx("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:148:9",className:"flex items-center gap-2",children:s.jsxs(y,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:149:11",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:[s.jsx(S,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:150:13",className:"h-3 w-3 mr-1"}),"AI 引擎运行中"]})})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:156:7",className:"grid grid-cols-2 gap-6 h-[calc(100vh-200px)]",children:[s.jsxs(z,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:158:9",className:"bg-slate-800 border-slate-700 flex flex-col",children:[s.jsx($,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:159:11",className:"border-b border-slate-700 pb-3",children:s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:160:13",className:"flex items-center justify-between",children:[s.jsxs(D,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:161:15",className:"text-slate-100 flex items-center gap-2",children:[s.jsx(R,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:162:17",className:"h-5 w-5 text-amber-400"}),"活跃告警"]}),s.jsxs(y,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:165:15",className:"bg-red-500/10 text-red-400 border-red-500/30",children:[e.filter(o=>o.status==="active").length," 个活跃"]})]})}),s.jsx(b,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:170:11",className:"flex-1",children:s.jsx(F,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:171:13",className:"p-4 space-y-3",children:t?s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:173:17",className:"flex flex-col items-center justify-center h-32",children:[s.jsx(v,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:174:19",className:"h-6 w-6 animate-spin text-slate-500 mb-2"}),s.jsx("p",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:175:19",className:"text-sm text-slate-500",children:"加载告警数据..."})]}):e.length===0?s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:178:17",className:"flex flex-col items-center justify-center h-32 text-slate-500",children:[s.jsx(g,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:179:19",className:"h-8 w-8 mb-2 opacity-50"}),s.jsx("p",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:180:19",className:"text-sm",children:"暂无告警事件"})]}):e.map(o=>s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:184:17",className:`p-4 rounded-lg border cursor-pointer transition-all ${n?.id===o.id?"border-purple-500 bg-purple-500/10":"border-slate-700 bg-slate-800/50 hover:border-slate-600"}`,onClick:()=>T(o),children:[s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:193:19",className:"flex items-start justify-between mb-2",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:194:21",className:"flex items-center gap-2",children:[V(o.severity),s.jsx("span",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:196:23",className:"font-medium text-slate-100",children:o.name})]}),s.jsx(y,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:198:21",variant:"outline",className:ss(o.severity),children:o.severity==="critical"?"严重":o.severity==="warning"?"警告":"提示"})]}),s.jsx("div",{"code-path":"src
Line truncated
|
||||
}`,N=await X.chat([{role:"user",content:M}]),I=N?.content||N?.message?.content||"";i(I?as(I,m):m)}catch{i(m)}finally{d(!1)}},k=()=>{h(!0)},V=o=>{switch(o){case"critical":return s.jsx(W,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:127:16",className:"h-4 w-4 text-red-400"});case"warning":return s.jsx(w,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:129:16",className:"h-4 w-4 text-amber-400"});default:return s.jsx(g,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:131:16",className:"h-4 w-4 text-blue-400"})}};return s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:136:5",className:"space-y-6",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:138:7",className:"flex items-center justify-between",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:139:9",className:"flex items-center gap-3",children:[s.jsx("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:140:11",className:"w-10 h-10 rounded-lg bg-gradient-to-br from-amber-500 to-orange-500 flex items-center justify-center",children:s.jsx(f,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:141:13",className:"h-5 w-5 text-white"})}),s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:143:11",children:[s.jsx("h1",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:144:13",className:"text-2xl font-bold text-slate-100",children:"AI 告警智能分析"}),s.jsx("p",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:145:13",className:"text-sm text-slate-500",children:"基于大模型的告警根因分析和自动修复建议"})]})]}),s.jsx("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:148:9",className:"flex items-center gap-2",children:s.jsxs(y,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:149:11",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:[s.jsx(S,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:150:13",className:"h-3 w-3 mr-1"}),"AI 引擎运行中"]})})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:156:7",className:"grid grid-cols-2 gap-6 h-[calc(100vh-200px)]",children:[s.jsxs(z,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:158:9",className:"bg-slate-800 border-slate-700 flex flex-col",children:[s.jsx($,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:159:11",className:"border-b border-slate-700 pb-3",children:s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:160:13",className:"flex items-center justify-between",children:[s.jsxs(D,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:161:15",className:"text-slate-100 flex items-center gap-2",children:[s.jsx(R,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:162:17",className:"h-5 w-5 text-amber-400"}),"活跃告警"]}),s.jsxs(y,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:165:15",className:"bg-red-500/10 text-red-400 border-red-500/30",children:[e.filter(o=>o.status==="active").length," 个活跃"]})]})}),s.jsx(b,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:170:11",className:"flex-1",children:s.jsx(F,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:171:13",className:"p-4 space-y-3",children:t?s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:173:17",className:"flex flex-col items-center justify-center h-32",children:[s.jsx(v,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:174:19",className:"h-6 w-6 animate-spin text-slate-500 mb-2"}),s.jsx("p",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:175:19",className:"text-sm text-slate-500",children:"加载告警数据..."})]}):e.length===0?s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:178:17",className:"flex flex-col items-center justify-center h-32 text-slate-500",children:[s.jsx(g,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:179:19",className:"h-8 w-8 mb-2 opacity-50"}),s.jsx("p",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:180:19",className:"text-sm",children:"暂无告警事件"})]}):e.map(o=>s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:184:17",className:`p-4 rounded-lg border cursor-pointer transition-all ${n?.id===o.id?"border-purple-500 bg-purple-500/10":"border-slate-700 bg-slate-800/50 hover:border-slate-600"}`,onClick:()=>T(o),children:[s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:193:19",className:"flex items-start justify-between mb-2",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:194:21",className:"flex items-center gap-2",children:[V(o.severity),s.jsx("span",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:196:23",className:"font-medium text-slate-100",children:o.name})]}),s.jsx(y,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:198:21",variant:"outline",className:ss(o.severity),children:o.severity==="critical"?"严重":o.severity==="warning"?"警告":"提示"})]}),s.jsx("div",{"code-path":"src
Line truncated
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
import{g as _s,r as x,j as s,ao as ks,aR as Es,aA as Ls,aw as H,X as ds,aJ as Rs,B as N,E as Z,T as ms,A as xs,L as k,H as Ms,aS as ss,a2 as Ps,a8 as Ds,I as w,D as Ts,b as qs,c as Us,d as Bs,e as zs,f as Fs}from"./index-DfyorCky.js";import{C as D,b as T,c as ts,a as q}from"./card-C55cvSHg.js";import{B as E}from"./badge-xNW8x0G1.js";import{L as y}from"./label-BK0h2apY.js";import{S as es,a as as,b as ns,c as os,d as cs}from"./select-D5qUzdAs.js";import{S as Hs}from"./switch-CGiGgOnh.js";import{t as C}from"./index-a3ybMjbR.js";import{d as U}from"./dashboard-BjQPIG2G.js";import{a as Vs}from"./monitor-BAaBXIsC.js";import{a as Ks}from"./agent-DqqIRCQX.js";import{a as $}from"./ai-BTgmlP5Q.js";import{C as Gs}from"./circle-check-DWcXrx2k.js";import{F as hs}from"./file-text-C9G5abwR.js";import{T as Ws}from"./trending-up-CdusV6gc.js";import{R as Js}from"./rotate-cw-5qcj_h_q.js";import{M as Qs}from"./message-square-DyxabBvb.js";import{S as Xs}from"./square-9TIYDO_t.js";import{W as Ys}from"./wifi-FqsslTyA.js";import"./index-CWVNW_qu.js";const Zs=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],st=_s("send",Zs);function tt(e,n=[]){let i=[];function r(a,d){const m=x.createContext(d);m.displayName=a+"Context";const l=i.length;i=[...i,d];const g=h=>{const{scope:u,children:c,...p}=h,A=u?.[e]?.[l]||m,j=x.useMemo(()=>p,Object.values(p));return s.jsx(A.Provider,{value:j,children:c})};g.displayName=a+"Provider";function v(h,u){const c=u?.[e]?.[l]||m,p=x.useContext(c);if(p)return p;if(d!==void 0)return d;throw new Error(`\`${h}\` must be used within \`${a}\``)}return[g,v]}const o=()=>{const a=i.map(d=>x.createContext(d));return function(m){const l=m?.[e]||a;return x.useMemo(()=>({[`__scope${e}`]:{...m,[e]:l}}),[m,l])}};return o.scopeName=e,[r,et(o,...n)]}function et(...e){const n=e[0];if(e.length===1)return n;const i=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const d=r.reduce((m,{useScope:l,scopeName:g})=>{const h=l(a)[`__scope${g}`];return{...m,...h}},{});return x.useMemo(()=>({[`__scope${n.scopeName}`]:d}),[d])}};return i.scopeName=n.scopeName,i}var at=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],V=at.reduce((e,n)=>{const i=ks(`Primitive.${n}`),r=x.forwardRef((o,a)=>{const{asChild:d,...m}=o,l=d?i:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(l,{...m,ref:a})});return r.displayName=`Primitive.${n}`,{...e,[n]:r}},{}),B={exports:{}},z={};var rs;function nt(){if(rs)return z;rs=1;var e=Es();function n(h,u){return h===u&&(h!==0||1/h===1/u)||h!==h&&u!==u}var i=typeof Object.is=="function"?Object.is:n,r=e.useState,o=e.useEffect,a=e.useLayoutEffect,d=e.useDebugValue;function m(h,u){var c=u(),p=r({inst:{value:c,getSnapshot:u}}),A=p[0].inst,j=p[1];return a(function(){A.value=c,A.getSnapshot=u,l(A)&&j({inst:A})},[h,c,u]),o(function(){return l(A)&&j({inst:A}),h(function(){l(A)&&j({inst:A})})},[h]),d(c),c}function l(h){var u=h.getSnapshot;h=h.value;try{var c=u();return!i(h,c)}catch{return!0}}function g(h,u){return u()}var v=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?g:m;return z.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:v,z}var is;function ot(){return is||(is=1,B.exports=nt()),B.exports}var ct=ot();function rt(){return ct.useSyncExternalStore(it,()=>!0,()=>!1)}function it(){return()=>{}}var K="Avatar",[pt]=tt(K),[lt,us]=pt(K),As=x.forwardRef((e,n)=>{const{__scopeAvatar:i,...r}=e,[o,a]=x.useState("idle");return s.jsx(lt,{scope:i,imageLoadingStatus:o,onImageLoadingStatusChange:a,children:s.jsx(V.span,{...r,ref:n})})});As.displayName=K;var fs="AvatarImage",dt=x.forwardRef((e,n)=>{const{__scopeAvatar:i,src:r,onLoadingStatusChange:o=()=>{},...a}=e,d=us(fs,i),m=mt(r,a),l=Ls(g=>{o(g),d.onImageLoadingStatusChange(g)});return H(()=>{m!=="idle"&&l(m)},[m,l]),m==="loaded"?s.jsx(V.img,{...a,ref:n,src:r}):null});dt.displayName=fs;var gs="AvatarFallback",Is=x.forwardRef((e,n)=>{const{__scopeAvatar:i,delayMs:r,...o}=e,a=us(gs,i),[d,m]=x.useState(r===void 0);return x.useEffect(()=>{if(r!==void 0){const l=window.setTimeout(()=>m(!0),r);return()=>window.clearTimeout(l)}},[r]),d&&a.imageLoadingStatus!=="loaded"?s.jsx(V.span,{...o,ref:n}):null});Is.displayName=gs;function ps(e,n){return e?n?(e.src!==n&&(e.src=n),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}function mt(e,{referrerPolicy:n,crossOrigin:i}){const r=rt(),o=x.useRef(null),a=r?(o.current||(o.current=new window.Image),o.current):null,[d,m]=x.useState(()=>ps(a,e));return H(()=>{m(ps(a,e))},[a,e]),H(()=>{const l=h=>()=>{m(h)};if(!a)return;const g=l("loaded"),v=l("error");return a.addEventListener("load",g),a.addEventListener("error",v),n&&(a.referrerPolicy=n),typeof i=="string"&&(a.crossOrigin=i),()=>{a.removeEventListener("Line truncated
|
||||
import{i as _s,r as x,j as s,aF as ks,aR as Es,aw as Ls,as as H,a0 as ds,aI as Rs,B as N,y as Z,T as ms,A as xs,L as k,E as Ms,aS as ss,a5 as Ps,U as Ds,D as Ts,a as qs,b as Us,c as Bs,d as Fs,e as zs}from"./index-Dmami9WE.js";import{C as D,b as T,c as ts,a as q}from"./card-CIfC-8Rh.js";import{I as w}from"./input-NsU9nXZF.js";import{B as E}from"./badge-3UzCvU7L.js";import{L as y}from"./label-Ap_-SPYI.js";import{S as es,a as as,b as ns,c as os,d as cs}from"./select-DUbxjT0z.js";import{S as Hs}from"./switch-TqjD2x0W.js";import{t as C}from"./index-BuEnLCjT.js";import{d as U}from"./dashboard-BHNKEvkq.js";import{a as Vs}from"./monitor-CicbJUrQ.js";import{a as Ks}from"./agent-B3ElXCx8.js";import{a as $}from"./ai-2t1T1OeI.js";import{C as Gs}from"./circle-check-CVbTTFQ0.js";import{F as hs}from"./file-text-CebshSV-.js";import{T as Ws}from"./trending-up-d1DKmRom.js";import{R as Qs}from"./rotate-cw-CKCO6IKE.js";import{M as Js}from"./message-square-BNbub2_o.js";import{S as Xs}from"./square-NjJOra_E.js";import{W as Ys}from"./wifi-CtC3YBV7.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";const Zs=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],st=_s("send",Zs);function tt(e,n=[]){let i=[];function r(a,d){const m=x.createContext(d);m.displayName=a+"Context";const l=i.length;i=[...i,d];const g=h=>{const{scope:u,children:c,...p}=h,A=u?.[e]?.[l]||m,j=x.useMemo(()=>p,Object.values(p));return s.jsx(A.Provider,{value:j,children:c})};g.displayName=a+"Provider";function v(h,u){const c=u?.[e]?.[l]||m,p=x.useContext(c);if(p)return p;if(d!==void 0)return d;throw new Error(`\`${h}\` must be used within \`${a}\``)}return[g,v]}const o=()=>{const a=i.map(d=>x.createContext(d));return function(m){const l=m?.[e]||a;return x.useMemo(()=>({[`__scope${e}`]:{...m,[e]:l}}),[m,l])}};return o.scopeName=e,[r,et(o,...n)]}function et(...e){const n=e[0];if(e.length===1)return n;const i=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const d=r.reduce((m,{useScope:l,scopeName:g})=>{const h=l(a)[`__scope${g}`];return{...m,...h}},{});return x.useMemo(()=>({[`__scope${n.scopeName}`]:d}),[d])}};return i.scopeName=n.scopeName,i}var at=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],V=at.reduce((e,n)=>{const i=ks(`Primitive.${n}`),r=x.forwardRef((o,a)=>{const{asChild:d,...m}=o,l=d?i:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(l,{...m,ref:a})});return r.displayName=`Primitive.${n}`,{...e,[n]:r}},{}),B={exports:{}},F={};var rs;function nt(){if(rs)return F;rs=1;var e=Es();function n(h,u){return h===u&&(h!==0||1/h===1/u)||h!==h&&u!==u}var i=typeof Object.is=="function"?Object.is:n,r=e.useState,o=e.useEffect,a=e.useLayoutEffect,d=e.useDebugValue;function m(h,u){var c=u(),p=r({inst:{value:c,getSnapshot:u}}),A=p[0].inst,j=p[1];return a(function(){A.value=c,A.getSnapshot=u,l(A)&&j({inst:A})},[h,c,u]),o(function(){return l(A)&&j({inst:A}),h(function(){l(A)&&j({inst:A})})},[h]),d(c),c}function l(h){var u=h.getSnapshot;h=h.value;try{var c=u();return!i(h,c)}catch{return!0}}function g(h,u){return u()}var v=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?g:m;return F.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:v,F}var is;function ot(){return is||(is=1,B.exports=nt()),B.exports}var ct=ot();function rt(){return ct.useSyncExternalStore(it,()=>!0,()=>!1)}function it(){return()=>{}}var K="Avatar",[pt]=tt(K),[lt,us]=pt(K),As=x.forwardRef((e,n)=>{const{__scopeAvatar:i,...r}=e,[o,a]=x.useState("idle");return s.jsx(lt,{scope:i,imageLoadingStatus:o,onImageLoadingStatusChange:a,children:s.jsx(V.span,{...r,ref:n})})});As.displayName=K;var fs="AvatarImage",dt=x.forwardRef((e,n)=>{const{__scopeAvatar:i,src:r,onLoadingStatusChange:o=()=>{},...a}=e,d=us(fs,i),m=mt(r,a),l=Ls(g=>{o(g),d.onImageLoadingStatusChange(g)});return H(()=>{m!=="idle"&&l(m)},[m,l]),m==="loaded"?s.jsx(V.img,{...a,ref:n,src:r}):null});dt.displayName=fs;var gs="AvatarFallback",Is=x.forwardRef((e,n)=>{const{__scopeAvatar:i,delayMs:r,...o}=e,a=us(gs,i),[d,m]=x.useState(r===void 0);return x.useEffect(()=>{if(r!==void 0){const l=window.setTimeout(()=>m(!0),r);return()=>window.clearTimeout(l)}},[r]),d&&a.imageLoadingStatus!=="loaded"?s.jsx(V.span,{...o,ref:n}):null});Is.displayName=gs;function ps(e,n){return e?n?(e.src!==n&&(e.src=n),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}function mt(e,{referrerPolicy:n,crossOrigin:i}){const r=rt(),o=x.useRef(null),a=r?(o.current||(o.current=new window.Image),o.current):null,[d,m]=x.useState(()=>ps(a,e));return H(()=>{m(ps(a,e))},[a,e]),H(()=>{const l=h=>()=>{m(h)};if(!a)return;const g=l("loaded"),v=l("error");return a.addEventListener("load",g),a.addEventListener("error",v),n&&(a.referrerPolicy=n),Line truncated
|
||||
${i.join(`
|
||||
`)}`}async function ls(){const e=await Ks.getLatest(),n=Array.isArray(e)?e:e?.list||[];if(!n.length)return"(当前无 Agent 上报数据,可能未部署监控 Agent)";const i=n.slice(0,20).map((a,d)=>{const m=a.cpu_usage??"-",l=a.mem_usage??"-";return`${d+1}. ${a.hostname||"-"} | CPU:${m}% | 内存:${l}% (${a.mem_used??"-"}/${a.mem_total??"-"}GB) | 核数:${a.cpu_cores??"-"} | 上报:${(a.report_time||"").slice(0,16)}`}),r=n.filter(a=>(a.cpu_usage??0)>=80||(a.mem_usage??0)>=80),o=r.length?`
|
||||
⚠️ 高负载主机 ${r.length} 台:${r.map(a=>`${a.hostname}(CPU${a.cpu_usage}%/MEM${a.mem_usage}%)`).join("、")}`:"";return`Agent 监控的 ${n.length} 台主机实时指标:
|
||||
@@ -11,9 +11,9 @@ ${u.join(`
|
||||
|
||||
最近发布:
|
||||
${c.join(`
|
||||
`)||"(无)"}`}const vt=[{id:"alerts",name:"分析今日告警",icon:ms,prompt:"帮我分析以下最近的告警事件,给出根因分析和处置建议(按严重程度排序,给出具体处置步骤)",contextLoader:gt},{id:"performance",name:"性能瓶颈分析",icon:xs,prompt:"分析以下主机实时指标,找出 CPU/内存使用率最高的主机并给出性能优化建议",contextLoader:ls},{id:"report",name:"生成运维报告",icon:hs,prompt:"基于以下平台实时数据,生成一份简洁的今日运维报告,包括资源概览、告警情况和发布状态,用 Markdown 格式输出",contextLoader:It},{id:"optimize",name:"资源优化建议",icon:Ws,prompt:"根据以下主机资源使用数据,提供成本优化和容量规划建议(识别闲置/过载主机,给出缩容/扩容建议)",contextLoader:ls}];function jt(e){return new Date(e).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"})}function Bt(){const[e,n]=x.useState([]),[i,r]=x.useState(""),[o,a]=x.useState(!1),d=x.useRef(null);x.useEffect(()=>()=>d.current?.abort(),[]);const[m,l]=x.useState(!1),[g,v]=x.useState(!1),[h,u]=x.useState(!1),[c,p]=x.useState(ft),[A,j]=x.useState(!1),[L,G]=x.useState(null),W=()=>{try{return crypto.randomUUID()}catch{}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const I=Math.random()*16|0;return(t==="x"?I:I&3|8).toString(16)})},[J,vs]=x.useState(()=>W()),Q=x.useRef(null),js=()=>Q.current?.scrollIntoView({behavior:"smooth"});x.useEffect(()=>{js()},[e]);const Os=async()=>{try{const t=await $.getConfig();p(t),j(!!(t.enabled&&t.configured))}catch{j(!1)}},bs=async()=>{try{const I=(await $.getHistory(J))?.list||[];n(I.map(f=>({id:String(f.id),role:f.role,content:f.content,timestamp:f.created_at})))}catch{}};x.useEffect(()=>{Os(),bs()},[]);const Ns=t=>{const I=F.find(f=>f.id===t);p(f=>({...f,provider:t,endpoint:I?.defaultEndpoint||f.endpoint,model:I?.models[0]||f.model}))},Ss=async()=>{if(c.enabled&&!c.api_key&&c.provider!=="ollama"){C.error("请填写 API Key");return}v(!0);try{const t=await $.saveConfig(c);p(t),j(!!(t.enabled&&t.configured)),C.success("配置已保存"),l(!1)}catch(t){C.error(t instanceof Error?t.message:"保存失败")}finally{v(!1)}},ys=async()=>{u(!0);try{await $.testConnection(),C.success("LLM 服务连接成功")}catch(t){C.error(t instanceof Error?t.message:"连接失败")}finally{u(!1)}},X=async t=>{const I={id:Date.now().toString(),role:"user",content:t,timestamp:new Date().toISOString()},f=(Date.now()+1).toString(),$s=[...e,I,{id:f,role:"assistant",content:"",timestamp:new Date().toISOString()}];n($s),a(!0);const M=new AbortController;d.current=M;let P=!1;try{const _=[...e,I].slice(-10).map(O=>({role:O.role,content:O.content}));await $.chatStream(_,O=>{P=!0,n(S=>S.map(b=>b.id===f?{...b,content:b.content+O}:b))},M.signal,J)}catch(_){if(M.signal.aborted)n(O=>O.map(S=>S.id===f?{...S,content:S.content||"(已停止生成)",isStopped:!0}:S));else{const O=_ instanceof Error?_.message:"对话失败";n(S=>S.map(b=>b.id===f?{...b,content:P?b.content+`
|
||||
`)||"(无)"}`}const vt=[{id:"alerts",name:"分析今日告警",icon:ms,prompt:"帮我分析以下最近的告警事件,给出根因分析和处置建议(按严重程度排序,给出具体处置步骤)",contextLoader:gt},{id:"performance",name:"性能瓶颈分析",icon:xs,prompt:"分析以下主机实时指标,找出 CPU/内存使用率最高的主机并给出性能优化建议",contextLoader:ls},{id:"report",name:"生成运维报告",icon:hs,prompt:"基于以下平台实时数据,生成一份简洁的今日运维报告,包括资源概览、告警情况和发布状态,用 Markdown 格式输出",contextLoader:It},{id:"optimize",name:"资源优化建议",icon:Ws,prompt:"根据以下主机资源使用数据,提供成本优化和容量规划建议(识别闲置/过载主机,给出缩容/扩容建议)",contextLoader:ls}];function jt(e){return new Date(e).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"})}function zt(){const[e,n]=x.useState([]),[i,r]=x.useState(""),[o,a]=x.useState(!1),d=x.useRef(null);x.useEffect(()=>()=>d.current?.abort(),[]);const[m,l]=x.useState(!1),[g,v]=x.useState(!1),[h,u]=x.useState(!1),[c,p]=x.useState(ft),[A,j]=x.useState(!1),[L,G]=x.useState(null),W=()=>{try{return crypto.randomUUID()}catch{}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const I=Math.random()*16|0;return(t==="x"?I:I&3|8).toString(16)})},[Q,vs]=x.useState(()=>W()),J=x.useRef(null),js=()=>J.current?.scrollIntoView({behavior:"smooth"});x.useEffect(()=>{js()},[e]);const Os=async()=>{try{const t=await $.getConfig();p(t),j(!!(t.enabled&&t.configured))}catch{j(!1)}},bs=async()=>{try{const I=(await $.getHistory(Q))?.list||[];n(I.map(f=>({id:String(f.id),role:f.role,content:f.content,timestamp:f.created_at})))}catch{}};x.useEffect(()=>{Os(),bs()},[]);const Ns=t=>{const I=z.find(f=>f.id===t);p(f=>({...f,provider:t,endpoint:I?.defaultEndpoint||f.endpoint,model:I?.models[0]||f.model}))},Ss=async()=>{if(c.enabled&&!c.api_key&&c.provider!=="ollama"){C.error("请填写 API Key");return}v(!0);try{const t=await $.saveConfig(c);p(t),j(!!(t.enabled&&t.configured)),C.success("配置已保存"),l(!1)}catch(t){C.error(t instanceof Error?t.message:"保存失败")}finally{v(!1)}},ys=async()=>{u(!0);try{await $.testConnection(),C.success("LLM 服务连接成功")}catch(t){C.error(t instanceof Error?t.message:"连接失败")}finally{u(!1)}},X=async t=>{const I={id:Date.now().toString(),role:"user",content:t,timestamp:new Date().toISOString()},f=(Date.now()+1).toString(),$s=[...e,I,{id:f,role:"assistant",content:"",timestamp:new Date().toISOString()}];n($s),a(!0);const M=new AbortController;d.current=M;let P=!1;try{const _=[...e,I].slice(-10).map(O=>({role:O.role,content:O.content}));await $.chatStream(_,O=>{P=!0,n(S=>S.map(b=>b.id===f?{...b,content:b.content+O}:b))},M.signal,Q)}catch(_){if(M.signal.aborted)n(O=>O.map(S=>S.id===f?{...S,content:S.content||"(已停止生成)",isStopped:!0}:S));else{const O=_ instanceof Error?_.message:"对话失败";n(S=>S.map(b=>b.id===f?{...b,content:P?b.content+`
|
||||
|
||||
⚠️ ${O}`:`⚠️ ${O}`,isError:!P}:b))}}finally{a(!1),d.current=null}},Y=async()=>{const t=i.trim();!t||o||(r(""),await X(t))},ws=async t=>{if(o||L)return;if(!A||!t.contextLoader){r(t.prompt);return}G(t.id);let I="";try{I=await t.contextLoader()}catch{I="(平台数据加载失败,请稍后重试或检查后端服务)"}finally{G(null)}const f=`${t.prompt}
|
||||
|
||||
【平台实时数据】
|
||||
${I}`;await X(f)},Cs=async()=>{try{await $.clearHistory()}catch{}const t=W();vs(t),n([]),r(""),C.success("已开始新对话")},R=F.find(t=>t.id===c.provider);return s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:370:5",className:"space-y-6",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:372:7",className:"flex items-center justify-between",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:373:9",className:"flex items-center gap-3",children:[s.jsx("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:374:11",className:"w-10 h-10 rounded-lg bg-gradient-to-br from-purple-500 to-pink-500 flex items-center justify-center",children:s.jsx(Rs,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:375:13",className:"h-5 w-5 text-white"})}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:377:11",children:[s.jsx("h1",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:378:13",className:"text-2xl font-bold text-slate-100",children:"AIOps 智能助手"}),s.jsx("p",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:379:13",className:"text-sm text-slate-500",children:"AI 驱动的智能运维助手"})]})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:382:9",className:"flex items-center gap-3",children:[A?s.jsxs(E,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:384:13",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:[s.jsx(Gs,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:385:15",className:"h-3 w-3 mr-1"}),c.model]}):s.jsx(E,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:389:13",variant:"outline",className:"border-amber-500/30 text-amber-400 bg-amber-500/10",children:"未配置"}),s.jsxs(N,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:393:11",variant:"outline",className:"border-slate-700 text-slate-300",onClick:()=>l(!0),children:[s.jsx(Z,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:394:13",className:"h-4 w-4 mr-2"}),"模型配置"]})]})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:400:7",className:"grid grid-cols-4 gap-6 h-[calc(100vh-200px)]",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:402:9",className:"col-span-1 space-y-4",children:[s.jsxs(D,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:403:11",className:"bg-slate-800 border-slate-700",children:[s.jsx(T,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:404:13",className:"pb-3",children:s.jsx(ts,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:405:15",className:"text-sm text-slate-300",children:"快速操作"})}),s.jsx(q,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:407:13",className:"space-y-2",children:vt.map(t=>s.jsxs(N,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:409:17",variant:"ghost",className:"w-full justify-start text-slate-300 hover:text-slate-100 hover:bg-slate-700",disabled:o||L!==null,onClick:()=>ws(t),children:[L===t.id?s.jsx(k,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:417:21",className:"h-4 w-4 mr-2 shrink-0 animate-spin"}):s.jsx(t.icon,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:419:21",className:"h-4 w-4 mr-2 shrink-0"}),s.jsx("span",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:421:19",className:"text-sm",children:t.name}),A&&t.contextLoader&&s.jsx("span",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:423:21",className:"ml-auto text-[10px] text-emerald-400/60 shrink-0",children:"实时"})]},t.id))})]}),s.jsxs(D,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:430:11",className:"bg-slate-800 border-slate-700",children:[s.jsx(T,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:431:13",className:"pb-3",children:s.jsx(ts,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:432:15",className:"text-sm text-slate-300",children:"能力展示"})}),s.jsxs(q,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:434:13",className:"space-y-3",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:435:15",className:"flex items-center gap-2 text-sm text-slate-400",children:[s.jsx(ms,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:436:17",className:"h-4 w-4 text-amber-400"}),s.jsx("span",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:437:17",children:"智能告警分析"})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:439:15",className:"flex items-center gap-2 text-sm text-slate-400",children:[s.jsx(xs,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:440:17",className:"h-4 w-4 text-blue-400"}),s.jsx("span",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:441:17",children:"性能瓶颈识别"})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:443:15",className:"flex items-center gap-2 text-sm text-slate-400",children:[s.jsx(hs,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:444:17",className:"h-4 w-4 text-emerald-400"}),s.jsx("
Line truncated
|
||||
${I}`;await X(f)},Cs=async()=>{try{await $.clearHistory()}catch{}const t=W();vs(t),n([]),r(""),C.success("已开始新对话")},R=z.find(t=>t.id===c.provider);return s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:370:5",className:"space-y-6",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:372:7",className:"flex items-center justify-between",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:373:9",className:"flex items-center gap-3",children:[s.jsx("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:374:11",className:"w-10 h-10 rounded-lg bg-gradient-to-br from-purple-500 to-pink-500 flex items-center justify-center",children:s.jsx(Rs,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:375:13",className:"h-5 w-5 text-white"})}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:377:11",children:[s.jsx("h1",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:378:13",className:"text-2xl font-bold text-slate-100",children:"AIOps 智能助手"}),s.jsx("p",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:379:13",className:"text-sm text-slate-500",children:"AI 驱动的智能运维助手"})]})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:382:9",className:"flex items-center gap-3",children:[A?s.jsxs(E,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:384:13",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:[s.jsx(Gs,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:385:15",className:"h-3 w-3 mr-1"}),c.model]}):s.jsx(E,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:389:13",variant:"outline",className:"border-amber-500/30 text-amber-400 bg-amber-500/10",children:"未配置"}),s.jsxs(N,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:393:11",variant:"outline",className:"border-slate-700 text-slate-300",onClick:()=>l(!0),children:[s.jsx(Z,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:394:13",className:"h-4 w-4 mr-2"}),"模型配置"]})]})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:400:7",className:"grid grid-cols-4 gap-6 h-[calc(100vh-200px)]",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:402:9",className:"col-span-1 space-y-4",children:[s.jsxs(D,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:403:11",className:"bg-slate-800 border-slate-700",children:[s.jsx(T,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:404:13",className:"pb-3",children:s.jsx(ts,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:405:15",className:"text-sm text-slate-300",children:"快速操作"})}),s.jsx(q,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:407:13",className:"space-y-2",children:vt.map(t=>s.jsxs(N,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:409:17",variant:"ghost",className:"w-full justify-start text-slate-300 hover:text-slate-100 hover:bg-slate-700",disabled:o||L!==null,onClick:()=>ws(t),children:[L===t.id?s.jsx(k,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:417:21",className:"h-4 w-4 mr-2 shrink-0 animate-spin"}):s.jsx(t.icon,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:419:21",className:"h-4 w-4 mr-2 shrink-0"}),s.jsx("span",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:421:19",className:"text-sm",children:t.name}),A&&t.contextLoader&&s.jsx("span",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:423:21",className:"ml-auto text-[10px] text-emerald-400/60 shrink-0",children:"实时"})]},t.id))})]}),s.jsxs(D,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:430:11",className:"bg-slate-800 border-slate-700",children:[s.jsx(T,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:431:13",className:"pb-3",children:s.jsx(ts,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:432:15",className:"text-sm text-slate-300",children:"能力展示"})}),s.jsxs(q,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:434:13",className:"space-y-3",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:435:15",className:"flex items-center gap-2 text-sm text-slate-400",children:[s.jsx(ms,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:436:17",className:"h-4 w-4 text-amber-400"}),s.jsx("span",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:437:17",children:"智能告警分析"})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:439:15",className:"flex items-center gap-2 text-sm text-slate-400",children:[s.jsx(xs,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:440:17",className:"h-4 w-4 text-blue-400"}),s.jsx("span",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:441:17",children:"性能瓶颈识别"})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIOpsAssistant.tsx:443:15",className:"flex items-center gap-2 text-sm text-slate-400",children:[s.jsx(hs,{"code-path":"src/components/aiops/AIOpsAssistant.tsx:444:17",className:"h-4 w-4 text-emerald-400"}),s.jsx("
Line truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{g as J,j as e,L as D,G as q,r as g,aJ as Q,B as ee,A as se,a3 as te,T as _,K as ce,o as ae,N as ie}from"./index-DfyorCky.js";import{C as w,b as K,c as H,a as C}from"./card-C55cvSHg.js";import{B as X}from"./badge-xNW8x0G1.js";import{T as ne,a as oe,b as F,c as B}from"./tabs-CIh_yD4s.js";import{S as re,a as le,b as de,c as pe,d as U}from"./select-D5qUzdAs.js";import{d as me}from"./dashboard-BjQPIG2G.js";import{s as xe}from"./server-CjDPBaTN.js";import{a as W}from"./monitor-BAaBXIsC.js";import{H as z}from"./hard-drive-BbPmnARR.js";import{Z as Y}from"./zap-D2uWSK32.js";import{S as G}from"./sparkles-Bld4NX5y.js";import{T as O}from"./trending-up-CdusV6gc.js";import{M as he}from"./memory-stick-QMV-0CnU.js";import{M as Ae}from"./minus-UVrx3jLc.js";import{T as ye}from"./trending-down-BGTWG_dA.js";import"./index-CWVNW_qu.js";const ve=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],ue=J("calendar",ve);const je=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],be=J("chart-line",je);function Pe({forecasts:a,loading:i}){return e.jsxs(w,{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:14:5",className:"bg-slate-800 border-slate-700",children:[e.jsx(K,{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:15:7",className:"pb-3",children:e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:16:9",className:"flex items-center justify-between",children:[e.jsxs(H,{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:17:11",className:"text-slate-100 flex items-center gap-2",children:[e.jsx(z,{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:18:13",className:"h-5 w-5 text-amber-400"}),"容量规划预警"]}),e.jsx("span",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:21:11",className:"text-xs text-slate-500",children:"基于日均增长率推算阈值触及时间"})]})}),e.jsx(C,{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:24:7",children:i?e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:26:11",className:"flex items-center justify-center py-12 text-slate-500",children:[e.jsx(D,{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:27:13",className:"h-5 w-5 animate-spin mr-2"})," 加载容量数据..."]}):a.length===0?e.jsx("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:30:11",className:"text-center py-12 text-slate-500",children:"暂无容量数据"}):e.jsx("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:32:11",className:"space-y-4",children:a.map((c,p)=>e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:34:15",className:"p-4 rounded-lg border border-slate-700 bg-slate-800/50",children:[e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:35:17",className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:36:19",className:"flex items-center gap-2",children:[e.jsx(q,{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:37:21",className:"h-5 w-5 text-blue-400"}),e.jsx("span",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:38:21",className:"font-medium text-slate-200",children:c.resource})]}),e.jsx(X,{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:40:19",variant:"outline",className:c.daysUntilThreshold<=7?"border-red-500/30 text-red-400 bg-red-500/10":c.daysUntilThreshold<=14?"border-amber-500/30 text-amber-400 bg-amber-500/10":"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:c.daysUntilThreshold<=7?"紧急":c.daysUntilThreshold<=14?"警告":"正常"})]}),e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:58:17",className:"mb-4",children:[e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:59:19",className:"flex items-center justify-between text-sm mb-1",children:[e.jsx("span",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:60:21",className:"text-slate-400",children:"7天使用率预测"}),e.jsx("span",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:61:21",className:"text-slate-400",children:c.daysUntilThreshold>=999?"增长平缓,暂无触顶风险":e.jsxs(e.Fragment,{children:["预计"," ",e.jsxs("span",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:67:27",className:"text-amber-400 font-medium",children:[c.daysUntilThreshold,"天"]})," ","后达到阈值"]})})]}),e.jsx("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:73:19",className:"h-3 bg-slate-700 rounded-full overflow-hidden",children:e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:74:21",className:"flex h-full",children:[e.jsx("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:75:23",className:"bg-blue-500",style:{width:`${c.cuLine truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{i as G,j as e,L as U,z as Y,r as g,aI as q,B as Q,A as ee,J as se,T as $,p as te,N as ce}from"./index-Dmami9WE.js";import{C as F,b as B,c as K,a as z}from"./card-CIfC-8Rh.js";import{S as ae}from"./stat-strip-BteRU1Iu.js";import{B as Z}from"./badge-3UzCvU7L.js";import{T as ie,a as ne,b as L,c as D}from"./tabs-lV44z_UR.js";import{S as re,a as oe,b as le,c as de,d as S}from"./select-DUbxjT0z.js";import{d as pe}from"./dashboard-BHNKEvkq.js";import{s as me}from"./server-3HmnhxQB.js";import{a as H}from"./monitor-CicbJUrQ.js";import{H as J}from"./hard-drive-DmC04Y5r.js";import{Z as X}from"./zap-CocSkPPl.js";import{C as xe}from"./calendar-CxZxrJ2o.js";import{T as W}from"./trending-up-d1DKmRom.js";import{S as he}from"./sparkles-rPZivnlW.js";import{M as ye}from"./memory-stick-DvAvWvue.js";import{M as ve}from"./minus-DRP_TSA-.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";const Ae=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],ue=G("chart-line",Ae);const be=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],je=G("trending-down",be);function Pe({forecasts:a,loading:i}){return e.jsxs(F,{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:14:5",className:"bg-slate-800 border-slate-700",children:[e.jsx(B,{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:15:7",className:"pb-3",children:e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:16:9",className:"flex items-center justify-between",children:[e.jsxs(K,{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:17:11",className:"text-slate-100 flex items-center gap-2",children:[e.jsx(J,{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:18:13",className:"h-5 w-5 text-amber-400"}),"容量规划预警"]}),e.jsx("span",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:21:11",className:"text-xs text-slate-500",children:"基于日均增长率推算阈值触及时间"})]})}),e.jsx(z,{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:24:7",children:i?e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:26:11",className:"flex items-center justify-center py-12 text-slate-500",children:[e.jsx(U,{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:27:13",className:"h-5 w-5 animate-spin mr-2"})," 加载容量数据..."]}):a.length===0?e.jsx("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:30:11",className:"text-center py-12 text-slate-500",children:"暂无容量数据"}):e.jsx("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:32:11",className:"space-y-4",children:a.map((c,p)=>e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:34:15",className:"p-4 rounded-lg border border-slate-700 bg-slate-800/50",children:[e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:35:17",className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:36:19",className:"flex items-center gap-2",children:[e.jsx(Y,{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:37:21",className:"h-5 w-5 text-blue-400"}),e.jsx("span",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:38:21",className:"font-medium text-slate-200",children:c.resource})]}),e.jsx(Z,{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:40:19",variant:"outline",className:c.daysUntilThreshold<=7?"border-red-500/30 text-red-400 bg-red-500/10":c.daysUntilThreshold<=14?"border-amber-500/30 text-amber-400 bg-amber-500/10":"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:c.daysUntilThreshold<=7?"紧急":c.daysUntilThreshold<=14?"警告":"正常"})]}),e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:58:17",className:"mb-4",children:[e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:59:19",className:"flex items-center justify-between text-sm mb-1",children:[e.jsx("span",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:60:21",className:"text-slate-400",children:"7天使用率预测"}),e.jsx("span",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:61:21",className:"text-slate-400",children:c.daysUntilThreshold>=999?"增长平缓,暂无触顶风险":e.jsxs(e.Fragment,{children:["预计"," ",e.jsxs("span",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:67:27",className:"text-amber-400 font-medium",children:[c.daysUntilThreshold,"天"]})," ","后达到阈值"]})})]}),e.jsx("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:73:19",className:"h-3 bg-slate-700 rounded-full overflow-hidden",children:e.jsxs("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:74:21",className:"flex h-full",children:[e.jsx("div",{"code-path":"src/components/aiops/PredictiveCapacityTab.tsx:75:23",className:"bg-blue-500",style:{width:`${c.currentUsage}%`}Line truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{g as Qe,j as e,w as Ze,T as te,$ as De,a3 as re,a8 as Xe,D as q,b as B,c as P,d as U,e as V,f as le,B as a,a9 as be,n as Ke,r as o,I as T,a as Ye,S as et,U as tt,a7 as rt}from"./index-DfyorCky.js";import{B as u}from"./badge-xNW8x0G1.js";import{C as y,a as w,b as Ne,c as ye}from"./card-C55cvSHg.js";import{S as ne,a as se,b as oe,c as ce,d as v}from"./select-D5qUzdAs.js";import{T as nt,a as st,b as M,c as F}from"./tabs-CIh_yD4s.js";import{S as ot}from"./switch-CGiGgOnh.js";import{t as m}from"./index-a3ybMjbR.js";import{a as D,b as z}from"./monitor-BAaBXIsC.js";import{a as K}from"./agent-DqqIRCQX.js";import{Z as ke}from"./zap-D2uWSK32.js";import{L as h}from"./label-BK0h2apY.js";import{A as ct}from"./AlertRuleDialog-DnF-_Zoj.js";import{T as at}from"./textarea-NXY8u32k.js";import{R as Y}from"./refresh-cw-DUB_tAG-.js";import{P as ee}from"./plus-CUG-9kpu.js";import"./index-CWVNW_qu.js";import"./message-square-DyxabBvb.js";import"./phone-DgvWDdJl.js";const lt=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]],Se=Qe("volume-x",lt);function it(r){return{id:String(r.id),title:r.rule_name||r.title||`告警 #${r.id}`,description:r.message||r.description||"",severity:r.severity||"info",status:r.status||"firing",source:r.target||r.source||"",service:r.service||"",metric:r.metric||"",value:r.value||0,threshold:r.threshold||0,startedAt:r.started_at||r.startedAt||r.created_at||new Date().toISOString(),resolvedAt:r.resolved_at||r.resolvedAt,labels:typeof r.labels=="string"?(()=>{try{return JSON.parse(r.labels||"{}")}catch{return{}}})():r.labels||{},annotations:typeof r.annotations=="string"?(()=>{try{return JSON.parse(r.annotations||"{}")}catch{return{}}})():r.annotations||{}}}function ae(r){switch(r){case"critical":return e.jsxs(u,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:106:14",variant:"destructive",className:"gap-1",children:[e.jsx(De,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:106:61",className:"w-3 h-3"}),"严重"]});case"warning":return e.jsxs(u,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:108:14",variant:"default",className:"bg-orange-500 gap-1",children:[e.jsx(te,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:108:71",className:"w-3 h-3"}),"警告"]});case"info":return e.jsxs(u,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:110:14",variant:"default",className:"bg-blue-500 gap-1",children:[e.jsx(Ze,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:110:69",className:"w-3 h-3"}),"信息"]});default:return e.jsx(u,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:112:14",variant:"secondary",children:"未知"})}}function mt(r){switch(r){case"firing":return e.jsxs(u,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:120:14",variant:"destructive",className:"gap-1 animate-pulse",children:[e.jsx(ke,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:120:75",className:"w-3 h-3"}),"触发中"]});case"acknowledged":return e.jsxs(u,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:122:14",variant:"default",className:"bg-yellow-500 gap-1",children:[e.jsx(Xe,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:122:71",className:"w-3 h-3"}),"已确认"]});case"resolved":return e.jsxs(u,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:124:14",variant:"default",className:"bg-green-500 gap-1",children:[e.jsx(re,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:124:70",className:"w-3 h-3"}),"已解决"]});case"suppressed":return e.jsxs(u,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:126:14",variant:"secondary",className:"gap-1",children:[e.jsx(Se,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:126:59",className:"w-3 h-3"}),"已静默"]});default:return e.jsx(u,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:128:14",variant:"secondary",children:"未知"})}}function dt(r){return{dingtalk:"钉钉",wechat:"企业微信",feishu:"飞书",email:"邮件",sms:"短信",webhook:"Webhook"}[r]||r}function pt({alert:r,open:C,onOpenChange:c,onAcknowledge:A}){return e.jsx(q,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:22:5",open:C,onOpenChange:c,children:e.jsxs(B,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:23:7",className:"max-w-3xl",children:[e.jsxs(P,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:24:9",children:[e.jsxs(U,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{i as Oe,j as e,I as st,T as Le,a6 as ot,P as ze,U as ct,D as V,a as H,b as U,c as Q,d as Y,e as ie,B as d,K as Ge,o as at,r as s,f as $e,C as lt,O as it,al as mt}from"./index-Dmami9WE.js";import{I as E}from"./input-NsU9nXZF.js";import{B as v}from"./badge-3UzCvU7L.js";import{C as F,a as J,b as Te,c as _e}from"./card-CIfC-8Rh.js";import{S as dt}from"./stat-strip-BteRU1Iu.js";import{S as se,a as oe,b as ce,c as ae,d as _}from"./select-DUbxjT0z.js";import{T as pt,a as xt,b as P,c as W}from"./tabs-lV44z_UR.js";import{S as Ie}from"./switch-TqjD2x0W.js";import{t as l}from"./index-BuEnLCjT.js";import{a as O,b as R}from"./monitor-CicbJUrQ.js";import{a as ge}from"./agent-B3ElXCx8.js";import{Z as ht}from"./zap-CocSkPPl.js";import{L as j}from"./label-Ap_-SPYI.js";import{A as ut}from"./AlertRuleDialog-CpPLZsky.js";import{T as gt}from"./textarea-DHUZ6N85.js";import{R as re}from"./refresh-cw-CTBERyFc.js";import{P as ne}from"./plus-O65gX7Qz.js";import{C as jt}from"./calendar-CxZxrJ2o.js";import{S as Ct}from"./square-pen-B3dPIBrm.js";import{T as ft}from"./trash-2-DWVnIU6o.js";import{S as vt}from"./search-Dd-PeBfg.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";import"./message-square-BNbub2_o.js";import"./phone-Cn_wSobp.js";const At=[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]],Nt=Oe("repeat",At);const yt=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]],le=Oe("volume-x",yt);function wt(r){return{id:String(r.id),title:r.rule_name||r.title||`告警 #${r.id}`,description:r.message||r.description||"",severity:r.severity||"info",status:r.status||"firing",source:r.target||r.source||"",service:r.service||"",metric:r.metric||"",value:r.value||0,threshold:r.threshold||0,startedAt:r.started_at||r.startedAt||r.created_at||new Date().toISOString(),resolvedAt:r.resolved_at||r.resolvedAt,labels:typeof r.labels=="string"?(()=>{try{return JSON.parse(r.labels||"{}")}catch{return{}}})():r.labels||{},annotations:typeof r.annotations=="string"?(()=>{try{return JSON.parse(r.annotations||"{}")}catch{return{}}})():r.annotations||{}}}function je(r){switch(r){case"critical":return e.jsxs(v,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:106:14",variant:"destructive",className:"gap-1",children:[e.jsx(ot,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:106:61",className:"w-3 h-3"}),"严重"]});case"warning":return e.jsxs(v,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:108:14",variant:"default",className:"bg-orange-500 gap-1",children:[e.jsx(Le,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:108:71",className:"w-3 h-3"}),"警告"]});case"info":return e.jsxs(v,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:110:14",variant:"default",className:"bg-blue-500 gap-1",children:[e.jsx(st,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:110:69",className:"w-3 h-3"}),"信息"]});default:return e.jsx(v,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:112:14",variant:"secondary",children:"未知"})}}function bt(r){switch(r){case"firing":return e.jsxs(v,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:120:14",variant:"destructive",className:"gap-1 animate-pulse",children:[e.jsx(ht,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:120:75",className:"w-3 h-3"}),"触发中"]});case"acknowledged":return e.jsxs(v,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:122:14",variant:"default",className:"bg-yellow-500 gap-1",children:[e.jsx(ct,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:122:71",className:"w-3 h-3"}),"已确认"]});case"resolved":return e.jsxs(v,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:124:14",variant:"default",className:"bg-green-500 gap-1",children:[e.jsx(ze,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:124:70",className:"w-3 h-3"}),"已解决"]});case"suppressed":return e.jsxs(v,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:126:14",variant:"secondary",className:"gap-1",children:[e.jsx(le,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:126:59",className:"w-3 h-3"}),"已静默"]});default:return e.jsx(v,{"code-path":"src/components/monitor/alert-center/alert-center-helpers.tsx:128:14",variant:"secondary",children:"未知"})}}function St(r){return{dingtalk:"钉钉",wechat:"企业微信",feishu:"飞书",email:"邮件",sms:"短信"Line truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{a as _,r as l,j as e,S as ee,I as Y,L as O,B as A,a3 as $,J,T as z,E as Q,D as te,b as se,c as oe,d as ae,e as ne,f as re,x as ce}from"./index-DfyorCky.js";import{C as w,a as M,b as le,c as ie,d as me}from"./card-C55cvSHg.js";import{T as de,a as xe,b as H,c as I}from"./tabs-CIh_yD4s.js";import{a as g}from"./monitor-BAaBXIsC.js";import{B as f}from"./badge-xNW8x0G1.js";import{T as X,a as V,b as E,c as i,d as q,e as c}from"./table-5sHV4Akp.js";import{S as B}from"./switch-CGiGgOnh.js";import{C as G}from"./checkbox-CH0bpj6b.js";import{t as R}from"./index-a3ybMjbR.js";import{r as pe,g as he,C as K,A as ge}from"./AlertRuleDialog-DnF-_Zoj.js";import{T as P}from"./trash-2-Dx32pOzT.js";import{L as D}from"./label-BK0h2apY.js";import{T as be}from"./textarea-NXY8u32k.js";import{P as U}from"./plus-CUG-9kpu.js";import{R as Ae,C as je,X as ue,Y as Ne,T as ve}from"./generateCategoricalChart-6v9BPbG2.js";import{A as fe,a as W}from"./AreaChart-B2zlWfdX.js";import"./index-CWVNW_qu.js";import"./message-square-DyxabBvb.js";import"./phone-DgvWDdJl.js";function Te({alerts:m,loading:T,onReload:d}){_();const[p,u]=l.useState(""),[o,h]=l.useState("all"),[b,C]=l.useState("all"),j=m.filter(t=>{const r=(t.rule&&t.rule.name||t.message||"").toLowerCase().includes(p.toLowerCase())||(t.target||"").toLowerCase().includes(p.toLowerCase()),N=o==="all"||t.severity===o,v=b==="all"||t.status===b;return r&&N&&v}),y=t=>{switch(t){case"critical":return e.jsxs(f,{"code-path":"src/components/monitor/AlertEventsTab.tsx:45:11",variant:"outline",className:"border-red-500/30 text-red-400 bg-red-500/10",children:[e.jsx(z,{"code-path":"src/components/monitor/AlertEventsTab.tsx:46:13",className:"h-3 w-3 mr-1"}),"严重"]});case"warning":return e.jsxs(f,{"code-path":"src/components/monitor/AlertEventsTab.tsx:52:11",variant:"outline",className:"border-amber-500/30 text-amber-400 bg-amber-500/10",children:[e.jsx(z,{"code-path":"src/components/monitor/AlertEventsTab.tsx:53:13",className:"h-3 w-3 mr-1"}),"警告"]});case"info":return e.jsxs(f,{"code-path":"src/components/monitor/AlertEventsTab.tsx:59:11",variant:"outline",className:"border-blue-500/30 text-blue-400 bg-blue-500/10",children:[e.jsx(J,{"code-path":"src/components/monitor/AlertEventsTab.tsx:60:13",className:"h-3 w-3 mr-1"}),"提示"]});default:return null}},a=t=>{switch(t){case"firing":return e.jsx(f,{"code-path":"src/components/monitor/AlertEventsTab.tsx:73:11",variant:"outline",className:"border-red-500/30 text-red-400 bg-red-500/10 animate-pulse",children:"触发中"});case"resolved":return e.jsx(f,{"code-path":"src/components/monitor/AlertEventsTab.tsx:79:11",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:"已恢复"});default:return null}},x=async t=>{try{await g.acknowledge(t),d()}catch(r){console.error("Failed to acknowledge alert:",r)}};return e.jsxs("div",{"code-path":"src/components/monitor/AlertEventsTab.tsx:98:5",className:"mt-4 space-y-4",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertEventsTab.tsx:100:7",className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertEventsTab.tsx:101:9",className:"relative w-64",children:[e.jsx(ee,{"code-path":"src/components/monitor/AlertEventsTab.tsx:102:11",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-500"}),e.jsx(Y,{"code-path":"src/components/monitor/AlertEventsTab.tsx:103:11",placeholder:"搜索告警名称或目标...",value:p,onChange:t=>u(t.target.value),className:"pl-9 h-9 bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-500"})]}),e.jsxs("select",{"code-path":"src/components/monitor/AlertEventsTab.tsx:110:9",value:o,onChange:t=>h(t.target.value),className:"h-9 px-3 rounded-md bg-slate-800/50 border border-slate-700 text-slate-200 text-sm",children:[e.jsx("option",{"code-path":"src/components/monitor/AlertEventsTab.tsx:115:11",value:"all",children:"全部级别"}),e.jsx("option",{"code-path":"src/components/monitor/AlertEventsTab.tsx:116:11",value:"critical",children:"严重"}),e.jsx("option",{"code-path":"src/components/monitor/AlertEventsTab.tsx:117:11",value:"warning",children:"警告"}),e.jsx("option",{"code-path":"src/components/monitor/AlertEventsTab.tsx:118:11",value:"info",children:"提示"})]}),e.jsxs("select",{"code-path":"src/components/monitor/AlertEventsTab.tsx:120:9",value:b,onChange:t=>C(t.target.value),className:"h-9 px-3 rounded-md bg-slate-800/50 border border-slate-700 text-slate-200 text-sm",children:[e.jsx("option",{"code-path":"src/components/monitor/AlertEventsTab.tsx:125:11",value:"all",children:"全部状态"}),e.jsx("option",{"code-path":"src/components/monitor/AlertEventsTab.tsx:126:11",value:"firing",children:"触发中"}),e.jsx("option",{"code-path":"src/components/monitor/AlertEventsTab.tsx:127:11",value:"resolved",children:"已恢复"})]})]}),e.jsx(w,{"code-path":"src/components/monitor/AlertEventsTab.tsx:132:7",className:"bg-slate-900 border-slatLine truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{f as H,r as l,j as e,L as O,B as A,P as Y,H as $,T as z,y as Q,D as ee,a as te,b as se,c as oe,d as ae,e as ne,C as re}from"./index-Dmami9WE.js";import{C as w,a as M,b as ce,c as le,d as ie}from"./card-CIfC-8Rh.js";import{T as me,a as de,b as _,c as I}from"./tabs-lV44z_UR.js";import{a as g}from"./monitor-CicbJUrQ.js";import{I as X}from"./input-NsU9nXZF.js";import{B as f}from"./badge-3UzCvU7L.js";import{T as J,a as V,b as R,c as i,d as q,e as c}from"./table-CG4mjNfb.js";import{S as xe}from"./search-Dd-PeBfg.js";import{S as B}from"./switch-TqjD2x0W.js";import{C as G}from"./checkbox-DoAtRzQj.js";import{t as E}from"./index-BuEnLCjT.js";import{r as pe,g as he,C as K,A as ge}from"./AlertRuleDialog-CpPLZsky.js";import{T as P}from"./trash-2-DWVnIU6o.js";import{L as D}from"./label-Ap_-SPYI.js";import{T as be}from"./textarea-DHUZ6N85.js";import{P as U}from"./plus-O65gX7Qz.js";import{R as Ae,C as je,X as ue,Y as Ne,T as ve}from"./generateCategoricalChart-ZqCvxO-S.js";import{A as fe,a as W}from"./AreaChart-CrvX3B0s.js";import"./index-CtCQcvyh.js";import"./message-square-BNbub2_o.js";import"./phone-Cn_wSobp.js";function Te({alerts:m,loading:T,onReload:d}){H();const[p,u]=l.useState(""),[o,h]=l.useState("all"),[b,C]=l.useState("all"),j=m.filter(t=>{const r=(t.rule&&t.rule.name||t.message||"").toLowerCase().includes(p.toLowerCase())||(t.target||"").toLowerCase().includes(p.toLowerCase()),N=o==="all"||t.severity===o,v=b==="all"||t.status===b;return r&&N&&v}),y=t=>{switch(t){case"critical":return e.jsxs(f,{"code-path":"src/components/monitor/AlertEventsTab.tsx:45:11",variant:"outline",className:"border-red-500/30 text-red-400 bg-red-500/10",children:[e.jsx(z,{"code-path":"src/components/monitor/AlertEventsTab.tsx:46:13",className:"h-3 w-3 mr-1"}),"严重"]});case"warning":return e.jsxs(f,{"code-path":"src/components/monitor/AlertEventsTab.tsx:52:11",variant:"outline",className:"border-amber-500/30 text-amber-400 bg-amber-500/10",children:[e.jsx(z,{"code-path":"src/components/monitor/AlertEventsTab.tsx:53:13",className:"h-3 w-3 mr-1"}),"警告"]});case"info":return e.jsxs(f,{"code-path":"src/components/monitor/AlertEventsTab.tsx:59:11",variant:"outline",className:"border-blue-500/30 text-blue-400 bg-blue-500/10",children:[e.jsx($,{"code-path":"src/components/monitor/AlertEventsTab.tsx:60:13",className:"h-3 w-3 mr-1"}),"提示"]});default:return null}},a=t=>{switch(t){case"firing":return e.jsx(f,{"code-path":"src/components/monitor/AlertEventsTab.tsx:73:11",variant:"outline",className:"border-red-500/30 text-red-400 bg-red-500/10 animate-pulse",children:"触发中"});case"resolved":return e.jsx(f,{"code-path":"src/components/monitor/AlertEventsTab.tsx:79:11",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:"已恢复"});default:return null}},x=async t=>{try{await g.acknowledge(t),d()}catch(r){console.error("Failed to acknowledge alert:",r)}};return e.jsxs("div",{"code-path":"src/components/monitor/AlertEventsTab.tsx:98:5",className:"mt-4 space-y-4",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertEventsTab.tsx:100:7",className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertEventsTab.tsx:101:9",className:"relative w-64",children:[e.jsx(xe,{"code-path":"src/components/monitor/AlertEventsTab.tsx:102:11",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-500"}),e.jsx(X,{"code-path":"src/components/monitor/AlertEventsTab.tsx:103:11",placeholder:"搜索告警名称或目标...",value:p,onChange:t=>u(t.target.value),className:"pl-9 h-9 bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-500"})]}),e.jsxs("select",{"code-path":"src/components/monitor/AlertEventsTab.tsx:110:9",value:o,onChange:t=>h(t.target.value),className:"h-9 px-3 rounded-md bg-slate-800/50 border border-slate-700 text-slate-200 text-sm",children:[e.jsx("option",{"code-path":"src/components/monitor/AlertEventsTab.tsx:115:11",value:"all",children:"全部级别"}),e.jsx("option",{"code-path":"src/components/monitor/AlertEventsTab.tsx:116:11",value:"critical",children:"严重"}),e.jsx("option",{"code-path":"src/components/monitor/AlertEventsTab.tsx:117:11",value:"warning",children:"警告"}),e.jsx("option",{"code-path":"src/components/monitor/AlertEventsTab.tsx:118:11",value:"info",children:"提示"})]}),e.jsxs("select",{"code-path":"src/components/monitor/AlertEventsTab.tsx:120:9",value:b,onChange:t=>C(t.target.value),className:"h-9 px-3 rounded-md bg-slate-800/50 border border-slate-700 text-slate-200 text-sm",children:[e.jsx("option",{"code-path":"src/components/monitor/AlertEventsTab.tsx:125:11",value:"all",children:"全部状态"}),e.jsx("option",{"code-path":"src/components/monitor/AlertEventsTab.tsx:126:11",value:"firing",children:"触发中"}),e.jsx("option",{"code-path":"src/components/monitor/AlertEventsTab.tsx:127:11",value:"resolved",children:"已恢复"})]})]}),e.jsx(w,{"code-path":"src/componentLine truncated
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
import{j as e,J as R,r as d,D as v,b as w,c as k,d as S,e as _,I as x,f as C,B as g,L}from"./index-DfyorCky.js";import{L as n}from"./label-BK0h2apY.js";import{T as E}from"./textarea-NXY8u32k.js";import{S as P}from"./switch-CGiGgOnh.js";import{a as A}from"./monitor-BAaBXIsC.js";import{M as T}from"./message-square-DyxabBvb.js";import{P as I,M as B}from"./phone-DgvWDdJl.js";function D(o){if(!o)return[];if(Array.isArray(o))return o;if(typeof o=="string"){try{const r=JSON.parse(o);if(Array.isArray(r))return r}catch{}return o.split(",").map(r=>r.trim()).filter(Boolean)}return[]}const F=["email","sms","dingtalk","wechat","webhook"],q={dingtalk:"钉钉",wechat:"企业微信",email:"邮件",sms:"短信",webhook:"Webhook"};function H(o,r){if(!o)return null;const a=r.find(c=>String(c.id)===String(o));return a?{type:a.type||"unknown",name:a.name||a.type||"未命名",isLegacy:!1}:F.includes(o)?{type:o,name:q[o]||o,isLegacy:!0}:null}const M=[{key:"dingtalk",label:"钉钉",placeholder:`{
|
||||
import{j as e,H as R,r as d,D as v,a as w,b as k,c as S,d as _,e as C,B as g,L}from"./index-Dmami9WE.js";import{I as x}from"./input-NsU9nXZF.js";import{L as n}from"./label-Ap_-SPYI.js";import{T as E}from"./textarea-DHUZ6N85.js";import{S as P}from"./switch-TqjD2x0W.js";import{a as A}from"./monitor-CicbJUrQ.js";import{M as T}from"./message-square-BNbub2_o.js";import{P as I,M as B}from"./phone-Cn_wSobp.js";function D(o){if(!o)return[];if(Array.isArray(o))return o;if(typeof o=="string"){try{const r=JSON.parse(o);if(Array.isArray(r))return r}catch{}return o.split(",").map(r=>r.trim()).filter(Boolean)}return[]}const F=["email","sms","dingtalk","wechat","webhook"],H={dingtalk:"钉钉",wechat:"企业微信",email:"邮件",sms:"短信",webhook:"Webhook"};function q(o,r){if(!o)return null;const a=r.find(c=>String(c.id)===String(o));return a?{type:a.type||"unknown",name:a.name||a.type||"未命名",isLegacy:!1}:F.includes(o)?{type:o,name:H[o]||o,isLegacy:!0}:null}const M=[{key:"dingtalk",label:"钉钉",placeholder:`{
|
||||
"webhook": "https://oapi.dingtalk.com/robot/send?access_token=***",
|
||||
"secret": "SECxxx"
|
||||
}`},{key:"wechat",label:"企业微信",placeholder:`{
|
||||
@@ -11,4 +11,4 @@ import{j as e,J as R,r as d,D as v,b as w,c as k,d as S,e as _,I as x,f as C,B a
|
||||
"sign": "AIOps"
|
||||
}`},{key:"webhook",label:"Webhook",placeholder:`{
|
||||
"url": "https://example.com/alert"
|
||||
}`}];function y(o){return M.find(r=>r.key===o)?.label||o}function j(o){switch(o){case"email":return B;case"sms":return I;case"dingtalk":case"wechat":return T;default:return R}}function Q(o,r){const a=D(o.notify_channels);return a.length===0?e.jsx("span",{"code-path":"src/components/monitor/alertShared.tsx:76:33",className:"text-xs text-slate-600",children:"--"}):e.jsx("div",{"code-path":"src/components/monitor/alertShared.tsx:78:5",className:"flex flex-wrap gap-1",children:a.map(c=>{const i=H(c,r);if(!i)return null;const t=j(i.type);return e.jsxs("span",{"code-path":"src/components/monitor/alertShared.tsx:84:11",title:`${i.name} (${y(i.type)})`,className:"inline-flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-slate-800 text-slate-300",children:[e.jsx(t,{"code-path":"src/components/monitor/alertShared.tsx:89:13",className:"h-3 w-3 text-slate-400"}),i.name]},c)})})}const b={name:"",description:"",type:"metric",source:"prometheus",expression:"",severity:"warning",duration:300,notify_channels:[]};function U({open:o,onOpenChange:r,editingRule:a,notifyChannels:c,onSaved:i}){const[t,l]=d.useState({...b}),[h,u]=d.useState(!1);d.useEffect(()=>{o&&l(a?{name:a.name||"",description:a.description||"",type:a.type||"metric",source:a.source||"prometheus",expression:a.expression||"",severity:a.severity||"warning",duration:a.duration||300,notify_channels:D(a.notify_channels)}:{...b})},[o,a]);const f=s=>{l(m=>({...m,notify_channels:m.notify_channels.includes(s)?m.notify_channels.filter(p=>p!==s):[...m.notify_channels,s]}))},N=async()=>{if(!(!t.name.trim()||!t.expression.trim())){u(!0);try{const s={name:t.name.trim(),description:t.description.trim(),type:t.type,source:t.source,expression:t.expression.trim(),severity:t.severity,duration:Number(t.duration)||0,notify_channels:t.notify_channels};a?await A.updateRule(a.id,s):await A.createRule(s),r(!1),i()}catch(s){console.error("Failed to save rule:",s)}finally{u(!1)}}};return e.jsx(v,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:103:5",open:o,onOpenChange:r,children:e.jsxs(w,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:104:7",className:"bg-slate-900 border-slate-700 text-slate-100 max-w-lg",children:[e.jsxs(k,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:105:9",children:[e.jsx(S,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:106:11",className:"text-slate-100",children:a?"编辑告警规则":"新建告警规则"}),e.jsx(_,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:109:11",className:"text-slate-500",children:a?"修改告警规则的触发条件和通知方式":"配置监控指标的告警触发条件"})]}),e.jsxs("div",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:114:9",className:"space-y-4 max-h-[60vh] overflow-y-auto pr-1",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:115:11",className:"space-y-1.5",children:[e.jsxs(n,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:116:13",className:"text-slate-300",children:["规则名称 ",e.jsx("span",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:116:52",className:"text-red-400",children:"*"})]}),e.jsx(x,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:117:13",value:t.name,onChange:s=>l({...t,name:s.target.value}),placeholder:"如:CPU 使用率告警",className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-600"})]}),e.jsxs("div",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:125:11",className:"space-y-1.5",children:[e.jsx(n,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:126:13",className:"text-slate-300",children:"描述"}),e.jsx(E,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:127:13",value:t.description,onChange:s=>l({...t,description:s.target.value}),placeholder:"规则说明",rows:2,className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-600 resize-none"})]}),e.jsxs("div",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:136:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:137:13",className:"space-y-1.5",children:[e.jsx(n,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:138:15",className:"text-slate-300",children:"规则类型"}),e.jsxs("select",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:139:15",value:t.type,onChange:s=>l({...t,type:s.target.value}),className:"w-full h-9 px-3 rounded-md bg-slate-800/50 border border-slate-700 text-slate-200 text-sm",children:[e.jsx("option",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:144:17",value:"metric",children:"指标监控"}),e.jsx("option",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:145:17",value:"log",children:"日志告警"}),e.jsx("option",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:146:17",value:"event",children:"事件告警"})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:149:13",className:"space-y-1.5",chi
Line truncated
|
||||
}`}];function y(o){return M.find(r=>r.key===o)?.label||o}function j(o){switch(o){case"email":return B;case"sms":return I;case"dingtalk":case"wechat":return T;default:return R}}function U(o,r){const a=D(o.notify_channels);return a.length===0?e.jsx("span",{"code-path":"src/components/monitor/alertShared.tsx:76:33",className:"text-xs text-slate-600",children:"--"}):e.jsx("div",{"code-path":"src/components/monitor/alertShared.tsx:78:5",className:"flex flex-wrap gap-1",children:a.map(c=>{const i=q(c,r);if(!i)return null;const t=j(i.type);return e.jsxs("span",{"code-path":"src/components/monitor/alertShared.tsx:84:11",title:`${i.name} (${y(i.type)})`,className:"inline-flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-slate-800 text-slate-300",children:[e.jsx(t,{"code-path":"src/components/monitor/alertShared.tsx:89:13",className:"h-3 w-3 text-slate-400"}),i.name]},c)})})}const b={name:"",description:"",type:"metric",source:"prometheus",expression:"",severity:"warning",duration:300,notify_channels:[]};function Z({open:o,onOpenChange:r,editingRule:a,notifyChannels:c,onSaved:i}){const[t,l]=d.useState({...b}),[h,u]=d.useState(!1);d.useEffect(()=>{o&&l(a?{name:a.name||"",description:a.description||"",type:a.type||"metric",source:a.source||"prometheus",expression:a.expression||"",severity:a.severity||"warning",duration:a.duration||300,notify_channels:D(a.notify_channels)}:{...b})},[o,a]);const f=s=>{l(m=>({...m,notify_channels:m.notify_channels.includes(s)?m.notify_channels.filter(p=>p!==s):[...m.notify_channels,s]}))},N=async()=>{if(!(!t.name.trim()||!t.expression.trim())){u(!0);try{const s={name:t.name.trim(),description:t.description.trim(),type:t.type,source:t.source,expression:t.expression.trim(),severity:t.severity,duration:Number(t.duration)||0,notify_channels:t.notify_channels};a?await A.updateRule(a.id,s):await A.createRule(s),r(!1),i()}catch(s){console.error("Failed to save rule:",s)}finally{u(!1)}}};return e.jsx(v,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:103:5",open:o,onOpenChange:r,children:e.jsxs(w,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:104:7",className:"bg-slate-900 border-slate-700 text-slate-100 max-w-lg",children:[e.jsxs(k,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:105:9",children:[e.jsx(S,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:106:11",className:"text-slate-100",children:a?"编辑告警规则":"新建告警规则"}),e.jsx(_,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:109:11",className:"text-slate-500",children:a?"修改告警规则的触发条件和通知方式":"配置监控指标的告警触发条件"})]}),e.jsxs("div",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:114:9",className:"space-y-4 max-h-[60vh] overflow-y-auto pr-1",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:115:11",className:"space-y-1.5",children:[e.jsxs(n,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:116:13",className:"text-slate-300",children:["规则名称 ",e.jsx("span",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:116:52",className:"text-red-400",children:"*"})]}),e.jsx(x,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:117:13",value:t.name,onChange:s=>l({...t,name:s.target.value}),placeholder:"如:CPU 使用率告警",className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-600"})]}),e.jsxs("div",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:125:11",className:"space-y-1.5",children:[e.jsx(n,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:126:13",className:"text-slate-300",children:"描述"}),e.jsx(E,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:127:13",value:t.description,onChange:s=>l({...t,description:s.target.value}),placeholder:"规则说明",rows:2,className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-600 resize-none"})]}),e.jsxs("div",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:136:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:137:13",className:"space-y-1.5",children:[e.jsx(n,{"code-path":"src/components/monitor/AlertRuleDialog.tsx:138:15",className:"text-slate-300",children:"规则类型"}),e.jsxs("select",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:139:15",value:t.type,onChange:s=>l({...t,type:s.target.value}),className:"w-full h-9 px-3 rounded-md bg-slate-800/50 border border-slate-700 text-slate-200 text-sm",children:[e.jsx("option",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:144:17",value:"metric",children:"指标监控"}),e.jsx("option",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:145:17",value:"log",children:"日志告警"}),e.jsx("option",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:146:17",value:"event",children:"事件告警"})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/AlertRuleDialog.tsx:149:13",className:"space-y-1.5",chi
Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{j as e}from"./index-Dmami9WE.js";import{A as t}from"./ApprovalCategoryPage-CIXhWQ3k.js";import"./card-CIfC-8Rh.js";import"./input-NsU9nXZF.js";import"./badge-3UzCvU7L.js";import"./label-Ap_-SPYI.js";import"./table-CG4mjNfb.js";import"./select-DUbxjT0z.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";import"./system-C3cYTuQH.js";import"./index-BuEnLCjT.js";import"./plus-O65gX7Qz.js";import"./search-Dd-PeBfg.js";import"./refresh-cw-CTBERyFc.js";import"./file-text-CebshSV-.js";import"./circle-x-BBQeW1R3.js";import"./play-0EwQQJX_.js";const r=[{key:"app_name",label:"应用名称",type:"text",placeholder:"如 user-service",required:!0},{key:"git_url",label:"Git 地址",type:"text",placeholder:"如 https://github.com/org/repo.git",required:!0},{key:"branch",label:"分支",type:"text",defaultValue:"main",required:!0},{key:"language",label:"开发语言",type:"select",options:["Java","Go","Python","Node.js","C++"],required:!0},{key:"http_port",label:"HTTP 端口",type:"number",placeholder:"如 8080"},{key:"env",label:"部署环境",type:"select",options:["dev","staging","prod"],required:!0},{key:"replicas",label:"副本数",type:"number",defaultValue:2,required:!0},{key:"remark",label:"备注",type:"textarea"}];function A(){return e.jsx(t,{"code-path":"src/pages/ApprovalAppPage.tsx:17:5",category:"app",title:"应用申请",description:"申请应用部署、版本发布、流水线配置",fields:r,templateCode:"app_deploy"})}export{A as ApprovalAppPage};
|
||||
@@ -0,0 +1 @@
|
||||
import{r as c,j as e,B as x,L as H,X as I,K as B,O as de,D as Q,a as W,b as Y,c as Z,d as ee,C as xe,P as ne,U as ie,o as he}from"./index-Dmami9WE.js";import{C as ve,a as me}from"./card-CIfC-8Rh.js";import{I as q}from"./input-NsU9nXZF.js";import{B as z}from"./badge-3UzCvU7L.js";import{L as ye}from"./label-Ap_-SPYI.js";import{T as ue,a as Ce,b as J,c as N,d as je,e as f}from"./table-CG4mjNfb.js";import{S as K,a as U,b as X,c as G,d as w}from"./select-DUbxjT0z.js";import{b as i}from"./system-C3cYTuQH.js";import{t as l}from"./index-BuEnLCjT.js";import{P as Pe}from"./plus-O65gX7Qz.js";import{S as Ae}from"./search-Dd-PeBfg.js";import{R as be}from"./refresh-cw-CTBERyFc.js";import{F as Ne}from"./file-text-CebshSV-.js";import{C as fe}from"./circle-x-BBQeW1R3.js";import{P as we}from"./play-0EwQQJX_.js";const ae=t=>{switch(t){case"approved":return e.jsxs(z,{"code-path":"src/pages/ApprovalCategoryPage.tsx:43:29",className:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30",children:[e.jsx(ne,{"code-path":"src/pages/ApprovalCategoryPage.tsx:43:105",className:"h-3 w-3 mr-1"}),"已通过"]});case"rejected":return e.jsxs(z,{"code-path":"src/pages/ApprovalCategoryPage.tsx:44:29",className:"bg-red-500/20 text-red-400 border-red-500/30",children:[e.jsx(fe,{"code-path":"src/pages/ApprovalCategoryPage.tsx:44:93",className:"h-3 w-3 mr-1"}),"已拒绝"]});default:return e.jsxs(z,{"code-path":"src/pages/ApprovalCategoryPage.tsx:45:21",className:"bg-amber-500/20 text-amber-400 border-amber-500/30",children:[e.jsx(xe,{"code-path":"src/pages/ApprovalCategoryPage.tsx:45:91",className:"h-3 w-3 mr-1"}),"审批中"]})}};function M(t){try{return JSON.parse(t)||{}}catch{return{}}}function se(t){const p=t?.applicant_user;return p?p.real_name||p.username||`#${t.applicant}`:t?.applicant?`#${t.applicant}`:"--"}function ke(t){if(t.status!=="pending")return"--";const p=t.steps||[];if(p.length===0)return"管理员(待分配)";const d=p.find(g=>g.step===t.current_step&&g.status==="pending");return d?d.approver_user?d.approver_user.real_name||d.approver_user.username||`#${d.approver}`:"管理员":"管理员(待分配)"}function Je({category:t,title:p,description:d,fields:g,templateCode:C}){const[y,j]=c.useState([]),[k,_]=c.useState(!0),[P,S]=c.useState(""),[h,D]=c.useState(""),[s,o]=c.useState(!1),[n,A]=c.useState(!1),[$,F]=c.useState(null),[v,b]=c.useState({}),[te,L]=c.useState(null),[E,T]=c.useState(!1),m=c.useCallback(async()=>{_(!0);try{const a={page_size:"100"};t&&(a.category=t),h&&(a.status=h);const r=await i.getProcesses(a);j(r?.list??r?.data?.list??[])}catch{j([])}finally{_(!1)}},[t,h]),O=c.useCallback(async()=>{try{const a=await i.getTemplates({type:C}),r=a?.list??a?.data?.list??[];r.length>0&&F(r[0].id)}catch{}},[C]);c.useEffect(()=>{m()},[m]),c.useEffect(()=>{O()},[O]);const re=async()=>{if(!$){l.error("模板未加载");return}for(const a of g)if(a.required&&!v[a.key]){l.error(`请填写「${a.label}」`);return}A(!0);try{const a=v[g[0]?.key]||"",r=g[1]&&v[g[1].key]||"";await i.createProcess({template_id:$,title:`${p} - ${a}${r?" / "+r:""}`,form_data:JSON.stringify(v)}),l.success("申请已提交"),o(!1),b({}),m()}catch(a){l.error(a?.message||"提交失败")}finally{A(!1)}},R=()=>{const a={};g.forEach(r=>{a[r.key]=r.defaultValue?.toString()||""}),b(a),o(!0)},pe=async a=>{T(!0);try{await i.approveProcess(a),l.success("已通过"),m()}catch(r){l.error(r?.response?.data?.message||"审批失败")}finally{T(!1)}},ce=async a=>{T(!0);try{await i.rejectProcess(a,"审批拒绝"),l.success("已拒绝"),m()}catch(r){l.error(r?.response?.data?.message||"操作失败")}finally{T(!1)}},oe=async a=>{try{const r=await i.getProcesses({page_size:200}),ge=(r?.list??r?.data?.list??[]).find(le=>le.id===a.id);L(ge||a)}catch{L(a)}},V=y.filter(a=>!P||(a.title||"").toLowerCase().includes(P.toLowerCase()));return e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:154:5",className:"space-y-5",children:[e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:155:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:156:9",children:[e.jsx("h1",{"code-path":"src/pages/ApprovalCategoryPage.tsx:157:11",className:"text-2xl font-bold text-[var(--dg-text-primary)]",children:p}),e.jsx("p",{"code-path":"src/pages/ApprovalCategoryPage.tsx:158:11",className:"text-sm text-[var(--dg-text-secondary)] mt-1",children:d})]}),e.jsxs(x,{"code-path":"src/pages/ApprovalCategoryPage.tsx:160:9",onClick:R,className:"bg-[var(--dg-blue)] hover:bg-[var(--dg-blue)]/90",children:[e.jsx(Pe,{"code-path":"src/pages/ApprovalCategoryPage.tsx:161:11",className:"h-4 w-4 mr-2"}),"新建申请"]})]}),e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:165:7",className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{"code-path":"src/pages/ApprovalCategoryPage.tsx:166:9",className:"relative w-64",children:[e.jsx(Ae,{"code-path":"src/pages/ApprovalCategoryPage.tsx:167:11",className:"Line truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{g as ye,q as Ne,j as e,X as b,L as $,S as we,I as pe,B as i,U as fe,a0 as oe,D as V,b as J,c as q,d as H,e as G,x as le,f as Q,r as v}from"./index-DfyorCky.js";import{C as u,a as j,b as Te,c as De,d as Fe}from"./card-C55cvSHg.js";import{B as C}from"./badge-xNW8x0G1.js";import{T as ce}from"./textarea-NXY8u32k.js";import{t as T}from"./index-a3ybMjbR.js";import{b as k}from"./system-BgtMMm0X.js";import{F as _}from"./file-text-C9G5abwR.js";import{C as D}from"./circle-check-DWcXrx2k.js";import{C as F}from"./circle-x-DK79Dhg2.js";import{F as Ce}from"./funnel-D2FHr15I.js";import{S as Pe}from"./square-pen-BxUFAe0F.js";import{A as Se}from"./arrow-right-DyIltvNZ.js";import{L as ke}from"./label-BK0h2apY.js";import{S as _e,a as Le,b as Oe,c as Ie,d as $e}from"./select-D5qUzdAs.js";import{P as ze}from"./plus-CUG-9kpu.js";import"./index-CWVNW_qu.js";const Re=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],Be=ye("git-commit-horizontal",Re);function Ee(a){if(Array.isArray(a))return a;if(typeof a=="string")try{const s=JSON.parse(a);return Array.isArray(s)?s:[]}catch{return[]}return[]}function I(a){if(!a)return[];const s=typeof a=="string"?(()=>{try{return JSON.parse(a)}catch{return null}})():a;return s?Array.isArray(s.fields)?s.fields:[]:[]}function Me(a,s){if(!a)return null;let r;try{r=typeof a=="string"?JSON.parse(a):a}catch{return null}if(!r||typeof r!="object")return null;const o=I(s?.form_schema),n=new Map;o.forEach(p=>n.set(p.key,p.label));const m=Object.entries(r).filter(([,p])=>p!=null&&p!=="");return m.length===0?null:e.jsx("div",{"code-path":"src/components/approval/helpers.tsx:53:5",className:"grid grid-cols-2 gap-x-4 gap-y-3",children:m.map(([p,d])=>e.jsxs("div",{"code-path":"src/components/approval/helpers.tsx:55:9",className:"min-w-0",children:[e.jsx("p",{"code-path":"src/components/approval/helpers.tsx:56:11",className:"text-xs text-[var(--dg-text-muted)] mb-0.5",children:n.get(p)||p}),e.jsx("p",{"code-path":"src/components/approval/helpers.tsx:57:11",className:"text-sm text-[var(--dg-text-primary)] break-words",children:String(d)})]},p))})}const z=[{value:"server_apply",label:"云服务器申请",icon:Ne,color:"var(--dg-cyan)"},{value:"app_deploy",label:"应用部署申请",icon:Be,color:"var(--dg-blue)"}],U=a=>z.find(s=>s.value===a)?.label||a||"通用审批",L=a=>z.find(s=>s.value===a)?.color||"var(--dg-text-secondary)",Ve=a=>z.find(s=>s.value===a)?.icon||_,A=a=>a?.template?.type||a?.type||"";function X(a){const s=Ee(a.steps),r=a.current_step??0,o=s.length,n=s.filter(p=>p.status==="approved"||p.status==="completed").length,m=o>0?Math.round(n/o*100):0;return{steps:s,currentIndex:r,total:o,completed:n,percentage:m}}function Y(a){const{steps:s,currentIndex:r}=X(a);return s.length===0?null:e.jsx("div",{"code-path":"src/components/approval/helpers.tsx:99:5",className:"flex items-center gap-1 overflow-x-auto",children:s.map((o,n)=>{const m=o.status==="approved"||o.status==="completed",p=n===r,d=o.status==="rejected";return e.jsxs("div",{"code-path":"src/components/approval/helpers.tsx:105:11",className:"flex items-center",children:[e.jsxs("div",{"code-path":"src/components/approval/helpers.tsx:106:13",className:b("flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs whitespace-nowrap",m&&"bg-emerald-500/10 text-emerald-400",p&&!d&&"bg-amber-500/10 text-amber-400 border border-amber-500/30",d&&"bg-red-500/10 text-red-400",!m&&!p&&!d&&"bg-[var(--dg-bg-tertiary)] text-[var(--dg-text-muted)]"),children:[m&&e.jsx(D,{"code-path":"src/components/approval/helpers.tsx:115:31",className:"h-3 w-3"}),d&&e.jsx(F,{"code-path":"src/components/approval/helpers.tsx:116:30",className:"h-3 w-3"}),p&&!d&&e.jsx($,{"code-path":"src/components/approval/helpers.tsx:117:44",className:"h-3 w-3 animate-spin"}),e.jsx("span",{"code-path":"src/components/approval/helpers.tsx:118:15",children:o.name||o.approver_name||`步骤 ${n+1}`})]}),n<s.length-1&&e.jsx("div",{"code-path":"src/components/approval/helpers.tsx:121:15",className:b("w-4 h-px",m?"bg-emerald-500/30":"bg-[var(--dg-border)]")})]},o.id||n)})})}const Je=[{key:"all",label:"全部",value:""},{key:"pending",label:"待审批",value:"pending"},{key:"approved",label:"已通过",value:"approved"},{key:"rejected",label:"已拒绝",value:"rejected"},{key:"processing",label:"进行中",value:"processing"},{key:"completed",label:"已完成",value:"completed"}];function qe(a){const s={pending:{label:"待审批",className:"border-amber-500/30 text-amber-400 bg-amber-500/10",dot:"bg-amber-400"},approved:{label:"已通过",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",dot:"bg-emerald-400"},rejected:{label:"已拒绝",className:"border-red-500/30 text-red-400 bg-red-500/10",dot:"bg-red-400"},processing:{label:"进行中",className:"border-[var(--dg-blue)]/30 text-[var(--dg-blue)] bg-[var(--dg-blue)]/10",dot:"bg-[var(--dg-blue)]"},completed:{label:"已完成Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{i as ye,S as Ne,j as e,a0 as b,L as $,B as i,O as we,Q as oe,D as V,a as J,b as q,c as H,d as Q,C as pe,e as G,r as v}from"./index-Dmami9WE.js";import{C as u,a as j,b as fe,c as Te,d as De}from"./card-CIfC-8Rh.js";import{B as C}from"./badge-3UzCvU7L.js";import{T as le}from"./textarea-DHUZ6N85.js";import{t as T}from"./index-BuEnLCjT.js";import{b as k}from"./system-C3cYTuQH.js";import{I as ce}from"./input-NsU9nXZF.js";import{F as _}from"./file-text-CebshSV-.js";import{C as D}from"./circle-check-CVbTTFQ0.js";import{C as F}from"./circle-x-BBQeW1R3.js";import{S as Fe}from"./search-Dd-PeBfg.js";import{F as Ce}from"./funnel-DngS63SK.js";import{S as Pe}from"./square-pen-B3dPIBrm.js";import{A as Se}from"./arrow-right-CkKR0P0R.js";import{L as ke}from"./label-Ap_-SPYI.js";import{S as _e,a as Le,b as Oe,c as Ie,d as $e}from"./select-DUbxjT0z.js";import{P as ze}from"./plus-O65gX7Qz.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";const Re=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],Be=ye("git-commit-horizontal",Re);function Ee(a){if(Array.isArray(a))return a;if(typeof a=="string")try{const s=JSON.parse(a);return Array.isArray(s)?s:[]}catch{return[]}return[]}function I(a){if(!a)return[];const s=typeof a=="string"?(()=>{try{return JSON.parse(a)}catch{return null}})():a;return s?Array.isArray(s.fields)?s.fields:[]:[]}function Me(a,s){if(!a)return null;let r;try{r=typeof a=="string"?JSON.parse(a):a}catch{return null}if(!r||typeof r!="object")return null;const o=I(s?.form_schema),n=new Map;o.forEach(p=>n.set(p.key,p.label));const m=Object.entries(r).filter(([,p])=>p!=null&&p!=="");return m.length===0?null:e.jsx("div",{"code-path":"src/components/approval/helpers.tsx:53:5",className:"grid grid-cols-2 gap-x-4 gap-y-3",children:m.map(([p,d])=>e.jsxs("div",{"code-path":"src/components/approval/helpers.tsx:55:9",className:"min-w-0",children:[e.jsx("p",{"code-path":"src/components/approval/helpers.tsx:56:11",className:"text-xs text-[var(--dg-text-muted)] mb-0.5",children:n.get(p)||p}),e.jsx("p",{"code-path":"src/components/approval/helpers.tsx:57:11",className:"text-sm text-[var(--dg-text-primary)] break-words",children:String(d)})]},p))})}const z=[{value:"server_apply",label:"云服务器申请",icon:Ne,color:"var(--dg-cyan)"},{value:"app_deploy",label:"应用部署申请",icon:Be,color:"var(--dg-blue)"}],Y=a=>z.find(s=>s.value===a)?.label||a||"通用审批",L=a=>z.find(s=>s.value===a)?.color||"var(--dg-text-secondary)",Ve=a=>z.find(s=>s.value===a)?.icon||_,A=a=>a?.template?.type||a?.type||"";function U(a){const s=Ee(a.steps),r=a.current_step??0,o=s.length,n=s.filter(p=>p.status==="approved"||p.status==="completed").length,m=o>0?Math.round(n/o*100):0;return{steps:s,currentIndex:r,total:o,completed:n,percentage:m}}function X(a){const{steps:s,currentIndex:r}=U(a);return s.length===0?null:e.jsx("div",{"code-path":"src/components/approval/helpers.tsx:99:5",className:"flex items-center gap-1 overflow-x-auto",children:s.map((o,n)=>{const m=o.status==="approved"||o.status==="completed",p=n===r,d=o.status==="rejected";return e.jsxs("div",{"code-path":"src/components/approval/helpers.tsx:105:11",className:"flex items-center",children:[e.jsxs("div",{"code-path":"src/components/approval/helpers.tsx:106:13",className:b("flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs whitespace-nowrap",m&&"bg-emerald-500/10 text-emerald-400",p&&!d&&"bg-amber-500/10 text-amber-400 border border-amber-500/30",d&&"bg-red-500/10 text-red-400",!m&&!p&&!d&&"bg-[var(--dg-bg-tertiary)] text-[var(--dg-text-muted)]"),children:[m&&e.jsx(D,{"code-path":"src/components/approval/helpers.tsx:115:31",className:"h-3 w-3"}),d&&e.jsx(F,{"code-path":"src/components/approval/helpers.tsx:116:30",className:"h-3 w-3"}),p&&!d&&e.jsx($,{"code-path":"src/components/approval/helpers.tsx:117:44",className:"h-3 w-3 animate-spin"}),e.jsx("span",{"code-path":"src/components/approval/helpers.tsx:118:15",children:o.name||o.approver_name||`步骤 ${n+1}`})]}),n<s.length-1&&e.jsx("div",{"code-path":"src/components/approval/helpers.tsx:121:15",className:b("w-4 h-px",m?"bg-emerald-500/30":"bg-[var(--dg-border)]")})]},o.id||n)})})}const Je=[{key:"all",label:"全部",value:""},{key:"pending",label:"待审批",value:"pending"},{key:"approved",label:"已通过",value:"approved"},{key:"rejected",label:"已拒绝",value:"rejected"},{key:"processing",label:"进行中",value:"processing"},{key:"completed",label:"已完成",value:"completed"}];function qe(a){const s={pending:{label:"待审批",className:"border-amber-500/30 text-amber-400 bg-amber-500/10",dot:"bg-amber-400"},approved:{label:"已通过",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",dot:"bg-emerald-400"},rejected:{label:"已拒绝",className:"border-red-500/30 text-red-400 bg-red-500/10",dot:"bg-red-400"},processing:{label:"进行中",className:"border-[var(--dg-blue)]/30
Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{j as e}from"./index-Dmami9WE.js";import{A as r}from"./ApprovalCategoryPage-CIXhWQ3k.js";import"./card-CIfC-8Rh.js";import"./input-NsU9nXZF.js";import"./badge-3UzCvU7L.js";import"./label-Ap_-SPYI.js";import"./table-CG4mjNfb.js";import"./select-DUbxjT0z.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";import"./system-C3cYTuQH.js";import"./index-BuEnLCjT.js";import"./plus-O65gX7Qz.js";import"./search-Dd-PeBfg.js";import"./refresh-cw-CTBERyFc.js";import"./file-text-CebshSV-.js";import"./circle-x-BBQeW1R3.js";import"./play-0EwQQJX_.js";const t=[{key:"perm_type",label:"权限类型",type:"select",options:["堡垒机权限","生产VPN权限","日志查询权限","数据库查询权限","服务器SSH权限","K8s集群权限"],required:!0},{key:"account",label:"申请账号",type:"text",placeholder:"如 logan.li",required:!0},{key:"reason",label:"申请理由",type:"textarea",placeholder:"说明为什么需要该权限",required:!0},{key:"duration",label:"权限时长",type:"select",options:["临时(24小时)","短期(7天)","中期(30天)","长期(90天)","永久"],required:!0}];function f(){return e.jsx(r,{"code-path":"src/pages/ApprovalPermissionPage.tsx:17:5",category:"permission",title:"权限审批",description:"申请堡垒机、VPN、日志查询、数据库查询等运维权限",fields:t,templateCode:"permission_request"})}export{f as ApprovalPermissionPage};
|
||||
@@ -0,0 +1 @@
|
||||
import{j as e}from"./index-Dmami9WE.js";import{A as r}from"./ApprovalCategoryPage-CIXhWQ3k.js";import"./card-CIfC-8Rh.js";import"./input-NsU9nXZF.js";import"./badge-3UzCvU7L.js";import"./label-Ap_-SPYI.js";import"./table-CG4mjNfb.js";import"./select-DUbxjT0z.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";import"./system-C3cYTuQH.js";import"./index-BuEnLCjT.js";import"./plus-O65gX7Qz.js";import"./search-Dd-PeBfg.js";import"./refresh-cw-CTBERyFc.js";import"./file-text-CebshSV-.js";import"./circle-x-BBQeW1R3.js";import"./play-0EwQQJX_.js";const t=[{key:"provider",label:"云厂商",type:"select",options:["阿里云","腾讯云","华为云","AWS"],required:!0},{key:"region",label:"地域",type:"text",placeholder:"如 cn-hangzhou",required:!0},{key:"spec",label:"规格",type:"select",options:["2C4G","4C8G","8C16G","16C32G","32C64G"],required:!0},{key:"disk",label:"系统盘(GB)",type:"number",defaultValue:40,required:!0},{key:"count",label:"数量(台)",type:"number",defaultValue:1,required:!0},{key:"duration",label:"时长",type:"select",options:["1个月","3个月","6个月","1年"],required:!0},{key:"purpose",label:"用途说明",type:"textarea",required:!0}];function f(){return e.jsx(r,{"code-path":"src/pages/ApprovalResourcePage.tsx:16:5",category:"resource",title:"资源申请",description:"申请云服务器、存储、网络等基础设施资源",fields:t,templateCode:"server_apply"})}export{f as ApprovalResourcePage};
|
||||
@@ -0,0 +1 @@
|
||||
import{r as c,h as j,j as e,L as R,B as T,Q as V,V as z,X as Y,t as J,W as X,P as H}from"./index-Dmami9WE.js";import{C as K,a as Z}from"./card-CIfC-8Rh.js";import{t as C}from"./index-BuEnLCjT.js";import{P as F}from"./plus-O65gX7Qz.js";import{S as D}from"./star-DRCV7Fx2.js";import{C as ee}from"./chevron-up-Cq4GPopa.js";import{P as G}from"./play-0EwQQJX_.js";import{P as se}from"./pen-0lfnZsyH.js";import{T as q}from"./trash-2-DWVnIU6o.js";import{A as ae,a as te}from"./arrow-up-DMuDiHn6.js";const re={resource:"资源申请",app:"应用申请",permission:"权限审批"},O={submit:"提交阶段",audit:"审核阶段",execute:"执行阶段"},B={submit:"bg-blue-500/15 text-blue-400 border-blue-500/30",audit:"bg-purple-500/15 text-purple-400 border-purple-500/30",execute:"bg-green-500/15 text-green-400 border-green-500/30"},oe={submit:X,audit:J,execute:G},pe=[{value:"submit",label:"提交阶段",desc:"工单提交人"},{value:"audit",label:"审核阶段",desc:"审核人员审批"},{value:"execute",label:"执行阶段",desc:"执行人员操作"}],S={list:p=>j.get("/approval-workflows",p),get:p=>j.get(`/approval-workflows/${p}`),create:p=>j.post("/approval-workflows",p),update:(p,i)=>j.put(`/approval-workflows/${p}`,i),delete:p=>j.delete(`/approval-workflows/${p}`),setDefault:p=>j.put(`/approval-workflows/${p}/default`)},le=()=>j.get("/admin/users");function ce({users:p,selectedIds:i,label:v,onToggle:W,onToggleAll:y,onClear:f,getUserName:N}){const[m,_]=c.useState(!1),b=c.useRef(null),[k,l]=c.useState({top:0,left:0,width:0}),h=()=>{if(b.current){const d=b.current.getBoundingClientRect();l({top:d.bottom+4,left:d.left,width:d.width})}};return e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:121:5",className:"relative",children:[e.jsxs("button",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:122:7",ref:b,type:"button",onClick:()=>{m||h(),_(!m)},className:`w-full flex items-center justify-between px-3 py-2 rounded-lg text-sm transition-colors ${i.length===0?"bg-[var(--dg-bg-tertiary)] border border-red-500/40 text-[var(--dg-text-muted)]":"bg-[var(--dg-bg-tertiary)] border border-[var(--dg-border)] text-[var(--dg-text-primary)]"}`,children:[e.jsx("span",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:132:9",className:"truncate",children:i.length===0?`${v} * 请选择`:`${v} (${i.length}人)`}),e.jsx(z,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:135:9",className:`w-4 h-4 text-[var(--dg-text-muted)] transition-transform ${m?"rotate-180":""}`})]}),i.length>1&&e.jsx("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:139:9",className:"flex flex-wrap gap-1 mt-1.5",children:i.map(d=>e.jsxs("span",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:141:13",className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] bg-blue-500/15 text-blue-400",children:[N(d),e.jsx("button",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:143:15",onClick:()=>W(d),className:"hover:text-red-400",children:e.jsx(Y,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:143:84",className:"w-3 h-3"})})]},d))}),m&&e.jsxs(e.Fragment,{children:[e.jsx("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:151:11",className:"fixed inset-0 z-40",onClick:()=>_(!1)}),e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:152:11",className:"fixed z-50 bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded-lg shadow-xl max-h-52 overflow-y-auto",style:{top:k.top,left:k.left,width:k.width},children:[e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:154:13",className:"flex items-center justify-between px-3 py-2 border-b border-[var(--dg-border)]",children:[e.jsx("button",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:155:15",onClick:y,className:"text-[11px] text-blue-400 hover:text-blue-300",children:i.length===p.length&&p.length>0?"取消全选":"全选"}),i.length>0&&e.jsx("button",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:159:17",onClick:f,className:"text-[11px] text-red-400 hover:text-red-300",children:"清空"})]}),p.map(d=>{const w=i.includes(d.id);return e.jsxs("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:165:17",onClick:()=>W(d.id),className:"flex items-center gap-2.5 px-3 py-2 cursor-pointer hover:bg-[var(--dg-bg-hover)] transition-colors",children:[e.jsx("div",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:167:19",className:`w-4 h-4 rounded border flex items-center justify-center flex-shrink-0 ${w?"bg-blue-500 border-blue-500":"border-[var(--dg-border)]"}`,children:w&&e.jsx(H,{"code-path":"src/pages/ApprovalWorkflowPage.tsx:170:33",className:"w-3 h-3 text-white"})}),e.jsx("span",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:172:19",className:`text-sm flex-1 ${w?"text-[var(--dg-text-primary)]":"text-[var(--dg-text-secondary)]"}`,children:d.display_name||d.username}),e.jsx("span",{"code-path":"src/pages/ApprovalWorkflowPage.tsx:175:19",className:"text-[10px] text-[var(--dg-text-muted)] px-1.5 py-0.5 rounded bg-[var(--dg-bg-tertiary)]",children:d.role})]},d.id)})]})]})]})}fuLine truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{b as R,L as W,m as T,i as C,c as F,A as ie,d as B,e as G,h as oe,j as q,k as se,l as le,u as ue,n as K,G as ce,o as J,p as Q,D as fe,g as pe,X as he,Y as de,f as me}from"./generateCategoricalChart-6v9BPbG2.js";import{_ as p,ab as ee,r as ve}from"./index-DfyorCky.js";var ye=["layout","type","stroke","connectNulls","isRange","ref"],be=["key"],te;function M(e){"@babel/helpers - typeof";return M=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},M(e)}function ae(e,t){if(e==null)return{};var r=Ae(e,t),a,n;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)a=i[n],!(t.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}function Ae(e,t){if(e==null)return{};var r={};for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){if(t.indexOf(a)>=0)continue;r[a]=e[a]}return r}function D(){return D=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},D.apply(this,arguments)}function U(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,a)}return r}function S(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?U(Object(r),!0).forEach(function(a){E(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):U(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function ge(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Z(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,ne(a.key),a)}}function xe(e,t,r){return t&&Z(e.prototype,t),r&&Z(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Pe(e,t,r){return t=$(t),Oe(e,re()?Reflect.construct(t,r||[],$(e).constructor):t.apply(e,r))}function Oe(e,t){if(t&&(M(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ee(e)}function Ee(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function re(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(re=function(){return!!e})()}function $(e){return $=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},$(e)}function we(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&X(e,t)}function X(e,t){return X=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,n){return a.__proto__=n,a},X(e,t)}function E(e,t,r){return t=ne(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ne(e){var t=_e(e,"string");return M(t)=="symbol"?t:t+""}function _e(e,t){if(M(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t);if(M(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var L=(function(e){function t(){var r;ge(this,t);for(var a=arguments.length,n=new Array(a),i=0;i<a;i++)n[i]=arguments[i];return r=Pe(this,t,[].concat(n)),E(r,"state",{isAnimationFinished:!0}),E(r,"id",ue("recharts-area-")),E(r,"handleAnimationEnd",function(){var o=r.props.onAnimationEnd;r.setState({isAnimationFinished:!0}),K(o)&&o()}),E(r,"handleAnimationStart",function(){var o=r.props.onAnimationStart;r.setState({isAnimationFinished:!1}),K(o)&&o()}),r}return we(t,e),xe(t,[{key:"renderDots",value:function(a,n,i){var o=this.props.isAnimationActive,s=this.state.isAnimationFinished;if(o&&!s)return null;var u=this.props,l=u.dot,f=u.points,c=u.dataKey,h=R(this.props,!1),A=R(l,!0),g=f.map(function(v,O){var y=S(S(S({key:"dot-".concat(O),r:3},h),A),{},{index:O,cx:v.x,cy:v.y,dataKey:c,value:v.value,payload:v.payload,points:f});return t.renderDotItem(l,y)}),x={clipPath:a?"url(#clipPath-".concat(n?"":"dots-").concat(i,")"):null};return p.createElement(W,D({className:"recharts-area-dots"},x),g)}},{key:"renderHorizontalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].x,l=o[o.length-1].x,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.y||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.y||0})),c)),C(Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{b as R,L as W,m as T,i as C,c as F,A as ie,d as B,e as G,h as oe,j as q,k as se,l as le,u as ue,n as K,G as ce,o as J,p as Q,D as fe,g as pe,X as he,Y as de,f as me}from"./generateCategoricalChart-ZqCvxO-S.js";import{a3 as p,a7 as ee,r as ve}from"./index-Dmami9WE.js";var ye=["layout","type","stroke","connectNulls","isRange","ref"],be=["key"],te;function M(e){"@babel/helpers - typeof";return M=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},M(e)}function ae(e,t){if(e==null)return{};var r=Ae(e,t),a,n;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)a=i[n],!(t.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}function Ae(e,t){if(e==null)return{};var r={};for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){if(t.indexOf(a)>=0)continue;r[a]=e[a]}return r}function D(){return D=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},D.apply(this,arguments)}function U(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,a)}return r}function S(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?U(Object(r),!0).forEach(function(a){E(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):U(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function ge(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Z(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,ne(a.key),a)}}function xe(e,t,r){return t&&Z(e.prototype,t),r&&Z(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Pe(e,t,r){return t=$(t),Oe(e,re()?Reflect.construct(t,r||[],$(e).constructor):t.apply(e,r))}function Oe(e,t){if(t&&(M(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ee(e)}function Ee(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function re(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(re=function(){return!!e})()}function $(e){return $=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},$(e)}function we(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&X(e,t)}function X(e,t){return X=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,n){return a.__proto__=n,a},X(e,t)}function E(e,t,r){return t=ne(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ne(e){var t=_e(e,"string");return M(t)=="symbol"?t:t+""}function _e(e,t){if(M(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t);if(M(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var L=(function(e){function t(){var r;ge(this,t);for(var a=arguments.length,n=new Array(a),i=0;i<a;i++)n[i]=arguments[i];return r=Pe(this,t,[].concat(n)),E(r,"state",{isAnimationFinished:!0}),E(r,"id",ue("recharts-area-")),E(r,"handleAnimationEnd",function(){var o=r.props.onAnimationEnd;r.setState({isAnimationFinished:!0}),K(o)&&o()}),E(r,"handleAnimationStart",function(){var o=r.props.onAnimationStart;r.setState({isAnimationFinished:!1}),K(o)&&o()}),r}return we(t,e),xe(t,[{key:"renderDots",value:function(a,n,i){var o=this.props.isAnimationActive,s=this.state.isAnimationFinished;if(o&&!s)return null;var u=this.props,l=u.dot,f=u.points,c=u.dataKey,h=R(this.props,!1),A=R(l,!0),g=f.map(function(v,O){var y=S(S(S({key:"dot-".concat(O),r:3},h),A),{},{index:O,cx:v.x,cy:v.y,dataKey:c,value:v.value,payload:v.payload,points:f});return t.renderDotItem(l,y)}),x={clipPath:a?"url(#clipPath-".concat(n?"":"dots-").concat(i,")"):null};return p.createElement(W,D({className:"recharts-area-dots"},x),g)}},{key:"renderHorizontalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].x,l=o[o.length-1].x,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.y||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.y||0})),c)),CLine truncated
|
||||
@@ -1,3 +0,0 @@
|
||||
import{g as Le,r as a,j as e,D as ie,b as le,c as oe,d as ne,e as de,L as pe,W as we,aq as Q,a8 as Oe,q as Se,x as Ce,a as xe,A as he,S as I,X as _e,I as E,B as y,U as me,a5 as ue,aQ as ke,O as De,z as Me}from"./index-DfyorCky.js";import{C as P,a as K}from"./card-C55cvSHg.js";import{B as w}from"./badge-xNW8x0G1.js";import{T as H,a as W,b as M,c as i,d as U,e as l}from"./table-5sHV4Akp.js";import{t as F,s as Re,a as X,l as ze}from"./system-BgtMMm0X.js";import{x as ge,a as be}from"./xterm-DSqgeKvr.js";import{R as q}from"./refresh-cw-DUB_tAG-.js";import{P as Be}from"./play-cdPayOtJ.js";import{D as Te}from"./download-DoZfYs2h.js";const Ie=[["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],$e=Le("octagon-x",Ie);function Ee({open:s,onOpenChange:o,sessionId:d}){const n=a.useRef(null),p=a.useRef(null),T=a.useRef(null),[h,L]=a.useState(!1),[b,O]=a.useState(""),[j,v]=a.useState(0);return a.useEffect(()=>{if(!s||!d)return;const r=new ge.Terminal({cursorBlink:!1,fontSize:13,fontFamily:'Menlo, Monaco, "Courier New", monospace',disableStdin:!0,cols:80,rows:24,theme:{background:"#0a0e14",foreground:"#d6d6d6",cursor:"#0a0e14",selectionBackground:"rgba(255,255,255,0.2)"}}),m=new be.FitAddon;r.loadAddon(m),p.current=r;let f=!1;return L(!0),O(""),v(0),F.getRecord(d).then(u=>{if(f)return;const C=typeof u=="string"?u:u?.data||u?.record_data||"";if(!C||C.trim()===""){O("No recording data available for this session"),L(!1);return}if(n.current){r.open(n.current);try{m.fit()}catch{}}const R=C.split(`
|
||||
`).filter(x=>x.trim()),S=[];for(const x of R)try{const g=JSON.parse(x);Array.isArray(g)&&g.length>=3&&S.push({time:g[0],eventType:g[1],data:g[2]})}catch{}if(S.length===0){r.write(C),v(100),L(!1);return}L(!1);const $=S[S.length-1].time;let N=0,z=0;const _=()=>{if(f||N>=S.length){v(100);return}const x=S[N],g=(x.time-z)*1e3;z=x.time,N++;const B=Math.min(g,2e3);T.current=setTimeout(()=>{f||(r.write(x.data),v(Math.round(x.time/$*100)),_())},B)};_()}).catch(u=>{f||(console.error("[Replay] Load failed:",u),O("Failed to load recording data"),L(!1))}),()=>{f=!0,T.current&&clearTimeout(T.current);try{r.dispose()}catch{}p.current=null}},[s,d]),e.jsx(ie,{"code-path":"src/components/system/ReplayDialog.tsx:153:5",open:s,onOpenChange:o,children:e.jsxs(le,{"code-path":"src/components/system/ReplayDialog.tsx:154:7",showOverlay:!1,className:"bg-slate-900 border-slate-800 p-0 gap-0",style:{maxWidth:"900px",width:"90vw"},children:[e.jsxs(oe,{"code-path":"src/components/system/ReplayDialog.tsx:155:9",className:"px-4 py-3 border-b border-slate-800",children:[e.jsxs(ne,{"code-path":"src/components/system/ReplayDialog.tsx:156:11",className:"text-slate-100 text-base flex items-center gap-2",children:["Terminal Replay #",d??"",j>0&&j<100&&e.jsxs("span",{"code-path":"src/components/system/ReplayDialog.tsx:159:15",className:"text-xs text-slate-500 font-normal ml-2",children:[j,"%"]})]}),e.jsx(de,{"code-path":"src/components/system/ReplayDialog.tsx:162:11",className:"text-slate-500 sr-only",children:"Replay recorded terminal output"})]}),e.jsxs("div",{"code-path":"src/components/system/ReplayDialog.tsx:164:9",className:"relative bg-[#0a0e14]",style:{height:"460px"},children:[h&&e.jsx("div",{"code-path":"src/components/system/ReplayDialog.tsx:166:13",className:"absolute inset-0 z-10 flex items-center justify-center bg-black/40",children:e.jsx(pe,{"code-path":"src/components/system/ReplayDialog.tsx:167:15",className:"h-6 w-6 animate-spin text-blue-400"})}),b&&e.jsx("div",{"code-path":"src/components/system/ReplayDialog.tsx:171:13",className:"absolute inset-0 z-10 flex items-center justify-center bg-black/40",children:e.jsx("p",{"code-path":"src/components/system/ReplayDialog.tsx:172:15",className:"text-red-400 text-sm",children:b})}),j>0&&j<100&&e.jsx("div",{"code-path":"src/components/system/ReplayDialog.tsx:176:13",className:"absolute bottom-0 left-0 right-0 h-0.5 bg-slate-800 z-10",children:e.jsx("div",{"code-path":"src/components/system/ReplayDialog.tsx:177:15",className:"h-full bg-blue-500 transition-all duration-300",style:{width:`${j}%`}})}),e.jsx("div",{"code-path":"src/components/system/ReplayDialog.tsx:183:11",ref:n,className:"absolute inset-0 p-1"})]})]})})}function Fe({open:s,onOpenChange:o,sessionId:d,sessionInfo:n}){const p=a.useRef(null),T=a.useRef(null),h=a.useRef(null),[L,b]=a.useState(!1),[O,j]=a.useState(""),[v,r]=a.useState(n||null);a.useEffect(()=>{if(!s||!d)return;const f=p.current;if(!f)return;const u=new ge.Terminal({cursorBlink:!1,fontSize:13,fontFamily:'Menlo, Monaco, "Courier New", monospace',disableStdin:!0,theme:{background:"#0a0e14",foreground:"#d6d6d6",cursor:"#d6d6d6",selectionBackground:"#264f78",black:"#1a1a2e",red:"#ff6b6b",green:"#69db7c",yellow:"#ffd43b",blue:"#4dabf7",magenta:"#da77f2",cyan:"#63e6be",white:"#d6d6d6",brightBlack:"#4a4a4a",brightRed:"#ff8787",brightGreen:"#8ce99a",brightYellow:"#ffe066",brightBlue:"#74c0fc",brightMagenta:"#e599f7",brightCyan:"#7ae5d5",brightWhite:"#f8f9fa"}}),C=new be.FitAddon;u.loadAddon(C),u.open(f),C.fit(),T.current=u;let R=we.getState().token;if(!R)try{R=JSON.parse(localStorage.getItem("user-storage")||"")?.state?.token||""}catch{}const $=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/audit/${d}?token=${encodeURIComponent(R||"")}`;console.debug("[LiveMonitor] Connecting to:",$.replace(/token=[^&]+/,"token=***"));const N=new WebSocket($);h.current=N;let z=!1;N.onopen=()=>{console.debug("[LiveMonitor] WS connected for session:",d),z=!0,b(!0),j(""),u.writeln("\x1B[36m[审计监控] 已连接到会话...\x1B[0m")},N.onmessage=x=>{try{const g=JSON.parse(x.data);switch(g.type){case"session_info":r(g.payload),u.writeln(`\x1B[36m用户: ${g.payload.username} 服务器: ${g.payload.server_name}\x1B[0m`);break;case"history":g.data&&u.write(g.data);break;case"output":g.data&&u.write(g.data);break}}catch{}},N.onerror=x=>{console.debug("[LiveMonitor] WS error:",x),j("WebSocket 连接失败")},N.onclose=x=>{console.debug("[LiveMonitor] WS closed code:",x.code,"reason:",x.reason),z||j(`连接失败 (code=${x.code}): ${x.reason||"认证失败或网络问题"}`),b(!1),u.writeln(`\r
|
||||
\x1B[33m[审计监控] 连接已断开\x1B[0m`)};const _=setTimeout(()=>{z||(j("连接超时 — 请确认已登录且有活跃会话"),N.close())},5e3);return()=>{clearTimeout(_),N.close(),u.dispose(),T.current=null,h.current=null,b(!1)}},[s,d]);const m=f=>f?new Date(f).toLocaleString():"--";return e.jsx(ie,{"code-path":"src/components/system/LiveMonitorDialog.tsx:169:5",open:s,onOpenChange:o,children:e.jsxs(le,{"code-path":"src/components/system/LiveMonitorDialog.tsx:170:7",showOverlay:!1,className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] max-w-[95vw] max-h-[90vh] w-[1200px]",children:[e.jsxs(oe,{"code-path":"src/components/system/LiveMonitorDialog.tsx:171:9",children:[e.jsxs(ne,{"code-path":"src/components/system/LiveMonitorDialog.tsx:172:11",className:"text-[var(--dg-text-primary)] flex items-center gap-2",children:[e.jsx(Q,{"code-path":"src/components/system/LiveMonitorDialog.tsx:173:13",className:"h-5 w-5 text-emerald-400"}),"终端实时监控",L&&e.jsx(w,{"code-path":"src/components/system/LiveMonitorDialog.tsx:176:15",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10 ml-2 text-xs",children:"● 在线"}),!L&&!O&&e.jsxs(w,{"code-path":"src/components/system/LiveMonitorDialog.tsx:181:15",variant:"outline",className:"border-yellow-500/30 text-yellow-400 bg-yellow-500/10 ml-2 text-xs",children:[e.jsx(pe,{"code-path":"src/components/system/LiveMonitorDialog.tsx:182:17",className:"h-3 w-3 animate-spin mr-1"}),"连接中"]}),O&&e.jsx(w,{"code-path":"src/components/system/LiveMonitorDialog.tsx:187:15",variant:"outline",className:"border-red-500/30 text-red-400 bg-red-500/10 ml-2 text-xs",children:"连接失败"})]}),e.jsx(de,{"code-path":"src/components/system/LiveMonitorDialog.tsx:192:11",className:"text-[var(--dg-text-secondary)]",children:v&&e.jsxs("div",{"code-path":"src/components/system/LiveMonitorDialog.tsx:194:15",className:"flex items-center gap-4 text-xs mt-1 flex-wrap",children:[e.jsxs("span",{"code-path":"src/components/system/LiveMonitorDialog.tsx:195:17",className:"flex items-center gap-1",children:[e.jsx(Oe,{"code-path":"src/components/system/LiveMonitorDialog.tsx:196:19",className:"h-3 w-3"}),v.username]}),e.jsxs("span",{"code-path":"src/components/system/LiveMonitorDialog.tsx:199:17",className:"flex items-center gap-1",children:[e.jsx(Se,{"code-path":"src/components/system/LiveMonitorDialog.tsx:200:19",className:"h-3 w-3"}),v.server_name," (",v.server_ip,")"]}),e.jsxs("span",{"code-path":"src/components/system/LiveMonitorDialog.tsx:203:17",className:"flex items-center gap-1",children:[e.jsx(Ce,{"code-path":"src/components/system/LiveMonitorDialog.tsx:204:19",className:"h-3 w-3"}),m(v.start_time)]})]})})]}),e.jsx("div",{"code-path":"src/components/system/LiveMonitorDialog.tsx:212:9",ref:p,className:"w-full rounded-md overflow-hidden border border-[var(--dg-border)]",style:{height:"55vh"}})]})})}function je(s){if(!s||s<0)return"--";if(s<60)return`${s}秒`;const o=Math.floor(s/60),d=s%60;if(o<60)return`${o}分${d>0?`${d}秒`:""}`;const n=Math.floor(o/60),p=o%60;return`${n}时${p>0?`${p}分`:""}`}function Pe(s){return s?s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/1024/1024).toFixed(2)} MB`:"0 B"}function fe(s){return s==="active"?e.jsxs(w,{"code-path":"src/pages/TerminalAuditTab.tsx:84:7",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:[e.jsx("span",{"code-path":"src/pages/TerminalAuditTab.tsx:85:9",className:"w-1.5 h-1.5 rounded-full bg-emerald-400 mr-1.5 inline-block animate-pulse"}),"活动中"]}):s==="failed"?e.jsx(w,{"code-path":"src/pages/TerminalAuditTab.tsx:92:7",variant:"outline",className:"border-red-500/30 text-red-400 bg-red-500/10",children:"失败"}):e.jsx(w,{"code-path":"src/pages/TerminalAuditTab.tsx:98:5",variant:"outline",className:"border-slate-500/30 text-slate-400 bg-slate-500/10",children:"已关闭"})}function Ke(s){const[o,d]=a.useState(0);return a.useEffect(()=>{if(!s)return;const n=new Date(s).getTime(),p=()=>d(Math.floor((Date.now()-n)/1e3));p();const T=setInterval(p,1e3);return()=>clearInterval(T)},[s]),o}const He=[{id:"active",name:"在线会话",icon:he},{id:"history",name:"历史会话",icon:Q},{id:"commands",name:"会话命令",icon:I}];function ce(){const s=xe(),[o,d]=a.useState("active"),[n,p]=a.useState([]),[T,h]=a.useState(!0),[L,b]=a.useState(""),[O,j]=a.useState([]),[v,r]=a.useState(!0),[m,f]=a.useState(""),[u,C]=a.useState(null),[R,S]=a.useState(!1),[$,N]=a.useState([]),[z,_]=a.useState(!0),[x,g]=a.useState(""),[B,V]=a.useState(""),[Y,c]=a.useState(!1),[k,Z]=a.useState(null),J=a.useCallback(async()=>{h(!0);try{const t=await F.list({page:1,page_size:100,status:"active"});p(t?.list??[])}catch{p([])}finally{h(!1)}},[]);a.useEffect(()=>{J()},[J]);const te=n.filter(t=>{const A=L.toLowerCase();return!A||(t.username||"").toLowerCase().includes(A)||(t.server_name||"").toLowerCase().includes(A)||(t.server_ip||"").toLowerCase().includes(A)}),Ae=async
Line truncated
|
||||
@@ -0,0 +1,3 @@
|
||||
import{i as ce,r as a,j as e,D as pe,a as xe,b as he,c as me,d as ue,L as ge,$ as _e,aH as Y,U as De,S as Re,C as Me,f as be,A as Te,a0 as ze,B as v,O as je,X as fe,aP as Ee,G as Ie,x as Be}from"./index-Dmami9WE.js";import{C as K,a as U}from"./card-CIfC-8Rh.js";import{I as F}from"./input-NsU9nXZF.js";import{B as _}from"./badge-3UzCvU7L.js";import{T as W,a as q,b as E,c as l,d as G,e as o}from"./table-CG4mjNfb.js";import{t as H,s as $e,a as X,l as Fe}from"./system-C3cYTuQH.js";import{x as Ae,a as ve}from"./xterm-DSqgeKvr.js";import{S as B}from"./search-Dd-PeBfg.js";import{R as J}from"./refresh-cw-CTBERyFc.js";import{P as Pe}from"./play-0EwQQJX_.js";import{D as Ne}from"./download-Vuij9wGr.js";const He=[["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Ke=ce("octagon-x",He);const Ue=[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"M4.6 11a8 8 0 0 0 1.7 8.7 8 8 0 0 0 8.7 1.7",key:"10he05"}],["path",{d:"M7.4 7.4a8 8 0 0 1 10.3 1 8 8 0 0 1 .9 10.2",key:"15f7sh"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M12 12v-2",key:"fwoke6"}]],We=ce("timer-off",Ue);const qe=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],Ge=ce("timer",qe);function Je({open:s,onOpenChange:i,sessionId:d}){const n=a.useRef(null),p=a.useRef(null),g=a.useRef(null),[m,w]=a.useState(!1),[b,N]=a.useState(""),[T,j]=a.useState(0);return a.useEffect(()=>{if(!s||!d)return;const r=new Ae.Terminal({cursorBlink:!1,fontSize:13,fontFamily:'Menlo, Monaco, "Courier New", monospace',disableStdin:!0,cols:80,rows:24,theme:{background:"#0a0e14",foreground:"#d6d6d6",cursor:"#0a0e14",selectionBackground:"rgba(255,255,255,0.2)"}}),u=new ve.FitAddon;r.loadAddon(u),p.current=r;let O=!1;return w(!0),N(""),j(0),H.getRecord(d).then(x=>{if(O)return;const y=typeof x=="string"?x:x?.data||x?.record_data||"";if(!y||y.trim()===""){N("No recording data available for this session"),w(!1);return}if(n.current){r.open(n.current);try{u.fit()}catch{}}const D=y.split(`
|
||||
`).filter(L=>L.trim()),S=[];for(const L of D)try{const h=JSON.parse(L);Array.isArray(h)&&h.length>=3&&S.push({time:h[0],eventType:h[1],data:h[2]})}catch{}if(S.length===0){r.write(y),j(100),w(!1);return}w(!1);const P=S[S.length-1].time;let R=0,k=0;const C=()=>{if(O||R>=S.length){j(100);return}const L=S[R],h=(L.time-k)*1e3;k=L.time,R++;const f=Math.min(h,2e3);g.current=setTimeout(()=>{O||(r.write(L.data),j(Math.round(L.time/P*100)),C())},f)};C()}).catch(x=>{O||(console.error("[Replay] Load failed:",x),N("Failed to load recording data"),w(!1))}),()=>{O=!0,g.current&&clearTimeout(g.current);try{r.dispose()}catch{}p.current=null}},[s,d]),e.jsx(pe,{"code-path":"src/components/system/ReplayDialog.tsx:153:5",open:s,onOpenChange:i,children:e.jsxs(xe,{"code-path":"src/components/system/ReplayDialog.tsx:154:7",showOverlay:!1,className:"bg-slate-900 border-slate-800 p-0 gap-0",style:{maxWidth:"900px",width:"90vw"},children:[e.jsxs(he,{"code-path":"src/components/system/ReplayDialog.tsx:155:9",className:"px-4 py-3 border-b border-slate-800",children:[e.jsxs(me,{"code-path":"src/components/system/ReplayDialog.tsx:156:11",className:"text-slate-100 text-base flex items-center gap-2",children:["Terminal Replay #",d??"",T>0&&T<100&&e.jsxs("span",{"code-path":"src/components/system/ReplayDialog.tsx:159:15",className:"text-xs text-slate-500 font-normal ml-2",children:[T,"%"]})]}),e.jsx(ue,{"code-path":"src/components/system/ReplayDialog.tsx:162:11",className:"text-slate-500 sr-only",children:"Replay recorded terminal output"})]}),e.jsxs("div",{"code-path":"src/components/system/ReplayDialog.tsx:164:9",className:"relative bg-[#0a0e14]",style:{height:"460px"},children:[m&&e.jsx("div",{"code-path":"src/components/system/ReplayDialog.tsx:166:13",className:"absolute inset-0 z-10 flex items-center justify-center bg-black/40",children:e.jsx(ge,{"code-path":"src/components/system/ReplayDialog.tsx:167:15",className:"h-6 w-6 animate-spin text-blue-400"})}),b&&e.jsx("div",{"code-path":"src/components/system/ReplayDialog.tsx:171:13",className:"absolute inset-0 z-10 flex items-center justify-center bg-black/40",children:e.jsx("p",{"code-path":"src/components/system/ReplayDialog.tsx:172:15",className:"text-red-400 text-sm",children:b})}),T>0&&T<100&&e.jsx("div",{"code-path":"src/components/system/ReplayDialog.tsx:176:13",className:"absolute bottom-0 left-0 right-0 h-0.5 bg-slate-800 z-10",children:e.jsx("div",{"code-path":"src/components/system/ReplayDialog.tsx:177:15",className:"h-full bg-blue-500 transition-all duration-300",style:{width:`${T}%`}})}),e.jsx("div",{"code-path":"src/components/system/ReplayDialog.tsx:183:11",ref:n,className:"absolute inset-0 p-1"})]})]})})}function Xe({open:s,onOpenChange:i,sessionId:d,sessionInfo:n}){const p=a.useRef(null),g=a.useRef(null),m=a.useRef(null),w=a.useRef(null),[b,N]=a.useState(!1),[T,j]=a.useState(""),[r,u]=a.useState(n||null);a.useEffect(()=>{s||(N(!1),j(""))},[s]),a.useEffect(()=>{if(!s||!d)return;N(!1),j("");const x=new Ae.Terminal({cursorBlink:!1,fontSize:13,fontFamily:'Menlo, Monaco, "Courier New", monospace',disableStdin:!0,theme:{background:"#0a0e14",foreground:"#d6d6d6",cursor:"#d6d6d6",selectionBackground:"#264f78",black:"#1a1a2e",red:"#ff6b6b",green:"#69db7c",yellow:"#ffd43b",blue:"#4dabf7",magenta:"#da77f2",cyan:"#63e6be",white:"#d6d6d6",brightBlack:"#4a4a4a",brightRed:"#ff8787",brightGreen:"#8ce99a",brightYellow:"#ffe066",brightBlue:"#74c0fc",brightMagenta:"#e599f7",brightCyan:"#7ae5d5",brightWhite:"#f8f9fa"}}),y=new ve.FitAddon;x.loadAddon(y),g.current=x,m.current=y;const D=()=>{const h=p.current;if(!h){requestAnimationFrame(D);return}x.open(h);try{y.fit()}catch{}},S=_e.getState().token||localStorage.getItem("token")||(()=>{try{return JSON.parse(localStorage.getItem("user-storage")||"{}")?.state?.token||""}catch{return""}})(),R=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/audit/${d}?token=${encodeURIComponent(S)}`;console.log("[LiveMonitor] Connecting to:",R.replace(/token=[^&]+/,"token=***"));const k=new WebSocket(R);w.current=k;let C=!1;k.onopen=()=>{console.log("[LiveMonitor] WS connected for session:",d),C=!0,N(!0),j(""),D(),x.writeln("\x1B[36m[审计监控] 已连接到会话...\x1B[0m")},k.onmessage=h=>{try{const f=JSON.parse(h.data);switch(f.type){case"session_info":u(f.payload),x.writeln(`\x1B[36m用户: ${f.payload.username} 服务器: ${f.payload.server_name}\x1B[0m`);break;case"history":f.data&&x.write(f.data);break;case"output":f.data&&x.write(f.data);break}}catch{}},k.onerror=h=>{console.log("[LiveMonitor] WS error:",h),j("WebSocket 连接失败")},k.onclose=h=>{console.log("[LiveMonitor] WS closed code:",h.code,"reason:",h.reason),C||j(`连接失败 (code=${h.code}): ${h.reason||"认证失败或网络问题"}`),N(!1),x.writeln(`\r
|
||||
\x1B[33m[审计监控] 连接已断开\x1B[0m`)};const L=setTimeout(()=>{C||(j("连接超时 — 请确认已登录且有活跃会话"),k.close())},5e3);return()=>{clearTimeout(L),k.close(),x.dispose(),g.current=null,m.current=null,w.current=null,N(!1)}},[s,d]),a.useEffect(()=>{if(!s)return;const x=p.current;if(!x)return;let y;const D=new ResizeObserver(()=>{clearTimeout(y),y=setTimeout(()=>{try{m.current?.fit()}catch{}},60)});return D.observe(x),()=>{clearTimeout(y),D.disconnect()}},[s,d]);const O=x=>x?new Date(x).toLocaleString():"--";return e.jsx(pe,{"code-path":"src/components/system/LiveMonitorDialog.tsx:223:5",open:s,onOpenChange:i,children:e.jsxs(xe,{"code-path":"src/components/system/LiveMonitorDialog.tsx:224:7",showOverlay:!1,className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] max-w-[95vw] max-h-[90vh] w-[1200px]",children:[e.jsxs(he,{"code-path":"src/components/system/LiveMonitorDialog.tsx:225:9",children:[e.jsxs(me,{"code-path":"src/components/system/LiveMonitorDialog.tsx:226:11",className:"text-[var(--dg-text-primary)] flex items-center gap-2",children:[e.jsx(Y,{"code-path":"src/components/system/LiveMonitorDialog.tsx:227:13",className:"h-5 w-5 text-emerald-400"}),"终端实时监控",b&&e.jsx(_,{"code-path":"src/components/system/LiveMonitorDialog.tsx:230:15",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10 ml-2 text-xs",children:"● 在线"}),!b&&!T&&e.jsxs(_,{"code-path":"src/components/system/LiveMonitorDialog.tsx:235:15",variant:"outline",className:"border-yellow-500/30 text-yellow-400 bg-yellow-500/10 ml-2 text-xs",children:[e.jsx(ge,{"code-path":"src/components/system/LiveMonitorDialog.tsx:236:17",className:"h-3 w-3 animate-spin mr-1"}),"连接中"]}),T&&e.jsx(_,{"code-path":"src/components/system/LiveMonitorDialog.tsx:241:15",variant:"outline",className:"border-red-500/30 text-red-400 bg-red-500/10 ml-2 text-xs",children:"连接失败"})]}),e.jsx(ue,{"code-path":"src/components/system/LiveMonitorDialog.tsx:246:11",className:"text-[var(--dg-text-secondary)]",children:r&&e.jsxs("div",{"code-path":"src/components/system/LiveMonitorDialog.tsx:248:15",className:"flex items-center gap-4 text-xs mt-1 flex-wrap",children:[e.jsxs("span",{"code-path":"src/components/system/LiveMonitorDialog.tsx:249:17",className:"flex items-center gap-1",children:[e.jsx(De,{"code-path":"src/components/system/LiveMonitorDialog.tsx:250:19",className:"h-3 w-3"}),r.username]}),e.jsxs("span",{"code-path":"src/components/system/LiveMonitorDialog.tsx:253:17",className:"flex items-center gap-1",children:[e.jsx(Re,{"code-path":"src/components/system/LiveMonitorDialog.tsx:254:19",className:"h-3 w-3"}),r.server_name," (",r.server_ip,")"]}),e.jsxs("span",{"code-path":"src/components/system/LiveMonitorDialog.tsx:257:17",className:"flex items-center gap-1",children:[e.jsx(Me,{"code-path":"src/components/system/LiveMonitorDialog.tsx:258:19",className:"h-3 w-3"}),O(r.start_time)]})]})})]}),T&&e.jsx("p",{"code-path":"src/components/system/LiveMonitorDialog.tsx:267:11",className:"text-sm text-red-400 px-1",children:T}),e.jsx("div",{"code-path":"src/components/system/LiveMonitorDialog.tsx:270:9",ref:p,className:"w-full rounded-md overflow-hidden border border-[var(--dg-border)]",style:{height:"55vh"}})]})})}function ye(s){if(!s||s<0)return"--";if(s<60)return`${s}秒`;const i=Math.floor(s/60),d=s%60;if(i<60)return`${i}分${d>0?`${d}秒`:""}`;const n=Math.floor(i/60),p=i%60;return`${n}时${p>0?`${p}分`:""}`}function Ve(s){return s?s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/1024/1024).toFixed(2)} MB`:"0 B"}function Le(s){return s==="active"?e.jsxs(_,{"code-path":"src/pages/TerminalAuditTab.tsx:86:7",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:[e.jsx("span",{"code-path":"src/pages/TerminalAuditTab.tsx:87:9",className:"w-1.5 h-1.5 rounded-full bg-emerald-400 mr-1.5 inline-block animate-pulse"}),"活动中"]}):s==="failed"?e.jsx(_,{"code-path":"src/pages/TerminalAuditTab.tsx:94:7",variant:"outline",className:"border-red-500/30 text-red-400 bg-red-500/10",children:"失败"}):e.jsx(_,{"code-path":"src/pages/TerminalAuditTab.tsx:100:5",variant:"outline",className:"border-slate-500/30 text-slate-400 bg-slate-500/10",children:"已关闭"})}function Ye(s){const[i,d]=a.useState(0);return a.useEffect(()=>{if(!s)return;const n=new Date(s).getTime(),p=()=>d(Math.floor((Date.now()-n)/1e3));p();const g=setInterval(p,1e3);return()=>clearInterval(g)},[s]),i}const Qe=[{id:"active",name:"在线会话",icon:Te},{id:"history",name:"历史会话",icon:Y},{id:"commands",name:"会话命令",icon:B}];function de(){const s=be(),[i,d]=a.useState("active"),[n,p]=a.useState([]),[g,m]=a.useState(!0),[w,b]=a.useState(""),[N,T]=a.useState([]),[j,r]=a.useState(!0),[u,O]=a.useState(""),[x,y]=a.useState(null),[D,S]=a.useState(!1),[P,R]=a.useState([]),[k,C]=a.useState(!0),[L,h]=a.useState(""),[f,Q]=a.useState(""),[Z,c]=a.useState(!1),[M,ee]=a.useSta
Line truncated
|
||||
+1
-1
@@ -1 +1 @@
|
||||
import{g as a,B as i,X as s,Y as t,f as e}from"./generateCategoricalChart-6v9BPbG2.js";var x=a({chartName:"BarChart",GraphicalChild:i,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:s},{axisType:"yAxis",AxisComp:t}],formatAxisMap:e});export{x as B};
|
||||
import{g as a,B as i,X as s,Y as t,f as e}from"./generateCategoricalChart-ZqCvxO-S.js";var x=a({chartName:"BarChart",GraphicalChild:i,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:s},{axisType:"yAxis",AxisComp:t}],formatAxisMap:e});export{x as B};
|
||||
@@ -0,0 +1 @@
|
||||
import{k as E,m as D,r as c,j as e,n as k,o as j,J as H,B as P,p as N}from"./index-Dmami9WE.js";import{C as L,a as M}from"./card-CIfC-8Rh.js";import{B as z}from"./badge-3UzCvU7L.js";import{S as f,a as v,b as S,c as w,d as x}from"./select-DUbxjT0z.js";import{T as U,a as F,b as d,c as r,d as I,e as n}from"./table-CG4mjNfb.js";import{k as p}from"./kubernetes-D2-GnE0t.js";import{R as J}from"./refresh-cw-CTBERyFc.js";import{D as G}from"./download-Vuij9wGr.js";import{H as _}from"./hard-drive-DmC04Y5r.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";function ce(){const{clusterCode:$}=E(),h=D(),[l,u]=c.useState(!1),[b,g]=c.useState([]),[q,T]=c.useState([]),[A,R]=c.useState([]),[o,V]=c.useState("all"),[a,C]=c.useState($||"");c.useEffect(()=>{p.getClusters().then(s=>{const t=s?.list||[];if(T(t),!a&&t.length>0){const y=t[0].code||String(t[0].id);C(y),h(`/kubernetes/${y}/capacity`,{replace:!0})}}).catch(()=>{})},[]),c.useEffect(()=>{a&&p.getNamespaces(a).then(s=>{R(Array.isArray(s)?s:s?.list||s?.data||[])}).catch(()=>{})},[a]);const i=c.useCallback(async()=>{if(a){u(!0);try{const s=o==="all"?void 0:o,t=await p.getCapacity(a,s);g(Array.isArray(t)?t:t?.list||[])}catch{g([])}finally{u(!1)}}},[a,o]);c.useEffect(()=>{i()},[i]);const m=c.useMemo(()=>b.flatMap(s=>(s.containers||[]).map(t=>({namespace:s.namespace,deployment:s.name,replicas:s.replicas,container:t.name,cpu_req:t.cpu_request||"-",cpu_lim:t.cpu_limit||"-",mem_req:t.mem_request||"-",mem_lim:t.mem_limit||"-"}))),[b]),B=()=>p.exportAsCSV(`capacity-${a}.csv`,m);return e.jsxs("div",{"code-path":"src/components/kubernetes/CapacityPage.tsx:73:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/CapacityPage.tsx:74:7",className:"flex items-center gap-2 text-sm text-slate-500",children:[e.jsx(k,{"code-path":"src/components/kubernetes/CapacityPage.tsx:75:9",to:"/kubernetes",className:"hover:text-slate-300",children:"集群"}),a&&e.jsxs(e.Fragment,{children:[e.jsx(j,{"code-path":"src/components/kubernetes/CapacityPage.tsx:76:29",className:"h-3 w-3"}),e.jsx(k,{"code-path":"src/components/kubernetes/CapacityPage.tsx:76:65",to:`/kubernetes/${a}`,className:"hover:text-slate-300",children:a})]}),e.jsx(j,{"code-path":"src/components/kubernetes/CapacityPage.tsx:77:9",className:"h-3 w-3"}),e.jsx("span",{"code-path":"src/components/kubernetes/CapacityPage.tsx:77:45",className:"text-slate-300",children:"容量分析"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/CapacityPage.tsx:80:7",className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("h2",{"code-path":"src/components/kubernetes/CapacityPage.tsx:81:9",className:"text-lg font-semibold text-slate-100 flex items-center gap-2",children:[e.jsx(H,{"code-path":"src/components/kubernetes/CapacityPage.tsx:81:86",className:"h-5 w-5 text-purple-400"}),"资源容量分析"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/CapacityPage.tsx:82:9",className:"flex items-center gap-2",children:[e.jsxs(f,{"code-path":"src/components/kubernetes/CapacityPage.tsx:83:11",value:a,onValueChange:s=>{C(s),h(`/kubernetes/${s}/capacity`)},children:[e.jsx(v,{"code-path":"src/components/kubernetes/CapacityPage.tsx:84:13",className:"w-40 h-8 text-xs bg-slate-800 border-slate-700",children:e.jsx(S,{"code-path":"src/components/kubernetes/CapacityPage.tsx:84:87"})}),e.jsx(w,{"code-path":"src/components/kubernetes/CapacityPage.tsx:85:13",className:"bg-slate-800 border-slate-700",children:q.map(s=>e.jsx(x,{"code-path":"src/components/kubernetes/CapacityPage.tsx:86:42",value:s.code||String(s.id),className:"text-xs",children:s.name||s.code},s.id))})]}),e.jsxs(f,{"code-path":"src/components/kubernetes/CapacityPage.tsx:89:11",value:o,onValueChange:V,children:[e.jsx(v,{"code-path":"src/components/kubernetes/CapacityPage.tsx:90:13",className:"w-32 h-8 text-xs bg-slate-800 border-slate-700",children:e.jsx(S,{"code-path":"src/components/kubernetes/CapacityPage.tsx:90:87",placeholder:"所有命名空间"})}),e.jsxs(w,{"code-path":"src/components/kubernetes/CapacityPage.tsx:91:13",className:"bg-slate-800 border-slate-700",children:[e.jsx(x,{"code-path":"src/components/kubernetes/CapacityPage.tsx:92:15",value:"all",className:"text-xs",children:"所有命名空间"}),A.map(s=>e.jsx(x,{"code-path":"src/components/kubernetes/CapacityPage.tsx:93:36",value:s,className:"text-xs",children:s},s))]})]}),e.jsxs(P,{"code-path":"src/components/kubernetes/CapacityPage.tsx:96:11",variant:"outline",size:"sm",className:"h-8 border-slate-700 text-slate-300 text-xs",onClick:i,disabled:l,children:[e.jsx(J,{"code-path":"src/components/kubernetes/CapacityPage.tsx:97:13",className:`h-3 w-3 mr-1 ${l?"animate-spin":""}`}),"刷新"]}),e.jsxs(P,{"code-path":"src/components/kubernetes/CapacityPage.tsx:99:11",variant:"outline",size:"sm",className:"h-8 border-slate-700 text-slate-300 text-xs",onClick:B,children:[e.jsx(G,{"code-path":"src/components/kubernetes/CapacityPage.tsx:100:13",className:"h-3 w-3 mr-1"}),"CLine truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{i as E,k as D,r as c,j as e,m as k,n as j,K as H,B as P,o as N}from"./index-DfyorCky.js";import{C as L,a as M}from"./card-C55cvSHg.js";import{B as z}from"./badge-xNW8x0G1.js";import{S as f,a as v,b as S,c as w,d as x}from"./select-D5qUzdAs.js";import{T as U,a as F,b as d,c as r,d as I,e as n}from"./table-5sHV4Akp.js";import{k as p}from"./kubernetes-J8O09fK7.js";import{R as K}from"./refresh-cw-DUB_tAG-.js";import{D as G}from"./download-DoZfYs2h.js";import{H as _}from"./hard-drive-BbPmnARR.js";import"./index-CWVNW_qu.js";function ae(){const{clusterCode:$}=E(),h=D(),[l,u]=c.useState(!1),[b,g]=c.useState([]),[q,T]=c.useState([]),[A,R]=c.useState([]),[o,V]=c.useState("all"),[a,C]=c.useState($||"");c.useEffect(()=>{p.getClusters().then(s=>{const t=s?.list||[];if(T(t),!a&&t.length>0){const y=t[0].code||String(t[0].id);C(y),h(`/kubernetes/${y}/capacity`,{replace:!0})}}).catch(()=>{})},[]),c.useEffect(()=>{a&&p.getNamespaces(a).then(s=>{R(Array.isArray(s)?s:s?.list||s?.data||[])}).catch(()=>{})},[a]);const i=c.useCallback(async()=>{if(a){u(!0);try{const s=o==="all"?void 0:o,t=await p.getCapacity(a,s);g(Array.isArray(t)?t:t?.list||[])}catch{g([])}finally{u(!1)}}},[a,o]);c.useEffect(()=>{i()},[i]);const m=c.useMemo(()=>b.flatMap(s=>(s.containers||[]).map(t=>({namespace:s.namespace,deployment:s.name,replicas:s.replicas,container:t.name,cpu_req:t.cpu_request||"-",cpu_lim:t.cpu_limit||"-",mem_req:t.mem_request||"-",mem_lim:t.mem_limit||"-"}))),[b]),B=()=>p.exportAsCSV(`capacity-${a}.csv`,m);return e.jsxs("div",{"code-path":"src/components/kubernetes/CapacityPage.tsx:73:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/CapacityPage.tsx:74:7",className:"flex items-center gap-2 text-sm text-slate-500",children:[e.jsx(k,{"code-path":"src/components/kubernetes/CapacityPage.tsx:75:9",to:"/kubernetes",className:"hover:text-slate-300",children:"集群"}),a&&e.jsxs(e.Fragment,{children:[e.jsx(j,{"code-path":"src/components/kubernetes/CapacityPage.tsx:76:29",className:"h-3 w-3"}),e.jsx(k,{"code-path":"src/components/kubernetes/CapacityPage.tsx:76:65",to:`/kubernetes/${a}`,className:"hover:text-slate-300",children:a})]}),e.jsx(j,{"code-path":"src/components/kubernetes/CapacityPage.tsx:77:9",className:"h-3 w-3"}),e.jsx("span",{"code-path":"src/components/kubernetes/CapacityPage.tsx:77:45",className:"text-slate-300",children:"容量分析"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/CapacityPage.tsx:80:7",className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("h2",{"code-path":"src/components/kubernetes/CapacityPage.tsx:81:9",className:"text-lg font-semibold text-slate-100 flex items-center gap-2",children:[e.jsx(H,{"code-path":"src/components/kubernetes/CapacityPage.tsx:81:86",className:"h-5 w-5 text-purple-400"}),"资源容量分析"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/CapacityPage.tsx:82:9",className:"flex items-center gap-2",children:[e.jsxs(f,{"code-path":"src/components/kubernetes/CapacityPage.tsx:83:11",value:a,onValueChange:s=>{C(s),h(`/kubernetes/${s}/capacity`)},children:[e.jsx(v,{"code-path":"src/components/kubernetes/CapacityPage.tsx:84:13",className:"w-40 h-8 text-xs bg-slate-800 border-slate-700",children:e.jsx(S,{"code-path":"src/components/kubernetes/CapacityPage.tsx:84:87"})}),e.jsx(w,{"code-path":"src/components/kubernetes/CapacityPage.tsx:85:13",className:"bg-slate-800 border-slate-700",children:q.map(s=>e.jsx(x,{"code-path":"src/components/kubernetes/CapacityPage.tsx:86:42",value:s.code||String(s.id),className:"text-xs",children:s.name||s.code},s.id))})]}),e.jsxs(f,{"code-path":"src/components/kubernetes/CapacityPage.tsx:89:11",value:o,onValueChange:V,children:[e.jsx(v,{"code-path":"src/components/kubernetes/CapacityPage.tsx:90:13",className:"w-32 h-8 text-xs bg-slate-800 border-slate-700",children:e.jsx(S,{"code-path":"src/components/kubernetes/CapacityPage.tsx:90:87",placeholder:"所有命名空间"})}),e.jsxs(w,{"code-path":"src/components/kubernetes/CapacityPage.tsx:91:13",className:"bg-slate-800 border-slate-700",children:[e.jsx(x,{"code-path":"src/components/kubernetes/CapacityPage.tsx:92:15",value:"all",className:"text-xs",children:"所有命名空间"}),A.map(s=>e.jsx(x,{"code-path":"src/components/kubernetes/CapacityPage.tsx:93:36",value:s,className:"text-xs",children:s},s))]})]}),e.jsxs(P,{"code-path":"src/components/kubernetes/CapacityPage.tsx:96:11",variant:"outline",size:"sm",className:"h-8 border-slate-700 text-slate-300 text-xs",onClick:i,disabled:l,children:[e.jsx(K,{"code-path":"src/components/kubernetes/CapacityPage.tsx:97:13",className:`h-3 w-3 mr-1 ${l?"animate-spin":""}`}),"刷新"]}),e.jsxs(P,{"code-path":"src/components/kubernetes/CapacityPage.tsx:99:11",variant:"outline",size:"sm",className:"h-8 border-slate-700 text-slate-300 text-xs",onClick:B,children:[e.jsx(G,{"code-path":"src/components/kubernetes/CapacityPage.tsx:100:13",className:"h-3 w-3 mr-1"}),"CSV"]})]})]}),e.jsx(L,{"code-path"Line truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{j as e,r as a,B as p,s as S,P as f,S as $,I as C,D as G,b as X,c as Z,d as q,e as J,f as U,L as Y}from"./index-DfyorCky.js";import{L as x}from"./label-BK0h2apY.js";import{C as r,a as d}from"./card-C55cvSHg.js";import{B as v}from"./badge-xNW8x0G1.js";import{c as N}from"./cloud-Dzoer-2i.js";import{R as k}from"./refresh-cw-DUB_tAG-.js";import{P as L}from"./plus-CUG-9kpu.js";import{C as B}from"./circle-check-DWcXrx2k.js";import{C as D}from"./circle-x-DK79Dhg2.js";import{P}from"./pencil-BqUotcjf.js";import{T as ee}from"./trash-2-Dx32pOzT.js";const E={aws:{viewBox:"0 0 24 24",color:"#FF9900",path:"M6.763 10.036c0 .296.032.535.088.71.064.176.144.368.256.576.04.063.056.127.056.183 0 .08-.048.16-.152.24l-.503.335a.383.383 0 0 1-.208.072c-.08 0-.16-.04-.24-.112a2.47 2.47 0 0 1-.288-.375 6.18 6.18 0 0 1-.248-.471c-.622.734-1.405 1.101-2.347 1.101-.671 0-1.205-.191-1.596-.574-.391-.384-.59-.894-.59-1.533 0-.678.239-1.23.726-1.644.487-.415 1.133-.623 1.955-.623.272 0 .551.024.846.064.296.04.6.104.918.176v-.583c0-.607-.127-1.03-.375-1.277-.255-.248-.686-.367-1.3-.367-.28 0-.568.031-.863.103-.295.072-.583.16-.862.272a2.287 2.287 0 0 1-.28.104.488.488 0 0 1-.127.023c-.112 0-.168-.08-.168-.247v-.391c0-.128.016-.224.056-.28a.597.597 0 0 1 .224-.167c.279-.144.614-.264 1.005-.36a4.84 4.84 0 0 1 1.246-.151c.95 0 1.644.216 2.091.647.439.43.662 1.085.662 1.963v2.586zm-3.24 1.21c.265 0 .538-.048.822-.144.283-.096.535-.271.742-.51.128-.152.224-.32.264-.512.04-.191.072-.423.072-.694v-.335a6.66 6.66 0 0 0-.735-.136 6.02 6.02 0 0 0-.75-.048c-.535 0-.926.104-1.19.32-.263.215-.39.518-.39.917 0 .375.095.654.295.846.191.2.47.296.838.296zm3.89.527c-.073 0-.12-.016-.152-.048-.032-.024-.064-.08-.088-.152L6.155 5.563a.715.715 0 0 1-.032-.16c0-.128.064-.2.192.2h.703c.08 0 .136.016.168.048.032.024.064.08.088.152l1.348 5.298 1.252-5.298c.024-.08.056-.128.088-.152a.355.355 0 0 1 .176-.048h.575c.08 0 .136.016.176.048.032.024.072.08.088.152l1.268 5.362 1.39-5.362c.024-.08.056-.128.088-.152a.344.344 0 0 1 .168-.048h.67c.128 0 .2.072.2.2 0 .04-.008.072-.016.112 0 0-.04.128-.088.152l-1.916 6.15c-.032.08-.064.128-.096.152a.355.355 0 0 1-.176.048h-.622c-.08 0-.136-.016-.176-.048-.032-.024-.064-.08-.088-.152l-1.26-5.186-1.252 5.178c-.024.08-.056.128-.088.152a.355.355 0 0 1-.176.048h-.623zm9.166.215c-.367 0-.734-.04-1.094-.127-.359-.088-.638-.184-.822-.296-.112-.064-.191-.136-.223-.2a.498.498 0 0 1-.032-.128v-.399c0-.167.064-.247.183-.247a.45.45 0 0 1 .144.024c.048.016.12.048.2.08.271.12.566.215.878.279.319.064.63.096.95.096.502 0 .893-.088 1.164-.264a.86.86 0 0 0 .415-.758.777.777 0 0 0-.215-.55c-.144-.151-.423-.287-.83-.415l-1.188-.367c-.598-.192-1.044-.471-1.316-.838a1.95 1.95 0 0 1-.415-1.205c0-.351.072-.662.215-.918.144-.255.335-.479.575-.654.24-.184.51-.319.822-.415.311-.096.638-.136.982-.136.176 0 .36.008.535.032.184.024.351.056.518.088.152.04.303.08.439.127.136.048.24.096.311.144a.66.66 0 0 1 .176.144.298.298 0 0 1 .048.184v.359c0 .168-.064.256-.183.256a.83.83 0 0 1-.304-.096 3.68 3.68 0 0 0-1.548-.311c-.463 0-.83.072-1.085.231-.255.16-.39.4-.39.743 0 .351.128.59.383.758.255.168.702.335 1.331.48.583.135 1.005.311 1.268.518.263.207.39.495.39.862 0 .367-.128.662-.375.902-.247.247-.67.375-1.26.375zm2.004 1.332c-2.637 1.948-6.488 2.984-9.793 2.984-4.635 0-8.81-1.715-11.966-4.566-.255-.224-.024-.335.271-.144 3.41 1.987 7.622 3.183 11.966 3.183 2.936 0 6.158-.61 9.119-1.876.44-.207.815.287.383.615zm1.078-1.23c-.336-.431-2.223-.2-3.073-.103-.255.024-.295-.192-.064-.351 1.5-1.053 3.962-.75 4.246-.4.287.359-.08 2.824-1.484 4.004-.215.184-.423.088-.319-.151.311-.774 1.005-2.51.662-2.956v-.443z"},azure:{viewBox:"0 0 24 24",color:"#0078D4",path:"M5.483 21.3H24L14.025 4.013l-3.022 5.915 5.99 9.357H8.787l-3.304 6.015zM8.7 3.197L0 21.3h6.395l4.49-8.51L8.7 3.196z"},gcp:{viewBox:"0 0 24 24",color:"#4285F4",path:"M12.19 2.38a9.344 9.344 0 0 0-9.234 6.893c.053-.02-.055.013 0 0-3.875 2.551-3.922 8.11-.247 10.941l.006-.007-.007.03a6.717 6.717 0 0 0 4.077 1.356h5.173l.03.03h5.192c6.687.053 9.376-8.605 3.835-12.35a9.365 9.365 0 0 0-2.821-4.552l-.043.043.006-.05A9.344 9.344 0 0 0 12.19 2.38zm-.358 4.146c1.244-.04 2.518.368 3.486 1.15a5.186 5.186 0 0 1 1.862 4.078v.518c3.53-.07 3.53 5.262 0 5.193h-5.193l-.008.009v-.04H6.785a2.59 2.59 0 0 1-1.067-.23h.001a2.597 2.597 0 1 1 3.437-3.437l3.013-3.012A6.747 6.747 0 0 0 8.11 8.24c.018-.01.04-.026.054-.023a5.186 5.186 0 0 1 3.67-1.69z"},aliyun:{viewBox:"0 0 24 24",color:"#FF6A00",path:"M3.996 4.517h5.291L8.01 6.324 4.153 7.506a1.668 1.668 0 0 0-1.165 1.601v5.786a1.668 1.668 0 0 0 1.165 1.6l3.857 1.183 1.277 1.807H3.996A3.996 3.996 0 0 1 0 15.487V8.513a3.996 3.996 0 0 1 3.996-3.996m16.008 0h-5.291l1.277 1.807 3.857 1.182c.715.227 1.17.889 1.165 1.601v5.786a1.668 1.668 0 0 1-1.165 1.6l-3.857 1.183-1.277 1.807h5.291A3.996 3.996 0 0 0 24 15.487V8.513a3.996 3.996 0 0 0-3.996-3.996m-4.007 8.345H8.002v-1.804h7.995Z"},tencent:{viewBox:"220 60 620 430",color:"#006EFF",paths:[{fill:"#006EFF",d:"M685.3,188.5c-24.7-66.3-88-110.4-158.Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{j as e,r as a,B as d,Y as _,D as R,a as W,b as Q,c as V,s as $,d as G,e as X,L as Y}from"./index-Dmami9WE.js";import{I as h}from"./input-NsU9nXZF.js";import{L as u}from"./label-Ap_-SPYI.js";import{C as N,a as y}from"./card-CIfC-8Rh.js";import{B as A}from"./badge-3UzCvU7L.js";import{c as v}from"./cloud-Dq4kl-JO.js";import{R as F}from"./refresh-cw-CTBERyFc.js";import{P as S}from"./plus-O65gX7Qz.js";import{S as Z}from"./search-Dd-PeBfg.js";import{C as q}from"./circle-check-CVbTTFQ0.js";import{C as J}from"./circle-x-BBQeW1R3.js";import{P as k}from"./pencil-BYahlvYT.js";import{T as U}from"./trash-2-DWVnIU6o.js";const L={aws:{viewBox:"0 0 24 24",color:"#FF9900",path:"M6.763 10.036c0 .296.032.535.088.71.064.176.144.368.256.576.04.063.056.127.056.183 0 .08-.048.16-.152.24l-.503.335a.383.383 0 0 1-.208.072c-.08 0-.16-.04-.24-.112a2.47 2.47 0 0 1-.288-.375 6.18 6.18 0 0 1-.248-.471c-.622.734-1.405 1.101-2.347 1.101-.671 0-1.205-.191-1.596-.574-.391-.384-.59-.894-.59-1.533 0-.678.239-1.23.726-1.644.487-.415 1.133-.623 1.955-.623.272 0 .551.024.846.064.296.04.6.104.918.176v-.583c0-.607-.127-1.03-.375-1.277-.255-.248-.686-.367-1.3-.367-.28 0-.568.031-.863.103-.295.072-.583.16-.862.272a2.287 2.287 0 0 1-.28.104.488.488 0 0 1-.127.023c-.112 0-.168-.08-.168-.247v-.391c0-.128.016-.224.056-.28a.597.597 0 0 1 .224-.167c.279-.144.614-.264 1.005-.36a4.84 4.84 0 0 1 1.246-.151c.95 0 1.644.216 2.091.647.439.43.662 1.085.662 1.963v2.586zm-3.24 1.21c.265 0 .538-.048.822-.144.283-.096.535-.271.742-.51.128-.152.224-.32.264-.512.04-.191.072-.423.072-.694v-.335a6.66 6.66 0 0 0-.735-.136 6.02 6.02 0 0 0-.75-.048c-.535 0-.926.104-1.19.32-.263.215-.39.518-.39.917 0 .375.095.654.295.846.191.2.47.296.838.296zm3.89.527c-.073 0-.12-.016-.152-.048-.032-.024-.064-.08-.088-.152L6.155 5.563a.715.715 0 0 1-.032-.16c0-.128.064-.2.192.2h.703c.08 0 .136.016.168.048.032.024.064.08.088.152l1.348 5.298 1.252-5.298c.024-.08.056-.128.088-.152a.355.355 0 0 1 .176-.048h.575c.08 0 .136.016.176.048.032.024.072.08.088.152l1.268 5.362 1.39-5.362c.024-.08.056-.128.088-.152a.344.344 0 0 1 .168-.048h.67c.128 0 .2.072.2.2 0 .04-.008.072-.016.112 0 0-.04.128-.088.152l-1.916 6.15c-.032.08-.064.128-.096.152a.355.355 0 0 1-.176.048h-.622c-.08 0-.136-.016-.176-.048-.032-.024-.064-.08-.088-.152l-1.26-5.186-1.252 5.178c-.024.08-.056.128-.088.152a.355.355 0 0 1-.176.048h-.623zm9.166.215c-.367 0-.734-.04-1.094-.127-.359-.088-.638-.184-.822-.296-.112-.064-.191-.136-.223-.2a.498.498 0 0 1-.032-.128v-.399c0-.167.064-.247.183-.247a.45.45 0 0 1 .144.024c.048.016.12.048.2.08.271.12.566.215.878.279.319.064.63.096.95.096.502 0 .893-.088 1.164-.264a.86.86 0 0 0 .415-.758.777.777 0 0 0-.215-.55c-.144-.151-.423-.287-.83-.415l-1.188-.367c-.598-.192-1.044-.471-1.316-.838a1.95 1.95 0 0 1-.415-1.205c0-.351.072-.662.215-.918.144-.255.335-.479.575-.654.24-.184.51-.319.822-.415.311-.096.638-.136.982-.136.176 0 .36.008.535.032.184.024.351.056.518.088.152.04.303.08.439.127.136.048.24.096.311.144a.66.66 0 0 1 .176.144.298.298 0 0 1 .048.184v.359c0 .168-.064.256-.183.256a.83.83 0 0 1-.304-.096 3.68 3.68 0 0 0-1.548-.311c-.463 0-.83.072-1.085.231-.255.16-.39.4-.39.743 0 .351.128.59.383.758.255.168.702.335 1.331.48.583.135 1.005.311 1.268.518.263.207.39.495.39.862 0 .367-.128.662-.375.902-.247.247-.67.375-1.26.375zm2.004 1.332c-2.637 1.948-6.488 2.984-9.793 2.984-4.635 0-8.81-1.715-11.966-4.566-.255-.224-.024-.335.271-.144 3.41 1.987 7.622 3.183 11.966 3.183 2.936 0 6.158-.61 9.119-1.876.44-.207.815.287.383.615zm1.078-1.23c-.336-.431-2.223-.2-3.073-.103-.255.024-.295-.192-.064-.351 1.5-1.053 3.962-.75 4.246-.4.287.359-.08 2.824-1.484 4.004-.215.184-.423.088-.319-.151.311-.774 1.005-2.51.662-2.956v-.443z"},azure:{viewBox:"0 0 24 24",color:"#0078D4",path:"M5.483 21.3H24L14.025 4.013l-3.022 5.915 5.99 9.357H8.787l-3.304 6.015zM8.7 3.197L0 21.3h6.395l4.49-8.51L8.7 3.196z"},gcp:{viewBox:"0 0 24 24",color:"#4285F4",path:"M12.19 2.38a9.344 9.344 0 0 0-9.234 6.893c.053-.02-.055.013 0 0-3.875 2.551-3.922 8.11-.247 10.941l.006-.007-.007.03a6.717 6.717 0 0 0 4.077 1.356h5.173l.03.03h5.192c6.687.053 9.376-8.605 3.835-12.35a9.365 9.365 0 0 0-2.821-4.552l-.043.043.006-.05A9.344 9.344 0 0 0 12.19 2.38zm-.358 4.146c1.244-.04 2.518.368 3.486 1.15a5.186 5.186 0 0 1 1.862 4.078v.518c3.53-.07 3.53 5.262 0 5.193h-5.193l-.008.009v-.04H6.785a2.59 2.59 0 0 1-1.067-.23h.001a2.597 2.597 0 1 1 3.437-3.437l3.013-3.012A6.747 6.747 0 0 0 8.11 8.24c.018-.01.04-.026.054-.023a5.186 5.186 0 0 1 3.67-1.69z"},aliyun:{viewBox:"0 0 24 24",color:"#FF6A00",path:"M3.996 4.517h5.291L8.01 6.324 4.153 7.506a1.668 1.668 0 0 0-1.165 1.601v5.786a1.668 1.668 0 0 0 1.165 1.6l3.857 1.183 1.277 1.807H3.996A3.996 3.996 0 0 1 0 15.487V8.513a3.996 3.996 0 0 1 3.996-3.996m16.008 0h-5.291l1.277 1.807 3.857 1.182c.715.227 1.17.889 1.165 1.601v5.786a1.668 1.668 0 0 1-1.165 1.6l-3.857 1.183-1.277 1.807h5.291A3.996 3.996 0 0 0 24 15.487V8.513a3.996 3.996 0 0 0-3.996-3.996m-4.007 8.345H8.002v-1.804h7.995Z"},tencent:{viewBox:"220 60 620 430",color:"#Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{i as ve,j as e,r as c,D as X,a as Y,b as Z,c as ee,d as se,e as le,B as u,L as R,f as Ne,H as A}from"./index-Dmami9WE.js";import{I as j}from"./input-NsU9nXZF.js";import{L as r}from"./label-Ap_-SPYI.js";import{C as T,a as V}from"./card-CIfC-8Rh.js";import{B as fe}from"./badge-3UzCvU7L.js";import{S as oe}from"./switch-TqjD2x0W.js";import{S as w,a as S,b as k,c as _,d as x}from"./select-DUbxjT0z.js";import{t as p}from"./index-BuEnLCjT.js";import{b as h}from"./cloud-Dq4kl-JO.js";import{S as be}from"./stat-strip-BteRU1Iu.js";import{R as q}from"./refresh-cw-CTBERyFc.js";import{P as G}from"./plus-O65gX7Qz.js";import{P as J}from"./pencil-BYahlvYT.js";import{T as K}from"./trash-2-DWVnIU6o.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";const De=[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]],ye=ve("wallet",De),v={aliyun:"阿里云",tencent:"腾讯云",aws:"AWS",huawei:"华为云",azure:"Azure"},O={aliyun:"bg-orange-500",tencent:"bg-blue-500",aws:"bg-amber-500",huawei:"bg-red-500",azure:"bg-sky-500"};function g(d){return`¥${d.toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2})}`}function Re({data:d}){if(d.length===0)return e.jsx("p",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:54:12",className:"text-sm text-slate-500 py-8 text-center",children:"暂无数据"});const n=Math.max(...d.map(a=>a.cost),1),t=d.slice(-30);return e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:60:5",children:[e.jsx("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:61:7",className:"flex items-end gap-0.5 h-40",children:t.map((a,o)=>{const i=Math.max(a.cost/n*100,2);return e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:65:13",className:"flex-1 group relative",style:{height:"100%"},children:[e.jsx("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:70:15",className:"absolute bottom-0 w-full rounded-t-sm bg-gradient-to-t from-blue-600/60 to-blue-400/80 group-hover:from-blue-500 group-hover:to-blue-300 transition-colors",style:{height:`${i}%`}}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:74:15",className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover:block whitespace-nowrap text-xs bg-slate-800 text-slate-200 px-2 py-1 rounded border border-slate-700 z-10",children:[a.date,": ",g(a.cost)]})]},o)})}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:81:7",className:"flex justify-between mt-2 text-xs text-slate-500",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:82:9",children:t[0]?.date}),e.jsx("span",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:83:9",children:t[t.length-1]?.date})]})]})}const Q={provider:"aliyun",billing_date:"",cost:"",service:"",region:"",account_name:"",description:""};function we({open:d,onOpenChange:n,editingRecord:t,onSuccess:a}){const[o,i]=c.useState(Q),[B,C]=c.useState(!1);c.useEffect(()=>{d&&i(t?{provider:t.provider,billing_date:t.billing_date,cost:t.cost,service:t.service||"",region:t.region||"",account_name:t.account_name||"",description:t.description||""}:{...Q,billing_date:new Date().toISOString().slice(0,10)})},[d,t]);const y=async()=>{if(!o.provider||!o.billing_date||!o.cost){p.error("请填写必填字段");return}C(!0);try{const l={...o,cost:parseFloat(o.cost)};t?(await h.remove(t.id),await h.create(l)):await h.create(l),n(!1),a(),p("保存成功")}catch(l){p.error("保存失败",{description:l.message})}finally{C(!1)}};return e.jsx(X,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:90:5",open:d,onOpenChange:n,children:e.jsxs(Y,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:91:7",className:"max-w-md",children:[e.jsxs(Z,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:92:9",children:[e.jsx(ee,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:93:11",children:t?"编辑成本记录":"记录成本"}),e.jsx(se,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:94:11",children:"记录一条每日云资源成本"})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:96:9",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:97:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:98:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:99:15",className:"text-sm text-slate-300",children:"厂商 *"}),e.jsxs(w,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:100:15",value:o.provider,onValueChange:l=>i({...o,provider:l}),children:[e.jsx(S,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:101:17",className:"mt-1",children:e.jsx(k,{"code-path":"src/components/cloud/BillingRecordDiaLine truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{g as Z,j as e,r as a,D as ee,b as se,c as le,d as oe,e as te,I as j,f as ce,B as m,L as R,a as ye,T as De,J as M}from"./index-DfyorCky.js";import{L as r}from"./label-BK0h2apY.js";import{C as A,a as V}from"./card-C55cvSHg.js";import{B as Re}from"./badge-xNW8x0G1.js";import{S as ne}from"./switch-CGiGgOnh.js";import{S as w,a as S,b as k,c as _,d as h}from"./select-D5qUzdAs.js";import{t as p}from"./index-a3ybMjbR.js";import{b as g}from"./cloud-Dzoer-2i.js";import{T as ae}from"./trending-up-CdusV6gc.js";import{T as we}from"./trending-down-BGTWG_dA.js";import{R as J}from"./refresh-cw-DUB_tAG-.js";import{P as U}from"./plus-CUG-9kpu.js";import{P as G}from"./pencil-BqUotcjf.js";import{T as K}from"./trash-2-Dx32pOzT.js";import"./index-CWVNW_qu.js";const Se=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]],ke=Z("calendar-days",Se);const _e=[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]],Q=Z("wallet",_e),v={aliyun:"阿里云",tencent:"腾讯云",aws:"AWS",huawei:"华为云",azure:"Azure"},O={aliyun:"bg-orange-500",tencent:"bg-blue-500",aws:"bg-amber-500",huawei:"bg-red-500",azure:"bg-sky-500"};function u(d){return`¥${d.toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2})}`}function E({icon:d,label:i,value:t,trend:c,trendLabel:o,alert:n}){return e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:35:5",className:`rounded-lg border p-4 ${n?"border-amber-500/30 bg-amber-500/5":"border-slate-800 bg-slate-900/50"}`,children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:36:7",className:"flex items-center justify-between mb-2",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:37:9",className:"text-slate-400 text-sm",children:i}),e.jsx("span",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:38:9",className:n?"text-amber-400":"text-slate-500",children:d})]}),e.jsx("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:40:7",className:`text-2xl font-bold ${n?"text-amber-300":"text-slate-100"}`,children:t}),o&&e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:42:9",className:"flex items-center gap-1 mt-1 text-xs",children:[c!==void 0&&c>0&&e.jsx(ae,{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:43:48",className:"h-3 w-3 text-red-400"}),c!==void 0&&c<0&&e.jsx(we,{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:44:48",className:"h-3 w-3 text-green-400"}),e.jsx("span",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:45:11",className:"text-slate-500",children:o})]})]})}function He({data:d}){if(d.length===0)return e.jsx("p",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:54:12",className:"text-sm text-slate-500 py-8 text-center",children:"暂无数据"});const i=Math.max(...d.map(c=>c.cost),1),t=d.slice(-30);return e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:60:5",children:[e.jsx("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:61:7",className:"flex items-end gap-0.5 h-40",children:t.map((c,o)=>{const n=Math.max(c.cost/i*100,2);return e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:65:13",className:"flex-1 group relative",style:{height:"100%"},children:[e.jsx("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:70:15",className:"absolute bottom-0 w-full rounded-t-sm bg-gradient-to-t from-blue-600/60 to-blue-400/80 group-hover:from-blue-500 group-hover:to-blue-300 transition-colors",style:{height:`${n}%`}}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:74:15",className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover:block whitespace-nowrap text-xs bg-slate-800 text-slate-200 px-2 py-1 rounded border border-slate-700 z-10",children:[c.date,": ",u(c.cost)]})]},o)})}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:81:7",className:"flex justify-between mt-2 text-xs text-slate-500",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:82:9",children:t[0]?.date}),e.jsx("span",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:83:9",children:t[t.length-1]?.date})]})]})}const X={provider:"aliyun",billing_date:"",cost:"",service:"",region:"",account_name:"",description:""};function ze({open:d,onOpenChange:i,editingRecord:t,onSuccess:c}){const[o,n]=a.useState(X),[B,C]=a.useState(!1);a.useEffect(()=>{d&&n(t?{provider:t.provider,billing_date:t.billing_date,cost:tLine truncated
|
||||
+1
-1
@@ -1 +1 @@
|
||||
import{i as F,k as K,r as c,j as e,m as w,n as C,B as G,L as A,o as k,p as R,q as T,s as H,A as q,t as z,v as D}from"./index-DfyorCky.js";import{C as i,a as u}from"./card-C55cvSHg.js";import{B as M}from"./badge-xNW8x0G1.js";import{T as J,a as Q,b as x,c as n,d as V,e as a}from"./table-5sHV4Akp.js";import{k as j}from"./kubernetes-J8O09fK7.js";import{u as W}from"./use-toast-CrSOP4cJ.js";import{R as X}from"./refresh-cw-DUB_tAG-.js";const Y={"kube-system":T,"kube-public":z,"kube-node-lease":q,default:H};function ne(){const{clusterCode:r}=F(),B=K(),{toast:E}=W(),[,P]=c.useState([]),[m,O]=c.useState([]),[N,f]=c.useState([]),[d,I]=c.useState(null),[p,y]=c.useState(!1),_=c.useCallback(async()=>{try{const t=(await j.getClusters())?.list||[];P(t);const o=t.find(l=>(l.code||String(l.id))===r);I(o||null),!o&&t.length>0&&r&&E({title:"集群未找到",description:`找不到集群 ${r}`,variant:"destructive"})}catch{P([])}},[r]),v=c.useCallback(async()=>{if(r){y(!0);try{const[s,t]=await Promise.all([j.getNodes(r).catch(()=>[]),j.getNamespaces(r).catch(()=>[])]);O(Array.isArray(s)?s:s?.list||s?.data||[]);const o=Array.isArray(t)?t:t?.list||t?.data||[];f(o)}catch{O([]),f([])}finally{y(!1)}}},[r]);c.useEffect(()=>{_()},[_]),c.useEffect(()=>{v()},[v]);const L=s=>s?.role==="master"||s?.role==="control-plane"?"bg-blue-500/20 text-blue-400 border-blue-500/30":"bg-slate-500/20 text-slate-400 border-slate-500/30";return e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:81:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:83:7",className:"flex items-center gap-2 text-sm text-slate-500",children:[e.jsx(w,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:84:9",to:"/kubernetes",className:"hover:text-slate-300 transition-colors",children:"集群"}),e.jsx(C,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:85:9",className:"h-3 w-3"}),e.jsx("span",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:86:9",className:"text-slate-300",children:r})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:90:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:91:9",children:[e.jsx("h1",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:92:11",className:"text-2xl font-bold text-slate-100",children:r}),e.jsxs("p",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:93:11",className:"text-sm text-slate-500 mt-1",children:["集群概览",d?.version?` — Kubernetes ${d.version}`:""]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:98:9",className:"flex items-center gap-2",children:e.jsx(G,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:99:11",variant:"outline",size:"icon",className:"h-9 w-9 border-slate-700 text-slate-400",onClick:v,disabled:p,children:p?e.jsx(A,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:101:24",className:"h-4 w-4 animate-spin"}):e.jsx(X,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:101:71",className:"h-4 w-4"})})})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:107:7",className:"grid grid-cols-3 md:grid-cols-3 gap-4",children:[e.jsx(i,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:108:9",className:"bg-slate-900 border-slate-800",children:e.jsx(u,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:109:11",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:110:13",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:111:15",children:[e.jsx("p",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:111:20",className:"text-sm text-slate-500",children:"节点"}),e.jsx("p",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:111:64",className:"text-2xl font-bold text-blue-400",children:m.length})]}),e.jsx(k,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:112:15",className:"h-8 w-8 opacity-30 text-blue-400"})]})})}),e.jsx(i,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:116:9",className:"bg-slate-900 border-slate-800",children:e.jsx(u,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:117:11",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:118:13",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:119:15",children:[e.jsx("p",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:119:20",className:"text-sm text-slate-500",children:"命名空间"}),e.jsx("p",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:119:66",className:"text-2xl font-bold text-emerald-400",children:N.length})]}),e.Line truncated
|
||||
import{k as F,m as K,r as c,j as e,n as w,o as C,B as G,L as A,p as k,q as R,S as T,s as H,A as q,t as z,v as D}from"./index-Dmami9WE.js";import{C as i,a as u}from"./card-CIfC-8Rh.js";import{B as M}from"./badge-3UzCvU7L.js";import{T as J,a as Q,b as x,c as n,d as V,e as a}from"./table-CG4mjNfb.js";import{k as j}from"./kubernetes-D2-GnE0t.js";import{u as W}from"./use-toast-jvSbBx20.js";import{R as X}from"./refresh-cw-CTBERyFc.js";const Y={"kube-system":T,"kube-public":z,"kube-node-lease":q,default:H};function ne(){const{clusterCode:r}=F(),B=K(),{toast:E}=W(),[,P]=c.useState([]),[m,O]=c.useState([]),[N,f]=c.useState([]),[d,I]=c.useState(null),[p,y]=c.useState(!1),_=c.useCallback(async()=>{try{const t=(await j.getClusters())?.list||[];P(t);const o=t.find(l=>(l.code||String(l.id))===r);I(o||null),!o&&t.length>0&&r&&E({title:"集群未找到",description:`找不到集群 ${r}`,variant:"destructive"})}catch{P([])}},[r]),v=c.useCallback(async()=>{if(r){y(!0);try{const[s,t]=await Promise.all([j.getNodes(r).catch(()=>[]),j.getNamespaces(r).catch(()=>[])]);O(Array.isArray(s)?s:s?.list||s?.data||[]);const o=Array.isArray(t)?t:t?.list||t?.data||[];f(o)}catch{O([]),f([])}finally{y(!1)}}},[r]);c.useEffect(()=>{_()},[_]),c.useEffect(()=>{v()},[v]);const L=s=>s?.role==="master"||s?.role==="control-plane"?"bg-blue-500/20 text-blue-400 border-blue-500/30":"bg-slate-500/20 text-slate-400 border-slate-500/30";return e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:81:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:83:7",className:"flex items-center gap-2 text-sm text-slate-500",children:[e.jsx(w,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:84:9",to:"/kubernetes",className:"hover:text-slate-300 transition-colors",children:"集群"}),e.jsx(C,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:85:9",className:"h-3 w-3"}),e.jsx("span",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:86:9",className:"text-slate-300",children:r})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:90:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:91:9",children:[e.jsx("h1",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:92:11",className:"text-2xl font-bold text-slate-100",children:r}),e.jsxs("p",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:93:11",className:"text-sm text-slate-500 mt-1",children:["集群概览",d?.version?` — Kubernetes ${d.version}`:""]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:98:9",className:"flex items-center gap-2",children:e.jsx(G,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:99:11",variant:"outline",size:"icon",className:"h-9 w-9 border-slate-700 text-slate-400",onClick:v,disabled:p,children:p?e.jsx(A,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:101:24",className:"h-4 w-4 animate-spin"}):e.jsx(X,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:101:71",className:"h-4 w-4"})})})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:107:7",className:"grid grid-cols-3 md:grid-cols-3 gap-4",children:[e.jsx(i,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:108:9",className:"bg-slate-900 border-slate-800",children:e.jsx(u,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:109:11",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:110:13",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:111:15",children:[e.jsx("p",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:111:20",className:"text-sm text-slate-500",children:"节点"}),e.jsx("p",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:111:64",className:"text-2xl font-bold text-blue-400",children:m.length})]}),e.jsx(k,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:112:15",className:"h-8 w-8 opacity-30 text-blue-400"})]})})}),e.jsx(i,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:116:9",className:"bg-slate-900 border-slate-800",children:e.jsx(u,{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:117:11",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:118:13",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:119:15",children:[e.jsx("p",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:119:20",className:"text-sm text-slate-500",children:"命名空间"}),e.jsx("p",{"code-path":"src/components/kubernetes/ClusterOverviewPage.tsx:119:66",className:"text-2xl font-bold text-emerald-400",children:N.length})]}),e.Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{f as st,r as a,h as I,j as e,B as b,t as $e,G as rt,z as nt,s as ot,v as ct,S as dt,Y as V,C as lt,D as qe,a as ze,b as Be,c as Ue,d as pt,e as Ge,T as it,Z as Ye,O as Qe,_ as xt}from"./index-Dmami9WE.js";import{I as p}from"./input-NsU9nXZF.js";import{L as l}from"./label-Ap_-SPYI.js";import{B as S}from"./badge-3UzCvU7L.js";import{S as Ke,a as De,b as Ae,c as Pe,d as _}from"./select-DUbxjT0z.js";import{t as y}from"./index-BuEnLCjT.js";import{R as mt}from"./refresh-cw-CTBERyFc.js";import{P as Re}from"./plus-O65gX7Qz.js";import{S as gt}from"./search-Dd-PeBfg.js";import{Z as ht}from"./zap-CocSkPPl.js";import{F as yt}from"./file-text-CebshSV-.js";import{P as vt}from"./pencil-BYahlvYT.js";import{C as Ze}from"./circle-x-BBQeW1R3.js";import{C as We}from"./circle-check-CVbTTFQ0.js";import{T as Ct}from"./trash-2-DWVnIU6o.js";import{C as Ve}from"./copy-CE_T92Lk.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";const O={ssh:{label:"SSH 密钥",icon:dt,color:"text-amber-400",desc:"SSH 私钥/公钥/密码"},docker:{label:"Docker 凭证",icon:ct,color:"text-cyan-400",desc:"Docker Registry 登录凭据"},tls:{label:"TLS 证书",icon:$e,color:"text-green-400",desc:"TLS/SSL 证书与私钥"},aksk:{label:"AKSK 密钥",icon:ot,color:"text-purple-400",desc:"云服务 AccessKey/SecretKey"},database:{label:"数据库凭证",icon:nt,color:"text-blue-400",desc:"数据库连接信息"},api:{label:"API 密钥",icon:rt,color:"text-orange-400",desc:"API Token/Key + 端点"},generic:{label:"通用凭证",icon:yt,color:"text-gray-400",desc:"自定义 Key/Value 键值对"}},Xe={ssh:"bg-amber-500/20 text-amber-400 border-amber-500/30",docker:"bg-cyan-500/20 text-cyan-400 border-cyan-500/30",tls:"bg-green-500/20 text-green-400 border-green-500/30",aksk:"bg-purple-500/20 text-purple-400 border-purple-500/30",database:"bg-blue-500/20 text-blue-400 border-blue-500/30",api:"bg-orange-500/20 text-orange-400 border-orange-500/30",generic:"bg-gray-500/20 text-gray-400 border-gray-500/30"};function ut({open:j,onClose:M,credId:k}){const[n,h]=a.useState(null),[T,v]=a.useState(!1),[E,w]=a.useState({});if(a.useEffect(()=>{!k||!j||(v(!0),I.get(`/credentials/${k}`).then(d=>{h(d)}).catch(()=>y.error("加载详情失败")).finally(()=>v(!1)))},[k,j]),!j||!k)return null;const c=d=>w(i=>({...i,[d]:!i[d]})),K=d=>{navigator.clipboard.writeText(d),y.success("已复制")},x=n?.secret_type,C=O[x],r=n?.content||{},o=({label:d,value:i,sensitive:m,fieldKey:D})=>{if(i==null||i==="")return null;const L=typeof i=="string"&&i.length>80,A=D?E[D]:!1;return e.jsxs("div",{"code-path":"src/components/deploy/CredentialManager.tsx:107:7",className:"mb-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/CredentialManager.tsx:108:9",className:"flex items-center gap-2 text-xs text-[var(--dg-text-muted)] mb-1",children:[e.jsx(xt,{"code-path":"src/components/deploy/CredentialManager.tsx:109:11",className:"h-3 w-3"}),d]}),e.jsxs("div",{"code-path":"src/components/deploy/CredentialManager.tsx:111:9",className:"flex gap-1",children:[L?e.jsx("textarea",{"code-path":"src/components/deploy/CredentialManager.tsx:113:13",readOnly:!0,value:m&&!A?"••••••••":i,className:"flex-1 rounded-md bg-[var(--dg-bg-tertiary)] border border-[var(--dg-border)] text-[var(--dg-text-primary)] p-2 text-xs font-mono resize-none",rows:4}):e.jsx(p,{"code-path":"src/components/deploy/CredentialManager.tsx:117:13",readOnly:!0,value:m&&!A?"••••••••":String(i),className:"flex-1 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] font-mono text-xs"}),e.jsxs("div",{"code-path":"src/components/deploy/CredentialManager.tsx:120:11",className:"flex flex-col gap-0.5 shrink-0",children:[m&&e.jsx(b,{"code-path":"src/components/deploy/CredentialManager.tsx:122:15",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>c(D),children:A?e.jsx(Ye,{"code-path":"src/components/deploy/CredentialManager.tsx:123:25",className:"h-3 w-3"}):e.jsx(Qe,{"code-path":"src/components/deploy/CredentialManager.tsx:123:58",className:"h-3 w-3"})}),e.jsx(b,{"code-path":"src/components/deploy/CredentialManager.tsx:126:13",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>K(String(i)),children:e.jsx(Ve,{"code-path":"src/components/deploy/CredentialManager.tsx:127:15",className:"h-3 w-3"})})]})]})]})};return e.jsx(qe,{"code-path":"src/components/deploy/CredentialManager.tsx:136:5",open:j,onOpenChange:M,children:e.jsxs(ze,{"code-path":"src/components/deploy/CredentialManager.tsx:137:7",className:"sm:max-w-[680px] max-h-[85vh] overflow-y-auto bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:[e.jsx(Be,{"code-path":"src/components/deploy/CredentialManager.tsx:138:9",children:e.jsxs(Ue,{"code-path":"src/components/deploy/CredentialManager.tsx:139:11",className:"text-[var(--dg-text-primary)] flex items-center gap-2",children:[C?e.jsx(C.icon,{"code-path":"src/components/deploy/CredentialManager.tsx:140:20",className:`h-5 w-5 ${C.coloLine truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{a as st,r as a,h as I,j as e,B as b,S as rt,I as p,t as qe,O as nt,G as ot,s as ct,v as dt,q as lt,P as V,x as pt,D as $e,b as Ue,c as ze,d as Be,e as it,f as Ge,T as xt,Q as Qe,U as Ye,V as mt}from"./index-DfyorCky.js";import{L as l}from"./label-BK0h2apY.js";import{B as S}from"./badge-xNW8x0G1.js";import{S as Ke,a as De,b as Ae,c as Pe,d as _}from"./select-D5qUzdAs.js";import{t as y}from"./index-a3ybMjbR.js";import{R as gt}from"./refresh-cw-DUB_tAG-.js";import{P as Re}from"./plus-CUG-9kpu.js";import{Z as ht}from"./zap-D2uWSK32.js";import{F as yt}from"./file-text-C9G5abwR.js";import{P as vt}from"./pencil-BqUotcjf.js";import{C as Ze}from"./circle-x-DK79Dhg2.js";import{C as We}from"./circle-check-DWcXrx2k.js";import{T as Ct}from"./trash-2-Dx32pOzT.js";import{C as Ve}from"./copy-DXW4LnkN.js";import"./index-CWVNW_qu.js";const O={ssh:{label:"SSH 密钥",icon:lt,color:"text-amber-400",desc:"SSH 私钥/公钥/密码"},docker:{label:"Docker 凭证",icon:dt,color:"text-cyan-400",desc:"Docker Registry 登录凭据"},tls:{label:"TLS 证书",icon:qe,color:"text-green-400",desc:"TLS/SSL 证书与私钥"},aksk:{label:"AKSK 密钥",icon:ct,color:"text-purple-400",desc:"云服务 AccessKey/SecretKey"},database:{label:"数据库凭证",icon:ot,color:"text-blue-400",desc:"数据库连接信息"},api:{label:"API 密钥",icon:nt,color:"text-orange-400",desc:"API Token/Key + 端点"},generic:{label:"通用凭证",icon:yt,color:"text-gray-400",desc:"自定义 Key/Value 键值对"}},Xe={ssh:"bg-amber-500/20 text-amber-400 border-amber-500/30",docker:"bg-cyan-500/20 text-cyan-400 border-cyan-500/30",tls:"bg-green-500/20 text-green-400 border-green-500/30",aksk:"bg-purple-500/20 text-purple-400 border-purple-500/30",database:"bg-blue-500/20 text-blue-400 border-blue-500/30",api:"bg-orange-500/20 text-orange-400 border-orange-500/30",generic:"bg-gray-500/20 text-gray-400 border-gray-500/30"};function ut({open:j,onClose:M,credId:k}){const[n,h]=a.useState(null),[T,v]=a.useState(!1),[E,w]=a.useState({});if(a.useEffect(()=>{!k||!j||(v(!0),I.get(`/credentials/${k}`).then(d=>{h(d)}).catch(()=>y.error("加载详情失败")).finally(()=>v(!1)))},[k,j]),!j||!k)return null;const c=d=>w(i=>({...i,[d]:!i[d]})),K=d=>{navigator.clipboard.writeText(d),y.success("已复制")},x=n?.secret_type,C=O[x],r=n?.content||{},o=({label:d,value:i,sensitive:m,fieldKey:D})=>{if(i==null||i==="")return null;const L=typeof i=="string"&&i.length>80,A=D?E[D]:!1;return e.jsxs("div",{"code-path":"src/components/deploy/CredentialManager.tsx:107:7",className:"mb-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/CredentialManager.tsx:108:9",className:"flex items-center gap-2 text-xs text-[var(--dg-text-muted)] mb-1",children:[e.jsx(mt,{"code-path":"src/components/deploy/CredentialManager.tsx:109:11",className:"h-3 w-3"}),d]}),e.jsxs("div",{"code-path":"src/components/deploy/CredentialManager.tsx:111:9",className:"flex gap-1",children:[L?e.jsx("textarea",{"code-path":"src/components/deploy/CredentialManager.tsx:113:13",readOnly:!0,value:m&&!A?"••••••••":i,className:"flex-1 rounded-md bg-[var(--dg-bg-tertiary)] border border-[var(--dg-border)] text-[var(--dg-text-primary)] p-2 text-xs font-mono resize-none",rows:4}):e.jsx(p,{"code-path":"src/components/deploy/CredentialManager.tsx:117:13",readOnly:!0,value:m&&!A?"••••••••":String(i),className:"flex-1 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] font-mono text-xs"}),e.jsxs("div",{"code-path":"src/components/deploy/CredentialManager.tsx:120:11",className:"flex flex-col gap-0.5 shrink-0",children:[m&&e.jsx(b,{"code-path":"src/components/deploy/CredentialManager.tsx:122:15",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>c(D),children:A?e.jsx(Qe,{"code-path":"src/components/deploy/CredentialManager.tsx:123:25",className:"h-3 w-3"}):e.jsx(Ye,{"code-path":"src/components/deploy/CredentialManager.tsx:123:58",className:"h-3 w-3"})}),e.jsx(b,{"code-path":"src/components/deploy/CredentialManager.tsx:126:13",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>K(String(i)),children:e.jsx(Ve,{"code-path":"src/components/deploy/CredentialManager.tsx:127:15",className:"h-3 w-3"})})]})]})]})};return e.jsx($e,{"code-path":"src/components/deploy/CredentialManager.tsx:136:5",open:j,onOpenChange:M,children:e.jsxs(Ue,{"code-path":"src/components/deploy/CredentialManager.tsx:137:7",className:"sm:max-w-[680px] max-h-[85vh] overflow-y-auto bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:[e.jsx(ze,{"code-path":"src/components/deploy/CredentialManager.tsx:138:9",children:e.jsxs(Be,{"code-path":"src/components/deploy/CredentialManager.tsx:139:11",className:"text-[var(--dg-text-primary)] flex items-center gap-2",children:[C?e.jsx(C.icon,{"code-path":"src/components/deploy/CredentialManager.tsx:140:20",className:`h-5 w-5 ${C.color}`}):e.jsx(V,{"code-path":"src/components/deploy/CredentialManager.tsx:140:70",className:"h-5 w-5 tLine truncated
|
||||
@@ -1,2 +0,0 @@
|
||||
import{j as t,L,a3 as mt,r as n,D as K,b as U,c as W,d as Y,e as Z,I as $,f as xt,B as p,H as tt,a as pt,S as ht,x as gt,F as ut}from"./index-DfyorCky.js";import{C as w,a as S}from"./card-C55cvSHg.js";import{B as C}from"./badge-xNW8x0G1.js";import{C as B}from"./checkbox-CH0bpj6b.js";import{t as d}from"./index-a3ybMjbR.js";import{s as z,c as y,t as bt}from"./automation-mtL167W_.js";import{C as vt}from"./circle-x-DK79Dhg2.js";import{S as O,a as R,b as A,c as V,d as N}from"./select-D5qUzdAs.js";import{T as Q}from"./textarea-NXY8u32k.js";import{L as J}from"./label-BK0h2apY.js";import{T as yt,a as Ct,b as I,c as E,d as jt,e as f}from"./table-5sHV4Akp.js";import{H as ot}from"./history-D_9jPUQg.js";import{R as Nt}from"./refresh-cw-DUB_tAG-.js";import{P as Jt}from"./plus-CUG-9kpu.js";import{T as q}from"./trash-2-Dx32pOzT.js";import{P as ft}from"./package-open-CUXo2Tda.js";import{P as X}from"./play-cdPayOtJ.js";import{P as Dt}from"./pause-D_famo9P.js";import{S as Mt}from"./square-pen-BxUFAe0F.js";import"./index-CWVNW_qu.js";function et(i){switch(i){case"success":return t.jsxs(C,{"code-path":"src/components/automation/cronJobHelpers.tsx:9:9",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:[t.jsx(mt,{"code-path":"src/components/automation/cronJobHelpers.tsx:10:11",className:"h-3 w-3 mr-1"}),"成功"]});case"failed":return t.jsxs(C,{"code-path":"src/components/automation/cronJobHelpers.tsx:16:9",variant:"outline",className:"border-red-500/30 text-red-400 bg-red-500/10",children:[t.jsx(vt,{"code-path":"src/components/automation/cronJobHelpers.tsx:17:11",className:"h-3 w-3 mr-1"}),"失败"]});case"running":return t.jsxs(C,{"code-path":"src/components/automation/cronJobHelpers.tsx:23:9",variant:"outline",className:"border-blue-500/30 text-blue-400 bg-blue-500/10 animate-pulse",children:[t.jsx(L,{"code-path":"src/components/automation/cronJobHelpers.tsx:24:11",className:"h-3 w-3 mr-1 animate-spin"}),"执行中"]});default:return t.jsx(C,{"code-path":"src/components/automation/cronJobHelpers.tsx:30:9",variant:"outline",className:"border-[var(--dg-border)] text-[var(--dg-text-muted)]",children:"从未执行"})}}function Ft(i){return{"0 2 * * *":"每天 02:00","0 3 * * 0":"每周日 03:00","*/5 * * * *":"每 5 分钟","0 * * * *":"每小时","0 9 * * 1":"每周一 09:00"}[i]||i}const G=[{value:"shell",label:"Shell 脚本",desc:"关联脚本库中的 Shell 脚本"},{value:"python",label:"Python 脚本",desc:"关联脚本库中的 Python 脚本"},{value:"command",label:"自定义命令",desc:"手动输入命令或脚本路径"}];function wt({open:i,onOpenChange:g,editJob:s,onSuccess:D}){const[a,l]=n.useState({name:"",description:"",cron_expr:"",type:"shell",content:"",script_id:null}),[h,v]=n.useState([]),[r,m]=n.useState(null),[H,M]=n.useState(!1);n.useEffect(()=>{i&&(z.getScripts({page_size:200}).then(e=>{v(e?.list||[])}).catch(()=>v([])),s?(l({name:s.name||"",description:s.description||"",cron_expr:s.cron_expr||"",type:s.type||"shell",content:s.content||"",script_id:s.script_id||null}),s.script_id?z.getScript(s.script_id).then(e=>{m(e)}).catch(()=>m(null)):m(null)):(l({name:"",description:"",cron_expr:"",type:"shell",content:"",script_id:null}),m(null)))},[i,s]);const F=a.type==="shell"||a.type==="python"?h.filter(e=>e.type===a.type):[],_=e=>{const x=h.find(j=>String(j.id)===e);x&&(m(x),l(j=>({...j,script_id:x.id,content:x.content})))},P=e=>{l(x=>({...x,type:e,script_id:null,content:e==="command"?x.content:""})),m(null)},k=async()=>{if(!a.name||!a.cron_expr){d.error("请填写任务名称和 Cron 表达式");return}if((a.type==="shell"||a.type==="python")&&!a.script_id){d.error("请选择关联的脚本");return}try{M(!0);const e={name:a.name,description:a.description,cron_expr:a.cron_expr,type:a.type,content:a.content,script_id:a.script_id};s?(await y.updateJob(s.id,e),d.success("任务更新成功")):(await y.createJob(e),d.success("任务创建成功")),g(!1),D()}catch(e){console.error("Failed to save cron job:",e),d.error(s?"更新失败":"创建失败")}finally{M(!1)}};return t.jsx(K,{"code-path":"src/components/automation/CronJobFormDialog.tsx:149:5",open:i,onOpenChange:g,children:t.jsxs(U,{"code-path":"src/components/automation/CronJobFormDialog.tsx:150:7",className:"max-w-2xl bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]",children:[t.jsxs(W,{"code-path":"src/components/automation/CronJobFormDialog.tsx:151:9",children:[t.jsx(Y,{"code-path":"src/components/automation/CronJobFormDialog.tsx:152:11",children:s?"编辑定时任务":"新建定时任务"}),t.jsx(Z,{"code-path":"src/components/automation/CronJobFormDialog.tsx:153:11",className:"text-[var(--dg-text-secondary)]",children:"配置 Cron 定时任务"})]}),t.jsxs("div",{"code-path":"src/components/automation/CronJobFormDialog.tsx:155:9",className:"space-y-4 py-4 max-h-[60vh] overflow-y-auto pr-1",children:[t.jsxs("div",{"code-path":"src/components/automation/CronJobFormDialog.tsx:1Line truncated
|
||||
`).length," 行"]})]}),t.jsx("pre",{"code-path":"src/components/automation/CronJobFormDialog.tsx:275:19",className:"max-h-48 overflow-auto rounded-md bg-[var(--dg-bg-tertiary)] border border-[var(--dg-border)] p-3 text-xs font-mono text-[var(--dg-text-secondary)] whitespace-pre-wrap break-all",children:r.content||"(空脚本)"})]})]}):t.jsxs("div",{"code-path":"src/components/automation/CronJobFormDialog.tsx:282:13",children:[t.jsx(J,{"code-path":"src/components/automation/CronJobFormDialog.tsx:283:15",className:"text-[var(--dg-text-primary)]",children:"执行命令"}),t.jsx(Q,{"code-path":"src/components/automation/CronJobFormDialog.tsx:284:15",value:a.content,onChange:e=>l({...a,content:e.target.value}),placeholder:"/scripts/backup.sh arg1 arg2",rows:4,className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] mt-1 font-mono"})]})]}),t.jsxs(xt,{"code-path":"src/components/automation/CronJobFormDialog.tsx:294:9",children:[t.jsx(p,{"code-path":"src/components/automation/CronJobFormDialog.tsx:295:11",variant:"outline",onClick:()=>g(!1),className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)]",children:"取消"}),t.jsx(p,{"code-path":"src/components/automation/CronJobFormDialog.tsx:298:11",className:"bg-blue-600 hover:bg-blue-700",onClick:k,disabled:H,children:H?"保存中...":s?"保存修改":"创建任务"})]})]})})}function St({open:i,onOpenChange:g}){const[s,D]=n.useState([]),[a,l]=n.useState(!1),[h,v]=n.useState(null);return n.useEffect(()=>{if(!i)return;(async()=>{try{l(!0);const m=await bt.getExecutions({task_type:"cron",page_size:50});D(m.list||[])}catch(m){console.error("Failed to load executions:",m)}finally{l(!1)}})()},[i]),t.jsx(K,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:51:5",open:i,onOpenChange:g,children:t.jsxs(U,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:52:7",className:"max-w-4xl bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] max-h-[85vh] overflow-y-auto",children:[t.jsxs(W,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:53:9",children:[t.jsx(Y,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:54:11",children:"执行历史"}),t.jsx(Z,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:55:11",className:"text-[var(--dg-text-secondary)]",children:"定时任务执行记录与输出日志"})]}),t.jsx("div",{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:57:9",className:"mt-4",children:a?t.jsx("div",{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:59:13",className:"flex items-center justify-center py-8",children:t.jsx(L,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:60:15",className:"h-6 w-6 text-[var(--dg-text-secondary)] animate-spin"})}):s.length===0?t.jsxs("div",{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:63:13",className:"flex flex-col items-center justify-center py-12 text-[var(--dg-text-secondary)]",children:[t.jsx(ot,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:64:15",className:"h-10 w-10 mb-3 opacity-40"}),t.jsx("p",{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:65:15",className:"text-sm",children:"暂无执行记录"})]}):t.jsxs(yt,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:68:13",children:[t.jsx(Ct,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:69:15",children:t.jsxs(I,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:70:17",className:"border-[var(--dg-border)]",children:[t.jsx(E,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:71:19",className:"text-[var(--dg-text-secondary)]",children:"任务"}),t.jsx(E,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:72:19",className:"text-[var(--dg-text-secondary)]",children:"状态"}),t.jsx(E,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:73:19",className:"text-[var(--dg-text-secondary)]",children:"耗时"}),t.jsx(E,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:74:19",className:"text-[var(--dg-text-secondary)]",children:"执行时间"}),t.jsx(E,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:75:19",className:"text-[var(--dg-text-secondary)]",children:"输出"})]})}),t.jsx(jt,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:78:15",children:s.map(r=>t.jsxs(n.Fragment,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:80:19",children:[t.jsxs(I,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:81:21",className:"border-[var(--dg-border)] cursor-pointer hover:bg-[var(--dg-bg-hover)]/50",onClick:()=>v(h===r.id?null:r.id),children:[t.jsx(f,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:82:23",className:"text-[var(--dg-text-primary)]",children:r.task_name}),t.jsx(f,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:83
Line truncated
|
||||
@@ -0,0 +1,2 @@
|
||||
import{j as t,L as k,P as lt,r as n,D as X,a as G,b as K,c as U,d as W,e as mt,B as p,E as Y,f as dt,C as xt,F as pt}from"./index-Dmami9WE.js";import{C as ht,a as gt}from"./card-CIfC-8Rh.js";import{S as ut}from"./stat-strip-BteRU1Iu.js";import{I as L}from"./input-NsU9nXZF.js";import{B as C}from"./badge-3UzCvU7L.js";import{C as I}from"./checkbox-DoAtRzQj.js";import{t as l}from"./index-BuEnLCjT.js";import{s as $,c as y,t as bt}from"./automation-WG-s4QEv.js";import{C as vt}from"./circle-x-BBQeW1R3.js";import{S as B,a as z,b as O,c as R,d as J}from"./select-DUbxjT0z.js";import{T as A}from"./textarea-DHUZ6N85.js";import{L as N}from"./label-Ap_-SPYI.js";import{T as yt,a as Ct,b as P,c as w,d as jt,e as f}from"./table-CG4mjNfb.js";import{H as Z}from"./history-CbX6uocL.js";import{R as Jt}from"./refresh-cw-CTBERyFc.js";import{P as Nt}from"./plus-O65gX7Qz.js";import{S as ft}from"./search-Dd-PeBfg.js";import{T as V}from"./trash-2-DWVnIU6o.js";import{P as Dt}from"./package-open-Bj2Cp1LK.js";import{P as Q}from"./play-0EwQQJX_.js";import{P as Ft}from"./pause-DOhduDQ5.js";import{S as Mt}from"./square-pen-B3dPIBrm.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";function tt(i){switch(i){case"success":return t.jsxs(C,{"code-path":"src/components/automation/cronJobHelpers.tsx:9:9",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:[t.jsx(lt,{"code-path":"src/components/automation/cronJobHelpers.tsx:10:11",className:"h-3 w-3 mr-1"}),"成功"]});case"failed":return t.jsxs(C,{"code-path":"src/components/automation/cronJobHelpers.tsx:16:9",variant:"outline",className:"border-red-500/30 text-red-400 bg-red-500/10",children:[t.jsx(vt,{"code-path":"src/components/automation/cronJobHelpers.tsx:17:11",className:"h-3 w-3 mr-1"}),"失败"]});case"running":return t.jsxs(C,{"code-path":"src/components/automation/cronJobHelpers.tsx:23:9",variant:"outline",className:"border-blue-500/30 text-blue-400 bg-blue-500/10 animate-pulse",children:[t.jsx(k,{"code-path":"src/components/automation/cronJobHelpers.tsx:24:11",className:"h-3 w-3 mr-1 animate-spin"}),"执行中"]});default:return t.jsx(C,{"code-path":"src/components/automation/cronJobHelpers.tsx:30:9",variant:"outline",className:"border-[var(--dg-border)] text-[var(--dg-text-muted)]",children:"从未执行"})}}function wt(i){return{"0 2 * * *":"每天 02:00","0 3 * * 0":"每周日 03:00","*/5 * * * *":"每 5 分钟","0 * * * *":"每小时","0 9 * * 1":"每周一 09:00"}[i]||i}const q=[{value:"shell",label:"Shell 脚本",desc:"关联脚本库中的 Shell 脚本"},{value:"python",label:"Python 脚本",desc:"关联脚本库中的 Python 脚本"},{value:"command",label:"自定义命令",desc:"手动输入命令或脚本路径"}];function St({open:i,onOpenChange:g,editJob:s,onSuccess:D}){const[a,m]=n.useState({name:"",description:"",cron_expr:"",type:"shell",content:"",script_id:null}),[h,v]=n.useState([]),[r,d]=n.useState(null),[S,F]=n.useState(!1);n.useEffect(()=>{i&&($.getScripts({page_size:200}).then(e=>{v(e?.list||[])}).catch(()=>v([])),s?(m({name:s.name||"",description:s.description||"",cron_expr:s.cron_expr||"",type:s.type||"shell",content:s.content||"",script_id:s.script_id||null}),s.script_id?$.getScript(s.script_id).then(e=>{d(e)}).catch(()=>d(null)):d(null)):(m({name:"",description:"",cron_expr:"",type:"shell",content:"",script_id:null}),d(null)))},[i,s]);const M=a.type==="shell"||a.type==="python"?h.filter(e=>e.type===a.type):[],E=e=>{const x=h.find(j=>String(j.id)===e);x&&(d(x),m(j=>({...j,script_id:x.id,content:x.content})))},T=e=>{m(x=>({...x,type:e,script_id:null,content:e==="command"?x.content:""})),d(null)},H=async()=>{if(!a.name||!a.cron_expr){l.error("请填写任务名称和 Cron 表达式");return}if((a.type==="shell"||a.type==="python")&&!a.script_id){l.error("请选择关联的脚本");return}try{F(!0);const e={name:a.name,description:a.description,cron_expr:a.cron_expr,type:a.type,content:a.content,script_id:a.script_id};s?(await y.updateJob(s.id,e),l.success("任务更新成功")):(await y.createJob(e),l.success("任务创建成功")),g(!1),D()}catch(e){console.error("Failed to save cron job:",e),l.error(s?"更新失败":"创建失败")}finally{F(!1)}};return t.jsx(X,{"code-path":"src/components/automation/CronJobFormDialog.tsx:149:5",open:i,onOpenChange:g,children:t.jsxs(G,{"code-path":"src/components/automation/CronJobFormDialog.tsx:150:7",className:"max-w-2xl bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]",children:[t.jsxs(K,{"code-path":"src/components/automation/CronJobFormDialog.tsx:151:9",children:[t.jsx(U,{"code-path":"src/components/automation/CronJobFormDialog.tsx:152:11",children:s?"编辑定时任务":"新建定时任务"}),t.jsx(W,{"code-path":"src/components/automation/CronJobFormDialog.tsx:153:11",className:"text-[var(--dg-text-secondary)]",children:"配置 Cron 定时任务"})]}),t.jsxs("div",{"code-path":"src/components/automation/CronJobFormDialog.tsx:155:Line truncated
|
||||
`).length," 行"]})]}),t.jsx("pre",{"code-path":"src/components/automation/CronJobFormDialog.tsx:275:19",className:"max-h-48 overflow-auto rounded-md bg-[var(--dg-bg-tertiary)] border border-[var(--dg-border)] p-3 text-xs font-mono text-[var(--dg-text-secondary)] whitespace-pre-wrap break-all",children:r.content||"(空脚本)"})]})]}):t.jsxs("div",{"code-path":"src/components/automation/CronJobFormDialog.tsx:282:13",children:[t.jsx(N,{"code-path":"src/components/automation/CronJobFormDialog.tsx:283:15",className:"text-[var(--dg-text-primary)]",children:"执行命令"}),t.jsx(A,{"code-path":"src/components/automation/CronJobFormDialog.tsx:284:15",value:a.content,onChange:e=>m({...a,content:e.target.value}),placeholder:"/scripts/backup.sh arg1 arg2",rows:4,className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] mt-1 font-mono"})]})]}),t.jsxs(mt,{"code-path":"src/components/automation/CronJobFormDialog.tsx:294:9",children:[t.jsx(p,{"code-path":"src/components/automation/CronJobFormDialog.tsx:295:11",variant:"outline",onClick:()=>g(!1),className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)]",children:"取消"}),t.jsx(p,{"code-path":"src/components/automation/CronJobFormDialog.tsx:298:11",className:"bg-blue-600 hover:bg-blue-700",onClick:H,disabled:S,children:S?"保存中...":s?"保存修改":"创建任务"})]})]})})}function Et({open:i,onOpenChange:g}){const[s,D]=n.useState([]),[a,m]=n.useState(!1),[h,v]=n.useState(null);return n.useEffect(()=>{if(!i)return;(async()=>{try{m(!0);const d=await bt.getExecutions({task_type:"cron",page_size:50});D(d.list||[])}catch(d){console.error("Failed to load executions:",d)}finally{m(!1)}})()},[i]),t.jsx(X,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:51:5",open:i,onOpenChange:g,children:t.jsxs(G,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:52:7",className:"max-w-4xl bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] max-h-[85vh] overflow-y-auto",children:[t.jsxs(K,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:53:9",children:[t.jsx(U,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:54:11",children:"执行历史"}),t.jsx(W,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:55:11",className:"text-[var(--dg-text-secondary)]",children:"定时任务执行记录与输出日志"})]}),t.jsx("div",{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:57:9",className:"mt-4",children:a?t.jsx("div",{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:59:13",className:"flex items-center justify-center py-8",children:t.jsx(k,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:60:15",className:"h-6 w-6 text-[var(--dg-text-secondary)] animate-spin"})}):s.length===0?t.jsxs("div",{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:63:13",className:"flex flex-col items-center justify-center py-12 text-[var(--dg-text-secondary)]",children:[t.jsx(Z,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:64:15",className:"h-10 w-10 mb-3 opacity-40"}),t.jsx("p",{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:65:15",className:"text-sm",children:"暂无执行记录"})]}):t.jsxs(yt,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:68:13",children:[t.jsx(Ct,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:69:15",children:t.jsxs(P,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:70:17",className:"border-[var(--dg-border)]",children:[t.jsx(w,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:71:19",className:"text-[var(--dg-text-secondary)]",children:"任务"}),t.jsx(w,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:72:19",className:"text-[var(--dg-text-secondary)]",children:"状态"}),t.jsx(w,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:73:19",className:"text-[var(--dg-text-secondary)]",children:"耗时"}),t.jsx(w,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:74:19",className:"text-[var(--dg-text-secondary)]",children:"执行时间"}),t.jsx(w,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:75:19",className:"text-[var(--dg-text-secondary)]",children:"输出"})]})}),t.jsx(jt,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:78:15",children:s.map(r=>t.jsxs(n.Fragment,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:80:19",children:[t.jsxs(P,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:81:21",className:"border-[var(--dg-border)] cursor-pointer hover:bg-[var(--dg-bg-hover)]/50",onClick:()=>v(h===r.id?null:r.id),children:[t.jsx(f,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:82:23",className:"text-[var(--dg-text-primary)]",children:r.task_name}),t.jsx(f,{"code-path":"src/components/automation/ExecutionHistoryDialog.tsx:83:
Line truncated
|
||||
@@ -0,0 +1,4 @@
|
||||
import{a7 as B,a3 as m,aT as tt,r as A,j as s,p as at,A as Dt,a0 as u,z as Nt,m as ie,B as se,a5 as st,T as rt,t as $e,al as Fe,S as ot,s as Me,C as Ct}from"./index-Dmami9WE.js";import{d as he}from"./dashboard-BHNKEvkq.js";import{s as kt}from"./server-3HmnhxQB.js";import{k as Rt}from"./kubernetes-D2-GnE0t.js";import{S as At}from"./stat-strip-BteRU1Iu.js";import{C as K,b as U,c as z,d as V,a as W}from"./card-CIfC-8Rh.js";import{B as L}from"./badge-3UzCvU7L.js";import{H as wt}from"./hard-drive-DmC04Y5r.js";import{b as C,r as nt,s as St,t as ct,v as Ot,n as X,w as Ee,x as I,L as T,y as dt,z as Te,E as it,D as Pt,c as _t,e as ae,o as J,S as Et,A as Tt,F as Lt,d as Be,j as It,i as Q,l as $t,u as Ft,G as Mt,H as me,I as Bt,a as lt,J as Kt,K as pe,M as Ke,g as Ut,N as zt,R as Re,C as ht,X as pt,Y as mt,T as Ae,B as Vt}from"./generateCategoricalChart-ZqCvxO-S.js";import{A as Wt,a as Ne}from"./AreaChart-CrvX3B0s.js";import{B as qt}from"./BarChart-CLIO1OEu.js";import{M as Ht}from"./memory-stick-DvAvWvue.js";import{A as le}from"./arrow-right-CkKR0P0R.js";import{C as Gt}from"./circle-CGbaa1m0.js";var Zt=["points","className","baseLinePoints","connectNulls"];function ee(){return ee=Object.assign?Object.assign.bind():function(t){for(var a=1;a<arguments.length;a++){var r=arguments[a];for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e])}return t},ee.apply(this,arguments)}function Xt(t,a){if(t==null)return{};var r=Yt(t,a),e,o;if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);for(o=0;o<n.length;o++)e=n[o],!(a.indexOf(e)>=0)&&Object.prototype.propertyIsEnumerable.call(t,e)&&(r[e]=t[e])}return r}function Yt(t,a){if(t==null)return{};var r={};for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e)){if(a.indexOf(e)>=0)continue;r[e]=t[e]}return r}function Ue(t){return ta(t)||ea(t)||Qt(t)||Jt()}function Jt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
||||
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Qt(t,a){if(t){if(typeof t=="string")return we(t,a);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return we(t,a)}}function ea(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function ta(t){if(Array.isArray(t))return we(t)}function we(t,a){(a==null||a>t.length)&&(a=t.length);for(var r=0,e=new Array(a);r<a;r++)e[r]=t[r];return e}var ze=function(a){return a&&a.x===+a.x&&a.y===+a.y},aa=function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],r=[[]];return a.forEach(function(e){ze(e)?r[r.length-1].push(e):r[r.length-1].length>0&&r.push([])}),ze(a[0])&&r[r.length-1].push(a[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},ce=function(a,r){var e=aa(a);r&&(e=[e.reduce(function(n,c){return[].concat(Ue(n),Ue(c))},[])]);var o=e.map(function(n){return n.reduce(function(c,d,l){return"".concat(c).concat(l===0?"M":"L").concat(d.x,",").concat(d.y)},"")}).join("");return e.length===1?"".concat(o,"Z"):o},sa=function(a,r,e){var o=ce(a,e);return"".concat(o.slice(-1)==="Z"?o.slice(0,-1):o,"L").concat(ce(r.reverse(),e).slice(1))},ra=function(a){var r=a.points,e=a.className,o=a.baseLinePoints,n=a.connectNulls,c=Xt(a,Zt);if(!r||!r.length)return null;var d=B("recharts-polygon",e);if(o&&o.length){var l=c.stroke&&c.stroke!=="none",i=sa(r,o,n);return m.createElement("g",{className:d},m.createElement("path",ee({},C(c,!0),{fill:i.slice(-1)==="Z"?c.fill:"none",stroke:"none",d:i})),l?m.createElement("path",ee({},C(c,!0),{fill:"none",d:ce(r,n)})):null,l?m.createElement("path",ee({},C(c,!0),{fill:"none",d:ce(o,n)})):null)}var p=ce(r,n);return m.createElement("path",ee({},C(c,!0),{fill:p.slice(-1)==="Z"?c.fill:"none",className:d,d:p}))},Ce,Ve;function oa(){if(Ve)return Ce;Ve=1;var t=nt(),a=St(),r=ct();function e(o,n){return o&&o.length?t(o,r(n,2),a):void 0}return Ce=e,Ce}var na=oa();const ca=tt(na);var ke,We;function da(){if(We)return ke;We=1;var t=nt(),a=ct(),r=Ot();function e(o,n){return o&&o.length?t(o,a(n,2),r):void 0}return ke=e,ke}var ia=da();const la=tt(ia);var ha=["cx","cy","angle","ticks","axisLine"],pa=["ticks","tick","angle","tickFormatter","stroke"];function re(t){"@babel/helpers - typeof";return re=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},re(t)}function de(){return de=Object.assign?Object.assign.bind():function(t){for(var a=1;a<arguments.length;a++){var r=arguments[a];for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e])}return t},de.apply(this,arguments)}function qe(t,a){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);a&&(e=e.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),r.push.apply(r,e)}return r}function G(t){for(var a=1;a<arguments.length;a++){var r=arguments[a]!=null?arguments[a]:{};a%2?qe(Object(r),!0).forEach(function(e){ve(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):qe(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function He(t,a){if(t==null)return{};var r=ma(t,a),e,o;if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);for(o=0;o<n.length;o++)e=n[o],!(a.indexOf(e)>=0)&&Object.prototype.propertyIsEnumerable.call(t,e)&&(r[e]=t[e])}return r}function ma(t,a){if(t==null)return{};var r={};for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e)){if(a.indexOf(e)>=0)continue;r[e]=t[e]}return r}function ua(t,a){if(!(t instanceof a))throw new TypeError("Cannot call a class as a function")}function Ge(t,a){for(var r=0;r<a.length;r++){var e=a[r];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,xt(e.key),e)}}function xa(t,a,r){return a&&Ge(t.prototype,a),r&&Ge(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function ba(t,a,r){return a=be(a),fa(t,ut()?Reflect.construct(a,r||[],be(t).constructor):a.apply(t,r))}function fa(t,a){if(a&&(re(a)==="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ga(t)}function ga(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function ut(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ut=function(){return!!t})()}function be(t){return be=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},be(t)}function va(t,a){if(typeof a!="function"&&a!==null)throw new TypeError("Supe
Line truncated
|
||||
the props "valueKey" will be deprecated in 1.1.0`),y="value"):ae(i)&&(Ke(!1,`Use "dataKey" to specify the value of pie,
|
||||
the props "valueKey" will be deprecated in 1.1.0`),y=x);var j=o.filter(function(D){return J(D,y,0)!==0}).length,k=(v>=360?j:j-1)*l,S=v-j*N-k,w=o.reduce(function(D,M){var O=J(M,y,0);return D+(Q(O)?O:0)},0),_;if(w>0){var F;_=o.map(function(D,M){var O=J(D,y,0),q=J(D,p,M),H=(Q(O)?O:0)/w,E;M?E=F.endAngle+me(h)*l*(O!==0?1:0):E=c;var R=E+me(h)*((O!==0?N:0)+H*S),Le=(E+R)/2,Ie=(f.innerRadius+f.outerRadius)/2,yt=[{name:q,value:O,payload:D,dataKey:y,type:b}],jt=I(f.cx,f.cy,Ie,Le);return F=g(g(g({percent:H,cornerRadius:n,name:q,tooltipPayload:yt,midAngle:Le,middleRadius:Ie,tooltipPosition:jt},D),f),{},{value:J(D,y),startAngle:E,endAngle:R,payload:D,paddingAngle:me(h)*l}),F})}return g(g({},f),{},{sectors:_,data:o})});var Ia=Ut({chartName:"PieChart",GraphicalChild:$,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:De},{axisType:"radiusAxis",AxisComp:ye}],formatAxisMap:zt,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});const $a={阿里云:"#ff6a00",aliyun:"#ff6a00",AWS:"#ff9900",aws:"#ff9900",腾讯云:"#006eff",tencent:"#006eff",华为云:"#ff0000",huawei:"#ff0000",Azure:"#0078d4",azure:"#0078d4"},et=["#ff6a00","#ff9900","#006eff","#ff0000","#0078d4","#10b981","#a855f7","#ec4899"];function Fa(t){if(!t||t.length<2)return{pct:0,label:"暂无数据",direction:"neutral"};const a=Number(t[t.length-1].cost??0),r=Number(t[t.length-2].cost??0);if(r===0)return{pct:0,label:a>0?"新增费用":"持平",direction:"neutral"};const e=(a-r)/r*100,o=e>.05?"up":e<-.05?"down":"neutral",n=`${e>0?"+":""}${e.toFixed(1)}% 较上月`;return{pct:e,label:n,direction:o}}function Ma(t,a,r,e=24){const o=[];for(let n=e-1;n>=0;n--){const c=new Date(Date.now()-n*60*60*1e3);o.push({time:`${c.getHours().toString().padStart(2,"0")}:00`,cpu:Number(Math.max(0,Math.min(100,t+(Math.random()-.5)*15)).toFixed(1)),memory:Number(Math.max(0,Math.min(100,a+(Math.random()-.5)*10)).toFixed(1)),disk:Number(Math.max(0,Math.min(100,r+(Math.random()-.5)*5)).toFixed(1))})}return o}function Ba(t,a){if(!t||t.length===0)return[];const r={};for(const e of t){const o=e.timestamp;if(!o)continue;const c=`${new Date(o).getHours().toString().padStart(2,"0")}:00`;r[c]||(r[c]={}),e.name==="cpu"&&(r[c].cpu=Number(e.value)||0),e.name==="memory"&&(r[c].memory=Number(e.value)||0)}return Object.entries(r).sort((e,o)=>e[0].localeCompare(o[0])).map(([e,o])=>({time:e,cpu:Number((o.cpu??0).toFixed(1)),memory:Number((o.memory??0).toFixed(1)),disk:Number(a.toFixed(1))}))}function _e({active:t,payload:a,label:r}){return!t||!a?null:s.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:94:5",className:"chart-tooltip px-3 py-2",children:[s.jsx("p",{"code-path":"src/components/dashboard/DashboardCharts.tsx:95:7",className:"text-xs font-medium mb-1.5",style:{color:"var(--dg-text-secondary)"},children:r}),a.map((e,o)=>s.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:97:9",className:"flex items-center gap-2 text-xs",children:[s.jsx("span",{"code-path":"src/components/dashboard/DashboardCharts.tsx:98:11",className:"w-2 h-2 rounded-full",style:{backgroundColor:e.color}}),s.jsxs("span",{"code-path":"src/components/dashboard/DashboardCharts.tsx:99:11",style:{color:"var(--dg-text-muted)"},children:[e.name,":"]}),s.jsx("span",{"code-path":"src/components/dashboard/DashboardCharts.tsx:100:11",className:"font-medium",style:{color:"var(--dg-text-primary)"},children:typeof e.value=="number"?`${e.value}%`:e.value})]},o))]})}function Ka({costStats:t}){const a=t?.cloud_costs??[],r=t?.month_trend??[],e=a.map((d,l)=>({name:d.cloud,value:d.cost,color:$a[d.cloud]||et[l%et.length]})),o=r.map(d=>({month:d.month,cost:d.cost})),n=t?.total_cost??e.reduce((d,l)=>d+l.value,0),c=Fa(r);return s.jsxs(K,{"code-path":"src/components/dashboard/DashboardCharts.tsx:123:5",className:"dg-card dg-card-hover",children:[s.jsx(U,{"code-path":"src/components/dashboard/DashboardCharts.tsx:124:7",className:"pb-2",children:s.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:125:9",className:"flex items-center justify-between",children:[s.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:126:11",children:[s.jsx(z,{"code-path":"src/components/dashboard/DashboardCharts.tsx:127:13",className:"text-[var(--dg-text-primary)]",children:"云成本概览"}),s.jsx(V,{"code-path":"src/components/dashboard/DashboardCharts.tsx:128:13",className:"text-[var(--dg-text-muted)]",children:"本月各云平台费用支出"})]}),s.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:130:11",className:"text-right",children:[s.jsxs("p",{"code-path":"src/components/dashboard/DashboardCharts.tsx:131:13",className:"text-2xl font-bold text-[var(--dg-text-primary)] tracking-tight",children:["¥",Number(n).toLocaleString()]}),s.jsx("p",{"code-path":"src/components/dashboard/DashboardCharts.tsx:134:13",className:u("text-xs
Line truncated
|
||||
@@ -1,4 +0,0 @@
|
||||
import{g as kt,j as t,X as m,ab as U,_ as x,aU as rt,r as A,o as ot,A as wt,G as Rt,k as le,B as se,a2 as nt,T as ct,t as Be,a7 as Ke,q as Ae,s as Se,x as At,J as St}from"./index-DfyorCky.js";import{d as pe}from"./dashboard-BjQPIG2G.js";import{s as Ot}from"./server-CjDPBaTN.js";import{k as _t}from"./kubernetes-J8O09fK7.js";import{C as I,a as F,b as z,c as V,d as q}from"./card-C55cvSHg.js";import{T as Pt}from"./trending-up-CdusV6gc.js";import{T as Et}from"./trending-down-BGTWG_dA.js";import{M as Tt}from"./minus-UVrx3jLc.js";import{B as $}from"./badge-xNW8x0G1.js";import{H as Lt}from"./hard-drive-BbPmnARR.js";import{b as C,r as dt,s as $t,t as it,v as It,n as Z,w as Ie,x as B,L,y as lt,z as Fe,E as ht,D as Ft,c as Mt,e as ae,o as Y,S as Bt,A as Kt,F as Ut,d as Ue,j as zt,i as Q,l as Vt,u as qt,G as Ht,H as ue,I as Wt,a as pt,J as Gt,K as me,M as ze,g as Zt,N as Xt,R as Oe,C as mt,X as xt,Y as ut,T as _e,B as Jt}from"./generateCategoricalChart-6v9BPbG2.js";import{A as Yt,a as ke}from"./AreaChart-B2zlWfdX.js";import{B as Qt}from"./BarChart-DlFprovY.js";import{M as ea}from"./memory-stick-QMV-0CnU.js";import{A as he}from"./arrow-right-DyIltvNZ.js";import{C as ta}from"./circle-DOZr6_68.js";const aa=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],sa=kt("dollar-sign",aa),Ve={blue:{bg:"bg-[var(--dg-blue)]/10",icon:"text-[var(--dg-blue)]",glow:"shadow-[var(--dg-blue)]/10"},emerald:{bg:"bg-[var(--dg-green)]/10",icon:"text-[var(--dg-green)]",glow:"shadow-[var(--dg-green)]/10"},amber:{bg:"bg-[var(--dg-yellow)]/10",icon:"text-[var(--dg-yellow)]",glow:"shadow-[var(--dg-yellow)]/10"},rose:{bg:"bg-[var(--dg-red)]/10",icon:"text-[var(--dg-red)]",glow:"shadow-[var(--dg-red)]/10"},purple:{bg:"bg-[var(--dg-purple)]/10",icon:"text-[var(--dg-purple)]",glow:"shadow-[var(--dg-purple)]/10"},cyan:{bg:"bg-[var(--dg-cyan)]/10",icon:"text-[var(--dg-cyan)]",glow:"shadow-[var(--dg-cyan)]/10"},orange:{bg:"bg-[var(--dg-orange)]/10",icon:"text-[var(--dg-orange)]",glow:"shadow-[var(--dg-orange)]/10"}};function xe({title:a,value:s,description:r,icon:e,trend:o,trendValue:n,color:c,onClick:d,loading:l=!1}){const i=Ve[c]||Ve.blue;if(l)return t.jsx(I,{"code-path":"src/components/dashboard/DashboardStats.tsx:53:7",className:"dg-card overflow-hidden",children:t.jsxs(F,{"code-path":"src/components/dashboard/DashboardStats.tsx:54:9",className:"p-6 space-y-4",children:[t.jsxs("div",{"code-path":"src/components/dashboard/DashboardStats.tsx:55:11",className:"flex items-start justify-between",children:[t.jsxs("div",{"code-path":"src/components/dashboard/DashboardStats.tsx:56:13",className:"space-y-3 flex-1",children:[t.jsx("div",{"code-path":"src/components/dashboard/DashboardStats.tsx:57:15",className:"dg-skeleton h-4 w-24 rounded"}),t.jsx("div",{"code-path":"src/components/dashboard/DashboardStats.tsx:58:15",className:"dg-skeleton h-8 w-16 rounded"})]}),t.jsx("div",{"code-path":"src/components/dashboard/DashboardStats.tsx:60:13",className:"dg-skeleton h-10 w-10 rounded-lg"})]}),t.jsx("div",{"code-path":"src/components/dashboard/DashboardStats.tsx:62:11",className:"dg-skeleton h-3 w-32 rounded"})]})});const p=o==="up"?Pt:o==="down"?Et:Tt,u=o==="up"?"text-[var(--dg-green)]":o==="down"?"text-[var(--dg-red)]":"text-[var(--dg-text-muted)]";return t.jsx(I,{"code-path":"src/components/dashboard/DashboardStats.tsx:76:5",className:m("dg-card dg-card-hover cursor-pointer overflow-hidden",d&&"cursor-pointer"),onClick:d,children:t.jsx(F,{"code-path":"src/components/dashboard/DashboardStats.tsx:83:7",className:"p-6",children:t.jsxs("div",{"code-path":"src/components/dashboard/DashboardStats.tsx:84:9",className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{"code-path":"src/components/dashboard/DashboardStats.tsx:85:11",className:"space-y-3 min-w-0 flex-1",children:[t.jsx("p",{"code-path":"src/components/dashboard/DashboardStats.tsx:86:13",className:"text-sm font-medium text-[var(--dg-text-secondary)] truncate",children:a}),t.jsxs("div",{"code-path":"src/components/dashboard/DashboardStats.tsx:89:13",className:"flex items-baseline gap-2 flex-wrap",children:[t.jsx("h3",{"code-path":"src/components/dashboard/DashboardStats.tsx:90:15",className:"text-2xl font-bold text-[var(--dg-text-primary)] tracking-tight",children:s}),o&&n&&t.jsxs("span",{"code-path":"src/components/dashboard/DashboardStats.tsx:94:17",className:m("flex items-center text-xs font-semibold gap-0.5",u),children:[t.jsx(p,{"code-path":"src/components/dashboard/DashboardStats.tsx:95:19",className:"h-3.5 w-3.5"}),n]})]}),r&&t.jsx("p",{"code-path":"src/components/dashboard/DashboardStats.tsx:101:15",className:"text-xs text-[var(--dg-text-muted)]",children:r})]}),t.jsx("div",{"code-path":"src/components/dashboard/DashboardStats.tsx:104:11",className:m("p-3 rounded-xl flex-shrink-0",i.bg,i.icon),children:t.jsx(e,{"code-path":"src/components/dashboard/DashboardStats.tsx:111:13",className:"h-5 w-5"})})]})})})Line truncated
|
||||
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function da(a,s){if(a){if(typeof a=="string")return Pe(a,s);var r=Object.prototype.toString.call(a).slice(8,-1);if(r==="Object"&&a.constructor&&(r=a.constructor.name),r==="Map"||r==="Set")return Array.from(a);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Pe(a,s)}}function ia(a){if(typeof Symbol<"u"&&a[Symbol.iterator]!=null||a["@@iterator"]!=null)return Array.from(a)}function la(a){if(Array.isArray(a))return Pe(a)}function Pe(a,s){(s==null||s>a.length)&&(s=a.length);for(var r=0,e=new Array(s);r<s;r++)e[r]=a[r];return e}var He=function(s){return s&&s.x===+s.x&&s.y===+s.y},ha=function(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],r=[[]];return s.forEach(function(e){He(e)?r[r.length-1].push(e):r[r.length-1].length>0&&r.push([])}),He(s[0])&&r[r.length-1].push(s[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},de=function(s,r){var e=ha(s);r&&(e=[e.reduce(function(n,c){return[].concat(qe(n),qe(c))},[])]);var o=e.map(function(n){return n.reduce(function(c,d,l){return"".concat(c).concat(l===0?"M":"L").concat(d.x,",").concat(d.y)},"")}).join("");return e.length===1?"".concat(o,"Z"):o},pa=function(s,r,e){var o=de(s,e);return"".concat(o.slice(-1)==="Z"?o.slice(0,-1):o,"L").concat(de(r.reverse(),e).slice(1))},ma=function(s){var r=s.points,e=s.className,o=s.baseLinePoints,n=s.connectNulls,c=oa(s,ra);if(!r||!r.length)return null;var d=U("recharts-polygon",e);if(o&&o.length){var l=c.stroke&&c.stroke!=="none",i=pa(r,o,n);return x.createElement("g",{className:d},x.createElement("path",ee({},C(c,!0),{fill:i.slice(-1)==="Z"?c.fill:"none",stroke:"none",d:i})),l?x.createElement("path",ee({},C(c,!0),{fill:"none",d:de(r,n)})):null,l?x.createElement("path",ee({},C(c,!0),{fill:"none",d:de(o,n)})):null)}var p=de(r,n);return x.createElement("path",ee({},C(c,!0),{fill:p.slice(-1)==="Z"?c.fill:"none",className:d,d:p}))},we,We;function xa(){if(We)return we;We=1;var a=dt(),s=$t(),r=it();function e(o,n){return o&&o.length?a(o,r(n,2),s):void 0}return we=e,we}var ua=xa();const ba=rt(ua);var Re,Ge;function fa(){if(Ge)return Re;Ge=1;var a=dt(),s=it(),r=It();function e(o,n){return o&&o.length?a(o,s(n,2),r):void 0}return Re=e,Re}var ga=fa();const va=rt(ga);var ya=["cx","cy","angle","ticks","axisLine"],ja=["ticks","tick","angle","tickFormatter","stroke"];function re(a){"@babel/helpers - typeof";return re=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},re(a)}function ie(){return ie=Object.assign?Object.assign.bind():function(a){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(a[e]=r[e])}return a},ie.apply(this,arguments)}function Ze(a,s){var r=Object.keys(a);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(a);s&&(e=e.filter(function(o){return Object.getOwnPropertyDescriptor(a,o).enumerable})),r.push.apply(r,e)}return r}function W(a){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Ze(Object(r),!0).forEach(function(e){je(a,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(r)):Ze(Object(r)).forEach(function(e){Object.defineProperty(a,e,Object.getOwnPropertyDescriptor(r,e))})}return a}function Xe(a,s){if(a==null)return{};var r=Da(a,s),e,o;if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(a);for(o=0;o<n.length;o++)e=n[o],!(s.indexOf(e)>=0)&&Object.prototype.propertyIsEnumerable.call(a,e)&&(r[e]=a[e])}return r}function Da(a,s){if(a==null)return{};var r={};for(var e in a)if(Object.prototype.hasOwnProperty.call(a,e)){if(s.indexOf(e)>=0)continue;r[e]=a[e]}return r}function Na(a,s){if(!(a instanceof s))throw new TypeError("Cannot call a class as a function")}function Je(a,s){for(var r=0;r<s.length;r++){var e=s[r];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,ft(e.key),e)}}function Ca(a,s,r){return s&&Je(a.prototype,s),r&&Je(a,r),Object.defineProperty(a,"prototype",{writable:!1}),a}function ka(a,s,r){return s=ge(s),wa(a,bt()?Reflect.construct(s,r||[],ge(a).constructor):s.apply(a,r))}function wa(a,s){if(s&&(re(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ra(a)}function Ra(a){if(a===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function bt(){try{var a=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(bt=function(){return!!a})()}function ge(a){return ge=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ge(a)}function Aa(a,s){if(typeof s!="function"&&s!==null)throw new TypeError("Supe
Line truncated
|
||||
the props "valueKey" will be deprecated in 1.1.0`),y="value"):ae(i)&&(ze(!1,`Use "dataKey" to specify the value of pie,
|
||||
the props "valueKey" will be deprecated in 1.1.0`),y=u);var j=o.filter(function(N){return Y(N,y,0)!==0}).length,k=(v>=360?j:j-1)*l,w=v-j*D-k,S=o.reduce(function(N,O){var P=Y(O,y,0);return N+(Q(P)?P:0)},0),_;if(S>0){var M;_=o.map(function(N,O){var P=Y(N,y,0),J=Y(N,p,O),H=(Q(P)?P:0)/S,T;O?T=M.endAngle+ue(h)*l*(P!==0?1:0):T=c;var ce=T+ue(h)*((P!==0?D:0)+H*w),R=(T+ce)/2,Me=(f.innerRadius+f.outerRadius)/2,Nt=[{name:J,value:P,payload:N,dataKey:y,type:b}],Ct=B(f.cx,f.cy,Me,R);return M=g(g(g({percent:H,cornerRadius:n,name:J,tooltipPayload:Nt,midAngle:R,middleRadius:Me,tooltipPosition:Ct},N),f),{},{value:Y(N,y),startAngle:T,endAngle:ce,payload:N,paddingAngle:ue(h)*l}),M})}return g(g({},f),{},{sectors:_,data:o})});var qa=Zt({chartName:"PieChart",GraphicalChild:K,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:Ce},{axisType:"radiusAxis",AxisComp:De}],formatAxisMap:Xt,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});const Ha={阿里云:"#ff6a00",aliyun:"#ff6a00",AWS:"#ff9900",aws:"#ff9900",腾讯云:"#006eff",tencent:"#006eff",华为云:"#ff0000",huawei:"#ff0000",Azure:"#0078d4",azure:"#0078d4"},st=["#ff6a00","#ff9900","#006eff","#ff0000","#0078d4","#10b981","#a855f7","#ec4899"];function Dt(a){if(!a||a.length<2)return{pct:0,label:"暂无数据",direction:"neutral"};const s=Number(a[a.length-1].cost??0),r=Number(a[a.length-2].cost??0);if(r===0)return{pct:0,label:s>0?"新增费用":"持平",direction:"neutral"};const e=(s-r)/r*100,o=e>.05?"up":e<-.05?"down":"neutral",n=`${e>0?"+":""}${e.toFixed(1)}% 较上月`;return{pct:e,label:n,direction:o}}function Wa(a,s,r,e=24){const o=[];for(let n=e-1;n>=0;n--){const c=new Date(Date.now()-n*60*60*1e3);o.push({time:`${c.getHours().toString().padStart(2,"0")}:00`,cpu:Number(Math.max(0,Math.min(100,a+(Math.random()-.5)*15)).toFixed(1)),memory:Number(Math.max(0,Math.min(100,s+(Math.random()-.5)*10)).toFixed(1)),disk:Number(Math.max(0,Math.min(100,r+(Math.random()-.5)*5)).toFixed(1))})}return o}function Ga(a,s){if(!a||a.length===0)return[];const r={};for(const e of a){const o=e.timestamp;if(!o)continue;const c=`${new Date(o).getHours().toString().padStart(2,"0")}:00`;r[c]||(r[c]={}),e.name==="cpu"&&(r[c].cpu=Number(e.value)||0),e.name==="memory"&&(r[c].memory=Number(e.value)||0)}return Object.entries(r).sort((e,o)=>e[0].localeCompare(o[0])).map(([e,o])=>({time:e,cpu:Number((o.cpu??0).toFixed(1)),memory:Number((o.memory??0).toFixed(1)),disk:Number(s.toFixed(1))}))}function $e({active:a,payload:s,label:r}){return!a||!s?null:t.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:94:5",className:"chart-tooltip px-3 py-2",children:[t.jsx("p",{"code-path":"src/components/dashboard/DashboardCharts.tsx:95:7",className:"text-xs font-medium mb-1.5",style:{color:"var(--dg-text-secondary)"},children:r}),s.map((e,o)=>t.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:97:9",className:"flex items-center gap-2 text-xs",children:[t.jsx("span",{"code-path":"src/components/dashboard/DashboardCharts.tsx:98:11",className:"w-2 h-2 rounded-full",style:{backgroundColor:e.color}}),t.jsxs("span",{"code-path":"src/components/dashboard/DashboardCharts.tsx:99:11",style:{color:"var(--dg-text-muted)"},children:[e.name,":"]}),t.jsx("span",{"code-path":"src/components/dashboard/DashboardCharts.tsx:100:11",className:"font-medium",style:{color:"var(--dg-text-primary)"},children:typeof e.value=="number"?`${e.value}%`:e.value})]},o))]})}function Za({costStats:a}){const s=a?.cloud_costs??[],r=a?.month_trend??[],e=s.map((d,l)=>({name:d.cloud,value:d.cost,color:Ha[d.cloud]||st[l%st.length]})),o=r.map(d=>({month:d.month,cost:d.cost})),n=a?.total_cost??e.reduce((d,l)=>d+l.value,0),c=Dt(r);return t.jsxs(I,{"code-path":"src/components/dashboard/DashboardCharts.tsx:123:5",className:"dg-card dg-card-hover",children:[t.jsx(z,{"code-path":"src/components/dashboard/DashboardCharts.tsx:124:7",className:"pb-2",children:t.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:125:9",className:"flex items-center justify-between",children:[t.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:126:11",children:[t.jsx(V,{"code-path":"src/components/dashboard/DashboardCharts.tsx:127:13",className:"text-[var(--dg-text-primary)]",children:"云成本概览"}),t.jsx(q,{"code-path":"src/components/dashboard/DashboardCharts.tsx:128:13",className:"text-[var(--dg-text-muted)]",children:"本月各云平台费用支出"})]}),t.jsxs("div",{"code-path":"src/components/dashboard/DashboardCharts.tsx:130:11",className:"text-right",children:[t.jsxs("p",{"code-path":"src/components/dashboard/DashboardCharts.tsx:131:13",className:"text-2xl font-bold text-[var(--dg-text-primary)] tracking-tight",children:["¥",Number(n).toLocaleString()]}),t.jsx("p",{"code-path":"src/components/dashboard/DashboardCharts.tsx:134:13",className:m("text-xs
Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{i as Ze,f as he,r,j as e,B as i,z as L,Y as Ce,D as le,a as xe,b as pe,c as ge,d as be,G as De,t as je,V as F,X as ke,T as Se,C as te,y as ve,P as Te,e as Me}from"./index-Dmami9WE.js";import{T as Ae,a as ze,b as de,c as me}from"./tabs-lV44z_UR.js";import{I as u}from"./input-NsU9nXZF.js";import{B as v}from"./badge-3UzCvU7L.js";import{C as re,b as Le,c as Fe,a as oe}from"./card-CIfC-8Rh.js";import{L as c}from"./label-Ap_-SPYI.js";import{S as l}from"./switch-TqjD2x0W.js";import{S as Y,a as ee,b as ae,c as se,d as A}from"./select-DUbxjT0z.js";import{t as o}from"./index-BuEnLCjT.js";import{p as k,z}from"./monitor-CicbJUrQ.js";import{R as ce}from"./refresh-cw-CTBERyFc.js";import{P as H}from"./plus-O65gX7Qz.js";import{S as V}from"./star-DRCV7Fx2.js";import{S as Ne}from"./square-pen-B3dPIBrm.js";import{T as fe}from"./trash-2-DWVnIU6o.js";import{C as I}from"./chevron-up-Cq4GPopa.js";import{W as Ie}from"./wrench-DMCGQEzN.js";import{C as _e}from"./circle-x-BBQeW1R3.js";import{C as qe}from"./circle-check-CVbTTFQ0.js";import"./index-CtCQcvyh.js";const Ee=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],ne=Ze("plug",Ee),ie={name:"",url:"",access:"server",http_method:"POST",basic_auth:!1,basic_auth_user:"",basic_auth_pass:"",with_credentials:!1,tls_client_auth:!1,with_ca_cert:!1,ca_cert:"",skip_tls_verify:!1,custom_headers_json:"",enable_alerting:!0,alertmanager_ds:"",scrape_interval:15,query_timeout:60,disable_metrics_lookup:!1,custom_query_params:"",is_default:!1};function Oe(){const x=he(),[h,p]=r.useState([]),[B,$]=r.useState(!0),[U,g]=r.useState(!1),[b,q]=r.useState(null),[s,_]=r.useState({...ie}),[P,D]=r.useState([]),[y,E]=r.useState(!1),[,O]=r.useState(!1),[S,R]=r.useState(!1),[T,w]=r.useState(!1),[M,N]=r.useState(!1),[j,Z]=r.useState(null),m=r.useCallback(async()=>{try{const a=await k.list();p(a?.data||a||[])}catch{o.error("获取数据源列表失败")}finally{$(!1)}},[]);r.useEffect(()=>{m()},[m]);const G=()=>{q(null),_({...ie}),D([]),Z(null),E(!1),O(!1),R(!1),w(!1),g(!0)},W=a=>{q(a.id),_({name:a.name,url:a.url,access:a.access||"server",http_method:a.http_method||"POST",basic_auth:a.basic_auth||!1,basic_auth_user:a.basic_auth_user||"",basic_auth_pass:a.basic_auth_pass||"",with_credentials:a.with_credentials||!1,tls_client_auth:a.tls_client_auth||!1,with_ca_cert:a.with_ca_cert||!1,ca_cert:a.ca_cert||"",skip_tls_verify:a.skip_tls_verify||!1,custom_headers_json:a.custom_headers||"",enable_alerting:a.enable_alerting!==!1,alertmanager_ds:a.alertmanager_ds||"",scrape_interval:a.scrape_interval||15,query_timeout:a.query_timeout||60,disable_metrics_lookup:a.disable_metrics_lookup||!1,custom_query_params:a.custom_query_params||"",is_default:a.is_default||!1});try{const d=JSON.parse(a.custom_headers||"[]");D(Array.isArray(d)?d:[])}catch{D([])}Z(null),g(!0)},n=(a,d)=>{_(f=>({...f,[a]:d}))},J=()=>{D(a=>[...a,{header:"",value:""}])},t=a=>{D(d=>d.filter((f,X)=>X!==a))},C=(a,d,f)=>{D(X=>{const K=[...X];return K[a]={...K[a],[d]:f},K})},Q=async()=>{if(!s.name.trim()){o.error("请输入数据源名称");return}if(!s.url.trim()){o.error("请输入 Prometheus URL");return}const a={name:s.name.trim(),url:s.url.trim(),access:s.access,http_method:s.http_method,basic_auth:s.basic_auth,basic_auth_user:s.basic_auth_user,basic_auth_pass:s.basic_auth_pass,with_credentials:s.with_credentials,tls_client_auth:s.tls_client_auth,with_ca_cert:s.with_ca_cert,ca_cert:s.ca_cert,skip_tls_verify:s.skip_tls_verify,custom_headers:JSON.stringify(P),enable_alerting:s.enable_alerting,alertmanager_ds:s.alertmanager_ds,scrape_interval:s.scrape_interval,query_timeout:s.query_timeout,disable_metrics_lookup:s.disable_metrics_lookup,custom_query_params:s.custom_query_params,is_default:s.is_default};try{b?(await k.update(b,a),o.success("数据源更新成功")):(await k.create(a),o.success("数据源创建成功")),g(!1),m()}catch(d){o.error(d?.message||"操作失败")}},Pe=async a=>{if(await x({title:"删除数据源",description:`确定删除数据源「${a.name}」吗?此操作不可撤销。`,variant:"destructive"}))try{await k.delete(a.id),o.success("已删除"),m()}catch{o.error("删除失败")}},ye=async a=>{try{await k.setDefault(a.id),o.success(`已将「${a.name}」设为默认数据源`),m()}catch{o.error("设置失败")}},we=async()=>{if(!s.url.trim()){o.error("请先输入 URL");return}N(!0),Z(null);try{const a=await k.testConnection({url:s.url.trim(),basic_auth:s.basic_auth,basic_auth_user:s.basic_auth_user,basic_auth_pass:s.basic_auth_pass,skip_tls_verify:s.skip_tls_verify}),d=a?.data||a;Z(d)}catch(a){Z({success:!1,message:a?.message||"测试失败"})}finally{N(!1)}};return B?e.jsx("div",{"code-path":"src/components/monitor/datasource/PrometheusDatasourceManager.tsx:298:7",className:"flex items-center justify-center h-96",children:e.jsx(ce,{"code-path":"src/components/monitor/dataLine truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{g as he,a as le,r,j as e,B as i,G as L,P as Ce,D as xe,b as pe,c as ge,d as be,e as De,I as u,O as je,t as ve,a4 as F,a5 as ke,T as Se,x as te,E as Me,a3 as Te,f as Ne}from"./index-DfyorCky.js";import{T as Ae,a as ze,b as de,c as me}from"./tabs-CIh_yD4s.js";import{B as v}from"./badge-xNW8x0G1.js";import{C as re,b as Le,c as Fe,a as oe}from"./card-C55cvSHg.js";import{L as c}from"./label-BK0h2apY.js";import{S as l}from"./switch-CGiGgOnh.js";import{S as Y,a as ee,b as ae,c as se,d as A,C as I}from"./select-D5qUzdAs.js";import{t as o}from"./index-a3ybMjbR.js";import{p as k,z}from"./monitor-BAaBXIsC.js";import{R as ce}from"./refresh-cw-DUB_tAG-.js";import{P as H}from"./plus-CUG-9kpu.js";import{S as fe}from"./square-pen-BxUFAe0F.js";import{T as _e}from"./trash-2-Dx32pOzT.js";import{W as Ie}from"./wrench-KfbhOOJm.js";import{C as Pe}from"./circle-x-DK79Dhg2.js";import{C as qe}from"./circle-check-DWcXrx2k.js";import"./index-CWVNW_qu.js";const Ee=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],ne=he("plug",Ee);const Oe=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],$=he("star",Oe),ie={name:"",url:"",access:"server",http_method:"POST",basic_auth:!1,basic_auth_user:"",basic_auth_pass:"",with_credentials:!1,tls_client_auth:!1,with_ca_cert:!1,ca_cert:"",skip_tls_verify:!1,custom_headers_json:"",enable_alerting:!0,alertmanager_ds:"",scrape_interval:15,query_timeout:60,disable_metrics_lookup:!1,custom_query_params:"",is_default:!1};function Re(){const x=le(),[h,p]=r.useState([]),[B,V]=r.useState(!0),[U,g]=r.useState(!1),[b,q]=r.useState(null),[s,_]=r.useState({...ie}),[P,D]=r.useState([]),[y,E]=r.useState(!1),[,O]=r.useState(!1),[S,R]=r.useState(!1),[T,w]=r.useState(!1),[M,N]=r.useState(!1),[j,Z]=r.useState(null),m=r.useCallback(async()=>{try{const a=await k.list();p(a?.data||a||[])}catch{o.error("获取数据源列表失败")}finally{V(!1)}},[]);r.useEffect(()=>{m()},[m]);const G=()=>{q(null),_({...ie}),D([]),Z(null),E(!1),O(!1),R(!1),w(!1),g(!0)},W=a=>{q(a.id),_({name:a.name,url:a.url,access:a.access||"server",http_method:a.http_method||"POST",basic_auth:a.basic_auth||!1,basic_auth_user:a.basic_auth_user||"",basic_auth_pass:a.basic_auth_pass||"",with_credentials:a.with_credentials||!1,tls_client_auth:a.tls_client_auth||!1,with_ca_cert:a.with_ca_cert||!1,ca_cert:a.ca_cert||"",skip_tls_verify:a.skip_tls_verify||!1,custom_headers_json:a.custom_headers||"",enable_alerting:a.enable_alerting!==!1,alertmanager_ds:a.alertmanager_ds||"",scrape_interval:a.scrape_interval||15,query_timeout:a.query_timeout||60,disable_metrics_lookup:a.disable_metrics_lookup||!1,custom_query_params:a.custom_query_params||"",is_default:a.is_default||!1});try{const d=JSON.parse(a.custom_headers||"[]");D(Array.isArray(d)?d:[])}catch{D([])}Z(null),g(!0)},n=(a,d)=>{_(f=>({...f,[a]:d}))},J=()=>{D(a=>[...a,{header:"",value:""}])},t=a=>{D(d=>d.filter((f,X)=>X!==a))},C=(a,d,f)=>{D(X=>{const K=[...X];return K[a]={...K[a],[d]:f},K})},Q=async()=>{if(!s.name.trim()){o.error("请输入数据源名称");return}if(!s.url.trim()){o.error("请输入 Prometheus URL");return}const a={name:s.name.trim(),url:s.url.trim(),access:s.access,http_method:s.http_method,basic_auth:s.basic_auth,basic_auth_user:s.basic_auth_user,basic_auth_pass:s.basic_auth_pass,with_credentials:s.with_credentials,tls_client_auth:s.tls_client_auth,with_ca_cert:s.with_ca_cert,ca_cert:s.ca_cert,skip_tls_verify:s.skip_tls_verify,custom_headers:JSON.stringify(P),enable_alerting:s.enable_alerting,alertmanager_ds:s.alertmanager_ds,scrape_interval:s.scrape_interval,query_timeout:s.query_timeout,disable_metrics_lookup:s.disable_metrics_lookup,custom_query_params:s.custom_query_params,is_default:s.is_default};try{b?(await k.update(b,a),o.success("数据源更新成功")):(await k.create(a),o.success("数据源创建成功")),g(!1),m()}catch(d){o.error(d?.message||"操作失败")}},ye=async a=>{if(await x({title:"删除数据源",description:`确定删除数据源「${a.name}」吗?此操作不可撤销。`,variant:"destructive"}))try{await k.delete(a.id),o.success("已删除"),m()}catch{o.error("删除失败")}},we=async a=>{try{await k.setDefault(a.id),o.success(`已将「${a.name}」设为默认数据源`),m()}catch{o.error("设置失败")}},Ze=async()=>{if(!s.url.trim()){o.error("请先输入 URL");return}N(!0),Z(null);try{const a=await k.testConnection({url:s.url.trim(),basic_auth:s.basic_auth,basic_auth_user:s.basic_auth_user,basic_auth_pass:s.basic_auth_pass,skip_tls_verify:s.skip_tls_verify}Line truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{g as te,r as o,j as e,D as A,b as H,c as M,d as W,O as Y,v as Z,I as z,P as oe,f as ae,B as d,h as ne,L as F,a3 as le,x as ce,a4 as de,e as re,a as pe,a0 as ie}from"./index-DfyorCky.js";import{B as w}from"./badge-xNW8x0G1.js";import{T as xe,a as me,b as $,c as B}from"./tabs-CIh_yD4s.js";import{L as _}from"./label-BK0h2apY.js";import{S as K,a as X,b as q,c as J,d as E}from"./select-D5qUzdAs.js";import{t as r}from"./index-a3ybMjbR.js";import{d as i}from"./deploy-B3Sg3N1U.js";import{P as G}from"./plus-CUG-9kpu.js";import{R as ee}from"./refresh-cw-DUB_tAG-.js";import{C as ye}from"./circle-x-DK79Dhg2.js";import{D as I}from"./download-DoZfYs2h.js";import{W as he}from"./wrench-KfbhOOJm.js";import{P}from"./pencil-BqUotcjf.js";import{T as U}from"./trash-2-Dx32pOzT.js";import"./index-CWVNW_qu.js";const ge=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Ce=te("settings-2",ge);function be({open:S,onOpenChange:b,type:L,editId:n,repos:h,registries:j,onSave:m}){const c=L==="repo",[g,u]=o.useState(""),[C,f]=o.useState(""),[p,v]=o.useState(""),[y,N]=o.useState(""),[D,T]=o.useState(""),[s,l]=o.useState([]),[x,V]=o.useState(!1),t=s.filter(a=>c?!0:a.secret_type==="docker"),k=async()=>{try{const a=await ne.get("/credentials?page_size=100");l(a?.list||[])}catch{}};o.useEffect(()=>{if(k(),n)if(c){const a=h.find(R=>R.id===n);a&&(u(a.name),f(""),v(a.url),T(a.credential_id||""))}else{const a=j.find(R=>R.id===n);a&&(u(a.name),f(""),v(a.registry_url),N(a.namespace||""),T(a.credential_id||""))}else u(""),f(""),v(""),N(""),T("")},[n,S,c]);const O=async()=>{if(!g.trim()||!p.trim()){r.error("请填写名称和地址");return}V(!0);try{const a=D?Number(D):null,R=c?{name:g.trim(),description:C.trim(),url:p.trim(),credential_id:a}:{name:g.trim(),description:C.trim(),registry_url:p.trim(),namespace:y.trim(),credential_id:a};n?(c?await i.updateRepo(n,R):await i.updateRegistry(n,R),r.success("已更新")):(c?await i.createRepo(R):await i.createRegistry(R),r.success("已创建")),b(!1),m()}catch{r.error("保存失败")}finally{V(!1)}},se=c?Y:Z;return e.jsx(A,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:97:5",open:S,onOpenChange:b,children:e.jsxs(H,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:98:7",className:"sm:max-w-[480px] bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:[e.jsx(M,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:99:9",children:e.jsxs(W,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:100:11",className:"text-[var(--dg-text-primary)] flex items-center gap-2",children:[e.jsx(se,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:101:13",className:"h-5 w-5 text-[var(--dg-blue)]"}),n?"编辑":"新增",c?" Git 仓库":" 镜像仓库"]})}),e.jsxs("div",{"code-path":"src/components/deploy/CredentialFormDialog.tsx:105:9",className:"space-y-4 py-2",children:[e.jsxs("div",{"code-path":"src/components/deploy/CredentialFormDialog.tsx:106:11",className:"space-y-1",children:[e.jsx(_,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:106:38",children:"名称 *"}),e.jsx(z,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:107:13",value:g,onChange:a=>u(a.target.value),placeholder:c?"如:GitLab CE":"如:Harbor",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]}),e.jsxs("div",{"code-path":"src/components/deploy/CredentialFormDialog.tsx:108:11",className:"space-y-1",children:[e.jsx(_,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:108:38",children:c?"仓库 URL *":"Registry URL *"}),e.jsx(z,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:109:13",value:p,onChange:a=>v(a.target.value),placeholder:c?"http://10.10.10.72:9000/group/repo.git":"http://10.10.10.72",className:"font-mono text-sm bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]}),!c&&e.jsxs("div",{"code-path":"src/components/deploy/CredentialFormDialog.tsx:110:23",className:"space-y-1",children:[e.jsx(_,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:110:50",children:"默认命名空间"}),e.jsx(z,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:111:13",value:y,onChange:a=>N(a.target.value),placeholder:"如:aiops",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]}),e.jsxs("div",{"code-path":"src/components/deploy/CredentialFormDialog.tsx:114:11",className:"space-y-1",children:[e.jsxs(_,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:115:13",children:["关联凭证 ",e.jsx("span",{"code-path":"src/components/deploy/CredentialFormDialog.tsx:115:25",className:"text-xs text-[var(--dg-text-secondary)] opacity-70",children:"(认证由凭据管理统一配置)"})]}),e.jsxs(K,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:116:13",value:String(D),onValueChange:a=Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{i as te,r as o,j as e,D as A,a as H,b as M,c as W,G as J,v as Z,Y as oe,e as ae,B as d,h as ne,L as F,P as le,C as ce,V as de,d as re,f as pe,Q as ie}from"./index-Dmami9WE.js";import{I as z}from"./input-NsU9nXZF.js";import{B as w}from"./badge-3UzCvU7L.js";import{T as xe,a as me,b as O,c as B}from"./tabs-lV44z_UR.js";import{L as _}from"./label-Ap_-SPYI.js";import{S as K,a as Q,b as X,c as Y,d as E}from"./select-DUbxjT0z.js";import{t as r}from"./index-BuEnLCjT.js";import{d as i}from"./deploy-CD5bEXt-.js";import{P as G}from"./plus-O65gX7Qz.js";import{R as ee}from"./refresh-cw-CTBERyFc.js";import{C as ye}from"./circle-x-BBQeW1R3.js";import{D as I}from"./download-Vuij9wGr.js";import{W as he}from"./wrench-DMCGQEzN.js";import{P}from"./pencil-BYahlvYT.js";import{T as U}from"./trash-2-DWVnIU6o.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";const ge=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Ce=te("settings-2",ge);function be({open:S,onOpenChange:b,type:L,editId:n,repos:h,registries:j,onSave:m}){const c=L==="repo",[g,u]=o.useState(""),[C,f]=o.useState(""),[p,v]=o.useState(""),[y,N]=o.useState(""),[D,T]=o.useState(""),[s,l]=o.useState([]),[x,V]=o.useState(!1),t=s.filter(a=>c?!0:a.secret_type==="docker"),k=async()=>{try{const a=await ne.get("/credentials?page_size=100");l(a?.list||[])}catch{}};o.useEffect(()=>{if(k(),n)if(c){const a=h.find(R=>R.id===n);a&&(u(a.name),f(""),v(a.url),T(a.credential_id||""))}else{const a=j.find(R=>R.id===n);a&&(u(a.name),f(""),v(a.registry_url),N(a.namespace||""),T(a.credential_id||""))}else u(""),f(""),v(""),N(""),T("")},[n,S,c]);const $=async()=>{if(!g.trim()||!p.trim()){r.error("请填写名称和地址");return}V(!0);try{const a=D?Number(D):null,R=c?{name:g.trim(),description:C.trim(),url:p.trim(),credential_id:a}:{name:g.trim(),description:C.trim(),registry_url:p.trim(),namespace:y.trim(),credential_id:a};n?(c?await i.updateRepo(n,R):await i.updateRegistry(n,R),r.success("已更新")):(c?await i.createRepo(R):await i.createRegistry(R),r.success("已创建")),b(!1),m()}catch{r.error("保存失败")}finally{V(!1)}},se=c?J:Z;return e.jsx(A,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:97:5",open:S,onOpenChange:b,children:e.jsxs(H,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:98:7",className:"sm:max-w-[480px] bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:[e.jsx(M,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:99:9",children:e.jsxs(W,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:100:11",className:"text-[var(--dg-text-primary)] flex items-center gap-2",children:[e.jsx(se,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:101:13",className:"h-5 w-5 text-[var(--dg-blue)]"}),n?"编辑":"新增",c?" Git 仓库":" 镜像仓库"]})}),e.jsxs("div",{"code-path":"src/components/deploy/CredentialFormDialog.tsx:105:9",className:"space-y-4 py-2",children:[e.jsxs("div",{"code-path":"src/components/deploy/CredentialFormDialog.tsx:106:11",className:"space-y-1",children:[e.jsx(_,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:106:38",children:"名称 *"}),e.jsx(z,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:107:13",value:g,onChange:a=>u(a.target.value),placeholder:c?"如:GitLab CE":"如:Harbor",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]}),e.jsxs("div",{"code-path":"src/components/deploy/CredentialFormDialog.tsx:108:11",className:"space-y-1",children:[e.jsx(_,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:108:38",children:c?"仓库 URL *":"Registry URL *"}),e.jsx(z,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:109:13",value:p,onChange:a=>v(a.target.value),placeholder:c?"http://10.10.10.72:9000/group/repo.git":"http://10.10.10.72",className:"font-mono text-sm bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]}),!c&&e.jsxs("div",{"code-path":"src/components/deploy/CredentialFormDialog.tsx:110:23",className:"space-y-1",children:[e.jsx(_,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:110:50",children:"默认命名空间"}),e.jsx(z,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:111:13",value:y,onChange:a=>N(a.target.value),placeholder:"如:aiops",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]"})]}),e.jsxs("div",{"code-path":"src/components/deploy/CredentialFormDialog.tsx:114:11",className:"space-y-1",children:[e.jsxs(_,{"code-path":"src/components/deploy/CredentialFormDialog.tsx:115:13",children:["关联凭证 ",e.jsx("span",{"code-path":"src/components/deploy/CredentialFormDialog.tsx:115:25",className:"text-xs text-[var(--dg-text-secondary)] opacity-70",children:"(认证由凭据管理统一配置)"})]}),e.jsxs(K,{"code-path":"src/components/deploy/CrLine truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{i as Ne,r as o,f as ve,j as e,L as M,t as ae,B as a,Q as D,K as fe,X as pe,W as we,u as be}from"./index-Dmami9WE.js";import{C as g,a as N}from"./card-CIfC-8Rh.js";import{I as h}from"./input-NsU9nXZF.js";import{B as x}from"./badge-3UzCvU7L.js";import{S as v,a as f,b as w,c as b,d as r}from"./select-DUbxjT0z.js";import{L as i}from"./label-Ap_-SPYI.js";import{t as c}from"./index-BuEnLCjT.js";import{d as m,p as Se}from"./deploy-CD5bEXt-.js";import{P as le}from"./plus-O65gX7Qz.js";import{S as ne}from"./save-YtnrpTd8.js";import{T as ke}from"./trash-2-DWVnIU6o.js";import{U as de}from"./user-plus-DKeca2Dx.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";const Ie=[["path",{d:"M17 3v10",key:"15fgeh"}],["path",{d:"m12.67 5.5 8.66 5",key:"1gpheq"}],["path",{d:"m12.67 10.5 8.66-5",key:"1dkfa6"}],["path",{d:"M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z",key:"swwfx4"}]],re=Ne("regex",Ie);function Ke(){const[l,me]=o.useState([]),[xe,T]=o.useState(!0),[S,A]=o.useState(!1),[y,ie]=o.useState([]),[n,k]=o.useState(null),[F,ye]=o.useState([]),[I,_]=o.useState([]),[p,he]=o.useState(""),[j,q]=o.useState(""),[G,H]=o.useState(!1),[J,z]=o.useState(!1),[P,K]=o.useState(""),[E,Q]=o.useState(""),[C,W]=o.useState(""),[X,O]=o.useState("editor"),[Y,Z]=o.useState(""),[Ce,U]=o.useState(null),[L,ee]=o.useState(""),[se,te]=o.useState(""),Re=ve(),R=async()=>{T(!0);try{const[s,t,d]=await Promise.all([m.getItemRoles(),Se.getPipelines({page_size:200}),be.getUsers({page_size:500})]);me(Array.isArray(s)?s:s?.list||s?.data||[]),ie(Array.isArray(t)?t:t?.list||t?.data||[]);const u=Array.isArray(d)?d:d?.list||d?.data||[];ye(u)}catch{}finally{T(!1)}};o.useEffect(()=>{R()},[]);const $=async()=>{if(!p){_([]);return}try{const s=await m.getUserItemRoles(Number(p));_(Array.isArray(s)?s:s?.data||s?.list||[])}catch{_([])}};o.useEffect(()=>{$()},[p]);const B=o.useMemo(()=>{const s={};return l.forEach(t=>{try{const d=new RegExp(t.pattern);s[t.id]=y.filter(u=>d.test(u.code)).map(u=>u.code)}catch{s[t.id]=[]}}),s},[l,y]),oe=(n?l.find(s=>s.id===n):null)?B[n]||[]:[],ue=async()=>{if(!P.trim()||!E.trim()||!C.trim()){c.error("名称、代码、正则表达式不能为空");return}A(!0);try{await m.createItemRole({name:P.trim(),code:E.trim(),pattern:C.trim(),role:X,description:Y}),c.success("已创建"),z(!1),K(""),Q(""),W(""),O("editor"),Z(""),R()}catch(s){c.error(s?.message||"创建失败")}finally{A(!1)}},Ae=async s=>{if(!L.trim()){c.error("正则不能为空");return}A(!0);try{await m.updateItemRole(s,{pattern:L,role:se}),c.success("已更新"),U(null),R()}catch(t){c.error(t?.message||"更新失败")}finally{A(!1)}},je=async s=>{if(await Re({title:"删除角色",description:`确定删除「${s.name}」?匹配 ${B[s.id]?.length||0} 条流水线`,variant:"destructive"}))try{await m.deleteItemRole(s.id),c.success("已删除"),R()}catch{c.error("删除失败")}},Be=async s=>{try{await m.updateItemRole(s.id,{status:s.status?0:1}),c.success(s.status?"已禁用":"已启用"),R()}catch{c.error("操作失败")}},De=async()=>{if(!p||!j){c.error("请选择用户和角色");return}H(!0);try{await m.assignItemRole(Number(p),{user_id:Number(p),item_role_id:Number(j)}),c.success("已分配"),q(""),$()}catch(s){c.error(s?.message||"分配失败")}finally{H(!1)}},ge=async s=>{try{await m.removeItemRole(Number(p),s),c.success("已撤销"),$()}catch{c.error("撤销失败")}},ce=s=>s==="owner"?"bg-amber-500/20 text-amber-400 border-amber-500/30":s==="editor"?"bg-blue-500/20 text-blue-400 border-blue-500/30":"bg-slate-500/20 text-slate-400 border-slate-500/30",V=F.find(s=>String(s.id)===p);return xe?e.jsx("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:167:23",className:"flex items-center justify-center py-20",children:e.jsx(M,{"code-path":"src/components/deploy/DeployRBAC.tsx:167:79",className:"w-6 h-6 animate-spin"})}):e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:170:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:172:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:173:9",children:[e.jsxs("h1",{"code-path":"src/components/deploy/DeployRBAC.tsx:174:11",className:"text-xl font-bold flex items-center gap-2 text-[var(--dg-text-primary)]",children:[e.jsx(ae,{"code-path":"src/components/deploy/DeployRBAC.tsx:175:13",className:"w-5 h-5 text-purple-500"}),"发布权限"]}),e.jsx("p",{"code-path":"src/components/deploy/DeployRBAC.tsx:177:11",className:"text-sm text-[var(--dg-text-secondary)] mt-1",children:"Jenkins-style Role Strategy — 按流水线 code 正则匹配分配角色"})]}),e.jsxs(a,{"code-path":"src/components/deploy/DeployRBAC.tsx:181:9",onClick:()=>z(!0),disabled:J,children:[e.jsx(le,{"code-path":"src/components/deploy/DeployRBAC.tsx:182:11",className:"w-4 h-4 mr-1"}),"新建角色"]})]}),e.jsx(g,{"code-path":"src/components/deploy/DeployRBAC.tsx:187:7",className:"bg-[var(--dgLine truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{g as Ne,r as o,a as ve,j as e,L as M,t as ae,B as a,a0 as D,I as h,a9 as fe,a5 as le,aa as we,u as be}from"./index-DfyorCky.js";import{C as g,a as N}from"./card-C55cvSHg.js";import{B as x}from"./badge-xNW8x0G1.js";import{S as v,a as f,b as w,c as b,d as r}from"./select-D5qUzdAs.js";import{L as i}from"./label-BK0h2apY.js";import{t as c}from"./index-a3ybMjbR.js";import{d as m,p as Se}from"./deploy-B3Sg3N1U.js";import{P as pe}from"./plus-CUG-9kpu.js";import{S as ne}from"./save-DoGGjfwC.js";import{T as ke}from"./trash-2-Dx32pOzT.js";import{U as de}from"./user-plus-BwUWtcQl.js";import"./index-CWVNW_qu.js";const Ie=[["path",{d:"M17 3v10",key:"15fgeh"}],["path",{d:"m12.67 5.5 8.66 5",key:"1gpheq"}],["path",{d:"m12.67 10.5 8.66-5",key:"1dkfa6"}],["path",{d:"M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z",key:"swwfx4"}]],re=Ne("regex",Ie);function He(){const[p,me]=o.useState([]),[xe,T]=o.useState(!0),[S,A]=o.useState(!1),[y,ie]=o.useState([]),[n,k]=o.useState(null),[F,ye]=o.useState([]),[I,_]=o.useState([]),[l,he]=o.useState(""),[j,q]=o.useState(""),[G,H]=o.useState(!1),[J,z]=o.useState(!1),[P,X]=o.useState(""),[E,K]=o.useState(""),[C,O]=o.useState(""),[Q,W]=o.useState("editor"),[Y,Z]=o.useState(""),[Ce,U]=o.useState(null),[L,ee]=o.useState(""),[se,te]=o.useState(""),Re=ve(),R=async()=>{T(!0);try{const[s,t,d]=await Promise.all([m.getItemRoles(),Se.getPipelines({page_size:200}),be.getUsers({page_size:500})]);me(Array.isArray(s)?s:s?.list||s?.data||[]),ie(Array.isArray(t)?t:t?.list||t?.data||[]);const u=Array.isArray(d)?d:d?.list||d?.data||[];ye(u)}catch{}finally{T(!1)}};o.useEffect(()=>{R()},[]);const $=async()=>{if(!l){_([]);return}try{const s=await m.getUserItemRoles(Number(l));_(Array.isArray(s)?s:s?.data||s?.list||[])}catch{_([])}};o.useEffect(()=>{$()},[l]);const B=o.useMemo(()=>{const s={};return p.forEach(t=>{try{const d=new RegExp(t.pattern);s[t.id]=y.filter(u=>d.test(u.code)).map(u=>u.code)}catch{s[t.id]=[]}}),s},[p,y]),oe=(n?p.find(s=>s.id===n):null)?B[n]||[]:[],ue=async()=>{if(!P.trim()||!E.trim()||!C.trim()){c.error("名称、代码、正则表达式不能为空");return}A(!0);try{await m.createItemRole({name:P.trim(),code:E.trim(),pattern:C.trim(),role:Q,description:Y}),c.success("已创建"),z(!1),X(""),K(""),O(""),W("editor"),Z(""),R()}catch(s){c.error(s?.message||"创建失败")}finally{A(!1)}},Ae=async s=>{if(!L.trim()){c.error("正则不能为空");return}A(!0);try{await m.updateItemRole(s,{pattern:L,role:se}),c.success("已更新"),U(null),R()}catch(t){c.error(t?.message||"更新失败")}finally{A(!1)}},je=async s=>{if(await Re({title:"删除角色",description:`确定删除「${s.name}」?匹配 ${B[s.id]?.length||0} 条流水线`,variant:"destructive"}))try{await m.deleteItemRole(s.id),c.success("已删除"),R()}catch{c.error("删除失败")}},Be=async s=>{try{await m.updateItemRole(s.id,{status:s.status?0:1}),c.success(s.status?"已禁用":"已启用"),R()}catch{c.error("操作失败")}},De=async()=>{if(!l||!j){c.error("请选择用户和角色");return}H(!0);try{await m.assignItemRole(Number(l),{user_id:Number(l),item_role_id:Number(j)}),c.success("已分配"),q(""),$()}catch(s){c.error(s?.message||"分配失败")}finally{H(!1)}},ge=async s=>{try{await m.removeItemRole(Number(l),s),c.success("已撤销"),$()}catch{c.error("撤销失败")}},ce=s=>s==="owner"?"bg-amber-500/20 text-amber-400 border-amber-500/30":s==="editor"?"bg-blue-500/20 text-blue-400 border-blue-500/30":"bg-slate-500/20 text-slate-400 border-slate-500/30",V=F.find(s=>String(s.id)===l);return xe?e.jsx("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:167:23",className:"flex items-center justify-center py-20",children:e.jsx(M,{"code-path":"src/components/deploy/DeployRBAC.tsx:167:79",className:"w-6 h-6 animate-spin"})}):e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:170:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:172:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/deploy/DeployRBAC.tsx:173:9",children:[e.jsxs("h1",{"code-path":"src/components/deploy/DeployRBAC.tsx:174:11",className:"text-xl font-bold flex items-center gap-2 text-[var(--dg-text-primary)]",children:[e.jsx(ae,{"code-path":"src/components/deploy/DeployRBAC.tsx:175:13",className:"w-5 h-5 text-purple-500"}),"发布权限"]}),e.jsx("p",{"code-path":"src/components/deploy/DeployRBAC.tsx:177:11",className:"text-sm text-[var(--dg-text-secondary)] mt-1",children:"Jenkins-style Role Strategy — 按流水线 code 正则匹配分配角色"})]}),e.jsxs(a,{"code-path":"src/components/deploy/DeployRBAC.tsx:181:9",onClick:()=>z(!0),disabled:J,children:[e.jsx(pe,{"code-path":"src/components/deploy/DeployRBAC.tsx:182:11",className:"w-4 h-4 mr-1"}),"新建角色"]})]}),e.jsx(g,{"code-path":"src/components/deploy/DeployRBAC.tsx:187:7",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(N,{Line truncated
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
import{g as Fe,r as m,v as ot,N as Se,A as Zt,j as e,B as u,I as v,L as xe,a4 as Qt,n as es,H as ts,x as ss,R as bs,o as ys,t as ns,V as os,G as tt,q as jt,E as vt,O as ks,M as vs,a3 as gt,a0 as xt,k as as,aT as gs,T as Mt,a7 as Ds,a5 as cs,W as Nt,i as js}from"./index-DfyorCky.js";import{C as L,a as G,b as ie,c as pe}from"./card-C55cvSHg.js";import{L as C}from"./label-BK0h2apY.js";import{B as se}from"./badge-xNW8x0G1.js";import{k as te}from"./kubernetes-J8O09fK7.js";import{u as Pe}from"./use-toast-CrSOP4cJ.js";import{S as we,f as Ye,e as Ns,b as fs,s as ht,Y as zt,P as Es,a as ws}from"./PodFileBrowser-BySN2XGN.js";import{T as Re,a as Be,b as De,c as X,d as Oe,e as Z}from"./table-5sHV4Akp.js";import{P as ae}from"./plus-CUG-9kpu.js";import{H as Cs}from"./history-D_9jPUQg.js";import{M as ft}from"./minus-UVrx3jLc.js";import{F as Et}from"./file-text-C9G5abwR.js";import{H as rs}from"./hard-drive-BbPmnARR.js";import{E as Dt}from"./external-link-CzIpMNu1.js";import{T as st}from"./textarea-NXY8u32k.js";import{S as Le,a as Ge,b as nt,c as He,d as ve}from"./select-D5qUzdAs.js";import{S as wt}from"./switch-CGiGgOnh.js";import{T as ue}from"./trash-2-Dx32pOzT.js";import{P as ls}from"./play-cdPayOtJ.js";import{S as at}from"./save-DoGGjfwC.js";import{R as ds}from"./rotate-cw-5qcj_h_q.js";import{Z as is}from"./zap-D2uWSK32.js";import{F as Ss}from"./folder-open-IMBifk-r.js";import{D as Ps}from"./disc-EsE6x5Oh.js";import{F as As,a as ut}from"./folder-DoMwqvzv.js";import{R as ct}from"./refresh-cw-DUB_tAG-.js";import{C as Vs}from"./circle-x-DK79Dhg2.js";import{A as Ws}from"./arrow-left-BDgGyrD0.js";import{P as _t}from"./pause-D_famo9P.js";import"./copy-DXW4LnkN.js";import"./sparkles-Bld4NX5y.js";import"./xterm-DSqgeKvr.js";import"./box-TTGA1p57.js";import"./minimize-2-CiCQYRfn.js";import"./upload-Ba6rlaGS.js";import"./download-DoZfYs2h.js";import"./index-CWVNW_qu.js";const Ts=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],Rs=Fe("hash",Ts);const Bs=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]],Os=Fe("heart",Bs);const Is=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Ms=Fe("image",Is);const zs=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],_s=Fe("key-round",zs);const $s=[["path",{d:"M13.172 2a2 2 0 0 1 1.414.586l6.71 6.71a2.4 2.4 0 0 1 0 3.408l-4.592 4.592a2.4 2.4 0 0 1-3.408 0l-6.71-6.71A2 2 0 0 1 6 9.172V3a1 1 0 0 1 1-1z",key:"16rjxf"}],["path",{d:"M2 7v6.172a2 2 0 0 0 .586 1.414l6.71 6.71a2.4 2.4 0 0 0 3.191.193",key:"178nd4"}],["circle",{cx:"10.5",cy:"6.5",r:".5",fill:"currentColor",key:"12ikhr"}]],$t=Fe("tags",$s);function ps(t){const s=t.conditions||t.pod_conditions||[],o=n=>s.find(d=>(d.type||d.Type)===n),a=n=>n?.lastTransitionTime||n?.LastTransitionTime||n?.last_transition_time;return{scheduled:a(o("PodScheduled")||{}),initialized:a(o("Initialized")||{}),containersReady:a(o("ContainersReady")||{}),ready:a(o("Ready")||{}),startTime:t.start_time||t.startTime}}function Ls(t){const{clusterCode:s,namespace:o,deployment:a,pods:n,revisions:d,onRefresh:i}=t,{toast:p}=Pe(),[D,h]=m.useState("pods"),[N,I]=m.useState(null),[q,V]=m.useState(null),[R,M]=m.useState(a?.replicas||0),[z,F]=m.useState(!1),[B,U]=m.useState([]),[Y,S]=m.useState([]),[Q,O]=m.useState([]),[H,ne]=m.useState(""),[oe,r]=m.useState([]),[b,f]=m.useState([]),P=a?.ready_replicas??a?.readyReplicas??0,l=a?.replicas??0,w=P===l&&l>0;m.useEffect(()=>{D==="services"&&(ne("services"),Promise.all([te.getNamespaceServices(s,o).catch(()=>[]),te.getNamespaceIngresses(s,o).catch(()=>[])]).then(([y,J])=>{const _=A=>Array.isArray(A)?A:A?.list||A?.items||A?.data||[],$=_(y),be=_(J),K=a?.spec?.selector?.matchLabels||a?.spec?.template?.metadata?.labels||{},he=$.filter(A=>{const ce=A.spec?.selector||A.selector||{};return Object.keys(ce).length===0?!1:Object.entries(ce).every(([ge,fe])=>K[ge]===fe)}).map(A=>({name:A.name||A.metadata?.name,type:A.spec?.type||A.type||"ClusterIP",clusterIP:A.spec?.clusterIP||A.cluster_ip||"<none>",ports:(A.spec?.ports||A.ports||[]).map(ce=>`${ce.port}${ce.targetPort?":"+ce.targetPort:""}/${ce.protocol||"TCP"}`),selector:A.spec?.selector||A.selector||{},age:A.age||""})),Ne=new Set(he.map(A=>A.name)),de=be.filter(A=>(A.spec?.rules||A.rules||[]).some(ge=>(ge.http?.paths||ge.paths||[]).some(fe=>{const g=fe.backend?.service?.name||fe.backendService||"";return Ne.has(g)}))).map(A=>({name:A.name||A.mLine truncated
|
||||
import{i as Fe,r as m,v as ot,N as Se,A as Zt,j as e,B as u,L as xe,V as Qt,o as es,E as ts,C as ss,R as bs,p as ys,t as ns,_ as os,z as tt,S as jt,y as vt,G as ks,M as vs,P as gt,Q as xt,m as as,aU as gs,T as Mt,al as Ds,X as cs,$ as Nt,k as js}from"./index-Dmami9WE.js";import{C as L,a as G,b as ie,c as pe}from"./card-CIfC-8Rh.js";import{I as v}from"./input-NsU9nXZF.js";import{L as C}from"./label-Ap_-SPYI.js";import{B as se}from"./badge-3UzCvU7L.js";import{k as te}from"./kubernetes-D2-GnE0t.js";import{u as Pe}from"./use-toast-jvSbBx20.js";import{S as we,f as Ye,e as Ns,b as fs,s as ht,Y as zt,P as Es,a as ws}from"./PodFileBrowser-BLvOIIeH.js";import{T as Re,a as Be,b as De,c as X,d as Oe,e as Z}from"./table-CG4mjNfb.js";import{P as ae}from"./plus-O65gX7Qz.js";import{H as Cs}from"./history-CbX6uocL.js";import{M as ft}from"./minus-DRP_TSA-.js";import{F as Et}from"./file-text-CebshSV-.js";import{H as rs}from"./hard-drive-DmC04Y5r.js";import{E as Dt}from"./external-link-2hCYo_Ng.js";import{T as st}from"./textarea-DHUZ6N85.js";import{S as Le,a as Ge,b as nt,c as He,d as ve}from"./select-DUbxjT0z.js";import{S as wt}from"./switch-TqjD2x0W.js";import{T as ue}from"./trash-2-DWVnIU6o.js";import{P as ls}from"./play-0EwQQJX_.js";import{S as at}from"./save-YtnrpTd8.js";import{R as ds}from"./rotate-cw-CKCO6IKE.js";import{Z as is}from"./zap-CocSkPPl.js";import{F as Ss}from"./folder-open-CjMh_m_2.js";import{D as Ps}from"./disc-BPxL4arn.js";import{F as As,a as ut}from"./folder-B5RGB3GG.js";import{R as ct}from"./refresh-cw-CTBERyFc.js";import{C as Vs}from"./circle-x-BBQeW1R3.js";import{A as Ws}from"./arrow-left-BIbk9wFC.js";import{P as _t}from"./pause-DOhduDQ5.js";import"./copy-CE_T92Lk.js";import"./sparkles-rPZivnlW.js";import"./xterm-DSqgeKvr.js";import"./box-88Ol5qY-.js";import"./minimize-2-BHcbNmdK.js";import"./upload-CRLg7Pbj.js";import"./download-Vuij9wGr.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";const Ts=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],Rs=Fe("hash",Ts);const Bs=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]],Os=Fe("heart",Bs);const Is=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Ms=Fe("image",Is);const zs=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],_s=Fe("key-round",zs);const $s=[["path",{d:"M13.172 2a2 2 0 0 1 1.414.586l6.71 6.71a2.4 2.4 0 0 1 0 3.408l-4.592 4.592a2.4 2.4 0 0 1-3.408 0l-6.71-6.71A2 2 0 0 1 6 9.172V3a1 1 0 0 1 1-1z",key:"16rjxf"}],["path",{d:"M2 7v6.172a2 2 0 0 0 .586 1.414l6.71 6.71a2.4 2.4 0 0 0 3.191.193",key:"178nd4"}],["circle",{cx:"10.5",cy:"6.5",r:".5",fill:"currentColor",key:"12ikhr"}]],$t=Fe("tags",$s);function ps(t){const s=t.conditions||t.pod_conditions||[],o=n=>s.find(d=>(d.type||d.Type)===n),a=n=>n?.lastTransitionTime||n?.LastTransitionTime||n?.last_transition_time;return{scheduled:a(o("PodScheduled")||{}),initialized:a(o("Initialized")||{}),containersReady:a(o("ContainersReady")||{}),ready:a(o("Ready")||{}),startTime:t.start_time||t.startTime}}function Ls(t){const{clusterCode:s,namespace:o,deployment:a,pods:n,revisions:d,onRefresh:i}=t,{toast:p}=Pe(),[D,h]=m.useState("pods"),[N,I]=m.useState(null),[q,V]=m.useState(null),[R,M]=m.useState(a?.replicas||0),[z,F]=m.useState(!1),[B,U]=m.useState([]),[Y,S]=m.useState([]),[Q,O]=m.useState([]),[H,ne]=m.useState(""),[oe,r]=m.useState([]),[b,f]=m.useState([]),P=a?.ready_replicas??a?.readyReplicas??0,l=a?.replicas??0,w=P===l&&l>0;m.useEffect(()=>{D==="services"&&(ne("services"),Promise.all([te.getNamespaceServices(s,o).catch(()=>[]),te.getNamespaceIngresses(s,o).catch(()=>[])]).then(([y,J])=>{const _=A=>Array.isArray(A)?A:A?.list||A?.items||A?.data||[],$=_(y),be=_(J),K=a?.spec?.selector?.matchLabels||a?.spec?.template?.metadata?.labels||{},he=$.filter(A=>{const ce=A.spec?.selector||A.selector||{};return Object.keys(ce).length===0?!1:Object.entries(ce).every(([ge,fe])=>K[ge]===fe)}).map(A=>({name:A.name||A.metadata?.name,type:A.spec?.type||A.type||"ClusterIP",clusterIP:A.spec?.clusterIP||A.cluster_ip||"<none>",ports:(A.spec?.ports||A.ports||[]).map(ce=>`${ce.port}${ce.targetPort?":"+ce.targetPort:""}/${ce.protocol||"TCP"}`),selector:A.spec?.selector||A.selector||{},age:A.age||""})),Ne=new Set(he.map(A=>A.name)),de=be.filter(A=>(A.spec?.rules||A.rules||[]).some(ge=>(ge.http?.paths||ge.paths||[]).some(fe=>{const g=fe.backend?.service?.name||fe.bacLine truncated
|
||||
`):n.exec?.command||"",initialDelaySeconds:n.initialDelaySeconds,periodSeconds:n.periodSeconds,timeoutSeconds:n.timeoutSeconds,successThreshold:n.successThreshold,failureThreshold:n.failureThreshold}},o=n=>{if(!n)return{type:"none"};let d="none";return n.exec?d="exec":n.httpGet?d="httpGet":n.tcpSocket&&(d="tcpSocket"),{type:d,execCommand:Array.isArray(n.exec?.command)?n.exec.command.join(`
|
||||
`):"",httpPath:n.httpGet?.path||"",httpPort:n.httpGet?.port??"",tcpPort:n.tcpSocket?.port??""}},a=t.securityContext;return{name:t.name||"",image:t.image||"",imagePullPolicy:t.imagePullPolicy||"",command:Array.isArray(t.command)?t.command:[],args:Array.isArray(t.args)?t.args:[],workingDir:t.workingDir||"",env:(Array.isArray(t.env)?t.env:[]).map(n=>({name:n.name||"",value:n.value??""})),ports:(Array.isArray(t.ports)?t.ports:[]).map(n=>({name:n.name||"",containerPort:n.containerPort??"",protocol:n.protocol||"TCP"})),resources:{requests:t.resources?.requests||{},limits:t.resources?.limits||{}},livenessProbe:s(t.livenessProbe),readinessProbe:s(t.readinessProbe),startupProbe:s(t.startupProbe),lifecycle:t.lifecycle?{postStart:t.lifecycle.postStart?o(t.lifecycle.postStart):void 0,preStop:t.lifecycle.preStop?o(t.lifecycle.preStop):void 0}:null,securityContext:a?{runAsUser:a.runAsUser,runAsGroup:a.runAsGroup,runAsNonRoot:a.runAsNonRoot,privileged:a.privileged,readOnlyRootFilesystem:a.readOnlyRootFilesystem,allowPrivilegeEscalation:a.allowPrivilegeEscalation,capabilitiesAdd:a.capabilities?.add||[],capabilitiesDrop:a.capabilities?.drop||[]}:null,volumeMounts:(Array.isArray(t.volumeMounts)?t.volumeMounts:[]).map(n=>({name:n.name||"",mountPath:n.mountPath||"",subPath:n.subPath||"",readOnly:n.readOnly||!1}))}}function Gt(t=""){return{name:t,image:"",imagePullPolicy:"IfNotPresent",command:[],args:[],workingDir:"",env:[],ports:[],resources:{},livenessProbe:null,readinessProbe:null,startupProbe:null,lifecycle:null,securityContext:null,volumeMounts:[]}}function bt(t){if(!t||t.type==="none"||!t.type)return;const s={};if(t.type==="httpGet")s.httpGet={},t.httpPath&&(s.httpGet.path=t.httpPath),t.httpPort!==""&&t.httpPort!=null&&(s.httpGet.port=typeof t.httpPort=="number"?t.httpPort:Number(t.httpPort)),t.httpHost&&(s.httpGet.host=t.httpHost);else if(t.type==="tcpSocket")s.tcpSocket={},t.tcpPort!==""&&t.tcpPort!=null&&(s.tcpSocket.port=typeof t.tcpPort=="number"?t.tcpPort:Number(t.tcpPort));else if(t.type==="exec"){const o=(t.execCommand||"").split(`
|
||||
`).map(a=>a.trim()).filter(Boolean);o.length&&(s.exec={command:o})}return t.initialDelaySeconds!=null&&(s.initialDelaySeconds=t.initialDelaySeconds),t.periodSeconds!=null&&(s.periodSeconds=t.periodSeconds),t.timeoutSeconds!=null&&(s.timeoutSeconds=t.timeoutSeconds),t.successThreshold!=null&&(s.successThreshold=t.successThreshold),t.failureThreshold!=null&&(s.failureThreshold=t.failureThreshold),Object.keys(s).length>0?s:void 0}function Ht(t){if(!(!t||t.type==="none"||!t.type)){if(t.type==="exec"){const s=(t.execCommand||"").split(`
|
||||
@@ -17,4 +17,4 @@ cluster.local`,rows:3,className:"w-full mt-1 bg-slate-800 border border-slate-70
|
||||
${N?"border-blue-500 text-blue-400":h.available?"border-transparent text-slate-400 hover:text-slate-200":"border-transparent text-slate-600 cursor-not-allowed"}`,children:[e.jsx(I,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:584:15",className:"h-3.5 w-3.5"}),h.label,h.badge&&e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:587:17",className:`text-[9px] px-1 py-0.5 rounded ${N?"bg-blue-500/20 text-blue-300":"bg-slate-800 text-slate-600"}`,children:h.badge})]},h.key)})}),i==="basic"?e.jsx(Xs,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:598:9",clusterCode:t,namespace:s,deploymentName:o,manifest:a,onSaved:n,onCancel:d}):i==="containers"?e.jsx(qs,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:608:9",clusterCode:t,namespace:s,deploymentName:o,manifest:a,onSaved:n,onCancel:d}):i==="storage"?e.jsx(en,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:618:9",clusterCode:t,namespace:s,deploymentName:o,manifest:a,onSaved:n,onCancel:d}):i==="advanced"?e.jsx(tn,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:628:9",clusterCode:t,namespace:s,deploymentName:o,manifest:a,onSaved:n,onCancel:d}):i==="service"?e.jsx(nn,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:638:9",clusterCode:t,namespace:s,deploymentName:o,manifest:a,onSaved:n,onCancel:d}):null]})}function cn({clusterCode:t,namespace:s,deploymentName:o}){const{toast:a}=Pe(),n=Nt(D=>D.token)||localStorage.getItem("token")||"",d=`${window.location.origin}/api/v1/clusters/${t}/namespaces/${s}/deployments/${o}/update-image`,i=`curl -X POST '${d}' \\
|
||||
-H 'Authorization: Bearer ${n?n.substring(0,16)+"...":"YOUR_TOKEN"}' \\
|
||||
-H 'Content-Type: application/json' \\
|
||||
-d '{"image": "harbor.example.com/app:v1.0", "container": "your-container-name"}'`,p=D=>{navigator.clipboard.writeText(D).then(()=>a({title:"已复制"})).catch(()=>{})};return e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:666:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:667:7",children:[e.jsx(C,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:668:9",className:"text-slate-400 text-sm",children:"Webhook URL"}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:669:9",className:"flex items-center gap-2 mt-1",children:[e.jsx("code",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:670:11",className:"flex-1 text-xs text-slate-300 bg-slate-800 rounded px-3 py-2 break-all font-mono",children:d}),e.jsx(u,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:671:11",variant:"outline",size:"sm",className:"border-slate-700 text-slate-400 shrink-0",onClick:()=>p(d),children:"复制"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:674:7",children:[e.jsx(C,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:675:9",className:"text-slate-400 text-sm",children:"curl 示例"}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:676:9",className:"relative mt-1",children:[e.jsx("pre",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:677:11",className:"text-xs text-slate-300 bg-slate-800 rounded p-3 overflow-x-auto font-mono whitespace-pre-wrap",children:i}),e.jsx(u,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:678:11",variant:"outline",size:"sm",className:"absolute top-2 right-2 border-slate-700 text-slate-400",onClick:()=>p(i),children:"复制"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:681:7",className:"text-xs text-slate-500 space-y-1",children:[e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:682:9",children:"• 使用 Bearer Token 认证(JWT 登录令牌)"}),e.jsxs("p",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:683:9",children:["• ",e.jsx("code",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:683:14",className:"text-slate-400",children:"image"})," 必填,指定新镜像地址"]}),e.jsxs("p",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:684:9",children:["• ",e.jsx("code",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:684:14",className:"text-slate-400",children:"container"})," 可选,不填则更新第一个容器"]})]})]})}function et({title:t,children:s,onClose:o}){return e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:693:5",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:o,children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:694:7",className:"bg-slate-900 border border-slate-700 rounded-xl p-6 w-[460px] max-w-[90vw] shadow-2xl",onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:695:9",className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:696:11",className:"text-base font-bold text-slate-100",children:t}),e.jsx(u,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:697:11",variant:"ghost",size:"icon",className:"h-7 w-7 text-slate-400",onClick:o,children:e.jsx(cs,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:697:100",className:"h-4 w-4"})})]}),s]})})}function rn({clusterCode:t,namespace:s,podName:o,containers:a,onClose:n}){const{toast:d}=Pe(),[i,p]=m.useState(""),[D,h]=m.useState(200),[N,I]=m.useState(a[0]||""),[q,V]=m.useState(!1),[R,M]=m.useState(!1),z=async()=>{V(!0);try{const B=await te.getPodLogs(t,s,o,D,N||void 0);p(B?.data?.logs||B?.logs||B||"无日志")}catch{p("获取日志失败")}finally{V(!1)}};m.useEffect(()=>{z()},[N,D]);const F=async()=>{M(!0);const B=Nt.getState().token||"",U="",Y=N?`&container=${encodeURIComponent(N)}`:"",S=`${U}/api/v1/kubernetes/${t}/namespace/${s}/pods/${o}/logs?tail=${D}&stream=true${Y}`;try{const O=(await fetch(S,{headers:{Authorization:`Bearer ${B}`}})).body?.getReader();if(!O)return;const H=new TextDecoder;let ne="";for(;;){const{done:oe,value:r}=await O.read();if(oe)break;ne+=H.decode(r,{stream:!0}),p(ne)}}catch{d({title:"流式日志连接中断",variant:"destructive"})}finally{M(!1)}};return e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:752:5",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:n,children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:753:7",className:"bg-slate-900 border border-slate-700 rounded-xl w-[90vw] max-w-4xl max-h-[80vh] flex flex-col",onClick:B=>B.stopPropagation(),children:[e.jsxs("div",{"code-path
Line truncated
|
||||
-d '{"image": "harbor.example.com/app:v1.0", "container": "your-container-name"}'`,p=D=>{navigator.clipboard.writeText(D).then(()=>a({title:"已复制"})).catch(()=>{})};return e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:666:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:667:7",children:[e.jsx(C,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:668:9",className:"text-slate-400 text-sm",children:"Webhook URL"}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:669:9",className:"flex items-center gap-2 mt-1",children:[e.jsx("code",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:670:11",className:"flex-1 text-xs text-slate-300 bg-slate-800 rounded px-3 py-2 break-all font-mono",children:d}),e.jsx(u,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:671:11",variant:"outline",size:"sm",className:"border-slate-700 text-slate-400 shrink-0",onClick:()=>p(d),children:"复制"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:674:7",children:[e.jsx(C,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:675:9",className:"text-slate-400 text-sm",children:"curl 示例"}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:676:9",className:"relative mt-1",children:[e.jsx("pre",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:677:11",className:"text-xs text-slate-300 bg-slate-800 rounded p-3 overflow-x-auto font-mono whitespace-pre-wrap",children:i}),e.jsx(u,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:678:11",variant:"outline",size:"sm",className:"absolute top-2 right-2 border-slate-700 text-slate-400",onClick:()=>p(i),children:"复制"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:681:7",className:"text-xs text-slate-500 space-y-1",children:[e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:682:9",children:"• 使用 Bearer Token 认证(JWT 登录令牌)"}),e.jsxs("p",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:683:9",children:["• ",e.jsx("code",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:683:14",className:"text-slate-400",children:"image"})," 必填,指定新镜像地址"]}),e.jsxs("p",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:684:9",children:["• ",e.jsx("code",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:684:14",className:"text-slate-400",children:"container"})," 可选,不填则更新第一个容器"]})]})]})}function et({title:t,children:s,onClose:o}){return e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:693:5",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:o,children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:694:7",className:"bg-slate-900 border border-slate-700 rounded-xl p-6 w-[460px] max-w-[90vw] shadow-2xl",onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:695:9",className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:696:11",className:"text-base font-bold text-slate-100",children:t}),e.jsx(u,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:697:11",variant:"ghost",size:"icon",className:"h-7 w-7 text-slate-400",onClick:o,children:e.jsx(cs,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:697:100",className:"h-4 w-4"})})]}),s]})})}function rn({clusterCode:t,namespace:s,podName:o,containers:a,onClose:n}){const{toast:d}=Pe(),[i,p]=m.useState(""),[D,h]=m.useState(200),[N,I]=m.useState(a[0]||""),[q,V]=m.useState(!1),[R,M]=m.useState(!1),z=async()=>{V(!0);try{const B=await te.getPodLogs(t,s,o,D,N||void 0);p(B?.data?.logs||B?.logs||B||"无日志")}catch{p("获取日志失败")}finally{V(!1)}};m.useEffect(()=>{z()},[N,D]);const F=async()=>{M(!0);const B=Nt.getState().token||"",U="",Y=N?`&container=${encodeURIComponent(N)}`:"",S=`${U}/api/v1/kubernetes/${t}/namespace/${s}/pods/${o}/logs?tail=${D}&stream=true${Y}`;try{const O=(await fetch(S,{headers:{Authorization:`Bearer ${B}`}})).body?.getReader();if(!O)return;const H=new TextDecoder;let ne="";for(;;){const{done:oe,value:r}=await O.read();if(oe)break;ne+=H.decode(r,{stream:!0}),p(ne)}}catch{d({title:"流式日志连接中断",variant:"destructive"})}finally{M(!1)}};return e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:752:5",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:n,children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:753:7",className:"bg-slate-900 border border-slate-700 rounded-xl w-[90vw] max-w-4xl max-h-[80vh] flex flex-col",onClick:B=>B.stopPropagation(),children:[e.jsxs("div",{"code-path
Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{r as n,j as e,B as m,G as E,C as U,D as A,a as H,b as X,c as q,d as J,e as K,L as V}from"./index-Dmami9WE.js";import{I as l}from"./input-NsU9nXZF.js";import{L as d}from"./label-Ap_-SPYI.js";import{C as j,a as M}from"./card-CIfC-8Rh.js";import{B as h}from"./badge-3UzCvU7L.js";import{c as u}from"./cloud-Dq4kl-JO.js";import{R as L}from"./refresh-cw-CTBERyFc.js";import{P as k}from"./plus-O65gX7Qz.js";import{S as W}from"./search-Dd-PeBfg.js";import{C as P}from"./circle-check-CVbTTFQ0.js";import{C as Y}from"./circle-x-BBQeW1R3.js";import{P as O}from"./pen-0lfnZsyH.js";import{T as Z}from"./trash-2-DWVnIU6o.js";function xe(){const[i,b]=n.useState([]),[N,v]=n.useState(!0),[g,B]=n.useState(""),[D,F]=n.useState("all"),[I,p]=n.useState(!1),[f,_]=n.useState(!1),[r,y]=n.useState(null),[a,t]=n.useState({name:"",registrar:"",status:"active",expire_date:"",dns_provider:"",record_count:"",ssl_enabled:!1,ssl_expire_date:""}),T=()=>{y(null),t({name:"",registrar:"",status:"active",expire_date:"",dns_provider:"",record_count:"",ssl_enabled:!1,ssl_expire_date:""})},R=()=>{T(),p(!0)},$=s=>{y(s);const o=c=>c?c.substring(0,10):"";t({name:s.name||"",registrar:s.registrar||"",status:s.status||"active",expire_date:o(s.expire_date||""),dns_provider:s.dns_provider||s.dnsProvider||"",record_count:String(s.record_count??s.recordCount??""),ssl_enabled:s.ssl_enabled??s.sslEnabled??!1,ssl_expire_date:o(s.ssl_expire_date||"")}),p(!0)},z=async()=>{if(a.name.trim())try{_(!0);const s={name:a.name.trim(),registrar:a.registrar.trim(),status:a.status,expire_date:a.expire_date,dns_provider:a.dns_provider.trim(),record_count:Number(a.record_count)||0,ssl_enabled:a.ssl_enabled,ssl_expire_date:a.ssl_expire_date};r?await u.updateDomain(r.id,s):await u.createDomain(s),p(!1),x()}catch(s){console.error(r?"更新域名失败:":"创建域名失败:",s)}finally{_(!1)}},x=async()=>{try{v(!0);const s=await u.getDomains();b(s?.list||[])}catch(s){console.error("加载域名列表失败:",s),b([])}finally{v(!1)}};n.useEffect(()=>{x()},[]);const G=async s=>{try{await u.deleteDomain(s),x()}catch(o){console.error("删除域名失败:",o)}},C=i.filter(s=>{const o=(s.name||"").toLowerCase().includes(g.toLowerCase())||(s.registrar||"").toLowerCase().includes(g.toLowerCase()),c=D==="all"||s.status===D;return o&&c});i.length,i.filter(s=>s.status==="active").length,i.filter(s=>s.status==="expired").length,i.filter(s=>s.status==="pending").length,i.filter(s=>s.ssl_enabled||s.sslEnabled).length;const Q=s=>s?Math.ceil((new Date(s).getTime()-Date.now())/(1e3*60*60*24)):1/0;return e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:162:5",className:"space-y-6",children:[e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:164:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:165:9",children:[e.jsx("h1",{"code-path":"src/components/cloud/DomainManager.tsx:166:11",className:"text-2xl font-bold text-slate-100",children:"域名管理"}),e.jsx("p",{"code-path":"src/components/cloud/DomainManager.tsx:167:11",className:"text-slate-400 mt-1",children:"管理域名注册信息和DNS解析记录"})]}),e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:169:9",className:"flex items-center gap-2",children:[e.jsxs(m,{"code-path":"src/components/cloud/DomainManager.tsx:170:11",variant:"outline",onClick:x,className:"border-slate-700 text-slate-300",children:[e.jsx(L,{"code-path":"src/components/cloud/DomainManager.tsx:171:13",className:`h-4 w-4 mr-2 ${N?"animate-spin":""}`}),"刷新"]}),e.jsxs(m,{"code-path":"src/components/cloud/DomainManager.tsx:174:11",className:"bg-blue-600 hover:bg-blue-700",onClick:R,children:[e.jsx(k,{"code-path":"src/components/cloud/DomainManager.tsx:175:13",className:"h-4 w-4 mr-2"}),"添加域名"]})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:182:7",className:"flex items-center gap-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:183:9",className:"relative flex-1 max-w-md",children:[e.jsx(W,{"code-path":"src/components/cloud/DomainManager.tsx:184:11",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx(l,{"code-path":"src/components/cloud/DomainManager.tsx:185:11",placeholder:"搜索域名...",value:g,onChange:s=>B(s.target.value),className:"pl-10 bg-slate-800 border-slate-700 text-slate-100"})]}),e.jsxs("select",{"code-path":"src/components/cloud/DomainManager.tsx:192:9",value:D,onChange:s=>F(s.target.value),className:"px-3 py-2 bg-slate-800 border border-slate-700 rounded-md text-slate-100 text-sm",children:[e.jsx("option",{"code-path":"src/components/cloud/DomainManager.tsx:197:11",value:"all",children:"全部状态"}),e.jsx("option",{"code-path":"src/components/cloud/DomainManager.tsx:198:11",value:"active",children:"正常"}),e.jsx("option",{"code-path":"src/components/cloud/DomainManager.tsx:199:11",value:"expired",children:"已过期"}),e.jsx("optioLine truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{g as X,r as o,j as e,B as x,O as v,x as O,S as q,I as i,D as J,b as K,c as V,d as W,e as Y,f as Z,L as ee}from"./index-DfyorCky.js";import{L as m}from"./label-BK0h2apY.js";import{C as r,a as l}from"./card-C55cvSHg.js";import{B as D}from"./badge-xNW8x0G1.js";import{c as j}from"./cloud-Dzoer-2i.js";import{R as P}from"./refresh-cw-DUB_tAG-.js";import{P as I}from"./plus-CUG-9kpu.js";import{C as M}from"./circle-check-DWcXrx2k.js";import{C as B}from"./circle-x-DK79Dhg2.js";import{T as se}from"./trash-2-Dx32pOzT.js";const ae=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],F=X("pen",ae);function xe(){const[p,f]=o.useState([]),[y,_]=o.useState(!0),[N,T]=o.useState(""),[b,z]=o.useState("all"),[R,h]=o.useState(!1),[w,C]=o.useState(!1),[d,S]=o.useState(null),[a,t]=o.useState({name:"",registrar:"",status:"active",expire_date:"",dns_provider:"",record_count:"",ssl_enabled:!1,ssl_expire_date:""}),$=()=>{S(null),t({name:"",registrar:"",status:"active",expire_date:"",dns_provider:"",record_count:"",ssl_enabled:!1,ssl_expire_date:""})},Q=()=>{$(),h(!0)},U=s=>{S(s);const c=n=>n?n.substring(0,10):"";t({name:s.name||"",registrar:s.registrar||"",status:s.status||"active",expire_date:c(s.expire_date||""),dns_provider:s.dns_provider||s.dnsProvider||"",record_count:String(s.record_count??s.recordCount??""),ssl_enabled:s.ssl_enabled??s.sslEnabled??!1,ssl_expire_date:c(s.ssl_expire_date||"")}),h(!0)},A=async()=>{if(a.name.trim())try{C(!0);const s={name:a.name.trim(),registrar:a.registrar.trim(),status:a.status,expire_date:a.expire_date,dns_provider:a.dns_provider.trim(),record_count:Number(a.record_count)||0,ssl_enabled:a.ssl_enabled,ssl_expire_date:a.ssl_expire_date};d?await j.updateDomain(d.id,s):await j.createDomain(s),h(!1),g()}catch(s){console.error(d?"更新域名失败:":"创建域名失败:",s)}finally{C(!1)}},g=async()=>{try{_(!0);const s=await j.getDomains();f(s?.list||[])}catch(s){console.error("加载域名列表失败:",s),f([])}finally{_(!1)}};o.useEffect(()=>{g()},[]);const G=async s=>{try{await j.deleteDomain(s),g()}catch(c){console.error("删除域名失败:",c)}},L=p.filter(s=>{const c=(s.name||"").toLowerCase().includes(N.toLowerCase())||(s.registrar||"").toLowerCase().includes(N.toLowerCase()),n=b==="all"||s.status===b;return c&&n}),u={total:p.length,active:p.filter(s=>s.status==="active").length,expired:p.filter(s=>s.status==="expired").length,pending:p.filter(s=>s.status==="pending").length,sslEnabled:p.filter(s=>s.ssl_enabled||s.sslEnabled).length},H=s=>s?Math.ceil((new Date(s).getTime()-Date.now())/(1e3*60*60*24)):1/0;return e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:162:5",className:"space-y-6",children:[e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:164:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:165:9",children:[e.jsx("h1",{"code-path":"src/components/cloud/DomainManager.tsx:166:11",className:"text-2xl font-bold text-slate-100",children:"域名管理"}),e.jsx("p",{"code-path":"src/components/cloud/DomainManager.tsx:167:11",className:"text-slate-400 mt-1",children:"管理域名注册信息和DNS解析记录"})]}),e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:169:9",className:"flex items-center gap-2",children:[e.jsxs(x,{"code-path":"src/components/cloud/DomainManager.tsx:170:11",variant:"outline",onClick:g,className:"border-slate-700 text-slate-300",children:[e.jsx(P,{"code-path":"src/components/cloud/DomainManager.tsx:171:13",className:`h-4 w-4 mr-2 ${y?"animate-spin":""}`}),"刷新"]}),e.jsxs(x,{"code-path":"src/components/cloud/DomainManager.tsx:174:11",className:"bg-blue-600 hover:bg-blue-700",onClick:Q,children:[e.jsx(I,{"code-path":"src/components/cloud/DomainManager.tsx:175:13",className:"h-4 w-4 mr-2"}),"添加域名"]})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:182:7",className:"grid grid-cols-5 gap-4",children:[e.jsx(r,{"code-path":"src/components/cloud/DomainManager.tsx:183:9",className:"bg-slate-800 border-slate-700",children:e.jsx(l,{"code-path":"src/components/cloud/DomainManager.tsx:184:11",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:185:13",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/cloud/DomainManager.tsx:186:15",children:[e.jsx("p",{"code-path":"src/components/cloud/DomainManager.tsx:187:17",className:"text-slate-400 text-sm",children:"域名总数"}),e.jsx("p",{"code-path":"src/components/cloud/DomainManager.tsx:188:17",className:"text-2xl font-bold text-slate-100 mt-1",children:u.total})]}),e.jsx("div",{"code-path":"src/components/cloud/DomainManager.tsx:190:15",className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:e.jsx(v,{"code-path":"src/components/cloud/DomainManLine truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{k as he,m as ue,r as n,j as e,n as q,o as J,H as be,B as ge,A as ve,T as E,I as Q,S as ke}from"./index-Dmami9WE.js";import{C as x,a as p}from"./card-CIfC-8Rh.js";import{B as g}from"./badge-3UzCvU7L.js";import{S as N,a as f,b as y,c as w,d as o}from"./select-DUbxjT0z.js";import{T as Ee,a as je,b as L,c as h,d as Pe,e as d}from"./table-CG4mjNfb.js";import{k as S}from"./kubernetes-D2-GnE0t.js";import{R as Ne}from"./refresh-cw-CTBERyFc.js";import{L as Z}from"./layers-Dv4yGMGm.js";import{R as W,C as D,X as K,Y as M,T as V,B as H,a as ee}from"./generateCategoricalChart-ZqCvxO-S.js";import{B as I}from"./BarChart-CLIO1OEu.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";const se=["#EF4444","#F59E0B","#3B82F6","#8B5CF6","#EC4899","#14B8A6","#F97316","#6366F1","#84CC16","#06B6D4"];function Fe(){const{clusterCode:te}=he(),O=ue(),[C,U]=n.useState(!1),[m,X]=n.useState([]),[ne,ae]=n.useState([]),[ce,re]=n.useState([]),[i,oe]=n.useState("all"),[j,le]=n.useState("all"),[T,xe]=n.useState("0"),[c,Y]=n.useState(te||""),[r,G]=n.useState(null),[u,B]=n.useState(""),[b,R]=n.useState(""),[pe,de]=n.useState(null);n.useEffect(()=>{S.getClusters().then(s=>{const t=s?.list||[];if(ae(t),!c&&t.length>0){const a=t[0].code||String(t[0].id);Y(a),O(`/kubernetes/${a}/events`,{replace:!0})}}).catch(()=>{})},[]),n.useEffect(()=>{c&&S.getNamespaces(c).then(s=>{re(Array.isArray(s)?s:s?.list||s?.data||[])}).catch(()=>{})},[c]);const _=n.useCallback(async()=>{if(c){U(!0);try{const s=i==="all"?void 0:i,t=j==="all"?void 0:j,a=await S.getEvents(c,s,t);X(Array.isArray(a)?a:a?.list||[])}catch{X([])}finally{U(!1)}}},[c,i,j]),A=n.useCallback(async()=>{if(c)try{const s=i==="all"?void 0:i,t=parseInt(T)||void 0,a=await S.getEventsSummary(c,s,t);G(a||null)}catch{G(null)}},[c,i,T]);n.useEffect(()=>{_()},[_]),n.useEffect(()=>{A()},[A]);const v=n.useMemo(()=>{let s=m;return u&&(s=s.filter(t=>t.reason===u)),b&&(s=s.filter(t=>(t.object||"").startsWith(b+"/"))),s},[m,u,b]),me=n.useMemo(()=>m.filter(s=>s.type==="Warning").length,[m]),ie=n.useMemo(()=>m.filter(s=>s.type==="Normal").length,[m]),k=n.useMemo(()=>(r?.by_reason||[]).map(t=>({name:t.reason||"Unknown",count:t.count})),[r]),z=n.useMemo(()=>(r?.by_namespace||[]).map(t=>({name:t.namespace||"<cluster>",count:t.count})),[r]),$=n.useMemo(()=>(r?.by_kind||[]).map(t=>({name:t.kind||"Unknown",count:t.count})),[r]),F=s=>s?s.replace("T"," ").substring(0,19):"-",P=s=>{if(!s)return"";const t=Date.now()-new Date(s).getTime();if(t<0)return"";const a=Math.floor(t/6e4);if(a<1)return"刚刚";if(a<60)return`${a}分钟前`;const l=Math.floor(a/60);return l<24?`${l}小时前`:`${Math.floor(l/24)}天前`};return e.jsxs("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:134:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:136:7",className:"flex items-center gap-2 text-sm text-slate-500",children:[e.jsx(q,{"code-path":"src/components/kubernetes/EventsPage.tsx:137:9",to:"/kubernetes",className:"hover:text-slate-300",children:"集群"}),c&&e.jsxs(e.Fragment,{children:[e.jsx(J,{"code-path":"src/components/kubernetes/EventsPage.tsx:138:29",className:"h-3 w-3"}),e.jsx(q,{"code-path":"src/components/kubernetes/EventsPage.tsx:138:65",to:`/kubernetes/${c}`,className:"hover:text-slate-300",children:c})]}),e.jsx(J,{"code-path":"src/components/kubernetes/EventsPage.tsx:139:9",className:"h-3 w-3"}),e.jsx("span",{"code-path":"src/components/kubernetes/EventsPage.tsx:139:45",className:"text-slate-300",children:"事件"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:143:7",className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("h2",{"code-path":"src/components/kubernetes/EventsPage.tsx:144:9",className:"text-lg font-semibold text-slate-100 flex items-center gap-2",children:[e.jsx(be,{"code-path":"src/components/kubernetes/EventsPage.tsx:145:11",className:"h-5 w-5 text-yellow-400"}),"事件中心"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:147:9",className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(N,{"code-path":"src/components/kubernetes/EventsPage.tsx:148:11",value:c,onValueChange:s=>{Y(s),O(`/kubernetes/${s}/events`)},children:[e.jsx(f,{"code-path":"src/components/kubernetes/EventsPage.tsx:149:13",className:"w-40 h-8 text-xs bg-slate-800 border-slate-700",children:e.jsx(y,{"code-path":"src/components/kubernetes/EventsPage.tsx:149:87"})}),e.jsx(w,{"code-path":"src/components/kubernetes/EventsPage.tsx:150:13",className:"bg-slate-800 border-slate-700",children:ne.map(s=>e.jsx(o,{"code-path":"src/components/kubernetes/EventsPage.tsx:151:42",value:s.code||String(s.id),className:"text-xs",children:s.name||s.code},s.id))})]}),e.jsxs(N,{"code-path":"src/components/kubernetes/EventsPage.tsx:154:11",value:i,onValueChange:s=>{oe(s),B(""),R("")},children:[e.jsx(f,{"code-path":"src/components/kubernetes/EventsPage.tsx:155:13",className:"w-36 h-8 text-xs bg-slate-800 border-slate-70Line truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{i as he,k as ue,r as n,j as e,m as G,n as J,J as be,B as ge,A as ve,T as E,w as Q,q as ke}from"./index-DfyorCky.js";import{C as x,a as p}from"./card-C55cvSHg.js";import{B as g}from"./badge-xNW8x0G1.js";import{S as N,a as f,b as y,c as w,d as o}from"./select-D5qUzdAs.js";import{T as Ee,a as je,b as L,c as h,d as Pe,e as d}from"./table-5sHV4Akp.js";import{k as S}from"./kubernetes-J8O09fK7.js";import{R as Ne}from"./refresh-cw-DUB_tAG-.js";import{L as Z}from"./layers-FW4KKJMi.js";import{R as W,C as D,X as K,Y as M,T as V,B as O,a as ee}from"./generateCategoricalChart-6v9BPbG2.js";import{B as H}from"./BarChart-DlFprovY.js";import"./index-CWVNW_qu.js";const se=["#EF4444","#F59E0B","#3B82F6","#8B5CF6","#EC4899","#14B8A6","#F97316","#6366F1","#84CC16","#06B6D4"];function $e(){const{clusterCode:te}=he(),I=ue(),[C,U]=n.useState(!1),[m,X]=n.useState([]),[ne,ae]=n.useState([]),[ce,re]=n.useState([]),[i,oe]=n.useState("all"),[j,le]=n.useState("all"),[T,xe]=n.useState("0"),[c,Y]=n.useState(te||""),[r,q]=n.useState(null),[u,B]=n.useState(""),[b,R]=n.useState(""),[pe,de]=n.useState(null);n.useEffect(()=>{S.getClusters().then(s=>{const t=s?.list||[];if(ae(t),!c&&t.length>0){const a=t[0].code||String(t[0].id);Y(a),I(`/kubernetes/${a}/events`,{replace:!0})}}).catch(()=>{})},[]),n.useEffect(()=>{c&&S.getNamespaces(c).then(s=>{re(Array.isArray(s)?s:s?.list||s?.data||[])}).catch(()=>{})},[c]);const _=n.useCallback(async()=>{if(c){U(!0);try{const s=i==="all"?void 0:i,t=j==="all"?void 0:j,a=await S.getEvents(c,s,t);X(Array.isArray(a)?a:a?.list||[])}catch{X([])}finally{U(!1)}}},[c,i,j]),A=n.useCallback(async()=>{if(c)try{const s=i==="all"?void 0:i,t=parseInt(T)||void 0,a=await S.getEventsSummary(c,s,t);q(a||null)}catch{q(null)}},[c,i,T]);n.useEffect(()=>{_()},[_]),n.useEffect(()=>{A()},[A]);const v=n.useMemo(()=>{let s=m;return u&&(s=s.filter(t=>t.reason===u)),b&&(s=s.filter(t=>(t.object||"").startsWith(b+"/"))),s},[m,u,b]),me=n.useMemo(()=>m.filter(s=>s.type==="Warning").length,[m]),ie=n.useMemo(()=>m.filter(s=>s.type==="Normal").length,[m]),k=n.useMemo(()=>(r?.by_reason||[]).map(t=>({name:t.reason||"Unknown",count:t.count})),[r]),z=n.useMemo(()=>(r?.by_namespace||[]).map(t=>({name:t.namespace||"<cluster>",count:t.count})),[r]),$=n.useMemo(()=>(r?.by_kind||[]).map(t=>({name:t.kind||"Unknown",count:t.count})),[r]),F=s=>s?s.replace("T"," ").substring(0,19):"-",P=s=>{if(!s)return"";const t=Date.now()-new Date(s).getTime();if(t<0)return"";const a=Math.floor(t/6e4);if(a<1)return"刚刚";if(a<60)return`${a}分钟前`;const l=Math.floor(a/60);return l<24?`${l}小时前`:`${Math.floor(l/24)}天前`};return e.jsxs("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:134:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:136:7",className:"flex items-center gap-2 text-sm text-slate-500",children:[e.jsx(G,{"code-path":"src/components/kubernetes/EventsPage.tsx:137:9",to:"/kubernetes",className:"hover:text-slate-300",children:"集群"}),c&&e.jsxs(e.Fragment,{children:[e.jsx(J,{"code-path":"src/components/kubernetes/EventsPage.tsx:138:29",className:"h-3 w-3"}),e.jsx(G,{"code-path":"src/components/kubernetes/EventsPage.tsx:138:65",to:`/kubernetes/${c}`,className:"hover:text-slate-300",children:c})]}),e.jsx(J,{"code-path":"src/components/kubernetes/EventsPage.tsx:139:9",className:"h-3 w-3"}),e.jsx("span",{"code-path":"src/components/kubernetes/EventsPage.tsx:139:45",className:"text-slate-300",children:"事件"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:143:7",className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("h2",{"code-path":"src/components/kubernetes/EventsPage.tsx:144:9",className:"text-lg font-semibold text-slate-100 flex items-center gap-2",children:[e.jsx(be,{"code-path":"src/components/kubernetes/EventsPage.tsx:145:11",className:"h-5 w-5 text-yellow-400"}),"事件中心"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:147:9",className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(N,{"code-path":"src/components/kubernetes/EventsPage.tsx:148:11",value:c,onValueChange:s=>{Y(s),I(`/kubernetes/${s}/events`)},children:[e.jsx(f,{"code-path":"src/components/kubernetes/EventsPage.tsx:149:13",className:"w-40 h-8 text-xs bg-slate-800 border-slate-700",children:e.jsx(y,{"code-path":"src/components/kubernetes/EventsPage.tsx:149:87"})}),e.jsx(w,{"code-path":"src/components/kubernetes/EventsPage.tsx:150:13",className:"bg-slate-800 border-slate-700",children:ne.map(s=>e.jsx(o,{"code-path":"src/components/kubernetes/EventsPage.tsx:151:42",value:s.code||String(s.id),className:"text-xs",children:s.name||s.code},s.id))})]}),e.jsxs(N,{"code-path":"src/components/kubernetes/EventsPage.tsx:154:11",value:i,onValueChange:s=>{oe(s),B(""),R("")},children:[e.jsx(f,{"code-path":"src/components/kubernetes/EventsPage.tsx:155:13",className:"w-36 h-8 text-xs bg-slate-800 border-slate-700",children:e.jsx(y,{"code-path":Line truncated
|
||||
@@ -1,3 +0,0 @@
|
||||
import{g as ya,j as a,r as o,h as oa,A as J,B as D,L as aa,T as Na,q as Q,v as Ya,o as ka,W as Wa,D as ra,b as na,c as da,d as ca,e as _a,H as pa,a9 as Qa,t as Xa,I as X,E as as,aq as $a,a as ss,k as es,a7 as ts,w as os,f as va,K as Za,G as Ta}from"./index-DfyorCky.js";import{B as E}from"./badge-xNW8x0G1.js";import{C as z,b as Ga,c as wa,a as k}from"./card-C55cvSHg.js";import{S as ba,a as ua,b as ga,c as fa,d as O}from"./select-D5qUzdAs.js";import{L}from"./label-BK0h2apY.js";import{t as u}from"./index-a3ybMjbR.js";import{s as Fa}from"./server-CjDPBaTN.js";import{z as rs,p as ns,d as ja}from"./monitor-BAaBXIsC.js";import{a as Aa}from"./agent-DqqIRCQX.js";import{T as ds}from"./trending-up-CdusV6gc.js";import{R as ha}from"./refresh-cw-DUB_tAG-.js";import{W as Ma}from"./wifi-FqsslTyA.js";import{A as Ia}from"./arrow-up-down-DnvTt5VG.js";import{T as Ba,a as Oa,b as R,c as K}from"./tabs-CIh_yD4s.js";import{Z as ta}from"./zap-D2uWSK32.js";import{C as cs}from"./copy-DXW4LnkN.js";import{D as hs}from"./download-DoZfYs2h.js";import{P as ms}from"./play-cdPayOtJ.js";import{C as Da}from"./checkbox-CH0bpj6b.js";import{M as is,a as ls}from"./minimize-2-CiCQYRfn.js";import{P as Sa}from"./package-open-CUXo2Tda.js";import{T as xs}from"./trash-2-Dx32pOzT.js";import{E as Ea}from"./external-link-CzIpMNu1.js";import{P as Ca}from"./plus-CUG-9kpu.js";import"./index-CWVNW_qu.js";const ps=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Ua=ya("arrow-down",ps);const bs=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Ha=ya("arrow-up",bs);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){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 js(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 Ds({panel:s}){const r=js();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(ds,{"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/dashbLine truncated
|
||||
...
|
||||
-----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:B,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(pa,{"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:ma.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((Z,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:Z})]},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:52:43",className:"w-3.5 h-3.5"})},{id:"zabbix",label:"Zabbix",icon:a.jsx(J,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:53:42",className:"w-3.5 h-3.5"})},{id:"prometheus",label:"Prometheus",icon:a.jsx(J,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:54:50",className:"w-3.5 h-3.5"})},{id:"dashboard",label:"自定义",icon:a.jsx($a,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:55:42",className:"w-3.5 h-3.5"})}],_s=()=>{const s=ss(),r=es(),[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,W]=o.useState(10),[v,h]=o.useState(new Set),[A,$]=o.useState(!1),[F,M]=o.useState(null),[I,T]=o.useState(!1),[p,f]=o.useState("install"),[n,l]=o.useState(!1),[S,j]=o.useState(!1),[ma,B]=o.useState(new Set),[d,Z]=o.useState(!1),sa=async()=>{if(await s({title:"批量卸载 Agent",description:`确定卸载选中的 ${ea.length} 台主机的 AIOps Agent?卸载将在后台异步执行。`,confirmText:"卸载",variant:"destructive"})){Z(!0),B(new Set(ea));try{await Aa.batchUninstall(ea),u.success(`已提交:批量卸载 ${ea.length} 台主机的 Agent,后台执行中,30秒后自动刷新`),h(new Set),setTimeout(()=>{q(),B(new Set)},3e4)}catch{u.error("提交失败"),B(new Set)}finally{Z(!1)}}},Pa=Math.max(1,Math.ceil(e.length/y)),q=async()=>{try{c(fs(await oa.get("/agent/latest")))}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]??"",_=C[b]??"";return b==="agent_status"&&(G=t.agent_status||"",_=C.agent_status||""),typeof G=="number"?N==="asc"?G-_:_-G:N==="asc"?String(G).localeCompare(String(_)):String(_).localeCompare(String(G))
Line truncated
|
||||
@@ -0,0 +1,3 @@
|
||||
import{i as Ya,j as a,r as o,h as oa,A as J,B as D,L as aa,T as Na,S as Q,v as Qa,p as za,$ as ka,D as ra,a as na,b as da,c as ca,d as Wa,E as pa,K as Xa,t as as,y as ss,aH as _a,f as es,m as ts,al as os,I as rs,e as va,J as $a,z as Za}from"./index-Dmami9WE.js";import{I as X}from"./input-NsU9nXZF.js";import{B}from"./badge-3UzCvU7L.js";import{C as U,b as ya,c as Ga,a as H}from"./card-CIfC-8Rh.js";import{S as ba,a as ua,b as ga,c as fa,d as I}from"./select-DUbxjT0z.js";import{L}from"./label-Ap_-SPYI.js";import{t as u}from"./index-BuEnLCjT.js";import{s as Ta}from"./server-3HmnhxQB.js";import{z as ns,p as ds,d as ja}from"./monitor-CicbJUrQ.js";import{a as Pa}from"./agent-B3ElXCx8.js";import{T as cs}from"./trending-up-d1DKmRom.js";import{R as ha}from"./refresh-cw-CTBERyFc.js";import{W as Fa}from"./wifi-CtC3YBV7.js";import{A as Ma}from"./arrow-up-down-Cn71rsC9.js";import{A as Ia,a as Ba}from"./arrow-up-DMuDiHn6.js";import{S as Oa}from"./stat-strip-BteRU1Iu.js";import{T as Ea,a as Ua,b as R,c as K}from"./tabs-lV44z_UR.js";import{Z as ta}from"./zap-CocSkPPl.js";import{C as hs}from"./copy-CE_T92Lk.js";import{D as ms}from"./download-Vuij9wGr.js";import{P as is}from"./play-0EwQQJX_.js";import{C as Da}from"./checkbox-DoAtRzQj.js";import{M as ls,a as xs}from"./minimize-2-BHcbNmdK.js";import{P as Aa}from"./package-open-Bj2Cp1LK.js";import{T as ps}from"./trash-2-DWVnIU6o.js";import{E as Ha}from"./external-link-2hCYo_Ng.js";import{P as Sa}from"./plus-O65gX7Qz.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";const bs=[["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"}]],us=Ya("wifi-off",bs);function gs(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 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 rLine truncated
|
||||
...
|
||||
-----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(pa,{"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:ma.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 ks=[{id:"agent",label:"Agent 主机",icon:a.jsx(Q,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:52:43",className:"w-3.5 h-3.5"})},{id:"zabbix",label:"Zabbix",icon:a.jsx(J,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:53:42",className:"w-3.5 h-3.5"})},{id:"prometheus",label:"Prometheus",icon:a.jsx(J,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:54:50",className:"w-3.5 h-3.5"})},{id:"dashboard",label:"自定义",icon:a.jsx(_a,{"code-path":"src/components/monitor/dashboard/GrafanaDashboard.tsx:55:42",className:"w-3.5 h-3.5"})}],Ws=()=>{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),[ma,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 Pa.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(gs(await oa.get("/agent/latest")))}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))
Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{i as os,aG as gs,r as i,j as t,L as ms,S as Y,B as A,aH as us,N as dt,I as bs,p as Ms,C as at,A as Wt,P as Hs,D as Kt,a as qt,b as Ut,c as Vt,d as Xt,e as Jt}from"./index-Dmami9WE.js";import{a as G}from"./agent-B3ElXCx8.js";import{C,a as S}from"./card-CIfC-8Rh.js";import{S as Qt,a as Yt,b as Zt,c as ts,d as rt}from"./select-DUbxjT0z.js";import{T as js,a as vs,b as fs,c as z}from"./tabs-lV44z_UR.js";import{B as Z}from"./badge-3UzCvU7L.js";import{H as W}from"./hard-drive-DmC04Y5r.js";import{D as mt}from"./disc-BPxL4arn.js";import{C as ut}from"./circle-x-BBQeW1R3.js";import{R as Mt,C as Ht,X as jt,Y as vt,T as ft,q as as}from"./generateCategoricalChart-ZqCvxO-S.js";import{A as Nt,a as it}from"./AreaChart-CrvX3B0s.js";import{R as ss}from"./refresh-cw-CTBERyFc.js";import{P as Ns}from"./plus-O65gX7Qz.js";import{S as _s}from"./square-pen-B3dPIBrm.js";import{T as ys}from"./trash-2-DWVnIU6o.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";const ws=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}],["path",{d:"M3.22 13H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27",key:"auskq0"}]],ks=os("heart-pulse",ws);const Cs=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],es=os("list",Cs),bt=[{label:"1小时",hours:1,window:60,buckets:60},{label:"6小时",hours:6,window:300,buckets:72},{label:"12小时",hours:12,window:600,buckets:72},{label:"1天",hours:24,window:1800,buckets:96},{label:"3天",hours:72,window:3600,buckets:72},{label:"7天",hours:168,window:10800,buckets:56},{label:"14天",hours:336,window:21600,buckets:48}];function u(r,T,O){if(!r||r.length===0)return[];const F=Math.max(1,Math.ceil(r.length/O)),d=[];for(let j=0;j<r.length;j+=F){const y=r.slice(j,j+F),w=T.slice(j,j+F),v=y.reduce((nt,K)=>nt+K,0)/y.length,f=Math.max(...y),R=Math.min(...y),n=w[Math.floor(w.length/2)]||0;d.push({time:new Date(n*1e3).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}),timestamp:n,avg:Number(v.toFixed(2)),max:Number(f.toFixed(2)),min:Number(R.toFixed(2)),count:y.length})}return d.slice(-O)}function M(r){if(!r)return{};if(typeof r=="object")return r;try{return JSON.parse(r)}catch{return{}}}function ct(r){return r>=1024*1024*1024?`${(r/1024/1024/1024).toFixed(1)} GB/s`:r>=1024*1024?`${(r/1024/1024).toFixed(1)} MB/s`:r>=1024?`${(r/1024).toFixed(1)} KB/s`:`${r.toFixed(1)} B/s`}function Us(){const[r]=gs(),T=r.get("host")||"",[O,F]=i.useState([]),[d,j]=i.useState(T),[y,w]=i.useState(!0),[P,v]=i.useState("basic"),[f,R]=i.useState(1),[n,nt]=i.useState("avg"),[K,_t]=i.useState([]),[o,yt]=i.useState(null),[b,rs]=i.useState(null),[wt,tt]=i.useState([]),[cs,q]=i.useState(!1),[U,kt]=i.useState(null),[a,N]=i.useState({name:"",hostname:"",probe_type:"http_get",http_url:"",http_method:"GET",http_expect_code:200,http_expect_body:"",tcp_host:"",tcp_port:3306,exec_command:"",timeout:10,interval:60,description:""}),V=i.useCallback(()=>{d&&G.getHealthProbes({hostname:d}).then(s=>{Array.isArray(s)?tt(s):s?.list?tt(s.list):tt([])}).catch(()=>tt([]))},[d]),[k,xt]=i.useState("whitelist"),[X,Ct]=i.useState([]),[ds,st]=i.useState(!1),[St,Tt]=i.useState(!1),pt=i.useCallback(()=>{d&&G.getPortPolicy(d).then(s=>{s?.data&&(xt(s.data.port_filter_mode||"blacklist"),Ct(s.data.port_whitelist||[]))}).catch(()=>{})},[d]);i.useEffect(()=>{pt()},[pt]);const is=async()=>{if(d){Tt(!0);try{await G.savePortPolicy(d,{port_filter_mode:k,port_whitelist:X}),st(!1)}catch{}finally{Tt(!1)}}};i.useEffect(()=>{V()},[V]);const h=bt.find(s=>s.hours===f)||bt[0];i.useEffect(()=>{G.getLatest().then(s=>{const e=Array.isArray(s)?s:s?.data||s?.list||[];if(F(e),e.length>0&&!d){const l=T?e.find(E=>E.hostname===T):null;j(l?.hostname||e[0]?.hostname||"")}const c=e.find(l=>l.hostname===(d||T));c&&(yt(c),rs(c))}).catch(()=>{}).finally(()=>w(!1))},[d]),i.useEffect(()=>{d&&G.getHistory(d,f).then(s=>{const e=Array.isArray(s)?s:s?.data||s?.list||[];if(_t(e),e.length>0){const c=e[e.length-1];yt(l=>({...l,...c}))}}).catch(()=>_t([])).finally(()=>w(!1))},[d,f]);const g=i.useMemo(()=>{const s=[],e=[],c=[],l=[],E=[],et=[],B=[],$t=[],At=[],Ft=[],It=[],Dt=[],Et=[],Bt=[],Ot=[],Gt=[],Rt=[],zt=[],Lt=[],ht=[],m=[];for(const x of K){const ns=x.report_time?new Date(x.report_time).getTime()/1e3:x.created_at?new Date(x.created_at).getTime()/1e3:0;m.push(ns),s.push(x.cpu_usage||0),Bt.push(x.cpu_iowait||0),e.push(x.mem_usage||0),Ot.push(x.mem_available||0),c.push(x.load1||0),l.push(x.disk_usage||0);const ot=M(x.disk_info);if(Array.isArray(ot)&&ot.length>0){const ls=ot.find(hs=>hs.mount==="/")||ot[0];ht.push(ls?.inode_usage_pct||0)}else ht.push(0);const $=M(x.net_info);E.push($.tcp_established||0),et.push($.tcp_time_wait||0),B.push($.tcp_close_wait||0),Rt.push(($.tcp_established||0)+($.tcp_time_wait||0)Line truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{g as os,ap as gs,r as n,j as t,L as ms,q as Y,B as A,aq as us,N as dt,w as bs,o as Ms,x as at,A as Wt,a3 as Hs,D as Kt,b as qt,c as Ut,d as Vt,e as Xt,f as Jt}from"./index-DfyorCky.js";import{a as R}from"./agent-DqqIRCQX.js";import{C,a as S}from"./card-C55cvSHg.js";import{S as Qt,a as Yt,b as Zt,c as ts,d as rt}from"./select-D5qUzdAs.js";import{T as js,a as vs,b as fs,c as G}from"./tabs-CIh_yD4s.js";import{B as Z}from"./badge-xNW8x0G1.js";import{H as W}from"./hard-drive-BbPmnARR.js";import{D as mt}from"./disc-EsE6x5Oh.js";import{C as ut}from"./circle-x-DK79Dhg2.js";import{R as Mt,C as Ht,X as jt,Y as vt,T as ft,q as as}from"./generateCategoricalChart-6v9BPbG2.js";import{A as Nt,a as nt}from"./AreaChart-B2zlWfdX.js";import{R as ss}from"./refresh-cw-DUB_tAG-.js";import{P as Ns}from"./plus-CUG-9kpu.js";import{S as _s}from"./square-pen-BxUFAe0F.js";import{T as ys}from"./trash-2-Dx32pOzT.js";import"./index-CWVNW_qu.js";const ws=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}],["path",{d:"M3.22 13H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27",key:"auskq0"}]],ks=os("heart-pulse",ws);const Cs=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],es=os("list",Cs),bt=[{label:"1小时",hours:1,window:60,buckets:60},{label:"6小时",hours:6,window:300,buckets:72},{label:"12小时",hours:12,window:600,buckets:72},{label:"1天",hours:24,window:1800,buckets:96},{label:"3天",hours:72,window:3600,buckets:72},{label:"7天",hours:168,window:10800,buckets:56},{label:"14天",hours:336,window:21600,buckets:48}];function u(r,T,O){if(!r||r.length===0)return[];const F=Math.max(1,Math.ceil(r.length/O)),d=[];for(let j=0;j<r.length;j+=F){const y=r.slice(j,j+F),w=T.slice(j,j+F),v=y.reduce((it,K)=>it+K,0)/y.length,f=Math.max(...y),z=Math.min(...y),i=w[Math.floor(w.length/2)]||0;d.push({time:new Date(i*1e3).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}),timestamp:i,avg:Number(v.toFixed(2)),max:Number(f.toFixed(2)),min:Number(z.toFixed(2)),count:y.length})}return d.slice(-O)}function M(r){if(!r)return{};if(typeof r=="object")return r;try{return JSON.parse(r)}catch{return{}}}function ct(r){return r>=1024*1024*1024?`${(r/1024/1024/1024).toFixed(1)} GB/s`:r>=1024*1024?`${(r/1024/1024).toFixed(1)} MB/s`:r>=1024?`${(r/1024).toFixed(1)} KB/s`:`${r.toFixed(1)} B/s`}function qs(){const[r]=gs(),T=r.get("host")||"",[O,F]=n.useState([]),[d,j]=n.useState(T),[y,w]=n.useState(!0),[P,v]=n.useState("basic"),[f,z]=n.useState(1),[i,it]=n.useState("avg"),[K,_t]=n.useState([]),[o,yt]=n.useState(null),[b,rs]=n.useState(null),[wt,tt]=n.useState([]),[cs,q]=n.useState(!1),[U,kt]=n.useState(null),[a,N]=n.useState({name:"",hostname:"",probe_type:"http_get",http_url:"",http_method:"GET",http_expect_code:200,http_expect_body:"",tcp_host:"",tcp_port:3306,exec_command:"",timeout:10,interval:60,description:""}),V=n.useCallback(()=>{d&&R.getHealthProbes({hostname:d}).then(s=>{Array.isArray(s)?tt(s):s?.list?tt(s.list):tt([])}).catch(()=>tt([]))},[d]),[k,xt]=n.useState("whitelist"),[X,Ct]=n.useState([]),[ds,st]=n.useState(!1),[St,Tt]=n.useState(!1),pt=n.useCallback(()=>{d&&R.getPortPolicy(d).then(s=>{s?.data&&(xt(s.data.port_filter_mode||"blacklist"),Ct(s.data.port_whitelist||[]))}).catch(()=>{})},[d]);n.useEffect(()=>{pt()},[pt]);const ns=async()=>{if(d){Tt(!0);try{await R.savePortPolicy(d,{port_filter_mode:k,port_whitelist:X}),st(!1)}catch{}finally{Tt(!1)}}};n.useEffect(()=>{V()},[V]);const h=bt.find(s=>s.hours===f)||bt[0];n.useEffect(()=>{R.getLatest().then(s=>{const e=Array.isArray(s)?s:s?.data||s?.list||[];if(F(e),e.length>0&&!d){const l=T?e.find(E=>E.hostname===T):null;j(l?.hostname||e[0]?.hostname||"")}const c=e.find(l=>l.hostname===(d||T));c&&(yt(c),rs(c))}).catch(()=>{}).finally(()=>w(!1))},[d]),n.useEffect(()=>{d&&R.getHistory(d,f).then(s=>{const e=Array.isArray(s)?s:s?.data||s?.list||[];if(_t(e),e.length>0){const c=e[e.length-1];yt(l=>({...l,...c}))}}).catch(()=>_t([])).finally(()=>w(!1))},[d,f]);const g=n.useMemo(()=>{const s=[],e=[],c=[],l=[],E=[],et=[],B=[],$t=[],At=[],Ft=[],It=[],Dt=[],Et=[],Bt=[],Ot=[],Rt=[],zt=[],Gt=[],Lt=[],ht=[],m=[];for(const x of K){const is=x.report_time?new Date(x.report_time).getTime()/1e3:x.created_at?new Date(x.created_at).getTime()/1e3:0;m.push(is),s.push(x.cpu_usage||0),Bt.push(x.cpu_iowait||0),e.push(x.mem_usage||0),Ot.push(x.mem_available||0),c.push(x.load1||0),l.push(x.disk_usage||0);const ot=M(x.disk_info);if(Array.isArray(ot)&&ot.length>0){const ls=ot.find(hs=>hs.mount==="/")||ot[0];ht.push(ls?.inode_usage_pct||0)}else ht.push(0);const $=M(x.net_info);E.push($.tcp_established||0),et.push($.tcp_time_wait||0),B.push($.tcp_close_wait||0),zt.push(($.tcp_established||0)+($.tcp_time_wait||0)+($.tcp_close_wait||0)),$t.push(Line truncated
|
||||
@@ -0,0 +1,10 @@
|
||||
import{r as n,j as e,s as ae,B as T,ah as ce,af as _e,ab as Re,a8 as oe,ai as Pe,aa as $,ac as X,aj as Te,ad as H,a9 as Ee,ae as Ae,a0 as E,D as le,a as ue,b as Me,c as de,d as ie,e as Ie,$ as Fe,E as Oe,L as Ge,X as Le,aJ as Be,aK as Ue,aL as ze,aM as $e,aN as Q,aO as F,O as We,y as Ve,v as qe,T as He,P as Xe}from"./index-Dmami9WE.js";import{C as O,b as U,c as z,d as xe,a as G}from"./card-CIfC-8Rh.js";import{I as B}from"./input-NsU9nXZF.js";import{B as y}from"./badge-3UzCvU7L.js";import{k as w}from"./kubernetes-D2-GnE0t.js";import{t as I}from"./index-BuEnLCjT.js";import{T as Je,a as Ye,b as A,c as M}from"./tabs-lV44z_UR.js";import{C as pe}from"./circle-x-BBQeW1R3.js";import{R as Ze,C as Qe,X as et,Y as tt,T as st}from"./generateCategoricalChart-ZqCvxO-S.js";import{A as rt,a as ee}from"./AreaChart-CrvX3B0s.js";import{T as te}from"./textarea-DHUZ6N85.js";import{L as P}from"./label-Ap_-SPYI.js";import{u as nt}from"./index-CtCQcvyh.js";import{C as at}from"./circle-CGbaa1m0.js";import{x as ct,a as ot}from"./xterm-DSqgeKvr.js";import{M as lt,a as ut}from"./minimize-2-BHcbNmdK.js";import{R as q}from"./refresh-cw-CTBERyFc.js";import{P as dt}from"./plus-O65gX7Qz.js";import{S as it}from"./search-Dd-PeBfg.js";import{E as xt}from"./ellipsis-BcWfelgl.js";import{D as pt}from"./download-Vuij9wGr.js";import{T as mt}from"./trash-2-DWVnIU6o.js";function bt({cluster:a,onClose:x}){const[r,g]=n.useState([]),[s,u]=n.useState([]),[d,K]=n.useState([]),[k,C]=n.useState([]),[b,f]=n.useState([]),h=n.useMemo(()=>{if(!r||r.length===0)return{cpuPct:0,memPct:0};let t=0,i=0,m=0;for(const j of r){const D=j.cpu||0,o=j.cpu_usage_m?parseFloat(String(j.cpu_usage_m).replace("m","")):0,l=D>0?o/1e3/D*100:0,N=j.memory_mb||0,_=j.mem_usage_mi?parseFloat(String(j.mem_usage_mi).replace("Mi","").replace("Ki","")):0,V=j.mem_usage_mi?.includes?.("Ki")?_/1024:j.mem_usage_mi?.includes?.("Gi")?_*1024:_,L=N>0?V/N*100:0;(l>0||L>0)&&(t+=l,i+=L,m++)}return{cpuPct:m>0?t/m:0,memPct:m>0?i/m:0}},[r]),p=async t=>{try{const[i,m,j,D,o]=await Promise.all([w.getNodes(t).catch(()=>[]),w.getPods(t).catch(()=>[]),w.getDeployments(t).catch(()=>[]),w.getServices(t).catch(()=>[]),w.getIngresses(t).catch(()=>[])]),l=N=>Array.isArray(N)?N:N?.list||[];g(l(i)),u(l(m)),K(l(j)),C(l(D)),f(l(o))}catch(i){console.error("加载集群详情失败:",i)}};return n.useEffect(()=>{a?.id&&p(a.id)},[a?.id]),e.jsxs(O,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:81:5",className:"bg-slate-900 border-slate-800",children:[e.jsx(U,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:82:7",children:e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:83:9",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:84:11",className:"flex items-center gap-3",children:[e.jsx(ae,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:85:13",className:"h-6 w-6 text-blue-400"}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:86:13",children:[e.jsx(z,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:87:15",className:"text-slate-100",children:a.name}),e.jsxs(xe,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:88:15",className:"text-slate-500",children:[a.version," · ",a.node_count||0," 节点 · 创建于"," ",a.created_at?new Date(a.created_at).toLocaleDateString():"-"]})]})]}),e.jsxs(T,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:94:11",variant:"ghost",size:"sm",className:"text-slate-400 hover:text-slate-100",onClick:x,children:[e.jsx(pe,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:100:13",className:"h-4 w-4 mr-2"}),"关闭"]})]})}),e.jsx(G,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:105:7",children:e.jsxs(Je,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:106:9",defaultValue:"overview",className:"w-full",children:[e.jsxs(Ye,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:107:11",className:"bg-slate-800 border border-slate-700 flex-wrap h-auto",children:[e.jsx(A,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:108:13",value:"overview",className:"data-[state=active]:bg-slate-700",children:"概览"}),e.jsxs(A,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:111:13",value:"nodes",className:"data-[state=active]:bg-slate-700",children:["节点 (",r.length,")"]}),e.jsxs(A,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:114:13",value:"pods",className:"data-[state=active]:bg-slate-700",children:["Pod (",s.length,")"]}),e.jsxs(A,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:117:13",value:"deployments",className:"data-[state=active]:bg-slate-700",children:["Deployment (",d.length,")"]}),e.jsxs(A,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:120:13",value:"services",className:"data-[Line truncated
|
||||
kind: Config
|
||||
clusters:
|
||||
- cluster:
|
||||
server: https://10.0.0.1:6443
|
||||
...`,rows:10,className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] placeholder:text-[var(--dg-text-muted)] font-mono text-xs"}),!b&&e.jsx("p",{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:243:17",className:"text-xs text-[var(--dg-text-muted)]",children:"粘贴 kubeconfig 内容后将自动解析 API Server 地址"})]})]}),e.jsxs(Ie,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:250:9",children:[e.jsx(T,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:251:11",variant:"outline",onClick:()=>{x(!1)},className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)] hover:bg-[var(--dg-bg-hover)]",children:"取消"}),e.jsx(T,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:258:11",onClick:j,disabled:D,className:"bg-[var(--dg-blue)] hover:opacity-90 text-white",children:d?"保存中...":r?"保存":"添加"})]})]})})}function Rt({open:a,onOpenChange:x,clusterId:r,clusterName:g}){const s=n.useRef(null),u=n.useRef(null),d=n.useRef(null),K=n.useRef(null),[k,C]=n.useState(!1),[b,f]=n.useState(!1),[h,p]=n.useState("");return n.useEffect(()=>{a||f(!1)},[a]),n.useEffect(()=>{if(!a||!r)return;const t=new ct.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,theme:{background:"#0f172a",foreground:"#e2e8f0",cursor:"#38bdf8",selectionBackground:"#1e40af",black:"#1e293b",red:"#ef4444",green:"#10b981",yellow:"#f59e0b",blue:"#3b82f6",magenta:"#a855f7",cyan:"#06b6d4",white:"#e2e8f0",brightBlack:"#475569",brightRed:"#f87171",brightGreen:"#34d399",brightYellow:"#fbbf24",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#22d3ee",brightWhite:"#f8fafc"}}),i=new ot.FitAddon;t.loadAddon(i),u.current=t,K.current=i;const j=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}`,D=Fe.getState().token||"",o=`${j.replace(/^http/,"ws").replace("/api/v1","")}/ws/kubectl?token=${encodeURIComponent(D)}&id=${r}`,l=new WebSocket(o);return d.current=l,t.onData(N=>{l.readyState===WebSocket.OPEN&&l.send(JSON.stringify({status:0,data:N}))}),l.onmessage=N=>{try{const _=JSON.parse(N.data);_.status===0&&typeof _.data=="string"&&t.write(_.data)}catch{typeof N.data=="string"&&t.write(N.data)}},l.onopen=()=>{C(!0),p(""),s.current&&(t.open(s.current),requestAnimationFrame(()=>{try{i.fit()}catch{}}),setTimeout(()=>{try{t.focus()}catch{}},150))},l.onclose=()=>{C(!1),t.write(`\r
|
||||
\x1B[31m[连接已断开]\x1B[0m\r
|
||||
`)},l.onerror=()=>{p("WebSocket 连接失败"),t.write(`\r
|
||||
\x1B[31m[连接发生错误]\x1B[0m\r
|
||||
`)},()=>{try{(l.readyState===WebSocket.OPEN||l.readyState===WebSocket.CONNECTING)&&l.close(),t.dispose()}catch{}u.current=null,d.current=null,C(!1)}},[a,r]),n.useEffect(()=>{if(!a)return;const t=s.current;if(!t)return;let i;const m=new ResizeObserver(()=>{clearTimeout(i),i=setTimeout(()=>{if(K.current&&u.current&&d.current)try{K.current.fit(),u.current.focus();const{cols:j,rows:D}=u.current;d.current.readyState===WebSocket.OPEN&&d.current.send(JSON.stringify({status:1,cols:j,rows:D}))}catch{}},60)});return m.observe(t),()=>{clearTimeout(i),m.disconnect()}},[a]),e.jsx(le,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:161:5",open:a,onOpenChange:x,children:e.jsxs(ue,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:162:7",showCloseButton:!1,onOpenAutoFocus:t=>t.preventDefault(),className:E("bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] p-0 gap-0","!duration-0 !transition-none",b?"!max-w-none !w-screen !h-screen !rounded-none !translate-x-0 !translate-y-0 !left-0 !top-0":""),style:b?{maxWidth:"100vw",width:"100vw",height:"100vh"}:{maxWidth:"900px",width:"90vw"},children:[e.jsxs(de,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:174:9",className:"sr-only",children:["kubectl — ",g]}),e.jsx(ie,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:175:9",className:"sr-only",children:"Kubernetes 集群命令行终端"}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:178:9",className:"flex items-center justify-between px-4 py-2 border-b border-[var(--dg-border)]",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:179:11",className:"flex items-center gap-2 text-sm",children:[e.jsx("div",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:180:13",className:E("w-2 h-2 rounded-full",k?"bg-emerald-400":h?"bg-red-400":"bg-yellow-400")}),e.jsx(Oe,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:181:13",className:"h-4 w-4 text-blue-400"}),e.jsxs("span",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:182:13",className:"text-[var(--dg-text-primary)] font-medium",children:["kubectl — ",g]}),!k&&!h&&e.jsx(Ge,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:183:38",className:"h-3 w-3 animate-spin text-[var(--dg-text-muted)]"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:185:11",className:"flex items-center gap-1",children:[e.jsx("button",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:186:13",onClick:()=>f(!b),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]",children:b?e.jsx(lt,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:190:29",className:"h-4 w-4"}):e.jsx(ut,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:190:65",className:"h-4 w-4"})}),e.jsx("button",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:192:13",onClick:()=>x(!1),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]",children:e.jsx(Le,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:196:15",className:"h-4 w-4"})})]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:202:9",ref:s,className:"bg-[#0f172a]",style:{height:b?"calc(100vh - 49px)":"480px"}})]})})}function Qt(){const[a,x]=n.useState([]),[r,g]=n.useState(!0),[s,u]=n.useState(null),[d,K]=n.useState(""),[k,C]=n.useState(!1),[b,f]=n.useState(null),[h,p]=n.useState(null),[t,i]=n.useState(!1),[m,j]=n.useState(null),[D,o]=n.useState(!1),l=async()=>{try{g(!0);const c=await w.getClusters();x(c?.list||[])}catch(c){console.error("加载集群列表失败:",c),x([])}finally{g(!1)}};n.useEffect(()=>{l()},[]);const[,N]=n.useState(null),_=()=>{l().then(()=>{b||setTimeout(async()=>{const v=(await w.getClusters())?.list||[];v.length>0&&L(v[v.length-1].id,!0)},500)})},V=async c=>{try{await w.deleteCluster(c),l()}catch(v){console.error("删除集群失败:",v)}},L=async(c,v)=>{try{v||I.info("正在同步集群资源...");const R=await w.syncCluster(c);v||I.success(R?.message||"同步完成"),l()}catch(R){v||I.error(R?.message||"同步失败")}},ye=async()=>{if(!m)return;const c=m.code||String(m.id);try{o(!0),I.info(`正在导出 ${m.name} 所有命名空间的资源...`),await w.exportAllResources(c),I.success("导出完成,已开始下载"),j(null)}catch(v){I.error(v?.message||"导出失败")}finally{o(!1)}},Y=a.filter(c=>(c.name||"").toLowerCase().includes(d.toLowerCase())||(c.version||"").includes(d)),we=c=>{switch(c){case"healthy":return e.jsxs(y,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:138:11",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:[e.jsx(Xe,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:139:13",className:"h-3 w-3 mr-1"}),"健康"]});case"warning":return e.jsxs(y,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:145:11",variant:"outline",className:"border-amber-500/30 text-amb
Line truncated
|
||||
@@ -1,10 +0,0 @@
|
||||
import{r as c,j as e,s as V,B as A,al as oe,aj as Re,af as Pe,ac as le,am as Te,ae as $,ag as Y,an as Ee,ah as X,ad as Ae,ai as Me,X as M,D as ue,b as de,c as Ie,d as ie,e as xe,I as B,f as Fe,W as Ge,H as Oe,L as Le,a5 as Be,a3 as ee,q as Ue,G as ze,S as $e,aK as We,aL as qe,aM as He,aN as Ve,aO as te,aP as O,U as Xe,E as Ye,v as Je,T as Ze}from"./index-DfyorCky.js";import{C as _,b as U,c as z,d as pe,a as R}from"./card-C55cvSHg.js";import{B as y}from"./badge-xNW8x0G1.js";import{k as w}from"./kubernetes-J8O09fK7.js";import{t as G}from"./index-a3ybMjbR.js";import{T as Qe,a as et,b as I,c as F}from"./tabs-CIh_yD4s.js";import{C as me}from"./circle-x-DK79Dhg2.js";import{R as tt,C as st,X as rt,Y as nt,T as at}from"./generateCategoricalChart-6v9BPbG2.js";import{A as ct,a as se}from"./AreaChart-B2zlWfdX.js";import{T as re}from"./textarea-NXY8u32k.js";import{L as E}from"./label-BK0h2apY.js";import{u as ot}from"./index-CWVNW_qu.js";import{C as lt}from"./circle-DOZr6_68.js";import{x as ut,a as dt}from"./xterm-DSqgeKvr.js";import{M as it,a as xt}from"./minimize-2-CiCQYRfn.js";import{R as H}from"./refresh-cw-DUB_tAG-.js";import{P as pt}from"./plus-CUG-9kpu.js";import{E as mt}from"./ellipsis-DU5enAwm.js";import{D as bt}from"./download-DoZfYs2h.js";import{T as ht}from"./trash-2-Dx32pOzT.js";function gt({cluster:n,onClose:x}){const[a,g]=c.useState([]),[s,u]=c.useState([]),[d,N]=c.useState([]),[k,C]=c.useState([]),[b,f]=c.useState([]),h=c.useMemo(()=>{if(!a||a.length===0)return{cpuPct:0,memPct:0};let t=0,i=0,m=0;for(const j of a){const D=j.cpu||0,o=j.cpu_usage_m?parseFloat(String(j.cpu_usage_m).replace("m","")):0,l=D>0?o/1e3/D*100:0,v=j.memory_mb||0,P=j.mem_usage_mi?parseFloat(String(j.mem_usage_mi).replace("Mi","").replace("Ki","")):0,q=j.mem_usage_mi?.includes?.("Ki")?P/1024:j.mem_usage_mi?.includes?.("Gi")?P*1024:P,L=v>0?q/v*100:0;(l>0||L>0)&&(t+=l,i+=L,m++)}return{cpuPct:m>0?t/m:0,memPct:m>0?i/m:0}},[a]),p=async t=>{try{const[i,m,j,D,o]=await Promise.all([w.getNodes(t).catch(()=>[]),w.getPods(t).catch(()=>[]),w.getDeployments(t).catch(()=>[]),w.getServices(t).catch(()=>[]),w.getIngresses(t).catch(()=>[])]),l=v=>Array.isArray(v)?v:v?.list||[];g(l(i)),u(l(m)),N(l(j)),C(l(D)),f(l(o))}catch(i){console.error("加载集群详情失败:",i)}};return c.useEffect(()=>{n?.id&&p(n.id)},[n?.id]),e.jsxs(_,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:81:5",className:"bg-slate-900 border-slate-800",children:[e.jsx(U,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:82:7",children:e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:83:9",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:84:11",className:"flex items-center gap-3",children:[e.jsx(V,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:85:13",className:"h-6 w-6 text-blue-400"}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:86:13",children:[e.jsx(z,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:87:15",className:"text-slate-100",children:n.name}),e.jsxs(pe,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:88:15",className:"text-slate-500",children:[n.version," · ",n.node_count||0," 节点 · 创建于"," ",n.created_at?new Date(n.created_at).toLocaleDateString():"-"]})]})]}),e.jsxs(A,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:94:11",variant:"ghost",size:"sm",className:"text-slate-400 hover:text-slate-100",onClick:x,children:[e.jsx(me,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:100:13",className:"h-4 w-4 mr-2"}),"关闭"]})]})}),e.jsx(R,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:105:7",children:e.jsxs(Qe,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:106:9",defaultValue:"overview",className:"w-full",children:[e.jsxs(et,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:107:11",className:"bg-slate-800 border border-slate-700 flex-wrap h-auto",children:[e.jsx(I,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:108:13",value:"overview",className:"data-[state=active]:bg-slate-700",children:"概览"}),e.jsxs(I,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:111:13",value:"nodes",className:"data-[state=active]:bg-slate-700",children:["节点 (",a.length,")"]}),e.jsxs(I,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:114:13",value:"pods",className:"data-[state=active]:bg-slate-700",children:["Pod (",s.length,")"]}),e.jsxs(I,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:117:13",value:"deployments",className:"data-[state=active]:bg-slate-700",children:["Deployment (",d.length,")"]}),e.jsxs(I,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:120:13",value:"services",className:"data-[state=active]:bg-slate-700",children:["Service (",kLine truncated
|
||||
kind: Config
|
||||
clusters:
|
||||
- cluster:
|
||||
server: https://10.0.0.1:6443
|
||||
...`,rows:10,className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] placeholder:text-[var(--dg-text-muted)] font-mono text-xs"}),!b&&e.jsx("p",{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:243:17",className:"text-xs text-[var(--dg-text-muted)]",children:"粘贴 kubeconfig 内容后将自动解析 API Server 地址"})]})]}),e.jsxs(Fe,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:250:9",children:[e.jsx(A,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:251:11",variant:"outline",onClick:()=>{x(!1)},className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)] hover:bg-[var(--dg-bg-hover)]",children:"取消"}),e.jsx(A,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:258:11",onClick:j,disabled:D,className:"bg-[var(--dg-blue)] hover:opacity-90 text-white",children:d?"保存中...":a?"保存":"添加"})]})]})})}function Tt({open:n,onOpenChange:x,clusterId:a,clusterName:g}){const s=c.useRef(null),u=c.useRef(null),d=c.useRef(null),N=c.useRef(null),[k,C]=c.useState(!1),[b,f]=c.useState(!1),[h,p]=c.useState("");return c.useEffect(()=>{n||f(!1)},[n]),c.useEffect(()=>{if(!n||!a)return;const t=new ut.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,theme:{background:"#0f172a",foreground:"#e2e8f0",cursor:"#38bdf8",selectionBackground:"#1e40af",black:"#1e293b",red:"#ef4444",green:"#10b981",yellow:"#f59e0b",blue:"#3b82f6",magenta:"#a855f7",cyan:"#06b6d4",white:"#e2e8f0",brightBlack:"#475569",brightRed:"#f87171",brightGreen:"#34d399",brightYellow:"#fbbf24",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#22d3ee",brightWhite:"#f8fafc"}}),i=new dt.FitAddon;t.loadAddon(i),u.current=t,N.current=i;const j=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}`,D=Ge.getState().token||"",o=`${j.replace(/^http/,"ws").replace("/api/v1","")}/ws/kubectl?token=${encodeURIComponent(D)}&id=${a}`,l=new WebSocket(o);return d.current=l,t.onData(v=>{l.readyState===WebSocket.OPEN&&l.send(JSON.stringify({status:0,data:v}))}),l.onmessage=v=>{try{const P=JSON.parse(v.data);P.status===0&&typeof P.data=="string"&&t.write(P.data)}catch{typeof v.data=="string"&&t.write(v.data)}},l.onopen=()=>{C(!0),p(""),s.current&&(t.open(s.current),requestAnimationFrame(()=>{try{i.fit()}catch{}}),setTimeout(()=>{try{t.focus()}catch{}},150))},l.onclose=()=>{C(!1),t.write(`\r
|
||||
\x1B[31m[连接已断开]\x1B[0m\r
|
||||
`)},l.onerror=()=>{p("WebSocket 连接失败"),t.write(`\r
|
||||
\x1B[31m[连接发生错误]\x1B[0m\r
|
||||
`)},()=>{try{(l.readyState===WebSocket.OPEN||l.readyState===WebSocket.CONNECTING)&&l.close(),t.dispose()}catch{}u.current=null,d.current=null,C(!1)}},[n,a]),c.useEffect(()=>{if(!n)return;const t=s.current;if(!t)return;let i;const m=new ResizeObserver(()=>{clearTimeout(i),i=setTimeout(()=>{if(N.current&&u.current&&d.current)try{N.current.fit(),u.current.focus();const{cols:j,rows:D}=u.current;d.current.readyState===WebSocket.OPEN&&d.current.send(JSON.stringify({status:1,cols:j,rows:D}))}catch{}},60)});return m.observe(t),()=>{clearTimeout(i),m.disconnect()}},[n]),e.jsx(ue,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:161:5",open:n,onOpenChange:x,children:e.jsxs(de,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:162:7",showCloseButton:!1,onOpenAutoFocus:t=>t.preventDefault(),className:M("bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] p-0 gap-0","!duration-0 !transition-none",b?"!max-w-none !w-screen !h-screen !rounded-none !translate-x-0 !translate-y-0 !left-0 !top-0":""),style:b?{maxWidth:"100vw",width:"100vw",height:"100vh"}:{maxWidth:"900px",width:"90vw"},children:[e.jsxs(ie,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:174:9",className:"sr-only",children:["kubectl — ",g]}),e.jsx(xe,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:175:9",className:"sr-only",children:"Kubernetes 集群命令行终端"}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:178:9",className:"flex items-center justify-between px-4 py-2 border-b border-[var(--dg-border)]",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:179:11",className:"flex items-center gap-2 text-sm",children:[e.jsx("div",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:180:13",className:M("w-2 h-2 rounded-full",k?"bg-emerald-400":h?"bg-red-400":"bg-yellow-400")}),e.jsx(Oe,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:181:13",className:"h-4 w-4 text-blue-400"}),e.jsxs("span",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:182:13",className:"text-[var(--dg-text-primary)] font-medium",children:["kubectl — ",g]}),!k&&!h&&e.jsx(Le,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:183:38",className:"h-3 w-3 animate-spin text-[var(--dg-text-muted)]"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:185:11",className:"flex items-center gap-1",children:[e.jsx("button",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:186:13",onClick:()=>f(!b),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]",children:b?e.jsx(it,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:190:29",className:"h-4 w-4"}):e.jsx(xt,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:190:65",className:"h-4 w-4"})}),e.jsx("button",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:192:13",onClick:()=>x(!1),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]",children:e.jsx(Be,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:196:15",className:"h-4 w-4"})})]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:202:9",ref:s,className:"bg-[#0f172a]",style:{height:b?"calc(100vh - 49px)":"480px"}})]})})}function Qt(){const[n,x]=c.useState([]),[a,g]=c.useState(!0),[s,u]=c.useState(null),[d,N]=c.useState(""),[k,C]=c.useState(!1),[b,f]=c.useState(null),[h,p]=c.useState(null),[t,i]=c.useState(!1),[m,j]=c.useState(null),[D,o]=c.useState(!1),l=async()=>{try{g(!0);const r=await w.getClusters();x(r?.list||[])}catch(r){console.error("加载集群列表失败:",r),x([])}finally{g(!1)}};c.useEffect(()=>{l()},[]);const[,v]=c.useState(null),P=()=>{l().then(()=>{b||setTimeout(async()=>{const K=(await w.getClusters())?.list||[];K.length>0&&L(K[K.length-1].id,!0)},500)})},q=async r=>{try{await w.deleteCluster(r),l()}catch(K){console.error("删除集群失败:",K)}},L=async(r,K)=>{try{K||G.info("正在同步集群资源...");const T=await w.syncCluster(r);K||G.success(T?.message||"同步完成"),l()}catch(T){K||G.error(T?.message||"同步失败")}},we=async()=>{if(!m)return;const r=m.code||String(m.id);try{o(!0),G.info(`正在导出 ${m.name} 所有命名空间的资源...`),await w.exportAllResources(r),G.success("导出完成,已开始下载"),j(null)}catch(K){G.error(K?.message||"导出失败")}finally{o(!1)}},Z=n.filter(r=>(r.name||"").toLowerCase().includes(d.toLowerCase())||(r.version||"").includes(d)),Se=r=>{switch(r){case"healthy":return e.jsxs(y,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:138:11",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:[e.jsx(ee,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:139:13",className:"h-3 w-3 mr-1"}),"健康"]});case"warning":return e.jsxs(y,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:145:11",variant:"outline",className:"border-amber-500/30 text-amb
Line truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{r as t,j as e,B as A,L as y,S as P,I as V,q as W}from"./index-DfyorCky.js";import{C,a as S}from"./card-C55cvSHg.js";import{B as x}from"./badge-xNW8x0G1.js";import{S as $,a as B,b as R,c as T,d as u}from"./select-D5qUzdAs.js";import{T as H,a as U,b,c as o,d as q,e as r}from"./table-5sHV4Akp.js";import{k as M}from"./kubernetes-J8O09fK7.js";import{R as z}from"./refresh-cw-DUB_tAG-.js";import"./index-CWVNW_qu.js";function ee(){const[L,i]=t.useState([]),[c,N]=t.useState(""),[a,k]=t.useState([]),[p,j]=t.useState(!1),[K,_]=t.useState(""),[m,E]=t.useState("all"),g=t.useCallback(async()=>{try{const n=(await M.getClusters())?.list||[];i(n),n.length>0&&!c&&N(String(n[0].id))}catch{i([])}},[]);t.useEffect(()=>{g()},[g]);const h=t.useCallback(async()=>{if(c){j(!0);try{const s=await M.getNodes(c);k(Array.isArray(s)?s:s?.list||[])}catch{k([])}finally{j(!1)}}},[c]);t.useEffect(()=>{h()},[h]);const f=a.filter(s=>(s.name||"").toLowerCase().includes(K.toLowerCase())&&(m==="all"||s.role===m)),F=s=>s==="master"?e.jsx(x,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:52:9",className:"bg-blue-500/20 text-blue-400 border-blue-500/30",children:"Master"}):e.jsx(x,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:53:9",className:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30",children:"Worker"}),I=s=>s==="Ready"?e.jsx(x,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:57:9",className:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30",children:s}):e.jsx(x,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:58:9",variant:"destructive",children:s||"Unknown"});return e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:61:5",className:"space-y-6",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:62:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:63:9",children:[e.jsx("h1",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:64:11",className:"text-2xl font-bold text-slate-100",children:"节点管理"}),e.jsx("p",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:65:11",className:"text-sm text-slate-500 mt-1",children:"Kubernetes 集群工作节点状态与资源"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:67:9",className:"flex items-center gap-2",children:[e.jsxs($,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:68:11",value:c,onValueChange:N,children:[e.jsx(B,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:69:13",className:"w-48 h-9 bg-slate-800/50 border-slate-700 text-slate-200",children:e.jsx(R,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:70:15",placeholder:"选择集群"})}),e.jsx(T,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:72:13",className:"bg-slate-800 border-slate-700",children:L.map(s=>e.jsx(u,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:74:17",value:String(s.id),children:s.name},s.id))})]}),e.jsx(A,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:78:11",variant:"outline",size:"icon",className:"h-9 w-9 border-slate-700 text-slate-400",onClick:h,disabled:p,children:p?e.jsx(y,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:79:24",className:"h-4 w-4 animate-spin"}):e.jsx(z,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:79:71",className:"h-4 w-4"})})]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:84:7",className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[{label:"总节点",value:a.length,color:"text-blue-400"},{label:"Master",value:a.filter(s=>s.role==="master").length,color:"text-purple-400"},{label:"Worker",value:a.filter(s=>s.role==="worker").length,color:"text-emerald-400"},{label:"就绪",value:a.filter(s=>s.status==="Ready").length,color:"text-cyan-400"}].map(s=>e.jsx(C,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:91:11",className:"bg-slate-900 border-slate-800",children:e.jsxs(S,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:92:13",className:"p-4",children:[e.jsx("p",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:93:15",className:"text-sm text-slate-500",children:s.label}),e.jsx("p",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:94:15",className:`text-2xl font-bold ${s.color}`,children:s.value})]})},s.label))}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:100:7",className:"flex items-center gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:101:9",className:"relative w-56",children:[e.jsx(P,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:102:11",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-500"}),e.jsx(V,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:103:11",placeholder:"搜索节点...",value:K,onChange:s=>_(s.target.value),className:"pl-9 h-9 bg-slate-800/50 borLine truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{r as t,j as e,B as F,L as w,S as I}from"./index-Dmami9WE.js";import{C as A,a as P}from"./card-CIfC-8Rh.js";import{I as V}from"./input-NsU9nXZF.js";import{B as l}from"./badge-3UzCvU7L.js";import{S as y,a as S,b as C,c as B,d as x}from"./select-DUbxjT0z.js";import{T as H,a as U,b as u,c as o,d as W,e as n}from"./table-CG4mjNfb.js";import{k as T}from"./kubernetes-D2-GnE0t.js";import{R as z}from"./refresh-cw-CTBERyFc.js";import{S as G}from"./search-Dd-PeBfg.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";function ne(){const[$,h]=t.useState([]),[c,i]=t.useState(""),[R,N]=t.useState([]),[b,k]=t.useState(!1),[j,M]=t.useState(""),[p,L]=t.useState("all"),K=t.useCallback(async()=>{try{const r=(await T.getClusters())?.list||[];h(r),r.length>0&&!c&&i(String(r[0].id))}catch{h([])}},[]);t.useEffect(()=>{K()},[K]);const m=t.useCallback(async()=>{if(c){k(!0);try{const s=await T.getNodes(c);N(Array.isArray(s)?s:s?.list||[])}catch{N([])}finally{k(!1)}}},[c]);t.useEffect(()=>{m()},[m]);const g=R.filter(s=>(s.name||"").toLowerCase().includes(j.toLowerCase())&&(p==="all"||s.role===p)),_=s=>s==="master"?e.jsx(l,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:52:9",className:"bg-blue-500/20 text-blue-400 border-blue-500/30",children:"Master"}):e.jsx(l,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:53:9",className:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30",children:"Worker"}),E=s=>s==="Ready"?e.jsx(l,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:57:9",className:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30",children:s}):e.jsx(l,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:58:9",variant:"destructive",children:s||"Unknown"});return e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:61:5",className:"space-y-6",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:62:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:63:9",children:[e.jsx("h1",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:64:11",className:"text-2xl font-bold text-slate-100",children:"节点管理"}),e.jsx("p",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:65:11",className:"text-sm text-slate-500 mt-1",children:"Kubernetes 集群工作节点状态与资源"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:67:9",className:"flex items-center gap-2",children:[e.jsxs(y,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:68:11",value:c,onValueChange:i,children:[e.jsx(S,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:69:13",className:"w-48 h-9 bg-slate-800/50 border-slate-700 text-slate-200",children:e.jsx(C,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:70:15",placeholder:"选择集群"})}),e.jsx(B,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:72:13",className:"bg-slate-800 border-slate-700",children:$.map(s=>e.jsx(x,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:74:17",value:String(s.id),children:s.name},s.id))})]}),e.jsx(F,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:78:11",variant:"outline",size:"icon",className:"h-9 w-9 border-slate-700 text-slate-400",onClick:m,disabled:b,children:b?e.jsx(w,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:79:24",className:"h-4 w-4 animate-spin"}):e.jsx(z,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:79:71",className:"h-4 w-4"})})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:84:7",className:"flex items-center gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:85:9",className:"relative w-56",children:[e.jsx(G,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:86:11",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-500"}),e.jsx(V,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:87:11",placeholder:"搜索节点...",value:j,onChange:s=>M(s.target.value),className:"pl-9 h-9 bg-slate-800/50 border-slate-700 text-slate-200"})]}),e.jsxs(y,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:89:9",value:p,onValueChange:L,children:[e.jsx(S,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:90:11",className:"w-32 h-9 bg-slate-800/50 border-slate-700 text-slate-200",children:e.jsx(C,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:91:13"})}),e.jsxs(B,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:93:11",className:"bg-slate-800 border-slate-700",children:[e.jsx(x,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:94:13",value:"all",children:"全部角色"}),e.jsx(x,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:95:13",value:"master",children:"Master"}),e.jsx(x,{"code-path":"src/components/kubernetes/KubernetesNodes.tsx:96:13",value:"worker",children:"Worker"})]})]})]}),e.jsx(A,{"code-pathLine truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{r as l,h as u,j as e,B as D,J as I,A as y,z as P,N as B,p as F}from"./index-Dmami9WE.js";import{C as b,a as M}from"./card-CIfC-8Rh.js";import{S as V,a as q,b as H,c as K,d as G}from"./select-DUbxjT0z.js";import{I as J}from"./input-NsU9nXZF.js";import{S as Q}from"./search-Dd-PeBfg.js";import{F as U}from"./funnel-DngS63SK.js";import{P as W}from"./plus-O65gX7Qz.js";import{H as v}from"./hard-drive-DmC04Y5r.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";const N={cpu:{label:"CPU",icon:e.jsx(F,{"code-path":"src/pages/MetricsExplorer.tsx:34:30",className:"h-4 w-4"})},memory:{label:"内存",icon:e.jsx(v,{"code-path":"src/pages/MetricsExplorer.tsx:35:32",className:"h-4 w-4"})},disk:{label:"磁盘",icon:e.jsx(v,{"code-path":"src/pages/MetricsExplorer.tsx:36:30",className:"h-4 w-4"})},network:{label:"网络",icon:e.jsx(B,{"code-path":"src/pages/MetricsExplorer.tsx:37:33",className:"h-4 w-4"})},middleware:{label:"中间件",icon:e.jsx(P,{"code-path":"src/pages/MetricsExplorer.tsx:38:37",className:"h-4 w-4"})},device:{label:"设备",icon:e.jsx(y,{"code-path":"src/pages/MetricsExplorer.tsx:39:32",className:"h-4 w-4"})}};function oe(){const[n,w]=l.useState([]),[j,S]=l.useState([]),[x,C]=l.useState(""),[o,E]=l.useState([]),[k,f]=l.useState([]),[O,T]=l.useState(!0),[m,_]=l.useState(""),L=l.useCallback(async()=>{try{const s=await u.get("/metrics/targets?page_size=200");w(s?.list||[])}catch{}finally{T(!1)}},[]),R=l.useCallback(async()=>{try{const s=await u.get("/metrics/names");S(s||[])}catch{}},[]);l.useEffect(()=>{L(),R()},[]),l.useEffect(()=>{if(!x||o.length===0||!n.find(c=>String(c.id)===x))return;const t=Math.floor(Date.now()/1e3),r=t-3600;Promise.all(o.map(c=>u.get("/metrics/query",{target_id:x,metric_name:c,from:String(r),to:String(t),limit:200}).then(a=>Array.isArray(a)?a:[]).catch(()=>[]))).then(c=>{f(c.flat())})},[x,o,n]);const $=m?j.filter(s=>s.toLowerCase().includes(m.toLowerCase())):j,g=n.find(s=>String(s.id)===x),z=$.reduce((s,t)=>{const r=t.split("_")[0]||"other";return s[r]||(s[r]=[]),s[r].push(t),s},{}),p={};k.forEach(s=>{p[s.timestamp]||(p[s.timestamp]={}),p[s.timestamp][s.metric_name]=s.value});const d=Object.keys(p).map(Number).sort((s,t)=>s-t),A=Math.max(1,...Object.values(p).flatMap(s=>Object.values(s))),h=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899","#06b6d4","#f97316"];return e.jsxs("div",{"code-path":"src/pages/MetricsExplorer.tsx:118:5",className:"space-y-6",children:[e.jsxs("div",{"code-path":"src/pages/MetricsExplorer.tsx:120:7",className:"flex items-center gap-4 flex-wrap",children:[e.jsxs(V,{"code-path":"src/pages/MetricsExplorer.tsx:121:9",value:x,onValueChange:C,children:[e.jsx(q,{"code-path":"src/pages/MetricsExplorer.tsx:122:11",className:"w-64 bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsx(H,{"code-path":"src/pages/MetricsExplorer.tsx:123:13",placeholder:O?"加载中...":"选择监控目标..."})}),e.jsx(K,{"code-path":"src/pages/MetricsExplorer.tsx:125:11",className:"bg-slate-800 border-slate-700 text-slate-200 max-h-80",children:n.map(s=>e.jsx(G,{"code-path":"src/pages/MetricsExplorer.tsx:127:15",value:String(s.id),children:e.jsxs("span",{"code-path":"src/pages/MetricsExplorer.tsx:128:17",className:"flex items-center gap-2",children:[e.jsx("span",{"code-path":"src/pages/MetricsExplorer.tsx:129:19",className:`inline-block w-1.5 h-1.5 rounded-full ${s.status==="online"?"bg-emerald-400":"bg-slate-500"}`}),s.name," (",s.ip||s.type,")"]})},s.id))})]}),e.jsxs("div",{"code-path":"src/pages/MetricsExplorer.tsx:137:9",className:"relative flex-1 max-w-sm",children:[e.jsx(Q,{"code-path":"src/pages/MetricsExplorer.tsx:138:11",className:"absolute left-2.5 top-2 h-4 w-4 text-slate-500"}),e.jsx(J,{"code-path":"src/pages/MetricsExplorer.tsx:139:11",className:"pl-8 bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] h-9",placeholder:"搜索指标...",value:m,onChange:s=>_(s.target.value)})]}),e.jsx(D,{"code-path":"src/pages/MetricsExplorer.tsx:146:9",variant:"ghost",size:"sm",onClick:()=>{E([]),f([])},children:"清除"})]}),x?e.jsxs("div",{"code-path":"src/pages/MetricsExplorer.tsx:159:9",className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsx(b,{"code-path":"src/pages/MetricsExplorer.tsx:161:11",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] lg:col-span-1",children:e.jsxs(M,{"code-path":"src/pages/MetricsExplorer.tsx:162:13",className:"p-4",children:[e.jsxs("div",{"code-path":"src/pages/MetricsExplorer.tsx:163:15",className:"flex items-center gap-2 mb-3",children:[e.jsx(I,{"code-path":"src/pages/MetricsExplorer.tsx:164:17",className:"h-4 w-4 text-[var(--dg-text-muted)]"}),e.jsx("h3",{"code-path":"src/pages/MetricsExplorer.tsx:165:17",className:"text-sm font-medium text-[var(--dg-text-primary)]",children:"指标列表"}),e.jsxs("span",{"code-path":"src/pages/MetricsExplorer.tsx:166:17",className:"text-xs text-[var(--dg-text-muted)] ml-auto",children:[o.length," 已选"]})]}),e.jsx("div",{"code-path":"src/pages/MetLine truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{r as l,h as u,j as e,S as I,I as z,B as P,K as B,A as y,G as F,N as K,o as V}from"./index-DfyorCky.js";import{C as b,a as M}from"./card-C55cvSHg.js";import{S as q,a as G,b as H,c as Q,d as U}from"./select-D5qUzdAs.js";import{F as W}from"./funnel-D2FHr15I.js";import{P as J}from"./plus-CUG-9kpu.js";import{H as v}from"./hard-drive-BbPmnARR.js";import"./index-CWVNW_qu.js";const N={cpu:{label:"CPU",icon:e.jsx(V,{"code-path":"src/pages/MetricsExplorer.tsx:34:30",className:"h-4 w-4"})},memory:{label:"内存",icon:e.jsx(v,{"code-path":"src/pages/MetricsExplorer.tsx:35:32",className:"h-4 w-4"})},disk:{label:"磁盘",icon:e.jsx(v,{"code-path":"src/pages/MetricsExplorer.tsx:36:30",className:"h-4 w-4"})},network:{label:"网络",icon:e.jsx(K,{"code-path":"src/pages/MetricsExplorer.tsx:37:33",className:"h-4 w-4"})},middleware:{label:"中间件",icon:e.jsx(F,{"code-path":"src/pages/MetricsExplorer.tsx:38:37",className:"h-4 w-4"})},device:{label:"设备",icon:e.jsx(y,{"code-path":"src/pages/MetricsExplorer.tsx:39:32",className:"h-4 w-4"})}};function ae(){const[n,w]=l.useState([]),[j,S]=l.useState([]),[x,C]=l.useState(""),[o,E]=l.useState([]),[k,f]=l.useState([]),[O,T]=l.useState(!0),[m,_]=l.useState(""),L=l.useCallback(async()=>{try{const s=await u.get("/metrics/targets?page_size=200");w(s?.list||[])}catch{}finally{T(!1)}},[]),R=l.useCallback(async()=>{try{const s=await u.get("/metrics/names");S(s||[])}catch{}},[]);l.useEffect(()=>{L(),R()},[]),l.useEffect(()=>{if(!x||o.length===0||!n.find(c=>String(c.id)===x))return;const t=Math.floor(Date.now()/1e3),r=t-3600;Promise.all(o.map(c=>u.get("/metrics/query",{target_id:x,metric_name:c,from:String(r),to:String(t),limit:200}).then(a=>Array.isArray(a)?a:[]).catch(()=>[]))).then(c=>{f(c.flat())})},[x,o,n]);const $=m?j.filter(s=>s.toLowerCase().includes(m.toLowerCase())):j,g=n.find(s=>String(s.id)===x),A=$.reduce((s,t)=>{const r=t.split("_")[0]||"other";return s[r]||(s[r]=[]),s[r].push(t),s},{}),d={};k.forEach(s=>{d[s.timestamp]||(d[s.timestamp]={}),d[s.timestamp][s.metric_name]=s.value});const p=Object.keys(d).map(Number).sort((s,t)=>s-t),D=Math.max(1,...Object.values(d).flatMap(s=>Object.values(s))),h=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899","#06b6d4","#f97316"];return e.jsxs("div",{"code-path":"src/pages/MetricsExplorer.tsx:118:5",className:"space-y-6",children:[e.jsxs("div",{"code-path":"src/pages/MetricsExplorer.tsx:120:7",className:"flex items-center gap-4 flex-wrap",children:[e.jsxs(q,{"code-path":"src/pages/MetricsExplorer.tsx:121:9",value:x,onValueChange:C,children:[e.jsx(G,{"code-path":"src/pages/MetricsExplorer.tsx:122:11",className:"w-64 bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsx(H,{"code-path":"src/pages/MetricsExplorer.tsx:123:13",placeholder:O?"加载中...":"选择监控目标..."})}),e.jsx(Q,{"code-path":"src/pages/MetricsExplorer.tsx:125:11",className:"bg-slate-800 border-slate-700 text-slate-200 max-h-80",children:n.map(s=>e.jsx(U,{"code-path":"src/pages/MetricsExplorer.tsx:127:15",value:String(s.id),children:e.jsxs("span",{"code-path":"src/pages/MetricsExplorer.tsx:128:17",className:"flex items-center gap-2",children:[e.jsx("span",{"code-path":"src/pages/MetricsExplorer.tsx:129:19",className:`inline-block w-1.5 h-1.5 rounded-full ${s.status==="online"?"bg-emerald-400":"bg-slate-500"}`}),s.name," (",s.ip||s.type,")"]})},s.id))})]}),e.jsxs("div",{"code-path":"src/pages/MetricsExplorer.tsx:137:9",className:"relative flex-1 max-w-sm",children:[e.jsx(I,{"code-path":"src/pages/MetricsExplorer.tsx:138:11",className:"absolute left-2.5 top-2 h-4 w-4 text-slate-500"}),e.jsx(z,{"code-path":"src/pages/MetricsExplorer.tsx:139:11",className:"pl-8 bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] h-9",placeholder:"搜索指标...",value:m,onChange:s=>_(s.target.value)})]}),e.jsx(P,{"code-path":"src/pages/MetricsExplorer.tsx:146:9",variant:"ghost",size:"sm",onClick:()=>{E([]),f([])},children:"清除"})]}),x?e.jsxs("div",{"code-path":"src/pages/MetricsExplorer.tsx:159:9",className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsx(b,{"code-path":"src/pages/MetricsExplorer.tsx:161:11",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] lg:col-span-1",children:e.jsxs(M,{"code-path":"src/pages/MetricsExplorer.tsx:162:13",className:"p-4",children:[e.jsxs("div",{"code-path":"src/pages/MetricsExplorer.tsx:163:15",className:"flex items-center gap-2 mb-3",children:[e.jsx(B,{"code-path":"src/pages/MetricsExplorer.tsx:164:17",className:"h-4 w-4 text-[var(--dg-text-muted)]"}),e.jsx("h3",{"code-path":"src/pages/MetricsExplorer.tsx:165:17",className:"text-sm font-medium text-[var(--dg-text-primary)]",children:"指标列表"}),e.jsxs("span",{"code-path":"src/pages/MetricsExplorer.tsx:166:17",className:"text-xs text-[var(--dg-text-muted)] ml-auto",children:[o.length," 已选"]})]}),e.jsx("div",{"code-path":"src/pages/MetricsExplorer.tsx:168:15",className:"space-y-4 max-h-[60vh] overflow-y-auto",children:Object.entries(Line truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{g as X,r as i,h as L,j as e,L as O,A as R,G as B,q as K,D as W,y as Ne,B as w,b as Y,c as Z,d as J,e as ee,I as y,f as te,a as ve,O as I,x as je,o as be,X as Se}from"./index-DfyorCky.js";import{HostMonitor as ye}from"./HostMonitor-C63FMElJ.js";import{C as h,a as M}from"./card-C55cvSHg.js";import{B as u}from"./badge-xNW8x0G1.js";import{C as fe}from"./circle-DOZr6_68.js";import{L as j}from"./label-BK0h2apY.js";import{S as se,a as ae,b as re,c as oe,d as A}from"./select-D5qUzdAs.js";import{T as ce,a as de,b as $,c as l,d as ie,e as p}from"./table-5sHV4Akp.js";import{H as we}from"./hard-drive-BbPmnARR.js";import{P as ne}from"./plus-CUG-9kpu.js";import{T as xe}from"./trash-2-Dx32pOzT.js";import{S as Pe}from"./switch-CGiGgOnh.js";import{t as C}from"./index-a3ybMjbR.js";import{s as F}from"./monitor-BAaBXIsC.js";import{A as Ce}from"./arrow-up-down-DnvTt5VG.js";import{R as _e}from"./refresh-cw-DUB_tAG-.js";import{C as Te}from"./circle-x-DK79Dhg2.js";import{C as ke}from"./circle-check-DWcXrx2k.js";import"./agent-DqqIRCQX.js";import"./tabs-CIh_yD4s.js";import"./disc-EsE6x5Oh.js";import"./generateCategoricalChart-6v9BPbG2.js";import"./AreaChart-B2zlWfdX.js";import"./square-pen-BxUFAe0F.js";import"./index-CWVNW_qu.js";const De=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],le=X("radio",De);const qe=[["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6.01 18H6",key:"19vcac"}],["path",{d:"M10.01 18H10",key:"uamcmx"}],["path",{d:"M15 10v4",key:"qjz1xs"}],["path",{d:"M17.84 7.17a4 4 0 0 0-5.66 0",key:"1rif40"}],["path",{d:"M20.66 4.34a8 8 0 0 0-11.31 0",key:"6a5xfq"}]],U=X("router",qe);function Fe(t){return t==null||t===0?"--":t>1e9?`${(t/1e9).toFixed(1)} GB`:t>1e6?`${(t/1e6).toFixed(1)} MB`:t>1e3?`${(t/1e3).toFixed(1)} KB`:`${t} B`}function E(t){return t==null||Number.isNaN(t)?"--":`${(t*100).toFixed(1)}%`}function D(t,n=0){return t==null||Number.isNaN(t)?"--":t.toFixed(n)}function Le(t){switch(t){case"online":return"text-emerald-400";case"warning":return"text-amber-400";case"error":return"text-red-400";default:return"text-slate-500"}}function Ie(t){switch(t){case"online":return"bg-emerald-400";case"warning":return"bg-amber-400";case"error":return"bg-red-400";default:return"bg-slate-500"}}function $e(){const[t,n]=i.useState([]),[d,N]=i.useState(!0),[v,_]=i.useState(""),T=i.useCallback(async()=>{try{N(!0),_("");const r=await L.get("/metrics/targets",{type:"middleware",page_size:200});n(r?.list||[])}catch(r){_(r.message||"加载失败"),n([])}finally{N(!1)}},[]);i.useEffect(()=>{T()},[]);const b=t.filter(r=>r.type==="redis"||r.name?.toLowerCase().includes("redis")),o=t.filter(r=>r.type==="mysql"||r.name?.toLowerCase().includes("mysql")),x=b.find(r=>r.status==="online")||b[0],c=x?.latest_metrics||{},m=o.find(r=>r.status==="online")||o[0],S=m?.latest_metrics||{};return e.jsxs("div",{"code-path":"src/pages/MiddlewareMonitor.tsx:96:5",className:"space-y-6",children:[d&&e.jsxs("div",{"code-path":"src/pages/MiddlewareMonitor.tsx:98:9",className:"flex items-center justify-center py-12",children:[e.jsx(O,{"code-path":"src/pages/MiddlewareMonitor.tsx:99:11",className:"h-6 w-6 animate-spin text-slate-500 mr-2"}),e.jsx("span",{"code-path":"src/pages/MiddlewareMonitor.tsx:100:11",className:"text-sm text-[var(--dg-text-muted)]",children:"正在加载中间件指标..."})]}),v&&!d&&e.jsx(h,{"code-path":"src/pages/MiddlewareMonitor.tsx:105:9",className:"bg-[var(--dg-bg-secondary)] border-red-500/30",children:e.jsxs(M,{"code-path":"src/pages/MiddlewareMonitor.tsx:106:11",className:"p-6 text-center",children:[e.jsx(R,{"code-path":"src/pages/MiddlewareMonitor.tsx:107:13",className:"h-8 w-8 text-red-400 mx-auto mb-2"}),e.jsx("p",{"code-path":"src/pages/MiddlewareMonitor.tsx:108:13",className:"text-sm text-red-400",children:v}),e.jsx("p",{"code-path":"src/pages/MiddlewareMonitor.tsx:109:13",className:"text-xs text-[var(--dg-text-muted)] mt-2",children:"请确认后端服务可用且已配置中间件采集"})]})}),!d&&!v&&t.length===0&&e.jsx(h,{"code-path":"src/pages/MiddlewareMonitor.tsx:115:9",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(M,{"code-path":"src/pages/MiddlewareMonitor.tsx:116:11",className:"p-12 text-center",children:[e.jsx(B,{"code-path":"src/pages/MiddlewareMonitor.tsx:117:13",className:"h-12 w-12 text-slate-600 mx-auto mb-4"}),e.jsx("p",{"code-path":"src/pages/MiddlewareMonitor.tsx:118:13",className:"text-sm text-[var(--dg-text-muted)]",children:"暂无中间件监控目标"}),e.jsx("p",{"code-path":"src/pages/MiddlewareMonitor.tsx:119:13",className:"text-xs text-[var(--dg-text-muted)] mt-2",children:"需在 Agent 配置 Redis / MySQL 连接信息后启用采集"})]})}),e.jsx(h,{"code-path":"src/pages/MiddlewarLine truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{i as X,r as i,h as L,j as e,L as O,A as R,z as B,S as K,D as W,w as Ne,B as w,a as Y,b as Z,c as J,d as ee,e as te,f as ve,G as I,C as je,p as be,a0 as Se}from"./index-Dmami9WE.js";import{HostMonitor as ye}from"./HostMonitor-BhnRAvcW.js";import{C as h,a as M}from"./card-CIfC-8Rh.js";import{B as u}from"./badge-3UzCvU7L.js";import{C as fe}from"./circle-CGbaa1m0.js";import{I as y}from"./input-NsU9nXZF.js";import{L as j}from"./label-Ap_-SPYI.js";import{S as se,a as ae,b as re,c as oe,d as A}from"./select-DUbxjT0z.js";import{T as ce,a as de,b as $,c as l,d as ie,e as p}from"./table-CG4mjNfb.js";import{H as we}from"./hard-drive-DmC04Y5r.js";import{P as ne}from"./plus-O65gX7Qz.js";import{T as xe}from"./trash-2-DWVnIU6o.js";import{S as Pe}from"./switch-TqjD2x0W.js";import{t as C}from"./index-BuEnLCjT.js";import{s as q}from"./monitor-CicbJUrQ.js";import{A as Ce}from"./arrow-up-down-Cn71rsC9.js";import{R as _e}from"./refresh-cw-CTBERyFc.js";import{C as Te}from"./circle-x-BBQeW1R3.js";import{C as ke}from"./circle-check-CVbTTFQ0.js";import"./agent-B3ElXCx8.js";import"./tabs-lV44z_UR.js";import"./disc-BPxL4arn.js";import"./generateCategoricalChart-ZqCvxO-S.js";import"./AreaChart-CrvX3B0s.js";import"./square-pen-B3dPIBrm.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";const De=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],le=X("radio",De);const Fe=[["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6.01 18H6",key:"19vcac"}],["path",{d:"M10.01 18H10",key:"uamcmx"}],["path",{d:"M15 10v4",key:"qjz1xs"}],["path",{d:"M17.84 7.17a4 4 0 0 0-5.66 0",key:"1rif40"}],["path",{d:"M20.66 4.34a8 8 0 0 0-11.31 0",key:"6a5xfq"}]],U=X("router",Fe);function qe(t){return t==null||t===0?"--":t>1e9?`${(t/1e9).toFixed(1)} GB`:t>1e6?`${(t/1e6).toFixed(1)} MB`:t>1e3?`${(t/1e3).toFixed(1)} KB`:`${t} B`}function E(t){return t==null||Number.isNaN(t)?"--":`${(t*100).toFixed(1)}%`}function D(t,n=0){return t==null||Number.isNaN(t)?"--":t.toFixed(n)}function Le(t){switch(t){case"online":return"text-emerald-400";case"warning":return"text-amber-400";case"error":return"text-red-400";default:return"text-slate-500"}}function Ie(t){switch(t){case"online":return"bg-emerald-400";case"warning":return"bg-amber-400";case"error":return"bg-red-400";default:return"bg-slate-500"}}function $e(){const[t,n]=i.useState([]),[d,N]=i.useState(!0),[v,_]=i.useState(""),T=i.useCallback(async()=>{try{N(!0),_("");const r=await L.get("/metrics/targets",{type:"middleware",page_size:200});n(r?.list||[])}catch(r){_(r.message||"加载失败"),n([])}finally{N(!1)}},[]);i.useEffect(()=>{T()},[]);const b=t.filter(r=>r.type==="redis"||r.name?.toLowerCase().includes("redis")),o=t.filter(r=>r.type==="mysql"||r.name?.toLowerCase().includes("mysql")),x=b.find(r=>r.status==="online")||b[0],c=x?.latest_metrics||{},m=o.find(r=>r.status==="online")||o[0],S=m?.latest_metrics||{};return e.jsxs("div",{"code-path":"src/pages/MiddlewareMonitor.tsx:96:5",className:"space-y-6",children:[d&&e.jsxs("div",{"code-path":"src/pages/MiddlewareMonitor.tsx:98:9",className:"flex items-center justify-center py-12",children:[e.jsx(O,{"code-path":"src/pages/MiddlewareMonitor.tsx:99:11",className:"h-6 w-6 animate-spin text-slate-500 mr-2"}),e.jsx("span",{"code-path":"src/pages/MiddlewareMonitor.tsx:100:11",className:"text-sm text-[var(--dg-text-muted)]",children:"正在加载中间件指标..."})]}),v&&!d&&e.jsx(h,{"code-path":"src/pages/MiddlewareMonitor.tsx:105:9",className:"bg-[var(--dg-bg-secondary)] border-red-500/30",children:e.jsxs(M,{"code-path":"src/pages/MiddlewareMonitor.tsx:106:11",className:"p-6 text-center",children:[e.jsx(R,{"code-path":"src/pages/MiddlewareMonitor.tsx:107:13",className:"h-8 w-8 text-red-400 mx-auto mb-2"}),e.jsx("p",{"code-path":"src/pages/MiddlewareMonitor.tsx:108:13",className:"text-sm text-red-400",children:v}),e.jsx("p",{"code-path":"src/pages/MiddlewareMonitor.tsx:109:13",className:"text-xs text-[var(--dg-text-muted)] mt-2",children:"请确认后端服务可用且已配置中间件采集"})]})}),!d&&!v&&t.length===0&&e.jsx(h,{"code-path":"src/pages/MiddlewareMonitor.tsx:115:9",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(M,{"code-path":"src/pages/MiddlewareMonitor.tsx:116:11",className:"p-12 text-center",children:[e.jsx(B,{"code-path":"src/pages/MiddlewareMonitor.tsx:117:13",className:"h-12 w-12 text-slate-600 mx-auto mb-4"}),e.jsx("p",{"code-path":"src/pages/MiddlewareMonitor.tsx:118:13",className:"text-sm text-[var(--dg-text-muted)]",children:"暂无中间件监控目标"}),e.jsx("p",{"code-path":"src/pages/MiddlewareMonitor.tsx:119:13",className:"text-xs text-[var(--dg-text-muted)] mt-2",children:"需在 Agent 配置 Redis / MySQL 连接信Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{k as X,m as Z,r as n,j as e,n as A,o as O,q as j,B as m,L as i,D as L,w as ee,a as E,b as B,c as q,e as R,v as ae,A as se,N as te,t as H,T as $}from"./index-Dmami9WE.js";import{C as p,a as l}from"./card-CIfC-8Rh.js";import{B as z}from"./badge-3UzCvU7L.js";import{I}from"./input-NsU9nXZF.js";import{L as ne}from"./label-Ap_-SPYI.js";import{T as ce,a as re,b as N,c,d as me,e as s}from"./table-CG4mjNfb.js";import{k as P}from"./kubernetes-D2-GnE0t.js";import{R as oe}from"./refresh-cw-CTBERyFc.js";import{P as pe}from"./plus-O65gX7Qz.js";import{C as le}from"./circle-check-CVbTTFQ0.js";import{T as xe}from"./trash-2-DWVnIU6o.js";const de=new Set(["kube-system","kube-public","kube-node-lease","default","devops"]);function ye(){const{clusterCode:t}=X(),Q=Z(),[o,M]=n.useState([]),[u,f]=n.useState(!1),[b,F]=n.useState(""),[J,k]=n.useState(!1),[d,y]=n.useState(""),[v,w]=n.useState(!1),[g,h]=n.useState(null),[C,S]=n.useState(!1),x=n.useCallback(async()=>{if(t){f(!0);try{const a=await P.getNamespacesDetail(t);M(Array.isArray(a)?a:[])}catch{M([])}finally{f(!1)}}},[t]);n.useEffect(()=>{x()},[x]);const D=async()=>{if(!(!t||!d.trim())){w(!0);try{await P.createNamespace(t,d.trim()),y(""),k(!1),await x()}catch(a){alert(a?.message||"创建失败")}finally{w(!1)}}},K=async()=>{if(!(!t||!g)){S(!0);try{await P.deleteNamespace(t,g),h(null),await x()}catch(a){alert(a?.message||"删除失败")}finally{S(!1)}}},T=o.filter(a=>!b||a.name.toLowerCase().includes(b.toLowerCase())),Y=o.reduce((a,r)=>a+(r.resource_counts?.deployments||0),0),G=o.reduce((a,r)=>a+(r.resource_counts?.pods||0),0),U=o.reduce((a,r)=>a+(r.resource_counts?.services||0),0),V=o.filter(a=>a.has_resource_quota).length;return e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:108:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:110:7",className:"flex items-center gap-2 text-sm text-slate-500",children:[e.jsx(A,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:111:9",to:"/kubernetes",className:"hover:text-slate-300 transition-colors",children:"集群"}),e.jsx(O,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:112:9",className:"h-3 w-3"}),e.jsx(A,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:113:9",to:`/kubernetes/${t}`,className:"hover:text-slate-300 transition-colors",children:t}),e.jsx(O,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:114:9",className:"h-3 w-3"}),e.jsx("span",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:115:9",className:"text-slate-300",children:"命名空间管理"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:119:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:120:9",children:[e.jsxs("h1",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:121:11",className:"text-2xl font-bold text-slate-100 flex items-center gap-2",children:[e.jsx(j,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:122:13",className:"h-6 w-6 text-emerald-400"}),"命名空间管理"]}),e.jsx("p",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:125:11",className:"text-sm text-slate-500 mt-1",children:"命名空间资源配额与生命周期管理"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:127:9",className:"flex items-center gap-2",children:[e.jsx(m,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:128:11",variant:"outline",size:"icon",className:"h-9 w-9 border-slate-700 text-slate-400",onClick:x,disabled:u,children:u?e.jsx(i,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:130:24",className:"h-4 w-4 animate-spin"}):e.jsx(oe,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:130:71",className:"h-4 w-4"})}),e.jsxs(L,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:132:11",open:J,onOpenChange:k,children:[e.jsx(ee,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:133:13",asChild:!0,children:e.jsxs(m,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:134:15",className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(pe,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:135:17",className:"h-4 w-4 mr-1"}),"创建命名空间"]})}),e.jsxs(E,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:138:13",children:[e.jsx(B,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:139:15",children:e.jsx(q,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:140:17",children:"创建命名空间"})}),e.jsx("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:142:15",className:"space-y-4 py-4",children:e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:143:17",classNaLine truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{i as X,k as Z,r as n,j as e,m as A,n as O,p as j,B as m,L as i,D as L,y as ee,b as E,c as B,d as R,I as q,f as H,v as ae,A as se,N as te,t as $,T as z}from"./index-DfyorCky.js";import{C as p,a as l}from"./card-C55cvSHg.js";import{B as I}from"./badge-xNW8x0G1.js";import{L as ne}from"./label-BK0h2apY.js";import{T as ce,a as re,b as N,c,d as me,e as s}from"./table-5sHV4Akp.js";import{k as P}from"./kubernetes-J8O09fK7.js";import{R as oe}from"./refresh-cw-DUB_tAG-.js";import{P as pe}from"./plus-CUG-9kpu.js";import{C as le}from"./circle-check-DWcXrx2k.js";import{T as xe}from"./trash-2-Dx32pOzT.js";const de=new Set(["kube-system","kube-public","kube-node-lease","default","devops"]);function fe(){const{clusterCode:t}=X(),Q=Z(),[o,M]=n.useState([]),[u,f]=n.useState(!1),[b,F]=n.useState(""),[J,k]=n.useState(!1),[d,y]=n.useState(""),[v,w]=n.useState(!1),[g,h]=n.useState(null),[C,S]=n.useState(!1),x=n.useCallback(async()=>{if(t){f(!0);try{const a=await P.getNamespacesDetail(t);M(Array.isArray(a)?a:[])}catch{M([])}finally{f(!1)}}},[t]);n.useEffect(()=>{x()},[x]);const D=async()=>{if(!(!t||!d.trim())){w(!0);try{await P.createNamespace(t,d.trim()),y(""),k(!1),await x()}catch(a){alert(a?.message||"创建失败")}finally{w(!1)}}},K=async()=>{if(!(!t||!g)){S(!0);try{await P.deleteNamespace(t,g),h(null),await x()}catch(a){alert(a?.message||"删除失败")}finally{S(!1)}}},T=o.filter(a=>!b||a.name.toLowerCase().includes(b.toLowerCase())),Y=o.reduce((a,r)=>a+(r.resource_counts?.deployments||0),0),G=o.reduce((a,r)=>a+(r.resource_counts?.pods||0),0),U=o.reduce((a,r)=>a+(r.resource_counts?.services||0),0),V=o.filter(a=>a.has_resource_quota).length;return e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:108:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:110:7",className:"flex items-center gap-2 text-sm text-slate-500",children:[e.jsx(A,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:111:9",to:"/kubernetes",className:"hover:text-slate-300 transition-colors",children:"集群"}),e.jsx(O,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:112:9",className:"h-3 w-3"}),e.jsx(A,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:113:9",to:`/kubernetes/${t}`,className:"hover:text-slate-300 transition-colors",children:t}),e.jsx(O,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:114:9",className:"h-3 w-3"}),e.jsx("span",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:115:9",className:"text-slate-300",children:"命名空间管理"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:119:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:120:9",children:[e.jsxs("h1",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:121:11",className:"text-2xl font-bold text-slate-100 flex items-center gap-2",children:[e.jsx(j,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:122:13",className:"h-6 w-6 text-emerald-400"}),"命名空间管理"]}),e.jsx("p",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:125:11",className:"text-sm text-slate-500 mt-1",children:"命名空间资源配额与生命周期管理"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:127:9",className:"flex items-center gap-2",children:[e.jsx(m,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:128:11",variant:"outline",size:"icon",className:"h-9 w-9 border-slate-700 text-slate-400",onClick:x,disabled:u,children:u?e.jsx(i,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:130:24",className:"h-4 w-4 animate-spin"}):e.jsx(oe,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:130:71",className:"h-4 w-4"})}),e.jsxs(L,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:132:11",open:J,onOpenChange:k,children:[e.jsx(ee,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:133:13",asChild:!0,children:e.jsxs(m,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:134:15",className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(pe,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:135:17",className:"h-4 w-4 mr-1"}),"创建命名空间"]})}),e.jsxs(E,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:138:13",children:[e.jsx(B,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:139:15",children:e.jsx(R,{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:140:17",children:"创建命名空间"})}),e.jsx("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:142:15",className:"space-y-4 py-4",children:e.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceManagementPage.tsx:143:17",className:"space-y-2",children:[e.jLine truncated
|
||||
+1
-1
@@ -1 +1 @@
|
||||
import{i as g,r,j as s,m as l,n as i,s as h,p as b,v as N,x as f,N as u,t as w,A as k}from"./index-DfyorCky.js";import{k as n}from"./kubernetes-J8O09fK7.js";import{F as P}from"./file-text-C9G5abwR.js";const j=[{type:"deployments",label:"Deployments",icon:b,desc:"工作负载副本管理"},{type:"pods",label:"Pods",icon:N,desc:"容器实例运行状态"},{type:"cronjobs",label:"CronJobs",icon:f,desc:"定时任务管理"},{type:"services",label:"Services",icon:u,desc:"服务发现与负载均衡"},{type:"ingresses",label:"Ingresses",icon:u,desc:"外部流量路由规则"},{type:"configmaps",label:"ConfigMaps",icon:P,desc:"配置字典"},{type:"secrets",label:"Secrets",icon:w,desc:"密钥与凭证"},{type:"hpas",label:"HPAs",icon:k,desc:"水平自动伸缩策略"}];function S(){const{clusterCode:t,namespace:a}=g(),[x,p]=r.useState({}),[v,m]=r.useState(!1),d=r.useCallback(async()=>{if(!(!t||!a)){m(!0);try{const e=await Promise.allSettled([n.getNamespaceDeployments(t,a),n.getNamespacePods(t,a),n.getNamespaceServices(t,a),n.getNamespaceIngresses(t,a),n.getNamespaceConfigMaps(t,a),n.getNamespaceSecrets(t,a),n.getHPAs(t,a),n.getCronJobs(t,a)]),c=o=>Array.isArray(o)?o:o?.list||o?.data||[];p({deployments:c(e[0].status==="fulfilled"?e[0].value:[]).length,pods:c(e[1].status==="fulfilled"?e[1].value:[]).length,services:c(e[2].status==="fulfilled"?e[2].value:[]).length,ingresses:c(e[3].status==="fulfilled"?e[3].value:[]).length,configmaps:c(e[4].status==="fulfilled"?e[4].value:[]).length,secrets:c(e[5].status==="fulfilled"?e[5].value:[]).length,hpas:c(e[6].status==="fulfilled"?e[6].value:[]).length,cronjobs:c(e[7].status==="fulfilled"?e[7].value:[]).length})}catch{p({})}finally{m(!1)}}},[t,a]);return r.useEffect(()=>{d()},[d]),s.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:65:5",className:"space-y-4",children:[s.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:67:7",className:"flex items-center gap-2 text-sm text-slate-500",children:[s.jsx(l,{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:68:9",to:"/kubernetes",className:"hover:text-slate-300 transition-colors",children:"集群"}),s.jsx(i,{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:69:9",className:"h-3 w-3"}),s.jsx(l,{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:70:9",to:`/kubernetes/${t}`,className:"hover:text-slate-300 transition-colors",children:t}),s.jsx(i,{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:71:9",className:"h-3 w-3"}),s.jsx("span",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:72:9",className:"text-slate-300",children:a})]}),s.jsx("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:76:7",className:"flex items-center justify-between",children:s.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:77:9",children:[s.jsxs("h1",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:78:11",className:"text-2xl font-bold text-slate-100 flex items-center gap-2",children:[s.jsx(h,{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:79:13",className:"h-6 w-6 text-blue-400"}),a]}),s.jsx("p",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:82:11",className:"text-sm text-slate-500 mt-1",children:"命名空间概览"})]})}),s.jsx("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:87:7",className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:j.map(e=>s.jsxs(l,{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:89:11",to:`/kubernetes/${t}/namespace/${a}/${e.type}`,className:"bg-slate-900 border border-slate-800 rounded-lg p-4 hover:border-slate-600 hover:bg-slate-800/50 transition-all group",children:[s.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:93:13",className:"flex items-center justify-between mb-2",children:[s.jsx(e.icon,{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:94:15",className:"h-5 w-5 text-slate-500 group-hover:text-blue-400 transition-colors"}),s.jsx(i,{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:95:15",className:"h-4 w-4 text-slate-600 group-hover:text-slate-400 transition-colors"})]}),s.jsx("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:97:13",className:"text-lg font-bold text-slate-100",children:v?"-":x[e.type]??0}),s.jsx("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:98:13",className:"text-sm text-slate-500",children:e.label}),s.jsx("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:99:13",className:"text-xs text-slate-600 mt-1",children:e.desc})]},e.type))})]})}export{S as default};
|
||||
import{k as g,r,j as s,n as l,o as i,s as h,q as b,v as N,C as f,N as u,t as k,A as w}from"./index-Dmami9WE.js";import{k as n}from"./kubernetes-D2-GnE0t.js";import{F as P}from"./file-text-CebshSV-.js";const j=[{type:"deployments",label:"Deployments",icon:b,desc:"工作负载副本管理"},{type:"pods",label:"Pods",icon:N,desc:"容器实例运行状态"},{type:"cronjobs",label:"CronJobs",icon:f,desc:"定时任务管理"},{type:"services",label:"Services",icon:u,desc:"服务发现与负载均衡"},{type:"ingresses",label:"Ingresses",icon:u,desc:"外部流量路由规则"},{type:"configmaps",label:"ConfigMaps",icon:P,desc:"配置字典"},{type:"secrets",label:"Secrets",icon:k,desc:"密钥与凭证"},{type:"hpas",label:"HPAs",icon:w,desc:"水平自动伸缩策略"}];function S(){const{clusterCode:t,namespace:a}=g(),[x,p]=r.useState({}),[v,m]=r.useState(!1),d=r.useCallback(async()=>{if(!(!t||!a)){m(!0);try{const e=await Promise.allSettled([n.getNamespaceDeployments(t,a),n.getNamespacePods(t,a),n.getNamespaceServices(t,a),n.getNamespaceIngresses(t,a),n.getNamespaceConfigMaps(t,a),n.getNamespaceSecrets(t,a),n.getHPAs(t,a),n.getCronJobs(t,a)]),c=o=>Array.isArray(o)?o:o?.list||o?.data||[];p({deployments:c(e[0].status==="fulfilled"?e[0].value:[]).length,pods:c(e[1].status==="fulfilled"?e[1].value:[]).length,services:c(e[2].status==="fulfilled"?e[2].value:[]).length,ingresses:c(e[3].status==="fulfilled"?e[3].value:[]).length,configmaps:c(e[4].status==="fulfilled"?e[4].value:[]).length,secrets:c(e[5].status==="fulfilled"?e[5].value:[]).length,hpas:c(e[6].status==="fulfilled"?e[6].value:[]).length,cronjobs:c(e[7].status==="fulfilled"?e[7].value:[]).length})}catch{p({})}finally{m(!1)}}},[t,a]);return r.useEffect(()=>{d()},[d]),s.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:65:5",className:"space-y-4",children:[s.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:67:7",className:"flex items-center gap-2 text-sm text-slate-500",children:[s.jsx(l,{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:68:9",to:"/kubernetes",className:"hover:text-slate-300 transition-colors",children:"集群"}),s.jsx(i,{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:69:9",className:"h-3 w-3"}),s.jsx(l,{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:70:9",to:`/kubernetes/${t}`,className:"hover:text-slate-300 transition-colors",children:t}),s.jsx(i,{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:71:9",className:"h-3 w-3"}),s.jsx("span",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:72:9",className:"text-slate-300",children:a})]}),s.jsx("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:76:7",className:"flex items-center justify-between",children:s.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:77:9",children:[s.jsxs("h1",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:78:11",className:"text-2xl font-bold text-slate-100 flex items-center gap-2",children:[s.jsx(h,{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:79:13",className:"h-6 w-6 text-blue-400"}),a]}),s.jsx("p",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:82:11",className:"text-sm text-slate-500 mt-1",children:"命名空间概览"})]})}),s.jsx("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:87:7",className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:j.map(e=>s.jsxs(l,{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:89:11",to:`/kubernetes/${t}/namespace/${a}/${e.type}`,className:"bg-slate-900 border border-slate-800 rounded-lg p-4 hover:border-slate-600 hover:bg-slate-800/50 transition-all group",children:[s.jsxs("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:93:13",className:"flex items-center justify-between mb-2",children:[s.jsx(e.icon,{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:94:15",className:"h-5 w-5 text-slate-500 group-hover:text-blue-400 transition-colors"}),s.jsx(i,{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:95:15",className:"h-4 w-4 text-slate-600 group-hover:text-slate-400 transition-colors"})]}),s.jsx("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:97:13",className:"text-lg font-bold text-slate-100",children:v?"-":x[e.type]??0}),s.jsx("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:98:13",className:"text-sm text-slate-500",children:e.label}),s.jsx("div",{"code-path":"src/components/kubernetes/NamespaceOverviewPage.tsx:99:13",className:"text-xs text-slate-600 mt-1",children:e.desc})]},e.type))})]})}export{S as default};
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
import{r as g,G as xe,n as te,N as Q,t as T,j as e,B as i,a5 as he,L as A,I as P,i as be,z as ge,k as Ne,p as O,x as ne,A as le,v as de,m as se,S as ke,F as M,H as ve}from"./index-DfyorCky.js";import{C as Re,a as je}from"./card-C55cvSHg.js";import{B as E}from"./badge-xNW8x0G1.js";import{S as I,a as F,b as H,c as J,d as $}from"./select-D5qUzdAs.js";import{T as Pe,a as ye,b as C,c as fe,d as Ee,e as a}from"./table-5sHV4Akp.js";import{c as re,R as Ve,y as we,o as Ce,Y as Se,P as ze,a as _e}from"./PodFileBrowser-BySN2XGN.js";import{L as _}from"./label-BK0h2apY.js";import{T as $e}from"./textarea-NXY8u32k.js";import{u as ie}from"./use-toast-CrSOP4cJ.js";import{k as f}from"./kubernetes-J8O09fK7.js";import{F as ce}from"./file-text-C9G5abwR.js";import{S as W}from"./save-DoGGjfwC.js";import{P as G}from"./plus-CUG-9kpu.js";import{T as U}from"./trash-2-Dx32pOzT.js";import{R as Me}from"./refresh-cw-DUB_tAG-.js";import{D as oe}from"./download-DoZfYs2h.js";import{P as B}from"./pencil-BqUotcjf.js";import{H as Ye}from"./hard-drive-BbPmnARR.js";import"./index-CWVNW_qu.js";import"./copy-DXW4LnkN.js";import"./sparkles-Bld4NX5y.js";import"./xterm-DSqgeKvr.js";import"./box-TTGA1p57.js";import"./rotate-cw-5qcj_h_q.js";import"./minimize-2-CiCQYRfn.js";import"./arrow-left-BDgGyrD0.js";import"./upload-Ba6rlaGS.js";import"./folder-DoMwqvzv.js";function Te(s){try{return JSON.parse(s)}catch{}try{const t=s.split(`
|
||||
import{r as g,z as xe,o as te,N as Q,t as T,j as e,B as i,X as he,L as A,k as be,x as ge,m as Ne,q as O,C as ne,A as le,v as de,n as se,F as M,E as ke}from"./index-Dmami9WE.js";import{C as ve,a as Re}from"./card-CIfC-8Rh.js";import{I as P}from"./input-NsU9nXZF.js";import{B as E}from"./badge-3UzCvU7L.js";import{S as I,a as F,b as H,c as J,d as $}from"./select-DUbxjT0z.js";import{T as je,a as Pe,b as C,c as ye,d as fe,e as a}from"./table-CG4mjNfb.js";import{c as re,R as Ee,y as Ve,o as we,Y as Ce,P as Se,a as ze}from"./PodFileBrowser-BLvOIIeH.js";import{L as _}from"./label-Ap_-SPYI.js";import{T as _e}from"./textarea-DHUZ6N85.js";import{u as ie}from"./use-toast-jvSbBx20.js";import{k as f}from"./kubernetes-D2-GnE0t.js";import{F as ce}from"./file-text-CebshSV-.js";import{S as W}from"./save-YtnrpTd8.js";import{P as G}from"./plus-O65gX7Qz.js";import{T as U}from"./trash-2-DWVnIU6o.js";import{R as $e}from"./refresh-cw-CTBERyFc.js";import{D as oe}from"./download-Vuij9wGr.js";import{S as Me}from"./search-Dd-PeBfg.js";import{P as B}from"./pencil-BYahlvYT.js";import{H as Ye}from"./hard-drive-DmC04Y5r.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";import"./copy-CE_T92Lk.js";import"./sparkles-rPZivnlW.js";import"./xterm-DSqgeKvr.js";import"./box-88Ol5qY-.js";import"./rotate-cw-CKCO6IKE.js";import"./minimize-2-BHcbNmdK.js";import"./arrow-left-BIbk9wFC.js";import"./upload-CRLg7Pbj.js";import"./folder-B5RGB3GG.js";function Te(s){try{return JSON.parse(s)}catch{}try{const t=s.split(`
|
||||
`).filter(o=>!o.trim().startsWith("#"));return JSON.parse(t.join(`
|
||||
`))}catch{return null}}function Ae({clusterCode:s,namespace:t,resource:o,name:d,onClose:r,onSaved:x}){const{toast:v}=ie(),[w,V]=g.useState(!0),[R,m]=g.useState(!1),[u,b]=g.useState(""),[l,h]=g.useState(null),[N,j]=g.useState("visual"),[n,k]=g.useState(""),p=g.useCallback(async()=>{V(!0);try{const S=await f.getResourceYaml(s,t,o,d),L=re(S);b(S),k(L);const ee=Te(L);h(ee),ee||(j("yaml"),v({title:"可视化编辑不可用",description:"无法解析资源结构,已切换到 YAML 编辑模式"}))}catch(S){v({title:"加载失败",description:S.message,variant:"destructive"})}finally{V(!1)}},[s,t,o,d]);g.useEffect(()=>{p()},[p]);const y=async S=>{m(!0);try{const L=q(S);await f.updateResourceYaml(s,t,o,d,L),v({title:"保存成功",description:`${o}/${d} 已更新`}),x?.(),r()}catch(L){v({title:"保存失败",description:L.message,variant:"destructive"})}finally{m(!1)}},Z=async()=>{m(!0);try{await f.updateResourceYaml(s,t,o,d,n),v({title:"YAML 已应用",description:`${o}/${d} 更新成功`}),x?.(),r()}catch(S){v({title:"保存失败",description:S.message,variant:"destructive"})}finally{m(!1)}};function q(S){return JSON.stringify(S,null,2)}const X={configmaps:{title:"ConfigMap",icon:ce,color:"text-blue-400"},secrets:{title:"Secret",icon:T,color:"text-amber-400"},services:{title:"Service",icon:Q,color:"text-cyan-400"},ingresses:{title:"Ingress",icon:te,color:"text-purple-400"},pvcs:{title:"PersistentVolumeClaim",icon:xe,color:"text-emerald-400"}},Y=X[o]||X.configmaps,D=Y.icon;return e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:114:5",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:r,children:e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:115:7",className:"bg-[var(--dg-bg-primary)] border border-[var(--dg-border)] rounded-xl w-[90vw] max-w-3xl max-h-[85vh] flex flex-col shadow-2xl",onClick:S=>S.stopPropagation(),children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:117:9",className:"flex items-center justify-between p-4 border-b border-[var(--dg-border)]",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:118:11",className:"flex items-center gap-2",children:[e.jsx(D,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:119:13",className:`h-5 w-5 ${Y.color}`}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:120:13",children:[e.jsxs("h2",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:121:15",className:"text-lg font-bold text-[var(--dg-text-primary)]",children:[Y.title," 编辑器"]}),e.jsxs("p",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:122:15",className:"text-xs text-[var(--dg-text-muted)]",children:[d," · ",t," · ",s]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:125:11",className:"flex items-center gap-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:127:13",className:"flex rounded-lg border border-[var(--dg-border)] overflow-hidden",children:[e.jsx("button",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:128:15",className:`px-3 py-1.5 text-xs font-medium transition-colors ${N==="visual"?"bg-blue-600 text-white":"bg-transparent text-[var(--dg-text-secondary)] hover:bg-[var(--dg-bg-tertiary)]"}`,onClick:()=>l&&j("visual"),disabled:!l,children:"可视化编辑"}),e.jsx("button",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:133:15",className:`px-3 py-1.5 text-xs font-medium transition-colors ${N==="yaml"?"bg-blue-600 text-white":"bg-transparent text-[var(--dg-text-secondary)] hover:bg-[var(--dg-bg-tertiary)]"}`,onClick:()=>j("yaml"),children:"YAML 编辑"})]}),e.jsx(i,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:138:13",variant:"ghost",size:"icon",className:"h-8 w-8 text-[var(--dg-text-secondary)]",onClick:r,children:e.jsx(he,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:138:119",className:"h-4 w-4"})})]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:143:9",className:"flex-1 overflow-auto p-4",children:w?e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:145:13",className:"flex items-center justify-center h-full py-20",children:e.jsx(A,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:145:76",className:"h-6 w-6 animate-spin text-[var(--dg-text-muted)]"})}):N==="yaml"?e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:147:13",className:"space-y-3",children:[e.jsx("p",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:148:15",className:"text-xs text-amber-400/80",children:"⚠️ YAML 编辑模式 — 修改后点击保存。已自动清理只读字段(status/managedFields/uid)"}),e.jsx(Ve,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:149:15",value:n,height:"550px",theme:Ce,exten
Line truncated
|
||||
`))}catch{return null}}function Ae({clusterCode:s,namespace:t,resource:o,name:d,onClose:r,onSaved:x}){const{toast:v}=ie(),[w,V]=g.useState(!0),[R,m]=g.useState(!1),[u,b]=g.useState(""),[l,h]=g.useState(null),[N,j]=g.useState("visual"),[n,k]=g.useState(""),p=g.useCallback(async()=>{V(!0);try{const S=await f.getResourceYaml(s,t,o,d),L=re(S);b(S),k(L);const ee=Te(L);h(ee),ee||(j("yaml"),v({title:"可视化编辑不可用",description:"无法解析资源结构,已切换到 YAML 编辑模式"}))}catch(S){v({title:"加载失败",description:S.message,variant:"destructive"})}finally{V(!1)}},[s,t,o,d]);g.useEffect(()=>{p()},[p]);const y=async S=>{m(!0);try{const L=q(S);await f.updateResourceYaml(s,t,o,d,L),v({title:"保存成功",description:`${o}/${d} 已更新`}),x?.(),r()}catch(L){v({title:"保存失败",description:L.message,variant:"destructive"})}finally{m(!1)}},Z=async()=>{m(!0);try{await f.updateResourceYaml(s,t,o,d,n),v({title:"YAML 已应用",description:`${o}/${d} 更新成功`}),x?.(),r()}catch(S){v({title:"保存失败",description:S.message,variant:"destructive"})}finally{m(!1)}};function q(S){return JSON.stringify(S,null,2)}const X={configmaps:{title:"ConfigMap",icon:ce,color:"text-blue-400"},secrets:{title:"Secret",icon:T,color:"text-amber-400"},services:{title:"Service",icon:Q,color:"text-cyan-400"},ingresses:{title:"Ingress",icon:te,color:"text-purple-400"},pvcs:{title:"PersistentVolumeClaim",icon:xe,color:"text-emerald-400"}},Y=X[o]||X.configmaps,D=Y.icon;return e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:114:5",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:r,children:e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:115:7",className:"bg-[var(--dg-bg-primary)] border border-[var(--dg-border)] rounded-xl w-[90vw] max-w-3xl max-h-[85vh] flex flex-col shadow-2xl",onClick:S=>S.stopPropagation(),children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:117:9",className:"flex items-center justify-between p-4 border-b border-[var(--dg-border)]",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:118:11",className:"flex items-center gap-2",children:[e.jsx(D,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:119:13",className:`h-5 w-5 ${Y.color}`}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:120:13",children:[e.jsxs("h2",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:121:15",className:"text-lg font-bold text-[var(--dg-text-primary)]",children:[Y.title," 编辑器"]}),e.jsxs("p",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:122:15",className:"text-xs text-[var(--dg-text-muted)]",children:[d," · ",t," · ",s]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:125:11",className:"flex items-center gap-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:127:13",className:"flex rounded-lg border border-[var(--dg-border)] overflow-hidden",children:[e.jsx("button",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:128:15",className:`px-3 py-1.5 text-xs font-medium transition-colors ${N==="visual"?"bg-blue-600 text-white":"bg-transparent text-[var(--dg-text-secondary)] hover:bg-[var(--dg-bg-tertiary)]"}`,onClick:()=>l&&j("visual"),disabled:!l,children:"可视化编辑"}),e.jsx("button",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:133:15",className:`px-3 py-1.5 text-xs font-medium transition-colors ${N==="yaml"?"bg-blue-600 text-white":"bg-transparent text-[var(--dg-text-secondary)] hover:bg-[var(--dg-bg-tertiary)]"}`,onClick:()=>j("yaml"),children:"YAML 编辑"})]}),e.jsx(i,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:138:13",variant:"ghost",size:"icon",className:"h-8 w-8 text-[var(--dg-text-secondary)]",onClick:r,children:e.jsx(he,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:138:119",className:"h-4 w-4"})})]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:143:9",className:"flex-1 overflow-auto p-4",children:w?e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:145:13",className:"flex items-center justify-center h-full py-20",children:e.jsx(A,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:145:76",className:"h-6 w-6 animate-spin text-[var(--dg-text-muted)]"})}):N==="yaml"?e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:147:13",className:"space-y-3",children:[e.jsx("p",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:148:15",className:"text-xs text-amber-400/80",children:"⚠️ YAML 编辑模式 — 修改后点击保存。已自动清理只读字段(status/managedFields/uid)"}),e.jsx(Ee,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:149:15",value:n,height:"550px",theme:we,exten
Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{k as R,m as M,r as p,j as e,n as g,o as k,S,B as q,L as j,T as P,I as B,A as F,N as L,v as U}from"./index-Dmami9WE.js";import{C as c,a as o}from"./card-CIfC-8Rh.js";import{B as l}from"./badge-3UzCvU7L.js";import{T as A,a as E,b as D,c as n,d as I,e as r}from"./table-CG4mjNfb.js";import{k as z}from"./kubernetes-D2-GnE0t.js";import{R as H}from"./refresh-cw-CTBERyFc.js";import{C as f}from"./circle-check-CVbTTFQ0.js";function X(){const{clusterCode:d,nodeName:i}=R();M();const[s,N]=p.useState(null),[h,u]=p.useState(!1),b=p.useCallback(async()=>{if(!(!d||!i)){u(!0);try{const t=await z.getNodeDetail(d,i);N(t)}catch{N(null)}finally{u(!1)}}},[d,i]);p.useEffect(()=>{b()},[b]);const x=({label:t,used:a,total:v,unit:w,pct:C,color:$})=>{const m=Math.min(Math.max(C||0,0),100),T=m>80?"bg-red-500":m>60?"bg-amber-500":"bg-emerald-500";return e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:53:7",className:"space-y-1.5",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:54:9",className:"flex items-center justify-between text-xs",children:[e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:55:11",className:"text-slate-400",children:t}),e.jsxs("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:56:11",className:"text-slate-300 font-medium",children:[a," / ",v," ",w]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:60:9",className:"flex items-center gap-2",children:[e.jsx("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:61:11",className:"flex-1 h-2 rounded-full bg-slate-700/50 overflow-hidden",children:e.jsx("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:62:13",className:`h-full rounded-full ${T} transition-all duration-500`,style:{width:`${m}%`}})}),e.jsxs("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:64:11",className:`text-xs font-semibold min-w-[40px] text-right ${$}`,children:[m.toFixed(0),"%"]})]})]})},_=(t,a)=>a==="True"?t==="Ready"?"bg-emerald-500/20 text-emerald-400":"bg-red-500/20 text-red-400":"bg-slate-500/20 text-slate-400",y=t=>t==="NoSchedule"?"bg-red-500/20 text-red-400 border-red-500/30":t==="NoExecute"?"bg-red-600/20 text-red-300 border-red-600/30":t==="PreferNoSchedule"?"bg-amber-500/20 text-amber-400 border-amber-500/30":"bg-slate-500/20 text-slate-400 border-slate-500/30";return e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:89:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:91:7",className:"flex items-center gap-2 text-sm text-slate-500",children:[e.jsx(g,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:92:9",to:"/kubernetes",className:"hover:text-slate-300 transition-colors",children:"集群"}),e.jsx(k,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:93:9",className:"h-3 w-3"}),e.jsx(g,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:94:9",to:`/kubernetes/${d}`,className:"hover:text-slate-300 transition-colors",children:d}),e.jsx(k,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:95:9",className:"h-3 w-3"}),e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:96:9",className:"text-slate-300",children:i})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:100:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:101:9",className:"flex items-center gap-3",children:[e.jsx("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:102:11",className:"flex items-center justify-center w-12 h-12 rounded-xl bg-slate-800 border border-slate-700",children:e.jsx(S,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:103:13",className:"h-6 w-6 text-blue-400"})}),e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:105:11",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:106:13",className:"flex items-center gap-2",children:[e.jsx("h1",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:107:15",className:"text-2xl font-bold text-slate-100",children:i}),e.jsx(l,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:108:15",className:s?.role==="master"?"bg-blue-500/20 text-blue-400 border-blue-500/30":"bg-slate-500/20 text-slate-400 border-slate-500/30",children:s?.role||"worker"}),e.jsx(l,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:111:15",className:s?.status==="Ready"?"bg-emerald-500/20 text-emerald-400":"bg-red-500/20 text-red-400",children:s?.status||"Unknown"})]}),e.jsxs("p",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:115:13",className:"text-sm text-slate-500 mt-0.5",children:[s?.internal_ip&&`${s.internal_ip}`,s?.hostname&&` · ${s.hostname}`]})]})]}),e.jsx(q,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:121:9",variant:"outline",size:"icon",className:"h-9 w-9 border-slate-700 text-slate-4Line truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{i as R,k as M,r as p,j as e,m as g,n as k,q,B,L as j,T as P,w as S,A as F,N as L,v as U}from"./index-DfyorCky.js";import{C as c,a as o}from"./card-C55cvSHg.js";import{B as l}from"./badge-xNW8x0G1.js";import{T as A,a as E,b as D,c as n,d as I,e as r}from"./table-5sHV4Akp.js";import{k as z}from"./kubernetes-J8O09fK7.js";import{R as H}from"./refresh-cw-DUB_tAG-.js";import{C as f}from"./circle-check-DWcXrx2k.js";function X(){const{clusterCode:d,nodeName:i}=R();M();const[s,N]=p.useState(null),[h,u]=p.useState(!1),b=p.useCallback(async()=>{if(!(!d||!i)){u(!0);try{const t=await z.getNodeDetail(d,i);N(t)}catch{N(null)}finally{u(!1)}}},[d,i]);p.useEffect(()=>{b()},[b]);const x=({label:t,used:a,total:v,unit:w,pct:C,color:$})=>{const m=Math.min(Math.max(C||0,0),100),T=m>80?"bg-red-500":m>60?"bg-amber-500":"bg-emerald-500";return e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:53:7",className:"space-y-1.5",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:54:9",className:"flex items-center justify-between text-xs",children:[e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:55:11",className:"text-slate-400",children:t}),e.jsxs("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:56:11",className:"text-slate-300 font-medium",children:[a," / ",v," ",w]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:60:9",className:"flex items-center gap-2",children:[e.jsx("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:61:11",className:"flex-1 h-2 rounded-full bg-slate-700/50 overflow-hidden",children:e.jsx("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:62:13",className:`h-full rounded-full ${T} transition-all duration-500`,style:{width:`${m}%`}})}),e.jsxs("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:64:11",className:`text-xs font-semibold min-w-[40px] text-right ${$}`,children:[m.toFixed(0),"%"]})]})]})},_=(t,a)=>a==="True"?t==="Ready"?"bg-emerald-500/20 text-emerald-400":"bg-red-500/20 text-red-400":"bg-slate-500/20 text-slate-400",y=t=>t==="NoSchedule"?"bg-red-500/20 text-red-400 border-red-500/30":t==="NoExecute"?"bg-red-600/20 text-red-300 border-red-600/30":t==="PreferNoSchedule"?"bg-amber-500/20 text-amber-400 border-amber-500/30":"bg-slate-500/20 text-slate-400 border-slate-500/30";return e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:89:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:91:7",className:"flex items-center gap-2 text-sm text-slate-500",children:[e.jsx(g,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:92:9",to:"/kubernetes",className:"hover:text-slate-300 transition-colors",children:"集群"}),e.jsx(k,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:93:9",className:"h-3 w-3"}),e.jsx(g,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:94:9",to:`/kubernetes/${d}`,className:"hover:text-slate-300 transition-colors",children:d}),e.jsx(k,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:95:9",className:"h-3 w-3"}),e.jsx("span",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:96:9",className:"text-slate-300",children:i})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:100:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:101:9",className:"flex items-center gap-3",children:[e.jsx("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:102:11",className:"flex items-center justify-center w-12 h-12 rounded-xl bg-slate-800 border border-slate-700",children:e.jsx(q,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:103:13",className:"h-6 w-6 text-blue-400"})}),e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:105:11",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:106:13",className:"flex items-center gap-2",children:[e.jsx("h1",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:107:15",className:"text-2xl font-bold text-slate-100",children:i}),e.jsx(l,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:108:15",className:s?.role==="master"?"bg-blue-500/20 text-blue-400 border-blue-500/30":"bg-slate-500/20 text-slate-400 border-slate-500/30",children:s?.role||"worker"}),e.jsx(l,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:111:15",className:s?.status==="Ready"?"bg-emerald-500/20 text-emerald-400":"bg-red-500/20 text-red-400",children:s?.status||"Unknown"})]}),e.jsxs("p",{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:115:13",className:"text-sm text-slate-500 mt-0.5",children:[s?.internal_ip&&`${s.internal_ip}`,s?.hostname&&` · ${s.hostname}`]})]})]}),e.jsx(B,{"code-path":"src/components/kubernetes/NodeDetailPage.tsx:121:9",variant:"outline",size:"icon",className:"h-9 w-9 border-slate-700 text-slate-400",oLine truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{g as B,i as Ke,r as i,a as Xe,j as e,L as J,a0 as V,B as p,t as Pe,a4 as Ee,n as ve,I as v,x as ue,a9 as Ye,a5 as Qe,aa as es,v as ss,F as ts,H as os,q as ns,D as cs,b as ds,c as is,d as rs}from"./index-DfyorCky.js";import{C as P,a as E}from"./card-C55cvSHg.js";import{B as j}from"./badge-xNW8x0G1.js";import{T as as,a as ps,b as k,c as C}from"./tabs-CIh_yD4s.js";import{S as $,a as R,b as O,c as I,d as h,C as ls}from"./select-D5qUzdAs.js";import{T as xs}from"./textarea-NXY8u32k.js";import{S as G}from"./switch-CGiGgOnh.js";import{L as y}from"./label-BK0h2apY.js";import{t as m}from"./index-a3ybMjbR.js";import{d as ms,p as g}from"./deploy-B3Sg3N1U.js";import{S as hs}from"./save-DoGGjfwC.js";import{P as ys}from"./play-cdPayOtJ.js";import{P as D}from"./plus-CUG-9kpu.js";import{T as S}from"./trash-2-Dx32pOzT.js";import{C as Ne}from"./circle-stop-s4wxdTEV.js";import{F as gs}from"./file-text-C9G5abwR.js";import{U as js}from"./user-plus-BwUWtcQl.js";import{Z as Ps}from"./zap-D2uWSK32.js";import{W as we}from"./wrench-KfbhOOJm.js";import"./index-CWVNW_qu.js";const Es=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],vs=B("flask-conical",Es);const us=[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]],be=B("hand",us);const Ns=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],bs=B("scroll-text",Ns);const fs=[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]],fe=B("webhook",fs),ws={source:"拉取代码",build:"构建",deploy:"部署",test:"测试",custom:"自定义"},ke={GitBranch:V,Wrench:we,Server:ns,FlaskConical:vs,Zap:Ps,Terminal:os,FileCode:ts,Container:ss};function ks(){return`tsk-${Date.now()}-${Math.random().toString(36).slice(2,7)}`}function Ce(r){if(!r)return"-";if(r<60)return`${r}s`;const d=Math.floor(r/60),c=r%60;return c>0?`${d}分${c}秒`:`${d}分`}function Cs({task:r,selected:d,onSelect:c,onDelete:u}){const a=ke[r.icon]||we;return e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:75:5",onClick:c,className:`flex items-center gap-3 p-3 rounded-md border cursor-pointer transition-all group ${d?"border-blue-500 bg-blue-500/10":"border-[var(--dg-border)] hover:border-slate-400 bg-[var(--dg-bg-secondary)]"}`,children:[e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:81:7",className:`p-1.5 rounded ${d?"bg-blue-100":"bg-slate-100 dark:bg-slate-800"}`,children:e.jsx(a,{"code-path":"src/components/deploy/PipelineEditor.tsx:82:9",className:`w-4 h-4 ${d?"text-blue-600":"text-[var(--dg-text-secondary)]"}`})}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:84:7",className:"flex-1 min-w-0",children:[e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:85:9",className:"text-sm font-medium text-[var(--dg-text-primary)] truncate",children:r.name}),e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:86:9",className:"text-xs text-[var(--dg-text-secondary)]",children:r.type})]}),e.jsx(p,{"code-path":"src/components/deploy/PipelineEditor.tsx:88:7",variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100",onClick:x=>{x.stopPropagation(),u()},children:e.jsx(S,{"code-path":"src/components/deploy/PipelineEditor.tsx:89:9",className:"w-3.5 h-3.5 text-red-500"})})]})}function Ss({task:r,onUpdate:d}){return r?e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:99:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:100:7",className:"space-y-1",children:[e.jsx(y,{"code-path":"src/components/deploy/PipelineEditor.tsx:100:34",className:"text-xs",children:"任务名称"}),e.jsx(v,{"code-path":"src/components/deploy/PipelineEditor.tsx:100:73",value:r.name,onChange:c=>d({...r,name:c.target.value}),className:"h-8 text-sm"})]}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:101:7",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:102:9",className:"space-y-1",children:[e.jsx(y,{"code-path":"src/components/deploy/PipelineEditor.tsx:102:36",className:"text-xs",children:"类型"}),e.jsxs($,{"code-path":"src/components/deploy/Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{i as W,k as Ze,r as i,f as Qe,j as e,L as q,Q as V,B as p,t as Pe,V as Ee,o as ve,C as ue,K as Xe,X as Ye,W as es,v as ss,F as ts,E as os,S as ns,D as cs,a as ds,b as is,c as rs}from"./index-Dmami9WE.js";import{C as P,a as E}from"./card-CIfC-8Rh.js";import{I as v}from"./input-NsU9nXZF.js";import{B as j}from"./badge-3UzCvU7L.js";import{T as as,a as ps,b as k,c as C}from"./tabs-lV44z_UR.js";import{S as $,a as R,b as O,c as I,d as h}from"./select-DUbxjT0z.js";import{T as ls}from"./textarea-DHUZ6N85.js";import{S as G}from"./switch-TqjD2x0W.js";import{L as y}from"./label-Ap_-SPYI.js";import{t as m}from"./index-BuEnLCjT.js";import{d as xs,p as g}from"./deploy-CD5bEXt-.js";import{S as ms}from"./save-YtnrpTd8.js";import{P as hs}from"./play-0EwQQJX_.js";import{P as D}from"./plus-O65gX7Qz.js";import{C as ys}from"./chevron-up-Cq4GPopa.js";import{T as S}from"./trash-2-DWVnIU6o.js";import{C as Ne}from"./circle-stop-DadQKvNg.js";import{F as gs}from"./file-text-CebshSV-.js";import{U as js}from"./user-plus-DKeca2Dx.js";import{Z as Ps}from"./zap-CocSkPPl.js";import{W as we}from"./wrench-DMCGQEzN.js";import"./index-CtCQcvyh.js";const Es=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],vs=W("flask-conical",Es);const us=[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]],be=W("hand",us);const Ns=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],bs=W("scroll-text",Ns);const fs=[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]],fe=W("webhook",fs),ws={source:"拉取代码",build:"构建",deploy:"部署",test:"测试",custom:"自定义"},ke={GitBranch:V,Wrench:we,Server:ns,FlaskConical:vs,Zap:Ps,Terminal:os,FileCode:ts,Container:ss};function ks(){return`tsk-${Date.now()}-${Math.random().toString(36).slice(2,7)}`}function Ce(r){if(!r)return"-";if(r<60)return`${r}s`;const d=Math.floor(r/60),c=r%60;return c>0?`${d}分${c}秒`:`${d}分`}function Cs({task:r,selected:d,onSelect:c,onDelete:u}){const a=ke[r.icon]||we;return e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:75:5",onClick:c,className:`flex items-center gap-3 p-3 rounded-md border cursor-pointer transition-all group ${d?"border-blue-500 bg-blue-500/10":"border-[var(--dg-border)] hover:border-slate-400 bg-[var(--dg-bg-secondary)]"}`,children:[e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:81:7",className:`p-1.5 rounded ${d?"bg-blue-100":"bg-slate-100 dark:bg-slate-800"}`,children:e.jsx(a,{"code-path":"src/components/deploy/PipelineEditor.tsx:82:9",className:`w-4 h-4 ${d?"text-blue-600":"text-[var(--dg-text-secondary)]"}`})}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:84:7",className:"flex-1 min-w-0",children:[e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:85:9",className:"text-sm font-medium text-[var(--dg-text-primary)] truncate",children:r.name}),e.jsx("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:86:9",className:"text-xs text-[var(--dg-text-secondary)]",children:r.type})]}),e.jsx(p,{"code-path":"src/components/deploy/PipelineEditor.tsx:88:7",variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100",onClick:x=>{x.stopPropagation(),u()},children:e.jsx(S,{"code-path":"src/components/deploy/PipelineEditor.tsx:89:9",className:"w-3.5 h-3.5 text-red-500"})})]})}function Ss({task:r,onUpdate:d}){return r?e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:99:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:100:7",className:"space-y-1",children:[e.jsx(y,{"code-path":"src/components/deploy/PipelineEditor.tsx:100:34",className:"text-xs",children:"任务名称"}),e.jsx(v,{"code-path":"src/components/deploy/PipelineEditor.tsx:100:73",value:r.name,onChange:c=>d({...r,name:c.target.value}),className:"h-8 text-sm"})]}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:101:7",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineEditor.tsx:102:9",className:"space-y-1",children:[e.jsx(y,{"code-path":"src/components/deploy/PipelineEditor.tsx:102:36",className:"text-xs"Line truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{g as bs,j as e,L as w,a3 as B,r as n,a as Js,k as Hs,h as fe,B as p,x as W,a0 as E,a7 as I,q as ye,v as ne,N as ue,S as Qs,I as g,O as ve,a4 as Ks,n as be,D as ds,b as ps,c as is,d as xs}from"./index-DfyorCky.js";import{C as ms,a as hs}from"./card-C55cvSHg.js";import{B as y}from"./badge-xNW8x0G1.js";import{T as Us}from"./textarea-NXY8u32k.js";import{L as d}from"./label-BK0h2apY.js";import{S as Z,a as ee,b as se,c as ae,d as v}from"./select-D5qUzdAs.js";import{d as je,p as P}from"./deploy-B3Sg3N1U.js";import{t as x}from"./index-a3ybMjbR.js";import{C as D}from"./circle-x-DK79Dhg2.js";import{P as Pe}from"./plus-CUG-9kpu.js";import{A as R}from"./arrow-right-DyIltvNZ.js";import{L as Xs}from"./layers-FW4KKJMi.js";import{S as js}from"./shield-check-Dcx486cW.js";import{C as Ys}from"./code-L62jFLTC.js";import{C as Me}from"./circle-stop-s4wxdTEV.js";import{P as Zs}from"./play-cdPayOtJ.js";import{H as ea}from"./history-D_9jPUQg.js";import{T as gs}from"./trash-2-Dx32pOzT.js";import{B as sa}from"./box-TTGA1p57.js";import{T as ys}from"./tag-0HCfq8kH.js";import{F as us}from"./file-text-C9G5abwR.js";import"./index-CWVNW_qu.js";const aa=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 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.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],ta=bs("package",aa);const na=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],vs=bs("workflow",na);function oa(c){return c.toLowerCase().replace(/[^a-z0-9]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||`pipeline-${Date.now()}`}function ca(c){switch(c){case"success":return e.jsxs(y,{"code-path":"src/components/deploy/pipeline-helpers.tsx:49:9",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:[e.jsx(B,{"code-path":"src/components/deploy/pipeline-helpers.tsx:50:11",className:"h-3 w-3 mr-1"}),"成功"]});case"failed":return e.jsxs(y,{"code-path":"src/components/deploy/pipeline-helpers.tsx:56:9",variant:"outline",className:"border-red-500/30 text-red-400 bg-red-500/10",children:[e.jsx(D,{"code-path":"src/components/deploy/pipeline-helpers.tsx:57:11",className:"h-3 w-3 mr-1"}),"失败"]});case"running":return e.jsxs(y,{"code-path":"src/components/deploy/pipeline-helpers.tsx:63:9",variant:"outline",className:"border-blue-500/30 text-blue-400 bg-blue-500/10 animate-pulse",children:[e.jsx(w,{"code-path":"src/components/deploy/pipeline-helpers.tsx:64:11",className:"h-3 w-3 mr-1 animate-spin"}),"运行中"]});default:return e.jsx(y,{"code-path":"src/components/deploy/pipeline-helpers.tsx:70:9",variant:"outline",className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)]",children:"从未运行"})}}const te=[{key:"checkout",label:"代码检出",icon:E,color:"#6366F1",order:1,needs:["repo"],desc:"从 Git 仓库拉取代码"},{key:"build",label:"构建",icon:sa,color:"#F59E0B",order:2,needs:[],desc:"编译/打包项目"},{key:"test",label:"测试",icon:B,color:"#10B981",order:3,needs:[],desc:"运行单元/集成测试"},{key:"image",label:"镜像打包",icon:ne,color:"#06B6D4",order:4,needs:["registry"],desc:"Docker 构建 & 推送"},{key:"deploy",label:"部署",icon:I,color:"#EF4444",order:5,needs:[],desc:"部署到目标环境"},{key:"verify",label:"验证",icon:js,color:"#3B82F6",order:6,needs:[],desc:"部署后健康检查"}].sort((c,b)=>c.order-b.order);function Ne(c){if(!c)return"-";if(c<60)return`${c}s`;const b=Math.floor(c/60),i=c%60;return i>0?`${b}分${i}秒`:`${b}分`}function ra(c){if(!c)return[];try{const b=typeof c=="string"?JSON.parse(c):c;return Array.isArray(b)?b:[]}catch{return[]}}function La(){const[c,b]=n.useState(""),[i,q]=n.useState([]),[J,L]=n.useState(!0),[M,k]=n.useState({}),[H,T]=n.useState({}),[N,A]=n.useState({}),[F,$]=n.useState("all"),[r,we]=n.useState({}),[Ps,z]=n.useState(!1),[Q,ke]=n.useState(""),[_,_e]=n.useState(""),[Ce,Se]=n.useState(""),[oe,Re]=n.useState(""),[Ee,Be]=n.useState("main"),[De,Le]=n.useState(""),[m,Te]=n.useState(["checkout","build","image","deploy"]),[,Ms]=n.useState(""),[,Ns]=n.useState(""),[ce,Ae]=n.useState("branch"),[Fe,$e]=n.useState("ssh"),[re,ze]=n.useState(""),[le,Oe]=n.useState(!1),[fs,ws]=n.useState([]),[ks,_s]=n.useState([]),[K,Ve]=n.useState(""),[C,Ge]=n.useState(""),[O,Ie]=n.useState("manual"),[We,qe]=n.useState(""),[Je,He]=n.useState(""),[Qe,de]=n.useState(""),[Ke,Ue]=n.useState(""),[j,S]=n.useState([]),[Xe,Ye]=n.useState(""),[Ze,Cs]=n.useState(2),[,Ss]=n.useState([]),[,Rs]=n.useState([]),[Es,Bs]=n.useState([]),[,da]=n.useState([]),[,pa]=n.useState([]),[Ds,es]=n.useState(!1),[V,Ls]=n.useState(null),[ss,as]=n.useState([]),ts=Js(),ns=Hs(),Ts=[{key:"all",label:"全部",icon:Xs,color:"#6B7280"},{key:"production",label:"生产",icon:js,color:"#EF4444"},{key:"testLine truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{i as gs,j as e,L as R,P as G,r as n,f as Gs,m as Is,h as Ne,B as p,C as I,Q as E,al as V,S as ge,v as te,N as ye,am as ys,G as ue,V as Ws,o as ve,D as ls,a as ds,b as ps,c as is}from"./index-Dmami9WE.js";import{C as qs,a as Js}from"./card-CIfC-8Rh.js";import{I as g}from"./input-NsU9nXZF.js";import{B as y}from"./badge-3UzCvU7L.js";import{T as Hs}from"./textarea-DHUZ6N85.js";import{L as d}from"./label-Ap_-SPYI.js";import{S as Y,a as Z,b as ee,c as se,d as v}from"./select-DUbxjT0z.js";import{d as be,p as P}from"./deploy-CD5bEXt-.js";import{t as x}from"./index-BuEnLCjT.js";import{C as W}from"./circle-x-BBQeW1R3.js";import{P as je}from"./plus-O65gX7Qz.js";import{A as S}from"./arrow-right-CkKR0P0R.js";import{S as Qs}from"./search-Dd-PeBfg.js";import{L as Ks}from"./layers-Dv4yGMGm.js";import{C as Us}from"./code-BAhZJUYV.js";import{C as Pe}from"./circle-stop-DadQKvNg.js";import{P as Xs}from"./play-0EwQQJX_.js";import{H as Ys}from"./history-CbX6uocL.js";import{T as xs}from"./trash-2-DWVnIU6o.js";import{B as Zs}from"./box-88Ol5qY-.js";import{T as ms}from"./tag-utZ9-UQ0.js";import{F as hs}from"./file-text-CebshSV-.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";const ea=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 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.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],sa=gs("package",ea);const aa=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],ta=gs("workflow",aa);function na(c){return c.toLowerCase().replace(/[^a-z0-9]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||`pipeline-${Date.now()}`}function oa(c){switch(c){case"success":return e.jsxs(y,{"code-path":"src/components/deploy/pipeline-helpers.tsx:49:9",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:[e.jsx(G,{"code-path":"src/components/deploy/pipeline-helpers.tsx:50:11",className:"h-3 w-3 mr-1"}),"成功"]});case"failed":return e.jsxs(y,{"code-path":"src/components/deploy/pipeline-helpers.tsx:56:9",variant:"outline",className:"border-red-500/30 text-red-400 bg-red-500/10",children:[e.jsx(W,{"code-path":"src/components/deploy/pipeline-helpers.tsx:57:11",className:"h-3 w-3 mr-1"}),"失败"]});case"running":return e.jsxs(y,{"code-path":"src/components/deploy/pipeline-helpers.tsx:63:9",variant:"outline",className:"border-blue-500/30 text-blue-400 bg-blue-500/10 animate-pulse",children:[e.jsx(R,{"code-path":"src/components/deploy/pipeline-helpers.tsx:64:11",className:"h-3 w-3 mr-1 animate-spin"}),"运行中"]});default:return e.jsx(y,{"code-path":"src/components/deploy/pipeline-helpers.tsx:70:9",variant:"outline",className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)]",children:"从未运行"})}}const ae=[{key:"checkout",label:"代码检出",icon:E,color:"#6366F1",order:1,needs:["repo"],desc:"从 Git 仓库拉取代码"},{key:"build",label:"构建",icon:Zs,color:"#F59E0B",order:2,needs:[],desc:"编译/打包项目"},{key:"test",label:"测试",icon:G,color:"#10B981",order:3,needs:[],desc:"运行单元/集成测试"},{key:"image",label:"镜像打包",icon:te,color:"#06B6D4",order:4,needs:["registry"],desc:"Docker 构建 & 推送"},{key:"deploy",label:"部署",icon:V,color:"#EF4444",order:5,needs:[],desc:"部署到目标环境"},{key:"verify",label:"验证",icon:ys,color:"#3B82F6",order:6,needs:[],desc:"部署后健康检查"}].sort((c,b)=>c.order-b.order);function Me(c){if(!c)return"-";if(c<60)return`${c}s`;const b=Math.floor(c/60),i=c%60;return i>0?`${b}分${i}秒`:`${b}分`}function ca(c){if(!c)return[];try{const b=typeof c=="string"?JSON.parse(c):c;return Array.isArray(b)?b:[]}catch{return[]}}function Ta(){const[c,b]=n.useState(""),[i,q]=n.useState([]),[J,B]=n.useState(!0),[M,w]=n.useState({}),[H,D]=n.useState({}),[N,L]=n.useState({}),[T,A]=n.useState("all"),[r,fe]=n.useState({}),[us,F]=n.useState(!1),[Q,we]=n.useState(""),[k,ke]=n.useState(""),[_e,Ce]=n.useState(""),[ne,Se]=n.useState(""),[Re,Ee]=n.useState("main"),[Be,De]=n.useState(""),[m,Le]=n.useState(["checkout","build","image","deploy"]),[,vs]=n.useState(""),[,bs]=n.useState(""),[oe,Te]=n.useState("branch"),[Ae,Fe]=n.useState("ssh"),[ce,$e]=n.useState(""),[re,ze]=n.useState(!1),[js,Ps]=n.useState([]),[Ms,Ns]=n.useState([]),[K,Oe]=n.useState(""),[_,Ve]=n.useState(""),[$,Ge]=n.useState("manual"),[Ie,We]=n.useState(""),[qe,Je]=n.useState(""),[He,le]=n.useState(""),[Qe,Ke]=n.useState(""),[j,C]=n.useState([]),[Ue,Xe]=n.useState(""),[Ye,fs]=n.useState(2),[,ws]=n.useState([]),[,ks]=n.useState([]),[_s,Cs]=n.useState([]),[,la]=n.useState([]),[,da]=n.useState([]),[Ss,Ze]=n.useState(!1),[z,Rs]=n.useState(null),[es,ss]=n.useState([]),as=Gs(),ts=Is(),Es=[{key:"all",label:"全部",icon:Ks,color:"#6B7280"},{key:"produLine truncated
|
||||
@@ -1,3 +0,0 @@
|
||||
import{r as n,j as e,D as me,b as he,X as ue,d as ge,e as ye,a5 as be,a6 as fe,n as ee,h as C,W as De,i as je,B as E,a0 as Ne,v as ve,a7 as we,L as $,$ as Re,x as te,a8 as Pe,_ as Be}from"./index-DfyorCky.js";import{B as A}from"./badge-xNW8x0G1.js";import{C as Fe,b as ke,c as Se,a as Ce}from"./card-C55cvSHg.js";import{t as S}from"./index-a3ybMjbR.js";import{F as H}from"./folder-open-IMBifk-r.js";import{M as $e,a as _e}from"./minimize-2-CiCQYRfn.js";import{A as ze}from"./arrow-left-BDgGyrD0.js";import{F as Ee}from"./file-text-C9G5abwR.js";import{D as Ae}from"./download-DoZfYs2h.js";import{H as Z}from"./history-D_9jPUQg.js";import{T as Le}from"./trash-2-Dx32pOzT.js";import{R as Ie}from"./refresh-cw-DUB_tAG-.js";import{P as Te}from"./play-cdPayOtJ.js";import{B as Oe}from"./box-TTGA1p57.js";import{C as I}from"./circle-check-DWcXrx2k.js";import{S as Me}from"./shield-check-Dcx486cW.js";import{C as G}from"./circle-x-DK79Dhg2.js";import{S as Ue}from"./square-9TIYDO_t.js";function We(s){return s===0?"-":s<1024?s+" B":s<1024*1024?(s/1024).toFixed(1)+" KB":(s/(1024*1024)).toFixed(1)+" MB"}function He({open:s,onOpenChange:o,runId:u,buildNumber:r}){const[x,a]=n.useState(null),[P,B]=n.useState(!1),[N,L]=n.useState(""),[v,i]=n.useState(""),[w,_]=n.useState(!1),F=async c=>{if(u){B(!0),L("");try{const h=c?`?path=${encodeURIComponent(c)}`:"",g=await C.get(`/pipelines/runs/${u}/files${h}`);a(g),i(g?.current||"")}catch(h){L(h?.message||"加载失败"),a(null)}finally{B(!1)}}};n.useEffect(()=>{s&&u&&(i(""),F(""))},[s,u]);const b=async c=>{const h=De.getState().token||"",g=`${location.protocol}//${location.host}/api/v1/pipelines/runs/${u}/files/download?path=${encodeURIComponent(c.path)}&token=${encodeURIComponent(h)}`;window.open(g,"_blank")},R=v?v.split("/").filter(Boolean):[],T=[""].concat(R.map((c,h)=>"/"+R.slice(0,h+1).join("/")));return e.jsx(me,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:105:5",open:s,onOpenChange:o,children:e.jsxs(he,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:106:7",showCloseButton:!1,className:ue("bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] p-0 gap-0","!duration-0 !transition-none",w?"!max-w-none !w-screen !h-screen !rounded-none":""),style:w?{maxWidth:"100vw",width:"100vw",height:"100vh"}:{maxWidth:"700px",width:"85vw"},children:[e.jsxs(ge,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:117:9",className:"sr-only",children:["文件浏览器 #",r]}),e.jsx(ye,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:118:9",className:"sr-only",children:"流水线构建目录文件浏览"}),e.jsxs("div",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:121:9",className:"flex items-center justify-between px-4 py-2.5 border-b border-[var(--dg-border)] shrink-0",children:[e.jsxs("div",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:122:11",className:"flex items-center gap-2 min-w-0",children:[e.jsx(H,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:123:13",className:"h-4 w-4 text-[var(--dg-text-secondary)] shrink-0"}),e.jsxs("span",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:124:13",className:"text-[var(--dg-text-primary)] font-medium text-sm",children:["#",r," 工作区文件"]})]}),e.jsxs("div",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:128:11",className:"flex items-center gap-1",children:[e.jsx("button",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:129:13",onClick:()=>_(!w),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]",children:w?e.jsx($e,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:133:29",className:"h-4 w-4"}):e.jsx(_e,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:133:65",className:"h-4 w-4"})}),e.jsx("button",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:135:13",onClick:()=>o(!1),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]",children:e.jsx(be,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:139:15",className:"h-4 w-4"})})]})]}),e.jsx("div",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:145:9",className:"flex items-center gap-0.5 px-4 py-2 text-xs border-b border-[var(--dg-border)] bg-[var(--dg-bg-primary)] overflow-x-auto shrink-0",children:T.map((c,h)=>e.jsx("span",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:147:13",className:"flex items-center gap-0.5",children:h===0?e.jsx("button",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:149:17",onClick:()=>F(""),className:"text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)] p-0.5",children:e.jsx(fe,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:153:19",className:"h-3.5 w-3.5"})}):e.jsxs(e.Fragment,{children:[e.jsx(ee,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:157:19",className:"h-3 w-3 text-[var(--dg-text-muted)] shrink-0"}),e.jsx("button",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:158:19",onClick:()=>F(c),className:"text-[varLine truncated
|
||||
${y?"ring-1 ring-offset-0 scale-[1.02]":"hover:brightness-110"}`,style:{backgroundColor:M,borderColor:U,color:D,borderRadius:xe},children:[de,e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:393:17",children:t.label})]}),!Y&&e.jsx("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:396:17",className:"flex items-center justify-center w-5 h-5 -mx-px z-10",children:e.jsx(ee,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:397:19",className:"h-3.5 w-3.5",style:{color:D+"99"}})})]},t.key)}),a&&e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:404:11",className:"ml-auto text-[10px] text-[var(--dg-text-secondary)] opacity-40 shrink-0 pl-3 whitespace-nowrap",children:i?j.find(t=>t.key===i)?.label:"全阶段"})]}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:411:7",className:"flex-1 flex flex-col min-h-0",children:[e.jsx("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:413:9",className:"rounded-md border border-[var(--dg-border)] overflow-hidden mb-4",children:L&&r.length===0?e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:415:13",className:"text-center py-12",children:[e.jsx($,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:416:15",className:"w-6 h-6 animate-spin mx-auto mb-2 text-[var(--dg-text-muted)]"}),"加载中..."]}):r.length===0?e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:420:13",className:"text-center py-12 border border-dashed border-[var(--dg-border)] rounded-lg m-4",children:[e.jsx(Z,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:421:15",className:"w-10 h-10 mx-auto mb-3 text-[var(--dg-text-muted)]"}),e.jsx("p",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:422:15",className:"text-[var(--dg-text-secondary)]",children:'暂无执行记录,点击"立即执行"触发构建'})]}):e.jsxs("table",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:425:13",className:"w-full text-sm",children:[e.jsx("thead",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:426:15",className:"bg-[var(--dg-bg-tertiary)] border-b border-[var(--dg-border)]",children:e.jsxs("tr",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:427:17",children:[e.jsx("th",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:428:19",className:"px-2 py-2.5 w-10",children:e.jsx("input",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:429:21",type:"checkbox",checked:b.size===r.length&&r.length>0,onChange:pe,className:"rounded"})}),e.jsx("th",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:432:19",className:"px-3 py-2.5 text-left font-medium text-[var(--dg-text-secondary)] w-16",children:"构建"}),e.jsx("th",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:433:19",className:"px-3 py-2.5 text-left font-medium text-[var(--dg-text-secondary)] w-20",children:"状态"}),e.jsx("th",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:434:19",className:"px-3 py-2.5 text-left font-medium text-[var(--dg-text-secondary)]",children:"触发方式"}),e.jsx("th",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:435:19",className:"px-3 py-2.5 text-left font-medium text-[var(--dg-text-secondary)]",children:"用户"}),e.jsx("th",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:436:19",className:"px-3 py-2.5 text-left font-medium text-[var(--dg-text-secondary)]",children:"耗时"}),e.jsx("th",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:437:19",className:"px-3 py-2.5 text-left font-medium text-[var(--dg-text-secondary)] hidden md:table-cell",children:"时间"}),e.jsx("th",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:438:19",className:"px-3 py-2.5 text-right font-medium text-[var(--dg-text-secondary)] w-32",children:"操作"})]})}),e.jsx("tbody",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:441:15",children:r.map(t=>{const p=Je[t.status]||te;return e.jsxs("tr",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:445:21",className:`border-b border-[var(--dg-border)] cursor-pointer transition-colors
|
||||
${a?.id===t.id?"bg-[var(--dg-blue)]/10":"hover:bg-[var(--dg-bg-tertiary)]/50"}`,onClick:()=>{P(t)},children:[e.jsx("td",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:449:23",className:"px-2 py-2.5",onClick:l=>l.stopPropagation(),children:e.jsx("input",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:450:25",type:"checkbox",checked:b.has(t.id),onChange:()=>ie(t.id),className:"rounded"})}),e.jsxs("td",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:453:23",className:"px-3 py-2.5 font-mono font-semibold text-[var(--dg-text-primary)]",children:["#",t.build_number]}),e.jsx("td",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:456:23",className:"px-3 py-2.5",children:e.jsxs(A,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:457:25",className:`text-xs ${Ge[t.status]||""} flex items-center gap-1 w-fit`,children:[e.jsx(p,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:458:27",className:`w-3 h-3 ${t.status==="running"?"animate-spin":""}`}),t.status==="success"?"成功":t.status==="failed"?"失败":t.status==="running"?"执行中":t.status==="cancelled"?"已取消":"待执行"]})}),e.jsx("td",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:466:23",className:"px-3 py-2.5",children:e.jsx(A,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:467:25",variant:"outline",className:"text-xs",children:K(t)})}),e.jsxs("td",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:469:23",className:"px-3 py-2.5 text-[var(--dg-text-secondary)] flex items-center gap-1",children:[e.jsx(Pe,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:470:25",className:"w-3 h-3"}),t.triggered_by||"admin"]}),e.jsx("td",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:473:23",className:"px-3 py-2.5 text-[var(--dg-text-secondary)] font-mono text-xs",children:t.status==="running"?e.jsxs("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:475:27",className:"flex items-center gap-1 text-blue-400",children:[e.jsx($,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:476:29",className:"w-3 h-3 animate-spin"}),"执行中..."]}):Xe(t.duration)}),e.jsx("td",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:480:23",className:"px-3 py-2.5 text-[var(--dg-text-muted)] text-xs hidden md:table-cell",children:qe(t.created_at)}),e.jsx("td",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:483:23",className:"px-3 py-2.5 text-right",onClick:l=>l.stopPropagation(),children:e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:484:25",className:"flex justify-end gap-1",children:[e.jsx(E,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:485:27",variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>P(t),children:"日志"}),e.jsxs(E,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:489:27",variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>{oe({id:t.id,buildNumber:t.build_number}),J(!0)},children:[e.jsx(H,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:491:29",className:"w-3.5 h-3.5 mr-1"}),"浏览"]}),t.status==="running"&&e.jsx(E,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:494:29",variant:"ghost",size:"icon",className:"h-7 w-7 text-red-500",onClick:()=>re(t.id),children:e.jsx(Ue,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:496:31",className:"w-3.5 h-3.5"})})]})})]},t.id)})})]})}),a&&e.jsxs(Fe,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:511:11",className:"flex-1 flex flex-col min-h-0 border-[var(--dg-border)] bg-[var(--dg-bg-secondary)]",children:[e.jsxs(ke,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:512:13",className:"py-3 px-4 flex flex-row items-center justify-between border-b border-[var(--dg-border)]",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:513:15",className:"flex items-center gap-3",children:[e.jsxs(Se,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:514:17",className:"text-sm font-mono",children:[o?.name||`#${s}`," #",a.build_number]}),a.status==="running"&&e.jsxs(A,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:518:19",className:"bg-blue-500/20 text-blue-400 border-blue-500/30 text-xs",children:[e.jsx($,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:519:21",className:"w-3 h-3 animate-spin mr-1"}),"实时"]}),i&&e.jsx(A,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:523:19",className:"text-xs border-[var(--dg-border)]",variant:"outline",children:j.find(t=>t.key===i)?.label||i})]}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:528:15",className:"flex items-center gap-2 text-xs text-[var(--dg-text-muted)]",children:[e.jsxs("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:529:17",children:["触发: ",K(a)," (",a.triggered_by||"admin",")"]}),e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:530:17",className:"opacity-40",children:"|"}),e.jsxs("span",{"code-path
Line truncated
|
||||
@@ -0,0 +1,3 @@
|
||||
import{r as n,j as e,D as me,a as he,a0 as ue,c as ge,d as ye,X as be,ak as fe,o as ee,h as C,$ as De,k as je,B as E,Q as Ne,v as ve,al as we,am as Re,L as $,a6 as Pe,C as te,U as ke,a3 as Be}from"./index-Dmami9WE.js";import{B as A}from"./badge-3UzCvU7L.js";import{C as Fe,b as Se,c as Ce,a as $e}from"./card-CIfC-8Rh.js";import{t as S}from"./index-BuEnLCjT.js";import{F as H}from"./folder-open-CjMh_m_2.js";import{M as ze,a as _e}from"./minimize-2-BHcbNmdK.js";import{A as Ee}from"./arrow-left-BIbk9wFC.js";import{F as Ae}from"./file-text-CebshSV-.js";import{D as Le}from"./download-Vuij9wGr.js";import{H as Z}from"./history-CbX6uocL.js";import{T as Ie}from"./trash-2-DWVnIU6o.js";import{R as Te}from"./refresh-cw-CTBERyFc.js";import{P as Oe}from"./play-0EwQQJX_.js";import{B as Ue}from"./box-88Ol5qY-.js";import{C as I}from"./circle-check-CVbTTFQ0.js";import{C as G}from"./circle-x-BBQeW1R3.js";import{S as Me}from"./square-NjJOra_E.js";function We(s){return s===0?"-":s<1024?s+" B":s<1024*1024?(s/1024).toFixed(1)+" KB":(s/(1024*1024)).toFixed(1)+" MB"}function He({open:s,onOpenChange:o,runId:u,buildNumber:r}){const[x,a]=n.useState(null),[P,k]=n.useState(!1),[N,L]=n.useState(""),[v,i]=n.useState(""),[w,z]=n.useState(!1),B=async c=>{if(u){k(!0),L("");try{const h=c?`?path=${encodeURIComponent(c)}`:"",g=await C.get(`/pipelines/runs/${u}/files${h}`);a(g),i(g?.current||"")}catch(h){L(h?.message||"加载失败"),a(null)}finally{k(!1)}}};n.useEffect(()=>{s&&u&&(i(""),B(""))},[s,u]);const b=async c=>{const h=De.getState().token||"",g=`${location.protocol}//${location.host}/api/v1/pipelines/runs/${u}/files/download?path=${encodeURIComponent(c.path)}&token=${encodeURIComponent(h)}`;window.open(g,"_blank")},R=v?v.split("/").filter(Boolean):[],T=[""].concat(R.map((c,h)=>"/"+R.slice(0,h+1).join("/")));return e.jsx(me,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:105:5",open:s,onOpenChange:o,children:e.jsxs(he,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:106:7",showCloseButton:!1,className:ue("bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] p-0 gap-0","!duration-0 !transition-none",w?"!max-w-none !w-screen !h-screen !rounded-none":""),style:w?{maxWidth:"100vw",width:"100vw",height:"100vh"}:{maxWidth:"700px",width:"85vw"},children:[e.jsxs(ge,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:117:9",className:"sr-only",children:["文件浏览器 #",r]}),e.jsx(ye,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:118:9",className:"sr-only",children:"流水线构建目录文件浏览"}),e.jsxs("div",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:121:9",className:"flex items-center justify-between px-4 py-2.5 border-b border-[var(--dg-border)] shrink-0",children:[e.jsxs("div",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:122:11",className:"flex items-center gap-2 min-w-0",children:[e.jsx(H,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:123:13",className:"h-4 w-4 text-[var(--dg-text-secondary)] shrink-0"}),e.jsxs("span",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:124:13",className:"text-[var(--dg-text-primary)] font-medium text-sm",children:["#",r," 工作区文件"]})]}),e.jsxs("div",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:128:11",className:"flex items-center gap-1",children:[e.jsx("button",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:129:13",onClick:()=>z(!w),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]",children:w?e.jsx(ze,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:133:29",className:"h-4 w-4"}):e.jsx(_e,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:133:65",className:"h-4 w-4"})}),e.jsx("button",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:135:13",onClick:()=>o(!1),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]",children:e.jsx(be,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:139:15",className:"h-4 w-4"})})]})]}),e.jsx("div",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:145:9",className:"flex items-center gap-0.5 px-4 py-2 text-xs border-b border-[var(--dg-border)] bg-[var(--dg-bg-primary)] overflow-x-auto shrink-0",children:T.map((c,h)=>e.jsx("span",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:147:13",className:"flex items-center gap-0.5",children:h===0?e.jsx("button",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:149:17",onClick:()=>B(""),className:"text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)] p-0.5",children:e.jsx(fe,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:153:19",className:"h-3.5 w-3.5"})}):e.jsxs(e.Fragment,{children:[e.jsx(ee,{"code-path":"src/components/deploy/FileBrowserDialog.tsx:157:19",className:"h-3 w-3 text-[var(--dg-text-muted)] shrink-0"}),e.jsx("button",{"code-path":"src/components/deploy/FileBrowserDialog.tsx:158:19",onClick:()=>B(c),className:"text-[var(--dg-text-secondary)] hover:text-[var(Line truncated
|
||||
${y?"ring-1 ring-offset-0 scale-[1.02]":"hover:brightness-110"}`,style:{backgroundColor:U,borderColor:M,color:D,borderRadius:xe},children:[de,e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:393:17",children:t.label})]}),!Y&&e.jsx("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:396:17",className:"flex items-center justify-center w-5 h-5 -mx-px z-10",children:e.jsx(ee,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:397:19",className:"h-3.5 w-3.5",style:{color:D+"99"}})})]},t.key)}),a&&e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:404:11",className:"ml-auto text-[10px] text-[var(--dg-text-secondary)] opacity-40 shrink-0 pl-3 whitespace-nowrap",children:i?j.find(t=>t.key===i)?.label:"全阶段"})]}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:411:7",className:"flex-1 flex flex-col min-h-0",children:[e.jsx("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:413:9",className:"rounded-md border border-[var(--dg-border)] overflow-hidden mb-4",children:L&&r.length===0?e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:415:13",className:"text-center py-12",children:[e.jsx($,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:416:15",className:"w-6 h-6 animate-spin mx-auto mb-2 text-[var(--dg-text-muted)]"}),"加载中..."]}):r.length===0?e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:420:13",className:"text-center py-12 border border-dashed border-[var(--dg-border)] rounded-lg m-4",children:[e.jsx(Z,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:421:15",className:"w-10 h-10 mx-auto mb-3 text-[var(--dg-text-muted)]"}),e.jsx("p",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:422:15",className:"text-[var(--dg-text-secondary)]",children:'暂无执行记录,点击"立即执行"触发构建'})]}):e.jsxs("table",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:425:13",className:"w-full text-sm",children:[e.jsx("thead",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:426:15",className:"bg-[var(--dg-bg-tertiary)] border-b border-[var(--dg-border)]",children:e.jsxs("tr",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:427:17",children:[e.jsx("th",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:428:19",className:"px-2 py-2.5 w-10",children:e.jsx("input",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:429:21",type:"checkbox",checked:b.size===r.length&&r.length>0,onChange:pe,className:"rounded"})}),e.jsx("th",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:432:19",className:"px-3 py-2.5 text-left font-medium text-[var(--dg-text-secondary)] w-16",children:"构建"}),e.jsx("th",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:433:19",className:"px-3 py-2.5 text-left font-medium text-[var(--dg-text-secondary)] w-20",children:"状态"}),e.jsx("th",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:434:19",className:"px-3 py-2.5 text-left font-medium text-[var(--dg-text-secondary)]",children:"触发方式"}),e.jsx("th",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:435:19",className:"px-3 py-2.5 text-left font-medium text-[var(--dg-text-secondary)]",children:"用户"}),e.jsx("th",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:436:19",className:"px-3 py-2.5 text-left font-medium text-[var(--dg-text-secondary)]",children:"耗时"}),e.jsx("th",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:437:19",className:"px-3 py-2.5 text-left font-medium text-[var(--dg-text-secondary)] hidden md:table-cell",children:"时间"}),e.jsx("th",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:438:19",className:"px-3 py-2.5 text-right font-medium text-[var(--dg-text-secondary)] w-32",children:"操作"})]})}),e.jsx("tbody",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:441:15",children:r.map(t=>{const p=Je[t.status]||te;return e.jsxs("tr",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:445:21",className:`border-b border-[var(--dg-border)] cursor-pointer transition-colors
|
||||
${a?.id===t.id?"bg-[var(--dg-blue)]/10":"hover:bg-[var(--dg-bg-tertiary)]/50"}`,onClick:()=>{P(t)},children:[e.jsx("td",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:449:23",className:"px-2 py-2.5",onClick:l=>l.stopPropagation(),children:e.jsx("input",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:450:25",type:"checkbox",checked:b.has(t.id),onChange:()=>ie(t.id),className:"rounded"})}),e.jsxs("td",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:453:23",className:"px-3 py-2.5 font-mono font-semibold text-[var(--dg-text-primary)]",children:["#",t.build_number]}),e.jsx("td",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:456:23",className:"px-3 py-2.5",children:e.jsxs(A,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:457:25",className:`text-xs ${Ge[t.status]||""} flex items-center gap-1 w-fit`,children:[e.jsx(p,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:458:27",className:`w-3 h-3 ${t.status==="running"?"animate-spin":""}`}),t.status==="success"?"成功":t.status==="failed"?"失败":t.status==="running"?"执行中":t.status==="cancelled"?"已取消":"待执行"]})}),e.jsx("td",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:466:23",className:"px-3 py-2.5",children:e.jsx(A,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:467:25",variant:"outline",className:"text-xs",children:K(t)})}),e.jsxs("td",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:469:23",className:"px-3 py-2.5 text-[var(--dg-text-secondary)] flex items-center gap-1",children:[e.jsx(ke,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:470:25",className:"w-3 h-3"}),t.triggered_by||"admin"]}),e.jsx("td",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:473:23",className:"px-3 py-2.5 text-[var(--dg-text-secondary)] font-mono text-xs",children:t.status==="running"?e.jsxs("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:475:27",className:"flex items-center gap-1 text-blue-400",children:[e.jsx($,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:476:29",className:"w-3 h-3 animate-spin"}),"执行中..."]}):Xe(t.duration)}),e.jsx("td",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:480:23",className:"px-3 py-2.5 text-[var(--dg-text-muted)] text-xs hidden md:table-cell",children:qe(t.created_at)}),e.jsx("td",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:483:23",className:"px-3 py-2.5 text-right",onClick:l=>l.stopPropagation(),children:e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:484:25",className:"flex justify-end gap-1",children:[e.jsx(E,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:485:27",variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>P(t),children:"日志"}),e.jsxs(E,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:489:27",variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>{oe({id:t.id,buildNumber:t.build_number}),J(!0)},children:[e.jsx(H,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:491:29",className:"w-3.5 h-3.5 mr-1"}),"浏览"]}),t.status==="running"&&e.jsx(E,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:494:29",variant:"ghost",size:"icon",className:"h-7 w-7 text-red-500",onClick:()=>re(t.id),children:e.jsx(Me,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:496:31",className:"w-3.5 h-3.5"})})]})})]},t.id)})})]})}),a&&e.jsxs(Fe,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:511:11",className:"flex-1 flex flex-col min-h-0 border-[var(--dg-border)] bg-[var(--dg-bg-secondary)]",children:[e.jsxs(Se,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:512:13",className:"py-3 px-4 flex flex-row items-center justify-between border-b border-[var(--dg-border)]",children:[e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:513:15",className:"flex items-center gap-3",children:[e.jsxs(Ce,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:514:17",className:"text-sm font-mono",children:[o?.name||`#${s}`," #",a.build_number]}),a.status==="running"&&e.jsxs(A,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:518:19",className:"bg-blue-500/20 text-blue-400 border-blue-500/30 text-xs",children:[e.jsx($,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:519:21",className:"w-3 h-3 animate-spin mr-1"}),"实时"]}),i&&e.jsx(A,{"code-path":"src/components/deploy/PipelineRunDetail.tsx:523:19",className:"text-xs border-[var(--dg-border)]",variant:"outline",children:j.find(t=>t.key===i)?.label||i})]}),e.jsxs("div",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:528:15",className:"flex items-center gap-2 text-xs text-[var(--dg-text-muted)]",children:[e.jsxs("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:529:17",children:["触发: ",K(a)," (",a.triggered_by||"admin",")"]}),e.jsx("span",{"code-path":"src/components/deploy/PipelineRunDetail.tsx:530:17",className:"opacity-40",children:"|"}),e.jsxs("span",{"code-path
Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{r as t,j as e,B as d,L as k,g as L,D as E,a as I,b as T,c as B,d as O,e as V}from"./index-Dmami9WE.js";import{I as m}from"./input-NsU9nXZF.js";import{L as r}from"./label-Ap_-SPYI.js";import{B as j}from"./badge-3UzCvU7L.js";import{S as P,a as M,b as v,c as b,d as o}from"./select-DUbxjT0z.js";import{p as x}from"./cloud-Dq4kl-JO.js";import{S as K}from"./search-Dd-PeBfg.js";import{P as U}from"./plus-O65gX7Qz.js";import{E as W}from"./external-link-2hCYo_Ng.js";import{P as Y}from"./pencil-BYahlvYT.js";import{T as Z}from"./trash-2-DWVnIU6o.js";import{C as $}from"./circle-check-CVbTTFQ0.js";import{C as ee}from"./circle-x-BBQeW1R3.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";const ae={public:"公有云",private:"私有云",hybrid:"混合云"},se={public:"text-blue-400",private:"text-purple-400",hybrid:"text-cyan-400"};function je(){const[F,N]=t.useState([]),[Q,y]=t.useState(!0),[h,A]=t.useState(""),[u,H]=t.useState("all"),[R,l]=t.useState(!1),[n,w]=t.useState(null),[C,S]=t.useState(!1),[s,c]=t.useState({name:"",code:"",type:"public",status:"active",website:"",description:""}),p=t.useCallback(async()=>{y(!0);try{const f=(await x.list())?.list||[];N(f)}catch{N([])}finally{y(!1)}},[]);t.useEffect(()=>{p()},[p]);const D=F.filter(a=>{const f=a.name?.toLowerCase().includes(h.toLowerCase())||a.code?.toLowerCase().includes(h.toLowerCase()),J=u==="all"||a.type===u;return f&&J}),X=()=>{w(null),c({name:"",code:"",type:"public",status:"active",website:"",description:""}),l(!0)},_=a=>{w(a),c({name:a.name||"",code:a.code||"",type:a.type||"public",status:a.status||"active",website:a.website||"",description:a.description||""}),l(!0)},q=async()=>{if(!(!s.name.trim()||!s.code.trim())){S(!0);try{n?await x.update(n.id,s):await x.create(s),l(!1),p()}catch{}finally{S(!1)}}},[g,i]=t.useState(null),z=a=>i(a),G=async()=>{g!==null&&(await x.delete(g),i(null),p())};return e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:124:5",className:"p-6 space-y-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:126:7",className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:127:9",className:"flex items-center gap-3 flex-1",children:[e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:128:11",className:"relative w-72",children:[e.jsx(K,{"code-path":"src/components/cloud/PlatformManager.tsx:129:13",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-500"}),e.jsx(m,{"code-path":"src/components/cloud/PlatformManager.tsx:130:13",placeholder:"搜索平台名称或编码...",value:h,onChange:a=>A(a.target.value),className:"pl-9 h-9 bg-slate-800/50 border-slate-700"})]}),e.jsxs(P,{"code-path":"src/components/cloud/PlatformManager.tsx:137:11",value:u,onValueChange:H,children:[e.jsx(M,{"code-path":"src/components/cloud/PlatformManager.tsx:138:13",className:"w-32 h-9 bg-slate-800/50 border-slate-700",children:e.jsx(v,{"code-path":"src/components/cloud/PlatformManager.tsx:139:15"})}),e.jsxs(b,{"code-path":"src/components/cloud/PlatformManager.tsx:141:13",children:[e.jsx(o,{"code-path":"src/components/cloud/PlatformManager.tsx:142:15",value:"all",children:"全部类型"}),e.jsx(o,{"code-path":"src/components/cloud/PlatformManager.tsx:143:15",value:"public",children:"公有云"}),e.jsx(o,{"code-path":"src/components/cloud/PlatformManager.tsx:144:15",value:"private",children:"私有云"}),e.jsx(o,{"code-path":"src/components/cloud/PlatformManager.tsx:145:15",value:"hybrid",children:"混合云"})]})]})]}),e.jsxs(d,{"code-path":"src/components/cloud/PlatformManager.tsx:149:9",onClick:X,className:"gap-2",children:[e.jsx(U,{"code-path":"src/components/cloud/PlatformManager.tsx:150:11",className:"h-4 w-4"}),"添加平台"]})]}),Q?e.jsx("div",{"code-path":"src/components/cloud/PlatformManager.tsx:157:9",className:"flex justify-center py-20",children:e.jsx(k,{"code-path":"src/components/cloud/PlatformManager.tsx:158:11",className:"h-6 w-6 animate-spin text-slate-500"})}):D.length===0?e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:161:9",className:"text-center py-20 text-slate-500",children:[e.jsx(L,{"code-path":"src/components/cloud/PlatformManager.tsx:162:11",className:"h-12 w-12 mx-auto mb-3 opacity-40"}),e.jsx("p",{"code-path":"src/components/cloud/PlatformManager.tsx:163:11",children:"暂无云平台数据"})]}):e.jsx("div",{"code-path":"src/components/cloud/PlatformManager.tsx:166:9",className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:D.map(a=>e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:168:13",className:"bg-slate-800/30 rounded-lg p-4 hover:bg-slate-800/50 transition-colors group",children:[e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:172:15",className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:173:17",className:"flex items-ceLine truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{r as t,j as e,S as K,I as d,B as m,L as k,C as L,D as E,b as I,c as T,d as B,e as O,f as V}from"./index-DfyorCky.js";import{L as r}from"./label-BK0h2apY.js";import{B as j}from"./badge-xNW8x0G1.js";import{S as P,a as M,b as v,c as b,d as o}from"./select-D5qUzdAs.js";import{p as x}from"./cloud-Dzoer-2i.js";import{P as U}from"./plus-CUG-9kpu.js";import{E as W}from"./external-link-CzIpMNu1.js";import{P as Y}from"./pencil-BqUotcjf.js";import{T as Z}from"./trash-2-Dx32pOzT.js";import{C as $}from"./circle-check-DWcXrx2k.js";import{C as ee}from"./circle-x-DK79Dhg2.js";import"./index-CWVNW_qu.js";const ae={public:"公有云",private:"私有云",hybrid:"混合云"},se={public:"text-blue-400",private:"text-purple-400",hybrid:"text-cyan-400"};function ue(){const[F,N]=t.useState([]),[Q,y]=t.useState(!0),[h,A]=t.useState(""),[u,H]=t.useState("all"),[R,l]=t.useState(!1),[n,C]=t.useState(null),[w,S]=t.useState(!1),[s,c]=t.useState({name:"",code:"",type:"public",status:"active",website:"",description:""}),p=t.useCallback(async()=>{y(!0);try{const f=(await x.list())?.list||[];N(f)}catch{N([])}finally{y(!1)}},[]);t.useEffect(()=>{p()},[p]);const D=F.filter(a=>{const f=a.name?.toLowerCase().includes(h.toLowerCase())||a.code?.toLowerCase().includes(h.toLowerCase()),J=u==="all"||a.type===u;return f&&J}),X=()=>{C(null),c({name:"",code:"",type:"public",status:"active",website:"",description:""}),l(!0)},_=a=>{C(a),c({name:a.name||"",code:a.code||"",type:a.type||"public",status:a.status||"active",website:a.website||"",description:a.description||""}),l(!0)},q=async()=>{if(!(!s.name.trim()||!s.code.trim())){S(!0);try{n?await x.update(n.id,s):await x.create(s),l(!1),p()}catch{}finally{S(!1)}}},[g,i]=t.useState(null),z=a=>i(a),G=async()=>{g!==null&&(await x.delete(g),i(null),p())};return e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:124:5",className:"p-6 space-y-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:126:7",className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:127:9",className:"flex items-center gap-3 flex-1",children:[e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:128:11",className:"relative w-72",children:[e.jsx(K,{"code-path":"src/components/cloud/PlatformManager.tsx:129:13",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-500"}),e.jsx(d,{"code-path":"src/components/cloud/PlatformManager.tsx:130:13",placeholder:"搜索平台名称或编码...",value:h,onChange:a=>A(a.target.value),className:"pl-9 h-9 bg-slate-800/50 border-slate-700"})]}),e.jsxs(P,{"code-path":"src/components/cloud/PlatformManager.tsx:137:11",value:u,onValueChange:H,children:[e.jsx(M,{"code-path":"src/components/cloud/PlatformManager.tsx:138:13",className:"w-32 h-9 bg-slate-800/50 border-slate-700",children:e.jsx(v,{"code-path":"src/components/cloud/PlatformManager.tsx:139:15"})}),e.jsxs(b,{"code-path":"src/components/cloud/PlatformManager.tsx:141:13",children:[e.jsx(o,{"code-path":"src/components/cloud/PlatformManager.tsx:142:15",value:"all",children:"全部类型"}),e.jsx(o,{"code-path":"src/components/cloud/PlatformManager.tsx:143:15",value:"public",children:"公有云"}),e.jsx(o,{"code-path":"src/components/cloud/PlatformManager.tsx:144:15",value:"private",children:"私有云"}),e.jsx(o,{"code-path":"src/components/cloud/PlatformManager.tsx:145:15",value:"hybrid",children:"混合云"})]})]})]}),e.jsxs(m,{"code-path":"src/components/cloud/PlatformManager.tsx:149:9",onClick:X,className:"gap-2",children:[e.jsx(U,{"code-path":"src/components/cloud/PlatformManager.tsx:150:11",className:"h-4 w-4"}),"添加平台"]})]}),Q?e.jsx("div",{"code-path":"src/components/cloud/PlatformManager.tsx:157:9",className:"flex justify-center py-20",children:e.jsx(k,{"code-path":"src/components/cloud/PlatformManager.tsx:158:11",className:"h-6 w-6 animate-spin text-slate-500"})}):D.length===0?e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:161:9",className:"text-center py-20 text-slate-500",children:[e.jsx(L,{"code-path":"src/components/cloud/PlatformManager.tsx:162:11",className:"h-12 w-12 mx-auto mb-3 opacity-40"}),e.jsx("p",{"code-path":"src/components/cloud/PlatformManager.tsx:163:11",children:"暂无云平台数据"})]}):e.jsx("div",{"code-path":"src/components/cloud/PlatformManager.tsx:166:9",className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:D.map(a=>e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:168:13",className:"bg-slate-800/30 rounded-lg p-4 hover:bg-slate-800/50 transition-colors group",children:[e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:172:15",className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/PlatformManager.tsx:173:17",className:"flex items-center gap-3",children:[e.jsx("div",{"code-path":"src/components/cloud/PlatformManager.tsx:174:19",claLine truncated
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import{r as H,j as y,B as le,a9 as gl,L as St,a5 as Zs,D as Iu,b as Wu,X as xl,d as Fu,e as Vu,H as Hu,n as zu}from"./index-DfyorCky.js";import{u as Ah}from"./use-toast-CrSOP4cJ.js";import{k as wt}from"./kubernetes-J8O09fK7.js";import{C as bl}from"./copy-DXW4LnkN.js";import{S as xs}from"./sparkles-Bld4NX5y.js";import{S as yl}from"./save-DoGGjfwC.js";import{S as kl,a as wl,b as vl,c as Sl,d as Ol}from"./select-D5qUzdAs.js";import{x as Qu,a as $u}from"./xterm-DSqgeKvr.js";import{B as ju}from"./box-TTGA1p57.js";import{R as qu}from"./rotate-cw-5qcj_h_q.js";import{M as Xu,a as Uu}from"./minimize-2-CiCQYRfn.js";import{B as Yu}from"./badge-xNW8x0G1.js";import{H as _u}from"./hard-drive-BbPmnARR.js";import{A as Ku}from"./arrow-left-BDgGyrD0.js";import{U as Gu}from"./upload-Ba6rlaGS.js";import{R as Ju}from"./refresh-cw-DUB_tAG-.js";import{a as Zu,F as ed}from"./folder-DoMwqvzv.js";import{D as td}from"./download-DoZfYs2h.js";function Tr(){return Tr=Object.assign?Object.assign.bind():function(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(s[i]=t[i])}return s},Tr.apply(null,arguments)}function id(s,e){if(s==null)return{};var t={};for(var i in s)if({}.hasOwnProperty.call(s,i)){if(e.indexOf(i)!==-1)continue;t[i]=s[i]}return t}function bs(s){if(!s)return"";const e=s.replace(/\r\n/g,`
|
||||
import{r as H,j as y,B as le,K as gl,L as St,X as Zs,D as Iu,a as Wu,a0 as xl,c as Fu,d as Vu,E as Hu,o as zu}from"./index-Dmami9WE.js";import{u as Ah}from"./use-toast-jvSbBx20.js";import{k as wt}from"./kubernetes-D2-GnE0t.js";import{C as bl}from"./copy-CE_T92Lk.js";import{S as xs}from"./sparkles-rPZivnlW.js";import{S as yl}from"./save-YtnrpTd8.js";import{S as kl,a as wl,b as vl,c as Sl,d as Ol}from"./select-DUbxjT0z.js";import{x as Qu,a as $u}from"./xterm-DSqgeKvr.js";import{B as ju}from"./box-88Ol5qY-.js";import{R as qu}from"./rotate-cw-CKCO6IKE.js";import{M as Xu,a as Uu}from"./minimize-2-BHcbNmdK.js";import{B as Yu}from"./badge-3UzCvU7L.js";import{H as _u}from"./hard-drive-DmC04Y5r.js";import{A as Ku}from"./arrow-left-BIbk9wFC.js";import{U as Gu}from"./upload-CRLg7Pbj.js";import{R as Ju}from"./refresh-cw-CTBERyFc.js";import{a as Zu,F as ed}from"./folder-B5RGB3GG.js";import{D as td}from"./download-Vuij9wGr.js";function Tr(){return Tr=Object.assign?Object.assign.bind():function(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(s[i]=t[i])}return s},Tr.apply(null,arguments)}function id(s,e){if(s==null)return{};var t={};for(var i in s)if({}.hasOwnProperty.call(s,i)){if(e.indexOf(i)!==-1)continue;t[i]=s[i]}return t}function bs(s){if(!s)return"";const e=s.replace(/\r\n/g,`
|
||||
`).split(`
|
||||
`),t=[];let i=0;const n=new Set(["uid","resourceVersion","creationTimestamp","generation","selfLink","clusterName","managedFields","generateName"]),r=new Set(["managedFields","ownerReferences"]),o={dnsPolicy:["ClusterFirst"],restartPolicy:["Always"],schedulerName:["default-scheduler"],terminationGracePeriodSeconds:["30"],serviceAccountName:["default"],enableServiceLinks:["true"],progressDeadlineSeconds:["600"],revisionHistoryLimit:["10"]},l={imagePullPolicy:["Always","IfNotPresent"],terminationMessagePath:["/dev/termination-log"],terminationMessagePolicy:["File"]},a=new Set(["kubectl.kubernetes.io/last-applied-configuration","deployment.kubernetes.io/revision","kubectl.kubernetes.io/restartedAt","control-plane.alpha.kubernetes.io/leader","autoscaling.alpha.kubernetes.io/conditions"]),h=["kube-api-access-","default-token-","kube-"];let c=!1,f=!1,u=!1,d=!1,p=!1,m=!1,g=!1,x=!1,k=0;function w(N){return N.length-N.trimStart().length}function T(N){const P=N.trimStart().match(/^([a-zA-Z_][a-zA-Z0-9_./-]*)\s*:/);return P?P[1]:null}function S(N){const P=N.trim().split(":").slice(1).join(":").trim();return P!==""&&!/^[>|]/.test(P)}function A(N){for(i++;i<e.length;){const P=e[i],D=P.trimStart();if(D===""||D.startsWith("#")){i++;continue}if(w(P)<=N)break;i++}}function O(N){const P=T(N);return P?h.some(D=>P.startsWith(D)):!1}for(;i<e.length;){const N=e[i],P=N.trimStart(),D=w(N),M=T(N);if(P===""||P.startsWith("#")){t.push(N),i++;continue}if(D===0&&M==="status"){A(0);continue}if(D===0&&M==="metadata"){c=!0,t.push(N),i++;continue}if(D===0&&M!=="metadata"&&(c=!1,f=!1),D===0&&M==="spec"){u=!0,t.push(N),i++;continue}if(D===0&&M!=="spec"&&(u=!1,d=!1,p=!1,m=!1,x=!1),c){if(D===2&&M==="annotations"){f=!0,t.push(N),i++;continue}if(D<=2&&M!=="annotations"&&(f=!1),D>=2&&D<=4&&P.startsWith("pod-template-hash")&&P.includes(":")){i++;continue}if(D===2&&M&&n.has(M)){S(N)?i++:A(2);continue}if(D===2&&M&&r.has(M)){A(2);continue}if(f&&D>2&&M&&a.has(M)){if(S(N))i++;else{const R=P.split(":").slice(1).join(":").trim();/^[>|]/.test(R)?A(D):i++}continue}}if(u){if(D===2&&M==="template"){t.push(N),i++;continue}if(D===2&&M&&o[M]){const F=P.split(":").slice(1).join(":").trim();if(o[M].includes(F)){i++;continue}}if(D===2&&M==="nodeName"){i++;continue}if(D===2&&M==="spec"){d=!0,k=D,t.push(N),i++;continue}}if(d&&D>k){if(M==="containers"){p=!0,m=!1,t.push(N),i++;continue}if(M==="initContainers"){m=!0,p=!1,t.push(N),i++;continue}if(M==="volumes"){x=!0,t.push(N),i++;continue}if(M&&o[M]){const F=P.split(":").slice(1).join(":").trim();if(o[M].includes(F)){i++;continue}}if(M==="nodeName"){i++;continue}if(M==="serviceAccount"&&P.endsWith(":")){S(N)?i++:A(D);continue}}if((p||m)&&D>=6){if(M&&l[M]){const F=P.split(":").slice(1).join(":").trim();if(l[M].includes(F)){i++;continue}}if(M==="volumeMounts"&&(g=!0),g&&P.startsWith("- name:")){let F=[N],R=i+1,C=!1;for(;R<e.length;){const B=e[R].trimStart();if(B===""||B.startsWith("#")){F.push(e[R]),R++;continue}if(w(e[R])<=D)break;sd(B)&&(C=!0),F.push(e[R]),R++}if(C){i=R;continue}g=!1}}if(x&&D>=4&&P.startsWith("- name:")&&O(P)){const F=D;for(i++;i<e.length;){const R=e[i],C=R.trimStart();if(C===""||C.startsWith("#")){i++;continue}if(w(R)<=F)break;i++}continue}if(P===""&&t.length>0&&t[t.length-1].trim()===""){i++;continue}t.push(N),i++}return t.join(`
|
||||
`).replace(/\n{3,}/g,`
|
||||
@@ -0,0 +1 @@
|
||||
import{k as H,m as U,r as c,j as e,n as N,o as f,A as V,B as W,p as F}from"./index-Dmami9WE.js";import{C as i,a as x}from"./card-CIfC-8Rh.js";import{B as L}from"./badge-3UzCvU7L.js";import{S as v,a as C,b as y,c as S,d as P}from"./select-DUbxjT0z.js";import{T as z,a as D,b as u,c as d,d as G,e as n}from"./table-CG4mjNfb.js";import{k as b}from"./kubernetes-D2-GnE0t.js";import{R as K}from"./refresh-cw-CTBERyFc.js";import{H as q}from"./hard-drive-DmC04Y5r.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";function ce(){const{clusterCode:w}=H(),g=U(),[m,M]=c.useState(!1),[p,k]=c.useState([]),[A,T]=c.useState([]),[$,E]=c.useState([]),[l,B]=c.useState("all"),[a,j]=c.useState(w||"");c.useEffect(()=>{b.getClusters().then(s=>{const t=s?.list||[];if(T(t),!a&&t.length>0){const r=t[0].code||String(t[0].id);j(r),g(`/kubernetes/${r}/metrics/pods`,{replace:!0})}}).catch(()=>{})},[]),c.useEffect(()=>{a&&b.getNamespaces(a).then(s=>{E(Array.isArray(s)?s:s?.list||s?.data||[])}).catch(()=>{})},[a]);const h=c.useCallback(async()=>{if(a){M(!0);try{const s=l==="all"?void 0:l,t=await b.getPodMetrics(a,s);k(Array.isArray(t)?t:t?.list||[])}catch{k([])}finally{M(!1)}}},[a,l]);c.useEffect(()=>{h()},[h]);const o=c.useMemo(()=>p.flatMap(s=>(s.containers||[]).map(t=>({pod:s.name,namespace:s.namespace,container:t.name,cpu:t.cpu||"0m",memory:t.memory||"0Mi"}))),[p]),I=c.useMemo(()=>o.reduce((s,t)=>s+(parseInt(t.cpu)||0),0),[o]),R=c.useMemo(()=>{let s=0;return o.forEach(t=>{const r=t.memory;r.endsWith("Mi")?s+=parseInt(r):r.endsWith("Ki")?s+=parseInt(r)/1024:r.endsWith("Gi")&&(s+=parseInt(r)*1024)}),s},[o]);return e.jsxs("div",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:81:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:82:7",className:"flex items-center gap-2 text-sm text-slate-500",children:[e.jsx(N,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:83:9",to:"/kubernetes",className:"hover:text-slate-300",children:"集群"}),a&&e.jsxs(e.Fragment,{children:[e.jsx(f,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:84:29",className:"h-3 w-3"}),e.jsx(N,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:84:65",to:`/kubernetes/${a}`,className:"hover:text-slate-300",children:a})]}),e.jsx(f,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:85:9",className:"h-3 w-3"}),e.jsx("span",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:85:45",className:"text-slate-300",children:"Pod 资源用量"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:88:7",className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("h2",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:89:9",className:"text-lg font-semibold text-slate-100 flex items-center gap-2",children:[e.jsx(V,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:89:86",className:"h-5 w-5 text-blue-400"}),"Pod 资源用量"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:90:9",className:"flex items-center gap-2",children:[e.jsxs(v,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:91:11",value:a,onValueChange:s=>{j(s),g(`/kubernetes/${s}/metrics/pods`)},children:[e.jsx(C,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:92:13",className:"w-44 h-8 text-xs bg-slate-800 border-slate-700",children:e.jsx(y,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:92:87"})}),e.jsx(S,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:93:13",className:"bg-slate-800 border-slate-700",children:A.map(s=>e.jsx(P,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:94:42",value:s.code||String(s.id),className:"text-xs",children:s.name||s.code},s.id))})]}),e.jsxs(v,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:97:11",value:l,onValueChange:B,children:[e.jsx(C,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:98:13",className:"w-36 h-8 text-xs bg-slate-800 border-slate-700",children:e.jsx(y,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:98:87",placeholder:"所有命名空间"})}),e.jsxs(S,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:99:13",className:"bg-slate-800 border-slate-700",children:[e.jsx(P,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:100:15",value:"all",className:"text-xs",children:"所有命名空间"}),$.map(s=>e.jsx(P,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:101:36",value:s,className:"text-xs",children:s},s))]})]}),e.jsxs(W,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:104:11",variant:"outline",size:"sm",className:"h-8 border-slate-700 text-slate-300 text-xs",onClick:h,disabled:m,children:[e.jsx(K,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:105:13",className:`h-3 w-3 mr-1 ${m?"animate-spin":""}`}),"刷新"]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:111:7",className:"grid grid-cols-3 gap-3",children:[e.jsx(i,{"code-path"Line truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{i as H,k as U,r as c,j as e,m as N,n as f,A as V,B as W,o as F}from"./index-DfyorCky.js";import{C as i,a as x}from"./card-C55cvSHg.js";import{B as L}from"./badge-xNW8x0G1.js";import{S as v,a as C,b as y,c as S,d as P}from"./select-D5qUzdAs.js";import{T as z,a as D,b as u,c as d,d as G,e as n}from"./table-5sHV4Akp.js";import{k as b}from"./kubernetes-J8O09fK7.js";import{R as K}from"./refresh-cw-DUB_tAG-.js";import{H as q}from"./hard-drive-BbPmnARR.js";import"./index-CWVNW_qu.js";function te(){const{clusterCode:w}=H(),g=U(),[m,M]=c.useState(!1),[p,k]=c.useState([]),[A,T]=c.useState([]),[$,E]=c.useState([]),[l,B]=c.useState("all"),[a,j]=c.useState(w||"");c.useEffect(()=>{b.getClusters().then(s=>{const t=s?.list||[];if(T(t),!a&&t.length>0){const r=t[0].code||String(t[0].id);j(r),g(`/kubernetes/${r}/metrics/pods`,{replace:!0})}}).catch(()=>{})},[]),c.useEffect(()=>{a&&b.getNamespaces(a).then(s=>{E(Array.isArray(s)?s:s?.list||s?.data||[])}).catch(()=>{})},[a]);const h=c.useCallback(async()=>{if(a){M(!0);try{const s=l==="all"?void 0:l,t=await b.getPodMetrics(a,s);k(Array.isArray(t)?t:t?.list||[])}catch{k([])}finally{M(!1)}}},[a,l]);c.useEffect(()=>{h()},[h]);const o=c.useMemo(()=>p.flatMap(s=>(s.containers||[]).map(t=>({pod:s.name,namespace:s.namespace,container:t.name,cpu:t.cpu||"0m",memory:t.memory||"0Mi"}))),[p]),I=c.useMemo(()=>o.reduce((s,t)=>s+(parseInt(t.cpu)||0),0),[o]),R=c.useMemo(()=>{let s=0;return o.forEach(t=>{const r=t.memory;r.endsWith("Mi")?s+=parseInt(r):r.endsWith("Ki")?s+=parseInt(r)/1024:r.endsWith("Gi")&&(s+=parseInt(r)*1024)}),s},[o]);return e.jsxs("div",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:81:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:82:7",className:"flex items-center gap-2 text-sm text-slate-500",children:[e.jsx(N,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:83:9",to:"/kubernetes",className:"hover:text-slate-300",children:"集群"}),a&&e.jsxs(e.Fragment,{children:[e.jsx(f,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:84:29",className:"h-3 w-3"}),e.jsx(N,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:84:65",to:`/kubernetes/${a}`,className:"hover:text-slate-300",children:a})]}),e.jsx(f,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:85:9",className:"h-3 w-3"}),e.jsx("span",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:85:45",className:"text-slate-300",children:"Pod 资源用量"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:88:7",className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("h2",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:89:9",className:"text-lg font-semibold text-slate-100 flex items-center gap-2",children:[e.jsx(V,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:89:86",className:"h-5 w-5 text-blue-400"}),"Pod 资源用量"]}),e.jsxs("div",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:90:9",className:"flex items-center gap-2",children:[e.jsxs(v,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:91:11",value:a,onValueChange:s=>{j(s),g(`/kubernetes/${s}/metrics/pods`)},children:[e.jsx(C,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:92:13",className:"w-44 h-8 text-xs bg-slate-800 border-slate-700",children:e.jsx(y,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:92:87"})}),e.jsx(S,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:93:13",className:"bg-slate-800 border-slate-700",children:A.map(s=>e.jsx(P,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:94:42",value:s.code||String(s.id),className:"text-xs",children:s.name||s.code},s.id))})]}),e.jsxs(v,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:97:11",value:l,onValueChange:B,children:[e.jsx(C,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:98:13",className:"w-36 h-8 text-xs bg-slate-800 border-slate-700",children:e.jsx(y,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:98:87",placeholder:"所有命名空间"})}),e.jsxs(S,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:99:13",className:"bg-slate-800 border-slate-700",children:[e.jsx(P,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:100:15",value:"all",className:"text-xs",children:"所有命名空间"}),$.map(s=>e.jsx(P,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:101:36",value:s,className:"text-xs",children:s},s))]})]}),e.jsxs(W,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:104:11",variant:"outline",size:"sm",className:"h-8 border-slate-700 text-slate-300 text-xs",onClick:h,disabled:m,children:[e.jsx(K,{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:105:13",className:`h-3 w-3 mr-1 ${m?"animate-spin":""}`}),"刷新"]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/PodMetricsPage.tsx:111:7",className:"grid grid-cols-3 gap-3",children:[e.jsx(i,{"code-path":"src/components/kubernetes/PodMeLine truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{a as ee,r as t,j as e,S as se,I as u,B as j,L as O,M as ae,D as oe,b as te,c as ce,d as ne,e as re,f as le}from"./index-DfyorCky.js";import{L as i}from"./label-BK0h2apY.js";import{B as A}from"./badge-xNW8x0G1.js";import{C as V}from"./checkbox-CH0bpj6b.js";import{T as de,a as ie,b as H,c as r,d as pe,e as l}from"./table-5sHV4Akp.js";import{S as y,a as C,b as w,c as S,d as R}from"./select-D5qUzdAs.js";import{r as M}from"./server-CjDPBaTN.js";import{t as N}from"./index-a3ybMjbR.js";import{P as ge}from"./plus-CUG-9kpu.js";import{T as $}from"./trash-2-Dx32pOzT.js";import{C as xe}from"./circle-check-DWcXrx2k.js";import{C as he}from"./circle-x-DK79Dhg2.js";import{P as me}from"./pencil-BqUotcjf.js";import"./index-CWVNW_qu.js";const k={aws:"AWS",aliyun:"阿里云",tencent:"腾讯云",huawei:"华为云",azure:"Azure"},ue={aws:"text-orange-400",aliyun:"text-orange-400",tencent:"text-blue-400",huawei:"text-red-400",azure:"text-blue-400"};function Le(){const D=ee(),[T,L]=t.useState([]),[F,P]=t.useState(!0),[f,Q]=t.useState(""),[b,W]=t.useState("all"),[c,d]=t.useState([]),[X,p]=t.useState(!1),[g,I]=t.useState(null),[B,z]=t.useState(!1),[a,n]=t.useState({name:"",code:"",provider:"aliyun",location:"",status:"active",endpoint:""}),x=t.useCallback(async()=>{P(!0);try{const o=(await M.list())?.list||[];L(o)}catch{L([])}finally{P(!1)}},[]);t.useEffect(()=>{x()},[x]);const h=T.filter(s=>{const o=s.name?.toLowerCase().includes(f.toLowerCase())||s.code?.toLowerCase().includes(f.toLowerCase()),v=b==="all"||s.provider===b;return o&&v}),E=h.length>0&&h.every(s=>c.includes(s.id)),q=()=>{d(E?[]:h.map(s=>s.id))},G=s=>{d(o=>o.includes(s)?o.filter(v=>v!==s):[...o,s])},J=()=>{I(null),n({name:"",code:"",provider:"aliyun",location:"",status:"active",endpoint:""}),p(!0)},K=s=>{I(s),n({name:s.name||"",code:s.code||"",provider:s.provider||"aliyun",location:s.location||"",status:s.status||"active",endpoint:s.endpoint||""}),p(!0)},U=async()=>{if(!(!a.name.trim()||!a.code.trim())){z(!0);try{g?await M.update(g.id,a):await M.create(a),p(!1),x()}catch{}finally{z(!1)}}},Y=async s=>{const o=T.find(m=>m.id===s);if(await D({title:"删除区域",description:`确定删除「${o?.name||s}」吗?此操作不可撤销。`,confirmText:"删除",variant:"destructive"}))try{await M.delete(s),N.success("区域已删除"),d(m=>m.filter(_=>_!==s)),x()}catch(m){console.error("删除区域失败:",m),N.error("删除失败")}},Z=async()=>{if(!(c.length===0||!await D({title:"批量删除区域",description:`确定删除选中的 ${c.length} 个区域吗?此操作不可撤销。`,confirmText:"批量删除",variant:"destructive"})))try{await M.batchDelete(c),N.success(`已删除 ${c.length} 个区域`),d([]),x()}catch(o){console.error("批量删除失败:",o),N.error("批量删除失败")}};return e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:185:5",className:"p-6 space-y-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:187:7",className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:188:9",className:"flex items-center gap-3 flex-1",children:[e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:189:11",className:"relative w-72",children:[e.jsx(se,{"code-path":"src/components/cloud/RegionManager.tsx:190:13",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-500"}),e.jsx(u,{"code-path":"src/components/cloud/RegionManager.tsx:191:13",placeholder:"搜索区域名称或编码...",value:f,onChange:s=>Q(s.target.value),className:"pl-9 h-9 bg-slate-800/50 border-slate-700"})]}),e.jsxs(y,{"code-path":"src/components/cloud/RegionManager.tsx:198:11",value:b,onValueChange:W,children:[e.jsx(C,{"code-path":"src/components/cloud/RegionManager.tsx:199:13",className:"w-32 h-9 bg-slate-800/50 border-slate-700",children:e.jsx(w,{"code-path":"src/components/cloud/RegionManager.tsx:200:15"})}),e.jsxs(S,{"code-path":"src/components/cloud/RegionManager.tsx:202:13",children:[e.jsx(R,{"code-path":"src/components/cloud/RegionManager.tsx:203:15",value:"all",children:"全部云商"}),Object.entries(k).map(([s,o])=>e.jsx(R,{"code-path":"src/components/cloud/RegionManager.tsx:205:17",value:s,children:o},s))]})]})]}),e.jsxs(j,{"code-path":"src/components/cloud/RegionManager.tsx:210:9",onClick:J,className:"gap-2",children:[e.jsx(ge,{"code-path":"src/components/cloud/RegionManager.tsx:211:11",className:"h-4 w-4"}),"添加区域"]})]}),c.length>0&&e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:218:9",className:"flex items-center justify-between gap-4 px-4 py-2.5 rounded-lg bg-slate-800/50 border border-slate-700",children:[e.jsxs("span",{"code-path":"src/components/cloud/RegionManager.tsx:219:11",className:"text-sm text-slate-300",children:["已选择 ",e.jsx("span",{"code-path":"src/components/cloud/RegionManager.tsx:220:17",className:"font-semibold text-slate-100",children:c.length})," 个区域"]}),e.jsxs("div",{"code-paLine truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{f as ee,r as t,j as e,B as u,L as O,M as se,D as oe,a as ae,b as te,c as ce,d as ne,e as re}from"./index-Dmami9WE.js";import{I as j}from"./input-NsU9nXZF.js";import{L as i}from"./label-Ap_-SPYI.js";import{B as A}from"./badge-3UzCvU7L.js";import{C as V}from"./checkbox-DoAtRzQj.js";import{T as le,a as de,b as H,c as r,d as ie,e as l}from"./table-CG4mjNfb.js";import{S as y,a as C,b as w,c as S,d as R}from"./select-DUbxjT0z.js";import{r as M}from"./server-3HmnhxQB.js";import{t as N}from"./index-BuEnLCjT.js";import{S as pe}from"./search-Dd-PeBfg.js";import{P as ge}from"./plus-O65gX7Qz.js";import{T as $}from"./trash-2-DWVnIU6o.js";import{C as xe}from"./circle-check-CVbTTFQ0.js";import{C as he}from"./circle-x-BBQeW1R3.js";import{P as me}from"./pencil-BYahlvYT.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";const k={aws:"AWS",aliyun:"阿里云",tencent:"腾讯云",huawei:"华为云",azure:"Azure"},ue={aws:"text-orange-400",aliyun:"text-orange-400",tencent:"text-blue-400",huawei:"text-red-400",azure:"text-blue-400"};function Be(){const D=ee(),[T,L]=t.useState([]),[F,P]=t.useState(!0),[f,Q]=t.useState(""),[b,W]=t.useState("all"),[c,d]=t.useState([]),[X,p]=t.useState(!1),[g,I]=t.useState(null),[B,z]=t.useState(!1),[o,n]=t.useState({name:"",code:"",provider:"aliyun",location:"",status:"active",endpoint:""}),x=t.useCallback(async()=>{P(!0);try{const a=(await M.list())?.list||[];L(a)}catch{L([])}finally{P(!1)}},[]);t.useEffect(()=>{x()},[x]);const h=T.filter(s=>{const a=s.name?.toLowerCase().includes(f.toLowerCase())||s.code?.toLowerCase().includes(f.toLowerCase()),v=b==="all"||s.provider===b;return a&&v}),E=h.length>0&&h.every(s=>c.includes(s.id)),q=()=>{d(E?[]:h.map(s=>s.id))},G=s=>{d(a=>a.includes(s)?a.filter(v=>v!==s):[...a,s])},J=()=>{I(null),n({name:"",code:"",provider:"aliyun",location:"",status:"active",endpoint:""}),p(!0)},K=s=>{I(s),n({name:s.name||"",code:s.code||"",provider:s.provider||"aliyun",location:s.location||"",status:s.status||"active",endpoint:s.endpoint||""}),p(!0)},U=async()=>{if(!(!o.name.trim()||!o.code.trim())){z(!0);try{g?await M.update(g.id,o):await M.create(o),p(!1),x()}catch{}finally{z(!1)}}},Y=async s=>{const a=T.find(m=>m.id===s);if(await D({title:"删除区域",description:`确定删除「${a?.name||s}」吗?此操作不可撤销。`,confirmText:"删除",variant:"destructive"}))try{await M.delete(s),N.success("区域已删除"),d(m=>m.filter(_=>_!==s)),x()}catch(m){console.error("删除区域失败:",m),N.error("删除失败")}},Z=async()=>{if(!(c.length===0||!await D({title:"批量删除区域",description:`确定删除选中的 ${c.length} 个区域吗?此操作不可撤销。`,confirmText:"批量删除",variant:"destructive"})))try{await M.batchDelete(c),N.success(`已删除 ${c.length} 个区域`),d([]),x()}catch(a){console.error("批量删除失败:",a),N.error("批量删除失败")}};return e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:185:5",className:"p-6 space-y-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:187:7",className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:188:9",className:"flex items-center gap-3 flex-1",children:[e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:189:11",className:"relative w-72",children:[e.jsx(pe,{"code-path":"src/components/cloud/RegionManager.tsx:190:13",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-500"}),e.jsx(j,{"code-path":"src/components/cloud/RegionManager.tsx:191:13",placeholder:"搜索区域名称或编码...",value:f,onChange:s=>Q(s.target.value),className:"pl-9 h-9 bg-slate-800/50 border-slate-700"})]}),e.jsxs(y,{"code-path":"src/components/cloud/RegionManager.tsx:198:11",value:b,onValueChange:W,children:[e.jsx(C,{"code-path":"src/components/cloud/RegionManager.tsx:199:13",className:"w-32 h-9 bg-slate-800/50 border-slate-700",children:e.jsx(w,{"code-path":"src/components/cloud/RegionManager.tsx:200:15"})}),e.jsxs(S,{"code-path":"src/components/cloud/RegionManager.tsx:202:13",children:[e.jsx(R,{"code-path":"src/components/cloud/RegionManager.tsx:203:15",value:"all",children:"全部云商"}),Object.entries(k).map(([s,a])=>e.jsx(R,{"code-path":"src/components/cloud/RegionManager.tsx:205:17",value:s,children:a},s))]})]})]}),e.jsxs(u,{"code-path":"src/components/cloud/RegionManager.tsx:210:9",onClick:J,className:"gap-2",children:[e.jsx(ge,{"code-path":"src/components/cloud/RegionManager.tsx:211:11",className:"h-4 w-4"}),"添加区域"]})]}),c.length>0&&e.jsxs("div",{"code-path":"src/components/cloud/RegionManager.tsx:218:9",className:"flex items-center justify-between gap-4 px-4 py-2.5 rounded-lg bg-slate-800/50 border border-slate-700",children:[e.jsxs("span",{"code-path":"src/components/cloud/RegionManager.tsx:219:11",className:"text-sm text-slate-300",children:["已选择 ",e.jsx("span",{"code-path":"src/components/cloud/RegionManager.tsx:220:17"Line truncated
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
import{j as t,a3 as Z,L as $,x as Lt,D as P,b as B,c as O,d as A,e as I,I as D,f as V,B as p,F as tt,a2 as et,U as _t,R as ot,H as zt,a as $t,r as i,S as Pt}from"./index-DfyorCky.js";import{S as st,a as at,b as ct,c as nt,d as z}from"./select-D5qUzdAs.js";import{T as Bt,a as Ot,b as J,c as K}from"./tabs-CIh_yD4s.js";import{C as rt}from"./checkbox-CH0bpj6b.js";import{t as l}from"./index-a3ybMjbR.js";import{s as j,t as At}from"./automation-mtL167W_.js";import{B as N}from"./badge-xNW8x0G1.js";import{C as It}from"./circle-x-DK79Dhg2.js";import{L as b}from"./label-BK0h2apY.js";import{T as Vt}from"./textarea-NXY8u32k.js";import{S as it}from"./square-pen-BxUFAe0F.js";import{C as pt,b as Rt,c as Ht,d as qt,a as lt}from"./card-C55cvSHg.js";import{P as Qt}from"./play-cdPayOtJ.js";import{C as Ut}from"./copy-DXW4LnkN.js";import{T as mt}from"./trash-2-Dx32pOzT.js";import{P as Xt}from"./plus-CUG-9kpu.js";import"./index-CWVNW_qu.js";function Gt(o){return{id:o.id,name:o.name,code:o.code||"",description:o.description||"",type:o.type||"shell",content:o.content||"",timeout:o.timeout||300,version:o.version||1,run_count:o.run_count||0,created_at:o.created_at,updated_at:o.updated_at}}const w=[{value:"shell",label:"Shell",sample:`#!/bin/bash
|
||||
import{j as t,P as Z,L as $,C as Lt,D as P,a as B,b as O,c as A,d as I,e as V,B as p,F as tt,a5 as et,O as _t,R as ot,E as zt,f as $t,r as i}from"./index-Dmami9WE.js";import{I as D}from"./input-NsU9nXZF.js";import{S as st,a as at,b as ct,c as nt,d as z}from"./select-DUbxjT0z.js";import{T as Pt,a as Bt,b as J,c as K}from"./tabs-lV44z_UR.js";import{C as rt}from"./checkbox-DoAtRzQj.js";import{t as l}from"./index-BuEnLCjT.js";import{s as j,t as Ot}from"./automation-WG-s4QEv.js";import{B as N}from"./badge-3UzCvU7L.js";import{C as At}from"./circle-x-BBQeW1R3.js";import{L as b}from"./label-Ap_-SPYI.js";import{T as It}from"./textarea-DHUZ6N85.js";import{S as it}from"./square-pen-B3dPIBrm.js";import{C as pt,b as Vt,c as Rt,d as qt,a as lt}from"./card-CIfC-8Rh.js";import{P as Ht}from"./play-0EwQQJX_.js";import{C as Qt}from"./copy-CE_T92Lk.js";import{T as mt}from"./trash-2-DWVnIU6o.js";import{S as Ut}from"./search-Dd-PeBfg.js";import{P as Xt}from"./plus-O65gX7Qz.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";function Gt(o){return{id:o.id,name:o.name,code:o.code||"",description:o.description||"",type:o.type||"shell",content:o.content||"",timeout:o.timeout||300,version:o.version||1,run_count:o.run_count||0,created_at:o.created_at,updated_at:o.updated_at}}const w=[{value:"shell",label:"Shell",sample:`#!/bin/bash
|
||||
# 系统巡检脚本
|
||||
echo "===== 系统信息 ====="
|
||||
uname -a
|
||||
@@ -14,4 +14,4 @@ import platform, socket
|
||||
print("主机名:", socket.gethostname())
|
||||
print("系统:", platform.platform())
|
||||
print("Python:", platform.python_version())
|
||||
`}],W={shell:"border-green-500/30 text-green-500 bg-green-500/10",bash:"border-green-500/30 text-green-500 bg-green-500/10",python:"border-blue-500/30 text-blue-500 bg-blue-500/10",powershell:"border-cyan-500/30 text-cyan-500 bg-cyan-500/10",yaml:"border-purple-500/30 text-purple-500 bg-purple-500/10"},dt=o=>t.jsx(N,{"code-path":"src/components/automation/script-helpers.tsx:66:3",variant:"outline",className:W[o]||W.shell,children:(o||"shell").toUpperCase()}),Y=()=>`sc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`;function xt(o){switch(o){case"pending":return t.jsxs(N,{"code-path":"src/components/automation/script-helpers.tsx:78:14",variant:"outline",className:"gap-1",children:[t.jsx(Lt,{"code-path":"src/components/automation/script-helpers.tsx:78:57",className:"w-3 h-3"}),"等待中"]});case"running":return t.jsxs(N,{"code-path":"src/components/automation/script-helpers.tsx:80:14",variant:"default",className:"bg-blue-500 gap-1",children:[t.jsx($,{"code-path":"src/components/automation/script-helpers.tsx:80:69",className:"w-3 h-3 animate-spin"}),"执行中"]});case"success":return t.jsxs(N,{"code-path":"src/components/automation/script-helpers.tsx:82:14",variant:"default",className:"bg-green-600 gap-1",children:[t.jsx(Z,{"code-path":"src/components/automation/script-helpers.tsx:82:70",className:"w-3 h-3"}),"成功"]});case"failed":return t.jsxs(N,{"code-path":"src/components/automation/script-helpers.tsx:84:14",variant:"destructive",className:"gap-1",children:[t.jsx(It,{"code-path":"src/components/automation/script-helpers.tsx:84:61",className:"w-3 h-3"}),"失败"]});default:return t.jsx(N,{"code-path":"src/components/automation/script-helpers.tsx:86:14",variant:"secondary",children:o||"未知"})}}const Jt=o=>{if(!o)return"-";const a=new Date(o);return Number.isNaN(a.getTime())?"-":a.toLocaleString("zh-CN",{hour12:!1})},Kt=({open:o,onOpenChange:a,editingId:s,editingCode:n,formData:m,setFormData:x,onTypeChange:f,onSave:C})=>t.jsx(P,{"code-path":"src/components/automation/ScriptFormDialog.tsx:38:5",open:o,onOpenChange:a,children:t.jsxs(B,{"code-path":"src/components/automation/ScriptFormDialog.tsx:39:7",className:"max-w-4xl max-h-[90vh]",children:[t.jsxs(O,{"code-path":"src/components/automation/ScriptFormDialog.tsx:40:9",children:[t.jsx(A,{"code-path":"src/components/automation/ScriptFormDialog.tsx:41:11",children:s!==null?"编辑脚本":"新建脚本"}),t.jsx(I,{"code-path":"src/components/automation/ScriptFormDialog.tsx:42:11",children:"编写运维脚本,支持 Shell / Python / PowerShell"})]}),t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:44:9",className:"space-y-4 overflow-y-auto max-h-[60vh] pr-1",children:[t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:45:11",className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:46:13",children:[t.jsx(b,{"code-path":"src/components/automation/ScriptFormDialog.tsx:47:15",children:"名称"}),t.jsx(D,{"code-path":"src/components/automation/ScriptFormDialog.tsx:48:15",value:m.name,onChange:r=>x({...m,name:r.target.value}),placeholder:"如:系统巡检脚本"})]}),t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:54:13",children:[t.jsx(b,{"code-path":"src/components/automation/ScriptFormDialog.tsx:55:15",children:"类型"}),t.jsxs(st,{"code-path":"src/components/automation/ScriptFormDialog.tsx:56:15",value:m.type,onValueChange:f,children:[t.jsx(at,{"code-path":"src/components/automation/ScriptFormDialog.tsx:57:17",children:t.jsx(ct,{"code-path":"src/components/automation/ScriptFormDialog.tsx:57:32"})}),t.jsx(nt,{"code-path":"src/components/automation/ScriptFormDialog.tsx:58:17",children:w.map(r=>t.jsx(z,{"code-path":"src/components/automation/ScriptFormDialog.tsx:60:21",value:r.value,children:r.label},r.value))})]})]})]}),t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:66:11",children:[t.jsx(b,{"code-path":"src/components/automation/ScriptFormDialog.tsx:67:13",children:"描述"}),t.jsx(D,{"code-path":"src/components/automation/ScriptFormDialog.tsx:68:13",value:m.description,onChange:r=>x({...m,description:r.target.value}),placeholder:"脚本用途说明"})]}),t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:74:11",className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:75:13",children:[t.jsx(b,{"code-path":"src/components/automation/ScriptFormDialog.tsx:76:15",children:"超时(秒)"}),t.jsx(D,{"code-path":"src/components/automation/ScriptFormDialog.tsx:77:15",type:"number",value:m.timeout,onChange:r=>x({...m,timeout:Number(r.target.value)}),placeholder:"300"})]}),s!==null&&t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:85:15",children:[t.jsx(b,{"code-path":"src/components/automation/ScriptFormDialog.tsx:86:17",children:"编码"}),t.jsx(D,{"code-path":"src/compone
Line truncated
|
||||
`}],W={shell:"border-green-500/30 text-green-500 bg-green-500/10",bash:"border-green-500/30 text-green-500 bg-green-500/10",python:"border-blue-500/30 text-blue-500 bg-blue-500/10",powershell:"border-cyan-500/30 text-cyan-500 bg-cyan-500/10",yaml:"border-purple-500/30 text-purple-500 bg-purple-500/10"},dt=o=>t.jsx(N,{"code-path":"src/components/automation/script-helpers.tsx:66:3",variant:"outline",className:W[o]||W.shell,children:(o||"shell").toUpperCase()}),Y=()=>`sc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`;function xt(o){switch(o){case"pending":return t.jsxs(N,{"code-path":"src/components/automation/script-helpers.tsx:78:14",variant:"outline",className:"gap-1",children:[t.jsx(Lt,{"code-path":"src/components/automation/script-helpers.tsx:78:57",className:"w-3 h-3"}),"等待中"]});case"running":return t.jsxs(N,{"code-path":"src/components/automation/script-helpers.tsx:80:14",variant:"default",className:"bg-blue-500 gap-1",children:[t.jsx($,{"code-path":"src/components/automation/script-helpers.tsx:80:69",className:"w-3 h-3 animate-spin"}),"执行中"]});case"success":return t.jsxs(N,{"code-path":"src/components/automation/script-helpers.tsx:82:14",variant:"default",className:"bg-green-600 gap-1",children:[t.jsx(Z,{"code-path":"src/components/automation/script-helpers.tsx:82:70",className:"w-3 h-3"}),"成功"]});case"failed":return t.jsxs(N,{"code-path":"src/components/automation/script-helpers.tsx:84:14",variant:"destructive",className:"gap-1",children:[t.jsx(At,{"code-path":"src/components/automation/script-helpers.tsx:84:61",className:"w-3 h-3"}),"失败"]});default:return t.jsx(N,{"code-path":"src/components/automation/script-helpers.tsx:86:14",variant:"secondary",children:o||"未知"})}}const Jt=o=>{if(!o)return"-";const a=new Date(o);return Number.isNaN(a.getTime())?"-":a.toLocaleString("zh-CN",{hour12:!1})},Kt=({open:o,onOpenChange:a,editingId:s,editingCode:n,formData:m,setFormData:x,onTypeChange:f,onSave:C})=>t.jsx(P,{"code-path":"src/components/automation/ScriptFormDialog.tsx:38:5",open:o,onOpenChange:a,children:t.jsxs(B,{"code-path":"src/components/automation/ScriptFormDialog.tsx:39:7",className:"max-w-4xl max-h-[90vh]",children:[t.jsxs(O,{"code-path":"src/components/automation/ScriptFormDialog.tsx:40:9",children:[t.jsx(A,{"code-path":"src/components/automation/ScriptFormDialog.tsx:41:11",children:s!==null?"编辑脚本":"新建脚本"}),t.jsx(I,{"code-path":"src/components/automation/ScriptFormDialog.tsx:42:11",children:"编写运维脚本,支持 Shell / Python / PowerShell"})]}),t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:44:9",className:"space-y-4 overflow-y-auto max-h-[60vh] pr-1",children:[t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:45:11",className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:46:13",children:[t.jsx(b,{"code-path":"src/components/automation/ScriptFormDialog.tsx:47:15",children:"名称"}),t.jsx(D,{"code-path":"src/components/automation/ScriptFormDialog.tsx:48:15",value:m.name,onChange:r=>x({...m,name:r.target.value}),placeholder:"如:系统巡检脚本"})]}),t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:54:13",children:[t.jsx(b,{"code-path":"src/components/automation/ScriptFormDialog.tsx:55:15",children:"类型"}),t.jsxs(st,{"code-path":"src/components/automation/ScriptFormDialog.tsx:56:15",value:m.type,onValueChange:f,children:[t.jsx(at,{"code-path":"src/components/automation/ScriptFormDialog.tsx:57:17",children:t.jsx(ct,{"code-path":"src/components/automation/ScriptFormDialog.tsx:57:32"})}),t.jsx(nt,{"code-path":"src/components/automation/ScriptFormDialog.tsx:58:17",children:w.map(r=>t.jsx(z,{"code-path":"src/components/automation/ScriptFormDialog.tsx:60:21",value:r.value,children:r.label},r.value))})]})]})]}),t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:66:11",children:[t.jsx(b,{"code-path":"src/components/automation/ScriptFormDialog.tsx:67:13",children:"描述"}),t.jsx(D,{"code-path":"src/components/automation/ScriptFormDialog.tsx:68:13",value:m.description,onChange:r=>x({...m,description:r.target.value}),placeholder:"脚本用途说明"})]}),t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:74:11",className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:75:13",children:[t.jsx(b,{"code-path":"src/components/automation/ScriptFormDialog.tsx:76:15",children:"超时(秒)"}),t.jsx(D,{"code-path":"src/components/automation/ScriptFormDialog.tsx:77:15",type:"number",value:m.timeout,onChange:r=>x({...m,timeout:Number(r.target.value)}),placeholder:"300"})]}),s!==null&&t.jsxs("div",{"code-path":"src/components/automation/ScriptFormDialog.tsx:85:15",children:[t.jsx(b,{"code-path":"src/components/automation/ScriptFormDialog.tsx:86:17",children:"编码"}),t.jsx(D,{"code-path":"src/compone
Line truncated
|
||||
@@ -0,0 +1,11 @@
|
||||
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-l6TwDTR3.js","./index-Dmami9WE.js","./index-C8L7RhXS.css","./dashboard-BHNKEvkq.js","./server-3HmnhxQB.js","./kubernetes-D2-GnE0t.js","./deploy-CD5bEXt-.js","./automation-WG-s4QEv.js","./monitor-CicbJUrQ.js","./agent-B3ElXCx8.js","./cloud-Dq4kl-JO.js","./system-C3cYTuQH.js","./ai-2t1T1OeI.js"])))=>i.map(i=>d[i]);
|
||||
import{i as Ke,j as e,r as t,aU as Tr,D as _e,a as Te,b as Je,c as Re,d as Me,s as xr,Y as Ae,M as Ve,P as cr,K as ve,o as Fe,B as N,a6 as $e,S as ze,e as qe,$ as ir,a0 as xe,X as ue,t as vr,L as Le,ak as Rr,ab as Mr,a8 as Br,ag as Pr,aa as Qe,ad as Ar,a9 as $r,ac as Or,as as zr,h as Lr,V as Hr,aQ as hr,N as Ur,E as ar,aJ as gr,aK as ur,aL as br,aM as Sr,aN as We,aO as he,f as Dr}from"./index-Dmami9WE.js";import{C as ke,a as Ee}from"./card-CIfC-8Rh.js";import{I as V}from"./input-NsU9nXZF.js";import{C as ge}from"./checkbox-DoAtRzQj.js";import{b as Oe,e as se,T as Vr,a as Wr,c as de,d as Gr}from"./table-CG4mjNfb.js";import{S as fe,a as we,b as Ce,c as Ie,d as H}from"./select-DUbxjT0z.js";import{s as te,r as Kr}from"./server-3HmnhxQB.js";import{S as Jr}from"./stat-strip-BteRU1Iu.js";import{t as J}from"./index-BuEnLCjT.js";import{B as $}from"./badge-3UzCvU7L.js";import{c as ye}from"./cloud-Dq4kl-JO.js";import{R as le}from"./refresh-cw-CTBERyFc.js";import{S as jr}from"./search-Dd-PeBfg.js";import{x as qr,a as Qr}from"./xterm-DSqgeKvr.js";import{c as Nr,s as Xr}from"./deploy-CD5bEXt-.js";import{M as yr,a as fr}from"./minimize-2-BHcbNmdK.js";import{F as wr}from"./folder-open-CjMh_m_2.js";import{U as Xe}from"./upload-CRLg7Pbj.js";import{a as nr,F as Yr}from"./folder-B5RGB3GG.js";import{A as Zr}from"./arrow-left-BIbk9wFC.js";import{D as Ye}from"./download-Vuij9wGr.js";import{T as Ze}from"./trash-2-DWVnIU6o.js";import{L as D}from"./label-Ap_-SPYI.js";import{T as dr}from"./textarea-DHUZ6N85.js";import{S as es}from"./save-YtnrpTd8.js";import{H as rs}from"./hard-drive-DmC04Y5r.js";import{E as ss}from"./ellipsis-BcWfelgl.js";import{S as ts}from"./square-pen-B3dPIBrm.js";import{P as os}from"./plus-O65gX7Qz.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";const cs=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],er=Ke("chevron-left",cs);const as=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]],Ge=Ke("file-spreadsheet",as);const ns=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],ds=Ke("folder-plus",ns);function ls({servers:s}){const x=s.filter(c=>c.status==="running").length,o=s.filter(c=>c.status==="maintenance").length,a=s.filter(c=>c.status==="stopped").length;return e.jsx(Jr,{"code-path":"src/components/server/ServerStatsStrip.tsx:14:5",items:[{label:"服务器",value:s.length,color:"blue"},{label:"运行中",value:x,color:"emerald"},{label:"维护中",value:o,color:"amber"},{label:"已停止",value:a,color:"muted"}]})}const ps=[{id:"aws",name:"AWS",color:"bg-orange-500",icon:"AWS"},{id:"aliyun",name:"阿里云",color:"bg-orange-600",icon:"AL"},{id:"tencent",name:"腾讯云",color:"bg-blue-500",icon:"TX"},{id:"huawei",name:"华为云",color:"bg-red-500",icon:"HW"},{id:"azure",name:"Azure",color:"bg-blue-600",icon:"AZ"}];function ms({open:s,onClose:x}){const[o,a]=t.useState([]),[c,u]=t.useState(1),[h,g]=t.useState(""),[m,F]=t.useState(null),[S,k]=t.useState([]),[n,y]=t.useState([]),[E,R]=t.useState(""),[w,f]=t.useState(!1),[v,C]=t.useState([]),[i,O]=t.useState([]),[W,j]=t.useState(!1),[z,p]=t.useState([]),[b,B]=t.useState(!1),[T,G]=t.useState(null),[ee,re]=t.useState("22"),[pe,l]=t.useState([]),[M,K]=t.useState(""),U=async()=>{try{const r=await ye.getAccounts();a(r?.list||[])}catch(r){console.error("加载云账号失败:",r)}};t.useEffect(()=>{s&&(U(),Tr(async()=>{const{credentialApi:r}=await import("./index-l6TwDTR3.js");return{credentialApi:r}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]),import.meta.url).then(({credentialApi:r})=>{r.list().then(_=>l(_?.list||[])).catch(()=>l([]))}))},[s]);const P=o.filter(r=>r.provider===h&&r.status==="active"),X=t.useCallback(async r=>{try{return(await ye.getAccountRegions(r))?.list||[]}catch{return[]}},[]),q=t.useCallback(async r=>{f(!0);try{await ye.syncRegions(r);const _=await X(r);k(_)}catch(_){throw console.error("同步区域失败:",_),_}finally{f(!1)}},[X]),A=t.useCallback(async()=>{if(!m)return;const r=await X(m.id);if(k(r),r.length===0)try{await q(m.id)}catch{}},[m,X,q]),me=t.useCallback(async()=>{if(!(!m||n.length===0)){j(!0),p([]),C([]),O([]);try{const r=await ye.discoverInstances(m.id,n);C(r?.list||[]),p(r?.errors||[])}catch(r){console.error("发现主机失败:",r),p([r?.message||"发现主机失败"])}finally{j(!1)}}},[m,n]),L=async()=>{if(!(!m||i.length===0)){B(!0);try{const r=v.filter(ae=>i.includes(ae.instance_id)),_=await ye.importInstances(m.id,r,{default_port:Number(ee)||22,credential_id:M?Number(M):void 0});G(_||{imported:0,skipped:0})}catch(r){console.error("导入失败:",r)}finally{B(!1)Line truncated
|
||||
\x1B[31m[连接已关闭]\x1B[0m\r
|
||||
`)},T.onerror=()=>{j.write(`\r
|
||||
\x1B[31m[连接发生错误]\x1B[0m\r
|
||||
`)},()=>{try{T.close(),j.dispose()}catch{}g.current=null,m.current=null,k(!1)}},[s,o,i]),t.useEffect(()=>{if(!s)return;const j=h.current;if(!j)return;let z;const p=new ResizeObserver(()=>{clearTimeout(z),z=setTimeout(()=>{if(F.current&&g.current&&m.current)try{F.current.fit(),g.current.focus();const{cols:b,rows:B}=g.current;m.current.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({status:1,cols:b,rows:B}))}catch{}},60)});return p.observe(j),()=>{clearTimeout(z),p.disconnect()}},[s]),e.jsx(_e,{"code-path":"src/components/server/TerminalDialog.tsx:196:5",open:s,onOpenChange:x,children:e.jsxs(Te,{"code-path":"src/components/server/TerminalDialog.tsx:197:7",showCloseButton:!1,className:xe("bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] p-0 gap-0","!duration-0 !transition-none",n?"!max-w-none !w-screen !h-screen !rounded-none !translate-x-0 !translate-y-0 !left-0 !top-0":""),style:n?{maxWidth:"100vw",width:"100vw",height:"100vh"}:{maxWidth:"900px",width:"90vw"},children:[e.jsxs(Re,{"code-path":"src/components/server/TerminalDialog.tsx:209:9",className:"sr-only",children:["终端 - ",a]}),e.jsx(Me,{"code-path":"src/components/server/TerminalDialog.tsx:210:9",className:"sr-only",children:"SSH 终端连接"}),e.jsxs("div",{"code-path":"src/components/server/TerminalDialog.tsx:212:9",className:"flex items-center justify-between px-4 py-2 border-b border-[var(--dg-border)]",children:[e.jsxs("div",{"code-path":"src/components/server/TerminalDialog.tsx:213:11",className:"flex items-center gap-2 text-sm",children:[e.jsx("div",{"code-path":"src/components/server/TerminalDialog.tsx:214:13",className:xe("w-2 h-2 rounded-full",S?"bg-emerald-400":"bg-red-400")}),e.jsx("span",{"code-path":"src/components/server/TerminalDialog.tsx:215:13",className:"text-[var(--dg-text-primary)] font-medium",children:a}),e.jsxs("span",{"code-path":"src/components/server/TerminalDialog.tsx:216:13",className:"text-[var(--dg-text-muted)]",children:["(",c,")"]})]}),e.jsxs("div",{"code-path":"src/components/server/TerminalDialog.tsx:218:11",className:"flex items-center gap-1",children:[e.jsx("button",{"code-path":"src/components/server/TerminalDialog.tsx:219:13",onClick:()=>y(!n),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]",children:n?e.jsx(yr,{"code-path":"src/components/server/TerminalDialog.tsx:223:29",className:"h-4 w-4"}):e.jsx(fr,{"code-path":"src/components/server/TerminalDialog.tsx:223:65",className:"h-4 w-4"})}),e.jsx("button",{"code-path":"src/components/server/TerminalDialog.tsx:225:13",onClick:()=>x(!1),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]",children:e.jsx(ue,{"code-path":"src/components/server/TerminalDialog.tsx:229:15",className:"h-4 w-4"})})]})]}),!i&&e.jsxs("div",{"code-path":"src/components/server/TerminalDialog.tsx:235:11",className:"p-6 flex flex-col items-center justify-center gap-4",style:{height:"480px"},children:[e.jsx(vr,{"code-path":"src/components/server/TerminalDialog.tsx:236:13",className:"h-12 w-12 text-amber-400"}),e.jsxs("div",{"code-path":"src/components/server/TerminalDialog.tsx:237:13",className:"text-center",children:[e.jsx("p",{"code-path":"src/components/server/TerminalDialog.tsx:238:15",className:"text-[var(--dg-text-primary)] font-medium mb-1",children:"服务器未配置认证凭据"}),e.jsx("p",{"code-path":"src/components/server/TerminalDialog.tsx:239:15",className:"text-sm text-[var(--dg-text-muted)]",children:"请选择一个凭据用于 SSH 连接"})]}),E.length===0?e.jsx("p",{"code-path":"src/components/server/TerminalDialog.tsx:242:15",className:"text-xs text-[var(--dg-text-muted)]",children:"暂无可用凭据,请先去「凭证配置」添加"}):e.jsxs("select",{"code-path":"src/components/server/TerminalDialog.tsx:244:15",value:w,onChange:j=>f(j.target.value),className:"w-64 px-3 py-2 bg-[var(--dg-bg-tertiary)] border border-[var(--dg-border)] rounded-md text-[var(--dg-text-primary)] text-sm",children:[e.jsx("option",{"code-path":"src/components/server/TerminalDialog.tsx:249:17",value:"",children:"-- 选择凭据 --"}),E.map(j=>e.jsxs("option",{"code-path":"src/components/server/TerminalDialog.tsx:251:19",value:String(j.id),children:[j.type==="ssh_key"?"🔑":"🔒"," ",j.name]},j.id))]}),e.jsx(N,{"code-path":"src/components/server/TerminalDialog.tsx:257:13",onClick:W,disabled:!w||v,className:"bg-[var(--dg-blue)] hover:opacity-90 text-white",children:v?"关联中...":"确认连接"})]}),i&&e.jsx("div",{"code-path":"src/components/server/TerminalDialog.tsx:268:11",ref:h,className:"bg-[#0a0e14]",style:{height:n?"calc(100vh - 49px)":"480px"}})]})})}const is=s=>s<1024?`${s} B`:s<1048576?`${(s/1024).toFixed(1)} KB`:`${(s/1048576).toFixed(2)} MB`;function vs({open:s,onOpenChange:x,serverId:o,serverName:a}){const[c,u]=t.useState([]),[h,g]=t.useState([]),[m,F]=t.useState("/"),[S,k]=t.useState(!1),[n,y]=t.useState(""),[E,R]=t.useState(!1),[w,f]=t.useState(!1),v=t.useRef(null),C=t.useCallback(asyn
Line truncated
|
||||
`).replace(/\r/g,`
|
||||
`).split(`
|
||||
`).filter(c=>c.trim());if(x.length<2)return[];const o=lr(x[0]).map(c=>c.toLowerCase()),a=[];for(let c=1;c<x.length;c++){const u=lr(x[c]),h={};o.forEach((g,m)=>{h[g]=u[m]??""}),a.push(h)}return a}function gs(s){return/^(\d{1,3}\.){3}\d{1,3}$/.test(s)&&s.split(".").every(x=>Number(x)>=0&&Number(x)<=255)}function us(){const s=["hostname,ip,port","web-01,192.168.1.10,22","db-01,192.168.1.20,22","cache-01,192.168.1.30,2222"].join(`
|
||||
`),x=new Blob(["\uFEFF"+s],{type:"text/csv;charset=utf-8;"}),o=URL.createObjectURL(x),a=document.createElement("a");a.href=o,a.download="servers-template.csv",a.click(),URL.revokeObjectURL(o)}function bs({open:s,onClose:x}){const[o,a]=t.useState(1),[c,u]=t.useState(""),[,h]=t.useState("password"),[g,m]=t.useState(null),[F,S]=t.useState(!1),[k,n]=t.useState([]),[y,E]=t.useState([]),[R,w]=t.useState(!1),[f,v]=t.useState([]),[C,i]=t.useState(""),[O,W]=t.useState("22");t.useEffect(()=>{if(!s)return;let l=!1;return(async()=>{try{const[M,K]=await Promise.all([Kr.list(),Nr.list()]);if(l)return;const U=M?.list??[];E(U.map(P=>({id:String(P.id??""),name:P.name??"",code:P.code??""}))),v(K?.list??[])}catch{l||(E([]),v([]))}})(),()=>{l=!0}},[s]);const j=async()=>{if(o===2&&g){S(!0);try{const l=await g.text(),M=hs(l);if(M.length===0){J.error("文件无有效数据,请使用模板格式(首行为表头)"),S(!1);return}const K=new Set,U=M.map((P,X)=>{const q=(P.hostname??"").trim(),A=(P.ip??"").trim(),me={row:X+2,hostname:q,ip:A,port:Number(P.port)||22,username:(P.username??"").trim()||"root",os:P.os??"",cpu:Number(P.cpu)||0,memory:Number(P.memory)||0,disk:Number(P.disk)||0,tags:P.tags??"",status:"valid",message:"有效"},L=[];q||L.push("主机名缺失"),A?gs(A)||L.push("IP格式错误"):L.push("IP缺失");const ie=`${q}|${A}`;return q&&A&&K.has(ie)?L.push("重复行"):K.add(ie),L.length>0&&(me.status="error",me.message=L.join("、")),me});n(U),a(o+1)}catch{J.error("文件解析失败,请确认是 CSV 格式")}finally{S(!1)}}else a(o+1)},z=()=>{o>1&&a(o-1)},p=l=>{l.target.files&&l.target.files[0]&&m(l.target.files[0])},b=()=>{a(1),u(""),W("22"),i(""),m(null),n([])},B=async()=>{const l=k.filter(M=>M.status==="valid");if(l.length!==0){w(!0);try{const M=l.map(A=>({hostname:A.hostname,ip:A.ip,port:A.port,username:A.username,os:A.os,cpu:A.cpu,memory:A.memory,disk:A.disk,tags:A.tags})),U=await te.batchCreate({servers:M,region_id:c||void 0,credential_id:C?Number(C):void 0,default_port:Number(O)||22})??{},P=U.success??0,X=U.skipped??0,q=U.failed??0;J.success(`导入完成:成功 ${P},跳过 ${X},失败 ${q}`),b(),x()}catch(M){J.error(M?.message||"导入失败,请重试")}finally{w(!1)}}},T=()=>{x(),b()},G=k.filter(l=>l.status==="valid").length,ee=k.filter(l=>l.status==="warning").length,re=k.filter(l=>l.status==="error").length,pe=[{id:1,title:"配置"},{id:2,title:"上传"},{id:3,title:"确认"}];return e.jsx(_e,{"code-path":"src/components/server/ExcelServerImport.tsx:278:5",open:s,onOpenChange:T,children:e.jsxs(Te,{"code-path":"src/components/server/ExcelServerImport.tsx:279:7",className:"max-w-3xl bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]",children:[e.jsxs(Je,{"code-path":"src/components/server/ExcelServerImport.tsx:280:9",children:[e.jsx(Re,{"code-path":"src/components/server/ExcelServerImport.tsx:281:11",className:"text-xl",children:"CSV 批量导入服务器"}),e.jsx(Me,{"code-path":"src/components/server/ExcelServerImport.tsx:282:11",className:"sr-only",children:"通过 CSV 文件批量导入服务器资产"})]}),e.jsx("div",{"code-path":"src/components/server/ExcelServerImport.tsx:286:9",className:"flex items-center justify-center mb-6",children:pe.map((l,M)=>e.jsxs("div",{"code-path":"src/components/server/ExcelServerImport.tsx:288:13",className:"flex items-center",children:[e.jsx("div",{"code-path":"src/components/server/ExcelServerImport.tsx:289:15",className:`flex items-center justify-center w-8 h-8 rounded-full ${o===l.id?"bg-blue-600 text-white":o>l.id?"bg-emerald-600 text-white":"bg-[var(--dg-bg-secondary)] text-[var(--dg-text-muted)]"}`,children:o>l.id?e.jsx(ve,{"code-path":"src/components/server/ExcelServerImport.tsx:296:32",className:"h-4 w-4"}):l.id}),e.jsx("span",{"code-path":"src/components/server/ExcelServerImport.tsx:298:15",className:`ml-2 text-sm ${o===l.id?"text-[var(--dg-text-primary)]":"text-[var(--dg-text-muted)]"}`,children:l.title}),M<pe.length-1&&e.jsx("div",{"code-path":"src/components/server/ExcelServerImport.tsx:302:17",className:"w-12 h-0.5 bg-[var(--dg-border)] mx-3"})]},l.id))}),o===1&&e.jsxs("div",{"code-path":"src/components/server/ExcelServerImport.tsx:310:11",className:"space-y-6",children:[e.jsx(ke,{"code-path":"src/components/server/ExcelServerImport.tsx:312:13",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsx(Ee,{"code-path":"src/components/server/ExcelServerImport.tsx:313:15",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/server/ExcelServerImport.tsx:314:17",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/server/ExcelServerImport.tsx:315:19",className:"flex items-center gap-3",children:[e.jsx("div",{"code-path":"src/components/server/ExcelServerImport.tsx:316:21",className:"w-10 h-10 rounded-lg bg-emerald-500/20 flex items-center justify-center",children:e.jsx(Ge,{"code-path":"src/components/server/ExcelServerImport.tsx:317:23"
Line truncated
|
||||
`),Z=new Blob(["\uFEFF"+ne],{type:"text/csv;charset=utf-8;"}),Q=URL.createObjectURL(Z),ce=document.createElement("a");ce.href=Q,ce.download=`servers_${new Date().toISOString().slice(0,10)}.csv`,ce.click(),URL.revokeObjectURL(Q),J.success(`已导出 ${o.length} 台服务器`)},or=8;return e.jsxs("div",{"code-path":"src/components/server/ServerManager.tsx:373:5",className:"space-y-6",children:[e.jsxs("div",{"code-path":"src/components/server/ServerManager.tsx:375:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/server/ServerManager.tsx:376:9",children:[e.jsx("h1",{"code-path":"src/components/server/ServerManager.tsx:377:11",className:"text-2xl font-bold text-[var(--dg-text-primary)]",children:"服务器管理"}),e.jsx("p",{"code-path":"src/components/server/ServerManager.tsx:378:11",className:"text-sm text-[var(--dg-text-muted)] mt-1",children:"管理云平台服务器资产"})]}),e.jsxs("div",{"code-path":"src/components/server/ServerManager.tsx:380:9",className:"flex items-center gap-2",children:[e.jsxs(N,{"code-path":"src/components/server/ServerManager.tsx:381:11",variant:"outline",className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)] hover:bg-[var(--dg-bg-hover)]",onClick:()=>L(),children:[e.jsx(le,{"code-path":"src/components/server/ServerManager.tsx:386:13",className:xe("h-4 w-4 mr-2",c&&"animate-spin")}),"刷新"]}),e.jsxs(N,{"code-path":"src/components/server/ServerManager.tsx:389:11",variant:"outline",className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)] hover:bg-[var(--dg-bg-hover)]",onClick:_r,children:[e.jsx(Ye,{"code-path":"src/components/server/ServerManager.tsx:394:13",className:"h-4 w-4 mr-2"}),"导出"]}),x("server:create")&&e.jsxs(gr,{"code-path":"src/components/server/ServerManager.tsx:398:11",children:[e.jsx(ur,{"code-path":"src/components/server/ServerManager.tsx:399:13",asChild:!0,children:e.jsxs(N,{"code-path":"src/components/server/ServerManager.tsx:400:15",variant:"outline",className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)] hover:bg-[var(--dg-bg-hover)]",children:[e.jsx(Xe,{"code-path":"src/components/server/ServerManager.tsx:401:17",className:"h-4 w-4 mr-2"}),"批量导入"]})}),e.jsxs(br,{"code-path":"src/components/server/ServerManager.tsx:405:13",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]",children:[e.jsx(Sr,{"code-path":"src/components/server/ServerManager.tsx:406:15",children:"选择导入方式"}),e.jsx(We,{"code-path":"src/components/server/ServerManager.tsx:407:15",className:"bg-[var(--dg-border)]"}),e.jsxs(he,{"code-path":"src/components/server/ServerManager.tsx:408:15",className:"hover:bg-[var(--dg-bg-hover)] cursor-pointer focus:bg-[var(--dg-bg-hover)] focus:text-[var(--dg-text-primary)]",onClick:()=>y(!0),children:[e.jsx(xr,{"code-path":"src/components/server/ServerManager.tsx:412:17",className:"h-4 w-4 mr-2 text-[var(--dg-blue)]"}),"云主机导入",e.jsx("span",{"code-path":"src/components/server/ServerManager.tsx:414:17",className:"ml-2 text-xs text-[var(--dg-text-muted)]",children:"从云平台同步"})]}),e.jsxs(he,{"code-path":"src/components/server/ServerManager.tsx:416:15",className:"hover:bg-[var(--dg-bg-hover)] cursor-pointer focus:bg-[var(--dg-bg-hover)] focus:text-[var(--dg-text-primary)]",onClick:()=>R(!0),children:[e.jsx(Ge,{"code-path":"src/components/server/ServerManager.tsx:420:17",className:"h-4 w-4 mr-2 text-emerald-400"}),"CSV导入",e.jsx("span",{"code-path":"src/components/server/ServerManager.tsx:422:17",className:"ml-2 text-xs text-[var(--dg-text-muted)]",children:"hostname + IP 即可"})]})]})]}),x("server:create")&&e.jsxs(N,{"code-path":"src/components/server/ServerManager.tsx:428:13",className:"bg-[var(--dg-blue)] hover:opacity-90 text-white",onClick:r,children:[e.jsx(os,{"code-path":"src/components/server/ServerManager.tsx:432:15",className:"h-4 w-4 mr-2"}),"添加服务器"]})]})]}),e.jsx(ls,{"code-path":"src/components/server/ServerManager.tsx:440:7",servers:o}),e.jsx(ke,{"code-path":"src/components/server/ServerManager.tsx:443:7",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(Ee,{"code-path":"src/components/server/ServerManager.tsx:444:9",className:"p-0",children:[e.jsxs("div",{"code-path":"src/components/server/ServerManager.tsx:446:11",className:"flex items-center justify-between flex-wrap gap-4 p-4",children:[e.jsxs("div",{"code-path":"src/components/server/ServerManager.tsx:447:13",className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{"code-path":"src/components/server/ServerManager.tsx:448:15",className:"relative w-64",children:[e.jsx(jr,{"code-path":"src/components/server/ServerManager.tsx:449:17",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-[var(--dg-text-muted)]"}),e.jsx(V,{"code-path":"src/components/server
Line truncated
|
||||
@@ -1,11 +0,0 @@
|
||||
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-CHhHmizP.js","./index-DfyorCky.js","./index-1EStmE-w.css","./dashboard-BjQPIG2G.js","./server-CjDPBaTN.js","./kubernetes-J8O09fK7.js","./deploy-B3Sg3N1U.js","./automation-mtL167W_.js","./monitor-BAaBXIsC.js","./agent-DqqIRCQX.js","./cloud-Dzoer-2i.js","./system-BgtMMm0X.js","./ai-BTgmlP5Q.js"])))=>i.map(i=>d[i]);
|
||||
import{g as He,j as e,q as Ee,A as Fr,r as t,aT as kr,D as Te,b as Re,c as Ue,d as Me,e as Be,s as xr,P as $e,M as Ge,a3 as ar,a9 as ge,n as _e,B as g,S as ir,I as H,$ as Oe,f as Je,W as vr,X as Se,a5 as fe,t as hr,L as Le,af as Er,ac as _r,ak as Tr,ae as Qe,ah as Rr,ad as Mr,ag as Br,aw as Pr,h as Ar,a4 as $r,N as Or,H as cr,aK as gr,aL as ur,aM as Sr,aN as br,aO as Ke,aP as we,a as zr}from"./index-DfyorCky.js";import{C as me,a as xe}from"./card-C55cvSHg.js";import{C as ue}from"./checkbox-CH0bpj6b.js";import{b as ze,e as re,T as Lr,a as Hr,c as le,d as Ur}from"./table-5sHV4Akp.js";import{S as Ce,a as Ie,b as Fe,c as ke,d as O}from"./select-D5qUzdAs.js";import{s as se,r as Dr}from"./server-CjDPBaTN.js";import{R as Vr}from"./rotate-cw-5qcj_h_q.js";import{t as V}from"./index-a3ybMjbR.js";import{B as A}from"./badge-xNW8x0G1.js";import{c as ye}from"./cloud-Dzoer-2i.js";import{R as pe}from"./refresh-cw-DUB_tAG-.js";import{x as Wr,a as Gr}from"./xterm-DSqgeKvr.js";import{c as jr,s as Kr}from"./deploy-B3Sg3N1U.js";import{M as qr,a as Jr}from"./minimize-2-CiCQYRfn.js";import{F as Nr}from"./folder-open-IMBifk-r.js";import{U as Xe}from"./upload-Ba6rlaGS.js";import{a as nr,F as Qr}from"./folder-DoMwqvzv.js";import{A as Xr}from"./arrow-left-BDgGyrD0.js";import{D as Ye}from"./download-DoZfYs2h.js";import{T as Ze}from"./trash-2-Dx32pOzT.js";import{L}from"./label-BK0h2apY.js";import{T as dr}from"./textarea-NXY8u32k.js";import{S as Yr}from"./save-DoGGjfwC.js";import{H as Zr}from"./hard-drive-BbPmnARR.js";import{E as es}from"./ellipsis-DU5enAwm.js";import{S as rs}from"./square-pen-BxUFAe0F.js";import{P as ss}from"./plus-CUG-9kpu.js";import"./index-CWVNW_qu.js";const ts=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],er=He("chevron-left",ts);const os=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]],qe=He("file-spreadsheet",os);const as=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],cs=He("folder-plus",as);const ns=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],ds=He("power",ns);function ls({servers:s}){const m=s.filter(o=>o.status==="running").length,a=s.filter(o=>o.status==="maintenance").length,c=s.filter(o=>o.status==="stopped").length;return e.jsxs("div",{"code-path":"src/components/server/ServerStatsCards.tsx:15:5",className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsx(me,{"code-path":"src/components/server/ServerStatsCards.tsx:16:7",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsx(xe,{"code-path":"src/components/server/ServerStatsCards.tsx:17:9",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/server/ServerStatsCards.tsx:18:11",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/server/ServerStatsCards.tsx:19:13",children:[e.jsx("p",{"code-path":"src/components/server/ServerStatsCards.tsx:20:15",className:"text-sm text-[var(--dg-text-muted)]",children:"服务器总数"}),e.jsx("p",{"code-path":"src/components/server/ServerStatsCards.tsx:21:15",className:"text-2xl font-bold text-[var(--dg-text-primary)]",children:s.length})]}),e.jsx("div",{"code-path":"src/components/server/ServerStatsCards.tsx:23:13",className:"p-3 rounded-lg bg-[var(--dg-blue)]/10 text-[var(--dg-blue)]",children:e.jsx(Ee,{"code-path":"src/components/server/ServerStatsCards.tsx:24:15",className:"h-5 w-5"})})]})})}),e.jsx(me,{"code-path":"src/components/server/ServerStatsCards.tsx:29:7",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsx(xe,{"code-path":"src/components/server/ServerStatsCards.tsx:30:9",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/server/ServerStatsCards.tsx:31:11",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/server/ServerStatsCards.tsx:32:13",children:[e.jsx("p",{"code-path":"src/components/server/ServerStatsCards.tsx:33:15",className:"text-sm text-[var(--dg-text-muted)]",children:"运行中"}),e.jsx("p",{"code-path":"src/components/server/ServerStatsCards.tsx:34:15",className:"text-2xl font-bold text-emerald-400",children:m})]}),e.jsx("div",{"code-path":"src/components/server/ServerStatsCards.tsx:36:13",className:"p-3 rounded-lg bg-emerald-500/10 text-emerald-400",children:e.jsx(Fr,{"code-path":"src/components/server/ServerStatsCards.tsx:37:15",className:"h-5 w-5"})})]})})}),e.jsx(me,{"code-path":"src/components/server/ServerStatsCards.tsx:42:7",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsx(xeLine truncated
|
||||
\x1B[31m[连接已关闭]\x1B[0m\r
|
||||
`)},B.onerror=()=>{d.write(`\r
|
||||
\x1B[31m[连接发生错误]\x1B[0m\r
|
||||
`)},()=>{try{B.close(),d.dispose()}catch{}j.current=null,x.current=null,I(!1)}},[s,a,k]),t.useEffect(()=>{if(!s)return;const d=b.current;if(!d)return;let S;const _=new ResizeObserver(()=>{clearTimeout(S),S=setTimeout(()=>{if(w.current&&j.current&&x.current)try{w.current.fit(),j.current.focus();const{cols:J,rows:W}=j.current;x.current.readyState===WebSocket.OPEN&&x.current.send(JSON.stringify({status:1,cols:J,rows:W}))}catch{}},60)});return _.observe(d),()=>{clearTimeout(S),_.disconnect()}},[s]),e.jsx(Te,{"code-path":"src/components/server/TerminalDialog.tsx:196:5",open:s,onOpenChange:m,children:e.jsxs(Re,{"code-path":"src/components/server/TerminalDialog.tsx:197:7",showCloseButton:!1,className:Se("bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] p-0 gap-0","!duration-0 !transition-none",n?"!max-w-none !w-screen !h-screen !rounded-none !translate-x-0 !translate-y-0 !left-0 !top-0":""),style:n?{maxWidth:"100vw",width:"100vw",height:"100vh"}:{maxWidth:"900px",width:"90vw"},children:[e.jsxs(Me,{"code-path":"src/components/server/TerminalDialog.tsx:209:9",className:"sr-only",children:["终端 - ",c]}),e.jsx(Be,{"code-path":"src/components/server/TerminalDialog.tsx:210:9",className:"sr-only",children:"SSH 终端连接"}),e.jsxs("div",{"code-path":"src/components/server/TerminalDialog.tsx:212:9",className:"flex items-center justify-between px-4 py-2 border-b border-[var(--dg-border)]",children:[e.jsxs("div",{"code-path":"src/components/server/TerminalDialog.tsx:213:11",className:"flex items-center gap-2 text-sm",children:[e.jsx("div",{"code-path":"src/components/server/TerminalDialog.tsx:214:13",className:Se("w-2 h-2 rounded-full",N?"bg-emerald-400":"bg-red-400")}),e.jsx("span",{"code-path":"src/components/server/TerminalDialog.tsx:215:13",className:"text-[var(--dg-text-primary)] font-medium",children:c}),e.jsxs("span",{"code-path":"src/components/server/TerminalDialog.tsx:216:13",className:"text-[var(--dg-text-muted)]",children:["(",o,")"]})]}),e.jsxs("div",{"code-path":"src/components/server/TerminalDialog.tsx:218:11",className:"flex items-center gap-1",children:[e.jsx("button",{"code-path":"src/components/server/TerminalDialog.tsx:219:13",onClick:()=>y(!n),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]",children:n?e.jsx(qr,{"code-path":"src/components/server/TerminalDialog.tsx:223:29",className:"h-4 w-4"}):e.jsx(Jr,{"code-path":"src/components/server/TerminalDialog.tsx:223:65",className:"h-4 w-4"})}),e.jsx("button",{"code-path":"src/components/server/TerminalDialog.tsx:225:13",onClick:()=>m(!1),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]",children:e.jsx(fe,{"code-path":"src/components/server/TerminalDialog.tsx:229:15",className:"h-4 w-4"})})]})]}),!k&&e.jsxs("div",{"code-path":"src/components/server/TerminalDialog.tsx:235:11",className:"p-6 flex flex-col items-center justify-center gap-4",style:{height:"480px"},children:[e.jsx(hr,{"code-path":"src/components/server/TerminalDialog.tsx:236:13",className:"h-12 w-12 text-amber-400"}),e.jsxs("div",{"code-path":"src/components/server/TerminalDialog.tsx:237:13",className:"text-center",children:[e.jsx("p",{"code-path":"src/components/server/TerminalDialog.tsx:238:15",className:"text-[var(--dg-text-primary)] font-medium mb-1",children:"服务器未配置认证凭据"}),e.jsx("p",{"code-path":"src/components/server/TerminalDialog.tsx:239:15",className:"text-sm text-[var(--dg-text-muted)]",children:"请选择一个凭据用于 SSH 连接"})]}),F.length===0?e.jsx("p",{"code-path":"src/components/server/TerminalDialog.tsx:242:15",className:"text-xs text-[var(--dg-text-muted)]",children:"暂无可用凭据,请先去「凭证配置」添加"}):e.jsxs("select",{"code-path":"src/components/server/TerminalDialog.tsx:244:15",value:u,onChange:d=>f(d.target.value),className:"w-64 px-3 py-2 bg-[var(--dg-bg-tertiary)] border border-[var(--dg-border)] rounded-md text-[var(--dg-text-primary)] text-sm",children:[e.jsx("option",{"code-path":"src/components/server/TerminalDialog.tsx:249:17",value:"",children:"-- 选择凭据 --"}),F.map(d=>e.jsxs("option",{"code-path":"src/components/server/TerminalDialog.tsx:251:19",value:String(d.id),children:[d.type==="ssh_key"?"🔑":"🔒"," ",d.name]},d.id))]}),e.jsx(g,{"code-path":"src/components/server/TerminalDialog.tsx:257:13",onClick:$,disabled:!u||h,className:"bg-[var(--dg-blue)] hover:opacity-90 text-white",children:h?"关联中...":"确认连接"})]}),k&&e.jsx("div",{"code-path":"src/components/server/TerminalDialog.tsx:268:11",ref:b,className:"bg-[#0a0e14]",style:{height:n?"calc(100vh - 49px)":"480px"}})]})})}const is=s=>s<1024?`${s} B`:s<1048576?`${(s/1024).toFixed(1)} KB`:`${(s/1048576).toFixed(2)} MB`;function vs({open:s,onOpenChange:m,serverId:a,serverName:c}){const[o,i]=t.useState([]),[b,j]=t.useState([]),[x,w]=t.useState("/"),[N,I]=t.useState(!1),[n,y]=t.useState(""),[F,T]=t.useState(!1),u=t.useRef(null),f=t.useCallback(async d=>{if(a){I(!0),y("
Line truncated
|
||||
`).replace(/\r/g,`
|
||||
`).split(`
|
||||
`).filter(o=>o.trim());if(m.length<2)return[];const a=lr(m[0]).map(o=>o.toLowerCase()),c=[];for(let o=1;o<m.length;o++){const i=lr(m[o]),b={};a.forEach((j,x)=>{b[j]=i[x]??""}),c.push(b)}return c}function gs(s){return/^(\d{1,3}\.){3}\d{1,3}$/.test(s)&&s.split(".").every(m=>Number(m)>=0&&Number(m)<=255)}function us(){const s=["hostname,ip,port","web-01,192.168.1.10,22","db-01,192.168.1.20,22","cache-01,192.168.1.30,2222"].join(`
|
||||
`),m=new Blob(["\uFEFF"+s],{type:"text/csv;charset=utf-8;"}),a=URL.createObjectURL(m),c=document.createElement("a");c.href=a,c.download="servers-template.csv",c.click(),URL.revokeObjectURL(a)}function Ss({open:s,onClose:m}){const[a,c]=t.useState(1),[o,i]=t.useState(""),[,b]=t.useState("password"),[j,x]=t.useState(null),[w,N]=t.useState(!1),[I,n]=t.useState([]),[y,F]=t.useState([]),[T,u]=t.useState(!1),[f,h]=t.useState([]),[v,k]=t.useState(""),[z,$]=t.useState("22");t.useEffect(()=>{if(!s)return;let l=!1;return(async()=>{try{const[R,D]=await Promise.all([Dr.list(),jr.list()]);if(l)return;const ee=R?.list??[];F(ee.map(M=>({id:String(M.id??""),name:M.name??"",code:M.code??""}))),h(D?.list??[])}catch{l||(F([]),h([]))}})(),()=>{l=!0}},[s]);const d=async()=>{if(a===2&&j){N(!0);try{const l=await j.text(),R=hs(l);if(R.length===0){V.error("文件无有效数据,请使用模板格式(首行为表头)"),N(!1);return}const D=new Set,ee=R.map((M,te)=>{const G=(M.hostname??"").trim(),P=(M.ip??"").trim(),K={row:te+2,hostname:G,ip:P,port:Number(M.port)||22,username:(M.username??"").trim()||"root",os:M.os??"",cpu:Number(M.cpu)||0,memory:Number(M.memory)||0,disk:Number(M.disk)||0,tags:M.tags??"",status:"valid",message:"有效"},oe=[];G||oe.push("主机名缺失"),P?gs(P)||oe.push("IP格式错误"):oe.push("IP缺失");const ve=`${G}|${P}`;return G&&P&&D.has(ve)?oe.push("重复行"):D.add(ve),oe.length>0&&(K.status="error",K.message=oe.join("、")),K});n(ee),c(a+1)}catch{V.error("文件解析失败,请确认是 CSV 格式")}finally{N(!1)}}else c(a+1)},S=()=>{a>1&&c(a-1)},_=l=>{l.target.files&&l.target.files[0]&&x(l.target.files[0])},J=()=>{c(1),i(""),$("22"),k(""),x(null),n([])},W=async()=>{const l=I.filter(R=>R.status==="valid");if(l.length!==0){u(!0);try{const R=l.map(P=>({hostname:P.hostname,ip:P.ip,port:P.port,username:P.username,os:P.os,cpu:P.cpu,memory:P.memory,disk:P.disk,tags:P.tags})),ee=await se.batchCreate({servers:R,region_id:o||void 0,credential_id:v?Number(v):void 0,default_port:Number(z)||22})??{},M=ee.success??0,te=ee.skipped??0,G=ee.failed??0;V.success(`导入完成:成功 ${M},跳过 ${te},失败 ${G}`),J(),m()}catch(R){V.error(R?.message||"导入失败,请重试")}finally{u(!1)}}},B=()=>{m(),J()},U=I.filter(l=>l.status==="valid").length,Q=I.filter(l=>l.status==="warning").length,Z=I.filter(l=>l.status==="error").length,ie=[{id:1,title:"配置"},{id:2,title:"上传"},{id:3,title:"确认"}];return e.jsx(Te,{"code-path":"src/components/server/ExcelServerImport.tsx:278:5",open:s,onOpenChange:B,children:e.jsxs(Re,{"code-path":"src/components/server/ExcelServerImport.tsx:279:7",className:"max-w-3xl bg-[var(--dg-bg-primary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]",children:[e.jsxs(Ue,{"code-path":"src/components/server/ExcelServerImport.tsx:280:9",children:[e.jsx(Me,{"code-path":"src/components/server/ExcelServerImport.tsx:281:11",className:"text-xl",children:"CSV 批量导入服务器"}),e.jsx(Be,{"code-path":"src/components/server/ExcelServerImport.tsx:282:11",className:"sr-only",children:"通过 CSV 文件批量导入服务器资产"})]}),e.jsx("div",{"code-path":"src/components/server/ExcelServerImport.tsx:286:9",className:"flex items-center justify-center mb-6",children:ie.map((l,R)=>e.jsxs("div",{"code-path":"src/components/server/ExcelServerImport.tsx:288:13",className:"flex items-center",children:[e.jsx("div",{"code-path":"src/components/server/ExcelServerImport.tsx:289:15",className:`flex items-center justify-center w-8 h-8 rounded-full ${a===l.id?"bg-blue-600 text-white":a>l.id?"bg-emerald-600 text-white":"bg-[var(--dg-bg-secondary)] text-[var(--dg-text-muted)]"}`,children:a>l.id?e.jsx(ge,{"code-path":"src/components/server/ExcelServerImport.tsx:296:32",className:"h-4 w-4"}):l.id}),e.jsx("span",{"code-path":"src/components/server/ExcelServerImport.tsx:298:15",className:`ml-2 text-sm ${a===l.id?"text-[var(--dg-text-primary)]":"text-[var(--dg-text-muted)]"}`,children:l.title}),R<ie.length-1&&e.jsx("div",{"code-path":"src/components/server/ExcelServerImport.tsx:302:17",className:"w-12 h-0.5 bg-[var(--dg-border)] mx-3"})]},l.id))}),a===1&&e.jsxs("div",{"code-path":"src/components/server/ExcelServerImport.tsx:310:11",className:"space-y-6",children:[e.jsx(me,{"code-path":"src/components/server/ExcelServerImport.tsx:312:13",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsx(xe,{"code-path":"src/components/server/ExcelServerImport.tsx:313:15",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/server/ExcelServerImport.tsx:314:17",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/server/ExcelServerImport.tsx:315:19",className:"flex items-center gap-3",children:[e.jsx("div",{"code-path":"src/components/server/ExcelServerImport.tsx:316:21",className:"w-10 h-10 rounded-lg bg-emerald-500/20 flex items-center justify-center",children:e.jsx(qe,{"code-path":"src/components/server/ExcelServerImpor
Line truncated
|
||||
`),Y=new Blob(["\uFEFF"+de],{type:"text/csv;charset=utf-8;"}),q=URL.createObjectURL(Y),ae=document.createElement("a");ae.href=q,ae.download=`servers_${new Date().toISOString().slice(0,10)}.csv`,ae.click(),URL.revokeObjectURL(q),V.success(`已导出 ${m.length} 台服务器`)},or=8;return e.jsxs("div",{"code-path":"src/components/server/ServerManager.tsx:371:5",className:"space-y-6",children:[e.jsxs("div",{"code-path":"src/components/server/ServerManager.tsx:373:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/server/ServerManager.tsx:374:9",children:[e.jsx("h1",{"code-path":"src/components/server/ServerManager.tsx:375:11",className:"text-2xl font-bold text-[var(--dg-text-primary)]",children:"服务器管理"}),e.jsx("p",{"code-path":"src/components/server/ServerManager.tsx:376:11",className:"text-sm text-[var(--dg-text-muted)] mt-1",children:"管理云平台服务器资产"})]}),e.jsxs("div",{"code-path":"src/components/server/ServerManager.tsx:378:9",className:"flex items-center gap-2",children:[e.jsxs(g,{"code-path":"src/components/server/ServerManager.tsx:379:11",variant:"outline",className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)] hover:bg-[var(--dg-bg-hover)]",onClick:()=>K(),children:[e.jsx(pe,{"code-path":"src/components/server/ServerManager.tsx:384:13",className:Se("h-4 w-4 mr-2",c&&"animate-spin")}),"刷新"]}),e.jsxs(g,{"code-path":"src/components/server/ServerManager.tsx:387:11",variant:"outline",className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)] hover:bg-[var(--dg-bg-hover)]",onClick:ne,children:[e.jsx(Ye,{"code-path":"src/components/server/ServerManager.tsx:392:13",className:"h-4 w-4 mr-2"}),"导出"]}),e.jsxs(gr,{"code-path":"src/components/server/ServerManager.tsx:395:11",children:[e.jsx(ur,{"code-path":"src/components/server/ServerManager.tsx:396:13",asChild:!0,children:e.jsxs(g,{"code-path":"src/components/server/ServerManager.tsx:397:15",variant:"outline",className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)] hover:bg-[var(--dg-bg-hover)]",children:[e.jsx(Xe,{"code-path":"src/components/server/ServerManager.tsx:398:17",className:"h-4 w-4 mr-2"}),"批量导入"]})}),e.jsxs(Sr,{"code-path":"src/components/server/ServerManager.tsx:402:13",className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)]",children:[e.jsx(br,{"code-path":"src/components/server/ServerManager.tsx:403:15",children:"选择导入方式"}),e.jsx(Ke,{"code-path":"src/components/server/ServerManager.tsx:404:15",className:"bg-[var(--dg-border)]"}),e.jsxs(we,{"code-path":"src/components/server/ServerManager.tsx:405:15",className:"hover:bg-[var(--dg-bg-hover)] cursor-pointer focus:bg-[var(--dg-bg-hover)] focus:text-[var(--dg-text-primary)]",onClick:()=>n(!0),children:[e.jsx(xr,{"code-path":"src/components/server/ServerManager.tsx:409:17",className:"h-4 w-4 mr-2 text-[var(--dg-blue)]"}),"云主机导入",e.jsx("span",{"code-path":"src/components/server/ServerManager.tsx:411:17",className:"ml-2 text-xs text-[var(--dg-text-muted)]",children:"从云平台同步"})]}),e.jsxs(we,{"code-path":"src/components/server/ServerManager.tsx:413:15",className:"hover:bg-[var(--dg-bg-hover)] cursor-pointer focus:bg-[var(--dg-bg-hover)] focus:text-[var(--dg-text-primary)]",onClick:()=>F(!0),children:[e.jsx(qe,{"code-path":"src/components/server/ServerManager.tsx:417:17",className:"h-4 w-4 mr-2 text-emerald-400"}),"CSV导入",e.jsx("span",{"code-path":"src/components/server/ServerManager.tsx:419:17",className:"ml-2 text-xs text-[var(--dg-text-muted)]",children:"hostname + IP 即可"})]})]})]}),e.jsxs(g,{"code-path":"src/components/server/ServerManager.tsx:423:11",className:"bg-[var(--dg-blue)] hover:opacity-90 text-white",onClick:Ae,children:[e.jsx(ss,{"code-path":"src/components/server/ServerManager.tsx:427:13",className:"h-4 w-4 mr-2"}),"添加服务器"]})]})]}),e.jsx(ls,{"code-path":"src/components/server/ServerManager.tsx:434:7",servers:m}),e.jsx(me,{"code-path":"src/components/server/ServerManager.tsx:437:7",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(xe,{"code-path":"src/components/server/ServerManager.tsx:438:9",className:"p-0",children:[e.jsxs("div",{"code-path":"src/components/server/ServerManager.tsx:440:11",className:"flex items-center justify-between flex-wrap gap-4 p-4",children:[e.jsxs("div",{"code-path":"src/components/server/ServerManager.tsx:441:13",className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{"code-path":"src/components/server/ServerManager.tsx:442:15",className:"relative w-64",children:[e.jsx(ir,{"code-path":"src/components/server/ServerManager.tsx:443:17",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-[var(--dg-text-muted)]"}),e.jsx(H,{"code-path":"src/components/server/ServerManager.tsx:444:17",placeholder:
Line truncated
|
||||
@@ -0,0 +1,2 @@
|
||||
import{r as o,u as q,j as s,D as Z,a as ss,b as es,c as ts,U as le,d as as,e as rs,B as x,Y as Ks,P as Ws,N as Qs,L as Ns,aQ as ve,O as de,t as qs,f as Js,_ as Xs,am as fe,V as De,W as pe,w as Bs,y as ie,l as $,x as Le}from"./index-Dmami9WE.js";import{T as Te,a as Ue,b as Vs,c as Hs}from"./tabs-lV44z_UR.js";import{B as cs}from"./badge-3UzCvU7L.js";import{C as xs,a as hs,b as Ss,c as js,d as us}from"./card-CIfC-8Rh.js";import{I as f}from"./input-NsU9nXZF.js";import{T as As,a as Ps,b as J,c as M,d as Es,e as w}from"./table-CG4mjNfb.js";import{S as Us,a as ws,b as Cs,c as Ms,d as V}from"./select-DUbxjT0z.js";import{S as vs}from"./square-pen-B3dPIBrm.js";import{U as Gs}from"./upload-CRLg7Pbj.js";import{D as xe}from"./download-Vuij9wGr.js";import{C as Ys}from"./circle-x-BBQeW1R3.js";import{R as Zs}from"./refresh-cw-CTBERyFc.js";import{S as we}from"./search-Dd-PeBfg.js";import{P as se}from"./plus-O65gX7Qz.js";import{M as Ce,P as Me}from"./phone-Cn_wSobp.js";import{T as ee}from"./trash-2-DWVnIU6o.js";import{t as H}from"./index-BuEnLCjT.js";import{T as ke}from"./textarea-DHUZ6N85.js";import{L as Ts}from"./label-Ap_-SPYI.js";import{C as Ie}from"./checkbox-DoAtRzQj.js";import{S as bs}from"./switch-TqjD2x0W.js";import{U as Re}from"./user-plus-DKeca2Dx.js";import{H as _e}from"./history-CbX6uocL.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";function Fe({open:e,onOpenChange:d,editingUser:t,form:a,setForm:m,saving:i,onSubmit:u}){const[T,N]=o.useState([]);return o.useEffect(()=>{if(!e)return;let n=!1;return(async()=>{try{const U=await q.getRoles();if(n)return;const h=U?.list??[];N(h.map(D=>({id:String(D.id??""),name:D.name??D.code??""})))}catch{n||N([])}})(),()=>{n=!0}},[e]),s.jsx(Z,{"code-path":"src/components/system/UserFormDialog.tsx:78:5",open:e,onOpenChange:d,children:s.jsxs(ss,{"code-path":"src/components/system/UserFormDialog.tsx:79:7",className:"bg-slate-900 border-slate-800",children:[s.jsxs(es,{"code-path":"src/components/system/UserFormDialog.tsx:80:9",children:[s.jsxs(ts,{"code-path":"src/components/system/UserFormDialog.tsx:81:11",className:"text-slate-100 flex items-center gap-2",children:[s.jsx(le,{"code-path":"src/components/system/UserFormDialog.tsx:82:13",className:"h-5 w-5 text-blue-400"}),t?"编辑用户":"新建用户"]}),s.jsx(as,{"code-path":"src/components/system/UserFormDialog.tsx:85:11",className:"text-slate-500",children:t?"修改用户信息":"创建新的系统用户"})]}),s.jsxs("div",{"code-path":"src/components/system/UserFormDialog.tsx:90:9",className:"space-y-4",children:[s.jsxs("div",{"code-path":"src/components/system/UserFormDialog.tsx:91:11",className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{"code-path":"src/components/system/UserFormDialog.tsx:92:13",className:"space-y-2",children:[s.jsx("label",{"code-path":"src/components/system/UserFormDialog.tsx:93:15",className:"text-xs text-slate-500",children:"用户名"}),s.jsx(f,{"code-path":"src/components/system/UserFormDialog.tsx:94:15",value:a.username,onChange:n=>m({...a,username:n.target.value}),disabled:!!t,className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-500",placeholder:"登录用户名"})]}),s.jsxs("div",{"code-path":"src/components/system/UserFormDialog.tsx:102:13",className:"space-y-2",children:[s.jsx("label",{"code-path":"src/components/system/UserFormDialog.tsx:103:15",className:"text-xs text-slate-500",children:"昵称"}),s.jsx(f,{"code-path":"src/components/system/UserFormDialog.tsx:104:15",value:a.nickname,onChange:n=>m({...a,nickname:n.target.value}),className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-500",placeholder:"显示昵称"})]}),s.jsxs("div",{"code-path":"src/components/system/UserFormDialog.tsx:111:13",className:"space-y-2",children:[s.jsx("label",{"code-path":"src/components/system/UserFormDialog.tsx:112:15",className:"text-xs text-slate-500",children:"邮箱"}),s.jsx(f,{"code-path":"src/components/system/UserFormDialog.tsx:113:15",value:a.email,onChange:n=>m({...a,email:n.target.value}),className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-500",placeholder:"user@example.com"})]}),s.jsxs("div",{"code-path":"src/components/system/UserFormDialog.tsx:120:13",className:"space-y-2",children:[s.jsx("label",{"code-path":"src/components/system/UserFormDialog.tsx:121:15",className:"text-xs text-slate-500",children:"手机号"}),s.jsx(f,{"code-path":"src/components/system/UserFormDialog.tsx:122:15",value:a.phone,onChange:n=>m({...a,phone:n.target.value}),className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-500",placeholder:"可选"})]}),s.jsxs("div",{"code-path":"src/components/system/UserFormDialog.tsx:129:13",className:"space-y-2",children:[s.jsx("label",{"code-path":"src/components/system/UserFormDialog.tsx:130:15",className:"text-xs text-slate-500",children:"角色"}),s.jsxs(Us,{"code-path":"src/components/system/UserFormDialog.tsx:131:15",value:a.role,onValueChange:n=>m({..Line truncated
|
||||
`).filter(g=>g.trim()&&!g.startsWith(""));if(c.length<2)return;const Q=c[0].split(",").map(g=>g.trim().toLowerCase()),is=Q.findIndex(g=>g.includes("用户名")||g.includes("username")),Is=Q.findIndex(g=>g.includes("昵称")||g.includes("name")||g.includes("显示名")),Rs=Q.findIndex(g=>g.includes("邮箱")||g.includes("email")||g.includes("mail")),Ds=Q.findIndex(g=>g.includes("手机")||g.includes("phone")),_s=Q.findIndex(g=>g.includes("角色")||g.includes("role")),ys=Q.findIndex(g=>g.includes("密码")||g.includes("password")),gs=[];for(let g=1;g<c.length;g++){const ms=c[g].split(",").map(Fs=>Fs.trim());gs.push({username:is>=0?ms[is]:"",nickname:Is>=0?ms[Is]:"",email:Rs>=0?ms[Rs]:"",phone:Ds>=0?ms[Ds]:"",role:_s>=0?ms[_s]:"",password:ys>=0?ms[ys]:""})}_(gs),E(null)},os.readAsText(z,"UTF-8")},Y=async()=>{L.setImporting(!0);try{const l=await q.batchImport({users:j,skip_existing:!0});E(l),await X()}catch(l){E({code:500,message:l?.message||"导入失败"})}finally{L.setImporting(!1)}};return s.jsxs("div",{"code-path":"src/components/system/SystemManager.tsx:232:5",className:"space-y-6",children:[s.jsx("div",{"code-path":"src/components/system/SystemManager.tsx:234:7",className:"flex items-center justify-between",children:s.jsxs("div",{"code-path":"src/components/system/SystemManager.tsx:235:9",children:[s.jsx("h1",{"code-path":"src/components/system/SystemManager.tsx:236:11",className:"text-2xl font-bold text-slate-100",children:"系统管理"}),s.jsx("p",{"code-path":"src/components/system/SystemManager.tsx:237:11",className:"text-sm text-slate-500 mt-1",children:"用户、权限与系统配置"})]})}),s.jsxs(Te,{"code-path":"src/components/system/SystemManager.tsx:242:7",value:a,onValueChange:m,className:"w-full",children:[s.jsxs(Ue,{"code-path":"src/components/system/SystemManager.tsx:243:9",className:"bg-slate-800 border border-slate-700",children:[s.jsxs(Vs,{"code-path":"src/components/system/SystemManager.tsx:244:11",value:"users",className:"data-[state=active]:bg-slate-700",children:[s.jsx(pe,{"code-path":"src/components/system/SystemManager.tsx:245:13",className:"h-4 w-4 mr-2"}),"用户管理"]}),s.jsxs(Vs,{"code-path":"src/components/system/SystemManager.tsx:248:11",value:"roles",className:"data-[state=active]:bg-slate-700",children:[s.jsx(qs,{"code-path":"src/components/system/SystemManager.tsx:249:13",className:"h-4 w-4 mr-2"}),"角色权限"]}),s.jsxs(Vs,{"code-path":"src/components/system/SystemManager.tsx:252:11",value:"settings",className:"data-[state=active]:bg-slate-700",children:[s.jsx(ie,{"code-path":"src/components/system/SystemManager.tsx:253:13",className:"h-4 w-4 mr-2"}),"系统设置"]})]}),s.jsx(Hs,{"code-path":"src/components/system/SystemManager.tsx:258:9",value:"users",className:"mt-4 space-y-4",children:s.jsx(Ee,{"code-path":"src/components/system/SystemManager.tsx:259:11",searchQuery:i,setSearchQuery:u,filteredUsers:ls,loading:n,selectedUser:h,setSelectedUser:D,getUserStatusBadge:ns,dialogOpen:y,setDialogOpen:R,editingUser:C,form:k,setForm:A,saving:F,handleSubmit:K,openCreate:ds,openEdit:ps,handleDelete:W,importDialogOpen:p,setImportDialogOpen:O,importPreview:j,setImportPreview:_,importing:L.importing,importResult:G,setImportResult:E,handleCsvUpload:v,handleBatchImport:Y,ldapUsers:L.ldapUsers,ldapSelected:L.ldapSelected,setLdapSelected:L.setLdapSelected,ldapLoading:L.ldapLoading,ldapImportOUs:L.ldapImportOUs,ldapImportOUDN:L.ldapImportOUDN,setLdapImportOUDN:L.setLdapImportOUDN,loadLdapUsers:L.loadLdapUsers,handleLdapImport:L.handleLdapImport,setLdapUsers:L.setLdapUsers})}),s.jsx(Hs,{"code-path":"src/components/system/SystemManager.tsx:299:9",value:"roles",className:"mt-4 space-y-4",children:s.jsx(We,{"code-path":"src/components/system/SystemManager.tsx:300:11",selectedRole:b,setSelectedRole:S})}),s.jsx(Hs,{"code-path":"src/components/system/SystemManager.tsx:306:9",value:"settings",className:"mt-4",children:s.jsx(Je,{"code-path":"src/components/system/SystemManager.tsx:307:11",...L.settingsTabProps})})]})]})}export{Tt as SystemManager};
|
||||
@@ -1,2 +0,0 @@
|
||||
import{r as o,u as q,j as s,D as X,b as G,c as Y,d as Z,a8 as le,e as ss,I as S,f as ms,B as i,P as qs,a3 as Js,N as Ws,L as Ns,S as Ne,U as re,t as Us,a as Xs,a4 as ve,aa as de,y as Vs,V as Te,E as pe,l as z,z as Le}from"./index-DfyorCky.js";import{T as De,a as fe,b as Hs,c as Ks}from"./tabs-CIh_yD4s.js";import{B as os}from"./badge-xNW8x0G1.js";import{C as xs,a as hs,b as Ss,c as js,d as us}from"./card-C55cvSHg.js";import{T as Ps,a as zs,b as J,c as U,d as Es,e as T}from"./table-5sHV4Akp.js";import{S as ws,a as Cs,b as Ms,c as Is,d as B}from"./select-D5qUzdAs.js";import{S as vs}from"./square-pen-BxUFAe0F.js";import{U as Qs}from"./upload-Ba6rlaGS.js";import{D as ie}from"./download-DoZfYs2h.js";import{C as Gs}from"./circle-x-DK79Dhg2.js";import{R as Ys}from"./refresh-cw-DUB_tAG-.js";import{P as Zs}from"./plus-CUG-9kpu.js";import{M as Ue,P as we}from"./phone-DgvWDdJl.js";import{T as se}from"./trash-2-Dx32pOzT.js";import{t as Q}from"./index-a3ybMjbR.js";import{T as Ce}from"./textarea-NXY8u32k.js";import{L as fs}from"./label-BK0h2apY.js";import{C as Me}from"./checkbox-CH0bpj6b.js";import{S as bs}from"./switch-CGiGgOnh.js";import{U as Ie}from"./user-plus-BwUWtcQl.js";import{H as ke}from"./history-D_9jPUQg.js";import"./index-CWVNW_qu.js";function Re({open:e,onOpenChange:r,editingUser:t,form:n,setForm:d,saving:x,onSubmit:D}){const[N,b]=o.useState([]);return o.useEffect(()=>{if(!e)return;let a=!1;return(async()=>{try{const u=await q.getRoles();if(a)return;const I=u?.list??[];b(I.map(L=>({id:String(L.id??""),name:L.name??L.code??""})))}catch{a||b([])}})(),()=>{a=!0}},[e]),s.jsx(X,{"code-path":"src/components/system/UserFormDialog.tsx:78:5",open:e,onOpenChange:r,children:s.jsxs(G,{"code-path":"src/components/system/UserFormDialog.tsx:79:7",className:"bg-slate-900 border-slate-800",children:[s.jsxs(Y,{"code-path":"src/components/system/UserFormDialog.tsx:80:9",children:[s.jsxs(Z,{"code-path":"src/components/system/UserFormDialog.tsx:81:11",className:"text-slate-100 flex items-center gap-2",children:[s.jsx(le,{"code-path":"src/components/system/UserFormDialog.tsx:82:13",className:"h-5 w-5 text-blue-400"}),t?"编辑用户":"新建用户"]}),s.jsx(ss,{"code-path":"src/components/system/UserFormDialog.tsx:85:11",className:"text-slate-500",children:t?"修改用户信息":"创建新的系统用户"})]}),s.jsxs("div",{"code-path":"src/components/system/UserFormDialog.tsx:90:9",className:"space-y-4",children:[s.jsxs("div",{"code-path":"src/components/system/UserFormDialog.tsx:91:11",className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{"code-path":"src/components/system/UserFormDialog.tsx:92:13",className:"space-y-2",children:[s.jsx("label",{"code-path":"src/components/system/UserFormDialog.tsx:93:15",className:"text-xs text-slate-500",children:"用户名"}),s.jsx(S,{"code-path":"src/components/system/UserFormDialog.tsx:94:15",value:n.username,onChange:a=>d({...n,username:a.target.value}),disabled:!!t,className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-500",placeholder:"登录用户名"})]}),s.jsxs("div",{"code-path":"src/components/system/UserFormDialog.tsx:102:13",className:"space-y-2",children:[s.jsx("label",{"code-path":"src/components/system/UserFormDialog.tsx:103:15",className:"text-xs text-slate-500",children:"昵称"}),s.jsx(S,{"code-path":"src/components/system/UserFormDialog.tsx:104:15",value:n.nickname,onChange:a=>d({...n,nickname:a.target.value}),className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-500",placeholder:"显示昵称"})]}),s.jsxs("div",{"code-path":"src/components/system/UserFormDialog.tsx:111:13",className:"space-y-2",children:[s.jsx("label",{"code-path":"src/components/system/UserFormDialog.tsx:112:15",className:"text-xs text-slate-500",children:"邮箱"}),s.jsx(S,{"code-path":"src/components/system/UserFormDialog.tsx:113:15",value:n.email,onChange:a=>d({...n,email:a.target.value}),className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-500",placeholder:"user@example.com"})]}),s.jsxs("div",{"code-path":"src/components/system/UserFormDialog.tsx:120:13",className:"space-y-2",children:[s.jsx("label",{"code-path":"src/components/system/UserFormDialog.tsx:121:15",className:"text-xs text-slate-500",children:"手机号"}),s.jsx(S,{"code-path":"src/components/system/UserFormDialog.tsx:122:15",value:n.phone,onChange:a=>d({...n,phone:a.target.value}),className:"bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-500",placeholder:"可选"})]}),s.jsxs("div",{"code-path":"src/components/system/UserFormDialog.tsx:129:13",className:"space-y-2",children:[s.jsx("label",{"code-path":"src/components/system/UserFormDialog.tsx:130:15",className:"text-xs text-slate-500",children:"角色"}),s.jsxs(ws,{"code-path":"src/components/system/UserFormDialog.tsx:131:15",value:n.role,onValueChange:a=>d({...n,role:a}),children:[s.jsx(Cs,{"code-path":"src/components/system/UserFormDialog.tsx:132:17",className:"bg-slate-800/50Line truncated
|
||||
`).filter(h=>h.trim()&&!h.startsWith(""));if(c.length<2)return;const K=c[0].split(",").map(h=>h.trim().toLowerCase()),is=K.findIndex(h=>h.includes("用户名")||h.includes("username")),Rs=K.findIndex(h=>h.includes("昵称")||h.includes("name")||h.includes("显示名")),Fs=K.findIndex(h=>h.includes("邮箱")||h.includes("email")||h.includes("mail")),Ls=K.findIndex(h=>h.includes("手机")||h.includes("phone")),_s=K.findIndex(h=>h.includes("角色")||h.includes("role")),ys=K.findIndex(h=>h.includes("密码")||h.includes("password")),gs=[];for(let h=1;h<c.length;h++){const ns=c[h].split(",").map(Os=>Os.trim());gs.push({username:is>=0?ns[is]:"",nickname:Rs>=0?ns[Rs]:"",email:Fs>=0?ns[Fs]:"",phone:Ls>=0?ns[Ls]:"",role:_s>=0?ns[_s]:"",password:ys>=0?ns[ys]:""})}$(gs),ts(null)},cs.readAsText(P,"UTF-8")},ps=async()=>{j.setImporting(!0);try{const l=await q.batchImport({users:g,skip_existing:!0});ts(l),await W()}catch(l){ts({code:500,message:l?.message||"导入失败"})}finally{j.setImporting(!1)}};return s.jsxs("div",{"code-path":"src/components/system/SystemManager.tsx:232:5",className:"space-y-6",children:[s.jsx("div",{"code-path":"src/components/system/SystemManager.tsx:234:7",className:"flex items-center justify-between",children:s.jsxs("div",{"code-path":"src/components/system/SystemManager.tsx:235:9",children:[s.jsx("h1",{"code-path":"src/components/system/SystemManager.tsx:236:11",className:"text-2xl font-bold text-slate-100",children:"系统管理"}),s.jsx("p",{"code-path":"src/components/system/SystemManager.tsx:237:11",className:"text-sm text-slate-500 mt-1",children:"用户、权限与系统配置"})]})}),s.jsxs(De,{"code-path":"src/components/system/SystemManager.tsx:242:7",value:n,onValueChange:d,className:"w-full",children:[s.jsxs(fe,{"code-path":"src/components/system/SystemManager.tsx:243:9",className:"bg-slate-800 border border-slate-700",children:[s.jsxs(Hs,{"code-path":"src/components/system/SystemManager.tsx:244:11",value:"users",className:"data-[state=active]:bg-slate-700",children:[s.jsx(de,{"code-path":"src/components/system/SystemManager.tsx:245:13",className:"h-4 w-4 mr-2"}),"用户管理"]}),s.jsxs(Hs,{"code-path":"src/components/system/SystemManager.tsx:248:11",value:"roles",className:"data-[state=active]:bg-slate-700",children:[s.jsx(Us,{"code-path":"src/components/system/SystemManager.tsx:249:13",className:"h-4 w-4 mr-2"}),"角色权限"]}),s.jsxs(Hs,{"code-path":"src/components/system/SystemManager.tsx:252:11",value:"settings",className:"data-[state=active]:bg-slate-700",children:[s.jsx(pe,{"code-path":"src/components/system/SystemManager.tsx:253:13",className:"h-4 w-4 mr-2"}),"系统设置"]})]}),s.jsx(Ks,{"code-path":"src/components/system/SystemManager.tsx:258:9",value:"users",className:"mt-4 space-y-4",children:s.jsx(Ae,{"code-path":"src/components/system/SystemManager.tsx:259:11",searchQuery:x,setSearchQuery:D,filteredUsers:ls,loading:a,selectedUser:I,setSelectedUser:L,getUserStatusBadge:as,dialogOpen:y,setDialogOpen:k,editingUser:f,form:C,setForm:_,saving:F,handleSubmit:V,openCreate:rs,openEdit:ds,handleDelete:v,importDialogOpen:p,setImportDialogOpen:O,importPreview:g,setImportPreview:$,importing:j.importing,importResult:es,setImportResult:ts,handleCsvUpload:H,handleBatchImport:ps,ldapUsers:j.ldapUsers,ldapSelected:j.ldapSelected,setLdapSelected:j.setLdapSelected,ldapLoading:j.ldapLoading,ldapImportOUs:j.ldapImportOUs,ldapImportOUDN:j.ldapImportOUDN,setLdapImportOUDN:j.setLdapImportOUDN,loadLdapUsers:j.loadLdapUsers,handleLdapImport:j.handleLdapImport,setLdapUsers:j.setLdapUsers})}),s.jsx(Ks,{"code-path":"src/components/system/SystemManager.tsx:299:9",value:"roles",className:"mt-4 space-y-4",children:s.jsx(Ee,{"code-path":"src/components/system/SystemManager.tsx:300:11",selectedRole:w,setSelectedRole:R})}),s.jsx(Ks,{"code-path":"src/components/system/SystemManager.tsx:306:9",value:"settings",className:"mt-4",children:s.jsx(Ve,{"code-path":"src/components/system/SystemManager.tsx:307:11",...j.settingsTabProps})})]})]})}export{gt as SystemManager};
|
||||
@@ -0,0 +1 @@
|
||||
import{i as Ue,j as e,S as Te,z as Fe,N as Je,q as Ge,s as de,G as Ke,k as qe,f as Ze,r as p,B as v,L as je,R as es,D as Ve,a as Ne,b as ve,c as Se,d as Ce,e as ss}from"./index-Dmami9WE.js";import{C as oe,a as ne,b as ts,c as os,d as ns}from"./card-CIfC-8Rh.js";import{I as Ee}from"./input-NsU9nXZF.js";import{L as ae}from"./label-Ap_-SPYI.js";import{B as _e}from"./badge-3UzCvU7L.js";import{S as ce,a as re,b as le,c as ie,d as Z}from"./select-DUbxjT0z.js";import{T as as}from"./textarea-DHUZ6N85.js";import{k as _}from"./kubernetes-D2-GnE0t.js";import{t as j}from"./index-BuEnLCjT.js";import{B as cs}from"./box-88Ol5qY-.js";import{Z as rs}from"./zap-CocSkPPl.js";import{P as Me}from"./pencil-BYahlvYT.js";import{R as ls}from"./refresh-cw-CTBERyFc.js";import{P as is}from"./plus-O65gX7Qz.js";import{S as ps}from"./save-YtnrpTd8.js";import{S as ds}from"./search-Dd-PeBfg.js";import{T as ms}from"./trash-2-DWVnIU6o.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";const us=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],$e=Ue("link-2",us),pe={cluster:"集群",loadbalancer:"Ingress",service:"Service",app:"Deployment",server:"Node",database:"数据库",external:"外部服务",custom:"自定义"},xs=[{value:"database",label:"数据库",desc:"MySQL / Redis / PostgreSQL 等"},{value:"external",label:"外部服务",desc:"外部 API / CDN / DNS 等"},{value:"custom",label:"自定义",desc:"其他自定义节点"}],X=u=>u.startsWith("custom-");function $(u,h="h-5 w-5"){switch(u){case"server":return e.jsx(Te,{"code-path":"src/components/kubernetes/topology-helpers.tsx:31:27",className:h});case"loadbalancer":return e.jsx(Ke,{"code-path":"src/components/kubernetes/topology-helpers.tsx:32:33",className:h});case"cluster":return e.jsx(de,{"code-path":"src/components/kubernetes/topology-helpers.tsx:33:28",className:h});case"app":return e.jsx(Ge,{"code-path":"src/components/kubernetes/topology-helpers.tsx:34:24",className:h});case"service":return e.jsx(Je,{"code-path":"src/components/kubernetes/topology-helpers.tsx:35:28",className:h});case"database":return e.jsx(Fe,{"code-path":"src/components/kubernetes/topology-helpers.tsx:36:29",className:h});case"external":return e.jsx(rs,{"code-path":"src/components/kubernetes/topology-helpers.tsx:37:29",className:h});case"custom":return e.jsx(cs,{"code-path":"src/components/kubernetes/topology-helpers.tsx:38:27",className:h});default:return e.jsx(Te,{"code-path":"src/components/kubernetes/topology-helpers.tsx:39:21",className:h})}}function ee(u){switch(u){case"server":return"bg-blue-500/20 text-blue-400 border-blue-500/30";case"loadbalancer":return"bg-purple-500/20 text-purple-400 border-purple-500/30";case"cluster":return"bg-cyan-500/20 text-cyan-400 border-cyan-500/30";case"app":return"bg-rose-500/20 text-rose-400 border-rose-500/30";case"service":return"bg-emerald-500/20 text-emerald-400 border-emerald-500/30";case"database":return"bg-amber-500/20 text-amber-400 border-amber-500/30";case"external":return"bg-orange-500/20 text-orange-400 border-orange-500/30";case"custom":return"bg-slate-500/20 text-slate-400 border-slate-500/30";default:return"bg-slate-500/20 text-slate-400 border-slate-500/30"}}function hs(u,h,D,z,x){const V=[],l=[],Y=Math.max(1,h.length,D.length,z.length,x.length),L=Math.max(900,Math.min(Y*130,2400)),r=[60,180,320,480,640],N=o=>{const i=Math.min(o,12);if(i===0)return[];if(i===1)return[L/2];const c=L/(i+1);return Array.from({length:i},(d,g)=>c*(g+1))},E=`cluster-${u.id}`;V.push({id:E,name:u.name||"集群",type:"cluster",x:L/2,y:r[0],data:{kind:"cluster",version:u.version,status:u.status,api_server:u.api_server,node_count:u.node_count,pod_count:u.pod_count}});const R=h.slice(0,12),B=N(R.length);R.forEach((o,i)=>{const c=`ingress-${o.id}`;V.push({id:c,name:o.name,type:"loadbalancer",x:B[i],y:r[1],data:{kind:"ingress",namespace:o.namespace,backend:o.backend,tls:o.tls,hosts:o.hosts}}),l.push({id:`e-${E}-${c}`,source:E,target:c,label:"route"})});const f=D.slice(0,12),A=N(f.length);f.forEach((o,i)=>{const c=`service-${o.id}`;V.push({id:c,name:o.name,type:"service",x:A[i],y:r[2],data:{kind:"service",namespace:o.namespace,type:o.type,cluster_ip:o.cluster_ip,external_ip:o.external_ip,selector:o.selector}})}),R.length>0&&f.length>0?R.forEach(o=>{const i=`ingress-${o.id}`,c=(o.backend||"").split(":")[0].trim();let d=f.filter(g=>g.name===c);d.length===0&&(d=f.filter(g=>g.namespace===o.namespace)),d.length===0&&(d=[f[0]]),d.forEach(g=>l.push({id:`e-${i}-service-${g.id}`,source:i,target:`service-${g.id}`,label:"→"}))}):f.length>0&&f.forEach(o=>l.push({id:`e-${E}-service-${o.id}`,source:E,target:`service-${o.id}`,label:"expose"}));const T=z.slice(0,12),F=N(T.length);T.forEach((o,i)=>{const c=`deploy-${o.id}`;V.push({id:c,name:o.name,type:"app",x:F[i],y:r[3],data:{kind:"deployment",namespace:o.namespace,replicas:o.replicas,ready_replicas:o.ready_replicas,availabLine truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{g as Ue,j as e,q as Te,G as Fe,N as Je,p as Ge,s as de,O as Ke,i as qe,a as Ze,r as p,B as v,L as je,R as es,S as ss,I as Ve,D as Ne,b as ve,c as Se,d as Ce,e as Ee,f as ts}from"./index-DfyorCky.js";import{C as oe,a as ne,b as os,c as ns,d as as}from"./card-C55cvSHg.js";import{L as ae}from"./label-BK0h2apY.js";import{B as _e}from"./badge-xNW8x0G1.js";import{S as ce,a as re,b as le,c as ie,d as Z}from"./select-D5qUzdAs.js";import{T as cs}from"./textarea-NXY8u32k.js";import{k as _}from"./kubernetes-J8O09fK7.js";import{t as j}from"./index-a3ybMjbR.js";import{B as rs}from"./box-TTGA1p57.js";import{Z as ls}from"./zap-D2uWSK32.js";import{P as Me}from"./pencil-BqUotcjf.js";import{R as is}from"./refresh-cw-DUB_tAG-.js";import{P as ps}from"./plus-CUG-9kpu.js";import{S as ds}from"./save-DoGGjfwC.js";import{T as ms}from"./trash-2-Dx32pOzT.js";import"./index-CWVNW_qu.js";const us=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],$e=Ue("link-2",us),pe={cluster:"集群",loadbalancer:"Ingress",service:"Service",app:"Deployment",server:"Node",database:"数据库",external:"外部服务",custom:"自定义"},xs=[{value:"database",label:"数据库",desc:"MySQL / Redis / PostgreSQL 等"},{value:"external",label:"外部服务",desc:"外部 API / CDN / DNS 等"},{value:"custom",label:"自定义",desc:"其他自定义节点"}],X=u=>u.startsWith("custom-");function $(u,h="h-5 w-5"){switch(u){case"server":return e.jsx(Te,{"code-path":"src/components/kubernetes/topology-helpers.tsx:31:27",className:h});case"loadbalancer":return e.jsx(Ke,{"code-path":"src/components/kubernetes/topology-helpers.tsx:32:33",className:h});case"cluster":return e.jsx(de,{"code-path":"src/components/kubernetes/topology-helpers.tsx:33:28",className:h});case"app":return e.jsx(Ge,{"code-path":"src/components/kubernetes/topology-helpers.tsx:34:24",className:h});case"service":return e.jsx(Je,{"code-path":"src/components/kubernetes/topology-helpers.tsx:35:28",className:h});case"database":return e.jsx(Fe,{"code-path":"src/components/kubernetes/topology-helpers.tsx:36:29",className:h});case"external":return e.jsx(ls,{"code-path":"src/components/kubernetes/topology-helpers.tsx:37:29",className:h});case"custom":return e.jsx(rs,{"code-path":"src/components/kubernetes/topology-helpers.tsx:38:27",className:h});default:return e.jsx(Te,{"code-path":"src/components/kubernetes/topology-helpers.tsx:39:21",className:h})}}function ee(u){switch(u){case"server":return"bg-blue-500/20 text-blue-400 border-blue-500/30";case"loadbalancer":return"bg-purple-500/20 text-purple-400 border-purple-500/30";case"cluster":return"bg-cyan-500/20 text-cyan-400 border-cyan-500/30";case"app":return"bg-rose-500/20 text-rose-400 border-rose-500/30";case"service":return"bg-emerald-500/20 text-emerald-400 border-emerald-500/30";case"database":return"bg-amber-500/20 text-amber-400 border-amber-500/30";case"external":return"bg-orange-500/20 text-orange-400 border-orange-500/30";case"custom":return"bg-slate-500/20 text-slate-400 border-slate-500/30";default:return"bg-slate-500/20 text-slate-400 border-slate-500/30"}}function hs(u,h,D,Y,x){const V=[],l=[],z=Math.max(1,h.length,D.length,Y.length,x.length),L=Math.max(900,Math.min(z*130,2400)),r=[60,180,320,480,640],N=o=>{const i=Math.min(o,12);if(i===0)return[];if(i===1)return[L/2];const c=L/(i+1);return Array.from({length:i},(d,g)=>c*(g+1))},E=`cluster-${u.id}`;V.push({id:E,name:u.name||"集群",type:"cluster",x:L/2,y:r[0],data:{kind:"cluster",version:u.version,status:u.status,api_server:u.api_server,node_count:u.node_count,pod_count:u.pod_count}});const R=h.slice(0,12),B=N(R.length);R.forEach((o,i)=>{const c=`ingress-${o.id}`;V.push({id:c,name:o.name,type:"loadbalancer",x:B[i],y:r[1],data:{kind:"ingress",namespace:o.namespace,backend:o.backend,tls:o.tls,hosts:o.hosts}}),l.push({id:`e-${E}-${c}`,source:E,target:c,label:"route"})});const f=D.slice(0,12),A=N(f.length);f.forEach((o,i)=>{const c=`service-${o.id}`;V.push({id:c,name:o.name,type:"service",x:A[i],y:r[2],data:{kind:"service",namespace:o.namespace,type:o.type,cluster_ip:o.cluster_ip,external_ip:o.external_ip,selector:o.selector}})}),R.length>0&&f.length>0?R.forEach(o=>{const i=`ingress-${o.id}`,c=(o.backend||"").split(":")[0].trim();let d=f.filter(g=>g.name===c);d.length===0&&(d=f.filter(g=>g.namespace===o.namespace)),d.length===0&&(d=[f[0]]),d.forEach(g=>l.push({id:`e-${i}-service-${g.id}`,source:i,target:`service-${g.id}`,label:"→"}))}):f.length>0&&f.forEach(o=>l.push({id:`e-${E}-service-${o.id}`,source:E,target:`service-${o.id}`,label:"expose"}));const T=Y.slice(0,12),F=N(T.length);T.forEach((o,i)=>{const c=`deploy-${o.id}`;V.push({id:c,name:o.name,type:"app",x:F[i],y:r[3],data:{kind:"deployment",namespace:o.namespace,replicas:o.replicas,ready_replicas:o.ready_replicas,available_replicas:o.available_replicas,image:o.image}})}),f.length>0&&T.length>0&&f.forEach(o=>{const i=`s
Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{r,j as e,B as y,O as le,J as he,D as Q,a as q,b as H,c as J,Q as ge,d as Z,a4 as w,a5 as ue,C as Te,P as je,V as Me,o as Ne,a6 as fe,S as ve}from"./index-Dmami9WE.js";import{I as ye}from"./input-NsU9nXZF.js";import{B as j}from"./badge-3UzCvU7L.js";import{C as M,a as N,b as S,c as b}from"./card-CIfC-8Rh.js";import{S as we}from"./stat-strip-BteRU1Iu.js";import{S as C,a as D,b as I,c as L,d as n}from"./select-DUbxjT0z.js";import{T as Se,a as be,b as O,c as R}from"./tabs-lV44z_UR.js";import{L as s}from"./label-Ap_-SPYI.js";import{t as B}from"./index-BuEnLCjT.js";import{t as F}from"./monitor-CicbJUrQ.js";import{S as Ce}from"./search-Dd-PeBfg.js";import{R as De}from"./refresh-cw-CTBERyFc.js";import{T as Ie}from"./trending-up-d1DKmRom.js";import{C as Le}from"./circle-x-BBQeW1R3.js";import{C as Oe}from"./code-BAhZJUYV.js";import{B as Re}from"./box-88Ol5qY-.js";import{Z as Be}from"./zap-CocSkPPl.js";import{A as Fe}from"./arrow-right-CkKR0P0R.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";const aa=()=>{const[k,G]=r.useState([]),[p,K]=r.useState([]),[U,A]=r.useState(!1),[f,X]=r.useState(""),[l,W]=r.useState("all"),[h,Y]=r.useState("all"),[g,_]=r.useState("1h"),[ee,ae]=r.useState("traces"),[m,te]=r.useState(null),[o,re]=r.useState(null),[ce,E]=r.useState(!1),[se,$]=r.useState(!1);r.useEffect(()=>{oe()},[g]);const oe=async()=>{await Promise.all([P(),ne()])},P=async()=>{A(!0);try{const a=await F.getTraces({timeRange:g,service:l,status:h});G(a.data||[])}catch{B.error("获取链路数据失败")}finally{A(!1)}},ne=async()=>{try{const a=await F.getServices(g);K(a.data||[])}catch{B.error("获取服务数据失败")}},me=async a=>{try{return(await F.getTraceDetail(a)).data}catch{return B.error("获取链路详情失败"),null}},v=a=>{switch(a){case"success":return e.jsxs(j,{"code-path":"src/components/monitor/trace/TraceManager.tsx:141:16",variant:"default",className:"bg-green-500 gap-1",children:[e.jsx(je,{"code-path":"src/components/monitor/trace/TraceManager.tsx:141:72",className:"w-3 h-3"}),"成功"]});case"error":return e.jsxs(j,{"code-path":"src/components/monitor/trace/TraceManager.tsx:143:16",variant:"destructive",className:"gap-1",children:[e.jsx(Le,{"code-path":"src/components/monitor/trace/TraceManager.tsx:143:63",className:"w-3 h-3"}),"错误"]});case"pending":return e.jsxs(j,{"code-path":"src/components/monitor/trace/TraceManager.tsx:145:16",variant:"outline",className:"gap-1",children:[e.jsx(Te,{"code-path":"src/components/monitor/trace/TraceManager.tsx:145:59",className:"w-3 h-3"}),"进行中"]});default:return e.jsx(j,{"code-path":"src/components/monitor/trace/TraceManager.tsx:147:16",variant:"secondary",children:"未知"})}},ie=a=>{switch(a){case"client":return e.jsx(Fe,{"code-path":"src/components/monitor/trace/TraceManager.tsx:153:29",className:"w-4 h-4"});case"server":return e.jsx(ve,{"code-path":"src/components/monitor/trace/TraceManager.tsx:154:29",className:"w-4 h-4"});case"producer":return e.jsx(Be,{"code-path":"src/components/monitor/trace/TraceManager.tsx:155:31",className:"w-4 h-4"});case"consumer":return e.jsx(Re,{"code-path":"src/components/monitor/trace/TraceManager.tsx:156:31",className:"w-4 h-4"});default:return e.jsx(Oe,{"code-path":"src/components/monitor/trace/TraceManager.tsx:157:23",className:"w-4 h-4"})}},de=a=>{switch(a){case"success":return"bg-green-500";case"error":return"bg-red-500";case"pending":return"bg-yellow-500";default:return"bg-gray-500"}},i=a=>a<1?`${(a*1e3).toFixed(2)}μs`:a<1e3?`${a.toFixed(2)}ms`:`${(a/1e3).toFixed(2)}s`,V=k.filter(a=>{const t=a.traceId.toLowerCase().includes(f.toLowerCase())||a.operationName.toLowerCase().includes(f.toLowerCase()),d=l==="all"||a.serviceName===l,c=h==="all"||a.status===h;return t&&d&&c}),pe=Array.from(new Set(k.map(a=>a.serviceName))),xe=a=>{const t=new Map,d=[];return a.forEach(c=>{t.set(c.spanId,{...c,children:[]})}),a.forEach(c=>{const u=t.get(c.spanId);if(c.parentSpanId&&t.has(c.parentSpanId)){const x=t.get(c.parentSpanId);x.children=x.children||[],x.children.push(u)}else d.push(u)}),d},z=({span:a,level:t,totalDuration:d})=>{const[c,u]=r.useState(!0),x=d>0?a.duration/d*100:0;return e.jsxs("div",{"code-path":"src/components/monitor/trace/TraceManager.tsx:216:7",className:"select-none",children:[e.jsxs("div",{"code-path":"src/components/monitor/trace/TraceManager.tsx:217:9",className:"flex items-center py-2 hover:bg-muted/50 cursor-pointer border-l-2 border-transparent hover:border-blue-500",style:{paddingLeft:`${t*24+12}px`},onClick:()=>{re(a),$(!0)},children:[a.children?.length>0&&e.jsx(y,{"code-path":"src/components/monitor/trace/TraceManager.tsx:223:13",variant:"ghost",size:"sm",className:"h-4 w-4 p-0 mr-1",onClick:T=>{T.stopPropagation(),u(!c)},children:c?e.jsx(Me,{"code-path":"src/components/monitor/trace/TraceManager.tsx:229:27",className:"w-3 h-3"}):e.jsx(Ne,{"code-path":"src/components/monitor/trace/TraceManager.tsx:229:65",className:"w-3 h-3"})}),!a.children?.length&&e.jsx("span",{"code-path":"src/compLine truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{r,j as e,A as ge,$ as z,x as H,S as Te,I as ue,B as y,U as je,K as Me,D as K,b as Q,c as U,d as Z,a0 as Ne,e as G,a1 as w,a2 as fe,a3 as ve,a4 as ye,n as we,q as be}from"./index-DfyorCky.js";import{B as N}from"./badge-xNW8x0G1.js";import{C as p,a as x,b,c as S}from"./card-C55cvSHg.js";import{S as C,a as D,b as I,c as L,d as n}from"./select-D5qUzdAs.js";import{T as Se,a as Ce,b as R,c as A}from"./tabs-CIh_yD4s.js";import{L as s}from"./label-BK0h2apY.js";import{t as B}from"./index-a3ybMjbR.js";import{t as F}from"./monitor-BAaBXIsC.js";import{L as De}from"./layers-FW4KKJMi.js";import{R as Ie}from"./refresh-cw-DUB_tAG-.js";import{T as Le}from"./trending-up-CdusV6gc.js";import{C as Re}from"./circle-x-DK79Dhg2.js";import{C as Ae}from"./code-L62jFLTC.js";import{B as Be}from"./box-TTGA1p57.js";import{Z as Fe}from"./zap-D2uWSK32.js";import{A as Oe}from"./arrow-right-DyIltvNZ.js";import"./index-CWVNW_qu.js";const _e=()=>{const[O,J]=r.useState([]),[l,X]=r.useState([]),[W,k]=r.useState(!1),[f,Y]=r.useState(""),[g,_]=r.useState("all"),[T,ee]=r.useState("all"),[u,ae]=r.useState("1h"),[te,re]=r.useState("traces"),[m,ce]=r.useState(null),[o,se]=r.useState(null),[oe,E]=r.useState(!1),[ne,$]=r.useState(!1);r.useEffect(()=>{me()},[u]);const me=async()=>{await Promise.all([P(),de()])},P=async()=>{k(!0);try{const a=await F.getTraces({timeRange:u,service:g,status:T});J(a.data||[])}catch{B.error("获取链路数据失败")}finally{k(!1)}},de=async()=>{try{const a=await F.getServices(u);X(a.data||[])}catch{B.error("获取服务数据失败")}},ie=async a=>{try{return(await F.getTraceDetail(a)).data}catch{return B.error("获取链路详情失败"),null}},v=a=>{switch(a){case"success":return e.jsxs(N,{"code-path":"src/components/monitor/trace/TraceManager.tsx:140:16",variant:"default",className:"bg-green-500 gap-1",children:[e.jsx(ve,{"code-path":"src/components/monitor/trace/TraceManager.tsx:140:72",className:"w-3 h-3"}),"成功"]});case"error":return e.jsxs(N,{"code-path":"src/components/monitor/trace/TraceManager.tsx:142:16",variant:"destructive",className:"gap-1",children:[e.jsx(Re,{"code-path":"src/components/monitor/trace/TraceManager.tsx:142:63",className:"w-3 h-3"}),"错误"]});case"pending":return e.jsxs(N,{"code-path":"src/components/monitor/trace/TraceManager.tsx:144:16",variant:"outline",className:"gap-1",children:[e.jsx(H,{"code-path":"src/components/monitor/trace/TraceManager.tsx:144:59",className:"w-3 h-3"}),"进行中"]});default:return e.jsx(N,{"code-path":"src/components/monitor/trace/TraceManager.tsx:146:16",variant:"secondary",children:"未知"})}},pe=a=>{switch(a){case"client":return e.jsx(Oe,{"code-path":"src/components/monitor/trace/TraceManager.tsx:152:29",className:"w-4 h-4"});case"server":return e.jsx(be,{"code-path":"src/components/monitor/trace/TraceManager.tsx:153:29",className:"w-4 h-4"});case"producer":return e.jsx(Fe,{"code-path":"src/components/monitor/trace/TraceManager.tsx:154:31",className:"w-4 h-4"});case"consumer":return e.jsx(Be,{"code-path":"src/components/monitor/trace/TraceManager.tsx:155:31",className:"w-4 h-4"});default:return e.jsx(Ae,{"code-path":"src/components/monitor/trace/TraceManager.tsx:156:23",className:"w-4 h-4"})}},xe=a=>{switch(a){case"success":return"bg-green-500";case"error":return"bg-red-500";case"pending":return"bg-yellow-500";default:return"bg-gray-500"}},d=a=>a<1?`${(a*1e3).toFixed(2)}μs`:a<1e3?`${a.toFixed(2)}ms`:`${(a/1e3).toFixed(2)}s`,V=O.filter(a=>{const t=a.traceId.toLowerCase().includes(f.toLowerCase())||a.operationName.toLowerCase().includes(f.toLowerCase()),i=g==="all"||a.serviceName===g,c=T==="all"||a.status===T;return t&&i&&c}),le=Array.from(new Set(O.map(a=>a.serviceName))),he=a=>{const t=new Map,i=[];return a.forEach(c=>{t.set(c.spanId,{...c,children:[]})}),a.forEach(c=>{const j=t.get(c.spanId);if(c.parentSpanId&&t.has(c.parentSpanId)){const h=t.get(c.parentSpanId);h.children=h.children||[],h.children.push(j)}else i.push(j)}),i},q=({span:a,level:t,totalDuration:i})=>{const[c,j]=r.useState(!0),h=i>0?a.duration/i*100:0;return e.jsxs("div",{"code-path":"src/components/monitor/trace/TraceManager.tsx:215:7",className:"select-none",children:[e.jsxs("div",{"code-path":"src/components/monitor/trace/TraceManager.tsx:216:9",className:"flex items-center py-2 hover:bg-muted/50 cursor-pointer border-l-2 border-transparent hover:border-blue-500",style:{paddingLeft:`${t*24+12}px`},onClick:()=>{se(a),$(!0)},children:[a.children?.length>0&&e.jsx(y,{"code-path":"src/components/monitor/trace/TraceManager.tsx:222:13",variant:"ghost",size:"sm",className:"h-4 w-4 p-0 mr-1",onClick:M=>{M.stopPropagation(),j(!c)},children:c?e.jsx(ye,{"code-path":"src/components/monitor/trace/TraceManager.tsx:228:27",className:"w-3 h-3"}):e.jsx(we,{"code-path":"src/components/monitor/trace/TraceManager.tsx:228:65",className:"w-3 h-3"})}),!a.children?.length&&e.jsx("span",{"code-path":"src/components/monitor/trace/TraceManager.tsx:231:38",className:"w-5"}),e.jsxs("div",{"code-path":"src/compoLine truncated
|
||||
@@ -0,0 +1 @@
|
||||
import{i as R,f as F,r as o,j as e,B as t,L as I,W as w,t as O,D as T,a as _,b as A,c as H}from"./index-Dmami9WE.js";import{I as u}from"./input-NsU9nXZF.js";import{B as $}from"./badge-3UzCvU7L.js";import{L as y}from"./label-Ap_-SPYI.js";import{t as a}from"./index-BuEnLCjT.js";import{d as n}from"./deploy-CD5bEXt-.js";import{R as q}from"./refresh-cw-CTBERyFc.js";import{P as K}from"./plus-O65gX7Qz.js";import{P as W}from"./pencil-BYahlvYT.js";import{T as X}from"./trash-2-DWVnIU6o.js";import{U as J}from"./user-plus-DKeca2Dx.js";const Q=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]],V=R("user-x",Q);function le(){const g=F(),[G,k]=o.useState([]),[C,M]=o.useState(!0),[S,D]=o.useState({}),[z,p]=o.useState(!1),[l,U]=o.useState(null),[i,m]=o.useState(""),[x,h]=o.useState(""),[j,f]=o.useState(!1),[v,N]=o.useState({}),c=async()=>{M(!0);try{const s=await n.getGroups();k(s?.list||[])}catch{a.error("加载失败")}finally{M(!1)}};o.useEffect(()=>{c()},[]);const E=async()=>{if(!i.trim()){a.error("请输入组名");return}f(!0);try{l?await n.updateGroup(l,{name:i,description:x}):await n.createGroup({name:i,description:x}),a.success(l?"已更新":"已创建"),p(!1),c()}catch{a.error("操作失败")}finally{f(!1)}},L=async s=>{if(await g({title:"删除用户组",description:`确定删除「${s.name}」?所有成员和流水线授权将同时移除。`,variant:"destructive"}))try{await n.deleteGroup(s.id),a.success("已删除"),c()}catch{a.error("删除失败")}},b=async s=>{const r=(v[s]||"").trim();if(!r){a.error("输入用户名");return}try{await n.addGroupMember(s,{username:r}),a.success("已添加"),c(),N(d=>({...d,[s]:""}))}catch{a.error("添加失败")}},P=async(s,r,d)=>{if(await g({title:"移除成员",description:`确定从组中移除「${d}」?`}))try{await n.removeGroupMember(s,r),a.success("已移除"),c()}catch{a.error("移除失败")}},B=s=>D(r=>({...r,[s]:!r[s]}));return e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:81:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:82:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:83:9",children:[e.jsx("h2",{"code-path":"src/components/deploy/UserGroupsManager.tsx:84:11",className:"text-lg font-semibold text-[var(--dg-text-primary)]",children:"用户组管理"}),e.jsx("p",{"code-path":"src/components/deploy/UserGroupsManager.tsx:85:11",className:"text-sm text-[var(--dg-text-secondary)] mt-1",children:"创建用户组,将组授权给流水线,组内成员自动获得流水线权限"})]}),e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:87:9",className:"flex items-center gap-2",children:[e.jsxs(t,{"code-path":"src/components/deploy/UserGroupsManager.tsx:88:11",variant:"outline",size:"sm",onClick:c,children:[e.jsx(q,{"code-path":"src/components/deploy/UserGroupsManager.tsx:88:68",className:"w-4 h-4 mr-1"}),"刷新"]}),e.jsxs(t,{"code-path":"src/components/deploy/UserGroupsManager.tsx:89:11",size:"sm",onClick:()=>{U(null),m(""),h(""),p(!0)},children:[e.jsx(K,{"code-path":"src/components/deploy/UserGroupsManager.tsx:90:13",className:"w-4 h-4 mr-1"}),"新建用户组"]})]})]}),C?e.jsx("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:96:9",className:"flex justify-center py-12",children:e.jsx(I,{"code-path":"src/components/deploy/UserGroupsManager.tsx:96:52",className:"w-6 h-6 animate-spin text-[var(--dg-text-secondary)]"})}):G.length===0?e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:98:9",className:"text-center py-12 text-[var(--dg-text-secondary)]",children:[e.jsx(w,{"code-path":"src/components/deploy/UserGroupsManager.tsx:99:11",className:"w-10 h-10 mx-auto mb-3 opacity-30"}),e.jsx("p",{"code-path":"src/components/deploy/UserGroupsManager.tsx:100:11",children:"暂无用户组,点击「新建用户组」创建"})]}):e.jsx("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:103:9",className:"space-y-3",children:G.map(s=>e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:105:13",className:"border border-[var(--dg-border)] rounded-lg bg-[var(--dg-bg-secondary)]",children:[e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:106:15",className:"flex items-center justify-between p-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:107:17",className:"flex items-center gap-3",style:{cursor:"pointer"},onClick:()=>B(s.id),children:[e.jsx(O,{"code-path":"src/components/deploy/UserGroupsManager.tsx:108:19",className:"w-5 h-5 text-blue-400"}),e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:109:19",children:[e.jsx("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:110:Line truncated
|
||||
@@ -1 +0,0 @@
|
||||
import{g as R,a as F,r as o,j as e,B as t,L as I,aa as w,t as O,I as u,D as T,b as _,c as A,d as H}from"./index-DfyorCky.js";import{B as $}from"./badge-xNW8x0G1.js";import{L as y}from"./label-BK0h2apY.js";import{t as a}from"./index-a3ybMjbR.js";import{d as n}from"./deploy-B3Sg3N1U.js";import{R as q}from"./refresh-cw-DUB_tAG-.js";import{P as K}from"./plus-CUG-9kpu.js";import{P as X}from"./pencil-BqUotcjf.js";import{T as J}from"./trash-2-Dx32pOzT.js";import{U as Q}from"./user-plus-BwUWtcQl.js";const V=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]],W=R("user-x",V);function de(){const g=F(),[G,k]=o.useState([]),[C,M]=o.useState(!0),[S,D]=o.useState({}),[z,p]=o.useState(!1),[l,U]=o.useState(null),[i,m]=o.useState(""),[x,h]=o.useState(""),[j,v]=o.useState(!1),[f,N]=o.useState({}),c=async()=>{M(!0);try{const s=await n.getGroups();k(s?.list||[])}catch{a.error("加载失败")}finally{M(!1)}};o.useEffect(()=>{c()},[]);const E=async()=>{if(!i.trim()){a.error("请输入组名");return}v(!0);try{l?await n.updateGroup(l,{name:i,description:x}):await n.createGroup({name:i,description:x}),a.success(l?"已更新":"已创建"),p(!1),c()}catch{a.error("操作失败")}finally{v(!1)}},L=async s=>{if(await g({title:"删除用户组",description:`确定删除「${s.name}」?所有成员和流水线授权将同时移除。`,variant:"destructive"}))try{await n.deleteGroup(s.id),a.success("已删除"),c()}catch{a.error("删除失败")}},b=async s=>{const r=(f[s]||"").trim();if(!r){a.error("输入用户名");return}try{await n.addGroupMember(s,{username:r}),a.success("已添加"),c(),N(d=>({...d,[s]:""}))}catch{a.error("添加失败")}},P=async(s,r,d)=>{if(await g({title:"移除成员",description:`确定从组中移除「${d}」?`}))try{await n.removeGroupMember(s,r),a.success("已移除"),c()}catch{a.error("移除失败")}},B=s=>D(r=>({...r,[s]:!r[s]}));return e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:81:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:82:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:83:9",children:[e.jsx("h2",{"code-path":"src/components/deploy/UserGroupsManager.tsx:84:11",className:"text-lg font-semibold text-[var(--dg-text-primary)]",children:"用户组管理"}),e.jsx("p",{"code-path":"src/components/deploy/UserGroupsManager.tsx:85:11",className:"text-sm text-[var(--dg-text-secondary)] mt-1",children:"创建用户组,将组授权给流水线,组内成员自动获得流水线权限"})]}),e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:87:9",className:"flex items-center gap-2",children:[e.jsxs(t,{"code-path":"src/components/deploy/UserGroupsManager.tsx:88:11",variant:"outline",size:"sm",onClick:c,children:[e.jsx(q,{"code-path":"src/components/deploy/UserGroupsManager.tsx:88:68",className:"w-4 h-4 mr-1"}),"刷新"]}),e.jsxs(t,{"code-path":"src/components/deploy/UserGroupsManager.tsx:89:11",size:"sm",onClick:()=>{U(null),m(""),h(""),p(!0)},children:[e.jsx(K,{"code-path":"src/components/deploy/UserGroupsManager.tsx:90:13",className:"w-4 h-4 mr-1"}),"新建用户组"]})]})]}),C?e.jsx("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:96:9",className:"flex justify-center py-12",children:e.jsx(I,{"code-path":"src/components/deploy/UserGroupsManager.tsx:96:52",className:"w-6 h-6 animate-spin text-[var(--dg-text-secondary)]"})}):G.length===0?e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:98:9",className:"text-center py-12 text-[var(--dg-text-secondary)]",children:[e.jsx(w,{"code-path":"src/components/deploy/UserGroupsManager.tsx:99:11",className:"w-10 h-10 mx-auto mb-3 opacity-30"}),e.jsx("p",{"code-path":"src/components/deploy/UserGroupsManager.tsx:100:11",children:"暂无用户组,点击「新建用户组」创建"})]}):e.jsx("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:103:9",className:"space-y-3",children:G.map(s=>e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:105:13",className:"border border-[var(--dg-border)] rounded-lg bg-[var(--dg-bg-secondary)]",children:[e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:106:15",className:"flex items-center justify-between p-4",children:[e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:107:17",className:"flex items-center gap-3",style:{cursor:"pointer"},onClick:()=>B(s.id),children:[e.jsx(O,{"code-path":"src/components/deploy/UserGroupsManager.tsx:108:19",className:"w-5 h-5 text-blue-400"}),e.jsxs("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:109:19",children:[e.jsx("div",{"code-path":"src/components/deploy/UserGroupsManager.tsx:110:21",className:"font-medium text-Line truncated
|
||||
+2
-2
@@ -1,2 +1,2 @@
|
||||
import{i as Ue,k as Te,z as Re,r as d,j as e,B as x,p as ne,R as Le,F as $e,E as Ae,G as Me,v as he,A as ze,H as Be}from"./index-DfyorCky.js";import{C as V,a as W,b as y,c as S}from"./card-C55cvSHg.js";import{B as j}from"./badge-xNW8x0G1.js";import{T as ce,a as le,b as C,c as h,d as de,e as i}from"./table-5sHV4Akp.js";import{k as U}from"./kubernetes-J8O09fK7.js";import{u as Oe}from"./use-toast-CrSOP4cJ.js";import{Y as ie,S as w,f as me,s as I,P as Fe,a as He}from"./PodFileBrowser-BySN2XGN.js";import{A as _e}from"./arrow-left-BDgGyrD0.js";import{T as Ye}from"./tag-0HCfq8kH.js";import{H as De}from"./hard-drive-BbPmnARR.js";import{M as Ee}from"./minus-UVrx3jLc.js";import{P as Ie}from"./plus-CUG-9kpu.js";import"./copy-DXW4LnkN.js";import"./sparkles-Bld4NX5y.js";import"./save-DoGGjfwC.js";import"./select-D5qUzdAs.js";import"./index-CWVNW_qu.js";import"./xterm-DSqgeKvr.js";import"./box-TTGA1p57.js";import"./rotate-cw-5qcj_h_q.js";import"./minimize-2-CiCQYRfn.js";import"./upload-Ba6rlaGS.js";import"./refresh-cw-DUB_tAG-.js";import"./folder-DoMwqvzv.js";import"./download-DoZfYs2h.js";function n({label:t,value:m,sub:P,color:u}){return e.jsx(V,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:28:5",className:"bg-slate-900 border-slate-800",children:e.jsxs(W,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:29:7",className:"p-3",children:[e.jsx("p",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:30:9",className:"text-xs text-slate-500",children:t}),e.jsx("p",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:31:9",className:"text-base font-bold mt-0.5",style:{color:u||"#e2e8f0"},children:m}),P&&e.jsx("p",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:32:17",className:"text-[10px] text-slate-600 mt-0.5",children:P})]})})}function pe({labels:t}){const m=Object.entries(t||{});return m.length===0?e.jsx("span",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:41:36",className:"text-xs text-slate-600",children:"无"}):e.jsx("div",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:43:5",className:"flex flex-wrap gap-1.5",children:m.map(([P,u])=>e.jsxs(j,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:45:9",variant:"outline",className:"border-slate-700 text-slate-400 text-[10px] font-mono",children:[P,"=",u]},P))})}function gs(){const t=Ue(),m=Te(),P=Re(),{toast:u}=Oe(),o=t.clusterCode||"",r=t.namespace||"",c=t.name||"",p=P.pathname.includes("/DaemonSet/")?"DaemonSet":"StatefulSet",T=t.mode==="yaml"?"yaml":"view",[N,ke]=d.useState(null),[R,ue]=d.useState([]),[be,J]=d.useState(!0),[ge,L]=d.useState(!1),[v,F]=d.useState(1),[$,A]=d.useState(!1),[H,q]=d.useState(null),[_,G]=d.useState(null),[we,K]=d.useState(!1),M=d.useCallback(async()=>{J(!0);try{const[s,l]=await Promise.all([U.getResourceYaml(o,r,p.toLowerCase()+"s",c).catch(()=>""),U.getPods(o).catch(()=>[])]);let f=null;if(s&&typeof s=="string")try{f=JSON.parse(s)}catch{f={_raw:s}}else s&&typeof s=="object"&&(f=s);ke(f);const E=(Array.isArray(l)?l:l?.list||l?.data||[]).filter(O=>{const Ce=O.name||O.metadata?.name||"",re=O.namespace||O.namespace_name||"";return Ce.startsWith(c)&&(!re||re===r)});ue(E)}catch(s){console.error("load error",s)}finally{J(!1)}},[o,r,c,p]);d.useEffect(()=>{M()},[M]);const Q=s=>{s!==T&&m(`/kubernetes/${o}/namespace/${r}/workload/${s}/${p}/${c}`,{replace:!0})},je=async()=>{if(confirm(`确认重启 ${p} ${c}?
|
||||
将触发滚动重启。`)){A(!0);try{p==="StatefulSet"?await U.restartStatefulSet(o,r,c):await U.restartDaemonSet(o,r,c),u({title:"重启指令已下发",description:`${p} 滚动重启已触发`}),setTimeout(M,1e3)}catch(s){u({title:"重启失败",description:s?.message||String(s),variant:"destructive"})}finally{A(!1)}}},Pe=async()=>{A(!0);try{await U.scaleStatefulSet(o,r,c,v),u({title:"扩缩容成功",description:`StatefulSet 副本数已更新为 ${v}`}),L(!1),setTimeout(M,1e3)}catch(s){u({title:"扩缩容失败",description:s?.message||String(s),variant:"destructive"})}finally{A(!1)}},k=N?.spec||{},b=N?.status||{},X=k?.template?.spec?.containers||[],Z=k?.template?.spec?.initContainers||[],z=k.replicas??1,ee=b.readyReplicas??0,Ve=b.currentReplicas??0,We=b.updatedReplicas??0,Y=b.desiredNumberScheduled??0,Ne=b.currentNumberScheduled??0,se=b.numberReady??0,fe=b.numberAvailable??0,ve=b.updatedNumberScheduled??0,g=p==="StatefulSet",B=g?ee===z&&z>0:se===Y&&Y>0,a=k.updateStrategy||{},D=a.type||"RollingUpdate",te=k.volumeClaimTemplates||[],ye=k.selector?.matchLabels||{},Se=N?.metadata?.labels||{},ae=N?.metadata?.annotations||{};return e.jsxs("div",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:183:5",className:"p-4 space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:185:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:186:9",className:"flex items-center gap-3",children:[e.jsx(x,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:187:11",variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-slate-200",onClick:()=>m(-1),children:e.jsx(_e,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:188:13",className:"h-4 w-4"})}),e.jsx(ne,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:190:11",className:"h-5 w-5 text-blue-400"}),e.jsxs("div",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:191:11",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:192:13",className:"flex items-center gap-2",children:[e.jsx("h1",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:193:15",className:"text-lg font-bold text-slate-100",children:c}),e.jsx(j,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:194:15",variant:"outline",className:"border-slate-700 text-slate-400",children:p}),e.jsx(j,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:195:15",variant:"outline",className:"border-slate-700 text-slate-400",children:r}),B?e.jsx(j,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:197:19",className:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30",children:"健康"}):e.jsx(j,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:198:19",className:"bg-amber-500/20 text-amber-400 border-amber-500/30",children:"更新中"})]}),e.jsxs("p",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:200:13",className:"text-xs text-slate-500 mt-0.5",children:["集群: ",o]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:203:9",className:"flex items-center gap-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:205:11",className:"flex items-center gap-1 bg-slate-900 border border-slate-800 rounded-lg p-0.5",children:[e.jsx("button",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:206:13",className:`px-3 py-1 text-xs rounded transition-colors ${T==="view"?"bg-blue-500/20 text-blue-400":"text-slate-400 hover:text-slate-200"}`,onClick:()=>Q("view"),children:"查看"}),e.jsx("button",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:210:13",className:`px-3 py-1 text-xs rounded transition-colors ${T==="yaml"?"bg-blue-500/20 text-blue-400":"text-slate-400 hover:text-slate-200"}`,onClick:()=>Q("yaml"),children:"YAML"})]}),g&&e.jsxs(x,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:217:13",variant:"outline",size:"sm",className:"h-8 border-slate-700 text-slate-300 hover:text-slate-100",onClick:()=>{F(z),L(!0)},children:[e.jsx(ne,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:219:15",className:"h-3.5 w-3.5 mr-1"}),"伸缩"]}),e.jsxs(x,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:222:11",variant:"outline",size:"sm",className:"h-8 border-slate-700 text-slate-300 hover:text-slate-100",disabled:$,onClick:je,children:[e.jsx(Le,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:224:13",className:"h-3.5 w-3.5 mr-1"}),$?"重启中...":"重启"]}),e.jsxs(x,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:226:11",variant:"outline",size:"sm",className:"h-8 border-slate-700 text-slate-300 hover:text-slate-100",onClick:()=>K(!0),children:[e.jsx($e,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:228:13",className:"h-3.5 w-3.5 mr-1"}),"YAML"]})]})]}),be?e.jsx("div",{"code-path":"src/components/kubernetes/WorkloadViewP
Line truncated
|
||||
import{k as Ue,m as Te,x as Re,r as d,j as e,B as x,q as ne,R as Le,F as $e,y as Ae,z as Me,v as he,A as ze,E as Be}from"./index-Dmami9WE.js";import{C as V,a as W,b as y,c as S}from"./card-CIfC-8Rh.js";import{B as j}from"./badge-3UzCvU7L.js";import{T as ce,a as le,b as C,c as h,d as de,e as i}from"./table-CG4mjNfb.js";import{k as U}from"./kubernetes-D2-GnE0t.js";import{u as Oe}from"./use-toast-jvSbBx20.js";import{Y as ie,S as w,f as me,s as q,P as Fe,a as _e}from"./PodFileBrowser-BLvOIIeH.js";import{A as He}from"./arrow-left-BIbk9wFC.js";import{T as Ye}from"./tag-utZ9-UQ0.js";import{H as De}from"./hard-drive-DmC04Y5r.js";import{M as Ee}from"./minus-DRP_TSA-.js";import{P as qe}from"./plus-O65gX7Qz.js";import"./copy-CE_T92Lk.js";import"./sparkles-rPZivnlW.js";import"./save-YtnrpTd8.js";import"./select-DUbxjT0z.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";import"./xterm-DSqgeKvr.js";import"./box-88Ol5qY-.js";import"./rotate-cw-CKCO6IKE.js";import"./minimize-2-BHcbNmdK.js";import"./upload-CRLg7Pbj.js";import"./refresh-cw-CTBERyFc.js";import"./folder-B5RGB3GG.js";import"./download-Vuij9wGr.js";function n({label:t,value:m,sub:P,color:u}){return e.jsx(V,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:28:5",className:"bg-slate-900 border-slate-800",children:e.jsxs(W,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:29:7",className:"p-3",children:[e.jsx("p",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:30:9",className:"text-xs text-slate-500",children:t}),e.jsx("p",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:31:9",className:"text-base font-bold mt-0.5",style:{color:u||"#e2e8f0"},children:m}),P&&e.jsx("p",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:32:17",className:"text-[10px] text-slate-600 mt-0.5",children:P})]})})}function pe({labels:t}){const m=Object.entries(t||{});return m.length===0?e.jsx("span",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:41:36",className:"text-xs text-slate-600",children:"无"}):e.jsx("div",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:43:5",className:"flex flex-wrap gap-1.5",children:m.map(([P,u])=>e.jsxs(j,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:45:9",variant:"outline",className:"border-slate-700 text-slate-400 text-[10px] font-mono",children:[P,"=",u]},P))})}function ws(){const t=Ue(),m=Te(),P=Re(),{toast:u}=Oe(),o=t.clusterCode||"",r=t.namespace||"",c=t.name||"",p=P.pathname.includes("/DaemonSet/")?"DaemonSet":"StatefulSet",T=t.mode==="yaml"?"yaml":"view",[N,ke]=d.useState(null),[R,ue]=d.useState([]),[be,I]=d.useState(!0),[ge,L]=d.useState(!1),[v,F]=d.useState(1),[$,A]=d.useState(!1),[_,J]=d.useState(null),[H,K]=d.useState(null),[we,G]=d.useState(!1),M=d.useCallback(async()=>{I(!0);try{const[s,l]=await Promise.all([U.getResourceYaml(o,r,p.toLowerCase()+"s",c).catch(()=>""),U.getPods(o).catch(()=>[])]);let f=null;if(s&&typeof s=="string")try{f=JSON.parse(s)}catch{f={_raw:s}}else s&&typeof s=="object"&&(f=s);ke(f);const E=(Array.isArray(l)?l:l?.list||l?.data||[]).filter(O=>{const Ce=O.name||O.metadata?.name||"",re=O.namespace||O.namespace_name||"";return Ce.startsWith(c)&&(!re||re===r)});ue(E)}catch(s){console.error("load error",s)}finally{I(!1)}},[o,r,c,p]);d.useEffect(()=>{M()},[M]);const Q=s=>{s!==T&&m(`/kubernetes/${o}/namespace/${r}/workload/${s}/${p}/${c}`,{replace:!0})},je=async()=>{if(confirm(`确认重启 ${p} ${c}?
|
||||
将触发滚动重启。`)){A(!0);try{p==="StatefulSet"?await U.restartStatefulSet(o,r,c):await U.restartDaemonSet(o,r,c),u({title:"重启指令已下发",description:`${p} 滚动重启已触发`}),setTimeout(M,1e3)}catch(s){u({title:"重启失败",description:s?.message||String(s),variant:"destructive"})}finally{A(!1)}}},Pe=async()=>{A(!0);try{await U.scaleStatefulSet(o,r,c,v),u({title:"扩缩容成功",description:`StatefulSet 副本数已更新为 ${v}`}),L(!1),setTimeout(M,1e3)}catch(s){u({title:"扩缩容失败",description:s?.message||String(s),variant:"destructive"})}finally{A(!1)}},k=N?.spec||{},b=N?.status||{},X=k?.template?.spec?.containers||[],Z=k?.template?.spec?.initContainers||[],z=k.replicas??1,ee=b.readyReplicas??0,Ve=b.currentReplicas??0,We=b.updatedReplicas??0,Y=b.desiredNumberScheduled??0,Ne=b.currentNumberScheduled??0,se=b.numberReady??0,fe=b.numberAvailable??0,ve=b.updatedNumberScheduled??0,g=p==="StatefulSet",B=g?ee===z&&z>0:se===Y&&Y>0,a=k.updateStrategy||{},D=a.type||"RollingUpdate",te=k.volumeClaimTemplates||[],ye=k.selector?.matchLabels||{},Se=N?.metadata?.labels||{},ae=N?.metadata?.annotations||{};return e.jsxs("div",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:183:5",className:"p-4 space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:185:7",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:186:9",className:"flex items-center gap-3",children:[e.jsx(x,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:187:11",variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-slate-200",onClick:()=>m(-1),children:e.jsx(He,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:188:13",className:"h-4 w-4"})}),e.jsx(ne,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:190:11",className:"h-5 w-5 text-blue-400"}),e.jsxs("div",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:191:11",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:192:13",className:"flex items-center gap-2",children:[e.jsx("h1",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:193:15",className:"text-lg font-bold text-slate-100",children:c}),e.jsx(j,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:194:15",variant:"outline",className:"border-slate-700 text-slate-400",children:p}),e.jsx(j,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:195:15",variant:"outline",className:"border-slate-700 text-slate-400",children:r}),B?e.jsx(j,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:197:19",className:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30",children:"健康"}):e.jsx(j,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:198:19",className:"bg-amber-500/20 text-amber-400 border-amber-500/30",children:"更新中"})]}),e.jsxs("p",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:200:13",className:"text-xs text-slate-500 mt-0.5",children:["集群: ",o]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:203:9",className:"flex items-center gap-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:205:11",className:"flex items-center gap-1 bg-slate-900 border border-slate-800 rounded-lg p-0.5",children:[e.jsx("button",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:206:13",className:`px-3 py-1 text-xs rounded transition-colors ${T==="view"?"bg-blue-500/20 text-blue-400":"text-slate-400 hover:text-slate-200"}`,onClick:()=>Q("view"),children:"查看"}),e.jsx("button",{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:210:13",className:`px-3 py-1 text-xs rounded transition-colors ${T==="yaml"?"bg-blue-500/20 text-blue-400":"text-slate-400 hover:text-slate-200"}`,onClick:()=>Q("yaml"),children:"YAML"})]}),g&&e.jsxs(x,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:217:13",variant:"outline",size:"sm",className:"h-8 border-slate-700 text-slate-300 hover:text-slate-100",onClick:()=>{F(z),L(!0)},children:[e.jsx(ne,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:219:15",className:"h-3.5 w-3.5 mr-1"}),"伸缩"]}),e.jsxs(x,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:222:11",variant:"outline",size:"sm",className:"h-8 border-slate-700 text-slate-300 hover:text-slate-100",disabled:$,onClick:je,children:[e.jsx(Le,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:224:13",className:"h-3.5 w-3.5 mr-1"}),$?"重启中...":"重启"]}),e.jsxs(x,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:226:11",variant:"outline",size:"sm",className:"h-8 border-slate-700 text-slate-300 hover:text-slate-100",onClick:()=>G(!0),children:[e.jsx($e,{"code-path":"src/components/kubernetes/WorkloadViewPage.tsx:228:13",className:"h-3.5 w-3.5 mr-1"}),"YAML"]})]})]}),be?e.jsx("div",{"code-path":"src/components/kubernetes/WorkloadViewP
Line truncated
|
||||
@@ -1 +1 @@
|
||||
import{h as t}from"./index-DfyorCky.js";const g={getLatest:()=>t.get("/agent/latest"),getHistory:(e,a=1)=>t.get(`/agent/history/${e}?hours=${a}`),createTask:e=>t.post("/agent/tasks",e),listTasks:e=>t.get("/agent/tasks",e),execCommand:e=>t.post("/agent/exec",e),getAggregate:e=>t.get("/agent/aggregate",e),aggregate:e=>t.post("/agent/aggregate",e),listRules:()=>t.get("/agent/rules"),createRule:e=>t.post("/agent/rules",e),updateRule:(e,a)=>t.put(`/agent/rules/${e}`,a),deleteRule:e=>t.delete(`/agent/rules/${e}`),quickSetup:e=>t.post("/agent/rules/quick-setup",{type:e||"ecs"}),uninstallAgent:e=>t.post("/agent/uninstall",e),batchUninstall:e=>t.post("/agent/batch-uninstall",{server_ids:e}),batchUpgrade:e=>t.post("/agent/batch-upgrade",{server_ids:e}),listAlerts:e=>t.get("/agent/alerts",e),resolveAlert:e=>t.post(`/agent/alerts/${e}/resolve`),getHealthProbes:e=>t.get("/agent/health-probes",e),createHealthProbe:e=>t.post("/agent/health-probes",e),updateHealthProbe:(e,a)=>t.put(`/agent/health-probes/${e}`,a),deleteHealthProbe:e=>t.delete(`/agent/health-probes/${e}`),getPortPolicy:e=>t.get(`/agent/port-policies/${e}`),savePortPolicy:(e,a)=>t.put(`/agent/port-policies/${e}`,a)};export{g as a};
|
||||
import{h as t}from"./index-Dmami9WE.js";const g={getLatest:()=>t.get("/agent/latest"),getHistory:(e,a=1)=>t.get(`/agent/history/${e}?hours=${a}`),createTask:e=>t.post("/agent/tasks",e),listTasks:e=>t.get("/agent/tasks",e),execCommand:e=>t.post("/agent/exec",e),getAggregate:e=>t.get("/agent/aggregate",e),aggregate:e=>t.post("/agent/aggregate",e),listRules:()=>t.get("/agent/rules"),createRule:e=>t.post("/agent/rules",e),updateRule:(e,a)=>t.put(`/agent/rules/${e}`,a),deleteRule:e=>t.delete(`/agent/rules/${e}`),quickSetup:e=>t.post("/agent/rules/quick-setup",{type:e||"ecs"}),uninstallAgent:e=>t.post("/agent/uninstall",e),batchUninstall:e=>t.post("/agent/batch-uninstall",{server_ids:e}),batchUpgrade:e=>t.post("/agent/batch-upgrade",{server_ids:e}),listAlerts:e=>t.get("/agent/alerts",e),resolveAlert:e=>t.post(`/agent/alerts/${e}/resolve`),getHealthProbes:e=>t.get("/agent/health-probes",e),createHealthProbe:e=>t.post("/agent/health-probes",e),updateHealthProbe:(e,a)=>t.put(`/agent/health-probes/${e}`,a),deleteHealthProbe:e=>t.delete(`/agent/health-probes/${e}`),getPortPolicy:e=>t.get(`/agent/port-policies/${e}`),savePortPolicy:(e,a)=>t.put(`/agent/port-policies/${e}`,a)};export{g as a};
|
||||
@@ -1,4 +1,4 @@
|
||||
import{h as o,W as h}from"./index-DfyorCky.js";const C={getConfig:()=>o.get("/aiops/llm-config"),saveConfig:e=>o.put("/aiops/llm-config",e),testConnection:()=>o.post("/aiops/llm-config/test"),chat:(e,s)=>o.post("/aiops/chat",{messages:e,session_id:s||""}),chatStream:async(e,s,d,g)=>{const c=h.getState().token,n=await fetch("/api/v1/aiops/chat/stream",{method:"POST",headers:{"Content-Type":"application/json",...c?{Authorization:`Bearer ${c}`}:{}},body:JSON.stringify({messages:e,session_id:g||""}),signal:d});if(n.status===401)throw h.getState().logout(),window.location.href="/login",new Error("登录已过期,请重新登录");if(!n.body)throw new Error("流式响应不可用");const m=n.body.getReader(),u=new TextDecoder("utf-8");let r="",f="";for(;;){const{done:w,value:y}=await m.read();if(w)break;r+=u.decode(y,{stream:!0});const p=r.split(`
|
||||
import{h as o,$ as h}from"./index-Dmami9WE.js";const C={getConfig:()=>o.get("/aiops/llm-config"),saveConfig:e=>o.put("/aiops/llm-config",e),testConnection:()=>o.post("/aiops/llm-config/test"),chat:(e,s)=>o.post("/aiops/chat",{messages:e,session_id:s||""}),chatStream:async(e,s,d,g)=>{const c=h.getState().token,n=await fetch("/api/v1/aiops/chat/stream",{method:"POST",headers:{"Content-Type":"application/json",...c?{Authorization:`Bearer ${c}`}:{}},body:JSON.stringify({messages:e,session_id:g||""}),signal:d});if(n.status===401)throw h.getState().logout(),window.location.href="/login",new Error("登录已过期,请重新登录");if(!n.body)throw new Error("流式响应不可用");const m=n.body.getReader(),u=new TextDecoder("utf-8");let r="",f="";for(;;){const{done:w,value:y}=await m.read();if(w)break;r+=u.decode(y,{stream:!0});const p=r.split(`
|
||||
|
||||
`);r=p.pop()??"";for(const S of p){const b=S.split(`
|
||||
`);let a="message",l=[];for(const t of b)t.startsWith("event:")?a=t.slice(6).trim():t.startsWith("data:")&&l.push(t.slice(5).trim());const i=l.join("");if(i){if(a==="error")try{const t=JSON.parse(i);throw new Error(t.message||"LLM 流式响应错误")}catch(t){throw t instanceof Error&&t.message?t:new Error("LLM 流式响应错误")}if(a!=="done")try{const t=JSON.parse(i);typeof t.content=="string"&&(f+=t.content,s(t.content))}catch{}}}}return f},getHistory:e=>{const s=e?`?session_id=${encodeURIComponent(e)}`:"";return o.get(`/aiops/chat-history${s}`)},clearHistory:()=>o.delete("/aiops/chat-history")};export{C as a};
|
||||
+1
-1
@@ -1 +1 @@
|
||||
import{g as o}from"./index-DfyorCky.js";const e=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],r=o("arrow-left",e);export{r as A};
|
||||
import{i as o}from"./index-Dmami9WE.js";const e=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],r=o("arrow-left",e);export{r as A};
|
||||
+1
-1
@@ -1 +1 @@
|
||||
import{g as o}from"./index-DfyorCky.js";const r=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],a=o("arrow-right",r);export{a as A};
|
||||
import{i as o}from"./index-Dmami9WE.js";const r=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],a=o("arrow-right",r);export{a as A};
|
||||
@@ -0,0 +1 @@
|
||||
import{i as o}from"./index-Dmami9WE.js";const r=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],t=o("arrow-down",r);const a=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],c=o("arrow-up",a);export{c as A,t as a};
|
||||
+1
-1
@@ -1 +1 @@
|
||||
import{g as o}from"./index-DfyorCky.js";const e=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],a=o("arrow-up-down",e);export{a as A};
|
||||
import{i as o}from"./index-Dmami9WE.js";const e=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],a=o("arrow-up-down",e);export{a as A};
|
||||
+1
-1
@@ -1 +1 @@
|
||||
import{h as e}from"./index-DfyorCky.js";const c={getJobs:async t=>e.get("/cron-jobs",t),getJob:async t=>e.get(`/cron-jobs/${t}`),createJob:async t=>e.post("/cron-jobs",t),updateJob:async(t,r)=>e.put(`/cron-jobs/${t}`,r),deleteJob:async t=>e.delete(`/cron-jobs/${t}`),toggleJob:async t=>e.post(`/cron-jobs/${t}/toggle`),executeJob:async t=>e.post(`/cron-jobs/${t}/execute`),batchDelete:async t=>e.delete("/cron-jobs/batch-delete",{ids:t})},n={getScripts:async t=>e.get("/scripts",t),getScript:async t=>e.get(`/scripts/${t}`),createScript:async t=>e.post("/scripts",t),updateScript:async(t,r)=>e.put(`/scripts/${t}`,r),deleteScript:async t=>e.delete(`/scripts/${t}`),batchDelete:async t=>e.post("/scripts/batch-delete",{ids:t}),executeScript:async t=>e.post(`/scripts/${t}/execute`)},o={getExecutions:async t=>e.get("/task-executions",t)};export{c,n as s,o as t};
|
||||
import{h as e}from"./index-Dmami9WE.js";const c={getJobs:async t=>e.get("/cron-jobs",t),getJob:async t=>e.get(`/cron-jobs/${t}`),createJob:async t=>e.post("/cron-jobs",t),updateJob:async(t,r)=>e.put(`/cron-jobs/${t}`,r),deleteJob:async t=>e.delete(`/cron-jobs/${t}`),toggleJob:async t=>e.post(`/cron-jobs/${t}/toggle`),executeJob:async t=>e.post(`/cron-jobs/${t}/execute`),batchDelete:async t=>e.delete("/cron-jobs/batch-delete",{ids:t})},n={getScripts:async t=>e.get("/scripts",t),getScript:async t=>e.get(`/scripts/${t}`),createScript:async t=>e.post("/scripts",t),updateScript:async(t,r)=>e.put(`/scripts/${t}`,r),deleteScript:async t=>e.delete(`/scripts/${t}`),batchDelete:async t=>e.post("/scripts/batch-delete",{ids:t}),executeScript:async t=>e.post(`/scripts/${t}/execute`)},o={getExecutions:async t=>e.get("/task-executions",t)};export{c,n as s,o as t};
|
||||
@@ -0,0 +1 @@
|
||||
import{j as n,a1 as s,a0 as o,a2 as d}from"./index-Dmami9WE.js";const c=d("inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function v({className:e,variant:r,asChild:t=!1,...a}){const i=t?s:"span";return n.jsx(i,{"code-path":"src/components/ui/badge.tsx:38:5","data-slot":"badge",className:o(c({variant:r}),e),...a})}export{v as B};
|
||||
@@ -1 +0,0 @@
|
||||
import{j as n,Y as s,X as o,Z as d}from"./index-DfyorCky.js";const c=d("inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function v({className:e,variant:r,asChild:t=!1,...a}){const i=t?s:"span";return n.jsx(i,{"code-path":"src/components/ui/badge.tsx:38:5","data-slot":"badge",className:o(c({variant:r}),e),...a})}export{v as B};
|
||||
@@ -1 +1 @@
|
||||
import{g as a}from"./index-DfyorCky.js";const o=[["path",{d:"M21 8a2 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",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],e=a("box",o);export{e as B};
|
||||
import{i as a}from"./index-Dmami9WE.js";const o=[["path",{d:"M21 8a2 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",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],e=a("box",o);export{e as B};
|
||||
@@ -0,0 +1 @@
|
||||
import{i as e}from"./index-Dmami9WE.js";const t=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],c=e("calendar",t);export{c as C};
|
||||
@@ -1 +0,0 @@
|
||||
import{j as r,X as s}from"./index-DfyorCky.js";function d({className:a,...t}){return r.jsx("div",{"code-path":"src/components/ui/card.tsx:7:5","data-slot":"card",className:s("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",a),...t})}function e({className:a,...t}){return r.jsx("div",{"code-path":"src/components/ui/card.tsx:20:5","data-slot":"card-header",className:s("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",a),...t})}function c({className:a,...t}){return r.jsx("div",{"code-path":"src/components/ui/card.tsx:33:5","data-slot":"card-title",className:s("leading-none font-semibold",a),...t})}function n({className:a,...t}){return r.jsx("div",{"code-path":"src/components/ui/card.tsx:43:5","data-slot":"card-description",className:s("text-muted-foreground text-sm",a),...t})}function i({className:a,...t}){return r.jsx("div",{"code-path":"src/components/ui/card.tsx:66:5","data-slot":"card-content",className:s("px-6",a),...t})}export{d as C,i as a,e as b,c,n as d};
|
||||
Loaded 100 of 226 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user