From 3ec7bf7acb47397f3e076ccbcfc2009b01fdd54c Mon Sep 17 00:00:00 2001 From: Peter Siegmund Date: Sun, 18 Jan 2026 22:41:20 +0100 Subject: [PATCH] more status values Signed-off-by: Peter Siegmund --- firmware/components/api-server/src/common.c | 9 ++++++++ firmware/storage/www/css/index.css | 5 +++++ firmware/storage/www/index.html | 12 +++++----- firmware/storage/www/js/app.js | 1 - firmware/storage/www/js/i18n.js | 8 +++++-- firmware/storage/www/js/light.js | 25 +++++++++++++++++++-- 6 files changed, 49 insertions(+), 11 deletions(-) diff --git a/firmware/components/api-server/src/common.c b/firmware/components/api-server/src/common.c index 5b1cf9f..9bb5b84 100644 --- a/firmware/components/api-server/src/common.c +++ b/firmware/components/api-server/src/common.c @@ -3,6 +3,7 @@ #include #include "persistence_manager.h" +#include // Gibt ein cJSON-Objekt with dem aktuellen Lichtstatus zurück cJSON *create_light_status_json(void) @@ -35,6 +36,14 @@ cJSON *create_light_status_json(void) cJSON_AddNumberToObject(color, "b", 220); cJSON_AddItemToObject(json, "color", color); + // Add current time as HH:MM only (suffix is handled in the frontend) + time_t now = time(NULL); + struct tm tm_info; + localtime_r(&now, &tm_info); + char time_str[8]; + strftime(time_str, sizeof(time_str), "%H:%M", &tm_info); + cJSON_AddStringToObject(json, "clock", time_str); + persistence_manager_deinit(&pm); return json; diff --git a/firmware/storage/www/css/index.css b/firmware/storage/www/css/index.css index 84592c4..09088ab 100644 --- a/firmware/storage/www/css/index.css +++ b/firmware/storage/www/css/index.css @@ -557,6 +557,11 @@ body { align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); + display: none; +} + +.status-item.visible { + display: flex; } .status-item:last-child { diff --git a/firmware/storage/www/index.html b/firmware/storage/www/index.html index cf8cfa1..fc69273 100644 --- a/firmware/storage/www/index.html +++ b/firmware/storage/www/index.html @@ -92,18 +92,18 @@

Aktueller Status

-
+
Modus Simulation
-
- Schema - Schema 1 -
-
+
Aktuelle Farbe
+
+ Uhrzeit + --:-- Uhr +
diff --git a/firmware/storage/www/js/app.js b/firmware/storage/www/js/app.js index 6e76058..5a5940c 100644 --- a/firmware/storage/www/js/app.js +++ b/firmware/storage/www/js/app.js @@ -40,7 +40,6 @@ document.addEventListener('touchend', (e) => { lastTouchEnd = now; }, false); -// Initialization document.addEventListener('DOMContentLoaded', async () => { initI18n(); initTheme(); diff --git a/firmware/storage/www/js/i18n.js b/firmware/storage/www/js/i18n.js index 30add6c..7e63d54 100644 --- a/firmware/storage/www/js/i18n.js +++ b/firmware/storage/www/js/i18n.js @@ -41,6 +41,7 @@ const translations = { 'control.status.mode': 'Modus', 'control.status.schema': 'Schema', 'control.status.color': 'Aktuelle Farbe', + 'control.status.clock': 'Uhrzeit', // Common 'common.on': 'AN', @@ -174,7 +175,8 @@ const translations = { // General 'loading': 'Laden...', 'error': 'Fehler', - 'success': 'Erfolg' + 'success': 'Erfolg', + 'clock.suffix': 'Uhr' }, en: { @@ -216,6 +218,7 @@ const translations = { 'control.status.mode': 'Mode', 'control.status.schema': 'Schema', 'control.status.color': 'Current Color', + 'control.status.clock': "Time", // Common 'common.on': 'ON', @@ -349,7 +352,8 @@ const translations = { // General 'loading': 'Loading...', 'error': 'Error', - 'success': 'Success' + 'success': 'Success', + 'clock.suffix': "o'clock" } }; diff --git a/firmware/storage/www/js/light.js b/firmware/storage/www/js/light.js index 3983f08..2828e10 100644 --- a/firmware/storage/www/js/light.js +++ b/firmware/storage/www/js/light.js @@ -115,6 +115,20 @@ function updateSimulationOptions() { } else { options.classList.remove('visible'); } + + [ + 'control.status.clock' + ].forEach(i18nKey => { + const label = document.querySelector(`.status-item .status-label[data-i18n="${i18nKey}"]`); + const item = label ? label.closest('.status-item') : null; + if (item) { + if (currentMode === 'simulation') { + item.classList.add('visible'); + } else { + item.classList.remove('visible'); + } + } + }); } async function setActiveSchema() { @@ -173,8 +187,6 @@ async function loadLightStatus() { // Update schema if (status.schema) { document.getElementById('active-schema').value = status.schema; - const schemaNum = status.schema.replace('schema_0', '').replace('.csv', ''); - document.getElementById('current-schema').textContent = t(`schema.name.${schemaNum}`); } // Update current color @@ -184,6 +196,15 @@ async function loadLightStatus() { colorPreview.style.backgroundColor = `rgb(${status.color.r}, ${status.color.g}, ${status.color.b})`; } } + + // Update clock/time + if (status.clock) { + const clockEl = document.getElementById('current-clock'); + if (clockEl) { + // Use one translation key for the suffix, language is handled by t() + clockEl.textContent = status.clock + ' ' + t('clock.suffix'); + } + } } } catch (error) { console.log('Light status not available');