Skip to content

Speakr is a personal, self-hosted web application designed for transcribing audio recordings

Python

One header on every page, and no loading-overlay blink

Murtaza Nasir98410d5342b3
diff --git a/src/app.py b/src/app.py
index 4aa1d02a..38da12f7 100644
--- a/src/app.py
+++ b/src/app.py
@@ -713,6 +713,12 @@ _app_version = get_version()
def inject_app_version():
return {'app_version': _app_version}
+def inject_inquire_mode_flag():
+ """The shared header shows the Inquire button on every page."""
+ return {'inquire_mode_enabled': ENABLE_INQUIRE_MODE}
+
+
@app.context_processor
def inject_help_center_link():
"""Optional custom help link in the user menu (#371).
diff --git a/static/js/app.modular.js b/static/js/app.modular.js
index d5002427..bc189816 100644
--- a/static/js/app.modular.js
+++ b/static/js/app.modular.js
@@ -3942,6 +3942,20 @@ document.addEventListener('DOMContentLoaded', async () => {
}
} catch (_) { /* no-op: param parsing/replaceState are best-effort */ }
+ // ?open=shares|appearance: the header on the other pages opens
+ // these main-app dialogs by linking here.
+ let openDialogDeepLink = null;
+ try {
+ const params = new URLSearchParams(window.location.search);
+ const wanted = params.get('open');
+ if (wanted === 'shares' || wanted === 'appearance') {
+ openDialogDeepLink = wanted;
+ params.delete('open');
+ const qs = params.toString();
+ window.history.replaceState({}, '', window.location.pathname + (qs ? '?' + qs : '') + window.location.hash);
+ }
+ } catch (_) { /* best-effort */ }
+
// Deep link to a specific recording: /recordings/<id> (#301).
// Captured before load; selected once recordings are in.
let deepLinkRecordingId = null;
@@ -4024,6 +4038,11 @@ document.addEventListener('DOMContentLoaded', async () => {
// Now open the upload modal. The pending flag (set above)
// prevents the auto-selected recording's selectRecording() from
// closing it once its fetch resolves.
+ if (openDialogDeepLink === 'shares') {
+ sharingComposable.openSharesList();
+ } else if (openDialogDeepLink === 'appearance') {
+ uiComposable.openColorSchemeModal();
+ }
if (wantUploadDeepLink) {
await nextTick();
uiComposable.switchToUploadView();
diff --git a/static/js/global-header.js b/static/js/global-header.js
new file mode 100644
index 00000000..7582601e
--- /dev/null
+++ b/static/js/global-header.js
@@ -0,0 +1,117 @@
+/**
+ * The page header outside the main app (account, admin, group management).
+ *
+ * The controls on the right of the header are one template,
+ * components/header-controls.html, shared with the main app. The main app
+ * renders it inside its own Vue app; this file mounts a small Vue app on
+ * page-header.html that supplies the same names, so every page shows the
+ * same header and menu. Actions that open a dialog only the main app has
+ * (a new recording, the shared transcripts list, the colour scheme) open the
+ * main app with that dialog.
+ */
+
+import { useNotifications } from './modules/composables/notifications.js';
+
+const SCHEMES = ['blue', 'emerald', 'purple', 'rose', 'amber', 'teal'];
+
+function applyTheme(dark) {
+ const root = document.documentElement;
+ root.classList.toggle('dark', dark);
+ SCHEMES.forEach(s => root.classList.remove(`theme-light-${s}`, `theme-dark-${s}`));
+ const scheme = localStorage.getItem('colorScheme') || 'blue';
+ if (scheme !== 'blue') root.classList.add(`theme-${dark ? 'dark' : 'light'}-${scheme}`);
+}
+
+function ensureVue() {
+ if (window.Vue) return Promise.resolve();
+ return new Promise((resolve, reject) => {
+ const script = document.createElement('script');
+ script.src = '/static/vendor/js/vue.global.prod.js';
+ script.onload = resolve;
+ script.onerror = reject;
+ document.head.appendChild(script);
+ });
+}
+
+async function mountGlobalHeader() {
+ const el = document.getElementById('global-header');
+ if (!el || el.dataset.mounted) return;
+ el.dataset.mounted = '1';
+ await ensureVue();
+ const { createApp, ref, onMounted } = window.Vue;
+
+ // Re-render the labels once the locale has loaded.
+ const localeVersion = ref(0);
+ window.addEventListener('localeChanged', () => { localeVersion.value++; });
+ const t = (key, params) => {
+ localeVersion.value; // dependency, so labels follow the locale
+ const i18n = window.i18n;
+ return i18n && i18n.t ? i18n.t(key, params || {}) : key;
+ };
+
+ const app = createApp({
+ setup() {
+ const notifications = useNotifications({}, { t });
+ const isUserMenuOpen = ref(false);
+ const tokenBudget = ref(null);
+ const isDarkMode = ref(document.documentElement.classList.contains('dark'));
+
+ const toggleDarkMode = () => {
+ isDarkMode.value = !isDarkMode.value;
+ localStorage.setItem('darkMode', isDarkMode.value);
+ applyTheme(isDarkMode.value);
+ };
+ const openInMainApp = (query) => { window.location.href = `/?${query}`; };
+
+ onMounted(async () => {
+ notifications.startNotificationPolling();
+ document.addEventListener('click', (event) => {
+ if (!isUserMenuOpen.value) return;
+ if (event.target.closest('[data-user-menu-toggle], [data-user-menu-dropdown]')) return;
+ isUserMenuOpen.value = false;
+ });
+ try {
+ const response = await fetch('/api/user/token-budget');
+ if (response.ok) tokenBudget.value = await response.json();
+ } catch (_) { /* the indicator stays hidden */ }
+ });
+
+ return {
+ t,
+ ...notifications,
+ isUserMenuOpen,
+ tokenBudget,
+ isDarkMode,
+ toggleDarkMode,
+ switchToUploadView: () => openInMainApp('upload=1'),
+ openSharesList: () => openInMainApp('open=shares'),
+ openColorSchemeModal: () => openInMainApp('open=appearance'),
+ // Installing the PWA is offered from the main app only.
+ showInstallButton: false,
+ isPWAInstalled: true,
+ promptInstall: () => {},
+ };
+ },
+ });
+ app.config.compilerOptions.delimiters = ['${', '}'];
+ // A template that fails to compile would leave an empty header; keep
+ // the server-rendered one instead and say why in the console.
+ const serverRendered = el.innerHTML;
+ try {
+ app.mount(el);
+ } catch (error) {
+ console.error('[global-header] could not mount:', error);
+ }
+ if (!el.hasAttribute('data-v-app') || el.childElementCount === 0) {
+ console.error('[global-header] mount produced no header; restoring the server-rendered one');
+ try { app.unmount(); } catch (_) { /* not mounted */ }
+ el.innerHTML = serverRendered;
+ el.setAttribute('data-v-app', '');
+ }
+}
+
+if (document.readyState === 'loading') {
+ document.addEventListener('DOMContentLoaded', mountGlobalHeader);
+} else {
+ mountGlobalHeader();
+}
diff --git a/templates/account.html b/templates/account.html
index a2b38610..d6d81acb 100644
--- a/templates/account.html
+++ b/templates/account.html
@@ -464,6 +464,7 @@
</head>
<body class="bg-[var(--bg-primary)] text-[var(--text-primary)] h-full flex flex-col overflow-hidden">
{% set page_label = 'Account' %}
+ {% set page_label_key = 'nav.account' %}
{% include 'components/page-header.html' %}
<div class="main-container flex-1 flex flex-col min-h-0 overflow-hidden">
@@ -4283,67 +4284,8 @@ curl "https://your-speakr-instance.com/api/recordings?token=YOUR_TOKEN_HERE"</co
// Update footer on page load
updateFooter();
- // Dark mode toggle functionality
- const darkModeToggle = document.getElementById('darkModeToggle');
- const darkModeIcon = document.getElementById('darkModeIcon');
-
- // Initialize dark mode based on localStorage or system preference
- function initializeDarkMode() {
- const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
- const savedMode = localStorage.getItem('darkMode');
-
- if (savedMode === 'true' || (savedMode === null && prefersDark)) {
- document.documentElement.classList.add('dark');
- darkModeIcon.classList.remove('fa-moon');
- darkModeIcon.classList.add('fa-sun');
- } else {
- document.documentElement.classList.remove('dark');
- darkModeIcon.classList.remove('fa-sun');
- darkModeIcon.classList.add('fa-moon');
- }
- }
-
- // Toggle dark mode. Re-applies the saved color scheme so the
- // mode-prefix (theme-light-* vs theme-dark-*) flips along with
- // the dark class — otherwise switching from dark→light leaves
- // the previous theme-dark-{amber|emerald|etc.} class on
- // documentElement and the page falls back to the default blue
- // light palette because no theme-light-* class was added.
- darkModeToggle.addEventListener('click', () => {
- const isDarkMode = document.documentElement.classList.toggle('dark');
- localStorage.setItem('darkMode', isDarkMode);
-
- if (isDarkMode) {
- darkModeIcon.classList.remove('fa-moon');
- darkModeIcon.classList.add('fa-sun');
- } else {
- darkModeIcon.classList.remove('fa-sun');
- darkModeIcon.classList.add('fa-moon');
- }
-
- // Re-apply the color scheme for the new mode.
- if (typeof applyTheme === 'function') {
- applyTheme();
- }
- });
-
- // User dropdown functionality
- const userDropdownButton = document.getElementById('userDropdownButton');
- const userDropdownMenu = document.getElementById('userDropdownMenu');
-
- userDropdownButton.addEventListener('click', () => {
- userDropdownMenu.classList.toggle('hidden');
- });
-
- // Close dropdown when clicking outside
- document.addEventListener('click', (event) => {
- if (!userDropdownButton.contains(event.target) && !userDropdownMenu.contains(event.target)) {
- userDropdownMenu.classList.add('hidden');
- }
- });
-
- // Initialize dark mode on page load
- initializeDarkMode();
+ // The header's dark mode switch and user menu live in the shared
+ // header (components/header-controls.html, static/js/global-header.js).
// Change Password Modal functionality
const changePasswordBtn = document.getElementById('changePasswordBtn');
diff --git a/templates/admin.html b/templates/admin.html
index eeb41d2c..d5a2ad44 100644
--- a/templates/admin.html
+++ b/templates/admin.html
@@ -113,45 +113,8 @@
}
applyTheme();
- // Wire up the shared page-header's controls (dark mode toggle
- // + user dropdown). Has to run after DOMContentLoaded because
- // the header partial includes its own script that registers
- // an outside-click handler for the dropdown.
+ // The header's controls are driven by static/js/global-header.js.
document.addEventListener('DOMContentLoaded', () => {
- const darkBtn = document.getElementById('darkModeToggle');
- const darkIcon = document.getElementById('darkModeIcon');
- const userBtn = document.getElementById('userDropdownButton');
- const userMenu = document.getElementById('userDropdownMenu');
-
- // Sync the icon to the current mode on first load.
- if (darkIcon) {
- const isDark = document.documentElement.classList.contains('dark');
- darkIcon.classList.toggle('fa-moon', !isDark);
- darkIcon.classList.toggle('fa-sun', isDark);
- }
-
- if (darkBtn) {
- darkBtn.addEventListener('click', () => {
- const isDark = document.documentElement.classList.toggle('dark');
- localStorage.setItem('darkMode', isDark);
- if (darkIcon) {
- darkIcon.classList.toggle('fa-moon', !isDark);
- darkIcon.classList.toggle('fa-sun', isDark);
- }
- // Re-apply the saved color scheme for the new mode
- // so the theme-{light|dark}-* prefix flips with the
- // .dark class (same bug fixed on the account page).
- if (typeof applyTheme === 'function') applyTheme();
- });
- }
-
- if (userBtn && userMenu) {
- userBtn.addEventListener('click', (e) => {
- e.stopPropagation();
- userMenu.classList.toggle('hidden');
- });
- }
-
// Update the tab-footer version string by writing to the
// --footer-version-text CSS variable that .tab-footer::before
// reads. Same pattern as the account page.
@@ -175,6 +138,7 @@
</head>
<body class="bg-[var(--bg-primary)] text-[var(--text-primary)] h-full flex flex-col overflow-hidden">
{% set page_label = ('Team Management' if is_team_admin and not current_user.is_admin else 'Admin') %}
+ {% set page_label_key = ('nav.groupManagement' if is_team_admin and not current_user.is_admin else 'admin.title') %}
{% include 'components/page-header.html' %}
<!-- inline min-height: 0 beats the global #app { min-height: 100% }
rule in styles.css (ID selector has higher specificity than the
diff --git a/templates/components/header-controls.html b/templates/components/header-controls.html
new file mode 100644
index 00000000..43f4a5e4
--- /dev/null
+++ b/templates/components/header-controls.html
@@ -0,0 +1,157 @@
+{#- The controls on the right of every page header: token budget, Inquire,
+ New Recording and the user menu. The main app renders them inside its own
+ Vue app; the other pages mount static/js/global-header.js on
+ page-header.html, which provides the same state and methods, so every
+ page shows the same header. Vue delimiters are ${ }. -#}
+ {% include 'components/token_budget_indicator.html' %}
+
+ <!-- Inquire / Install PWA / New Recording header buttons.
+ All three use the .btn .btn--sm primitive so their height
+ + padding + font size are identical; only the colour
+ intent differs (Inquire = quiet/highlighted, PWA Install
+ = primary-success, New Recording = primary). -->
+ <!-- Inquire Mode Button -->
+ {% if inquire_mode_enabled %}
+ <a href="/inquire" class="btn btn--sm" style="background: var(--bg-accent); color: var(--text-accent); border-color: transparent;">
+ <i class="fas fa-search"></i>
+ <span class="hidden sm:inline" v-text="t('inquire.title')"></span>
+ </a>
+ {% endif %}
+
+ <!-- Install PWA Button -->
+ <button v-if="showInstallButton && !isPWAInstalled"
+ @click="promptInstall"
+ class="btn btn--sm"
+ style="background: #16a34a; color: #fff; border-color: transparent;"
+ :title="t('pwa.installApp')">
+ <i class="fas fa-download"></i>
+ <span class="hidden sm:inline" v-text="t('pwa.installApp')"></span>
+ </button>
+
+ <!-- New Recording Button -->
+ <button @click="switchToUploadView" class="btn btn--sm btn--primary">
+ <i class="fas fa-plus"></i><span class="hidden sm:inline" v-text="t('nav.newRecording')"></span>
+ </button>
+
+ <!-- User menu -->
+ {% if current_user.is_authenticated %}
+ <div class="relative">
+ <button @click="isUserMenuOpen = !isUserMenuOpen"
+ data-user-menu-toggle
+ class="btn btn--icon relative"
+ :title="t('admin.userMenu')">
+ <i class="fas fa-user-circle text-lg"></i>
+ <!-- Unread badge. The menu is the only always-visible anchor
+ in the header, so the count rides on it rather than on the
+ admin link, which lives inside the dropdown. -->
+ <span v-if="unreadCount > 0"
+ data-notification-badge
+ class="absolute -top-1 -right-1 min-w-[18px] h-[18px] px-1 rounded-full bg-red-600 text-white text-[11px] font-semibold leading-[18px] text-center"
+ v-text="unreadCount > 9 ? '9+' : unreadCount"></span>
+ </button>
+
+ <!-- User dropdown -->
+ <div v-if="isUserMenuOpen"
+ data-user-menu-dropdown
+ class="absolute right-0 mt-2 w-56 surface-raised z-50">
+ <!-- Notifications. Opening the section marks them read; the
+ individual X dismisses one. Notices that describe a
+ condition disappear on their own when it ends, so most
+ people never need either control. -->
+ <button @click="toggleNotifications"
+ data-notifications-toggle
+ class="w-full text-left px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors flex items-center justify-between">
+ <span>
+ <i class="fas fa-bell mr-2 w-4 text-center"></i><span v-text="t('nav.notifications')"></span>
+ </span>
+ <span v-if="unreadCount > 0"
+ class="ml-2 min-w-[18px] h-[18px] px-1 rounded-full bg-red-600 text-white text-[11px] font-semibold leading-[18px] text-center"
+ v-text="unreadCount > 9 ? '9+' : unreadCount"></span>
+ </button>
+ <div v-if="isNotificationsOpen" data-notifications-panel
+ class="max-h-64 overflow-y-auto border-y border-[var(--border-secondary)] bg-[var(--bg-tertiary)]">
+ <p v-if="notifications.length === 0"
+ class="px-4 py-3 text-xs text-[var(--text-muted)]"
+ v-text="t('notifications.empty')"></p>
+ <div v-for="n in notifications" :key="n.id"
+ class="px-4 py-3 border-b border-[var(--border-secondary)] last:border-b-0 flex items-start gap-2">
+ <i class="fas mt-0.5 w-4 text-center"
+ :class="n.level === 'error' ? 'fa-circle-exclamation text-red-500' : (n.level === 'warning' ? 'fa-triangle-exclamation text-amber-500' : 'fa-circle-info text-[var(--text-accent)]')"></i>
+ <div class="flex-1 min-w-0">
+ <p class="text-xs text-[var(--text-primary)] break-words" v-text="notificationText(n)"></p>
+ <a v-if="n.link" :href="n.link"
+ class="text-[11px] text-[var(--text-accent)] hover:underline"
+ v-text="t('notifications.view')"></a>
+ </div>
+ <button @click.stop="dismissNotification(n.id)"
+ class="text-[var(--text-muted)] hover:text-[var(--text-primary)] text-xs"
+ :title="t('notifications.dismiss')">
+ <i class="fas fa-xmark"></i>
+ </button>
+ </div>
+ </div>
+
+ <a href="/account" class="block px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors">
+ <i class="fas fa-cog mr-2 w-4 text-center"></i><span v-text="t('nav.settings')"></span>
+ </a>
+ <a href="/account#tags" class="block px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors">
+ <i class="fas fa-tags mr-2 w-4 text-center"></i><span v-text="t('accountTabs.tagsAndFolders')"></span>
+ </a>
+ <button @click="openSharesList" class="w-full text-left px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors flex items-center">
+ <i class="fas fa-share-alt mr-2 w-4 text-center"></i><span v-text="t('modal.sharedTranscripts')"></span>
+ </button>
+ {% if current_user.is_admin %}
+ <a href="/admin" class="block px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors">
+ <i class="fas fa-user-shield mr-2 w-4 text-center"></i>
+ <span v-text="t('admin.title')"></span>
+ </a>
+ {% elif is_group_admin %}
+ <a href="/group-management" class="block px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors">
+ <i class="fas fa-users-cog mr-2 w-4 text-center"></i>
+ <span v-text="t('nav.groupManagement')"></span>
+ </a>
+ {% endif %}
+ {% if help_center_url %}
+ <a href="{{ help_center_url }}" target="_blank" rel="noopener noreferrer"
+ class="block px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors">
+ <i class="fas fa-question-circle mr-2 w-4 text-center"></i>
+ {% if help_center_label %}
+ <span>{{ help_center_label }}</span>
+ {% else %}
+ <span v-text="t('nav.helpCenter')"></span>
+ {% endif %}
+ </a>
+ {% endif %}
+ <div class="border-t border-[var(--border-primary)] my-1"></div>
+ <!-- Combined appearance row: the row opens the color scheme
+ modal, the sun/moon pill toggles light/dark in place
+ (click.stop keeps the menu open for instant feedback). -->
+ <div @click="openColorSchemeModal"
+ class="w-full text-left px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors flex items-center justify-between cursor-pointer">
+ <span class="flex items-center whitespace-nowrap">
+ <i class="fas fa-palette mr-2 w-4 text-center"></i>
+ <span v-text="t('modal.colorScheme')"></span>
+ </span>
+ <button @click.stop="toggleDarkMode"
+ class="flex items-center rounded-full border border-[var(--border-secondary)] bg-[var(--bg-secondary)] p-0.5 ml-3 flex-shrink-0"
+ :title="isDarkMode ? t('nav.lightMode') : t('nav.darkMode')">
+ <span :class="!isDarkMode ? 'bg-[var(--bg-accent)] text-white' : 'text-[var(--text-muted)]'"
+ class="w-6 h-6 rounded-full flex items-center justify-center text-[11px] transition-colors">
+ <i class="fas fa-sun"></i>
+ </span>
+ <span :class="isDarkMode ? 'bg-[var(--bg-accent)] text-white' : 'text-[var(--text-muted)]'"
+ class="w-6 h-6 rounded-full flex items-center justify-center text-[11px] transition-colors">
+ <i class="fas fa-moon"></i>
+ </span>
+ </button>
+ </div>
+ <div class="border-t border-[var(--border-primary)] my-1"></div>
+ <form method="POST" action="/logout" class="m-0">
+ <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
+ <button type="submit" class="w-full text-left block px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors">
+ <i class="fas fa-sign-out-alt mr-2 w-4 text-center"></i><span v-text="t('nav.signOut')"></span>
+ </button>
+ </form>
+ </div>
+ </div>
+ {% endif %}
diff --git a/templates/components/header.html b/templates/components/header.html
index 2c9f270d..1957a6dd 100644
--- a/templates/components/header.html
+++ b/templates/components/header.html
@@ -217,157 +217,6 @@
<div class="hidden md:block w-px h-6 bg-[var(--border-primary)] mx-1"></div>
</template>
- {% include 'components/token_budget_indicator.html' %}
-
- <!-- Inquire / Install PWA / New Recording header buttons.
- All three use the .btn .btn--sm primitive so their height
- + padding + font size are identical; only the colour
- intent differs (Inquire = quiet/highlighted, PWA Install
- = primary-success, New Recording = primary). -->
- <!-- Inquire Mode Button -->
- {% if inquire_mode_enabled %}
- <a href="/inquire" class="btn btn--sm" style="background: var(--bg-accent); color: var(--text-accent); border-color: transparent;">
- <i class="fas fa-search"></i>
- <span class="hidden sm:inline" v-text="t('inquire.title')"></span>
- </a>
- {% endif %}
-
- <!-- Install PWA Button -->
- <button v-if="showInstallButton && !isPWAInstalled"
- @click="promptInstall"
- class="btn btn--sm"
- style="background: #16a34a; color: #fff; border-color: transparent;"
- :title="t('pwa.installApp')">
- <i class="fas fa-download"></i>
- <span class="hidden sm:inline" v-text="t('pwa.installApp')"></span>
- </button>
-
- <!-- New Recording Button -->
- <button @click="switchToUploadView" class="btn btn--sm btn--primary">
- <i class="fas fa-plus"></i><span class="hidden sm:inline" v-text="t('nav.newRecording')"></span>
- </button>
-
- <!-- User menu -->
- {% if current_user.is_authenticated %}
- <div class="relative">
- <button @click="isUserMenuOpen = !isUserMenuOpen"
- data-user-menu-toggle
- class="btn btn--icon relative"
- :title="t('admin.userMenu')">
- <i class="fas fa-user-circle text-lg"></i>
- <!-- Unread badge. The menu is the only always-visible anchor
- in the header, so the count rides on it rather than on the
- admin link, which lives inside the dropdown. -->
- <span v-if="unreadCount > 0"
- data-notification-badge
- class="absolute -top-1 -right-1 min-w-[18px] h-[18px] px-1 rounded-full bg-red-600 text-white text-[11px] font-semibold leading-[18px] text-center"
- v-text="unreadCount > 9 ? '9+' : unreadCount"></span>
- </button>
-
- <!-- User dropdown -->
- <div v-if="isUserMenuOpen"
- data-user-menu-dropdown
- class="absolute right-0 mt-2 w-56 surface-raised z-50">
- <!-- Notifications. Opening the section marks them read; the
- individual X dismisses one. Notices that describe a
- condition disappear on their own when it ends, so most
- people never need either control. -->
- <button @click="toggleNotifications"
- data-notifications-toggle
- class="w-full text-left px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors flex items-center justify-between">
- <span>
- <i class="fas fa-bell mr-2 w-4 text-center"></i><span v-text="t('nav.notifications')"></span>
- </span>
- <span v-if="unreadCount > 0"
- class="ml-2 min-w-[18px] h-[18px] px-1 rounded-full bg-red-600 text-white text-[11px] font-semibold leading-[18px] text-center"
- v-text="unreadCount > 9 ? '9+' : unreadCount"></span>
- </button>
- <div v-if="isNotificationsOpen" data-notifications-panel
- class="max-h-64 overflow-y-auto border-y border-[var(--border-secondary)] bg-[var(--bg-tertiary)]">
- <p v-if="notifications.length === 0"
- class="px-4 py-3 text-xs text-[var(--text-muted)]"
- v-text="t('notifications.empty')"></p>
- <div v-for="n in notifications" :key="n.id"
- class="px-4 py-3 border-b border-[var(--border-secondary)] last:border-b-0 flex items-start gap-2">
- <i class="fas mt-0.5 w-4 text-center"
- :class="n.level === 'error' ? 'fa-circle-exclamation text-red-500' : (n.level === 'warning' ? 'fa-triangle-exclamation text-amber-500' : 'fa-circle-info text-[var(--text-accent)]')"></i>
- <div class="flex-1 min-w-0">
- <p class="text-xs text-[var(--text-primary)] break-words" v-text="notificationText(n)"></p>
- <a v-if="n.link" :href="n.link"
- class="text-[11px] text-[var(--text-accent)] hover:underline"
- v-text="t('notifications.view')"></a>
- </div>
- <button @click.stop="dismissNotification(n.id)"
- class="text-[var(--text-muted)] hover:text-[var(--text-primary)] text-xs"
- :title="t('notifications.dismiss')">
- <i class="fas fa-xmark"></i>
- </button>
- </div>
- </div>
-
- <a href="/account" class="block px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors">
- <i class="fas fa-cog mr-2 w-4 text-center"></i><span v-text="t('nav.settings')"></span>
- </a>
- <a href="/account#tags" class="block px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors">
- <i class="fas fa-tags mr-2 w-4 text-center"></i><span v-text="t('accountTabs.tagsAndFolders')"></span>
- </a>
- <button @click="openSharesList" class="w-full text-left px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors flex items-center">
- <i class="fas fa-share-alt mr-2 w-4 text-center"></i><span v-text="t('modal.sharedTranscripts')"></span>
- </button>
- {% if current_user.is_admin %}
- <a href="/admin" class="block px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors">
- <i class="fas fa-user-shield mr-2 w-4 text-center"></i>
- <span v-text="t('admin.title')"></span>
- </a>
- {% elif is_group_admin %}
- <a href="/group-management" class="block px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors">
- <i class="fas fa-users-cog mr-2 w-4 text-center"></i>
- <span v-text="t('nav.groupManagement')"></span>
- </a>
- {% endif %}
- {% if help_center_url %}
- <a href="{{ help_center_url }}" target="_blank" rel="noopener noreferrer"
- class="block px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors">
- <i class="fas fa-question-circle mr-2 w-4 text-center"></i>
- {% if help_center_label %}
- <span>{{ help_center_label }}</span>
- {% else %}
- <span v-text="t('nav.helpCenter')"></span>
- {% endif %}
- </a>
- {% endif %}
- <div class="border-t border-[var(--border-primary)] my-1"></div>
- <!-- Combined appearance row: the row opens the color scheme
- modal, the sun/moon pill toggles light/dark in place
- (click.stop keeps the menu open for instant feedback). -->
- <div @click="openColorSchemeModal"
- class="w-full text-left px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors flex items-center justify-between cursor-pointer">
- <span class="flex items-center whitespace-nowrap">
- <i class="fas fa-palette mr-2 w-4 text-center"></i>
- <span v-text="t('modal.colorScheme')"></span>
- </span>
- <button @click.stop="toggleDarkMode"
- class="flex items-center rounded-full border border-[var(--border-secondary)] bg-[var(--bg-secondary)] p-0.5 ml-3 flex-shrink-0"
- :title="isDarkMode ? t('nav.lightMode') : t('nav.darkMode')">
- <span :class="!isDarkMode ? 'bg-[var(--bg-accent)] text-white' : 'text-[var(--text-muted)]'"
- class="w-6 h-6 rounded-full flex items-center justify-center text-[11px] transition-colors">
- <i class="fas fa-sun"></i>
- </span>
- <span :class="isDarkMode ? 'bg-[var(--bg-accent)] text-white' : 'text-[var(--text-muted)]'"
- class="w-6 h-6 rounded-full flex items-center justify-center text-[11px] transition-colors">
- <i class="fas fa-moon"></i>
- </span>
- </button>
- </div>
- <div class="border-t border-[var(--border-primary)] my-1"></div>
- <form method="POST" action="/logout" class="m-0">
- <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
- <button type="submit" class="w-full text-left block px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors">
- <i class="fas fa-sign-out-alt mr-2 w-4 text-center"></i><span v-text="t('nav.signOut')"></span>
- </button>
- </form>
- </div>
- </div>
- {% endif %}
+ {% include 'components/header-controls.html' %}
</div>
</header>
diff --git a/templates/components/page-header.html b/templates/components/page-header.html
index 820b4e77..20fa0396 100644
--- a/templates/components/page-header.html
+++ b/templates/components/page-header.html
@@ -1,14 +1,15 @@
-{# Shared page header for non-Vue tab-driven pages (account, admin,
- inquire-when-needed). Visually identical to the main app's Vue header:
- 56px min-height, compact px-3/4 py-2, btn--icon primitives, single
- adaptive bar. Vanilla HTML + tiny inline JS for the dropdown.
+{# Page header for the pages outside the main app (account, admin, group
+ management). The right side is components/header-controls.html, the same
+ template the main app's header uses, driven here by the small Vue app in
+ static/js/global-header.js, so every page has the same controls and menu.
Usage:
- set page_label = 'Account' (optional small label after logo)
+ set page_label = 'Account' (fallback text)
+ set page_label_key = 'nav.account' (i18n key for the label)
include 'components/page-header.html'
#}
-<header class="bg-[var(--bg-secondary)] border-b border-[var(--border-primary)] px-3 sm:px-4 py-2 flex items-center justify-between flex-shrink-0 z-50 gap-3 sticky top-0" style="min-height: 56px;">
- <!-- Left: Speakr logo + name + optional page label -->
+<header id="global-header" class="bg-[var(--bg-secondary)] border-b border-[var(--border-primary)] px-3 sm:px-4 py-2 flex items-center justify-between flex-shrink-0 z-50 gap-3 sticky top-0" style="min-height: 56px;">
+ <!-- Left: Speakr logo + name + page label -->
<div class="flex items-center gap-2 sm:gap-3 min-w-0 flex-1">
<a href="{{ url_for('recordings.index') }}" class="flex items-center gap-2 sm:gap-3 min-w-0 hover:opacity-80 transition-opacity">
<img src="{{ url_for('static', filename='img/icon-32x32.png') }}" alt="Speakr" class="app-logo w-7 h-7 sm:w-8 sm:h-8 flex-shrink-0">
@@ -16,77 +17,27 @@
</a>
{% if page_label %}
<span class="text-[var(--text-muted)] hidden sm:inline" aria-hidden="true">/</span>
+ {% if page_label_key %}
+ <span class="t-meta hidden sm:inline" v-text="t('{{ page_label_key }}')"></span>
+ {% else %}
<span class="t-meta hidden sm:inline">{{ page_label }}</span>
{% endif %}
+ {% endif %}
</div>
- <!-- Right: theme toggle + user menu -->
- <div class="flex items-center gap-1 sm:gap-2 flex-shrink-0">
- <!-- Dark mode toggle (id preserved so existing JS still works) -->
- <button id="darkModeToggle" class="btn btn--icon" title="Toggle dark mode">
- <i id="darkModeIcon" class="fas fa-moon"></i>
- </button>
-
- {% if current_user.is_authenticated %}
- <!-- User menu -->
- <div class="relative" id="userDropdown">
- <button id="userDropdownButton" class="btn btn--icon" title="User menu" data-user-menu-toggle>
- <i class="fas fa-user-circle text-lg"></i>
- </button>
- <div id="userDropdownMenu" class="hidden absolute right-0 mt-2 w-56 surface-raised z-50" data-user-menu-dropdown>
- <a href="{{ url_for('recordings.index') }}" class="block px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors">
- <i class="fas fa-home mr-2 w-4 text-center"></i><span data-i18n="nav.home">Home</span>
- </a>
- <a href="{{ url_for('auth.account') }}" class="block px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors {% if request.endpoint == 'auth.account' %}text-[var(--text-accent)] bg-[var(--bg-accent)]{% endif %}">
- <i class="fas fa-user-circle mr-2 w-4 text-center"></i><span data-i18n="nav.account">Account</span>
- </a>
- {% if current_user.is_admin %}
- <a href="{{ url_for('admin.admin') }}" class="block px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors {% if request.endpoint == 'admin.admin' %}text-[var(--text-accent)] bg-[var(--bg-accent)]{% endif %}">
- <i class="fas fa-user-shield mr-2 w-4 text-center"></i><span data-i18n="nav.admin">Admin</span>
- </a>
- {% elif is_team_admin %}
- <a href="{{ url_for('admin.admin') }}" class="block px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors">
- <i class="fas fa-users-cog mr-2 w-4 text-center"></i><span data-i18n="nav.groupManagement">Team Management</span>
- </a>
- {% endif %}
- {% if help_center_url %}
- <a href="{{ help_center_url }}" target="_blank" rel="noopener noreferrer"
- class="block px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors">
- <i class="fas fa-question-circle mr-2 w-4 text-center"></i>
- {% if help_center_label %}
- <span>{{ help_center_label }}</span>
- {% else %}
- <span data-i18n="nav.helpCenter">Help Center</span>
- {% endif %}
- </a>
- {% endif %}
- <div class="border-t border-[var(--border-primary)] my-1"></div>
- <form method="POST" action="{{ url_for('auth.logout') }}" class="m-0">
- <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
- <button type="submit" class="w-full text-left block px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors">
- <i class="fas fa-sign-out-alt mr-2 w-4 text-center"></i><span data-i18n="nav.signOut">Sign out</span>
- </button>
- </form>
- </div>
- </div>
- {% endif %}
+ <!-- Right: the same controls as the main app's header -->
+ <div class="flex items-center gap-1 sm:gap-2 flex-shrink-0 global-header-controls">
+ {% include 'components/header-controls.html' %}
</div>
</header>
+<style>
+ /* Until the header app mounts, the controls hold their space but stay
+ invisible, so raw template markup never shows. */
+ #global-header:not([data-v-app]) .global-header-controls { visibility: hidden; }
+</style>
+<script type="module" src="{{ url_for('static', filename='js/global-header.js') }}"></script>
<script>
-// Tiny vanilla JS: close the user dropdown on outside click. The dark
-// mode toggle and dropdown open/close are owned by the page's existing
-// JS (account.js / admin.js / inquire.html inline) — we just preserve
-// the IDs they expect.
-document.addEventListener('click', function(e) {
- var dd = document.getElementById('userDropdownMenu');
- var btn = document.getElementById('userDropdownButton');
- if (!dd || !btn) return;
- if (!dd.contains(e.target) && !btn.contains(e.target)) {
- dd.classList.add('hidden');
- }
-});
-
// Tabs scroller — attaches to any element marked [data-tabs-scroller]
// that wraps a .tabs container. Shows/hides left/right chevron buttons
// based on whether the tab strip can scroll further in that direction;
diff --git a/templates/components/token_budget_indicator.html b/templates/components/token_budget_indicator.html
index edbebc23..88b27f87 100644
--- a/templates/components/token_budget_indicator.html
+++ b/templates/components/token_budget_indicator.html
@@ -2,7 +2,7 @@
<!-- Only shows if user has a budget limit set -->
<div v-if="tokenBudget && tokenBudget.has_budget"
class="hidden sm:flex items-center gap-1.5 px-2 py-1 rounded text-xs text-[var(--text-muted)] hover:text-[var(--text-secondary)] transition-colors cursor-default"
- :title="t('adminDashboard.tokenUsage') + ': ' + (tokenBudget.usage || 0).toLocaleString() + ' / ' + (tokenBudget.budget || 0).toLocaleString()">
+ :title="t('adminDashboard.tokenUsage.title') + ': ' + (tokenBudget.usage || 0).toLocaleString() + ' / ' + (tokenBudget.budget || 0).toLocaleString()">
<i class="fas fa-coins text-[10px]"
:style="tokenBudget.percentage >= 100 ? {color: '#ef4444'} : tokenBudget.percentage >= 80 ? {color: '#f59e0b'} : {}"></i>
<span :style="tokenBudget.percentage >= 100 ? {color: '#ef4444'} : tokenBudget.percentage >= 80 ? {color: '#f59e0b'} : {}">${ tokenBudget.percentage }%</span>
diff --git a/templates/group-admin.html b/templates/group-admin.html
index b458b909..f768e4ca 100644
--- a/templates/group-admin.html
+++ b/templates/group-admin.html
@@ -113,49 +113,10 @@
</script>
</head>
<body class="bg-[var(--bg-primary)] text-[var(--text-primary)]">
+ {% set page_label = 'Group Management' %}
+ {% set page_label_key = 'nav.groupManagement' %}
+ {% include 'components/page-header.html' %}
<div id="app" v-cloak class="container mx-auto px-4 sm:px-6 lg:px-8 py-6 flex flex-col min-h-screen">
- <header class="flex justify-between items-center mb-6 pb-4 border-b border-[var(--border-primary)]">
- <h1 class="text-3xl font-bold text-[var(--text-primary)]">
- <a href="{{ url_for('recordings.index') }}" class="flex items-center">
- <img src="{{ url_for('static', filename='img/icon-192x192.png') }}" alt="Speakr Logo" class="app-logo h-9 w-9 mr-2">
- Speakr
- </a>
- </h1>
- <div class="flex items-center space-x-2">
- <button @click="toggleDarkMode" class="p-2 rounded-full text-[var(--text-muted)] hover:bg-[var(--bg-tertiary)] dark:text-gray-400 dark:hover:bg-gray-700 transition-colors duration-200" :title="isDarkMode ? 'Switch to Light Mode' : 'Switch to Dark Mode'">
- <i :class="isDarkMode ? 'fas fa-sun' : 'fas fa-moon'"></i>
- </button>
- <div class="relative">
- <button @click="isUserMenuOpen = !isUserMenuOpen"
- data-user-menu-toggle
- class="flex items-center px-3 py-2 border border-[var(--border-secondary)] rounded-lg text-[var(--text-secondary)] hover:text-[var(--text-accent)] focus:outline-none">
- <i class="fas fa-users-cog mr-2"></i>
- <span>{{ current_user.username }}</span>
- <i class="fas fa-chevron-down ml-2"></i>
- </button>
- <div v-if="isUserMenuOpen"
- data-user-menu-dropdown
- class="absolute right-0 mt-2 w-48 bg-[var(--bg-secondary)] border border-[var(--border-primary)] rounded-lg shadow-lg z-10">
- <a href="{{ url_for('recordings.index') }}" class="block px-4 py-2 text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-accent)]">
- <i class="fas fa-home mr-2"></i> Home
- </a>
- <a href="{{ url_for('auth.account') }}" class="block px-4 py-2 text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-accent)]">
- <i class="fas fa-user mr-2"></i> Account
- </a>
- <a href="{{ url_for('admin.group_management') }}" class="block px-4 py-2 text-[var(--text-accent)] bg-[var(--bg-accent)]">
- <i class="fas fa-users-cog mr-2"></i>
- Group Management
- </a>
- <form method="POST" action="{{ url_for('auth.logout') }}" class="m-0">
- <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
- <button type="submit" class="w-full text-left block px-4 py-2 text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-danger)]">
- <i class="fas fa-sign-out-alt mr-2"></i> Sign Out
- </button>
- </form>
- </div>
- </div>
- </div>
- </header>
<main class="flex-grow">
<div class="bg-[var(--bg-secondary)] p-4 sm:p-6 lg:p-8 rounded-xl shadow-lg border border-[var(--border-primary)]">
diff --git a/templates/includes/loading_overlay.html b/templates/includes/loading_overlay.html
index 817a5f0c..a1d14775 100644
--- a/templates/includes/loading_overlay.html
+++ b/templates/includes/loading_overlay.html
@@ -7,15 +7,26 @@
left: 0;
right: 0;
bottom: 0;
- background: #1a1b26;
+ /* The page's own theme colours, set in <head> before this appears,
+ so the overlay never flashes a different colour. */
+ background: var(--bg-primary, #1a1b26);
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
+ /* Invisible at first and faded in only if the page is still loading
+ after 400 ms: a page that loads quickly goes straight from its
+ background to its content with no spinner flashing in between. */
+ opacity: 0;
+ animation: app-loading-appear 0.2s ease-out 0.4s forwards;
transition: opacity 0.3s ease-out;
}
+ @keyframes app-loading-appear {
+ to { opacity: 1; }
+ }
.app-loading-overlay.fade-out {
opacity: 0;
+ animation: none;
pointer-events: none;
}
.app-loading-content {
@@ -25,13 +36,13 @@
width: 50px;
height: 50px;
margin: 0 auto 20px;
- border: 3px solid rgba(255, 255, 255, 0.1);
- border-top-color: #7aa2f7;
+ border: 3px solid var(--border-primary, rgba(255, 255, 255, 0.1));
+ border-top-color: var(--text-accent, #7aa2f7);
border-radius: 50%;
animation: spin 1s linear infinite;
}
.app-loading-text {
- color: #a0a0b0;
+ color: var(--text-muted, #a0a0b0);
font-size: 14px;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
letter-spacing: 0.5px;
@@ -41,12 +52,6 @@
}
body.app-loading { overflow: hidden; }
body.app-loading > *:not(.app-loading-overlay) { opacity: 0; }
- body.light .app-loading-overlay { background: #ffffff; }
- body.light .app-loading-spinner {
- border-color: rgba(0, 0, 0, 0.1);
- border-top-color: #3b82f6;
- }
- body.light .app-loading-text { color: #6b7280; }
</style>
<script>
// Immediate loading overlay initialization
diff --git a/templates/inquire.html b/templates/inquire.html
index 9a53b9ab..476e14db 100644
--- a/templates/inquire.html
+++ b/templates/inquire.html
@@ -219,7 +219,7 @@
data-current-user-name="{{ (current_user.name or current_user.username) if current_user.is_authenticated else '' }}">
<!-- Header -->
- <header class="bg-[var(--bg-secondary)] border-b border-[var(--border-primary)] px-3 sm:px-4 py-3 flex items-center justify-between flex-shrink-0 z-50">
+ <header class="bg-[var(--bg-secondary)] border-b border-[var(--border-primary)] px-3 sm:px-4 py-2 flex items-center justify-between flex-shrink-0 z-50 gap-3" style="min-height: 56px;">
<!-- Left side: Menu and logo -->
<div class="flex items-center gap-2 sm:gap-4 min-w-0 flex-shrink">
<!-- Mobile Sidebar Toggle — uses the design system
@@ -234,96 +234,15 @@
<a href="/" class="flex items-center gap-2 sm:gap-3 min-w-0 hover:opacity-80 transition-opacity">
<img src="{{ url_for('static', filename='img/icon-32x32.png') }}" alt="Speakr" class="app-logo w-6 h-6 sm:w-8 sm:h-8 flex-shrink-0">
<h1 class="text-lg sm:text-xl font-bold text-[var(--text-primary)] truncate">Speakr</h1>
- <span class="text-xs sm:text-sm text-[var(--text-muted)] hidden sm:inline">• Inquire Mode</span>
</a>
+ <span class="text-[var(--text-muted)] hidden sm:inline" aria-hidden="true">/</span>
+ <span class="t-meta hidden sm:inline" v-text="t('inquire.title')"></span>
</div>
- <!-- Right side: User menu -->
- <div class="flex items-center gap-2 sm:gap-3">
- {% include 'components/token_budget_indicator.html' %}
-
- <!-- New Recording Button.
- Inquire mode is a separate Vue app that can't
- embed the main app's upload modal directly. We
- redirect to "/" with ?upload=1 — the main app
- reads that query param on mount and opens the
- upload modal automatically (then clears the
- param via history.replaceState so a refresh
- doesn't re-trigger). Click is the same single
- action the user expected. -->
- <a href="/?upload=1"
- class="btn btn--sm btn--primary">
- <i class="fas fa-plus"></i>
- <span class="hidden sm:inline">${ t('nav.newRecording') }</span>
- </a>
-
- <!-- User menu -->
- {% if current_user.is_authenticated %}
- <div class="relative">
- <button @click="isUserMenuOpen = !isUserMenuOpen"
- data-user-menu-toggle
- class="btn btn--ghost btn--sm flex-shrink-0"
- :title="t('admin.userMenu')">
- <i class="fas fa-user-circle"></i>
- <span class="hidden lg:inline">{{ (current_user.name or current_user.username) if current_user.is_authenticated else 'User' }}</span>
- <i class="fas fa-chevron-down text-xs hidden sm:inline"></i>
- </button>
-
- <!-- User dropdown -->
- <div v-if="isUserMenuOpen"
- data-user-menu-dropdown
- class="absolute right-0 mt-2 w-56 bg-[var(--bg-secondary)] border border-[var(--border-primary)] rounded-lg shadow-lg z-50">
- <a href="/" class="block px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors">
- <i class="fas fa-home mr-2 w-4 text-center"></i><span v-text="t('nav.home')"></span>
- </a>
- <a href="/account" class="block px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors">
- <i class="fas fa-cog mr-2 w-4 text-center"></i><span v-text="t('nav.settings')"></span>
- </a>
- <a href="/account#tags" class="block px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors">
- <i class="fas fa-tags mr-2 w-4 text-center"></i><span v-text="t('accountTabs.tagsAndFolders')"></span>
- </a>
- <button @click="openSharesList" class="w-full text-left px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors flex items-center">
- <i class="fas fa-share-alt mr-2 w-4 text-center"></i><span v-text="t('modal.sharedTranscripts')"></span>
- </button>
- {% if current_user.is_admin or is_group_admin %}
- <a href="/admin" class="block px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors">
- <i class="fas fa-{% if current_user.is_admin %}user-shield{% else %}users-cog{% endif %} mr-2 w-4 text-center"></i>
- <span v-text="{% if current_user.is_admin %}t('admin.title'){% else %}t('nav.groupManagement'){% endif %}"></span>
- </a>
- {% endif %}
- <div class="border-t border-[var(--border-primary)] my-1"></div>
- <!-- Combined appearance row: the row opens the color
- scheme modal, the sun/moon pill toggles light/dark
- in place (click.stop keeps the menu open). -->
- <div @click="openColorSchemeModal"
- class="w-full text-left px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors flex items-center justify-between cursor-pointer">
- <span class="flex items-center whitespace-nowrap">
- <i class="fas fa-palette mr-2 w-4 text-center"></i>
- <span v-text="t('modal.colorScheme')"></span>
- </span>
- <button @click.stop="toggleDarkMode"
- class="flex items-center rounded-full border border-[var(--border-secondary)] bg-[var(--bg-secondary)] p-0.5 ml-3 flex-shrink-0"
- :title="isDarkMode ? t('nav.lightMode') : t('nav.darkMode')">
- <span :class="!isDarkMode ? 'bg-[var(--bg-accent)] text-white' : 'text-[var(--text-muted)]'"
- class="w-6 h-6 rounded-full flex items-center justify-center text-[11px] transition-colors">
- <i class="fas fa-sun"></i>
- </span>
- <span :class="isDarkMode ? 'bg-[var(--bg-accent)] text-white' : 'text-[var(--text-muted)]'"
- class="w-6 h-6 rounded-full flex items-center justify-center text-[11px] transition-colors">
- <i class="fas fa-moon"></i>
- </span>
- </button>
- </div>
- <div class="border-t border-[var(--border-primary)] my-1"></div>
- <form method="POST" action="/logout" class="m-0">
- <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
- <button type="submit" class="w-full text-left block px-4 py-2 hover:bg-[var(--bg-tertiary)] transition-colors">
- <i class="fas fa-sign-out-alt mr-2 w-4 text-center"></i><span v-text="t('nav.signOut')"></span>
- </button>
- </form>
- </div>
- </div>
- {% endif %}
+ <!-- Right side: the same controls as every other page
+ (components/header-controls.html). -->
+ <div class="flex items-center gap-1 sm:gap-2 flex-shrink-0">
+ {% include 'components/header-controls.html' %}
</div>
</header>
@@ -815,6 +734,8 @@
document.addEventListener('DOMContentLoaded', async () => {
await initializeI18n();
+ // Notifications for the shared header's user menu.
+ const { useNotifications } = await import('/static/js/modules/composables/notifications.js');
const csrfToken = ref(document.querySelector('meta[name="csrf-token"]')?.getAttribute('content'));
const i18nInstance = window.i18n;
@@ -1377,9 +1298,21 @@
}
});
+ const headerNotifications = useNotifications({}, {
+ t: (key, params) => i18nInstance ? i18nInstance.t(key, params) : key,
+ });
+ onMounted(() => headerNotifications.startNotificationPolling());
+
return {
// i18n - bind to i18n instance to maintain context
t: (key, params) => i18nInstance ? i18nInstance.t(key, params) : key,
+
+ // Shared header controls (components/header-controls.html)
+ ...headerNotifications,
+ switchToUploadView: () => { window.location.href = '/?upload=1'; },
+ showInstallButton: false,
+ isPWAInstalled: true,
+ promptInstall: () => {},
// State
inquireFilters,
diff --git a/tests/test_unified_header.py b/tests/test_unified_header.py
new file mode 100644
index 00000000..180e4f13
--- /dev/null
+++ b/tests/test_unified_header.py
@@ -0,0 +1,92 @@
+"""Every page shows the same header controls and menu.
+
+The controls on the right of the header are one template,
+components/header-controls.html. The main app renders it in its own Vue app;
+account, admin and group management render it through page-header.html and
+static/js/global-header.js; Inquire includes it in its own header. These tests
+pin that every page carries the shared menu and none keeps an old copy.
+
+SHARED-DB: the test users are removed afterwards.
+"""
+
+import os
+import re
+import sys
+import uuid
+
+import pytest
+from flask import g
+from flask.testing import FlaskClient
+
+sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+from src.app import app, db
+from src.models import User
+
+app.config["WTF_CSRF_ENABLED"] = False
+
+# Markers only the shared template has.
+SHARED_MARKERS = ('data-notifications-toggle', 'openSharesList', 'openColorSchemeModal', 'switchToUploadView')
+
+
+class _Client(FlaskClient):
+ def open(self, *args, **kwargs):
+ g.pop('_login_user', None)
+ return super().open(*args, **kwargs)
+
+
+def admin_client():
+ with app.app_context():
+ s = uuid.uuid4().hex[:8]
+ user = User(username=f"uh_{s}", email=f"uh_{s}@local.test", password="x", is_admin=True)
+ db.session.add(user)
+ db.session.commit()
+ client = _Client(app, app.response_class)
+ with client.session_transaction() as sess:
+ sess["_user_id"] = str(user.id)
+ sess["_fresh"] = True
+ yield client
+ db.session.delete(db.session.get(User, user.id))
+ db.session.commit()
+
+
[email protected]("path", ["/", "/account", "/admin"])
+def test_each_page_renders_the_shared_header_controls(admin_client, path):
+ html = admin_client.get(path).get_data(as_text=True)
+ for marker in SHARED_MARKERS:
+ assert marker in html, (path, marker)
+ buttons = re.findall(r'<button[^>]*data-user-menu-toggle', html)
+ assert len(buttons) == 1, (path, len(buttons))
+
+
[email protected]("path", ["/account", "/admin"])
+def test_pages_outside_the_main_app_mount_the_header_app_and_drop_the_old_controls(admin_client, path):
+ html = admin_client.get(path).get_data(as_text=True)
+ assert 'id="global-header"' in html
+ assert 'js/global-header.js' in html
+ assert 'id="darkModeToggle"' not in html and 'id="userDropdownButton"' not in html
+
+
+def test_the_inquire_page_uses_the_shared_controls(admin_client):
+ from unittest.mock import patch
+ with patch("src.app.ENABLE_INQUIRE_MODE", True):
+ response = admin_client.get("/inquire")
+ if response.status_code != 200:
+ pytest.skip("Inquire mode is not available in this configuration")
+ html = response.get_data(as_text=True)
+ for marker in SHARED_MARKERS:
+ assert marker in html, marker
+
+
+def test_the_page_label_has_no_fallback_text_inside_v_text(admin_client):
+ """Vue refuses to compile an element with both v-text and children, and
+ the header app then renders nothing."""
+ html = admin_client.get("/account").get_data(as_text=True)
+ assert "v-text=\"t('nav.account')\"></span>" in html
+
+
+def test_the_loading_overlay_follows_the_theme_and_waits_before_showing(admin_client):
+ html = admin_client.get("/account").get_data(as_text=True)
+ assert "background: var(--bg-primary" in html
+ assert "app-loading-appear" in html