From f48e1270192735d260e0362da1c2f9dace6b2411 Mon Sep 17 00:00:00 2001 From: James Rich <2199651+jamesarich@users.noreply.github.com> Date: Wed, 28 May 2025 16:10:35 -0500 Subject: [PATCH] feat: host metrics part 2 (#1972) --- .../mesh/ui/components/HostMetricsLog.kt | 34 +++++++++++++------ app/src/main/res/values/strings.xml | 1 + 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/ui/components/HostMetricsLog.kt b/app/src/main/java/com/geeksville/mesh/ui/components/HostMetricsLog.kt index d744f9cf4..c5fb25aea 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/components/HostMetricsLog.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/components/HostMetricsLog.kt @@ -134,16 +134,20 @@ fun HostMetricsItem( value = formatBytes(hostMetrics.diskfree1Bytes), modifier = Modifier.fillMaxWidth(), ) - LogLine( - label = stringResource(R.string.disk_free) + " 2", - value = formatBytes(hostMetrics.diskfree2Bytes), - modifier = Modifier.fillMaxWidth(), - ) - LogLine( - label = stringResource(R.string.disk_free) + " 3", - value = formatBytes(hostMetrics.diskfree3Bytes), - modifier = Modifier.fillMaxWidth(), - ) + if (hostMetrics.hasDiskfree2Bytes()) { + LogLine( + label = stringResource(R.string.disk_free) + " 2", + value = formatBytes(hostMetrics.diskfree2Bytes), + modifier = Modifier.fillMaxWidth(), + ) + } + if (hostMetrics.hasDiskfree3Bytes()) { + LogLine( + label = stringResource(R.string.disk_free) + " 3", + value = formatBytes(hostMetrics.diskfree3Bytes), + modifier = Modifier.fillMaxWidth(), + ) + } LogLine( label = stringResource(R.string.load) + " 1", value = (hostMetrics.load1 / 100.0).toString(), @@ -186,6 +190,13 @@ fun HostMetricsItem( trackColor = ProgressIndicatorDefaults.linearTrackColor, strokeCap = ProgressIndicatorDefaults.LinearStrokeCap, ) + if (hostMetrics.hasUserString()) { + LogLine( + label = stringResource(R.string.user_string), + value = hostMetrics.userString, + modifier = Modifier.fillMaxWidth(), + ) + } } } } @@ -241,11 +252,12 @@ private fun HostMetricsItemPreview() { .setUptimeSeconds(3600) .setFreememBytes(2048000) .setDiskfree1Bytes(104857600) - .setDiskfree2Bytes(209715200) + .setDiskfree2Bytes(2097915200) .setDiskfree3Bytes(44444) .setLoad1(30) .setLoad5(75) .setLoad15(19) + .setUserString("test") .build() val logs = TelemetryProtos.Telemetry.newBuilder() .setTime((System.currentTimeMillis() / 1000L).toInt()) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6aa8b0c7f..76ab7f60d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -637,4 +637,5 @@ Free Memory Disk Free Load + User String