Configuration split to lists, send configurations and server config.

This is before testing.
This commit is contained in:
Tomas Bures 2018-04-22 17:33:43 +02:00
parent 4fce4b6f81
commit c12efeb97f
40 changed files with 819 additions and 311 deletions

View file

@ -2,36 +2,33 @@
import mailtrainConfig from "mailtrainConfig";
let urlBase;
let sandboxUrlBase;
if (mailtrainConfig.urlBase.startsWith('/')) {
urlBase = window.location.protocol + '//' + window.location.hostname + ':' + mailtrainConfig.port + mailtrainConfig.urlBase;
} else {
urlBase = mailtrainConfig.urlBase
}
if (mailtrainConfig.sandboxUrlBase) {
if (mailtrainConfig.urlBase.startsWith('/')) {
sandboxUrlBase = window.location.protocol + '//' + window.location.hostname + ':' + mailtrainConfig.sandboxPort + mailtrainConfig.sandboxUrlBase;
} else {
sandboxUrlBase = mailtrainConfig.sandboxUrlBase
}
} else {
const loc = document.createElement("a");
loc.href = urlBase;
sandboxUrlBase = loc.protocol + '//' + loc.hostname + ':' + mailtrainConfig.sandboxPort + loc.pathname;
}
function getTrustedUrl(path) {
return urlBase + path;
return mailtrainConfig.trustedUrlBase + (path || '');
}
function getSandboxUrl(path) {
return sandboxUrlBase + path;
return mailtrainConfig.sandboxUrlBase + (path || '');
}
function getUrl(path) {
if (mailtrainConfig.trusted) {
return getTrustedUrl(path);
} else {
return getSandboxUrl(path);
}
}
function getBaseDir() {
if (mailtrainConfig.trusted) {
return mailtrainConfig.trustedUrlBaseDir;
} else {
return mailtrainConfig.sandboxUrlBaseDir;
}
}
export {
getTrustedUrl,
getSandboxUrl
getSandboxUrl,
getUrl,
getBaseDir
}