1
0
mirror of https://github.com/mailcow/mailcow-dockerized.git synced 2025-01-08 04:05:03 +02:00

[SOGo] fix custom html elements and wrong redirection

This commit is contained in:
FreddleSpl0it 2024-02-23 09:12:17 +01:00
parent 916d0fd46a
commit 766c270b1f
No known key found for this signature in database
GPG Key ID: 00E14E7634F4BEC5
2 changed files with 34 additions and 28 deletions

View File

@ -6,42 +6,48 @@ document.addEventListener('DOMContentLoaded', function () {
} }
angularReady = false; angularReady = false;
// Wait for the Angular components to be initialized function observe() {
function waitForAngularComponents(callback) { angularReady = toolbarExists();
const targetNode = document.body; if (angularReady && !mcElementsExists()) addMCElements();
const observer = new MutationObserver(function(mutations) { const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) { if (!angularReady) {
if (mutation.addedNodes.length > 0) { mutations.forEach(function(mutation) {
const toolbarElement = document.body.querySelector('md-toolbar'); if (mutation.addedNodes.length > 0) angularReady = toolbarExists();
if (toolbarElement) { });
observer.disconnect(); } else if (angularReady && !mcElementsExists()) {
callback(); addMCElements();
}
} }
});
}); });
const targetNode = document.body;
const config = { childList: true, subtree: true }; const config = { childList: true, subtree: true };
observer.observe(targetNode, config); 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_logout"))
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 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><a class="md-icon-button md-button md-ink-ripple" aria-label="mailcow" href="#" onclick="mc_logout.submit()" aria-hidden="false" tabindex="-1">' +
'<md-icon class="material-icons" role="img" aria-label="settings_power">settings_power</md-icon>' +
'</a><form action="/" method="post" id="mc_logout"><input type="hidden" name="logout"></form>';
toolbarElement.insertAdjacentHTML('beforeend', htmlCode);
}
// Usage observe();
waitForAngularComponents(function() {
if (!angularReady){
angularReady = true;
const toolbarElement = document.body.querySelector('.md-toolbar-tools.sg-toolbar-group-last.layout-align-end-center.layout-row');
var htmlCode = '<a 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><a class="md-icon-button md-button md-ink-ripple" aria-label="mailcow" href="#" onclick="logout.submit()" aria-hidden="false" tabindex="-1">' +
'<md-icon class="material-icons" role="img" aria-label="settings_power">settings_power</md-icon>' +
'</a><form action="/" method="post" id="logout"><input type="hidden" name="logout"></form>';
toolbarElement.insertAdjacentHTML('beforeend', htmlCode);
}
});
}); });
// Custom SOGo JS // Custom SOGo JS

View File

@ -72,7 +72,7 @@ elseif (isset($_GET['login'])) {
} }
} }
} }
header("Location: /SOGo/"); header("Location: /");
exit; exit;
} }
// only check for admin-login on sogo GUI requests // only check for admin-login on sogo GUI requests