import{Dr as e,Lr as t,Lt as n,M as r,Nr as i,P as a,Xn as o,Yn as s,br as c,er as l,fr as u,j as d,rr as f,tr as p,ur as m}from"./index-D6kmN0iw.js";import{a as h}from"./VSelectionControl-CB3RXt-d.js";import{t as g}from"./VSpacer-D_GqDOug.js";import{t as _}from"./VChip-BtzC63Ui.js";import{t as v}from"./VSelect-6PVoJJ_P.js";import{t as y}from"./VDataTableServer-ZeDQGEA6.js";import{t as b}from"./useServerList-B-lhmClk.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=e(!1),A=e(`commands`),j=e(1),M=e(0),N=e(30),P=e(null),F=e([]),I=e([]),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()}),(e,n)=>(u(),o(h,{fluid:``,class:`pa-6`},{default:c(()=>[p(r,{elevation:`0`,border:``,rounded:`lg`},{default:c(()=>[p(a,{class:`d-flex align-center`},{default:c(()=>[n[4]||=l(` 命令日志 `,-1),p(g),p(v,{modelValue:A.value,"onUpdate:modelValue":[n[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`]),p(v,{modelValue:P.value,"onUpdate:modelValue":[n[1]||=e=>P.value=e,z],items:i(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}),p(d),A.value===`commands`?(u(),o(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":n[2]||=e=>{j.value=e,z()}},{"item.command":c(({item:e})=>[s(`code`,x,t(e.command),1)]),"item.server_name":c(({item:e})=>[s(`span`,S,t(e.server_name||`—`),1)]),"item.admin_username":c(({item:e})=>[s(`span`,C,t(e.admin_username||`—`),1)]),"item.created_at":c(({item:e})=>[s(`span`,w,t(e.created_at),1)]),"no-data":c(()=>[...n[5]||=[s(`div`,{class:`text-center text-medium-emphasis py-6`},`暂无数据`,-1)]]),_:1},8,[`items`,`items-length`,`loading`,`page`])):(u(),o(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":n[3]||=e=>{j.value=e,z()}},{"item.server_name":c(({item:e})=>[s(`span`,T,t(e.server_name||`—`),1)]),"item.status":c(({item:e})=>[p(_,{color:e.status===`closed`?`grey`:`success`,size:`small`,variant:`tonal`,label:``},{default:c(()=>[l(t(e.status),1)]),_:2},1032,[`color`])]),"item.started_at":c(({item:e})=>[s(`span`,E,t(e.started_at),1)]),"no-data":c(()=>[...n[6]||=[s(`div`,{class:`text-center text-medium-emphasis py-6`},`暂无数据`,-1)]]),_:1},8,[`items`,`items-length`,`loading`,`page`]))]),_:1})]),_:1}))}});export{D as default};