add option to auto redirect to jellyfin (or given link)

if enabled (General>Auto redirect on success), the user will not have to
    click "continue" on the form or creation success page and will
    insted be redirected. For #242.
This commit is contained in:
Harvey Tindall
2023-02-02 10:34:22 +00:00
parent de6bc02ad8
commit eb85ee4d35
4 changed files with 55 additions and 38 deletions
+8 -2
View File
@@ -10,7 +10,8 @@ interface formWindow extends Window {
telegramModal: Modal;
discordModal: Modal;
matrixModal: Modal;
confirmationModal: Modal
confirmationModal: Modal;
redirectToJellyfin: boolean;
code: string;
messages: { [key: string]: string };
confirmation: boolean;
@@ -412,7 +413,12 @@ const create = (event: SubmitEvent) => {
if (!vals[type]) { valid = false; }
}
if (req.status == 200 && valid) {
window.successModal.show();
if (window.redirectToJellyfin == true) {
const url = ((document.getElementById("modal-success") as HTMLDivElement).querySelector("a.submit") as HTMLAnchorElement).href;
window.location.href = url;
} else {
window.successModal.show();
}
} else {
submitSpan.classList.add("~critical");
submitSpan.classList.remove("~urge");