diff --git a/apps/web/app.vue b/apps/web/app.vue index 76577a7..d9673c2 100644 --- a/apps/web/app.vue +++ b/apps/web/app.vue @@ -3,9 +3,17 @@ import { useTelemetryStore } from "~/stores/telemetry"; const telemetry = useTelemetryStore(); const user = useSupabaseUser(); +const session = useSupabaseSession(); +// Driven by the session rather than a one-shot onMounted: the session can +// arrive after mount, and sign-out should drop the socket instead of leaving +// it running on a token that is about to stop being valid. onMounted(() => { - telemetry.connect(); + watch( + () => session.value?.access_token, + (token) => (token ? telemetry.connect() : telemetry.disconnect()), + { immediate: true }, + ); }); onBeforeUnmount(() => { @@ -18,7 +26,13 @@ onBeforeUnmount(() => {
Continuum - {{ telemetry.connected ? "Live" : "Reconnecting…" }} + {{ + telemetry.link === "connected" + ? "Live" + : telemetry.link === "connecting" + ? "Connecting…" + : "Offline" + }} {{ user.email }}
diff --git a/apps/web/pages/index.vue b/apps/web/pages/index.vue index 4e0a54e..71e3565 100644 --- a/apps/web/pages/index.vue +++ b/apps/web/pages/index.vue @@ -1,28 +1,31 @@ @@ -81,6 +102,14 @@ const state = computed(() => props.live?.state ?? "offline"); font-size: 0.8rem; } +/* + * One rule per value of the backend's `printer_status` enum - offline, idle, + * printing, paused, error, maintenance - plus the "unknown" this card + * substitutes for a null status. The enum was only two thirds covered, so a + * paused printer and one in maintenance drew in the default colour and read + * as ordinary. `status` is not a closed enum on the wire, so anything new + * still falls back to that default rather than breaking. + */ .printer-card.is-printing .printer-card__state { color: #35d07f; } @@ -89,7 +118,16 @@ const state = computed(() => props.live?.state ?? "offline"); color: #f2604c; } -.printer-card.is-offline .printer-card__state { +.printer-card.is-paused .printer-card__state { + color: #f0b429; +} + +.printer-card.is-maintenance .printer-card__state { + color: #9f7aea; +} + +.printer-card.is-offline .printer-card__state, +.printer-card.is-unknown .printer-card__state { color: #6b7280; } diff --git a/packages/ui/src/components/TemperatureGraph.vue b/packages/ui/src/components/TemperatureGraph.vue index d5f5cee..9aab525 100644 --- a/packages/ui/src/components/TemperatureGraph.vue +++ b/packages/ui/src/components/TemperatureGraph.vue @@ -1,9 +1,13 @@