Fixes build warning and errors

This commit is contained in:
Rune Harlyk
2025-07-10 21:32:28 +02:00
committed by Rune Harlyk
parent c8ee64d7f4
commit d529eaa201
22 changed files with 2053 additions and 2116 deletions
+352 -356
View File
@@ -1,373 +1,369 @@
<script lang="ts">
import { onMount } from 'svelte';
import { page } from '$app/stores';
import SettingsCard from '$lib/components/SettingsCard.svelte';
import { slide } from 'svelte/transition';
import { cubicOut } from 'svelte/easing';
import { Chart, registerables } from 'chart.js';
import { daisyColor } from '$lib/utilities';
import { analytics } from '$lib/stores/analytics';
import { Metrics } from '$lib/components/icons';
import { onMount } from 'svelte';
import { page } from '$app/stores';
import SettingsCard from '$lib/components/SettingsCard.svelte';
import { slide } from 'svelte/transition';
import { cubicOut } from 'svelte/easing';
import { Chart, registerables } from 'chart.js';
Chart.register(...registerables);
import { daisyColor } from '$lib/utilities';
import { analytics } from '$lib/stores/analytics';
import { Metrics } from '$lib/components/icons';
let cpuChartElement: HTMLCanvasElement = $state();
let cpuChart: Chart;
Chart.register(...registerables);
let heapChartElement: HTMLCanvasElement = $state();
let heapChart: Chart;
let cpuChartElement: HTMLCanvasElement;
let cpuChart: Chart;
let filesystemChartElement: HTMLCanvasElement = $state();
let filesystemChart: Chart;
let heapChartElement: HTMLCanvasElement;
let heapChart: Chart;
let temperatureChartElement: HTMLCanvasElement = $state();
let temperatureChart: Chart;
let filesystemChartElement: HTMLCanvasElement;
let filesystemChart: Chart;
onMount(() => {
cpuChart = new Chart(cpuChartElement, {
type: 'line',
data: {
labels: $analytics.cpu_usage,
datasets: [
{
label: 'Cpu usage core 0',
borderColor: daisyColor('--p'),
backgroundColor: daisyColor('--p', 50),
borderWidth: 2,
data: $analytics.cpu0_usage,
yAxisID: 'y'
},
{
label: 'Cpu usage core 1',
borderColor: daisyColor('--p'),
backgroundColor: daisyColor('--p', 50),
borderWidth: 2,
data: $analytics.cpu1_usage,
yAxisID: 'y'
},
{
label: 'Cpu usage total',
borderColor: daisyColor('--s'),
backgroundColor: daisyColor('--s', 50),
borderWidth: 2,
data: $analytics.cpu_usage,
yAxisID: 'y'
},
]
},
options: {
maintainAspectRatio: false,
responsive: true,
plugins: {
legend: {
display: true
},
tooltip: {
mode: 'index',
intersect: false
}
},
elements: {
point: {
radius: 0
}
},
scales: {
x: {
grid: {
color: daisyColor('--bc', 10)
},
ticks: {
color: daisyColor('--bc')
},
display: false
},
y: {
type: 'linear',
title: {
display: true,
text: 'Cpu usage [%]',
color: daisyColor('--bc'),
font: {
size: 16,
weight: 'bold'
}
},
position: 'left',
min: 0,
max: 100,
grid: { color: daisyColor('--bc', 10) },
ticks: {
color: daisyColor('--bc')
},
border: { color: daisyColor('--bc', 10) }
}
}
}
});
heapChart = new Chart(heapChartElement, {
type: 'line',
data: {
labels: $analytics.uptime,
datasets: [
{
label: 'Used Heap',
borderColor: daisyColor('--p'),
backgroundColor: daisyColor('--p', 50),
borderWidth: 2,
data: $analytics.used_heap,
fill:true,
yAxisID: 'y'
}
]
},
options: {
maintainAspectRatio: false,
responsive: true,
plugins: {
legend: {
display: true
},
tooltip: {
mode: 'index',
intersect: false
}
},
elements: {
point: {
radius: 0
}
},
scales: {
x: {
grid: {
color: daisyColor('--bc', 10)
},
ticks: {
color: daisyColor('--bc')
},
display: false
},
y: {
type: 'linear',
title: {
display: true,
text: 'Heap [kb]',
color: daisyColor('--bc'),
font: {
size: 16,
weight: 'bold'
}
},
position: 'left',
min: 0,
max: Math.round($analytics.total_heap[0]),
grid: { color: daisyColor('--bc', 10) },
ticks: {
color: daisyColor('--bc')
},
border: { color: daisyColor('--bc', 10) }
}
}
}
});
filesystemChart = new Chart(filesystemChartElement, {
type: 'line',
data: {
labels: $analytics.uptime,
datasets: [
{
label: 'File System Used',
borderColor: daisyColor('--p'),
backgroundColor: daisyColor('--p', 50),
borderWidth: 2,
data: $analytics.fs_used,
fill:true,
yAxisID: 'y'
}
]
},
options: {
maintainAspectRatio: false,
responsive: true,
plugins: {
legend: {
display: true
},
tooltip: {
mode: 'index',
intersect: false
}
},
elements: {
point: {
radius: 0
}
},
scales: {
x: {
grid: {
color: daisyColor('--bc', 10)
},
ticks: {
color: daisyColor('--bc')
},
display: false
},
y: {
type: 'linear',
title: {
display: true,
text: 'File System [kb]',
color: daisyColor('--bc'),
font: {
size: 16,
weight: 'bold'
}
},
position: 'left',
min: 0,
max: Math.round($analytics.fs_total[0]),
grid: { color: daisyColor('--bc', 10) },
ticks: {
color: daisyColor('--bc')
},
border: { color: daisyColor('--bc', 10) }
}
}
}
});
temperatureChart = new Chart(temperatureChartElement, {
type: 'line',
data: {
labels: $analytics.uptime,
datasets: [
{
label: 'Core Temperature',
borderColor: daisyColor('--p'),
backgroundColor: daisyColor('--p', 50),
borderWidth: 2,
data: $analytics.core_temp,
yAxisID: 'y'
}
]
},
options: {
maintainAspectRatio: false,
responsive: true,
plugins: {
legend: {
display: true
},
tooltip: {
mode: 'index',
intersect: false
}
},
elements: {
point: {
radius: 0
}
},
scales: {
x: {
grid: {
color: daisyColor('--bc', 10)
},
ticks: {
color: daisyColor('--bc')
},
display: false
},
y: {
type: 'linear',
title: {
display: true,
text: 'Core Temperature [°C]',
color: daisyColor('--bc'),
font: {
size: 16,
weight: 'bold'
}
},
position: 'left',
suggestedMin: 20,
suggestedMax: 100,
grid: { color: daisyColor('--bc', 10) },
ticks: {
color: daisyColor('--bc')
},
border: { color: daisyColor('--bc', 10) }
}
}
}
});
setInterval(updateData, 500);
});
let temperatureChartElement: HTMLCanvasElement;
let temperatureChart: Chart;
function updateData() {
cpuChart.data.labels = $analytics.cpu_usage;
cpuChart.data.datasets[0].data = $analytics.cpu0_usage;
cpuChart.data.datasets[1].data = $analytics.cpu1_usage;
cpuChart.data.datasets[2].data = $analytics.cpu_usage;
cpuChart.update('none');
onMount(() => {
cpuChart = new Chart(cpuChartElement, {
type: 'line',
data: {
labels: $analytics.cpu_usage,
datasets: [
{
label: 'Cpu usage core 0',
borderColor: daisyColor('--p'),
backgroundColor: daisyColor('--p', 50),
borderWidth: 2,
data: $analytics.cpu0_usage,
yAxisID: 'y',
},
{
label: 'Cpu usage core 1',
borderColor: daisyColor('--p'),
backgroundColor: daisyColor('--p', 50),
borderWidth: 2,
data: $analytics.cpu1_usage,
yAxisID: 'y',
},
{
label: 'Cpu usage total',
borderColor: daisyColor('--s'),
backgroundColor: daisyColor('--s', 50),
borderWidth: 2,
data: $analytics.cpu_usage,
yAxisID: 'y',
},
],
},
options: {
maintainAspectRatio: false,
responsive: true,
plugins: {
legend: {
display: true,
},
tooltip: {
mode: 'index',
intersect: false,
},
},
elements: {
point: {
radius: 0,
},
},
scales: {
x: {
grid: {
color: daisyColor('--bc', 10),
},
ticks: {
color: daisyColor('--bc'),
},
display: false,
},
y: {
type: 'linear',
title: {
display: true,
text: 'Cpu usage [%]',
color: daisyColor('--bc'),
font: {
size: 16,
weight: 'bold',
},
},
position: 'left',
min: 0,
max: 100,
grid: { color: daisyColor('--bc', 10) },
ticks: {
color: daisyColor('--bc'),
},
border: { color: daisyColor('--bc', 10) },
},
},
},
});
heapChart = new Chart(heapChartElement, {
type: 'line',
data: {
labels: $analytics.uptime,
datasets: [
{
label: 'Used Heap',
borderColor: daisyColor('--p'),
backgroundColor: daisyColor('--p', 50),
borderWidth: 2,
data: $analytics.used_heap,
fill: true,
yAxisID: 'y',
},
],
},
options: {
maintainAspectRatio: false,
responsive: true,
plugins: {
legend: {
display: true,
},
tooltip: {
mode: 'index',
intersect: false,
},
},
elements: {
point: {
radius: 0,
},
},
scales: {
x: {
grid: {
color: daisyColor('--bc', 10),
},
ticks: {
color: daisyColor('--bc'),
},
display: false,
},
y: {
type: 'linear',
title: {
display: true,
text: 'Heap [kb]',
color: daisyColor('--bc'),
font: {
size: 16,
weight: 'bold',
},
},
position: 'left',
min: 0,
max: Math.round($analytics.total_heap[0]),
grid: { color: daisyColor('--bc', 10) },
ticks: {
color: daisyColor('--bc'),
},
border: { color: daisyColor('--bc', 10) },
},
},
},
});
filesystemChart = new Chart(filesystemChartElement, {
type: 'line',
data: {
labels: $analytics.uptime,
datasets: [
{
label: 'File System Used',
borderColor: daisyColor('--p'),
backgroundColor: daisyColor('--p', 50),
borderWidth: 2,
data: $analytics.fs_used,
fill: true,
yAxisID: 'y',
},
],
},
options: {
maintainAspectRatio: false,
responsive: true,
plugins: {
legend: {
display: true,
},
tooltip: {
mode: 'index',
intersect: false,
},
},
elements: {
point: {
radius: 0,
},
},
scales: {
x: {
grid: {
color: daisyColor('--bc', 10),
},
ticks: {
color: daisyColor('--bc'),
},
display: false,
},
y: {
type: 'linear',
title: {
display: true,
text: 'File System [kb]',
color: daisyColor('--bc'),
font: {
size: 16,
weight: 'bold',
},
},
position: 'left',
min: 0,
max: Math.round($analytics.fs_total[0]),
grid: { color: daisyColor('--bc', 10) },
ticks: {
color: daisyColor('--bc'),
},
border: { color: daisyColor('--bc', 10) },
},
},
},
});
temperatureChart = new Chart(temperatureChartElement, {
type: 'line',
data: {
labels: $analytics.uptime,
datasets: [
{
label: 'Core Temperature',
borderColor: daisyColor('--p'),
backgroundColor: daisyColor('--p', 50),
borderWidth: 2,
data: $analytics.core_temp,
yAxisID: 'y',
},
],
},
options: {
maintainAspectRatio: false,
responsive: true,
plugins: {
legend: {
display: true,
},
tooltip: {
mode: 'index',
intersect: false,
},
},
elements: {
point: {
radius: 0,
},
},
scales: {
x: {
grid: {
color: daisyColor('--bc', 10),
},
ticks: {
color: daisyColor('--bc'),
},
display: false,
},
y: {
type: 'linear',
title: {
display: true,
text: 'Core Temperature [°C]',
color: daisyColor('--bc'),
font: {
size: 16,
weight: 'bold',
},
},
position: 'left',
suggestedMin: 20,
suggestedMax: 100,
grid: { color: daisyColor('--bc', 10) },
ticks: {
color: daisyColor('--bc'),
},
border: { color: daisyColor('--bc', 10) },
},
},
},
});
setInterval(updateData, 500);
});
heapChart.data.labels = $analytics.uptime;
heapChart.data.datasets[0].data = $analytics.used_heap;
heapChart.options.scales!.y!.max = Math.ceil($analytics.total_heap[0]);
heapChart.update('none');
function updateData() {
cpuChart.data.labels = $analytics.cpu_usage;
cpuChart.data.datasets[0].data = $analytics.cpu0_usage;
cpuChart.data.datasets[1].data = $analytics.cpu1_usage;
cpuChart.data.datasets[2].data = $analytics.cpu_usage;
cpuChart.update('none');
filesystemChart.data.labels = $analytics.uptime;
filesystemChart.data.datasets[0].data = $analytics.fs_used;
heapChart.options.scales!.y!.max = Math.ceil($analytics.fs_total[0]);
filesystemChart.update('none');
heapChart.data.labels = $analytics.uptime;
heapChart.data.datasets[0].data = $analytics.used_heap;
heapChart.options.scales!.y!.max = Math.ceil($analytics.total_heap[0]);
heapChart.update('none');
temperatureChart.data.labels = $analytics.uptime;
temperatureChart.data.datasets[0].data = $analytics.core_temp;
temperatureChart.update('none');
}
filesystemChart.data.labels = $analytics.uptime;
filesystemChart.data.datasets[0].data = $analytics.fs_used;
heapChart.options.scales!.y!.max = Math.ceil($analytics.fs_total[0]);
filesystemChart.update('none');
temperatureChart.data.labels = $analytics.uptime;
temperatureChart.data.datasets[0].data = $analytics.core_temp;
temperatureChart.update('none');
}
</script>
<SettingsCard collapsible={false}>
{#snippet icon()}
<Metrics class="lex-shrink-0 mr-2 h-6 w-6 self-end" />
{/snippet}
{#snippet title()}
<span >System Metrics</span>
{/snippet}
{#snippet icon()}
<Metrics class="lex-shrink-0 mr-2 h-6 w-6 self-end" />
{/snippet}
{#snippet title()}
<span>System Metrics</span>
{/snippet}
<div class="w-full overflow-x-auto">
<div
class="flex w-full flex-col space-y-1 h-60"
transition:slide|local={{ duration: 300, easing: cubicOut }}
>
<canvas bind:this={cpuChartElement}></canvas>
</div>
</div>
<div class="w-full overflow-x-auto">
<div
class="flex w-full flex-col space-y-1 h-60"
transition:slide|local={{ duration: 300, easing: cubicOut }}>
<canvas bind:this={cpuChartElement}></canvas>
</div>
</div>
<div class="w-full overflow-x-auto">
<div
class="flex w-full flex-col space-y-1 h-60"
transition:slide|local={{ duration: 300, easing: cubicOut }}
>
<canvas bind:this={heapChartElement}></canvas>
</div>
</div>
<div class="w-full overflow-x-auto">
<div
class="flex w-full flex-col space-y-1 h-52"
transition:slide|local={{ duration: 300, easing: cubicOut }}
>
<canvas bind:this={filesystemChartElement}></canvas>
</div>
</div>
<div class="w-full overflow-x-auto">
<div
class="flex w-full flex-col space-y-1 h-52"
transition:slide|local={{ duration: 300, easing: cubicOut }}
>
<canvas bind:this={temperatureChartElement}></canvas>
</div>
</div>
<div class="w-full overflow-x-auto">
<div
class="flex w-full flex-col space-y-1 h-60"
transition:slide|local={{ duration: 300, easing: cubicOut }}>
<canvas bind:this={heapChartElement}></canvas>
</div>
</div>
<div class="w-full overflow-x-auto">
<div
class="flex w-full flex-col space-y-1 h-52"
transition:slide|local={{ duration: 300, easing: cubicOut }}>
<canvas bind:this={filesystemChartElement}></canvas>
</div>
</div>
<div class="w-full overflow-x-auto">
<div
class="flex w-full flex-col space-y-1 h-52"
transition:slide|local={{ duration: 300, easing: cubicOut }}>
<canvas bind:this={temperatureChartElement}></canvas>
</div>
</div>
</SettingsCard>