import{_ as F}from"./index-BRQskX9P.js?v=1773287522785";import{_ as U}from"./index-lEMZglLp.js?v=1773287522785";import{_ as G}from"./index.vue_vue_type_script_setup_true_lang-D8O2mMsP.js?v=1773287522785";import{k as C,R as S,e as W,r as u,c as N,$ as R,Z as B,a0 as s,a9 as f,_ as k,S as a,ai as H,j as V,aa as L,X as J}from"./vue-core-DJjvd5ZC.js?v=1773287522785";import{bm as K,ao as M,m as h,bz as Q,n as Y,h0 as ee}from"./index-BTglIPU2.js?v=1773287522785";import{u as O}from"./useSocket-DTHwGZgK.js?v=1773287522785";import{a1 as ae,a6 as oe,au as j,b as z,B as A}from"./naive-ui--dJnpVcV.js?v=1773287522785";import"./prismjs-BZPoR7_J.js?v=1773287522785";import"./data-BVsViUMm.js?v=1773287522785";const ne={class:"pt-4px"},se={class:"w-440px"},te={class:"w-440px"},le={class:"px-2px py-4px"},ce={class:"h-420px"},re=C({__name:"index",setup(E){const{t:n}=S(),m=K(),e=W({name:null,image:""}),b={name:{trigger:"change",validator:()=>e.name===null?new Error(n("Docker.LocalImage.pull.index_8")):!0},image:{trigger:["input","blur"],validator:()=>e.image===""?new Error(n("Docker.LocalImage.pull.index_9")):!0}},l=u(null),i=u(n("Docker.LocalImage.pull.index_10")),_=u(!1),D=u([]),$=async()=>{try{_.value=!0;const{message:o}=await Q();Y(o)&&o.length>0&&(D.value=o.map(t=>({label:t.name,value:t.name})),e.name=o[0].name)}finally{_.value=!1}},y=async()=>{var o;await((o=l.value)==null?void 0:o.validate()),i.value="",x.value=!0,d(),w()},x=u(!1),c=N(()=>x.value),{open:d,send:r,close:p}=O("/ws_model",{immediate:!1,onMessage:(o,t)=>{const{data:g}=t;if(M(g)&&(i.value+=t.data,g.includes("successful")||g.includes("failed"))){x.value=!1;const v={status:g.includes("successful"),msg:g.includes("successful")?n("Docker.Container.create.command_7"):n("Docker.Container.create.command_6")};v.status?(h.success(v.msg),m.setRefresh(!0)):h.error(v.msg),p()}}}),w=()=>{r({model_index:"btdocker",mod_name:"image",def_name:"pull_from_some_registry",ws_callback:111,name:e.name,image:e.image})};return $(),(o,t)=>{const g=oe,v=ae,P=z,T=A,X=j,Z=G,q=U;return R(),B("div",ne,[s(Z,{ref_key:"formRef",ref:l,model:a(e),rules:b},{default:f(()=>[s(v,{label:o.$t("Docker.LocalImage.pull.index_3"),path:"name"},{default:f(()=>[k("div",se,[s(g,{value:a(e).name,"onUpdate:value":t[0]||(t[0]=I=>a(e).name=I),loading:a(_),disabled:a(c),options:a(D)},null,8,["value","loading","disabled","options"])])]),_:1},8,["label"]),s(v,{label:o.$t("Docker.LocalImage.pull.index_4"),path:"image"},{default:f(()=>[k("div",te,[s(X,null,{default:f(()=>[s(P,{value:a(e).image,"onUpdate:value":t[1]||(t[1]=I=>a(e).image=I),disabled:a(c),placeholder:o.$t("Docker.LocalImage.pull.index_5"),onKeyup:H(y,["enter"])},null,8,["value","disabled","placeholder"]),s(T,{type:"primary",disabled:a(c),onClick:y},{default:f(()=>[V(L(o.$t("Docker.LocalImage.pull.index_6")),1)]),_:1},8,["disabled"])]),_:1})])]),_:1},8,["label"])]),_:1},8,["model"]),k("div",le,L(o.$t("Docker.LocalImage.pull.index_7")),1),k("div",ce,[s(q,{log:a(i)},null,8,["log"])])])}}}),ie={class:"pt-4px"},ue={class:"px-2px py-4px"},me={class:"h-456px"},_e=C({__name:"index",setup(E){const{t:n}=S(),m=K(),e=W({cmd:""}),b=u(n("Docker.LocalImage.pull.index_10")),l=u(!1),i=N(()=>l.value),_=async()=>{if(e.cmd.trim()===""){h.error(n("Docker.LocalImage.pull.index_13"));return}try{l.value=!0,b.value=n("Docker.Container.create.command_8"),await ee({cmd:e.cmd}),D(),x()}catch(c){l.value=!1,console.error(c)}},{open:D,send:$,close:y}=O("/ws_model",{immediate:!1,onMessage:(c,d)=>{const{data:r}=d;if(M(r)&&(b.value+=d.data,r.includes("bt_successful")||r.includes("bt_failed"))){l.value=!1;const p={status:r.includes("bt_successful"),msg:r.includes("bt_successful")?n("Docker.Container.create.command_7"):n("Docker.Container.create.command_6")};p.status?(h.success(p.msg),m.setRefresh(!0)):h.error(p.msg),y()}}}),x=()=>{$({model_index:"btdocker",mod_name:"image",def_name:"get_cmd_log",ws_callback:111,name:"",image:""})};return(c,d)=>{const r=z,p=A,w=j,o=U;return R(),B("div",ie,[s(w,{class:"mb-16px"},{default:f(()=>[s(r,{value:a(e).cmd,"onUpdate:value":d[0]||(d[0]=t=>a(e).cmd=t),disabled:a(i),placeholder:c.$t("Docker.LocalImage.pull.index_11")},null,8,["value","disabled","placeholder"]),s(p,{type:"primary",disabled:a(i),onClick:_},{default:f(()=>[V(L(c.$t("Docker.LocalImage.pull.index_12")),1)]),_:1},8,["disabled"])]),_:1}),k("div",ue,L(c.$t("Docker.LocalImage.pull.index_7")),1),k("div",me,[s(o,{log:a(b)},null,8,["log"])])])}}}),de={class:"p-16px"},ye=C({__name:"index",setup(E){const{t:n}=S(),m=u("normal"),e=[{key:"normal",label:n("Docker.LocalImage.pull.index_1"),component:re},{key:"command",label:n("Docker.LocalImage.pull.index_2"),component:_e}];return(b,l)=>{const i=F;return R(),B("div",de,[s(i,{value:a(m),"onUpdate:value":l[0]||(l[0]=_=>J(m)?m.value=_:null),options:e},null,8,["value"])])}}});export{ye as default};
