add URL base option for subfolder proxies

also cleaned up the naming of some things.
This commit is contained in:
Harvey Tindall
2020-11-22 16:36:43 +00:00
parent e35d0579c8
commit 9dbf60e3df
15 changed files with 145 additions and 115 deletions
+4 -2
View File
@@ -121,10 +121,12 @@ window.toClipboard = (str: string): void => {
function login(username: string, password: string, modal: boolean, button?: HTMLButtonElement, run?: (arg0: number) => void): void {
const req = new XMLHttpRequest();
req.responseType = 'json';
let url = "/token/login";
let url = window.URLBase;
const refresh = (username == "" && password == "");
if (refresh) {
url = "/token/refresh";
url += "/token/refresh";
} else {
url += "/token/login";
}
req.open("GET", url, true);
if (!refresh) {
+3 -3
View File
@@ -46,7 +46,7 @@ export const addAttr = (el: HTMLElement, attr: string): void => el.classList.add
export const _get = (url: string, data: Object, onreadystatechange: () => void): void => {
let req = new XMLHttpRequest();
req.open("GET", url, true);
req.open("GET", window.URLBase + url, true);
req.responseType = 'json';
req.setRequestHeader("Authorization", "Bearer " + window.token);
req.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
@@ -56,7 +56,7 @@ export const _get = (url: string, data: Object, onreadystatechange: () => void):
export const _post = (url: string, data: Object, onreadystatechange: () => void, response?: boolean): void => {
let req = new XMLHttpRequest();
req.open("POST", url, true);
req.open("POST", window.URLBase + url, true);
if (response) {
req.responseType = 'json';
}
@@ -68,7 +68,7 @@ export const _post = (url: string, data: Object, onreadystatechange: () => void,
export function _delete(url: string, data: Object, onreadystatechange: () => void): void {
let req = new XMLHttpRequest();
req.open("DELETE", url, true);
req.open("DELETE", window.URLBase + url, true);
req.setRequestHeader("Authorization", "Bearer " + window.token);
req.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
req.onreadystatechange = onreadystatechange;
+1
View File
@@ -14,6 +14,7 @@ declare interface Window {
bsVersion: number;
bs5: boolean;
BS: Bootstrap;
URLBase: string;
Modals: BSModals;
cssFile: string;
availableProfiles: Array<any>;