import{c as e,t as a,o as l,r as t,q as s,v as r,N as o,B as u,e as n,C as i,A as m,y as d,z as p,R as _,ab as c,T as g,U as f,G as w,a9 as v}from"./base-lib.js?v=1761009159";import{aP as b,M as y,p as V,P as h,h7 as C}from"./utils-lib.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";const I={class:"max-w-[35rem] truncate"},j=e({__name:"container-upgrade",props:{compData:{default:()=>({})}},emits:["close"],setup(e,{emit:j}){const{refs:{currentConDetail:U}}=b(),q=e,x=j,{row:D}=a(q.compData),k=l({new_image:"latest",upgrade:!1,pull:!1}),M=t(),N={new_image:[{required:!0,message:"请输入目标镜像版本",trigger:["blur"]}]},P=async()=>{await M.value.validate(),!(()=>{const e=U.value.Config.Image.split(":")[1],a=k.new_image;if("latest"==e||"latest"==a)return!1;const l=e.split("."),t=a.split(".");for(let s=0;s<Math.max(l.length,t.length);s++){const e=parseInt(l[s])||0,a=parseInt(t[s])||0;if(e<a)return!1;if(e>a)return!0}})()||k.upgrade?(await V({title:"升级",content:"升级操作需要重建容器，任何未持久化的数据将会丢失，是否继续？"}),h({request:C({data:JSON.stringify({new_image:k.new_image,upgrade:"1",id:D.value.id,force_pull:k.pull?"1":"0"})}),message:!0,success:async e=>{e.status&&(x("close"),setTimeout(()=>{window.location.reload()},1e3))}})):y.error("检测到当前目标版本低于原镜像版本，请重新输入或点击强制升级！")};return s(async()=>{}),(e,a)=>{const l=c,t=g,s=f,b=w,y=v;return r(),o(y,{ref_key:"cmdFormRef",ref:M,model:d(k),rules:N,onSubmit:a[3]||(a[3]=_(()=>{},["prevent"]))},{default:u(()=>[n(l,{label:"当前镜像"},{default:u(()=>{var e;return[i(m((null==(e=d(U).Config)?void 0:e.Image)||""),1)]}),_:1}),n(l,{prop:"new_image",label:"目标镜像"},{default:u(()=>[n(t,{modelValue:d(k).new_image,"onUpdate:modelValue":a[0]||(a[0]=e=>d(k).new_image=e),style:{width:"50rem"},placeholder:"请输入版本号"},{prepend:u(()=>{var e;return[p("div",I,m((null==(e=d(U).Config)?void 0:e.Image.split(":")[0])||""),1)]}),_:1},8,["modelValue"])]),_:1}),n(l,{label:" "},{default:u(()=>[n(s,{modelValue:d(k).upgrade,"onUpdate:modelValue":a[1]||(a[1]=e=>d(k).upgrade=e)},{default:u(()=>a[4]||(a[4]=[i("强制升级",-1)])),_:1,__:[4]},8,["modelValue"])]),_:1}),n(l,{label:" "},{default:u(()=>[n(s,{modelValue:d(k).pull,"onUpdate:modelValue":a[2]||(a[2]=e=>d(k).pull=e)},{default:u(()=>a[5]||(a[5]=[i("强制拉取镜像",-1)])),_:1,__:[5]},8,["modelValue"])]),_:1}),n(b,{class:"ml-[10rem]",type:"primary",onClick:P},{default:u(()=>a[6]||(a[6]=[i("保存配置",-1)])),_:1,__:[6]})]),_:1},8,["model"])}}});export{j as default};
