diff --git a/frontend/react/src/mission/missionmanager.ts b/frontend/react/src/mission/missionmanager.ts index e5dab791..94723055 100644 --- a/frontend/react/src/mission/missionmanager.ts +++ b/frontend/react/src/mission/missionmanager.ts @@ -248,7 +248,7 @@ export class MissionManager { } var xhr = new XMLHttpRequest(); - xhr.open("GET", window.location.href.split("?")[0].replace("vite/", "") + `api/airbases/${this.#theatre.toLowerCase()}/${callsign}`, true); + xhr.open("GET", getApp().getExpressAddress() + `api/airbases/${this.#theatre.toLowerCase()}/${callsign}`, true); xhr.responseType = "json"; xhr.onload = () => { var status = xhr.status; diff --git a/frontend/react/src/olympusapp.ts b/frontend/react/src/olympusapp.ts index 9749113c..3b621ff8 100644 --- a/frontend/react/src/olympusapp.ts +++ b/frontend/react/src/olympusapp.ts @@ -92,6 +92,14 @@ export class OlympusApp { } */ + getExpressAddress() { + return `${window.location.href.split("?")[0].replace("vite/", "").replace("vite", "")}express` + } + + getBackendAddress() { + return `${window.location.href.split("?")[0].replace("vite/", "").replace("vite", "")}olympus` + } + start() { /* Initialize base functionalitites */ this.#shortcutManager = new ShortcutManager(); /* Keep first */ @@ -105,8 +113,8 @@ export class OlympusApp { this.#audioManager = new AudioManager(); /* Set the address of the server */ - this.getServerManager().setAddress(window.location.href.split("?")[0].replace("vite/", "")); - this.getAudioManager().setAddress(window.location.href.split("?")[0].replace("vite/", "")); + this.getServerManager().setAddress(this.getBackendAddress()); + this.getAudioManager().setAddress(this.getExpressAddress()); /* Check if we are running the latest version */ const request = new Request("https://raw.githubusercontent.com/Pax1601/DCSOlympus/main/version.json"); @@ -128,7 +136,7 @@ export class OlympusApp { }); /* Load the config file from the server */ - const configRequest = new Request(window.location.href.split("?")[0].replace("vite/", "") + "resources/config"); + const configRequest = new Request(this.getExpressAddress() + "resources/config"); fetch(configRequest) .then((response) => { if (response.status === 200) { @@ -164,7 +172,7 @@ export class OlympusApp { body: JSON.stringify(profile), // Send the data in JSON format }; - fetch(window.location.href.split("?")[0].replace("vite/", "") + `resources/profile/${this.#profileName}`, requestOptions) + fetch(this.getExpressAddress() + `resources/profile/${this.#profileName}`, requestOptions) .then((response) => { if (response.status === 200) { console.log(`Profile ${this.#profileName} saved correctly`); diff --git a/frontend/react/src/other/utils.ts b/frontend/react/src/other/utils.ts index 430c0e38..74539948 100644 --- a/frontend/react/src/other/utils.ts +++ b/frontend/react/src/other/utils.ts @@ -291,7 +291,7 @@ export function convertDateAndTimeToDate(dateAndTime: DateAndTime) { export function getGroundElevation(latlng: LatLng, callback: CallableFunction) { /* Get the ground elevation from the server endpoint */ const xhr = new XMLHttpRequest(); - xhr.open("GET", window.location.href.split("?")[0].replace("vite/", "") + `api/elevation/${latlng.lat}/${latlng.lng}`, true); + xhr.open("GET", getApp().getExpressAddress() + `api/elevation/${latlng.lat}/${latlng.lng}`, true); xhr.timeout = 500; // ms xhr.responseType = "json"; xhr.onload = () => { diff --git a/frontend/react/src/server/servermanager.ts b/frontend/react/src/server/servermanager.ts index a1f5a370..6ceb7c16 100644 --- a/frontend/react/src/server/servermanager.ts +++ b/frontend/react/src/server/servermanager.ts @@ -39,7 +39,7 @@ export class ServerManager { getApp().getShortcutManager().addShortcut("togglePause", { label: "Pause data update", - callback: () => { + keyUpCallback: () => { this.setPaused(!this.getPaused()); }, code: "Space" @@ -138,7 +138,7 @@ export class ServerManager { getConfig(callback: CallableFunction) { var xmlHttp = new XMLHttpRequest(); - xmlHttp.open("GET", window.location.href.split("?")[0].replace("vite/", "") + "config", true); + xmlHttp.open("GET", getApp().getExpressAddress() + "config", true); xmlHttp.onload = function (e) { var data = JSON.parse(xmlHttp.responseText); callback(data); diff --git a/frontend/react/src/unit/unitsmanager.ts b/frontend/react/src/unit/unitsmanager.ts index 3bb7a894..7cc89696 100644 --- a/frontend/react/src/unit/unitsmanager.ts +++ b/frontend/react/src/unit/unitsmanager.ts @@ -56,10 +56,10 @@ export class UnitsManager { constructor() { this.#unitDatabase = new UnitDatabase(); - this.#unitDatabase.load(window.location.href.split("?")[0].replace("vite/", "") + "api/databases/units/aircraftdatabase", "aircraft"); - this.#unitDatabase.load(window.location.href.split("?")[0].replace("vite/", "") + "api/databases/units/helicopterdatabase", "helicopter"); - this.#unitDatabase.load(window.location.href.split("?")[0].replace("vite/", "") + "api/databases/units/groundunitdatabase", "groundunit"); - this.#unitDatabase.load(window.location.href.split("?")[0].replace("vite/", "") + "api/databases/units/navyunitdatabase", "navyunit"); + this.#unitDatabase.load(getApp().getExpressAddress() + "api/databases/units/aircraftdatabase", "aircraft"); + this.#unitDatabase.load(getApp().getExpressAddress() + "api/databases/units/helicopterdatabase", "helicopter"); + this.#unitDatabase.load(getApp().getExpressAddress() + "api/databases/units/groundunitdatabase", "groundunit"); + this.#unitDatabase.load(getApp().getExpressAddress() + "api/databases/units/navyunitdatabase", "navyunit"); CommandModeOptionsChangedEvent.on(() => { Object.values(this.#units).forEach((unit: Unit) => unit.updateVisibility());