import{n as e,t}from"./useSnackbar-BFeYjAzp.js";import{n,t as r}from"./VRow-ZHldweuW.js";import{Cr as i,Er as a,Or as o,Q as s,Tr as c,Ur as l,Vr as u,Zr as d,_ as f,br as p,di as m,en as h,gr as g,h as _,hi as v,ii as y,l as b,m as x,qt as S,xr as C,y as w}from"./index-BKLG6eUi.js";import{t as T}from"./usePageActivateRefresh-BXQgZGHS.js";import{n as E,t as D}from"./dataTable-esDY4cOk.js";import{n as O}from"./paginatedFetch-Bh_Ds7m8.js";import{_ as k,b as A}from"./VTextField-Bs8XQAKI.js";import{t as j}from"./VSelect-Dy70bHJm.js";import{t as M}from"./VDataTableServer-GLUwxaQu.js";var N={class:`font-weight-medium`},P={class:`text-body-2`},F={class:`text-caption text-medium-emphasis`},I=o({name:`AlertsPage`,__name:`AlertsPage`,setup(o){let I=t(),L=y(!1),R=y([]),z=y(0),B=y(1),V=y(20),H=D,U=y(null),W=y(null),G=y([{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`}]),K=[{label:`CPU`,value:`cpu`},{label:`内存`,value:`memory`},{label:`磁盘`,value:`disk`},{label:`连接`,value:`connection`}],q=[{label:`活跃`,value:`active`},{label:`已恢复`,value:`recovered`}],J=E([{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 Y(){try{let e=await h.get(`/alert-history/stats`);G.value[0].value=String(e.today||0),G.value[1].value=String(e.active||0),G.value[2].value=String(e.recovered||0),G.value[3].value=e.top_server||`—`}catch{I(`加载统计失败`,`error`)}}function X(e){B.value=e,Q()}function Z(e){V.value=e,B.value=1,Q()}async function Q(e=!1){e||(L.value=!0);try{let e=await O(`/alert-history/`,{type:U.value||void 0,status:W.value||void 0},B.value,V.value);R.value=e.items,z.value=e.total,V.value===-1&&(B.value=1)}catch{R.value=[],z.value=0,I(`加载告警列表失败`,`error`)}finally{e||(L.value=!1)}}function $(e){return e===`cpu`||e===`CPU`?`error`:e===`memory`||e===`内存`?`warning`:e===`disk`||e===`磁盘`?`info`:`primary`}function ee(e){return e===`cpu`||e===`CPU`?`mdi-chip`:e===`memory`||e===`内存`?`mdi-memory`:e===`disk`||e===`磁盘`?`mdi-harddisk`:`mdi-lan-disconnect`}async function te(e=!1){await Promise.all([Y(),Q(e)])}return T(e=>te(e)),(t,o)=>(u(),C(e,{fluid:``,class:`pa-6`},{default:d(()=>[a(r,{class:`mb-4`},{default:d(()=>[(u(!0),i(g,null,l(G.value,e=>(u(),C(n,{cols:`12`,sm:`6`,lg:`3`,key:e.label},{default:d(()=>[a(b,{elevation:`0`,lines:`two`,rounded:`lg`,border:``},{default:d(()=>[a(x,null,{append:d(()=>[a(s,{color:e.color,size:`30`},{default:d(()=>[c(v(e.icon),1)]),_:2},1032,[`color`])]),default:d(()=>[a(_,{class:`text-body-small`},{default:d(()=>[c(v(e.label),1)]),_:2},1024),a(_,null,{default:d(()=>[c(v(e.value),1)]),_:2},1024)]),_:2},1024)]),_:2},1024)]),_:2},1024))),128))]),_:1}),a(k,{elevation:`0`,border:``,rounded:`lg`},{default:d(()=>[a(A,{class:`d-flex align-center`},{default:d(()=>[o[4]||=c(` 告警历史 `,-1),a(f),a(j,{modelValue:U.value,"onUpdate:modelValue":[o[0]||=e=>U.value=e,o[1]||=e=>{B.value=1,Q()}],items:K,"item-title":`label`,"item-value":`value`,label:`类型`,variant:`outlined`,density:`compact`,"hide-details":``,style:{"max-width":`140px`},clearable:``},null,8,[`modelValue`]),a(j,{modelValue:W.value,"onUpdate:modelValue":[o[2]||=e=>W.value=e,o[3]||=e=>{B.value=1,Q()}],items:q,"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}),a(M,{items:R.value,headers:m(J),"items-length":z.value,loading:L.value,page:B.value,"items-per-page":V.value,"items-per-page-options":m(H),hover:``,density:`comfortable`,"onUpdate:page":X,"onUpdate:itemsPerPage":Z},{"item.alert_type":d(({item:e})=>[a(w,{color:$(e.alert_type),size:`small`,variant:`tonal`,label:``},{prepend:d(()=>[a(s,{size:`12`},{default:d(()=>[c(v(ee(e.alert_type)),1)]),_:2},1024)]),default:d(()=>[c(` `+v(e.alert_type),1)]),_:2},1032,[`color`])]),"item.server_name":d(({item:e})=>[p(`span`,N,v(e.server_name),1)]),"item.value":d(({item:e})=>[p(`span`,P,v(e.value),1)]),"item.is_recovery":d(({item:e})=>[e.is_recovery?(u(),C(w,{key:0,color:`success`,size:`small`,variant:`tonal`,label:``},{default:d(()=>[...o[5]||=[c(`已恢复`,-1)]]),_:1})):(u(),C(w,{key:1,color:`error`,size:`small`,variant:`tonal`,label:``},{default:d(()=>[...o[6]||=[c(`告警中`,-1)]]),_:1}))]),"item.created_at":d(({item:e})=>[p(`span`,F,v(m(S)(e.created_at)),1)]),"no-data":d(()=>[...o[7]||=[p(`div`,{class:`text-center text-medium-emphasis py-6`},`暂无数据`,-1)]]),_:1},8,[`items`,`headers`,`items-length`,`loading`,`page`,`items-per-page`,`items-per-page-options`])]),_:1})]),_:1}))}});export{I as default};