setup: show internal and external links on finish

internal generated from host, port and url_base, external is just
jfa_url. Both are shown (if jfa_url is set).
This commit is contained in:
Harvey Tindall
2025-05-15 15:08:32 +01:00
parent eab33d9f6d
commit 16c5420c6f
4 changed files with 46 additions and 11 deletions

View File

@@ -557,12 +557,13 @@
<div class="card lg:container sectioned ~neutral @low unfocused">
<section class="section flex flex-col gap-2 justify-center items-center">
<span class="heading">{{ .lang.EndPage.finished }}</span>
<p class="content text-center">{{ .lang.EndPage.restartMessage }} {{ .lang.EndPage.urlChangedNotice }}</p>
<p class="content text-center">{{ .lang.EndPage.moreFeatures }} {{ .lang.EndPage.restartReload }} {{ .lang.EndPage.ifFailedLoad }}</p>
</section>
<section class="section w-full ~neutral footer flex flex-row justify-center items-center gap-2">
<span class="button ~neutral @low back">{{ .lang.Strings.back }}</span>
<span class="button ~urge @low" id="restart">{{ .lang.Strings.submit }}</span>
<span class="button ~urge @low unfocused" id="refresh">{{ .lang.EndPage.refreshPage }}</span>
<a class="button ~urge @low flex flex-col gap-0.5 unfocused" id="refresh-internal"></a>
<a class="button ~urge @low flex flex-col gap-0.5 unfocused" id="refresh-external"></a>
</div>
</div>
</div>

View File

@@ -41,7 +41,9 @@
"delete": "Delete",
"myAccount": "My Account",
"referrals": "Referrals",
"inviteRemainingUses": "Remaining uses"
"inviteRemainingUses": "Remaining uses",
"internal": "Internal",
"external": "External"
},
"notifications": {
"errorLoginBlank": "The username and/or password were left blank.",

View File

@@ -33,8 +33,9 @@
},
"endPage": {
"finished": "Finished!",
"restartMessage": "Features like Discord/Telegram/Matrix bots, custom Markdown messages, and a user-accessible \"My Account\" page can be found in Settings, so make sure to give it a browse. Click below to restart, then refresh the page.",
"urlChangedNotice": "If you've changed the host, port, subfolder etc. that jfa-go is hosted on, check the URL is right.",
"moreFeatures": "Tons more features like Discord/Telegram/Matrix bots and custom Markdown messages can be found in Settings, so make sure to give it a browse.",
"restartReload": "Click below to restart, then access jfa-go at one of the given internal/external URLs.",
"ifFailedLoad": "If it doesn't load, check the application's logs for any clues as to why.",
"refreshPage": "Refresh"
},
"language": {

View File

@@ -365,6 +365,33 @@ const checkTheme = () => {
settings["ui"]["theme"].onchange = checkTheme;
checkTheme();
const fixFullURL = (v: string): string => {
if (!(v.startsWith("http://")) && !(v.startsWith("https://"))) {
v = "http://" + v;
}
return v;
};
const formatSubpath = (v: string): string => {
if (v == "/") return "";
if (v.charAt(-1) == "/") { v = v.slice(0, -1); }
return v;
}
const constructNewURLs = (): string[] => {
let local = settings["ui"]["host"].value + ":" + settings["ui"]["port"].value;
if (settings["ui"]["url_base"].value != "") {
local += formatSubpath(settings["ui"]["url_base"].value);
}
local = fixFullURL(local);
let remote = settings["ui"]["jfa_url"].value;
if (remote == "") {
return [local];
}
remote = fixFullURL(remote);
return [local, remote];
}
const restartButton = document.getElementById("restart") as HTMLSpanElement;
const serialize = () => {
toggleLoader(restartButton);
@@ -409,12 +436,16 @@ const serialize = () => {
}
restartButton.parentElement.querySelector("span.back").classList.add("unfocused");
restartButton.classList.add("unfocused");
const refresh = document.getElementById("refresh") as HTMLSpanElement;
refresh.classList.remove("unfocused");
refresh.onclick = () => {
let host = window.location.href.split("#")[0].split("?")[0] + settings["ui"]["url_base"].value;
window.location.href = host;
};
const refreshURLs = constructNewURLs();
const refreshButtons = [document.getElementById("refresh-internal") as HTMLAnchorElement, document.getElementById("refresh-external") as HTMLAnchorElement];
["internal", "external"].forEach((urltype, i) => {
const button = refreshButtons[i];
button.classList.remove("unfocused");
button.href = refreshURLs[i];
button.innerHTML = `<span>${urltype.charAt(0).toUpperCase() + urltype.slice(1)}:</span><i class="italic underline">${button.href}</i>`;
// skip external if it isn't set
if (refreshURLs.length == 1) return;
});
}
}, true, (req: XMLHttpRequest) => {
if (req.status == 0) {