File: /www/server/panel/BTPanel/static/js/add-slave-node.js
import{X as D,M as l,ea as w,eb as B}from"./utils-lib.js?v=1777008528";import{c as F,aL as h,r as E,g as R,e as o,an as b,am as x,x as p,j as y,k as C,p as k}from"./base-lib.js?v=1777008528";import{g as G,d as M}from"./form-item.js?v=1777008528";import{u as S}from"./index75.js?v=1777008528";import"./__commonjsHelpers__.js?v=1777008528";import"./index119.js?v=1777008528";import"./index118.js?v=1777008528";import"./index3.js?v=1777008528";import"./index116.js?v=1777008528";import"./useController13.js?v=1777008528";import"./site.js?v=1777008528";import"./useStore2.js?v=1777008528";const V={class:"p-[2rem]"},J=F({__name:"add-slave-node",props:{compData:{default:()=>({group_id:"",nodes:[]})}},setup(d,{expose:i}){const{redisGroupDetail:c,isRedisRefreshList:m}=S(),r=h(),u=d,_=E(u.compData.nodes.map(e=>({label:"".concat(e.server_ip," - Redis ").concat(e.redis_version),value:e.id}))),{BtForm:v,submit:f}=D({data:{new_slave_node_id:[]},options:e=>R(()=>[G("选择节点",()=>o("div",{class:"w-full"},[o(b,{modelValue:e.value.new_slave_node_id,"onUpdate:modelValue":a=>e.value.new_slave_node_id=a,"popper-class":"slave-select-popper",placeholder:"请选择要添加的从节点"},{default:()=>o("div",null,[_.value.map(a=>o(x,{label:a.label,value:a.value},null))]),empty:()=>o("div",{style:"text-align: center;"},[p("暂无可用的Redis节点,"),o("span",{class:"bt-link",onClick:()=>{r&&typeof r.push=="function"?r.push({name:"node-mgt"}):window.location.href="/node/node-mgt"}},[p("去添加")])])})]),"new_slave_node_id",{rules:[{required:!0,message:"请选择要添加的从节点"}]}),M(" ",[{content:"只显示可用的Redis节点,已在复制组中的节点不会显示"}])]),submit:async(e,a,A)=>{let s=null;try{await a(),s=l.load("正在配置从节点信息,请稍后...");const{new_slave_node_id:n}=e.value,t=await w({group_id:u.compData.group_id,new_slave_node_id:n});if(t.status){const{data:g}=await B({group_id:u.compData.group_id});c.value.slave_details=g.data.slave_details,m.value=!0,l.success(t.msg||"添加从节点成功")}else l.error(t.msg||"添加从节点失败");return t.status}catch(n){return!1}finally{s==null||s.close()}}});return i({onConfirm:f}),(e,a)=>(y(),C("div",V,[o(k(v))]))}});export{J as default};