mirror of
https://github.com/hrfee/jfa-go.git
synced 2026-01-18 16:47:42 +01:00
admin: change path behaviour for the billionth time
URLs are made with app.ExternalURI (now included in window.pages), which itself should include Base. Also fixed the subfolder being removed from the url after login.
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
<script>
|
||||
window.pages = {
|
||||
"Base": "{{ .pages.Base }}",
|
||||
"TrueBase": "{{ .pages.TrueBase }}",
|
||||
"ExternalURI": "{{ .pages.ExternalURI }}",
|
||||
"Current": "{{ .pages.Current }}",
|
||||
"Admin": "{{ .pages.Admin }}",
|
||||
"MyAccount": "{{ .pages.MyAccount }}",
|
||||
|
||||
@@ -485,5 +485,8 @@ type PagePaths struct {
|
||||
type PagePathsDTO struct {
|
||||
PagePaths
|
||||
// The subdirectory this bit of the app is hosted on (e.g. admin is usually on "/", myacc is usually on "/my/account")
|
||||
Current string `json:"Current"`
|
||||
Current string `json:"Current"`
|
||||
ExternalURI string `json:"ExternalURI"`
|
||||
// The subdirectory the app is meant to be accessed from ("Reverse proxy subfolder")
|
||||
TrueBase string `json:"TrueBase"`
|
||||
}
|
||||
|
||||
@@ -174,12 +174,12 @@ const defaultTab = tabs[0];
|
||||
window.tabs = new Tabs();
|
||||
|
||||
for (let tab of tabs) {
|
||||
window.tabs.addTab(tab.id, window.pages.Admin + "/" + tab.url, null, tab.reloader, tab.unloader || null);
|
||||
window.tabs.addTab(tab.id, window.pages.Base + window.pages.Admin + "/" + tab.url, null, tab.reloader, tab.unloader || null);
|
||||
}
|
||||
|
||||
let matchedTab = false
|
||||
for (const tab of tabs) {
|
||||
if (window.location.pathname.startsWith(window.pages.Base + window.pages.Current + "/" + tab.url)) {
|
||||
if (window.location.pathname.startsWith(window.pages.Current + "/" + tab.url)) {
|
||||
window.tabs.switch(tab.url, true);
|
||||
matchedTab = true;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,12 @@ import { reloadProfileNames } from "../modules/profiles.js";
|
||||
|
||||
declare var window: GlobalWindow;
|
||||
|
||||
export const generateCodeLink = (code: string): string => {
|
||||
// let codeLink = window.pages.Base + window.pages.Form + "/" + code;
|
||||
let codeLink = window.pages.ExternalURI + window.pages.Form + "/" + code;
|
||||
return codeLink;
|
||||
}
|
||||
|
||||
class DOMInvite implements Invite {
|
||||
updateNotify = (checkbox: HTMLInputElement) => {
|
||||
let state: { [code: string]: { [type: string]: boolean } } = {};
|
||||
@@ -63,7 +69,7 @@ class DOMInvite implements Invite {
|
||||
get code(): string { return this._code; }
|
||||
set code(code: string) {
|
||||
this._code = code;
|
||||
this._codeLink = window.pages.Base + window.pages.Form + "/" + code;
|
||||
this._codeLink = generateCodeLink(code);
|
||||
const linkEl = this._codeArea.querySelector("a") as HTMLAnchorElement;
|
||||
if (this.label == "") {
|
||||
linkEl.textContent = code.replace(/-/g, '-');
|
||||
|
||||
@@ -13,14 +13,18 @@ interface ArrayConstructor {
|
||||
}
|
||||
|
||||
declare interface PagePaths {
|
||||
// The base subfolder the app is hosted on.
|
||||
// The base subfolder the app is being accessed from.
|
||||
Base: string;
|
||||
// The base subfolder the app is meant to be accessed from ("Reverse proxy subfolder")
|
||||
TrueBase: string;
|
||||
// The subdirectory this bit of the app is hosted on (e.g. admin is usually on "/", myacc is usually on "/my/account")
|
||||
Current: string;
|
||||
// Those for other pages
|
||||
Admin: string;
|
||||
MyAccount: string;
|
||||
Form: string;
|
||||
// The "External jfa-go URL"
|
||||
ExternalURI: string;
|
||||
}
|
||||
|
||||
declare interface GlobalWindow extends Window {
|
||||
|
||||
16
ts/user.ts
16
ts/user.ts
@@ -6,6 +6,7 @@ import { Login } from "./modules/login.js";
|
||||
import { Discord, Telegram, Matrix, ServiceConfiguration, MatrixConfiguration } from "./modules/account-linking.js";
|
||||
import { Validator, ValidatorConf, ValidatorRespDTO } from "./modules/validator.js";
|
||||
import { PageManager } from "./modules/pages.js";
|
||||
import { generateCodeLink } from "./modules/invites.js";
|
||||
|
||||
interface userWindow extends GlobalWindow {
|
||||
jellyfinID: string;
|
||||
@@ -305,14 +306,15 @@ class ReferralCard {
|
||||
this._code = c;
|
||||
|
||||
|
||||
let u = new URL(window.location.href);
|
||||
const path = window.pages.Base + window.pages.Form + "/" + this._code;
|
||||
|
||||
u.pathname = path;
|
||||
u.hash = "";
|
||||
u.search = "";
|
||||
// let u = new URL(window.location.href);
|
||||
// const path = window.pages.Base + window.pages.Form + "/" + this._code;
|
||||
//
|
||||
// u.pathname = path;
|
||||
// u.hash = "";
|
||||
// u.search = "";
|
||||
|
||||
this._url = u.toString();
|
||||
// this._url = u.toString();
|
||||
this._url = generateCodeLink(this._code);
|
||||
}
|
||||
|
||||
get remaining_uses(): number { return this._remainingUses; }
|
||||
|
||||
Reference in New Issue
Block a user