Eyecandy on admin page and fix of functionality on that page
Build LinkLog Development Image / development-image (push) Successful in 11s
Build LinkLog Development Image / development-image (push) Successful in 11s
This commit is contained in:
@@ -12,7 +12,7 @@ const smtpForm = document.querySelector('#smtp-form');
|
||||
const smtpTestButton = document.querySelector('#smtp-test-button');
|
||||
const smtpStatus = document.querySelector('#smtp-status');
|
||||
const themesForm = document.querySelector('#themes-form');
|
||||
const themeOptions = document.querySelector('#theme-options');
|
||||
const themeOptions = document.querySelector('#admin-theme-options');
|
||||
const themeStatus = document.querySelector('#theme-status');
|
||||
let smtpNextAllowedAt = null;
|
||||
let smtpTimerHandle = null;
|
||||
@@ -259,9 +259,51 @@ async function loadUsers() {
|
||||
renderUsers(await response.json());
|
||||
}
|
||||
|
||||
function initPanelToggles() {
|
||||
const panels = document.querySelectorAll('#admin-controls .settings-panel');
|
||||
panels.forEach((panel) => {
|
||||
panel.classList.add('minimized');
|
||||
const h2 = panel.querySelector('h2');
|
||||
if (!h2) return;
|
||||
let btn = h2.querySelector('.panel-toggle-btn');
|
||||
if (!btn) {
|
||||
const titleText = h2.textContent.trim();
|
||||
h2.replaceChildren();
|
||||
btn = document.createElement('button');
|
||||
btn.type = 'button';
|
||||
btn.className = 'panel-toggle-btn';
|
||||
btn.setAttribute('aria-expanded', 'false');
|
||||
const textSpan = document.createElement('span');
|
||||
textSpan.textContent = titleText;
|
||||
const iconSpan = document.createElement('span');
|
||||
iconSpan.className = 'panel-toggle-icon';
|
||||
iconSpan.setAttribute('aria-hidden', 'true');
|
||||
iconSpan.textContent = '▼';
|
||||
btn.append(textSpan, iconSpan);
|
||||
h2.appendChild(btn);
|
||||
} else {
|
||||
btn.setAttribute('aria-expanded', 'false');
|
||||
}
|
||||
|
||||
if (h2.dataset.initialized) return;
|
||||
h2.dataset.initialized = 'true';
|
||||
|
||||
h2.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
const isMinimized = panel.classList.toggle('minimized');
|
||||
if (btn) {
|
||||
btn.setAttribute('aria-expanded', String(!isMinimized));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function showAdminState(isAdmin) {
|
||||
adminControls.classList.toggle('hidden', !isAdmin);
|
||||
adminAuthNotice.classList.toggle('hidden', isAdmin);
|
||||
if (isAdmin) {
|
||||
initPanelToggles();
|
||||
}
|
||||
}
|
||||
|
||||
function showSignedOutState() {
|
||||
@@ -446,4 +488,7 @@ loadAdminState().catch((error) => {
|
||||
smtpForm.reset();
|
||||
themesForm.reset();
|
||||
});
|
||||
|
||||
document.addEventListener('DOMContentLoaded', initPanelToggles);
|
||||
initPanelToggles();
|
||||
})();
|
||||
|
||||
@@ -310,6 +310,48 @@ passwordForm.addEventListener('submit', async (event) => {
|
||||
if (response.ok) passwordForm.reset();
|
||||
});
|
||||
|
||||
function initPanelToggles() {
|
||||
const panels = document.querySelectorAll('.settings-panel');
|
||||
panels.forEach((panel) => {
|
||||
panel.classList.add('minimized');
|
||||
const h2 = panel.querySelector('h2');
|
||||
if (!h2) return;
|
||||
let btn = h2.querySelector('.panel-toggle-btn');
|
||||
if (!btn) {
|
||||
const titleText = h2.textContent.trim();
|
||||
h2.replaceChildren();
|
||||
btn = document.createElement('button');
|
||||
btn.type = 'button';
|
||||
btn.className = 'panel-toggle-btn';
|
||||
btn.setAttribute('aria-expanded', 'false');
|
||||
const textSpan = document.createElement('span');
|
||||
textSpan.textContent = titleText;
|
||||
const iconSpan = document.createElement('span');
|
||||
iconSpan.className = 'panel-toggle-icon';
|
||||
iconSpan.setAttribute('aria-hidden', 'true');
|
||||
iconSpan.textContent = '▼';
|
||||
btn.append(textSpan, iconSpan);
|
||||
h2.appendChild(btn);
|
||||
} else {
|
||||
btn.setAttribute('aria-expanded', 'false');
|
||||
}
|
||||
|
||||
if (h2.dataset.initialized) return;
|
||||
h2.dataset.initialized = 'true';
|
||||
|
||||
h2.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
const isMinimized = panel.classList.toggle('minimized');
|
||||
if (btn) {
|
||||
btn.setAttribute('aria-expanded', String(!isMinimized));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', initPanelToggles);
|
||||
initPanelToggles();
|
||||
|
||||
Promise.all([loadProfile(), loadMastodonConfig(), loadOtp(), loadEmailAddresses()]).catch((error) => {
|
||||
setStatus('#profile-status', accessToken ? error.message : 'Please sign in first.', true);
|
||||
});
|
||||
|
||||
@@ -451,6 +451,108 @@ main.container {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
#admin-controls {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.settings-panel + .settings-panel {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.settings-panel h2 {
|
||||
margin: 0 0 12px;
|
||||
padding: 10px 14px;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s ease, margin 0.2s ease;
|
||||
}
|
||||
|
||||
.settings-panel h2:hover {
|
||||
filter: brightness(1.08);
|
||||
}
|
||||
|
||||
.settings-panel:nth-of-type(5n+1) h2 {
|
||||
color: var(--mauve);
|
||||
background: var(--surface-1);
|
||||
background: color-mix(in srgb, var(--mauve) 14%, transparent);
|
||||
border-left: 4px solid var(--mauve);
|
||||
}
|
||||
|
||||
.settings-panel:nth-of-type(5n+2) h2 {
|
||||
color: var(--teal);
|
||||
background: var(--surface-1);
|
||||
background: color-mix(in srgb, var(--teal) 14%, transparent);
|
||||
border-left: 4px solid var(--teal);
|
||||
}
|
||||
|
||||
.settings-panel:nth-of-type(5n+3) h2 {
|
||||
color: var(--peach);
|
||||
background: var(--surface-1);
|
||||
background: color-mix(in srgb, var(--peach) 14%, transparent);
|
||||
border-left: 4px solid var(--peach);
|
||||
}
|
||||
|
||||
.settings-panel:nth-of-type(5n+4) h2 {
|
||||
color: var(--blue);
|
||||
background: var(--surface-1);
|
||||
background: color-mix(in srgb, var(--blue) 14%, transparent);
|
||||
border-left: 4px solid var(--blue);
|
||||
}
|
||||
|
||||
.settings-panel:nth-of-type(5n+5) h2 {
|
||||
color: var(--lavender);
|
||||
background: var(--surface-1);
|
||||
background: color-mix(in srgb, var(--lavender) 14%, transparent);
|
||||
border-left: 4px solid var(--lavender);
|
||||
}
|
||||
|
||||
.settings-panel.minimized h2 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.panel-toggle-btn {
|
||||
display: flex !important;
|
||||
align-items: center !important;
|
||||
justify-content: space-between !important;
|
||||
width: 100% !important;
|
||||
min-width: 0 !important;
|
||||
padding: 0 !important;
|
||||
border: none !important;
|
||||
background: transparent !important;
|
||||
color: inherit !important;
|
||||
font: inherit !important;
|
||||
font-size: 1rem !important;
|
||||
font-weight: inherit !important;
|
||||
cursor: pointer !important;
|
||||
text-align: left !important;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
.panel-toggle-btn > * {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.panel-toggle-btn:focus-visible {
|
||||
outline: 2px solid var(--lavender) !important;
|
||||
outline-offset: 2px !important;
|
||||
}
|
||||
|
||||
.panel-toggle-icon {
|
||||
font-size: 0.75rem;
|
||||
transition: transform 0.2s ease;
|
||||
margin-left: 8px;
|
||||
color: var(--subtext);
|
||||
}
|
||||
|
||||
.settings-panel.minimized .panel-toggle-icon {
|
||||
transform: rotate(-90deg);
|
||||
}
|
||||
|
||||
.settings-panel.minimized > *:not(h2) {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.toolbar label,
|
||||
.settings-panel label {
|
||||
display: grid;
|
||||
|
||||
@@ -44,8 +44,13 @@
|
||||
<main class="container">
|
||||
<p id="admin-auth-notice" class="auth-notice hidden"></p>
|
||||
<div id="admin-controls" class="hidden">
|
||||
<section class="link-item settings-panel">
|
||||
<h2>Users</h2>
|
||||
<section class="link-item settings-panel minimized">
|
||||
<h2>
|
||||
<button type="button" class="panel-toggle-btn" aria-expanded="false">
|
||||
<span>Users</span>
|
||||
<span class="panel-toggle-icon" aria-hidden="true">▼</span>
|
||||
</button>
|
||||
</h2>
|
||||
<form id="user-form">
|
||||
<label>
|
||||
Username
|
||||
@@ -69,16 +74,31 @@
|
||||
<div id="user-list" class="plugin-list" aria-live="polite">Loading users...</div>
|
||||
</section>
|
||||
|
||||
<section class="link-item settings-panel">
|
||||
<h2>Plugins</h2>
|
||||
<section class="link-item settings-panel minimized">
|
||||
<h2>
|
||||
<button type="button" class="panel-toggle-btn" aria-expanded="false">
|
||||
<span>Plugins</span>
|
||||
<span class="panel-toggle-icon" aria-hidden="true">▼</span>
|
||||
</button>
|
||||
</h2>
|
||||
<div id="plugin-list" class="plugin-list" aria-live="polite">Loading plugins...</div>
|
||||
</section>
|
||||
<section class="link-item settings-panel">
|
||||
<h2>Labels</h2>
|
||||
<section class="link-item settings-panel minimized">
|
||||
<h2>
|
||||
<button type="button" class="panel-toggle-btn" aria-expanded="false">
|
||||
<span>Labels</span>
|
||||
<span class="panel-toggle-icon" aria-hidden="true">▼</span>
|
||||
</button>
|
||||
</h2>
|
||||
<div id="admin-label-list" class="plugin-list" aria-live="polite">Loading labels...</div>
|
||||
</section>
|
||||
<section class="link-item settings-panel">
|
||||
<h2>SMTP settings</h2>
|
||||
<section class="link-item settings-panel minimized">
|
||||
<h2>
|
||||
<button type="button" class="panel-toggle-btn" aria-expanded="false">
|
||||
<span>SMTP settings</span>
|
||||
<span class="panel-toggle-icon" aria-hidden="true">▼</span>
|
||||
</button>
|
||||
</h2>
|
||||
<form id="smtp-form">
|
||||
<label>
|
||||
SMTP host
|
||||
@@ -109,11 +129,16 @@
|
||||
|
||||
</form>
|
||||
</section>
|
||||
<section class="link-item settings-panel">
|
||||
<h2>Available themes</h2>
|
||||
<section class="link-item settings-panel minimized">
|
||||
<h2>
|
||||
<button type="button" class="panel-toggle-btn" aria-expanded="false">
|
||||
<span>Available themes</span>
|
||||
<span class="panel-toggle-icon" aria-hidden="true">▼</span>
|
||||
</button>
|
||||
</h2>
|
||||
<p>Choose the themes visitors may use.</p>
|
||||
<form id="themes-form">
|
||||
<div id="theme-options" class="theme-options" aria-live="polite">Loading themes...</div>
|
||||
<div id="admin-theme-options" class="theme-options" aria-live="polite">Loading themes...</div>
|
||||
<button type="submit">Save themes</button>
|
||||
<p id="theme-status" class="status" role="status"></p>
|
||||
</form>
|
||||
@@ -124,6 +149,6 @@
|
||||
<script src="/static/auth-header.js?v=3"></script>
|
||||
<script src="/static/logout.js?v=2"></script>
|
||||
<script src="/static/theme.js?v=1"></script>
|
||||
<script src="/static/admin.js?v=5"></script>
|
||||
<script src="/static/admin.js?v=7"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -43,8 +43,13 @@
|
||||
</header>
|
||||
|
||||
<main class="container">
|
||||
<section class="link-item settings-panel">
|
||||
<h2>Profile Settings</h2>
|
||||
<section class="link-item settings-panel minimized">
|
||||
<h2>
|
||||
<button type="button" class="panel-toggle-btn" aria-expanded="false">
|
||||
<span>Profile Settings</span>
|
||||
<span class="panel-toggle-icon" aria-hidden="true">▼</span>
|
||||
</button>
|
||||
</h2>
|
||||
<form id="profile-form">
|
||||
<label>
|
||||
Username
|
||||
@@ -69,8 +74,13 @@
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section class="link-item settings-panel">
|
||||
<h2>Email addresses</h2>
|
||||
<section class="link-item settings-panel minimized">
|
||||
<h2>
|
||||
<button type="button" class="panel-toggle-btn" aria-expanded="false">
|
||||
<span>Email addresses</span>
|
||||
<span class="panel-toggle-icon" aria-hidden="true">▼</span>
|
||||
</button>
|
||||
</h2>
|
||||
<div id="email-address-list" class="email-address-list" aria-live="polite">Loading email addresses...</div>
|
||||
<form id="additional-email-form">
|
||||
<label>
|
||||
@@ -82,8 +92,13 @@
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section class="link-item settings-panel">
|
||||
<h2>Password</h2>
|
||||
<section class="link-item settings-panel minimized">
|
||||
<h2>
|
||||
<button type="button" class="panel-toggle-btn" aria-expanded="false">
|
||||
<span>Password</span>
|
||||
<span class="panel-toggle-icon" aria-hidden="true">▼</span>
|
||||
</button>
|
||||
</h2>
|
||||
<form id="password-form">
|
||||
<label>
|
||||
Current password
|
||||
@@ -102,8 +117,13 @@
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section class="link-item settings-panel">
|
||||
<h2>One-time password</h2>
|
||||
<section class="link-item settings-panel minimized">
|
||||
<h2>
|
||||
<button type="button" class="panel-toggle-btn" aria-expanded="false">
|
||||
<span>One-time password</span>
|
||||
<span class="panel-toggle-icon" aria-hidden="true">▼</span>
|
||||
</button>
|
||||
</h2>
|
||||
<p>Use an authenticator app to add a second sign-in step.</p>
|
||||
<div id="otp-disabled">
|
||||
<button id="otp-setup" type="button">Set up one-time password</button>
|
||||
@@ -131,8 +151,13 @@
|
||||
<p id="otp-status" class="status" role="status"></p>
|
||||
</section>
|
||||
|
||||
<section class="link-item settings-panel">
|
||||
<h2>Mastodon</h2>
|
||||
<section class="link-item settings-panel minimized">
|
||||
<h2>
|
||||
<button type="button" class="panel-toggle-btn" aria-expanded="false">
|
||||
<span>Mastodon</span>
|
||||
<span class="panel-toggle-icon" aria-hidden="true">▼</span>
|
||||
</button>
|
||||
</h2>
|
||||
<form id="mastodon-form">
|
||||
<label>
|
||||
Mastodon server
|
||||
@@ -155,7 +180,7 @@
|
||||
<script src="/static/auth-header.js?v=3"></script>
|
||||
<script src="/static/logout.js?v=2"></script>
|
||||
<script src="/static/theme.js?v=1"></script>
|
||||
<script src="/static/profile.js?v=5"></script>
|
||||
<script src="/static/profile.js?v=6"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user