1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-24 06:28:42 +01:00

Adds total CPU and Mem usage. See #1715

This commit is contained in:
Amir Raminfar
2022-04-20 12:46:21 -07:00
parent 038e2dee88
commit 5d9db17b9c
3 changed files with 25 additions and 9 deletions

View File

@@ -20,6 +20,7 @@
<script lang="ts" setup>
import { ContainerStat } from "@/types/Container";
import { PropType } from "vue";
import { formatBytes } from "@/utils";
defineProps({
stat: {
@@ -28,14 +29,6 @@ defineProps({
},
state: String,
});
function formatBytes(bytes: number, decimals = 2) {
if (bytes === 0) return "0 Bytes";
const k = 1024;
const dm = decimals < 0 ? 0 : decimals;
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
}
</script>
<style lang="scss" scoped>