From 1db7db4bf02259e47d5d906d6b21ecc6451b0a09 Mon Sep 17 00:00:00 2001 From: zhangzengfei <zhangzengfei@smartai.com> Date: 星期一, 23 十月 2023 15:26:46 +0800 Subject: [PATCH] 添加集群手动选主节点, 无线网络显示ip --- src/pages/settings/views/clusterManagement.vue | 41 ++++++++++++++++++++++++++++++++++------- 1 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/pages/settings/views/clusterManagement.vue b/src/pages/settings/views/clusterManagement.vue index bec9238..ec80f34 100644 --- a/src/pages/settings/views/clusterManagement.vue +++ b/src/pages/settings/views/clusterManagement.vue @@ -5,8 +5,16 @@ <!-- <cloud-node :nodes="innerNodes"></cloud-node> --> <net-node :innerNodes="innerNodes"></net-node> - <div class="cls-bar">瑙嗛鍒嗘瀽闆嗙兢绠$悊</div> - + <div class="cls-bar"> + <div class="title">鑺傜偣鐘舵��</div> + <div class="input-area"> + <div class="text" v-show="!isFillingName"> + {{ ruleForm.state }} + </div> + <el-switch v-model="masterNode" :disabled="masterNode" style="margin-top:5px" @change="change2Master"> + </el-switch> + </div> + </div> <div class="cls-bar"> <div class="title">闆嗙兢鍚嶇О</div> <div class="input-area"> @@ -168,7 +176,8 @@ stopSearching, findCluster, updateClusterName, - joinCluster + joinCluster, + update2Master } from "@/api/clusterManage" // import cloudNode from "../components/CloudNode"; import NetNode from "../components/NetNode" @@ -195,6 +204,7 @@ } } return { + masterNode: false, innerNodes: [], intervalTimer: null, isFillingName: false, @@ -210,7 +220,9 @@ ruleForm: { clustername: "", clusterpwd: "", - virtualIp: "" + virtualIp: "", + state: "", + localId: "" }, selfForm: { virtualIp: "", @@ -222,7 +234,7 @@ clusterpwd: "" }, isSearch: false, - showCurCluster: true, + showCurCluster: false, loading: false, joinLoading: false, isHasColony: false, @@ -349,7 +361,6 @@ }) }, join(formName) { - console.log("join", formName) let _this = this _this.joinLoading = true let data = { @@ -357,7 +368,6 @@ password: _this.joinForm.clusterpwd, nodeIps: [_this.joinForm.clusterip] } - console.log("body:", data) _this .joinCluster(data) .then(() => { @@ -590,6 +600,7 @@ if (res && res.success) { if (res.data && res.data.clusterId) { this.isHasColony = true + this.showCurCluster = true this.clusterid = res.data.clusterId this.ruleForm.clustername = res.data.clusterName this.ruleForm.clusterpwd = "******" @@ -609,6 +620,13 @@ obj.nodeName = i.node_name obj.Address = i.node_ip obj.role = i.drift_state ? i.drift_state : "pc" + obj.online = i.online + + if (obj.id == res.data.localId) { + this.ruleForm.state = i.drift_state + this.ruleForm.localId = res.data.localId + this.masterNode = i.drift_state === "master" + } return obj }) } else { @@ -618,6 +636,15 @@ }, clearInnerNodes() { this.innerNodes = [] + }, + async change2Master() { + let res = await update2Master({ clusterId: this.clusterid, nodeId: this.ruleForm.localId }) + if (res && res.success) { + this.$message.success("鍒囨崲鎴愬姛") + this.findCluster() + } else { + this.$message.warning("鍒囨崲澶辫触") + } } } } -- Gitblit v1.8.0