From 7eab75b9e971524990228d1910e97d9f0bb0f6d3 Mon Sep 17 00:00:00 2001 From: hanbaoshan <hanbaoshan@aiotlink.com> Date: 星期一, 19 十月 2020 15:29:28 +0800 Subject: [PATCH] 集群云大小在一定范围内跟随节点数量变化 --- src/pages/settings/components/ClusterManagement.vue | 93 ++++++++++++++++++++++++++++++++-------------- 1 files changed, 65 insertions(+), 28 deletions(-) diff --git a/src/pages/settings/components/ClusterManagement.vue b/src/pages/settings/components/ClusterManagement.vue index 9a04946..51173b1 100644 --- a/src/pages/settings/components/ClusterManagement.vue +++ b/src/pages/settings/components/ClusterManagement.vue @@ -94,13 +94,18 @@ style="margin-right:10px;" type="primary" size="small" - @click="submitForm('manageForm')" + @click="updateCluster('manageForm')" >淇濆瓨</el-button> </el-form-item> </el-form> </div> </el-col> - <el-col :span="12" style="height: 100%;" v-if="members.length !== 0"> + <el-col + :span="12" + style="height: 100%;" + v-if="members.length !== 0 && isSearch" + class="node-container" + > <serfDiagram ref="diagram" :members="members" @@ -109,6 +114,14 @@ @selected-node="joinNode" class="nodes-svg" ></serfDiagram> + </el-col> + <el-col + :span="12" + style="height: 100%;" + v-if="innerNodes.length !== 0 && !isSearch" + class="node-container" + > + <cloud-node :nodes="innerNodes"></cloud-node> </el-col> </el-row> @@ -163,7 +176,6 @@ </el-tabs> </el-col> </el-row> - </div> </template> @@ -188,14 +200,15 @@ import { getDevInfo } from "@/api/system"; - +import cloudNode from "./CloudNode"; import serfDiagram from "@/components/serfDiagram"; import ipInput from "@/components/subComponents/IPInput"; -import {isIPv4} from "@/scripts/validate"; +import { isIPv4 } from "@/scripts/validate"; export default { components: { serfDiagram, - ipInput + ipInput, + cloudNode }, data() { const checkPwd = (rule, value, callback) => { @@ -215,7 +228,7 @@ } }, 1000); }; - + return { activeName: "1", sActiveName: "s-first", @@ -267,18 +280,27 @@ esNodes: [], scheduleId: "", isHasColony: false, + isSearch: false, currentCluster: {}, searchNum: "", loading: false, searchDis: false, agentName: "", - members: [] + members: [], + innerNodes: [], + intervalTimer: null, }; }, mounted() { this.findCluster(); - this.getVrrpInfo(); + let _this = this; + this.intervalTimer = setInterval(()=>{ + _this.findCluster(); + },30000); this.getEsClusterNodes(); + }, + beforeDestroy(){ + clearInterval(this.intervalTimer); }, methods: { cleanValue() { @@ -290,7 +312,6 @@ submitForm(formName) { this.$refs[formName].validate(valid => { if (valid) { - debugger //alert("submit!"); let json = { clusterId: this.clusterid, @@ -327,8 +348,8 @@ } }); }, - - join (formName) { + + join(formName) { this.$refs[formName].validate(valid => { if (valid) { if (Object.keys(this.currentCluster).length === 0) { @@ -372,6 +393,7 @@ } }, async searchColony() { + this.isSearch = true; this.$refs["joinForm"].validate(valid => { if (valid) { this.members = []; @@ -389,10 +411,12 @@ .catch(() => { this.searchDis = false; this.loading = false; + this.isSearch = false; }); } else { this.searchDis = false; this.loading = false; + this.isSearch = false; return false; } }); @@ -409,6 +433,7 @@ this.stopSearch(); }, 10 * 1000); }, + //鎼滅储闆嗙兢 async getSearchNodes() { let res = await getSearchNodes(); if (res && res.success) { @@ -473,10 +498,13 @@ this.ruleForm.clustername = res.data.clusterName; this.ruleForm.clusterpwd = res.data.clusterpwd this.ruleForm.virtualIp = res.data.virtualIp - let list = res.data.nodes.map(i => { - debugger + //let list = res.data.nodes.map(i => { + this.isSearch = false; + this.innerNodes = res.data.nodes.map(i => { let obj = {}; obj.device_type = i.device_type; + obj.workType = i.device_type.substr(2, 2); + obj.hardwareType = i.device_type.substr(4, 2); obj.cluster_id = i.cluster_id; obj.clusterName = res.data.clusterName; obj.create_time = i.create_time; @@ -485,10 +513,12 @@ obj.node_ip = i.node_ip; obj.nodeName = i.node_name; obj.Address = i.node_ip; - obj.role = i.role ? i.role : "pc"; + obj.role = i.drift_state ? i.drift_state : "pc"; return obj; }); - this.members = this.members.concat(list); + + //this.members = this.members.concat(list); + console.log(this.members) } else { this.isHasColony = false; // this.activeName = '1' @@ -505,9 +535,19 @@ console.log(e) }) }, - async updateClusterName() { + async updateCluster() { + if (this.ruleForm.clustername === "") { + this.$message({ + type: "error", + message: "闆嗙兢鍚嶇О涓嶈兘涓虹┖" + }) + + return + } + let res = await updateClusterName({ - clusterName: this.mangeForm.colonyName + clusterName: this.ruleForm.clustername, + virtualIp: this.ruleForm.virtualIp }); this.$notify({ title: res.success ? "鎴愬姛" : "澶辫触", @@ -545,11 +585,13 @@ this.isHasColony = false; this.activeName = "1"; this.members = []; + this.innerNodes = []; } }).catch(() => { }); }, joinNode(event, node) { + debugger this.currentCluster.cluster_id = node.cluster_id; if (this.activeName === "3") { this.manageForm.clustername = node.clusterName; @@ -690,20 +732,15 @@ }); }) }, - onIpBlur (ip) { + onIpBlur(ip) { //this.vrIpForm.virtual_ip = ip; this.ruleForm.virtualIp = ip; console.log(this.ruleForm.virtualIp) } - - }, - mounted () { - this.findCluster(); - - }, - created () { } + + created() { } }; </script> @@ -776,7 +813,7 @@ height: 30px; line-height: 30px; } -.nodes-svg{ - background-color: aquamarine; +.nodes-svg { + background-color: rgba(127, 172, 255, 0.459); } </style> -- Gitblit v1.8.0