iceshrimp-legacy/packages/client/src/widgets/server-metric/cpu.vue

66 lines
967 B
Vue
Raw Normal View History

2021-01-03 14:38:32 +01:00
<template>
2023-04-08 02:01:42 +02:00
<div class="vrvdvrys">
<XPie class="pie" :value="usage" />
<div>
2023-05-30 00:10:14 +02:00
<p><i class="ph-cpu ph-bold ph-lg"></i>CPU</p>
2023-04-08 02:01:42 +02:00
<p>{{ meta.cpu.cores }} Logical cores</p>
<p>{{ meta.cpu.model }}</p>
</div>
2021-01-03 14:38:32 +01:00
</div>
</template>
<script lang="ts" setup>
2023-07-17 00:32:32 +02:00
import { onBeforeUnmount, onMounted } from "vue";
2023-04-08 02:01:42 +02:00
import XPie from "./pie.vue";
2021-01-03 14:38:32 +01:00
const props = defineProps<{
2023-04-08 02:01:42 +02:00
connection: any;
meta: any;
}>();
let usage: number = $ref(0);
function onStats(stats) {
usage = stats.cpu;
}
onMounted(() => {
2023-04-08 02:01:42 +02:00
props.connection.on("stats", onStats);
});
onBeforeUnmount(() => {
2023-04-08 02:01:42 +02:00
props.connection.off("stats", onStats);
2021-01-03 14:38:32 +01:00
});
</script>
<style lang="scss" scoped>
.vrvdvrys {
display: flex;
padding: 16px;
> .pie {
height: 82px;
flex-shrink: 0;
margin-right: 16px;
}
> div {
flex: 1;
> p {
margin: 0;
font-size: 0.8em;
&:first-child {
font-weight: bold;
margin-bottom: 4px;
> i {
2021-01-03 14:38:32 +01:00
margin-right: 4px;
}
}
}
}
}
</style>