| | |
| | | ipInput, |
| | | cloudNode |
| | | }, |
| | | data () { |
| | | data() { |
| | | const checkPwd = (rule, value, callback) => { |
| | | if (!value) { |
| | | return callback(new Error("密码不能为空")); |
| | |
| | | showJoinConfirm: false |
| | | }; |
| | | }, |
| | | mounted () { |
| | | mounted() { |
| | | this.findCluster(); |
| | | let _this = this; |
| | | this.intervalTimer = setInterval(() => { |
| | |
| | | }, 30000); |
| | | //this.getEsClusterNodes(); |
| | | }, |
| | | beforeDestroy () { |
| | | beforeDestroy() { |
| | | clearInterval(this.intervalTimer); |
| | | }, |
| | | methods: { |
| | | checkPsd (psd) { |
| | | checkPsd(psd) { |
| | | return psd.trim().length === 6 |
| | | }, |
| | | cleanValue () { |
| | | this.members = []; |
| | | }, |
| | | sHandleClick (tab, event) { |
| | | console.log(tab, event); |
| | | }, |
| | | submitForm (formName) { |
| | | // cleanValue() { |
| | | // this.members = []; |
| | | // }, |
| | | // sHandleClick(tab, event) { |
| | | // console.log(tab, event); |
| | | // }, |
| | | submitForm(formName) { |
| | | this.$refs[formName].validate(valid => { |
| | | if (valid) { |
| | | //alert("submit!"); |
| | |
| | | }); |
| | | }, |
| | | |
| | | saveForm (formName) { |
| | | this.$refs[formName].validate(valid => { |
| | | if (valid) { |
| | | alert("submit!"); |
| | | let json = { |
| | | enable: this.vrIpForm.enable, |
| | | serve_port: this.vrIpForm.serve_port, |
| | | virtual_ip: this.vrIpForm.virtual_ip, |
| | | // saveForm(formName) { |
| | | // this.$refs[formName].validate(valid => { |
| | | // if (valid) { |
| | | // alert("submit!"); |
| | | // let json = { |
| | | // enable: this.vrIpForm.enable, |
| | | // serve_port: this.vrIpForm.serve_port, |
| | | // virtual_ip: this.vrIpForm.virtual_ip, |
| | | |
| | | }; |
| | | setVrrp(json).then(() => { |
| | | this.getVrrpInfo(); |
| | | }); |
| | | } else { |
| | | console.log("error submit!!"); |
| | | return false; |
| | | } |
| | | }); |
| | | }, |
| | | // }; |
| | | // setVrrp(json).then(() => { |
| | | // this.getVrrpInfo(); |
| | | // }); |
| | | // } else { |
| | | // console.log("error submit!!"); |
| | | // return false; |
| | | // } |
| | | // }); |
| | | // }, |
| | | |
| | | join (formName) { |
| | | join(formName) { |
| | | let _this = this; |
| | | this.$refs[formName].validate(valid => { |
| | | if (valid) { |
| | |
| | | } |
| | | }); |
| | | }, |
| | | async createCluster (json) { |
| | | async createCluster(json) { |
| | | let res = await createSerfCluster(json); |
| | | console.log(res, "创建集群"); |
| | | this.$notify({ |
| | |
| | | type: res.success ? "success" : "error" |
| | | }); |
| | | }, |
| | | async randomPwd () { |
| | | async randomPwd() { |
| | | let res = await randomPwd(); |
| | | if (res && res.success) { |
| | | this.ruleForm.clusterpwd = res.data; |
| | | } |
| | | }, |
| | | async searchColony () { |
| | | async searchColony() { |
| | | this.isSearch = true; |
| | | this.$refs["joinForm"].clearValidate(); |
| | | this.$refs["joinForm"].validateField('clusterpwd'); |
| | |
| | | } |
| | | //}); |
| | | }, |
| | | async search (json) { |
| | | async search(json) { |
| | | let res = await search(json); |
| | | if (res && res.success) { |
| | | console.log(res, "搜索集群"); |
| | |
| | | }, 10 * 1000); |
| | | }, |
| | | //搜索集群 |
| | | async getSearchNodes () { |
| | | async getSearchNodes() { |
| | | let res = await getSearchNodes(); |
| | | if (res && res.success) { |
| | | let list = res.data.map(i => { |
| | |
| | | }); |
| | | } |
| | | }, |
| | | setSchedule () { |
| | | setSchedule() { |
| | | this.scheduleId = window.setInterval(() => { |
| | | this.getSearchNodes(); |
| | | }, 1000); |
| | | }, |
| | | async stopSearch () { |
| | | async stopSearch() { |
| | | if (!this.loading) { |
| | | return true; |
| | | } |
| | |
| | | // },2000) |
| | | }) |
| | | }, |
| | | async findCluster () { |
| | | async findCluster() { |
| | | let res = await findCluster(); |
| | | if (res && res.success) { |
| | | if (res.data && res.data.clusterId) { |
| | |
| | | } |
| | | } |
| | | }, |
| | | getVrrpInfo () { |
| | | getVrrp().then(res => { |
| | | if (res.success) { |
| | | this.vrIpForm.virtual_ip = res.data.virtual_ip; |
| | | this.vrIpForm.enable = res.data.enable; |
| | | } |
| | | }).catch(e => { |
| | | console.log(e) |
| | | }) |
| | | }, |
| | | async updateCluster () { |
| | | // getVrrpInfo() { |
| | | // getVrrp().then(res => { |
| | | // if (res.success) { |
| | | // this.vrIpForm.virtual_ip = res.data.virtual_ip; |
| | | // this.vrIpForm.enable = res.data.enable; |
| | | // } |
| | | // }).catch(e => { |
| | | // console.log(e) |
| | | // }) |
| | | // }, |
| | | async updateCluster() { |
| | | if (this.ruleForm.clustername === "") { |
| | | this.$message({ |
| | | type: "error", |
| | |
| | | type: res.success ? "success" : "error" |
| | | }); |
| | | }, |
| | | async joinCluster (json) { |
| | | async joinCluster(json) { |
| | | let res = await joinCluster(json); |
| | | if (res.success) { |
| | | this.members = [] |
| | |
| | | type: res.success ? "success" : "error" |
| | | }); |
| | | }, |
| | | leave () { |
| | | leave() { |
| | | this.$confirm(`确定退出集群吗?`, { |
| | | center: true, |
| | | cancelButtonClass: "comfirm-class-cancle", |
| | |
| | | this.members = []; |
| | | this.innerNodes = []; |
| | | } |
| | | }).catch(() => { }); |
| | | }).catch(() => { |
| | | this.ruleForm.clustername = ""; |
| | | this.ruleForm.clusterpwd = "" |
| | | this.clusterid = ""; |
| | | this.isHasColony = false; |
| | | this.activeName = "1"; |
| | | this.members = []; |
| | | this.innerNodes = []; |
| | | }); |
| | | |
| | | }, |
| | | joinNode (event, node) { |
| | | console.log('join',node) |
| | | joinNode(event, node) { |
| | | console.log('join', node) |
| | | let _this = this; |
| | | this.currentCluster.cluster_id = node.cluster_id; |
| | | if (this.activeName === "3") { |
| | |
| | | return; |
| | | } |
| | | if (this.activeName === "2") { |
| | | debugger |
| | | if (_this.showJoinConfirm) return; |
| | | |
| | | this.$confirm("是否要加入节点 " + node.nodeName + "?", "加入集群", { |
| | |
| | | // }); |
| | | } |
| | | }, |
| | | generatePassword () { |
| | | generatePassword() { |
| | | var chars = |
| | | "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; |
| | | var uuid = []; |
| | |
| | | this.ruleForm.clusterpwd = uuid.join(""); |
| | | }, |
| | | |
| | | async getEsClusterNodes () { |
| | | async getEsClusterNodes() { |
| | | let rsp = await getDevInfo(); |
| | | let hostIpAddr = ""; |
| | | if (rsp && rsp.success) { |
| | |
| | | } |
| | | } |
| | | }, |
| | | createEsCluster () { |
| | | createEsCluster() { |
| | | createESNode().then(rsp => { |
| | | if (rsp && rsp.success) { |
| | | this.$message({ |
| | |
| | | }); |
| | | }) |
| | | }, |
| | | joinESCluster () { |
| | | joinESCluster() { |
| | | if (!this.esNodeIp.length) { |
| | | this.$message({ |
| | | type: "error", |
| | |
| | | }); |
| | | }) |
| | | }, |
| | | onIpBlur (ip) { |
| | | onIpBlur(ip) { |
| | | //this.vrIpForm.virtual_ip = ip; |
| | | this.ruleForm.virtualIp = ip; |
| | | console.log(this.ruleForm.virtualIp) |
| | |
| | | |
| | | }, |
| | | |
| | | created () { } |
| | | created() { } |
| | | |
| | | }; |
| | | </script> |