<template>
|
<div class="HashManage">
|
<div class="hashManage_top">
|
<div class="left">
|
<!-- 总算力 -->
|
<div class="card">
|
<div class="hashrate">
|
<img src="/images/hashrate/total.png" alt="" />
|
<div class="hashrateContent">
|
<div class="label">总算力</div>
|
<div class="data">
|
<span class="number">{{ total }}</span
|
>路
|
</div>
|
</div>
|
</div>
|
</div>
|
<!-- 实时算力 -->
|
<HashCard :type="0" :hashrate="polling"></HashCard>
|
</div>
|
|
<div class="medium">
|
<!-- 轮询算力 -->
|
<HashCard class="topCard" :type="1" :hashrate="realTime"></HashCard>
|
<!-- 数据栈算力 -->
|
<HashCard :type="2" :hashrate="stack"></HashCard>
|
</div>
|
|
<div class="right">
|
<div class="title">算力信息</div>
|
<div class="chart">
|
<!-- 内存进度条 -->
|
<div class="row">
|
<div class="label">内存</div>
|
<el-progress
|
:percentage="systemInfo.mem"
|
:stroke-width="24"
|
:show-text="false"
|
></el-progress>
|
<div class="number">{{ systemInfo.mem }}%</div>
|
</div>
|
<!-- 算力进度条 -->
|
<div class="row">
|
<div class="label">算力</div>
|
<el-progress
|
:percentage="systemInfo.gpu"
|
:stroke-width="24"
|
:show-text="false"
|
></el-progress>
|
<div class="number">{{ systemInfo.gpu }}%</div>
|
</div>
|
<!-- CPU进度条 -->
|
<div class="row">
|
<div class="label">CPU</div>
|
<el-progress
|
:percentage="systemInfo.cpu"
|
:stroke-width="24"
|
:show-text="false"
|
></el-progress>
|
<div class="number">{{ systemInfo.cpu }}%</div>
|
</div>
|
<!-- 硬盘进度条 -->
|
<div class="row">
|
<div class="label">硬盘</div>
|
<el-progress
|
:percentage="systemInfo.disk"
|
:stroke-width="24"
|
:show-text="false"
|
></el-progress>
|
<div class="number">{{ systemInfo.disk }}%</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
|
<ClusterList
|
:list="deviceList"
|
@chooseCluster="chooseCluster"
|
@chooseDevice="chooseDevice"
|
@refreshCluster="chooseCluster(ClusterId)"
|
@back="back"
|
:listType="listType"
|
></ClusterList>
|
</div>
|
</template>
|
|
<script>
|
import HashCard from "./components/HashCard";
|
import ClusterList from "./components/ClusterList";
|
import {
|
userStatisticRunInfo,
|
userStatisticRun,
|
clusterStatisticRunInfo,
|
clusterSysInfo,
|
clusterStatisticRun,
|
deviceStatisticRunInfo,
|
devicesSysInfo,
|
} from "@/api/clusterManage";
|
export default {
|
components: {
|
HashCard,
|
ClusterList,
|
},
|
created() {
|
sessionStorage.removeItem("devId");
|
sessionStorage.removeItem("clusterId");
|
this.getUserInfo();
|
this.getUserDevice();
|
},
|
|
data() {
|
return {
|
total: "",
|
realTime: {},
|
polling: {},
|
stack: {},
|
systemInfo: {
|
cpu: 0,
|
disk: 0,
|
gpu: 0,
|
mem: 0,
|
},
|
deviceList: [],
|
listType: "cluster",
|
ClusterId: "",
|
};
|
},
|
methods: {
|
//获取全部信息
|
async getUserInfo() {
|
const res1 = await userStatisticRunInfo();
|
if (res1 && res1.success) {
|
this.total = res1.data.channelTotal;
|
this.realTime = {
|
total: res1.data.realValidCount,
|
valid: res1.data.realTotal,
|
invalid: res1.data.realInvalidCount,
|
run: res1.data.realRunningCount,
|
noDeal:
|
res1.data.realTotal -
|
res1.data.realRunningCount -
|
res1.data.realInvalidCount,
|
};
|
if (res1.data.hasOwnProperty("duanliuID")) {
|
this.realTime["duanliu"] = [...new Set(res1.data.duanliuID)]
|
|
this.realTime.noDeal += this.realTime["duanliu"].length
|
}
|
|
this.polling = {
|
valid: res1.data.pollTotal,
|
total: res1.data.pollChannelCount,
|
invalid: res1.data.pollInvalidCount,
|
run: res1.data.pollRunningCount,
|
noDeal:
|
res1.data.pollTotal -
|
res1.data.pollRunningCount -
|
res1.data.pollInvalidCount,
|
};
|
|
this.stack = {
|
total: res1.data.stackChannelCount,
|
valid: res1.data.stackTotal,
|
invalid: res1.data.stackInvalidCount,
|
run: res1.data.stackRunningCount,
|
noDeal:
|
res1.data.stackTotal -
|
res1.data.stackInvalidCount -
|
res1.data.stackRunningCount,
|
};
|
}
|
const res2 = await clusterSysInfo({
|
clusterId: "",
|
});
|
if (res2 && res2.success) {
|
this.systemInfo = {
|
cpu: parseInt(res2.data.cpu.usedPercent),
|
disk: parseInt(res2.data.disk.usedPercent),
|
gpu: parseInt(res2.data.gpu.usedPercent),
|
mem: parseInt(res2.data.mem.usedPercent),
|
};
|
}
|
},
|
//获取全部设备
|
async getUserDevice() {
|
const res = await userStatisticRun();
|
if (res && res.success) {
|
this.deviceList = res.data.lists;
|
this.listType = "cluster";
|
}
|
},
|
//获取集群信息
|
async getClusterInfo(id) {
|
const res1 = await clusterStatisticRunInfo({ clusterId: id });
|
if (res1 && res1.success) {
|
this.total = res1.data.channelTotal;
|
this.realTime = {
|
total: res1.data.realValidCount,
|
valid: res1.data.realTotal,
|
invalid: res1.data.realInvalidCount,
|
run: res1.data.realRunningCount,
|
noDeal:
|
res1.data.realTotal -
|
res1.data.realRunningCount -
|
res1.data.realInvalidCount,
|
};
|
this.polling = {
|
valid: res1.data.pollTotal,
|
total: res1.data.pollChannelCount,
|
invalid: res1.data.pollInvalidCount,
|
run: res1.data.pollRunningCount,
|
noDeal:
|
res1.data.pollTotal -
|
res1.data.pollRunningCount -
|
res1.data.pollInvalidCount,
|
};
|
|
this.stack = {
|
total: res1.data.stackChannelCount,
|
valid: res1.data.stackTotal,
|
invalid: res1.data.stackInvalidCount,
|
run: res1.data.stackRunningCount,
|
noDeal:
|
res1.data.stackTotal -
|
res1.data.stackInvalidCount -
|
res1.data.stackRunningCount,
|
};
|
}
|
const res2 = await clusterSysInfo(
|
//id
|
{ clusterId: "" }
|
);
|
if (res2 && res2.success) {
|
this.systemInfo = {
|
cpu: parseInt(res2.data.cpu.usedPercent),
|
disk: parseInt(res2.data.disk.usedPercent),
|
gpu: parseInt(res2.data.gpu.usedPercent),
|
mem: parseInt(res2.data.mem.usedPercent),
|
};
|
}
|
},
|
//获取集群设备
|
async getClusterDevice(id) {
|
const res = await clusterStatisticRun({ clusterId: id });
|
if (res && res.success) {
|
this.deviceList = res.data.lists;
|
this.listType = "device";
|
}
|
},
|
//获取设备信息
|
async chooseDevice(id) {
|
const res1 = await deviceStatisticRunInfo({ deviceId: [id] });
|
if (res1 && res1.success) {
|
this.total = res1.data.channelTotal;
|
this.realTime = {
|
total: res1.data.realValidCount,
|
valid: res1.data.realTotal,
|
invalid: res1.data.realInvalidCount,
|
run: res1.data.realRunningCount,
|
noDeal:
|
res1.data.realTotal -
|
res1.data.realRunningCount -
|
res1.data.realInvalidCount,
|
};
|
this.polling = {
|
valid: res1.data.pollTotal,
|
total: res1.data.pollChannelCount,
|
invalid: res1.data.pollInvalidCount,
|
run: res1.data.pollRunningCount,
|
noDeal:
|
res1.data.pollTotal -
|
res1.data.pollRunningCount -
|
res1.data.pollInvalidCount,
|
};
|
|
this.stack = {
|
total: res1.data.stackChannelCount,
|
valid: res1.data.stackTotal,
|
invalid: res1.data.stackInvalidCount,
|
run: res1.data.stackRunningCount,
|
noDeal:
|
res1.data.stackTotal -
|
res1.data.stackInvalidCount -
|
res1.data.stackRunningCount,
|
};
|
}
|
const res2 = await devicesSysInfo({ deviceId: [id] });
|
if (res2 && res2.success) {
|
this.systemInfo = {
|
cpu: parseInt(res2.data.cpu.usedPercent),
|
disk: parseInt(res2.data.disk.usedPercent),
|
gpu: parseInt(res2.data.gpu.usedPercent),
|
mem: parseInt(res2.data.mem.usedPercent),
|
};
|
}
|
},
|
chooseCluster(id) {
|
this.getClusterInfo(id);
|
this.getClusterDevice(id);
|
this.ClusterId = id;
|
},
|
back() {
|
this.getUserInfo();
|
this.getUserDevice();
|
},
|
},
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
.HashManage {
|
.hashManage_top {
|
display: flex;
|
margin: 24px 0;
|
}
|
|
.left,
|
.medium {
|
margin-right: 24px;
|
flex: 1;
|
|
.card {
|
overflow: hidden;
|
margin-bottom: 24px;
|
height: 156px;
|
background-color: #fff;
|
|
.hashrate {
|
margin-top: 38px;
|
display: flex;
|
justify-content: center;
|
|
img {
|
margin-right: 20px;
|
width: 80px;
|
height: 80px;
|
}
|
|
.hashrateContent {
|
.label {
|
margin-bottom: 4px;
|
font-size: 14px;
|
}
|
|
.data {
|
font-size: 16px;
|
font-weight: 700;
|
.number {
|
font-size: 48px;
|
}
|
}
|
}
|
}
|
}
|
|
.topCard {
|
margin-bottom: 24px;
|
}
|
}
|
|
.right {
|
box-sizing: border-box;
|
padding: 20px;
|
flex: 1;
|
height: 336px;
|
background-color: #fff;
|
|
.title {
|
margin-bottom: 54px;
|
padding-left: 10px;
|
height: 20px;
|
line-height: 20px;
|
border-left: 4px solid #0065ff;
|
font-size: 16px;
|
font-weight: 700;
|
}
|
|
.row {
|
margin-bottom: 30px;
|
display: flex;
|
height: 24px;
|
.label {
|
width: 48px;
|
}
|
|
.el-progress ::v-deep {
|
flex: 1;
|
border-radius: 15px;
|
.el-progress-bar__inner {
|
background: linear-gradient(
|
270deg,
|
#0065ff 0%,
|
rgba(0, 101, 255, 0.25) 100%
|
);
|
}
|
|
.el-progress-bar__outer {
|
background-color: #d4e3fa;
|
}
|
}
|
|
.number {
|
margin-left: 20px;
|
font-size: 14px;
|
color: #0065ff;
|
}
|
}
|
}
|
}
|
</style>
|