From bfd97dd4d2be0970a931cec882c8cab98b6b40af Mon Sep 17 00:00:00 2001 From: Andrew Brazzatti Date: Fri, 13 Oct 2023 01:58:10 +0000 Subject: [PATCH 1/2] Added support for displaying a system message controllable through the language system --- assets/locales/en/translation.json | 6 ++++- assets/styles/default-theme.scss | 5 ++++ views/default/default/layout.ejs | 37 ++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/assets/locales/en/translation.json b/assets/locales/en/translation.json index e4a0c5ffa6..21da87af25 100644 --- a/assets/locales/en/translation.json +++ b/assets/locales/en/translation.json @@ -754,5 +754,9 @@ "oidc-user-doesnt-exist-in-tenant": "User account from identity provider does not exist in tenant. The account needs to be added as an external user in the tenant first.", "oidc-user-doesnt-exist-in-tenant-detail": "For email {{-email}} and url {{-url}} and tenant {{-name}}", "lang-en": "English", - "lang-mri": "Māori" + "lang-mri": "Māori", + "system-message-enabled": "true", + "system-message-title": "System Notification", + "system-message-description": "ReDBox will be unavailable from 9am to 12pm on October 20 for system upgrades. Please contact support for any help" + } diff --git a/assets/styles/default-theme.scss b/assets/styles/default-theme.scss index a8b670ef95..690cee2a5c 100644 --- a/assets/styles/default-theme.scss +++ b/assets/styles/default-theme.scss @@ -192,6 +192,11 @@ z-index: 999; padding: 80px 0 130px; } +#system-message-area { + padding-top: 80px; + display: none; + } + .site-branding-area { background-color: $site-branding-area-background; } diff --git a/views/default/default/layout.ejs b/views/default/default/layout.ejs index 1686765b6e..b75184d418 100644 --- a/views/default/default/layout.ejs +++ b/views/default/default/layout.ejs @@ -115,6 +115,16 @@ <% if (typeof title!== 'undefined') { %> <% } %> +<% if (TranslationService.t('system-message-enabled') == 'true') { %> +
+ +
+ <% } %> +
<%- body %>
@@ -155,6 +165,33 @@ curHref.closest('li').addClass('active').closest('.dropdown').addClass('site-branding-area'); } } + + const storedsystemMessageDismissalTime = parseInt(localStorage.getItem('systemMessageDismissalTime'), 10); + + if (storedsystemMessageDismissalTime) { + const currentsystemMessageDismissalTime = Date.now(); + const eightHoursInMillis = 8 * 60 * 60 * 1000; // 8 hours in milliseconds + if (currentsystemMessageDismissalTime - storedsystemMessageDismissalTime > eightHoursInMillis) { + //Already been dismissed in the past 8 hours so close it + $('#system-message-area').show() + } else { + //remove the system message area as it takes up space even when hidden + const systemMessageArea = document.getElementById('system-message-area'); + systemMessageArea.parentNode.removeChild(systemMessageArea) + } + } else { + $('#system-message-area').show() + } + + $('#system-message').on('closed.bs.alert', function () { + + const currentEpochMillis = Date.now(); + + localStorage.setItem('systemMessageDismissalTime', currentEpochMillis.toString()); + $//remove the system message area as it takes up space even when hidden + const systemMessageArea = document.getElementById('system-message-area'); + systemMessageArea.parentNode.removeChild(systemMessageArea) + }) }); From 8aefdc90d5cf58db7e26def1e8aa607dff16069e Mon Sep 17 00:00:00 2001 From: Andrew Brazzatti Date: Fri, 13 Oct 2023 02:02:09 +0000 Subject: [PATCH 2/2] Fixed typo in javascript Set the system message enabled to default to false --- assets/locales/en/translation.json | 2 +- views/default/default/layout.ejs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/locales/en/translation.json b/assets/locales/en/translation.json index 21da87af25..b34fbc39dd 100644 --- a/assets/locales/en/translation.json +++ b/assets/locales/en/translation.json @@ -755,7 +755,7 @@ "oidc-user-doesnt-exist-in-tenant-detail": "For email {{-email}} and url {{-url}} and tenant {{-name}}", "lang-en": "English", "lang-mri": "Māori", - "system-message-enabled": "true", + "system-message-enabled": "false", "system-message-title": "System Notification", "system-message-description": "ReDBox will be unavailable from 9am to 12pm on October 20 for system upgrades. Please contact support for any help" diff --git a/views/default/default/layout.ejs b/views/default/default/layout.ejs index b75184d418..859c14c698 100644 --- a/views/default/default/layout.ejs +++ b/views/default/default/layout.ejs @@ -188,7 +188,7 @@ const currentEpochMillis = Date.now(); localStorage.setItem('systemMessageDismissalTime', currentEpochMillis.toString()); - $//remove the system message area as it takes up space even when hidden + //remove the system message area as it takes up space even when hidden const systemMessageArea = document.getElementById('system-message-area'); systemMessageArea.parentNode.removeChild(systemMessageArea) })