import{Ar as e,Er as t,It as n,Kn as r,M as i,P as a,Qn as o,Zn as s,br as c,er as l,gr as u,j as d,lr as f,qn as p,sr as m}from"./index-DUEFNqm3.js";import{a as h}from"./VSelectionControl-9aWkfgIK.js";import{t as g}from"./VSpacer-B5IkWXXo.js";import{t as _}from"./VChip-WOREmFB2.js";import{t as v}from"./VSelect-nnPFAUxC.js";import{t as y}from"./VDataTableServer-BzS7y6z-.js";import{t as b}from"./useServerList-C47EoI9D.js";var x={class:`text-body-2`},S={class:`text-medium-emphasis`},C={class:`text-medium-emphasis`},w={class:`text-caption text-medium-emphasis`},T={class:`font-weight-medium`},E={class:`text-caption text-medium-emphasis`},D=l({__name:`CommandsPage`,setup(l){let{servers:D,loadServers:O}=b(),k=c(!1),A=c(`commands`),j=c(1),M=c(0),N=c(30),P=c(null),F=c([]),I=c([]),L=[{title:`命令`,key:`command`},{title:`服务器`,key:`server_name`},{title:`用户`,key:`admin_username`,width:100},{title:`时间`,key:`created_at`,width:160}],R=[{title:`服务器`,key:`server_name`},{title:`状态`,key:`status`,width:80},{title:`来源`,key:`remote_addr`,width:120},{title:`开始时间`,key:`started_at`,width:160}];async function z(){k.value=!0;try{if(A.value===`commands`){let e=await n.getList(`/assets/command-logs`,{server_id:P.value||void 0,page:j.value,per_page:N.value});F.value=e.items,M.value=e.total}else{let e=await n.getList(`/assets/ssh-sessions`,{server_id:P.value||void 0,page:j.value,per_page:N.value});I.value=e.items,M.value=e.total}}catch{F.value=[],I.value=[]}finally{k.value=!1}}return m(()=>{O(),z()}),(n,c)=>(f(),p(h,{fluid:``,class:`pa-6`},{default:u(()=>[o(i,{elevation:`0`,border:``,rounded:`lg`},{default:u(()=>[o(a,{class:`d-flex align-center`},{default:u(()=>[c[4]||=s(` 命令日志 `,-1),o(g),o(v,{modelValue:A.value,"onUpdate:modelValue":[c[0]||=e=>A.value=e,z],items:[{title:`命令视图`,value:`commands`},{title:`会话视图`,value:`sessions`}],"item-title":`title`,"item-value":`value`,variant:`outlined`,density:`compact`,"hide-details":``,style:{"max-width":`160px`}},null,8,[`modelValue`]),o(v,{modelValue:P.value,"onUpdate:modelValue":[c[1]||=e=>P.value=e,z],items:t(D),"item-title":`name`,"item-value":`id`,label:`服务器`,variant:`outlined`,density:`compact`,"hide-details":``,style:{"max-width":`180px`},class:`ml-3`,clearable:``},null,8,[`modelValue`,`items`])]),_:1}),o(d),A.value===`commands`?(f(),p(y,{key:0,items:F.value,headers:L,"items-length":M.value,loading:k.value,page:j.value,"items-per-page":30,hover:``,density:`compact`,"onUpdate:page":c[2]||=e=>{j.value=e,z()}},{"item.command":u(({item:t})=>[r(`code`,x,e(t.command),1)]),"item.server_name":u(({item:t})=>[r(`span`,S,e(t.server_name||`—`),1)]),"item.admin_username":u(({item:t})=>[r(`span`,C,e(t.admin_username||`—`),1)]),"item.created_at":u(({item:t})=>[r(`span`,w,e(t.created_at),1)]),"no-data":u(()=>[...c[5]||=[r(`div`,{class:`text-center text-medium-emphasis py-6`},`暂无数据`,-1)]]),_:1},8,[`items`,`items-length`,`loading`,`page`])):(f(),p(y,{key:1,items:I.value,headers:R,"items-length":M.value,loading:k.value,page:j.value,"items-per-page":30,hover:``,density:`compact`,"onUpdate:page":c[3]||=e=>{j.value=e,z()}},{"item.server_name":u(({item:t})=>[r(`span`,T,e(t.server_name||`—`),1)]),"item.status":u(({item:t})=>[o(_,{color:t.status===`closed`?`grey`:`success`,size:`small`,variant:`tonal`,label:``},{default:u(()=>[s(e(t.status),1)]),_:2},1032,[`color`])]),"item.started_at":u(({item:t})=>[r(`span`,E,e(t.started_at),1)]),"no-data":u(()=>[...c[6]||=[r(`div`,{class:`text-center text-medium-emphasis py-6`},`暂无数据`,-1)]]),_:1},8,[`items`,`items-length`,`loading`,`page`]))]),_:1})]),_:1}))}});export{D as default};