aboutsummaryrefslogtreecommitdiff
path: root/174bg/manager
diff options
context:
space:
mode:
authorAlex Pooley (@zuedev) <zuedev@gmail.com>2026-05-31 09:39:08 +0100
committerAlex Pooley (@zuedev) <zuedev@gmail.com>2026-05-31 09:39:08 +0100
commit780787ca768fc534adfa702871229018da93a960 (patch)
treed9311ac19f986e07f13676c2c75fe64a7901ee40 /174bg/manager
parent04802b1566f741154e42961f6ce1a118f7756645 (diff)
downloadunnamed-group-780787ca768fc534adfa702871229018da93a960.tar
unnamed-group-780787ca768fc534adfa702871229018da93a960.tar.gz
unnamed-group-780787ca768fc534adfa702871229018da93a960.tar.bz2
unnamed-group-780787ca768fc534adfa702871229018da93a960.tar.xz
unnamed-group-780787ca768fc534adfa702871229018da93a960.zip
refactor authentication UI initialization for improved readability and maintainability
Diffstat (limited to '174bg/manager')
-rw-r--r--174bg/manager/public/index.html33
1 files changed, 17 insertions, 16 deletions
diff --git a/174bg/manager/public/index.html b/174bg/manager/public/index.html
index ba25c42..e18dfee 100644
--- a/174bg/manager/public/index.html
+++ b/174bg/manager/public/index.html
@@ -76,6 +76,8 @@
avatarEl.alt = name;
avatarEl.hidden = false;
} else {
+ avatarEl.removeAttribute("src");
+ avatarEl.alt = "";
avatarEl.hidden = true;
}
}
@@ -128,7 +130,9 @@
for (const { id, field } of REQUIRED_INFO_FIELDS) {
const span = document.getElementById(id);
const value = record[field];
- if (value) {
+ // Treat only null/undefined/empty-string as missing so legitimately
+ // falsy values (e.g. Rank_Number 0, joined_rsi_org false) still show.
+ if (value != null && value !== "") {
span.textContent = value;
span.style.color = "";
} else {
@@ -175,10 +179,9 @@
}
}
- // Role options are fetched from the collection schema after auth
let ROLES = [];
- async function fetchRoles() {
+ function fetchRoles() {
ROLES = [
{
branch: "Naval",
@@ -466,7 +469,6 @@
expand: "sender,recipient",
sort: "-created",
requestKey: null,
- cache: "no-store",
});
} catch (err) {
console.error("Failed to load ledger:", err);
@@ -536,6 +538,15 @@
const anonymousSection = document.getElementById("anonymous");
const authedSection = document.getElementById("authed");
+ function initAuthedUI() {
+ fetchRoles();
+ buildRolesSection();
+ populateWelcome();
+ populateRequiredInfo();
+ loadRoles();
+ loadLedger();
+ }
+
function updateAuthUI() {
const loggedIn = pb.authStore.isValid;
anonymousSection.style.display = loggedIn ? "none" : "";
@@ -580,13 +591,8 @@
"color:green; background:#dfd; border:1px solid #080; border-radius:4px; padding:0.5rem";
oauthStatus.textContent = "✅ Login successful!";
window.history.replaceState({}, "", window.location.pathname);
- await fetchRoles();
- buildRolesSection();
updateAuthUI();
- populateWelcome();
- populateRequiredInfo();
- loadRoles();
- loadLedger();
+ initAuthedUI();
} catch (err) {
console.error("OAuth callback failed:", err);
const detail = [
@@ -609,12 +615,7 @@
updateAuthUI();
if (pb.authStore.isValid) {
- await fetchRoles();
- buildRolesSection();
- populateWelcome();
- populateRequiredInfo();
- loadRoles();
- loadLedger();
+ initAuthedUI();
}
loginBtn.addEventListener("click", async () => {