From dc6b1589d33a9361dbe35e0e9d8698171081f3f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Tue, 6 Feb 2024 20:00:32 +0100 Subject: [PATCH] Fix dashboard script --- assets/script.js | 15 +++++++++++---- templates/dashboard.html | 16 ---------------- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/assets/script.js b/assets/script.js index 7089679..ca32b4d 100644 --- a/assets/script.js +++ b/assets/script.js @@ -33,6 +33,10 @@ function handleResponse(data, successMessage, failureMessage) { }, 3000); } +async function showDashboardGreeting() { + document.getElementById("welcomeMsg").innerText = `Ahoj, ${UserInfo.FirstName}.`; +} + async function doAction(url, requestData, successMessage, failureMessage, silent = false) { try { const params = new URLSearchParams(); @@ -63,8 +67,8 @@ async function doAction(url, requestData, successMessage, failureMessage, silent } function handlePageResponse(data) { - const navbar = document.getElementById("navbar"); - const pageArea = document.getElementById("pagearea"); + const navbar = document.getElementById("navbar_container"); + const pageArea = document.getElementById("page_container"); if (data.Navigation) { navbar.innerHTML = data.Navigation; @@ -162,13 +166,16 @@ function onPageLoad(){ let currentPage = localStorage.getItem("currentPage"); if(currentSite === "home" && currentPage === "settings"){ if(document.getElementById("user-settings")){ - getUserInfo(); + populateUserInfoFields(UserInfo); } if(document.getElementById("admin-settings")){ listActivationCodes(); listUsers(); } } + if(currentSite === "home" && currentPage === "account") { + showDashboardGreeting(); + } } function navigateTo(site, page){ @@ -217,6 +224,7 @@ function login() { doLogin(email, password); refreshNavbar(); softReload(); + getUserInfo(); } async function doLogin(email, password) { @@ -320,7 +328,6 @@ function getUserInfo() { const result = doAction('/account', data, "User info retrieved Successfully!", "User info retrieval failed.", true); if (result && result.Status === "Success") { - populateUserInfoFields(result.UserInfo); UserInfo = result.UserInfo; } } diff --git a/templates/dashboard.html b/templates/dashboard.html index 80b1e75..f93b64c 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -1,19 +1,3 @@ - - -

\ No newline at end of file