LoongPanel-Asp/web/pages/host/disk/[[id]].vue

232 lines
5.0 KiB
Vue
Raw Normal View History

2024-06-22 10:54:02 +08:00
<script lang="ts" setup>
import {useMainLayoutStore} from "~/strores/UseMainLayoutStore";
import {useDataStore} from "~/strores/DataStore";
2024-06-29 18:16:29 +08:00
import AreaChart2 from "~/components/Charts/AreaChart2.vue";
2024-06-22 10:54:02 +08:00
type diskInfo = {
name: string,
2024-06-29 18:16:29 +08:00
value: string
2024-06-22 10:54:02 +08:00
}
const id = toRef(useRoute().params.id);
const lsDisk = ref<diskInfo[]>([])
const mainLayoutStore = useMainLayoutStore()
const dataStore = useDataStore()
onMounted(() => {
$fetch('/Api/Server/GetServerDiskInfo', {
method: 'GET',
params: {
2024-07-22 21:05:18 +08:00
ServerId: mainLayoutStore.SelectServer.value,
2024-06-22 10:54:02 +08:00
DiskId: id.value
},
headers: {
'Content-Type': 'application/json',
'Authorization': "Bearer " + useCookie('token').value
},
baseURL: useRuntimeConfig().public.baseUrl
}).then(res => {
lsDisk.value = res as diskInfo[]
})
})
</script>
<template>
<div class="disk-layout">
<div class="left-chart">
<div class="disk-title">
<h1>驱动器 {{ $route.params.id }}</h1>
<h2>{{ lsDisk.find(x => x.name === 'Device_Model' || x.name === 'Model_Number')?.value }}</h2>
</div>
<div class="disk-chart-top">
<p>活动时间</p>
<p>100%</p>
</div>
<div class="disk-chart">
2024-06-29 18:16:29 +08:00
<AreaChart2 :bg-color="'rgba(38,153,100,0.3)'" :colors="['#269964']" :value-ids="[`DiskUtil-${$route.params.id}`]"
:configs="[
{
areaStyle: {}
}
]"
:value-names="['磁盘使用率']"/>
2024-06-22 10:54:02 +08:00
</div>
<div class="disk-chat-bottom">
2024-06-29 18:16:29 +08:00
<p>更早</p>
2024-06-22 10:54:02 +08:00
<p>0</p>
</div>
<div class="disk-chart-top">
<p>吞吐量</p>
<p></p>
</div>
<div class="disk-chart">
2024-06-29 18:16:29 +08:00
<AreaChart2 :bg-color="'rgba(38,153,100,0.3)'" :colors="['#269964']" :min="null" :max="null" :configs="[{},{lineStyle: {type: 'dashed'},type: 'line'}]"
:value-ids="[`DiskReadKB-${$route.params.id}`,`DiskWriteKB-${$route.params.id}`]" :value-names="['磁盘读取KB','磁盘写入KB']"/>
2024-06-22 10:54:02 +08:00
</div>
<div class="disk-chat-bottom">
2024-06-29 18:16:29 +08:00
<p>更早</p>
2024-06-22 10:54:02 +08:00
<p>0</p>
</div>
</div>
<div class="right-info">
<div class="info-title-box">
<div class="info-title">
<p>使用率</p>
2024-07-11 18:23:35 +08:00
<h2>{{ dataStore.data[`DiskUtil-${id}`] }}%</h2>
2024-06-22 10:54:02 +08:00
</div>
<div class="info-title">
<p>平均响应时间</p>
2024-07-11 18:23:35 +08:00
<h2>{{ dataStore.data[`DiskAwait-${id}`] }} ms</h2>
2024-06-22 10:54:02 +08:00
</div>
<div class="infos">
<div class="info2">
<div></div>
<p>读取速度</p>
2024-07-11 18:23:35 +08:00
<h2>{{ dataStore.data[`DiskReadKB-${id}`] }} KiB/s</h2>
2024-06-22 10:54:02 +08:00
</div>
<div class="info2">
<div></div>
<p>写入速度</p>
2024-07-11 18:23:35 +08:00
<h2>{{ dataStore.data[`DiskWriteKB-${id}`] }} KiB/s</h2>
2024-06-22 10:54:02 +08:00
</div>
</div>
</div>
<div class="other-info-box">
<div v-for="value in lsDisk" class="other-info">
<p>{{ value.name }}</p>
<p>{{ value.value }}</p>
</div>
</div>
</div>
</div>
</template>
<style lang="scss" scoped>
@import "base";
.disk-layout {
padding: $padding*1.5;
display: grid;
grid-template-columns: 1fr 300px;
grid-template-rows: 1fr;
2024-06-29 18:16:29 +08:00
gap: $gap*4;
2024-06-22 10:54:02 +08:00
}
.left-chart {
display: flex;
flex-direction: column;
gap: $gap;
.disk-title {
display: flex;
justify-content: space-between;
align-items: center;
.dark-mode & {
h1, h2 {
color: $dark-text-color;
}
}
h1, h2 {
color: $light-text-color;
}
h1 {
font-size: 32px;
}
}
}
.disk-chart-top {
display: flex;
justify-content: space-between;
align-items: center;
}
.disk-chart {
flex: 1;
border: 4px solid #269964;
border-radius: $radius*2;
height: min-content;
max-height: 32rem;
2024-06-29 18:16:29 +08:00
min-height: 32rem;
2024-06-22 10:54:02 +08:00
overflow: hidden;
}
.disk-chat-bottom {
display: flex;
justify-content: space-between;
align-items: center;
}
.info-title-box {
display: flex;
flex-wrap: wrap;
gap: $gap*2;
.info-title {
display: flex;
flex-direction: column;
gap: $gap*.5;
}
.info-title:nth-of-type(2) {
width: 60%;
}
}
.other-info-box {
display: flex;
flex-direction: column;
gap: $gap*.5;
.other-info {
display: flex;
gap: $gap;
2024-06-29 18:16:29 +08:00
overflow: hidden;
2024-06-22 10:54:02 +08:00
p:first-of-type {
font-weight: 500;
}
p {
flex: 1;
//文本换行
word-wrap: break-word;
2024-06-29 18:16:29 +08:00
max-width: 50%;
2024-06-22 10:54:02 +08:00
}
}
}
.right-info {
display: flex;
flex-direction: column;
gap: $gap*2;
}
.infos {
display: flex;
flex-direction: column;
gap: $gap*2;
.info2 {
display: grid;
grid-template-columns: 4px 1fr;
grid-template-rows: 1fr 1fr;
2024-07-22 21:05:18 +08:00
grid-column-gap: $gap*2;
2024-06-22 10:54:02 +08:00
& > div {
height: 100%;
border: 3px solid #269964;
grid-row: 1/3;
}
}
.info2:last-of-type {
& > div {
height: 100%;
border: 3px dashed #269964;
grid-row: 1/3;
}
}
}
</style>