F1 告警静默规则 [done]: - 后端 alert_silence.go: CRUD + Toggle (onetime/daily/weekly 三模式) - 告警引擎 isSilenced 集成 (alert_engine.go) - 前端 SilenceRuleTab + SilenceDialog - 路由 /alerts/silences 已注册 F2 审计日志导出 [done]: - 重写 ExportAuditLogs: 真正的 CSV 导出 (encoding/csv + UTF-8 BOM) - 支持 module/action/username/startTime/endTime 筛选 - 导出限制 10000 条防溢出,自动记录审计日志 - JSON 格式向后兼容 (format=json) - 前端 exportLogs 传递查询参数 同时包含累积的前期工作: - 目录重构 internal/ -> controller/model/router (v0.55-v0.57) - 后端分层架构 dto/repository/service/utils - 审计模块全功能 (终端审计/操作审计/登录日志) - asciicast v2 录制格式 - SFTP 文件浏览器 - StatStrip 紧凑统计条 - 在线会话自动刷新 - LiveMonitor WebSocket 诊断修复 验证: go build ✅ | npm run build ✅ | Docker 部署 ✅ | 10 回归端点 ✅ | CSV 导出 ✅ | 静默 CRUD ✅
2 lines
49 KiB
JavaScript
2 lines
49 KiB
JavaScript
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:25:11",className:"flex items-center gap-2",children:[r?.title,r&&ae(r.severity)]}),e.jsx(V,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:29:11",className:"sr-only",children:"查看告警详情"})]}),r&&e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:32:11",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:33:13",children:[e.jsx(h,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:34:15",className:"text-muted-foreground",children:"描述"}),e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:35:15",className:"mt-1",children:r.description})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:37:13",className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:38:15",children:[e.jsx(h,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:39:17",className:"text-muted-foreground",children:"来源"}),e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:40:17",className:"font-medium",children:r.source})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:42:15",children:[e.jsx(h,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:43:17",className:"text-muted-foreground",children:"服务"}),e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:44:17",className:"font-medium",children:r.service})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:46:15",children:[e.jsx(h,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:47:17",className:"text-muted-foreground",children:"指标"}),e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:48:17",className:"font-medium",children:r.metric})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:50:15",children:[e.jsx(h,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:51:17",className:"text-muted-foreground",children:"当前值 / 阈值"}),e.jsxs("p",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:52:17",className:"font-medium",children:[r.value," / ",r.threshold]})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:54:15",children:[e.jsx(h,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:55:17",className:"text-muted-foreground",children:"开始时间"}),e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:56:17",className:"font-medium",children:r.startedAt})]}),r.resolvedAt&&e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:59:17",children:[e.jsx(h,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:60:19",className:"text-muted-foreground",children:"解决时间"}),e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:61:19",className:"font-medium",children:r.resolvedAt})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:65:13",children:[e.jsx(h,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:66:15",className:"text-muted-foreground",children:"标签"}),e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:67:15",className:"flex flex-wrap gap-2 mt-1",children:Object.entries(r.labels).map(([j,x])=>e.jsxs(u,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:69:19",variant:"outline",children:[j,"=",x]},j))})]}),r.runbookUrl&&e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:74:15",children:[e.jsx(h,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:75:17",className:"text-muted-foreground",children:"处理手册"}),e.jsx("a",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:76:17",href:r.runbookUrl,target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:underline block mt-1",children:"查看处理手册 →"})]})]}),e.jsxs(le,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:83:9",children:[e.jsx(a,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:84:11",variant:"outline",onClick:()=>c(!1),children:"关闭"}),r?.status==="firing"&&e.jsxs(a,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:86:13",onClick:()=>{A(r.id),c(!1)},children:[e.jsx(be,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:87:15",className:"w-4 h-4 mr-2"}),"确认告警"]})]})]})})}function xt({alert:r,open:C,onOpenChange:c,onSilence:A}){return e.jsx(q,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:109:5",open:C,onOpenChange:c,children:e.jsxs(B,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:110:7",children:[e.jsxs(P,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:111:9",children:[e.jsx(U,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:112:11",children:"静默告警"}),e.jsx(V,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:113:11",children:"选择静默持续时间"})]}),e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:115:9",className:"space-y-2",children:["1h","4h","8h","24h","7d"].map(j=>e.jsxs(a,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:117:13",variant:"outline",className:"w-full justify-between",onClick:()=>r&&A(r.id,j),children:[e.jsxs("span",{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:123:15",children:["静默 ",j]}),e.jsx(Ke,{"code-path":"src/components/monitor/alert-center/AlertCenterDetail.tsx:124:15",className:"w-4 h-4"})]},j))})]})})}const we=[{value:"feishu",label:"飞书",placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/..."},{value:"dingtalk",label:"钉钉",placeholder:"https://oapi.dingtalk.com/robot/send?access_token=..."},{value:"wechat",label:"企业微信",placeholder:"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=..."},{value:"webhook",label:"自定义Webhook",placeholder:"https://your-webhook-url..."}];function ht({open:r,onOpenChange:C,editingContact:c,onSaved:A}){const[j,x]=o.useState("feishu"),[i,g]=o.useState({name:"",phone:"",email:"",webhook_url:""}),[b,f]=o.useState(!1);o.useEffect(()=>{r&&(c?(x(c.channel_type||"feishu"),g({name:c.name||"",phone:c.phone||"",email:c.email||"",webhook_url:c.webhook_url||""})):(x("feishu"),g({name:"",phone:"",email:"",webhook_url:""})))},[r,c]);const G=async()=>{if(!(!i.name.trim()||!i.webhook_url.trim())){f(!0);try{const d={name:i.name.trim(),phone:i.phone.trim()||void 0,email:i.email.trim()||void 0,channel_type:j,webhook_url:i.webhook_url.trim()};c?(await D.updateContact(c.id,d),m.success("联系人已更新")):(await D.createContact(d),m.success("联系人已添加")),C(!1),A()}catch{m.error("保存失败")}finally{f(!1)}}},l=we.find(d=>d.value===j);return e.jsx(q,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:85:5",open:r,onOpenChange:C,children:e.jsxs(B,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:86:7",children:[e.jsxs(P,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:87:9",children:[e.jsx(U,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:88:11",children:c?"编辑报警联系人":"添加报警联系人"}),e.jsx(V,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:89:11",children:"选择通知渠道并填入 Webhook 地址"})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:91:9",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:92:11",className:"space-y-2",children:[e.jsx(h,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:93:13",children:"姓名 *"}),e.jsx(T,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:94:13",value:i.name,onChange:d=>g({...i,name:d.target.value}),placeholder:"如:张三"})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:100:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:101:13",className:"space-y-2",children:[e.jsx(h,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:102:15",children:"手机号"}),e.jsx(T,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:103:15",value:i.phone,onChange:d=>g({...i,phone:d.target.value}),placeholder:"13800138000"})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:109:13",className:"space-y-2",children:[e.jsx(h,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:110:15",children:"邮箱"}),e.jsx(T,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:111:15",value:i.email,onChange:d=>g({...i,email:d.target.value}),placeholder:"zhangsan@example.com"})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:118:11",className:"space-y-2",children:[e.jsx(h,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:119:13",children:"渠道类型 *"}),e.jsxs(ne,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:120:13",value:j,onValueChange:x,children:[e.jsx(se,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:121:15",children:e.jsx(oe,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:122:17",placeholder:"选择渠道类型"})}),e.jsx(ce,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:124:15",children:we.map(d=>e.jsx(v,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:126:19",value:d.value,children:d.label},d.value))})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:131:11",className:"space-y-2",children:[e.jsx(h,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:132:13",children:"Webhook URL *"}),e.jsx(T,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:133:13",value:i.webhook_url,onChange:d=>g({...i,webhook_url:d.target.value}),placeholder:l?.placeholder||"https://...",className:"font-mono text-xs"})]})]}),e.jsxs(le,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:141:9",children:[e.jsx(a,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:142:11",variant:"outline",onClick:()=>C(!1),children:"取消"}),e.jsx(a,{"code-path":"src/components/monitor/alert-center/ContactDialog.tsx:143:11",onClick:G,disabled:!i.name.trim()||!i.webhook_url.trim()||b,children:b?"保存中...":c?"保存修改":"添加联系人"})]})]})})}function ut({open:r,onOpenChange:C,editingGroup:c,contacts:A,onSaved:j}){const[x,i]=o.useState({group_name:"",notes:"",contact_ids:[]}),[g,b]=o.useState(!1);o.useEffect(()=>{if(r)if(c){let l=[];try{l=JSON.parse(c.contact_ids||"[]")}catch{}i({group_name:c.group_name||"",notes:c.notes||"",contact_ids:l})}else i({group_name:"",notes:"",contact_ids:[]})},[r,c]);const f=l=>{i(d=>({...d,contact_ids:d.contact_ids.includes(l)?d.contact_ids.filter(S=>S!==l):[...d.contact_ids,l]}))},G=async()=>{if(x.group_name.trim()){b(!0);try{const l={group_name:x.group_name.trim(),notes:x.notes.trim()||void 0,contact_ids:x.contact_ids};c?(await D.updateContactGroup(c.id,l),m.success("联系组已更新")):(await D.createContactGroup(l),m.success("联系组已添加")),C(!1),j()}catch{m.error("保存失败")}finally{b(!1)}}};return e.jsx(q,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:84:5",open:r,onOpenChange:C,children:e.jsxs(B,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:85:7",children:[e.jsxs(P,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:86:9",children:[e.jsx(U,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:87:11",children:c?"编辑报警联系组":"添加报警联系组"}),e.jsx(V,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:88:11",children:"配置报警联系组,选择组内成员"})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:90:9",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:91:11",className:"space-y-2",children:[e.jsx(h,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:92:13",children:"组名称 *"}),e.jsx(T,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:93:13",value:x.group_name,onChange:l=>i({...x,group_name:l.target.value}),placeholder:"如:运维值班组"})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:99:11",className:"space-y-2",children:[e.jsx(h,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:100:13",children:"备注"}),e.jsx(at,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:101:13",value:x.notes,onChange:l=>i({...x,notes:l.target.value}),placeholder:"如:周一至周五 9:00-21:00",rows:2})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:108:11",className:"space-y-2",children:[e.jsx(h,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:109:13",children:"选择联系人"}),A.length===0?e.jsx("p",{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:111:15",className:"text-xs text-muted-foreground",children:"暂无联系人,请先在「报警联系人」标签页添加"}):e.jsx("div",{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:113:15",className:"flex flex-wrap gap-1.5 max-h-[180px] overflow-y-auto border rounded-md p-2",children:A.map(l=>e.jsxs(u,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:115:19",variant:x.contact_ids.includes(l.id)?"default":"outline",className:"cursor-pointer text-xs",onClick:()=>f(l.id),children:[l.name,x.contact_ids.includes(l.id)&&" ✓"]},l.id))}),x.contact_ids.length>0&&e.jsxs("p",{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:128:15",className:"text-xs text-muted-foreground",children:["已选择 ",x.contact_ids.length," 位联系人"]})]})]}),e.jsxs(le,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:132:9",children:[e.jsx(a,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:133:11",variant:"outline",onClick:()=>C(!1),children:"取消"}),e.jsx(a,{"code-path":"src/components/monitor/alert-center/ContactGroupDialog.tsx:134:11",onClick:G,disabled:!x.group_name.trim()||g,children:g?"保存中...":c?"保存修改":"添加联系组"})]})]})})}const zt=()=>{const r=Ye(),[C,c]=o.useState([]),[A,j]=o.useState([]),[x,i]=o.useState(!1),[g,b]=o.useState(""),[f,G]=o.useState("all"),[l,d]=o.useState("all"),[S,_e]=o.useState("alerts"),[ie,me]=o.useState(null),[Te,de]=o.useState(!1),[Ge,W]=o.useState(!1),[N,Oe]=o.useState({firing:0,critical:0,warning:0,resolved:0}),[Re,J]=o.useState(!1),[ze,H]=o.useState(null),[pe,xe]=o.useState(!1),[L,Le]=o.useState([]),[he,Ee]=o.useState([]),[$e,Q]=o.useState(!1),[Ie,ue]=o.useState(null),[Me,Z]=o.useState(!1),[Fe,Ce]=o.useState(null),[k,E]=o.useState(1),[je]=o.useState(10),[X,qe]=o.useState(0),_=Math.max(1,Math.ceil(X/je));o.useEffect(()=>{ge(),S==="contacts"&&$(),S==="groups"&&($(),I());const t=setInterval(ge,3e4);return()=>clearInterval(t)},[k,f,l,S]);const ge=async()=>{await Promise.all([O(),R()])},O=async()=>{i(!0);try{const t=await z.getAlerts({page:k,page_size:je,severity:f!=="all"?f:void 0,status:l!=="all"?l:void 0}),s=(t.list||t.data?.list||[]).map(it);c(s),qe(t.total||t.data?.total||s.length),Oe({firing:s.filter(p=>p.status==="firing").length,critical:s.filter(p=>p.severity==="critical"&&p.status==="firing").length,warning:s.filter(p=>p.severity==="warning"&&p.status==="firing").length,resolved:s.filter(p=>p.status==="resolved").length})}catch{m.error("获取告警失败")}finally{i(!1)}},R=async()=>{try{const t=await K.listRules(),n=Array.isArray(t)?t:t.list||[];j(n.map(s=>({id:s.id,name:s.name,description:`${s.metric} ${s.operator} ${s.threshold}%`,enabled:s.enabled,severity:"warning",type:s.metric,hostname:s.hostname||"全部主机",threshold:s.threshold})))}catch{m.error("获取告警规则失败")}},$=async()=>{try{const t=await D.getContacts();Le(t?.data?.list||t?.list||[])}catch{}},I=async()=>{try{const t=await D.getContactGroups();Ee(t?.data?.list||t?.list||[])}catch{}},Ae=async t=>{try{await z.acknowledge(t),m.success("告警已确认"),O()}catch{m.error("操作失败")}},Be=async t=>{try{await z.resolve(t),m.success("告警已解决"),O()}catch{m.error("操作失败")}},Pe=async(t,n)=>{try{await z.silence(t,n),m.success("告警已静默"),W(!1),O()}catch{m.error("操作失败")}},Ue=async(t,n)=>{try{await K.updateRule(Number(t),{enabled:n}),j(A.map(s=>String(s.id)===t?{...s,enabled:n}:s)),m.success("规则状态已更新")}catch{m.error("更新失败")}},Ve=()=>{H(null),J(!0)},We=t=>{H(t),J(!0)},fe=()=>{J(!1),H(null)},Je=async()=>{if(await r({title:"一键报警",description:"为 Agent 在线主机创建 CPU(>80%)/内存(>80%)/磁盘(>90%)/TIME_WAIT(>15000)/CLOSE_WAIT(>200)/进程检测 6 条告警规则。",confirmText:"确认创建"})){xe(!0);try{const n=await z.quickSetup("ecs");m.success(typeof n=="string"?n:n?.message||"默认告警规则创建成功"),R()}catch{m.error("创建失败,请检查 Agent 主机是否在线")}finally{xe(!1)}}},He=async t=>{if(await r({title:"删除规则",description:`确定删除规则「${t.name}」?`,confirmText:"删除",variant:"destructive"}))try{await K.deleteRule(Number(t.id)),m.success("已删除"),R()}catch{m.error("删除失败")}},ve=(t,n)=>{t==="severity"?G(n):d(n),E(1)};return e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:207:5",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:209:7",className:"grid grid-cols-4 gap-3",children:[e.jsx(y,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:210:9",className:N.firing>0?"border-red-500 border-2":"",children:e.jsx(w,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:211:11",className:"p-3",children:e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:212:13",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:213:15",children:[e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:214:17",className:"text-xs text-muted-foreground",children:"触发中"}),e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:215:17",className:`text-xl font-bold ${N.firing>0?"text-red-600":""}`,children:N.firing})]}),e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:217:15",className:`p-2 rounded-md ${N.firing>0?"bg-red-100":"bg-gray-100"}`,children:e.jsx(ke,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:218:17",className:`w-4 h-4 ${N.firing>0?"text-red-600":"text-gray-600"}`})})]})})}),e.jsx(y,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:223:9",children:e.jsx(w,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:224:11",className:"p-3",children:e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:225:13",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:226:15",children:[e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:227:17",className:"text-xs text-muted-foreground",children:"严重告警"}),e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:228:17",className:"text-xl font-bold text-red-600",children:N.critical})]}),e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:230:15",className:"p-2 bg-red-100 rounded-md",children:e.jsx(De,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:231:17",className:"w-4 h-4 text-red-600"})})]})})}),e.jsx(y,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:236:9",children:e.jsx(w,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:237:11",className:"p-3",children:e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:238:13",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:239:15",children:[e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:240:17",className:"text-xs text-muted-foreground",children:"警告告警"}),e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:241:17",className:"text-xl font-bold text-orange-600",children:N.warning})]}),e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:243:15",className:"p-2 bg-orange-100 rounded-md",children:e.jsx(te,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:244:17",className:"w-4 h-4 text-orange-600"})})]})})}),e.jsx(y,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:249:9",children:e.jsx(w,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:250:11",className:"p-3",children:e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:251:13",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:252:15",children:[e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:253:17",className:"text-xs text-muted-foreground",children:"今日已解决"}),e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:254:17",className:"text-xl font-bold text-green-600",children:N.resolved})]}),e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:256:15",className:"p-2 bg-green-100 rounded-md",children:e.jsx(re,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:257:17",className:"w-4 h-4 text-green-600"})})]})})})]}),e.jsxs(nt,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:264:7",value:S,onValueChange:_e,children:[e.jsxs(st,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:265:9",className:"grid w-full grid-cols-4 lg:w-[480px] h-9",children:[e.jsx(M,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:266:11",value:"alerts",className:"text-xs",children:"告警列表"}),e.jsx(M,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:267:11",value:"rules",className:"text-xs",children:"告警规则"}),e.jsx(M,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:268:11",value:"contacts",className:"text-xs",children:"报警联系人"}),e.jsx(M,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:269:11",value:"groups",className:"text-xs",children:"报警联系组"})]}),e.jsxs(F,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:273:9",value:"alerts",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:274:11",className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:275:13",className:"flex items-center gap-2 flex-1 min-w-[280px]",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:276:15",className:"relative flex-1",children:[e.jsx(et,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:277:17",className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground"}),e.jsx(T,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:278:17",placeholder:"搜索告警...",value:g,onChange:t=>b(t.target.value),className:"pl-8 h-8 text-xs"})]}),e.jsxs(ne,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:285:15",value:f,onValueChange:t=>ve("severity",t),children:[e.jsx(se,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:286:17",className:"w-[100px] h-8 text-xs",children:e.jsx(oe,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:287:19",placeholder:"级别"})}),e.jsxs(ce,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:289:17",children:[e.jsx(v,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:290:19",value:"all",children:"全部级别"}),e.jsx(v,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:291:19",value:"critical",children:"严重"}),e.jsx(v,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:292:19",value:"warning",children:"警告"}),e.jsx(v,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:293:19",value:"info",children:"信息"})]})]}),e.jsxs(ne,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:296:15",value:l,onValueChange:t=>ve("status",t),children:[e.jsx(se,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:297:17",className:"w-[100px] h-8 text-xs",children:e.jsx(oe,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:298:19",placeholder:"状态"})}),e.jsxs(ce,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:300:17",children:[e.jsx(v,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:301:19",value:"all",children:"全部状态"}),e.jsx(v,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:302:19",value:"firing",children:"触发中"}),e.jsx(v,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:303:19",value:"acknowledged",children:"已确认"}),e.jsx(v,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:304:19",value:"resolved",children:"已解决"})]})]})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:308:13",className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsxs("span",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:309:15",children:["共 ",X," 条"]}),e.jsxs(a,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:310:15",variant:"outline",size:"sm",onClick:O,className:"h-7 text-xs px-2",children:[e.jsx(Y,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:311:17",className:"w-3 h-3 mr-1"}),"刷新"]})]})]}),e.jsx(y,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:317:11",children:e.jsxs(w,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:318:13",className:"p-0",children:[e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:319:15",className:"overflow-x-auto",children:e.jsxs("table",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:320:17",className:"w-full text-sm",children:[e.jsx("thead",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:321:19",className:"bg-muted/50",children:e.jsxs("tr",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:322:21",children:[e.jsx("th",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:323:23",className:"px-3 py-2 text-left text-xs font-medium",children:"告警信息"}),e.jsx("th",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:324:23",className:"px-3 py-2 text-left text-xs font-medium w-16",children:"级别"}),e.jsx("th",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:325:23",className:"px-3 py-2 text-left text-xs font-medium w-16",children:"状态"}),e.jsx("th",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:326:23",className:"px-3 py-2 text-left text-xs font-medium w-24",children:"来源"}),e.jsx("th",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:327:23",className:"px-3 py-2 text-left text-xs font-medium w-20",children:"持续"}),e.jsx("th",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:328:23",className:"px-3 py-2 text-left text-xs font-medium w-28",children:"操作"})]})}),e.jsx("tbody",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:331:19",className:"divide-y",children:x?e.jsx("tr",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:333:23",children:e.jsx("td",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:333:27",colSpan:6,className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"加载中..."})}):C.length===0?e.jsx("tr",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:335:23",children:e.jsx("td",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:335:27",colSpan:6,className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"暂无告警"})}):C.filter(t=>{if(!g)return!0;const n=g.toLowerCase();return t.title.toLowerCase().includes(n)||t.description.toLowerCase().includes(n)||t.source.toLowerCase().includes(n)}).map(t=>e.jsxs("tr",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:345:25",className:"hover:bg-muted/50",children:[e.jsxs("td",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:346:27",className:"px-3 py-2",children:[e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:347:29",className:"font-medium text-xs",children:t.title}),e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:348:29",className:"text-xs text-muted-foreground line-clamp-1",children:t.description}),e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:349:29",className:"flex gap-1 mt-0.5",children:Object.entries(t.labels).slice(0,2).map(([n,s])=>e.jsxs(u,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:351:33",variant:"outline",className:"text-[10px] px-1 py-0",children:[n,"=",s]},n))})]}),e.jsx("td",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:355:27",className:"px-3 py-2",children:ae(t.severity)}),e.jsx("td",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:356:27",className:"px-3 py-2",children:mt(t.status)}),e.jsxs("td",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:357:27",className:"px-3 py-2 text-xs",children:[e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:358:29",children:t.source}),e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:359:29",className:"text-muted-foreground text-[10px]",children:t.service})]}),e.jsx("td",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:361:27",className:"px-3 py-2 text-xs text-muted-foreground",children:t.status==="resolved"&&t.resolvedAt?`${Math.floor((new Date(t.resolvedAt).getTime()-new Date(t.startedAt).getTime())/6e4)}分`:`${Math.floor((Date.now()-new Date(t.startedAt).getTime())/6e4)}分`}),e.jsx("td",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:366:27",className:"px-3 py-2",children:e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:367:29",className:"flex items-center gap-0.5",children:[e.jsx(a,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:368:31",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{me(t),de(!0)},children:e.jsx(tt,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:370:33",className:"w-3.5 h-3.5"})}),t.status==="firing"&&e.jsx(a,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:373:33",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>Ae(t.id),children:e.jsx(be,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:375:35",className:"w-3.5 h-3.5 text-blue-600"})}),(t.status==="firing"||t.status==="acknowledged")&&e.jsx(a,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:379:33",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>Be(t.id),children:e.jsx(re,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:381:35",className:"w-3.5 h-3.5 text-green-600"})}),e.jsx(a,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:384:31",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{me(t),W(!0)},children:e.jsx(Se,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:386:33",className:"w-3.5 h-3.5 text-orange-600"})})]})})]},t.id))})]})}),_>1&&e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:398:17",className:"flex items-center justify-between px-3 py-2 border-t text-xs",children:[e.jsxs("span",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:399:19",className:"text-muted-foreground",children:["第 ",k,"/",_," 页,共 ",X," 条"]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:400:19",className:"flex items-center gap-1",children:[e.jsx(a,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:401:21",variant:"outline",size:"sm",className:"h-7 text-xs px-2",disabled:k<=1,onClick:()=>E(t=>t-1),children:"上一页"}),Array.from({length:Math.min(_,5)},(t,n)=>{const p=Math.max(1,Math.min(k-2,_-4))+n;return p>_?null:e.jsx(a,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:410:25",variant:p===k?"default":"outline",size:"sm",className:"h-7 min-w-[28px] text-xs px-1",onClick:()=>E(p),children:p},p)}),e.jsx(a,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:417:21",variant:"outline",size:"sm",className:"h-7 text-xs px-2",disabled:k>=_,onClick:()=>E(t=>t+1),children:"下一页"})]})]})]})})]}),e.jsxs(F,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:429:9",value:"rules",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:430:11",className:"flex justify-between items-center",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:431:13",className:"flex items-center gap-2",children:[e.jsxs(a,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:432:15",onClick:Ve,children:[e.jsx(ee,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:433:17",className:"w-4 h-4 mr-1"}),"添加规则"]}),e.jsxs(a,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:435:15",variant:"secondary",onClick:Je,disabled:pe,children:[e.jsx(rt,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:436:17",className:"w-4 h-4 mr-1"}),pe?"创建中…":"一键报警"]})]}),e.jsxs(a,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:440:13",variant:"outline",onClick:R,children:[e.jsx(Y,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:441:15",className:"w-4 h-4 mr-2"}),"刷新"]})]}),A.length===0?e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:446:13",className:"text-center py-12 text-muted-foreground",children:[e.jsx(te,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:447:15",className:"w-10 h-10 mx-auto mb-2 opacity-50"}),e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:448:15",className:"text-sm",children:"暂无告警规则"}),e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:449:15",className:"text-xs mt-1",children:"点击「添加规则」或「一键报警」快速创建"})]}):e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:452:11",className:"grid grid-cols-1 gap-4",children:A.map(t=>e.jsx(y,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:454:15",children:e.jsx(w,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:455:17",className:"p-4",children:e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:456:19",className:"flex items-start justify-between",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:457:21",className:"flex-1",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:458:23",className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:459:25",className:"font-medium",children:t.name}),ae(t.severity),e.jsx(u,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:461:25",variant:t.enabled?"default":"secondary",children:t.enabled?"已启用":"已禁用"})]}),e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:465:23",className:"text-sm text-muted-foreground mb-2",children:t.description}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:466:23",className:"flex items-center gap-4 text-xs text-muted-foreground",children:[t.expression&&e.jsx("span",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:468:27",className:"font-mono bg-muted px-2 py-1 rounded",children:t.expression}),t.duration?e.jsxs("span",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:470:42",children:["持续 ",t.duration,"秒"]}):null]}),(()=>{let n=[];try{const s=t.notify_channels;s&&(n=Array.isArray(s)?s:JSON.parse(s))}catch{}return n.length?e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:480:27",className:"flex gap-1 mt-2",children:n.map(s=>e.jsx(u,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:482:31",variant:"outline",className:"text-xs",children:s},s))}):null})()]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:488:21",className:"flex items-center gap-2",children:[e.jsx(a,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:489:23",variant:"ghost",size:"sm",onClick:()=>We(t),children:"编辑"}),e.jsx(a,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:490:23",variant:"ghost",size:"sm",className:"text-red-400",onClick:()=>He(t),children:"删除"}),e.jsx(ot,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:491:23",checked:t.enabled,onCheckedChange:n=>Ue(String(t.id),n)})]})]})})},t.id))})]}),e.jsxs(F,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:505:9",value:"contacts",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:506:13",className:"flex justify-between items-center",children:[e.jsx("h3",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:507:15",className:"text-sm font-medium",children:"报警联系人"}),e.jsxs(a,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:508:15",size:"sm",onClick:()=>{ue(null),Q(!0)},children:[e.jsx(ee,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:509:17",className:"w-4 h-4 mr-1"}),"添加联系人"]})]}),L.length===0?e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:514:15",className:"text-center py-8 text-muted-foreground border border-dashed rounded-lg text-xs",children:"暂无报警联系人,点击「添加联系人」创建"}):e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:518:15",className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:L.map(t=>e.jsxs(y,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:520:19",className:"hover:border-primary/50 transition-colors",children:[e.jsx(Ne,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:521:21",className:"pb-2",children:e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:522:23",className:"flex items-start justify-between",children:e.jsx(ye,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:523:25",className:"text-sm",children:t.name})})}),e.jsxs(w,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:526:21",className:"pt-0 space-y-1 text-xs text-muted-foreground",children:[t.phone&&e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:527:35",children:["📱 ",t.phone]}),t.email&&e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:528:35",children:["📧 ",t.email]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:529:23",className:"flex gap-1 flex-wrap",children:[t.channel_type&&e.jsx(u,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:531:27",variant:"outline",className:"text-[10px]",children:dt(t.channel_type)}),t.webhook_url&&e.jsx("span",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:536:27",className:"text-[10px] text-muted-foreground truncate max-w-[200px]",title:t.webhook_url,children:t.webhook_url})]}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:541:23",className:"flex gap-1.5 pt-1.5",children:[e.jsx(a,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:542:25",variant:"outline",size:"sm",className:"h-7 text-xs flex-1",onClick:()=>{ue(t),Q(!0)},children:"编辑"}),e.jsx(a,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:546:25",variant:"outline",size:"sm",className:"h-7 text-xs",onClick:async()=>{if(await r({title:"删除联系人",description:`确定删除「${t.name}」?`,confirmText:"删除",variant:"destructive"}))try{await D.deleteContact(t.id),m.success("已删除"),$()}catch{m.error("删除失败")}},children:"删除"})]})]})]},t.id))})]}),e.jsxs(F,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:564:9",value:"groups",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:565:11",className:"flex justify-between items-center",children:[e.jsxs(a,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:566:13",variant:"outline",onClick:I,children:[e.jsx(Y,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:567:15",className:"w-4 h-4 mr-2"}),"刷新"]}),e.jsxs(a,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:570:13",onClick:()=>{Ce(null),Z(!0)},children:[e.jsx(ee,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:571:15",className:"w-4 h-4 mr-2"}),"添加联系组"]})]}),he.length===0?e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:576:13",className:"text-center py-16 text-muted-foreground border border-dashed rounded-lg",children:"暂无报警联系组,点击「添加联系组」创建"}):e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:580:13",className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:he.map(t=>{let n=[];try{n=JSON.parse(t.contact_ids||"[]")}catch{}const s=L.filter(p=>n.includes(p.id)).map(p=>p.name);return e.jsxs(y,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:588:19",className:"hover:border-primary/50 transition-colors",children:[e.jsx(Ne,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:589:21",children:e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:590:23",className:"flex items-start justify-between",children:[e.jsx(ye,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:591:25",className:"text-base",children:t.group_name}),e.jsxs(u,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:592:25",variant:"secondary",children:[n.length," 人"]})]})}),e.jsxs(w,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:595:21",className:"pt-0 space-y-2",children:[t.notes&&e.jsx("p",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:596:35",className:"text-sm text-muted-foreground",children:t.notes}),e.jsx("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:597:23",className:"flex flex-wrap gap-1",children:s.map(p=>e.jsx(u,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:599:27",variant:"outline",className:"text-xs",children:p},p))}),e.jsxs("div",{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:602:23",className:"flex gap-2 pt-2",children:[e.jsx(a,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:603:25",variant:"outline",size:"sm",className:"flex-1",onClick:()=>{Ce(t),Z(!0)},children:"编辑"}),e.jsx(a,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:607:25",variant:"outline",size:"sm",onClick:async()=>{if(await r({title:"删除联系组",description:`确定删除联系组「${t.group_name}」?`,confirmText:"删除",variant:"destructive"}))try{await D.deleteContactGroup(t.id),m.success("已删除"),I()}catch{m.error("删除失败")}},children:"删除"})]})]})]},t.id)})})]})]}),e.jsx(pt,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:626:7",alert:ie,open:Te,onOpenChange:de,onAcknowledge:Ae}),e.jsx(xt,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:632:7",alert:ie,open:Ge,onOpenChange:W,onSilence:Pe}),e.jsx(ct,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:638:7",open:Re,onOpenChange:fe,editingRule:ze,notifyChannels:[],onSaved:()=>{fe(),R()}}),e.jsx(ht,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:645:7",open:$e,onOpenChange:Q,editingContact:Ie,onSaved:$}),e.jsx(ut,{"code-path":"src/components/monitor/alert-center/AlertCenter.tsx:651:7",open:Me,onOpenChange:Z,editingGroup:Fe,contacts:L,onSaved:()=>{I()}})]})};export{zt as default};
|