forked from wazuh/wazuh-docker
112 lines
3.9 KiB
Handlebars
112 lines
3.9 KiB
Handlebars
var kbnCsp = JSON.parse(document.querySelector('kbn-csp').getAttribute('data'));
|
|
window.__kbnStrictCsp__ = kbnCsp.strictCsp;
|
|
window.__kbnDarkMode__ = {{darkMode}};
|
|
window.__kbnPublicPath__ = {{publicPathMap}};
|
|
|
|
if (window.__kbnStrictCsp__ && window.__kbnCspNotEnforced__) {
|
|
var legacyBrowserError = document.getElementById('kbn_legacy_browser_error');
|
|
legacyBrowserError.style.display = 'flex';
|
|
} else {
|
|
if (!window.__kbnCspNotEnforced__ && window.console) {
|
|
window.console.log("^ A single error about an inline script not firing due to content security policy is expected!");
|
|
}
|
|
var loadingMessage = document.getElementById('kbn_loading_message');
|
|
loadingMessage.style.display = 'flex';
|
|
|
|
window.onload = function () {
|
|
//WAZUH
|
|
var interval = setInterval(() => {
|
|
var title = document.getElementsByClassName('login-title');
|
|
if ((title || []).length) {
|
|
clearInterval(interval);
|
|
title[0].textContent = "Welcome to Wazuh";
|
|
var subtitle = document.getElementsByClassName('login-subtitle');
|
|
subtitle[0].textContent = "The Open Source Security Platform";
|
|
var logo = document.getElementsByClassName('brand-image-container');
|
|
$(logo).append('<span class="loginWelcome__logo"></span>');
|
|
}
|
|
})
|
|
//
|
|
|
|
function failure() {
|
|
// make subsequent calls to failure() noop
|
|
failure = function () {};
|
|
|
|
var err = document.createElement('h1');
|
|
err.style['color'] = 'white';
|
|
err.style['font-family'] = 'monospace';
|
|
err.style['text-align'] = 'center';
|
|
err.style['background'] = '#F44336';
|
|
err.style['padding'] = '25px';
|
|
err.innerText = document.querySelector('[data-error-message]').dataset.errorMessage;
|
|
|
|
document.body.innerHTML = err.outerHTML;
|
|
}
|
|
|
|
var stylesheetTarget = document.querySelector('head meta[name="add-styles-here"]')
|
|
function loadStyleSheet(url, cb) {
|
|
var dom = document.createElement('link');
|
|
dom.rel = 'stylesheet';
|
|
dom.type = 'text/css';
|
|
dom.href = url;
|
|
dom.addEventListener('error', failure);
|
|
dom.addEventListener('load', cb);
|
|
document.head.insertBefore(dom, stylesheetTarget);
|
|
}
|
|
|
|
var scriptsTarget = document.querySelector('head meta[name="add-scripts-here"]')
|
|
function loadScript(url, cb) {
|
|
var dom = document.createElement('script');
|
|
{{!-- NOTE: async = false is used to trigger async-download/ordered-execution as outlined here: https://www.html5rocks.com/en/tutorials/speed/script-loading/ --}}
|
|
dom.async = false;
|
|
dom.src = url;
|
|
dom.addEventListener('error', failure);
|
|
dom.addEventListener('load', cb);
|
|
document.head.insertBefore(dom, scriptsTarget);
|
|
}
|
|
|
|
function load(urls, cb) {
|
|
var pending = urls.length;
|
|
urls.forEach(function (url) {
|
|
var innerCb = function () {
|
|
pending = pending - 1;
|
|
if (pending === 0 && typeof cb === 'function') {
|
|
cb();
|
|
}
|
|
}
|
|
|
|
if (typeof url !== 'string') {
|
|
load(url, innerCb);
|
|
} else if (url.slice(-4) === '.css') {
|
|
loadStyleSheet(url, innerCb);
|
|
} else {
|
|
loadScript(url, innerCb);
|
|
}
|
|
});
|
|
}
|
|
|
|
load([
|
|
{{#each jsDependencyPaths}}
|
|
'{{this}}',
|
|
{{/each}}
|
|
], function () {
|
|
{{#unless legacyBundlePath}}
|
|
if (!__kbnBundles__ || !__kbnBundles__['entry/core'] || typeof __kbnBundles__['entry/core'].__kbnBootstrap__ !== 'function') {
|
|
console.error('entry/core bundle did not load correctly');
|
|
failure();
|
|
} else {
|
|
__kbnBundles__['entry/core'].__kbnBootstrap__()
|
|
}
|
|
{{/unless}}
|
|
|
|
load([
|
|
{{#if legacyBundlePath}}
|
|
'{{legacyBundlePath}}',
|
|
{{/if}}
|
|
{{#each styleSheetPaths}}
|
|
'{{this}}',
|
|
{{/each}}
|
|
]);
|
|
});
|
|
}
|
|
} |