Skip to content

Commit a437bba

Browse files
committed
Post merge: PSRAM in metrics + metrics max dynamic + WiFi improvement
1 parent bfb8fd3 commit a437bba

File tree

2 files changed

+114
-26
lines changed

2 files changed

+114
-26
lines changed

interface/src/routes/system/metrics/SystemMetrics.svelte

Lines changed: 97 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
let heapChartElement: HTMLCanvasElement = $state();
1919
let heapChart: Chart;
2020
21-
let psramChartElement: HTMLCanvasElement = $state();
21+
let psramChartElement: HTMLCanvasElement = $state(); // 🌙
2222
let psramChart: Chart;
2323
2424
let filesystemChartElement: HTMLCanvasElement = $state();
@@ -99,15 +99,15 @@
9999
labels: $analytics.uptime,
100100
datasets: [
101101
{
102-
label: 'Free Heap',
102+
label: 'Used', // 🌙
103103
borderColor: daisyColor('--color-primary'),
104104
backgroundColor: daisyColor('--color-primary', 50),
105105
borderWidth: 2,
106-
data: $analytics.free_heap,
106+
data: $analytics.used_heap, // 🌙
107107
yAxisID: 'y'
108108
},
109109
{
110-
label: 'Max Alloc Heap',
110+
label: 'Max Alloc',
111111
borderColor: daisyColor('--color-secondary'),
112112
backgroundColor: daisyColor('--color-secondary', 50),
113113
borderWidth: 2,
@@ -147,7 +147,7 @@
147147
type: 'linear',
148148
title: {
149149
display: true,
150-
text: 'Heap [kb]',
150+
text: 'Memory [KB]', // 🌙
151151
color: daisyColor('--color-base-content'),
152152
font: {
153153
size: 16,
@@ -156,7 +156,73 @@
156156
},
157157
position: 'left',
158158
min: 0,
159-
max: Math.round($analytics.total_heap[0]),
159+
max: Math.round(Math.max(...$analytics.total_heap)), // 🌙
160+
grid: { color: daisyColor('--color-base-content', 10) },
161+
ticks: {
162+
color: daisyColor('--color-base-content')
163+
},
164+
border: { color: daisyColor('--color-base-content', 10) }
165+
}
166+
}
167+
}
168+
});
169+
// 🌙
170+
psramChart = new Chart(psramChartElement, {
171+
type: 'line',
172+
data: {
173+
labels: $analytics.uptime,
174+
datasets: [
175+
{
176+
label: 'Used',
177+
borderColor: daisyColor('--color-primary'),
178+
backgroundColor: daisyColor('--color-primary', 50),
179+
borderWidth: 2,
180+
data: $analytics.used_psram,
181+
yAxisID: 'y'
182+
}
183+
]
184+
},
185+
options: {
186+
maintainAspectRatio: false,
187+
responsive: true,
188+
plugins: {
189+
legend: {
190+
display: true
191+
},
192+
tooltip: {
193+
mode: 'index',
194+
intersect: false
195+
}
196+
},
197+
elements: {
198+
point: {
199+
radius: 1
200+
}
201+
},
202+
scales: {
203+
x: {
204+
grid: {
205+
color: daisyColor('--color-base-content', 10)
206+
},
207+
ticks: {
208+
color: daisyColor('--color-base-content')
209+
},
210+
display: false
211+
},
212+
y: {
213+
type: 'linear',
214+
title: {
215+
display: true,
216+
text: 'PSRAM [KB]',
217+
color: daisyColor('--color-base-content'),
218+
font: {
219+
size: 16,
220+
weight: 'bold'
221+
}
222+
},
223+
position: 'left',
224+
min: 0,
225+
max: Math.round(Math.max(...$analytics.psram_size)),
160226
grid: { color: daisyColor('--color-base-content', 10) },
161227
ticks: {
162228
color: daisyColor('--color-base-content')
@@ -172,7 +238,7 @@
172238
labels: $analytics.uptime,
173239
datasets: [
174240
{
175-
label: 'File System Used',
241+
label: 'Used', // 🌙
176242
borderColor: daisyColor('--color-primary'),
177243
backgroundColor: daisyColor('--color-primary', 50),
178244
borderWidth: 2,
@@ -212,7 +278,7 @@
212278
type: 'linear',
213279
title: {
214280
display: true,
215-
text: 'File System [kb]',
281+
text: 'File System [KB]', // 🌙
216282
color: daisyColor('--color-base-content'),
217283
font: {
218284
size: 16,
@@ -221,7 +287,7 @@
221287
},
222288
position: 'left',
223289
min: 0,
224-
max: Math.round($analytics.fs_total[0]),
290+
max: Math.round(Math.max(...$analytics.fs_total)), // 🌙
225291
grid: { color: daisyColor('--color-base-content', 10) },
226292
ticks: {
227293
color: daisyColor('--color-base-content')
@@ -308,13 +374,23 @@
308374
lpsChart.options.scales.y.max = Math.round(Math.max(...$analytics.lps));
309375
310376
heapChart.data.labels = $analytics.uptime;
311-
heapChart.data.datasets[0].data = $analytics.free_heap;
377+
heapChart.data.datasets[0].data = $analytics.used_heap; // 🌙
312378
heapChart.data.datasets[1].data = $analytics.max_alloc_heap;
313379
heapChart.update('none');
380+
heapChart.options.scales.y.max = Math.round(Math.max(...$analytics.total_heap)); // 🌙
381+
382+
// 🌙
383+
if (Math.max(...$analytics.psram_size)) {
384+
psramChart.data.labels = $analytics.uptime;
385+
psramChart.data.datasets[0].data = $analytics.used_psram;
386+
psramChart.update('none');
387+
psramChart.options.scales.y.max = Math.round(Math.max(...$analytics.psram_size));
388+
}
314389
315390
filesystemChart.data.labels = $analytics.uptime;
316391
filesystemChart.data.datasets[0].data = $analytics.fs_used;
317392
filesystemChart.update('none');
393+
filesystemChart.options.scales.y.max = Math.round(Math.max(...$analytics.fs_total)); // 🌙
318394
319395
temperatureChart.data.labels = $analytics.uptime;
320396
temperatureChart.data.datasets[0].data = $analytics.core_temp;
@@ -374,6 +450,17 @@
374450
<canvas bind:this={heapChartElement}></canvas>
375451
</div>
376452
</div>
453+
<!-- 🌙 PSRAM -->
454+
{#if (Math.max(...$analytics.psram_size))}
455+
<div class="w-full overflow-x-auto">
456+
<div
457+
class="flex w-full flex-col space-y-1 h-60"
458+
transition:slide|local={{ duration: 300, easing: cubicOut }}
459+
>
460+
<canvas bind:this={psramChartElement}></canvas>
461+
</div>
462+
</div>
463+
{/if}
377464
<div class="w-full overflow-x-auto">
378465
<div
379466
class="flex w-full flex-col space-y-1 h-52"

interface/src/routes/wifi/sta/Wifi.svelte

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
let wifiStatus: WifiStatus = $state();
5353
let wifiSettings: WifiSettings = $state();
5454
55-
let dndNetworkList: KnownNetworkItem[] = $state([]);
55+
// 🌙 remove dndNetworkList, use wifiSettings.wifi_networks
5656
5757
let showWifiDetails = $state(false);
5858
@@ -113,7 +113,7 @@
113113
} catch (error) {
114114
console.error('Error:', error);
115115
}
116-
dndNetworkList = wifiSettings.wifi_networks;
116+
// 🌙 remove dndNetworkList, use wifiSettings.wifi_networks
117117
return wifiSettings;
118118
}
119119
@@ -149,8 +149,7 @@
149149
formErrorhostname = true;
150150
} else {
151151
formErrorhostname = false;
152-
// Update global wifiSettings object
153-
wifiSettings.wifi_networks = dndNetworkList;
152+
// 🌙 remove dndNetworkList, use wifiSettings.wifi_networks
154153
// Post to REST API
155154
postWiFiSettings(wifiSettings);
156155
}
@@ -222,13 +221,14 @@
222221
}
223222
// Submit JSON to REST API
224223
if (valid) {
224+
// 🌙 remove dndNetworkList, use wifiSettings.wifi_networks
225225
if (newNetwork) {
226-
dndNetworkList.push(networkEditable);
226+
wifiSettings.wifi_networks.push(networkEditable);
227227
} else {
228-
dndNetworkList.splice(dndNetworkList.indexOf(networkEditable), 1, networkEditable);
228+
wifiSettings.wifi_networks.splice(wifiSettings.wifi_networks.indexOf(networkEditable), 1, networkEditable);
229229
}
230230
addNetwork();
231-
dndNetworkList = [...dndNetworkList]; //Trigger reactivity
231+
wifiSettings.wifi_networks = [...wifiSettings.wifi_networks]; //Trigger reactivity
232232
showNetworkEditor = false;
233233
}
234234
}
@@ -261,7 +261,7 @@
261261
function handleEdit(index: number) {
262262
newNetwork = false;
263263
showNetworkEditor = true;
264-
networkEditable = dndNetworkList[index];
264+
networkEditable = wifiSettings.wifi_networks[index]; // 🌙 remove dndNetworkList, use wifiSettings.wifi_networks
265265
}
266266
267267
function confirmDelete(index: number) {
@@ -274,20 +274,20 @@
274274
},
275275
onConfirm: () => {
276276
// Check if network is currently been edited and delete as well
277-
if (dndNetworkList[index].ssid === networkEditable.ssid) {
277+
if (wifiSettings.wifi_networks[index].ssid === networkEditable.ssid) { // 🌙 remove dndNetworkList, use wifiSettings.wifi_networks
278278
addNetwork();
279279
}
280280
// Remove network from array
281-
dndNetworkList.splice(index, 1);
282-
dndNetworkList = [...dndNetworkList]; //Trigger reactivity
281+
wifiSettings.wifi_networks.splice(index, 1);
282+
wifiSettings.wifi_networks = [...wifiSettings.wifi_networks]; //Trigger reactivity
283283
showNetworkEditor = false;
284284
modals.close();
285285
}
286286
});
287287
}
288288
289289
function checkNetworkList() {
290-
if (dndNetworkList.length >= 5) {
290+
if (wifiSettings.wifi_networks.length >= 5) { // 🌙 remove dndNetworkList, use wifiSettings.wifi_networks
291291
modals.open(InfoDialog, {
292292
title: 'Reached Maximum Networks',
293293
message:
@@ -308,8 +308,9 @@
308308
return;
309309
}
310310
311-
dndNetworkList = reorder(dndNetworkList, from.index, to.index);
312-
console.log(dndNetworkList);
311+
// 🌙 remove dndNetworkList, use wifiSettings.wifi_networks
312+
wifiSettings.wifi_networks = reorder(wifiSettings.wifi_networks, from.index, to.index);
313+
console.log(wifiSettings.wifi_networks);
313314
}
314315
315316
function preventDefault(fn) {
@@ -517,7 +518,7 @@
517518
id="networks"
518519
type={VerticalDropZone}
519520
itemSize={60}
520-
itemCount={dndNetworkList.length}
521+
itemCount={wifiSettings.wifi_networks.length}
521522
on:drop={onDrop}
522523
>
523524
{#snippet children({ index })}
@@ -527,7 +528,7 @@
527528
<Router class="text-primary-content h-auto w-full scale-75" />
528529
</div>
529530
<div>
530-
<div class="font-bold">{dndNetworkList[index].ssid}</div>
531+
<div class="font-bold">{wifiSettings.wifi_networks[index].ssid}</div>
531532
</div>
532533
{#if !page.data.features.security || $user.admin}
533534
<div class="grow"></div>

0 commit comments

Comments
 (0)