Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: System Message Support #1639

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading