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

Add trending CPU and Memory usage (#1896)

* Refactors to stat history

* Uses markRaw

* Cleans up proxies

* Removes id from snapshots

* Adds d3

* Adds more d3 modules

* Fixes package

* Cleans up packages

* Updates modules

* Adds initital d3 chart

* Cleans up svg

* Fixes @types/d3-array

* Adds memory

* Moves charts around
This commit is contained in:
Amir Raminfar
2022-10-12 14:21:41 -07:00
committed by GitHub
parent 4f84beb835
commit afd37d3455
17 changed files with 550 additions and 145 deletions

View File

@@ -1,16 +1,23 @@
<template>
<div class="is-size-7 is-uppercase columns is-marginless is-mobile" v-if="container.stat">
<div class="is-size-7 is-uppercase columns is-marginless is-mobile is-vcentered" v-if="container.stat">
<div class="column is-narrow has-text-weight-bold">
{{ container.state }}
</div>
<div class="column is-narrow" v-if="container.stat.memoryUsage !== null">
<div class="column is-narrow has-text-centered">
<div>
<stat-sparkline :data="memoryData"></stat-sparkline>
</div>
<span class="has-text-weight-light has-spacer">mem</span>
<span class="has-text-weight-bold">
{{ formatBytes(container.stat.memoryUsage) }}
</span>
</div>
<div class="column is-narrow"></div>
<div class="column is-narrow" v-if="container.stat.cpu !== null">
<div class="column is-narrow has-text-centered">
<div>
<stat-sparkline :data="cpuData"></stat-sparkline>
</div>
<span class="has-text-weight-light has-spacer">load</span>
<span class="has-text-weight-bold"> {{ container.stat.cpu }}% </span>
</div>
@@ -18,10 +25,26 @@
</template>
<script lang="ts" setup>
import { type Container } from "@/types/Container";
import { Container } from "@/models/Container";
import { type ComputedRef } from "vue";
const container = inject("container") as ComputedRef<Container>;
const cpuData = computedWithControl(
() => container.value.getLastStat(),
() => {
const history = container.value.getStatHistory();
return history.map((stat, i) => ({ x: history.length - i, y: stat.snapshot.cpu }));
}
);
const memoryData = computedWithControl(
() => container.value.getLastStat(),
() => {
const history = container.value.getStatHistory();
return history.map((stat, i) => ({ x: history.length - i, y: stat.snapshot.memory }));
}
);
</script>
<style lang="scss" scoped>