From 2cc4bf699a6ad51d1169e32c80bc8ed3a2300495 Mon Sep 17 00:00:00 2001 From: "alexei.dolgolyov" Date: Tue, 24 Mar 2026 00:09:11 +0300 Subject: [PATCH] fix: NUT template preview + tracking config event checkboxes - Add NUT variables to _SAMPLE_CONTEXT (fixes ups_name undefined in preview) - Add NUT event tracking checkboxes to tracking config form - Add NUT event i18n keys (EN + RU) --- frontend/src/lib/i18n/en.json | 19 ++++++++++++++++++- frontend/src/lib/i18n/ru.json | 19 ++++++++++++++++++- .../src/routes/tracking-configs/+page.svelte | 11 +++++++++++ .../services/sample_context.py | 13 +++++++++++++ 4 files changed, 60 insertions(+), 2 deletions(-) diff --git a/frontend/src/lib/i18n/en.json b/frontend/src/lib/i18n/en.json index 0bfa4d1..2850d3a 100644 --- a/frontend/src/lib/i18n/en.json +++ b/frontend/src/lib/i18n/en.json @@ -112,6 +112,7 @@ "typePlanka": "Planka", "typeScheduler": "Scheduler", "typeNut": "NUT (UPS)", + "typeGooglePhotos": "Google Photos", "loadError": "Failed to load providers.", "externalDomain": "External Domain", "optional": "optional", @@ -135,6 +136,13 @@ "nutPassword": "Password", "nutUsernameHint": "Optional — only needed if upsd requires authentication", "nutPasswordHint": "Optional — upsd user password", + "gpClientId": "OAuth Client ID", + "gpClientSecret": "OAuth Client Secret", + "gpClientSecretKeep": "OAuth Client Secret (leave empty to keep current)", + "gpRefreshToken": "Refresh Token", + "gpRefreshTokenKeep": "Refresh Token (leave empty to keep current)", + "gpRefreshTokenHint": "Obtain from Google OAuth Playground (developers.google.com/oauthplayground) with the Photos Library API scope.", + "gpAllFieldsRequired": "Client ID, Client Secret, and Refresh Token are all required", "testAndSave": "Test & Save", "saveWithoutTest": "Save without testing" }, @@ -422,6 +430,14 @@ "attachmentCreated": "Attachment added", "cardLabelAdded": "Label added", "taskCompleted": "Task completed", + "upsOnline": "UPS online (mains restored)", + "upsOnBattery": "UPS on battery", + "upsLowBattery": "Low battery", + "upsBatteryRestored": "Battery recovered", + "upsCommsLost": "Communication lost", + "upsCommsRestored": "Communication restored", + "upsReplaceBattery": "Replace battery", + "upsOverload": "UPS overloaded", "scheduledMessage": "Scheduled message", "trackImages": "Track images", "trackVideos": "Track videos", @@ -841,7 +857,8 @@ "providerGitea": "Self-hosted Git service", "providerPlanka": "Self-hosted Kanban board", "providerScheduler": "Time-based scheduled messages", - "providerNut": "Network UPS monitoring" + "providerNut": "Network UPS monitoring", + "providerGooglePhotos": "Google Photos albums & shared libraries" }, "error": { "notFound": "Page not found", diff --git a/frontend/src/lib/i18n/ru.json b/frontend/src/lib/i18n/ru.json index 7683907..3addd0d 100644 --- a/frontend/src/lib/i18n/ru.json +++ b/frontend/src/lib/i18n/ru.json @@ -112,6 +112,7 @@ "typePlanka": "Planka", "typeScheduler": "Планировщик", "typeNut": "NUT (ИБП)", + "typeGooglePhotos": "Google Фото", "loadError": "Не удалось загрузить провайдеры.", "externalDomain": "Внешний домен", "optional": "необязательно", @@ -135,6 +136,13 @@ "nutPassword": "Пароль", "nutUsernameHint": "Необязательно — только если upsd требует аутентификации", "nutPasswordHint": "Необязательно — пароль пользователя upsd", + "gpClientId": "OAuth Client ID", + "gpClientSecret": "OAuth Client Secret", + "gpClientSecretKeep": "OAuth Client Secret (оставьте пустым для сохранения текущего)", + "gpRefreshToken": "Refresh Token", + "gpRefreshTokenKeep": "Refresh Token (оставьте пустым для сохранения текущего)", + "gpRefreshTokenHint": "Получите через Google OAuth Playground (developers.google.com/oauthplayground) с областью Photos Library API.", + "gpAllFieldsRequired": "Client ID, Client Secret и Refresh Token обязательны", "testAndSave": "Проверить и сохранить", "saveWithoutTest": "Сохранить без проверки" }, @@ -422,6 +430,14 @@ "attachmentCreated": "Вложение добавлено", "cardLabelAdded": "Метка добавлена", "taskCompleted": "Задача завершена", + "upsOnline": "ИБП на сети (питание восстановлено)", + "upsOnBattery": "ИБП на батарее", + "upsLowBattery": "Низкий заряд батареи", + "upsBatteryRestored": "Заряд восстановлен", + "upsCommsLost": "Связь потеряна", + "upsCommsRestored": "Связь восстановлена", + "upsReplaceBattery": "Замена батареи", + "upsOverload": "Перегрузка ИБП", "scheduledMessage": "Запланированное сообщение", "trackImages": "Фото", "trackVideos": "Видео", @@ -841,7 +857,8 @@ "providerGitea": "Git-сервер для самостоятельного размещения", "providerPlanka": "Канбан-доска для самостоятельного размещения", "providerScheduler": "Запланированные сообщения по расписанию", - "providerNut": "Мониторинг ИБП через NUT" + "providerNut": "Мониторинг ИБП через NUT", + "providerGooglePhotos": "Альбомы и общие библиотеки Google Фото" }, "error": { "notFound": "Страница не найдена", diff --git a/frontend/src/routes/tracking-configs/+page.svelte b/frontend/src/routes/tracking-configs/+page.svelte index 9fb2912..c508fcb 100644 --- a/frontend/src/routes/tracking-configs/+page.svelte +++ b/frontend/src/routes/tracking-configs/+page.svelte @@ -167,6 +167,17 @@ + {:else if form.provider_type === 'nut'} +
+ + + + + + + + +
{:else}
diff --git a/packages/server/src/notify_bridge_server/services/sample_context.py b/packages/server/src/notify_bridge_server/services/sample_context.py index 476b38c..69d9057 100644 --- a/packages/server/src/notify_bridge_server/services/sample_context.py +++ b/packages/server/src/notify_bridge_server/services/sample_context.py @@ -166,6 +166,19 @@ _SAMPLE_CONTEXT = { "attachment_id": "att-1", "label_name": "bug", "label_color": "berry-red", + # NUT (UPS) variables (for nut provider templates) + "ups_name": "kiper", + "ups_model": "Smart-UPS 1500", + "ups_manufacturer": "APC", + "battery_charge": 95, + "battery_runtime": "1:23:45", + "battery_runtime_seconds": 5025, + "ups_load": 42, + "ups_status": "OL", + "input_voltage": "230.0", + "output_voltage": "230.0", + "event_description": "UPS switched to battery power", + "previous_status": "OL", # Scheduler variables (for scheduler provider templates) "schedule_name": "Daily Reminder", "fire_count": 42,