Skip to content

Commit

Permalink
Feature: System Message Support (#1639)
Browse files Browse the repository at this point in the history
* Added support for displaying a system message controllable through the language system

* Fixed typo in javascript
Set the system message enabled to default to false
  • Loading branch information
andrewbrazzatti authored Oct 16, 2023
1 parent 765d179 commit 00a9b86
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
6 changes: 5 additions & 1 deletion assets/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "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"

}
5 changes: 5 additions & 0 deletions assets/styles/default-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
37 changes: 37 additions & 0 deletions views/default/default/layout.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@
<% if (typeof title!== 'undefined') { %>
<% } %>

<% if (TranslationService.t('system-message-enabled') == 'true') { %>
<div id="system-message-area" class="container">
<div id="system-message" class="alert alert-primary alert-dismissible fade show" role="alert">
<h4><%- TranslationService.t('system-message-title') %></h4>
<div><%- TranslationService.t('system-message-description') %></div>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
</div>
<% } %>

<div class="maincontent-body">
<%- body %>
</div>
Expand Down Expand Up @@ -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)
})
});
</script>
</body>
Expand Down

0 comments on commit 00a9b86

Please sign in to comment.