diff --git a/display/frontend/src/pages/Layouts.tsx b/display/frontend/src/pages/Layouts.tsx index f17bcb1..807c8f1 100644 --- a/display/frontend/src/pages/Layouts.tsx +++ b/display/frontend/src/pages/Layouts.tsx @@ -113,6 +113,22 @@ export default function Layouts() { } catch (e) { setError((e as Error).message); } } + async function updateDatapointLabel(dpId: number, label: string) { + try { + await api.put(`/api/datapoints/${dpId}`, { label }); + loadDatapoints(); + if (selected) selectLayout(selected.id); + } catch (e) { setError((e as Error).message); } + } + + async function updateDatapointUnit(dpId: number, unit: string) { + try { + await api.put(`/api/datapoints/${dpId}`, { unit }); + loadDatapoints(); + if (selected) selectLayout(selected.id); + } catch (e) { setError((e as Error).message); } + } + async function handleDeleteElement(elId: number) { if (!selected) return; try { @@ -278,6 +294,26 @@ export default function Layouts() { )} + {/* Editable datapoint label + unit (for value with assigned datapoint) */} + {el.type === 'value' && dp && ( + <> +
+
Anzeigename
+ { if (e.target.value !== (dp.label || dp.name)) updateDatapointLabel(dp.id, e.target.value); }} + placeholder="Anzeigename" /> +
+
+
Einheit
+ { if (e.target.value !== (dp.unit || '')) updateDatapointUnit(dp.id, e.target.value); }} + placeholder="z.B. W" /> +
+ + )} + {/* Static text (for label) */} {el.type === 'label' && (