userpage: use form langfile, move login strings to common

login-related stuff was moved into common using the langmover script, so
that the user page doesn't have to use the admin language files.
This commit is contained in:
Harvey Tindall
2023-06-17 12:48:28 +01:00
parent 96c62f556b
commit d3c5feaf1b
131 changed files with 569 additions and 474 deletions
+17 -4
View File
@@ -4,6 +4,13 @@ import { Modal } from "./modules/modal.js";
import { _get, _post, notificationBox, whichAnimationEvent } from "./modules/common.js";
import { Login } from "./modules/login.js";
interface userWindow extends Window {
jellyfinID: string;
username: string;
}
declare var window: userWindow;
const theme = new ThemeManager(document.getElementById("button-theme"));
window.lang = new lang(window.langFile as LangFile);
@@ -22,14 +29,20 @@ window.modals = {} as Modals;
window.notifications = new notificationBox(document.getElementById('notification-box') as HTMLDivElement, 5);
var rootCard = document.getElementById("card-user");
const login = new Login(window.modals.login as Modal, "/my/");
login.onLogin = () => {
console.log("Logged in.");
document.getElementById("card-user").textContent = "Logged In!";
_get("/my/hello", null, (req: XMLHttpRequest) => {
_get("/my/details", null, (req: XMLHttpRequest) => {
if (req.readyState == 4) {
const card = document.getElementById("card-user");
card.textContent = card.textContent + " got response " + req.response["response"];
if (req.status != 200) {
window.notifications.customError("myDetailsError", req.response["error"]);
return;
}
window.jellyfinID = req.response["id"];
window.username = req.response["username"];
rootCard.querySelector(".heading").textContent = window.lang.strings("welcomeUser").replace("{user}", window.username);
}
});
};