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