From abf943da5ffee91dfefec07e691e6412aa7872a4 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Fri, 26 Jul 2024 12:30:58 +0200 Subject: [PATCH] ui: allow disabling notifications globally --- CHANGELOG.md | 2 ++ resources/docs/docs/client-options.md | 1 + resources/docs/docs/user-interface/client.md | 1 + src/client/locales/de.js | 5 ++++- src/client/locales/en.js | 3 +++ src/client/locales/fr.js | 3 +++ src/client/locales/pl.js | 3 +++ src/client/ui/main-menu.js | 7 +++++++ src/client/ui/notifications.js | 10 ++++++++++ 9 files changed, 34 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4d2de0c..626b0c10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ - client - file browser now remembers the last displayed directory - allow dismissing notifications by clicking on them + - allow toggling notifications globally from main menu + - add `notifications` client option ## 1.26.2 diff --git a/resources/docs/docs/client-options.md b/resources/docs/docs/client-options.md index 0ec69a1c..41b046ae 100644 --- a/resources/docs/docs/client-options.md +++ b/resources/docs/docs/client-options.md @@ -17,6 +17,7 @@ Client options can be set either with the server's `--client-options` option, or | clientSync | 1 / 0 | 1 | set to 0 to prevent the client from syncing with other clients | | altTraversing | 1 / 0 | 0 | set to 1 to enable an alternative traversing behavior for toggle buttons (traversing gestures on toggle buttons will change their values in only one way depending on the first touched button's state) | | virtualKeyboard | 1 / 0 | 0 | (desktop only) set to 1 to enable the virtual keyboard by default | +| notifications | 1 / 0 | 1 | set to 0 to hide notifications by default | Example: diff --git a/resources/docs/docs/user-interface/client.md b/resources/docs/docs/user-interface/client.md index a7a05e0d..2133c01f 100644 --- a/resources/docs/docs/user-interface/client.md +++ b/resources/docs/docs/user-interface/client.md @@ -30,6 +30,7 @@ - Clear console: remove logged messages from the console - Virtual keyboard: (desktop only) toggle virtual keyboard (displayed only when a text input is in focus, except for code editors in the inspector) - Fullscreen: toggle fullscreen +- Notifications: toggle visibility of notifications - Prevent sleep (mobile only): attempt to prevent device from going to sleep when idle ## 2. Sidepanels diff --git a/src/client/locales/de.js b/src/client/locales/de.js index 4b534f2a..a0e8d1cb 100644 --- a/src/client/locales/de.js +++ b/src/client/locales/de.js @@ -94,6 +94,9 @@ module.exports = { // nosleep nosleep: 'Prevent sleep', + // notifications + notifications: 'Benachrichtigungen', + // remote save remotesave_open: 'Öffnen (auf dem Server)', remotesave_save: 'Speichern (auf dem Server)', @@ -135,4 +138,4 @@ module.exports = { error: 'Error' -} \ No newline at end of file +} diff --git a/src/client/locales/en.js b/src/client/locales/en.js index 854b632d..eb43793e 100644 --- a/src/client/locales/en.js +++ b/src/client/locales/en.js @@ -94,6 +94,9 @@ module.exports = { // nosleep nosleep: 'Prevent sleep', + // notifications + notifications: 'Notifications', + // remote save remotesave_open: 'Open (on the server)', remotesave_save: 'Save (on the server)', diff --git a/src/client/locales/fr.js b/src/client/locales/fr.js index 2930a437..9538d4dc 100644 --- a/src/client/locales/fr.js +++ b/src/client/locales/fr.js @@ -94,6 +94,9 @@ module.exports = { // nosleep nosleep: 'Empêcher la veille', + // notifications + notifications: 'Notifications', + // remote save remotesave_open: 'Ouvrir (sur le serveur)', remotesave_save: 'Enregistrer (sur le serveur)', diff --git a/src/client/locales/pl.js b/src/client/locales/pl.js index 0e48a7fa..7fac7fa1 100644 --- a/src/client/locales/pl.js +++ b/src/client/locales/pl.js @@ -94,6 +94,9 @@ module.exports = { // nosleep nosleep: 'Nie pozwalaj na uśpienie ekranu', + // notifications + notifications: 'Powiadomienia', + // remote save remotesave_open: 'Otwórz (na serwerze)', remotesave_save: 'Sapisz (na serwerze)', diff --git a/src/client/ui/main-menu.js b/src/client/ui/main-menu.js index c948983d..03adeac4 100644 --- a/src/client/ui/main-menu.js +++ b/src/client/ui/main-menu.js @@ -211,6 +211,13 @@ var menuEntries = [ if (fullscreen.isEnabled) fullscreen.toggle() }, shortcut: 'f11' + }, + { + label: locales('notifications'), + class: ()=>{return 'toggle ' + (notifications.visible ? 'on' : 'off')}, + action: ()=>{ + notifications.setVisibility(!notifications.visible) + } } ] diff --git a/src/client/ui/notifications.js b/src/client/ui/notifications.js index 3a5e1324..37d1e187 100644 --- a/src/client/ui/notifications.js +++ b/src/client/ui/notifications.js @@ -63,6 +63,9 @@ class Notifications extends UiWidget { this.toasts = [] this.loop = null + this.visible = undefined + + this.setVisibility(ENV.notifications != 0) this.container.addEventListener('fast-click', (e)=>{ for (var toast of this.toasts) { @@ -124,6 +127,13 @@ class Notifications extends UiWidget { } + setVisibility(v) { + + this.visible = v + this.container.style.display = v ? '' : 'none' + + } + } module.exports = new Notifications({selector: '#notifications'})