Fixed error in express address

This commit is contained in:
Pax1601 2024-11-12 16:56:51 +01:00
parent 53237c6197
commit b97713f8cc
5 changed files with 11 additions and 10 deletions

View File

@ -248,7 +248,7 @@ export class MissionManager {
}
var xhr = new XMLHttpRequest();
xhr.open("GET", getApp().getExpressAddress() + `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;

View File

@ -136,7 +136,7 @@ export class OlympusApp {
});
/* Load the config file from the server */
const configRequest = new Request(this.getExpressAddress() + "resources/config");
const configRequest = new Request(this.getExpressAddress() + "/resources/config");
fetch(configRequest)
.then((response) => {
if (response.status === 200) {
@ -172,7 +172,7 @@ export class OlympusApp {
body: JSON.stringify(profile), // Send the data in JSON format
};
fetch(this.getExpressAddress() + `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`);

View File

@ -6,6 +6,7 @@ import { DateAndTime, UnitBlueprint } from "../interfaces";
import { Converter } from "usng";
import { MGRS } from "../types/types";
import { featureCollection } from "turf";
import { getApp } from "../olympusapp";
export function bearing(lat1: number, lon1: number, lat2: number, lon2: number) {
const φ1 = deg2rad(lat1); // φ, λ in radians
@ -291,7 +292,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", getApp().getExpressAddress() + `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 = () => {

View File

@ -138,7 +138,7 @@ export class ServerManager {
getConfig(callback: CallableFunction) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", getApp().getExpressAddress() + "config", true);
xmlHttp.open("GET", getApp().getExpressAddress() + "/config", true);
xmlHttp.onload = function (e) {
var data = JSON.parse(xmlHttp.responseText);
callback(data);
@ -150,7 +150,7 @@ export class ServerManager {
}
setAddress(address: string) {
this.#REST_ADDRESS = `${address.replace("vite/", "").replace("vite", "")}olympus`;
this.#REST_ADDRESS = address;
console.log(`Setting REST address to ${this.#REST_ADDRESS}`);
}

View File

@ -56,10 +56,10 @@ export class UnitsManager {
constructor() {
this.#unitDatabase = new UnitDatabase();
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");
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());