From c6b7f1fa9624f0ce8d089136980a1e364bf777ab Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 16 Sep 2022 15:20:35 +0200 Subject: [PATCH 1/2] Json stringify `object` measurements This change will e.g. make the values of `typing.NamedTuple`s visible in the Web UI. Before this change they were displayed as `[object Object]`. I believe the measurements are guaranteed to be json-serializable because they are coming in via the websocket transport, which uses json already. --- .../output/web_gui/src/app/stations/station/station-data.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openhtf/output/web_gui/src/app/stations/station/station-data.ts b/openhtf/output/web_gui/src/app/stations/station/station-data.ts index 8392a5624..5fe15420f 100644 --- a/openhtf/output/web_gui/src/app/stations/station/station-data.ts +++ b/openhtf/output/web_gui/src/app/stations/station/station-data.ts @@ -205,7 +205,9 @@ function makePhase(phase: RawPhase, running: boolean) { measurements = Object.keys(phase.measurements).map(key => { const rawMeasuredValue = phase.measurements[key].measured_value; let measuredValue = null; - if (typeof rawMeasuredValue !== 'undefined') { + if (typeof rawMeasuredValue === 'object') { + measuredValue = JSON.stringify(rawMeasuredValue); + } else if (typeof rawMeasuredValue !== 'undefined') { measuredValue = `${rawMeasuredValue}`; } return new Measurement({ From ce7387cab3a04190219abee395fe4c1a0ef7bc43 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Thu, 13 Oct 2022 14:46:04 +0200 Subject: [PATCH 2/2] Pretty-print json-stringified measurement values --- .../web_gui/src/app/shared/trimmed-text.component.ts | 2 +- .../web_gui/src/app/stations/station/station-data.ts | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/openhtf/output/web_gui/src/app/shared/trimmed-text.component.ts b/openhtf/output/web_gui/src/app/shared/trimmed-text.component.ts index 818289f3c..f6d465802 100644 --- a/openhtf/output/web_gui/src/app/shared/trimmed-text.component.ts +++ b/openhtf/output/web_gui/src/app/shared/trimmed-text.component.ts @@ -22,7 +22,7 @@ import { Component, Input } from '@angular/core'; const ellipsis = '…'; const template = ` - {{ trimmedContent }} +
{{ trimmedContent }}