import{$n as e,A as t,Ar as n,Gn as r,Jn as i,M as a,P as o,Qn as s,Rt as c,T as l,Xn as u,Y as d,br as f,cr as p,fr as m,gr as h,k as g,qn as _,tr as v,ur as y}from"./index-Dr0D0hQu.js";import{t as b}from"./useSnackbar-D7YOfKok.js";import{t as x}from"./VChip-BASRYLBn.js";import{a as S}from"./VSelectionControl-BWDawnx3.js";import{n as C,t as w}from"./VRow-CrnE-Xma.js";import{t as T}from"./VSpacer-C6Z-OqDQ.js";import{t as E}from"./VSelect-IetqarsS.js";import{t as D}from"./VDataTableServer-DQKBz4QV.js";var O={class:`font-weight-medium`},k={class:`text-body-2`},A={class:`text-caption text-medium-emphasis`},j=v({__name:`AlertsPage`,setup(v){let j=b(),M=f(!1),N=f([]),P=f(0),F=f(1),I=f(null),L=f(null),R=f([{label:`今日告警`,value:`0`,color:`blue`,icon:`mdi-alert`},{label:`活跃告警`,value:`0`,color:`orange`,icon:`mdi-bell-ring`},{label:`已恢复`,value:`0`,color:`green`,icon:`mdi-check-circle`},{label:`Top 服务器`,value:`—`,color:`red`,icon:`mdi-server`}]),z=[{label:`CPU`,value:`cpu`},{label:`内存`,value:`memory`},{label:`磁盘`,value:`disk`},{label:`连接`,value:`connection`}],B=[{label:`活跃`,value:`active`},{label:`已恢复`,value:`recovered`}],V=[{title:`类型`,key:`alert_type`,width:100},{title:`服务器`,key:`server_name`},{title:`详情`,key:`value`},{title:`状态`,key:`is_recovery`,width:100},{title:`时间`,key:`created_at`,width:160}];async function H(){try{let e=await c.get(`/alert-history/stats`);R.value[0].value=String(e.today||0),R.value[1].value=String(e.active||0),R.value[2].value=String(e.recovered||0),R.value[3].value=e.top_server||`—`}catch{j(`加载统计失败`,`error`)}}async function U(){M.value=!0;try{let e=await c.get(`/alert-history/`,{page:F.value,per_page:20,type:I.value||void 0,status:L.value||void 0});N.value=e.items||[],P.value=e.total||0}catch{N.value=[]}finally{M.value=!1}}function W(e){return e===`cpu`||e===`CPU`?`error`:e===`memory`||e===`内存`?`warning`:e===`disk`||e===`磁盘`?`info`:`primary`}function G(e){return e===`cpu`||e===`CPU`?`mdi-chip`:e===`memory`||e===`内存`?`mdi-memory`:e===`disk`||e===`磁盘`?`mdi-harddisk`:`mdi-lan-disconnect`}return p(()=>{H(),U()}),(c,f)=>(y(),i(S,{fluid:``,class:`pa-6`},{default:h(()=>[e(w,{class:`mb-4`},{default:h(()=>[(y(!0),u(r,null,m(R.value,r=>(y(),i(C,{cols:`12`,sm:`6`,lg:`3`,key:r.label},{default:h(()=>[e(l,{elevation:`0`,lines:`two`,rounded:`lg`,border:``},{default:h(()=>[e(g,null,{append:h(()=>[e(d,{color:r.color,size:`30`},{default:h(()=>[s(n(r.icon),1)]),_:2},1032,[`color`])]),default:h(()=>[e(t,{class:`text-body-small`},{default:h(()=>[s(n(r.label),1)]),_:2},1024),e(t,null,{default:h(()=>[s(n(r.value),1)]),_:2},1024)]),_:2},1024)]),_:2},1024)]),_:2},1024))),128))]),_:1}),e(a,{elevation:`0`,border:``,rounded:`lg`},{default:h(()=>[e(o,{class:`d-flex align-center`},{default:h(()=>[f[5]||=s(` 告警历史 `,-1),e(T),e(E,{modelValue:I.value,"onUpdate:modelValue":[f[0]||=e=>I.value=e,f[1]||=e=>{F.value=1,U()}],items:z,"item-title":`label`,"item-value":`value`,label:`类型`,variant:`outlined`,density:`compact`,"hide-details":``,style:{"max-width":`140px`},clearable:``},null,8,[`modelValue`]),e(E,{modelValue:L.value,"onUpdate:modelValue":[f[2]||=e=>L.value=e,f[3]||=e=>{F.value=1,U()}],items:B,"item-title":`label`,"item-value":`value`,label:`状态`,variant:`outlined`,density:`compact`,"hide-details":``,style:{"max-width":`140px`},class:`ml-3`,clearable:``},null,8,[`modelValue`])]),_:1}),e(D,{items:N.value,headers:V,"items-length":P.value,loading:M.value,page:F.value,"items-per-page":20,hover:``,density:`comfortable`,"onUpdate:page":f[4]||=e=>{F.value=e,U()}},{"item.alert_type":h(({item:t})=>[e(x,{color:W(t.alert_type),size:`small`,variant:`tonal`,label:``},{prepend:h(()=>[e(d,{size:`12`},{default:h(()=>[s(n(G(t.alert_type)),1)]),_:2},1024)]),default:h(()=>[s(` `+n(t.alert_type),1)]),_:2},1032,[`color`])]),"item.server_name":h(({item:e})=>[_(`span`,O,n(e.server_name),1)]),"item.value":h(({item:e})=>[_(`span`,k,n(e.value),1)]),"item.is_recovery":h(({item:e})=>[e.is_recovery?(y(),i(x,{key:0,color:`success`,size:`small`,variant:`tonal`,label:``},{default:h(()=>[...f[6]||=[s(`已恢复`,-1)]]),_:1})):(y(),i(x,{key:1,color:`error`,size:`small`,variant:`tonal`,label:``},{default:h(()=>[...f[7]||=[s(`告警中`,-1)]]),_:1}))]),"item.created_at":h(({item:e})=>[_(`span`,A,n(e.created_at),1)]),"no-data":h(()=>[...f[8]||=[_(`div`,{class:`text-center text-medium-emphasis py-6`},`暂无数据`,-1)]]),_:1},8,[`items`,`items-length`,`loading`,`page`])]),_:1})]),_:1}))}});export{j as default};