import{aP as e,P as a,cq as l,M as s,ay as o,h6 as n,ax as u,aC as r,_ as m}from"./utils-lib.js?v=1761009159";import{r as t,o as d,c,q as i,a6 as _,v as f,x as p,e as v,B as b,y as g,R as y,P as h,C as x,z as V,Q as w,ab as C,G as k,T as j,a9 as q,aC as R}from"./base-lib.js?v=1761009159";import{_ as T}from"./index119.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";const{refs:{isRefreshTableList:U}}=e();let z=null;const P=t(!1),E=t(""),K=t("common"),M=d({name:"",image:"",cmd:""}),S={model_index:"btdocker",mod_name:"image",def_name:"pull_from_some_registry",ws_callback:111,name:"",image:""},A=()=>{E.value=""},B=(e,a)=>{try{const e=a.data;if(E.value+="".concat(e),e.includes("bt_successful")||e.includes("bt_failed")){const a={status:e.includes("bt_successful"),msg:e.includes("bt_successful")?"拉取成功":"拉取失败"};s.request(a),a.status&&(U.value=!0),null==z||z.close(),P.value=!1}}catch(l){}},F=()=>{null==z||z.close(),E.value="",z=o({route:"/ws_model",onMessage:B}),null==z||z.send(S)},G={image:[{validator:(e,a,l)=>{""===a?l(new Error("请输入镜像名")):l()},trigger:["blur"]}]},H=()=>{U.value=!0},I=t([]),L=async e=>{try{if("cmd"===K.value)return void(async()=>{try{if(""===M.cmd)return void s.error("请输入命令");P.value=!0,S.name="",S.url="",S.image="",S.def_name="get_cmd_log";const e=await n({cmd:M.cmd},"image");e.status?F():(s.error(e.msg),P.value=!1)}catch(e){}})();if(""===M.name)return void s.error("请选择仓库名");P.value=!0,await e.value.validate(async e=>{e?(S.name=I.value.find(e=>e.url==M.name).name,S.url=I.value.find(e=>e.url==M.name).url,S.image=M.image,S.def_name="pull_from_some_registry",F()):P.value=!1})}catch(a){}},Q={class:"flex flex-col p-[1.6rem] lib-box"},D={class:"rounded-small h-[45.6rem]"},J={class:"rounded-small h-[45.6rem]"},N=m(c({__name:"index",setup(e,{expose:s}){const o=t(),n=()=>{L(o)};return i(()=>{(async()=>{a({request:l(),data:Array,success:e=>{var a;e.forEach(e=>{I.value.push({value:e.url,label:"".concat(e.name).concat("docker.io"===e.url?"":"(".concat(e.url,")")),url:e.url,name:e.name})}),M.name=null==(a=I.value[0])?void 0:a.value}})})()}),_(()=>{null==z||z.close(),z=null,I.value=[],M.name="",M.image="",M.cmd="",A()}),s({onConfirm:n,onCancel:H}),(e,a)=>{const l=u,s=C,m=k,t=j,d=T,c=q,i=R,_=r;return f(),p("div",Q,[v(_,{modelValue:g(K),"onUpdate:modelValue":a[5]||(a[5]=e=>w(K)?K.value=e:null),type:"card",onChange:g(A)},{default:b(()=>[v(i,{name:"common",label:"常规拉取"},{default:b(()=>[v(c,{ref_key:"cmdFormRef",ref:o,size:"default",model:g(M),rules:g(G),disabled:g(P),class:"relative w-full","label-position":"right",onSubmit:a[2]||(a[2]=y(()=>{},["prevent"]))},{default:b(()=>[v(s,{prop:"name",label:"仓库名"},{default:b(()=>[v(l,{modelValue:g(M).name,"onUpdate:modelValue":a[0]||(a[0]=e=>g(M).name=e),options:g(I),class:"!w-[32rem]"},null,8,["modelValue","options"])]),_:1}),v(s,{prop:"image",label:"镜像名"},{default:b(()=>[v(t,{class:"!w-[32rem]",modelValue:g(M).image,"onUpdate:modelValue":a[1]||(a[1]=e=>g(M).image=e),onKeydown:h(n,["enter"]),placeholder:"请输入镜像名，按回车拉取,如:image:v1"},{append:b(()=>[v(m,{type:"default",onClick:n},{default:b(()=>a[6]||(a[6]=[x("拉取",-1)])),_:1,__:[6]})]),_:1},8,["modelValue"])]),_:1}),a[7]||(a[7]=V("div",{class:"resultTitle px-[.2rem] py-[.4rem] mt-[1.6rem]"},"拉取结果：",-1)),V("div",D,[v(d,{class:"h-[45.6rem] !rounded-none",content:g(E)},null,8,["content"])])]),_:1,__:[7]},8,["model","rules","disabled"])]),_:1}),v(i,{name:"cmd",label:"命令拉取"},{default:b(()=>[v(c,{ref:"cmdRef",size:"large",model:g(M),rules:g(G),disabled:g(P),class:"relative w-full","label-position":"right",onSubmit:a[4]||(a[4]=y(()=>{},["prevent"]))},{default:b(()=>[v(s,{prop:"cmd"},{default:b(()=>[v(t,{autofocus:"",modelValue:g(M).cmd,"onUpdate:modelValue":a[3]||(a[3]=e=>g(M).cmd=e),onKeyup:h(n,["enter"]),placeholder:"请输入需要执行的命令,docker pull redis:latest，按回车执行"},{append:b(()=>[v(m,{type:"default",onClick:n},{default:b(()=>a[8]||(a[8]=[x("执行命令",-1)])),_:1,__:[8]})]),_:1},8,["modelValue"])]),_:1}),a[9]||(a[9]=V("div",{class:"resultTitle px-[.2rem] py-[.4rem] mt-[1.6rem]"},"拉取结果：",-1)),V("div",J,[v(d,{class:"h-[45.6rem] !rounded-none",content:g(E)},null,8,["content"])])]),_:1,__:[9]},8,["model","rules","disabled"])]),_:1})]),_:1},8,["modelValue","onChange"])])}}}),[["__scopeId","data-v-e3d09b27"]]);export{N as default};
