1
0
mirror of https://github.com/mailcow/mailcow-dockerized.git synced 2025-12-27 08:41:32 +00:00

[SOGo] Add mailcow Buttons to SOGo navbar

This commit is contained in:
FreddleSpl0it
2025-01-15 16:15:25 +01:00
parent 8048e0a53c
commit 1e70a20188
5 changed files with 26 additions and 43 deletions

View File

@@ -4,48 +4,6 @@ document.addEventListener('DOMContentLoaded', function () {
if (loginForm) {
window.location.href = '/user';
}
angularReady = false;
function observe() {
angularReady = toolbarExists();
if (angularReady && !mcElementsExists()) addMCElements();
const observer = new MutationObserver(function(mutations) {
if (!angularReady) {
mutations.forEach(function(mutation) {
if (mutation.addedNodes.length > 0) angularReady = toolbarExists();
});
} else if (angularReady && !mcElementsExists()) {
addMCElements();
}
});
const targetNode = document.body;
const config = { childList: true, subtree: true };
observer.observe(targetNode, config);
}
function toolbarExists() {
const toolbarElement = document.body.querySelector('md-toolbar');
if (toolbarElement)
return true;
else
return false;
}
function mcElementsExists() {
if (document.getElementById("mc_backlink"))
return true;
else
return false;
}
function addMCElements() {
const toolbarElement = document.body.querySelector('.md-toolbar-tools.sg-toolbar-group-last.layout-align-end-center.layout-row');
var htmlCode = '<a id="mc_backlink" class="md-icon-button md-button md-ink-ripple" aria-label="mailcow" href="/user" aria-hidden="false" tabindex="-1">' +
'<md-icon class="material-icons" role="img" aria-label="build">build</md-icon>' +
'</a>';
toolbarElement.insertAdjacentHTML('beforeend', htmlCode);
}
observe();
});
// Custom SOGo JS