pull/3895/head
TidusJar 6 years ago
parent 0ad8eccbdf
commit 09144aa080

@ -83,9 +83,6 @@ export function HttpLoaderFactory(http: HttpClient, platformLocation: PlatformLo
} }
return new TranslateHttpLoader(http, "/translations/", `.json?v=${version}`); return new TranslateHttpLoader(http, "/translations/", `.json?v=${version}`);
} }
export function baseurlFact() {
return "/" + localStorage.getItem("baseUrl");
}
export function JwtTokenGetter() { export function JwtTokenGetter() {
const token = localStorage.getItem("id_token"); const token = localStorage.getItem("id_token");
@ -171,10 +168,7 @@ export function JwtTokenGetter() {
PlexTvService, PlexTvService,
SearchService, SearchService,
SearchV2Service, SearchV2Service,
{ ],
provide: APP_BASE_HREF,
useFactory: baseurlFact
} ],
bootstrap: [AppComponent], bootstrap: [AppComponent],
}) })
export class AppModule { } export class AppModule { }

@ -5,17 +5,18 @@
<script> <script>
// TODO change to fetch and reload page const existingBaseUrl = window.localStorage.getItem("baseUrl");
const existingBaseUrl = window.localStorage.getItem("baseUrl");
if (existingBaseUrl) { if (existingBaseUrl) {
document.write('<base href="/' + existingBaseUrl + '" />'); document.write('<base href="/' + existingBaseUrl + '" />');
document.write(" <link rel=\"stylesheet\" href='" + existingBaseUrl + "/loading.css'/>")
} else { } else {
// Work out the base URL // Work out the base URL
// Need to find the baseUrl.txt file // Need to find the baseUrl.txt file
let url = window.location.href; let url = window.location.href;
let hasFile = false;
var xmlhttp = new XMLHttpRequest(); var xmlhttp = new XMLHttpRequest();
debugger;
xmlhttp.open("GET", url + "api/v1/Settings/baseurl", false); xmlhttp.open("GET", url + "api/v1/Settings/baseurl", false);
xmlhttp.send(); xmlhttp.send();
while (xmlhttp.status === 404) { while (xmlhttp.status === 404) {
@ -24,14 +25,14 @@
tryGetBaseUrl(xmlhttp, url); tryGetBaseUrl(xmlhttp, url);
} }
const data = JSON.parse(xmlhttp.responseText); const data = JSON.parse(xmlhttp.responseText);
hasFile = true;
debugger; debugger;
document.write('<base href="/' + data + '" />'); document.write('<base href="/' + data + '" />');
document.write(" <link rel=\"stylesheet\" href=" + data + "/loading.css\"/>")
window.localStorage.setItem("baseUrl", data); window.localStorage.setItem("baseUrl", data);
function tryGetBaseUrl(xmlhttp, url) {
function tryGetBaseUrl(xmlhttp, url) { xmlhttp.open("GET", url + "api/v1/Settings/baseurl", false);
debugger;
xmlhttp.open("GET", url + "/api/v1/Settings/baseurl", false);
xmlhttp.send(); xmlhttp.send();
} }
} }
@ -45,7 +46,6 @@
<link rel="stylesheet" href="/loading.css" />
<script src="//maps.google.com/maps/api/js?libraries=visualization&key=AIzaSyBDar8LXU5vbURGTMcNLI0f9AsoSnpiV3I" async <script src="//maps.google.com/maps/api/js?libraries=visualization&key=AIzaSyBDar8LXU5vbURGTMcNLI0f9AsoSnpiV3I" async
defer></script> defer></script>

Loading…
Cancel
Save