import{$n as e,Dr as t,Jn as n,M as r,P as i,Qn as a,Rt as o,_r as s,cr as c,j as l,jr as u,qn as d,tr as f,ur as p,xr as m}from"./index-S1YK6zxF.js";import{t as h}from"./VChip-DtHsaJZp.js";import{a as g}from"./VSelectionControl-CppJho83.js";import{t as _}from"./VSpacer-WuA4duee.js";import{t as v}from"./VSelect-xRav0l2r.js";import{t as y}from"./VDataTableServer-KU9hdj6p.js";import{t as b}from"./useServerList-iiDiddo5.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=f({__name:`CommandsPage`,setup(f){let{servers:D,loadServers:O}=b(),k=m(!1),A=m(`commands`),j=m(1),M=m(0),N=m(30),P=m(null),F=m([]),I=m([]),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 o.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 o.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 c(()=>{O(),z()}),(o,c)=>(p(),n(g,{fluid:``,class:`pa-6`},{default:s(()=>[e(r,{elevation:`0`,border:``,rounded:`lg`},{default:s(()=>[e(i,{class:`d-flex align-center`},{default:s(()=>[c[4]||=a(` 命令日志 `,-1),e(_),e(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`]),e(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}),e(l),A.value===`commands`?(p(),n(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":s(({item:e})=>[d(`code`,x,u(e.command),1)]),"item.server_name":s(({item:e})=>[d(`span`,S,u(e.server_name||`—`),1)]),"item.admin_username":s(({item:e})=>[d(`span`,C,u(e.admin_username||`—`),1)]),"item.created_at":s(({item:e})=>[d(`span`,w,u(e.created_at),1)]),"no-data":s(()=>[...c[5]||=[d(`div`,{class:`text-center text-medium-emphasis py-6`},`暂无数据`,-1)]]),_:1},8,[`items`,`items-length`,`loading`,`page`])):(p(),n(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":s(({item:e})=>[d(`span`,T,u(e.server_name||`—`),1)]),"item.status":s(({item:t})=>[e(h,{color:t.status===`closed`?`grey`:`success`,size:`small`,variant:`tonal`,label:``},{default:s(()=>[a(u(t.status),1)]),_:2},1032,[`color`])]),"item.started_at":s(({item:e})=>[d(`span`,E,u(e.started_at),1)]),"no-data":s(()=>[...c[6]||=[d(`div`,{class:`text-center text-medium-emphasis py-6`},`暂无数据`,-1)]]),_:1},8,[`items`,`items-length`,`loading`,`page`]))]),_:1})]),_:1}))}});export{D as default};