import{Ar as e,It as t,Kn as n,M as r,O as i,P as a,Qn as o,Un as s,Y as c,Yn as l,Zn as u,br as d,dr as f,er as p,gr as m,k as h,lr as g,qn as _,sr as v,w as y}from"./index-CW0-iTHP.js";import{a as b}from"./VSelectionControl-BMKbJ2fF.js";import{n as x,t as S}from"./VRow-D_8vUXB_.js";import{t as C}from"./VSpacer-BktjR1YY.js";import{t as w}from"./useSnackbar-D7YOfKok.js";import{t as T}from"./VChip-3FLli2MP.js";import{t as E}from"./VSelect-DAawRCyV.js";import{t as D}from"./VDataTableServer-ti_w4FEr.js";var O={class:`font-weight-medium`},k={class:`text-body-2`},A={class:`text-caption text-medium-emphasis`},j=p({__name:`AlertsPage`,setup(p){let j=w(),M=d(!1),N=d([]),P=d(0),F=d(1),I=d(null),L=d(null),R=d([{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 t.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 t.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 v(()=>{H(),U()}),(t,d)=>(g(),_(b,{fluid:``,class:`pa-6`},{default:m(()=>[o(S,{class:`mb-4`},{default:m(()=>[(g(!0),l(s,null,f(R.value,t=>(g(),_(x,{cols:`12`,sm:`6`,lg:`3`,key:t.label},{default:m(()=>[o(y,{elevation:`0`,lines:`two`,rounded:`lg`,border:``},{default:m(()=>[o(i,null,{append:m(()=>[o(c,{color:t.color,size:`30`},{default:m(()=>[u(e(t.icon),1)]),_:2},1032,[`color`])]),default:m(()=>[o(h,{class:`text-body-small`},{default:m(()=>[u(e(t.label),1)]),_:2},1024),o(h,null,{default:m(()=>[u(e(t.value),1)]),_:2},1024)]),_:2},1024)]),_:2},1024)]),_:2},1024))),128))]),_:1}),o(r,{elevation:`0`,border:``,rounded:`lg`},{default:m(()=>[o(a,{class:`d-flex align-center`},{default:m(()=>[d[5]||=u(` 告警历史 `,-1),o(C),o(E,{modelValue:I.value,"onUpdate:modelValue":[d[0]||=e=>I.value=e,d[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`]),o(E,{modelValue:L.value,"onUpdate:modelValue":[d[2]||=e=>L.value=e,d[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}),o(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":d[4]||=e=>{F.value=e,U()}},{"item.alert_type":m(({item:t})=>[o(T,{color:W(t.alert_type),size:`small`,variant:`tonal`,label:``},{prepend:m(()=>[o(c,{size:`12`},{default:m(()=>[u(e(G(t.alert_type)),1)]),_:2},1024)]),default:m(()=>[u(` `+e(t.alert_type),1)]),_:2},1032,[`color`])]),"item.server_name":m(({item:t})=>[n(`span`,O,e(t.server_name),1)]),"item.value":m(({item:t})=>[n(`span`,k,e(t.value),1)]),"item.is_recovery":m(({item:e})=>[e.is_recovery?(g(),_(T,{key:0,color:`success`,size:`small`,variant:`tonal`,label:``},{default:m(()=>[...d[6]||=[u(`已恢复`,-1)]]),_:1})):(g(),_(T,{key:1,color:`error`,size:`small`,variant:`tonal`,label:``},{default:m(()=>[...d[7]||=[u(`告警中`,-1)]]),_:1}))]),"item.created_at":m(({item:t})=>[n(`span`,A,e(t.created_at),1)]),"no-data":m(()=>[...d[8]||=[n(`div`,{class:`text-center text-medium-emphasis py-6`},`暂无数据`,-1)]]),_:1},8,[`items`,`items-length`,`loading`,`page`])]),_:1})]),_:1}))}});export{j as default};