import{c as e,at as a,g as t,v as s,x as l,z as r,A as n,y as i,K as o,N as c,B as d,C as u,D as p,e as m,F as v,b0 as k,L as g,I as y,J as f,G as b,aS as x}from"./base-lib.js?v=1761009159";import{aP as _,V as h,P as w,bO as I,_ as C}from"./utils-lib.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";const S={class:"container-dialog"},P={class:"pb-[3rem] border-b border-dark"},T={class:"flex items-center ml-[2rem]"},j={class:"ml-[1rem]"},A={class:"flex mt-[2rem] ml-[2rem]"},D={class:"table ml-[2rem] mt-[2rem]"},N={class:"w-[30%]"},O={key:0,class:"w-[70%] truncate"},G=["onClick"],H={key:1,class:"h-[5rem] flex items-center"},J=C(e({__name:"container-status",setup(e){const{refs:{currentConDetail:C},getCurrentCon:J,refreshActiveTable:L}=_(),M=[{key:"name",label:"容器名称"},{key:"id",label:"容器ID",tooltip:!0},{key:"image",label:"使用的镜像"},{key:"run",label:"运行时间"},{key:"created",label:"创建时间"},{key:"start",label:"启动时间"},{key:"port",label:"端口",tag:!0,expand:a(!1)},{key:"ip",label:"IP",tag:!0,expand:a(!1)},{key:"ipv6",label:"IPV6",tag:!0,expand:a(!1)}],V=t(()=>B(C.value)),q=t(()=>{var e,a;return"running"===(null==(a=null==(e=C.value)?void 0:e.State)?void 0:a.Status)}),z=e=>{const a=new Date(e).getTime();return h(a)},B=e=>{var a,t,s,l,r;if(!e.Id)return{name:"正在获取...",id:"正在获取...",idTip:"正在获取...",run:"正在获取...",created:"正在获取...",start:"正在获取...",image:"正在获取...",port:[],ip:[],ipv6:[]};const n=e.Name,i=e.Id.slice(0,12),o=(null==(a=e.Config)?void 0:a.Image)||"--",c=((e,a)=>{const t=Math.abs(e-a);return Math.floor(t/36e5)})((new Date).getTime(),new Date(null==(t=C.value.State)?void 0:t.StartedAt).getTime()),d=z(e.Created),u=z(null==(s=e.State)?void 0:s.StartedAt),p=Object.entries((null==(l=e.NetworkSettings)?void 0:l.Ports)||{})||[],m=[];p.forEach(e=>{e[1]&&m.push("".concat(e[1][0].HostPort,"--\x3e").concat(e[0]," "))});const v=Object.values((null==(r=e.NetworkSettings)?void 0:r.Networks)||{}),k=v.map(e=>e.IPAddress).filter(e=>""!==e)||[],g=v.map(e=>e.GlobalIPv6Address).filter(e=>""!==e)||[];return{name:n,id:i,idTip:e.Id,image:o,run:c>0?"".concat(c,"小时"):"不到1小时",created:d,start:u,port:m,ip:k,ipv6:g}},E=async e=>{const a="start"==e?"启动":"stop"==e?"停止":"重启",t={id:C.value.Id,status:e};await w({request:I({data:JSON.stringify(t)}),message:!0,loading:"正在".concat(a,"容器，请稍候..."),success:e=>{e.status&&(J(C.value.Id),L())}})};return(e,a)=>{const t=b,_=x;return s(),l("div",S,[r("div",P,[r("div",T,[a[3]||(a[3]=r("span",null,"当前状态：",-1)),r("span",j,n(i(q)?"运行中":"已停止"),1),r("span",{class:o(i(q)?"svgtofont-icon-start text-primary":"svgtofont-icon-stop text-danger")},null,2)]),r("div",A,[i(q)?p("",!0):(s(),c(t,{key:0,onClick:a[0]||(a[0]=e=>E("start"))},{default:d(()=>a[4]||(a[4]=[u(" 启动 ",-1)])),_:1,__:[4]})),i(q)?(s(),c(t,{key:1,onClick:a[1]||(a[1]=e=>E("stop"))},{default:d(()=>a[5]||(a[5]=[u("停止",-1)])),_:1,__:[5]})):p("",!0),m(t,{onClick:a[2]||(a[2]=e=>E("restart"))},{default:d(()=>a[6]||(a[6]=[u("重启",-1)])),_:1,__:[6]})])]),r("div",D,[(s(),l(v,null,k(M,e=>r("div",{key:e.key,class:"item"},[r("div",N,n(e.label),1),e.tag?p("",!0):(s(),l("div",O,[m(_,{ref_for:!0,ref:"tlp",content:i(V)["".concat(e.key,"Tip")],disabled:!e.tooltip,placement:"top"},{default:d(()=>[r("span",null,n(i(V)[e.key]),1)]),_:2},1032,["content","disabled"])])),e.tag?(s(),l("div",{key:1,class:o(["w-[70%] relative",{"cursor-pointer":i(V)[e.key].length>("ipv6"===e.key?2:3)}]),onClick:a=>(e=>{var a;!e.tag||(null==(a=V.value[e.key])?void 0:a.length)<=("ipv6"===e.key?2:3)||(e.expand.value=!e.expand.value)})(e)},[i(V)[e.key].length>0?(s(),l("div",{key:0,class:o(["py-[1rem] pr-[2rem] min-h-[5rem] grid gap-[1rem]",{"h-[5rem]":!e.expand.value,"items-center":!e.expand.value}]),style:g("grid-template-columns: repeat(auto-fill, minmax(".concat("ipv6"===e.key?"16":"13","rem, 1fr))"))},[(s(!0),l(v,null,k(i(V)[e.key],(a,t)=>y((s(),l("span",{key:a,class:"custom-success-tag"},n(a),513)),[[f,("ipv6"===e.key?t<2:t<3)||e.expand.value]])),128)),i(V)[e.key].length>("ipv6"===e.key?2:3)?(s(),l("span",{key:0,class:o(["absolute top-[50%] right-[0rem] text-extraLarge",e.expand.value?"svgtofont-el-arrow-up":"svgtofont-el-arrow-down"]),style:{transform:"translateY(-50%)"}},null,2)):p("",!0)],6)):p("",!0),i(V)[e.key].length?p("",!0):(s(),l("div",H,"--"))],10,G)):p("",!0)])),64))])])}}}),[["__scopeId","data-v-443c08f1"]]);export{J as default};
