Header: show the logged-in user with an OIDC / local badge, or (no auth)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
7f053a0fe9
commit
a57531c95f
3 files changed
+25
No files matched your search
+13
@@ -2638,6 +2638,19 @@ renderPeriod();
|
|||||||
fetch('/auth/me').then((res) => (res.ok ? res.json() : null)).then((me) => {
|
fetch('/auth/me').then((res) => (res.ok ? res.json() : null)).then((me) => {
|
||||||
if (!me) return;
|
if (!me) return;
|
||||||
if (me.mode === 'none' && store.get('authWarnHidden') !== '1') $('#authWarn').hidden = false;
|
if (me.mode === 'none' && store.get('authWarnHidden') !== '1') $('#authWarn').hidden = false;
|
||||||
|
const who = $('#whoami');
|
||||||
|
if (me.mode === 'none') {
|
||||||
|
who.classList.add('none');
|
||||||
|
who.querySelector('.who-name').textContent = '(no auth)';
|
||||||
|
who.hidden = false;
|
||||||
|
} else if (me.user) {
|
||||||
|
who.querySelector('.who-name').textContent = me.user;
|
||||||
|
who.title = me.user;
|
||||||
|
const badge = who.querySelector('.who-badge');
|
||||||
|
badge.textContent = me.mode === 'oidc' ? 'OIDC' : 'local';
|
||||||
|
badge.classList.add(me.mode);
|
||||||
|
who.hidden = false;
|
||||||
|
}
|
||||||
if (me.role === 'viewer') {
|
if (me.role === 'viewer') {
|
||||||
document.body.classList.add('read-only');
|
document.body.classList.add('read-only');
|
||||||
for (const p of document.querySelectorAll('[data-panel="filters"], [data-panel="sources"], [data-panel="data"]')) {
|
for (const p of document.querySelectorAll('[data-panel="filters"], [data-panel="sources"], [data-panel="data"]')) {
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
<svg class="sun" viewBox="0 0 24 24"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>
|
<svg class="sun" viewBox="0 0 24 24"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>
|
||||||
<svg class="moon" viewBox="0 0 24 24"><path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/></svg>
|
<svg class="moon" viewBox="0 0 24 24"><path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/></svg>
|
||||||
</button>
|
</button>
|
||||||
|
<span id="whoami" class="whoami" hidden><span class="who-name"></span><span class="who-badge"></span></span>
|
||||||
<a id="logoutBtn" class="icon-btn" href="/auth/logout" hidden data-i18n-title="logout" data-i18n-aria="logout">
|
<a id="logoutBtn" class="icon-btn" href="/auth/logout" hidden data-i18n-title="logout" data-i18n-aria="logout">
|
||||||
<!-- Log out icon (Lucide "log-out", ISC license) -->
|
<!-- Log out icon (Lucide "log-out", ISC license) -->
|
||||||
<svg viewBox="0 0 24 24"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><path d="m16 17 5-5-5-5"/><path d="M21 12H9"/></svg>
|
<svg viewBox="0 0 24 24"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><path d="m16 17 5-5-5-5"/><path d="M21 12H9"/></svg>
|
||||||
|
|||||||
@@ -189,6 +189,16 @@ svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round;
|
|||||||
.chip.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
|
.chip.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
|
||||||
|
|
||||||
.actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
|
.actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
|
||||||
|
/* Logged-in user, with how they logged in (OIDC / local) */
|
||||||
|
.whoami { display: flex; align-items: center; gap: 6px; min-width: 0; margin-left: 6px; font-size: 13px; color: var(--muted); }
|
||||||
|
.whoami .who-name { font-weight: 600; color: var(--text); max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||||
|
.whoami .who-badge {
|
||||||
|
flex: none; border: 1px solid var(--border); border-radius: 6px;
|
||||||
|
padding: 1px 6px; font-size: 10.5px; font-weight: 650; letter-spacing: .02em;
|
||||||
|
}
|
||||||
|
.whoami .who-badge.oidc { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
|
||||||
|
.whoami .who-badge:empty { display: none; }
|
||||||
|
.whoami.none .who-name { font-weight: 400; color: var(--muted); }
|
||||||
.icon-btn {
|
.icon-btn {
|
||||||
width: 36px; height: 36px; display: grid; place-items: center;
|
width: 36px; height: 36px; display: grid; place-items: center;
|
||||||
border: 1px solid transparent; background: transparent; border-radius: 9px; color: var(--muted);
|
border: 1px solid transparent; background: transparent; border-radius: 9px; color: var(--muted);
|
||||||
@@ -750,6 +760,7 @@ input.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2
|
|||||||
.topbar { flex-wrap: wrap; padding: 8px 16px; gap: 8px 10px; }
|
.topbar { flex-wrap: wrap; padding: 8px 16px; gap: 8px 10px; }
|
||||||
.search { order: 3; flex-basis: 100%; max-width: none; }
|
.search { order: 3; flex-basis: 100%; max-width: none; }
|
||||||
.live .lbl { display: none; }
|
.live .lbl { display: none; }
|
||||||
|
.whoami .who-name { max-width: 12ch; }
|
||||||
.filters { padding: 10px 16px 6px; }
|
.filters { padding: 10px 16px 6px; }
|
||||||
.filters select { flex: 1 1 calc(50% - 8px); max-width: none; min-width: 0; }
|
.filters select { flex: 1 1 calc(50% - 8px); max-width: none; min-width: 0; }
|
||||||
.view-mode { flex: 1 1 100%; }
|
.view-mode { flex: 1 1 100%; }
|
||||||
|
|||||||
Reference in new issue
Block a user