UI review, stage 3: cleanup, shared chart code, confirmations, routing
useTrafficChart composable replaces the duplicated chart code in Analytics and HistoryModal; theme observer is released on unmount; blob URLs are revoked. ConfirmModal gets a unique id; confirm() in Server/PKI and SweetAlert2 in Account are replaced by ConfirmModal and toasts, sweetalert2 and sass removed. Separate authApiClient for /api/auth. 404 redirect, lazy Clients, token-based isAuthenticated, theme from prefers-color-scheme set before mount. BaseModal reactive size, NewClientModal name check and focus on opened, HistoryModal ignores stale answers. Login.vue.bak, the dead global axios interceptor and empty <p> removed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
600119cdd1
commit
897c82ab88
23 files changed
+430
-710
No files matched your search
+11
-22
@@ -24,7 +24,6 @@
|
||||
|
||||
<!-- SECTION: MONITORING -->
|
||||
<div class="nav-section-header">MONITORING</div>
|
||||
<p></p>
|
||||
<router-link to="/" class="nav-link" active-class="active" title="Analytics">
|
||||
<i class="fas fa-chart-line"></i> <span>Analytics</span>
|
||||
</router-link>
|
||||
@@ -34,7 +33,6 @@
|
||||
|
||||
<!-- SECTION: CONFIGURATION -->
|
||||
<div class="nav-section-header mt-3">CONFIGURATION</div>
|
||||
<p></p>
|
||||
<router-link to="/config/pki" class="nav-link" active-class="active" title="PKI">
|
||||
<i class="fas fa-fingerprint"></i> <span>PKI</span>
|
||||
</router-link>
|
||||
@@ -48,7 +46,6 @@
|
||||
|
||||
<!-- SECTION: MANAGEMENT -->
|
||||
<div class="nav-section-header mt-3">MANAGEMENT</div>
|
||||
<p></p>
|
||||
<router-link to="/certificates" class="nav-link" active-class="active" title="Certificates">
|
||||
<i class="fas fa-certificate"></i> <span>Certificates</span>
|
||||
</router-link>
|
||||
@@ -61,7 +58,6 @@
|
||||
|
||||
<!-- SECTION: ACCOUNT -->
|
||||
<div class="nav-section-header mt-3">ACCOUNT</div>
|
||||
<p></p>
|
||||
<router-link to="/account" class="nav-link" active-class="active" title="Account Settings">
|
||||
<i class="fas fa-user-cog"></i> <span>Account Settings</span>
|
||||
</router-link>
|
||||
@@ -96,10 +92,10 @@
|
||||
<i class="fas fa-globe me-1 text-muted"></i>{{ timezoneAbbr }}
|
||||
</span>
|
||||
<button class="btn-header" @click="toggleTheme" title="Toggle Theme">
|
||||
<i class="fas" :class="isDark ? 'fa-sun' : 'fa-moon'" id="themeIcon"></i>
|
||||
<i class="fas" :class="isDark ? 'fa-sun' : 'fa-moon'"></i>
|
||||
</button>
|
||||
<button class="btn-header me-2" @click="refreshPage" title="Refresh">
|
||||
<i class="fas fa-sync-alt" id="refreshIcon"></i>
|
||||
<i class="fas fa-sync-alt"></i>
|
||||
</button>
|
||||
|
||||
<div class="header-divider d-none d-md-block"></div>
|
||||
@@ -138,11 +134,12 @@ import { useRoute, useRouter } from 'vue-router';
|
||||
import ToastContainer from './components/ToastContainer.vue';
|
||||
import { usePkiStatus } from './composables/usePkiStatus';
|
||||
import { useToast } from './composables/useToast';
|
||||
import { useTheme } from './composables/useTheme';
|
||||
|
||||
const { loadConfig, isLoaded } = useAppConfig();
|
||||
const { apiClient } = useApi();
|
||||
const timezoneAbbr = ref(new Date().toLocaleTimeString('en-us',{timeZoneName:'short'}).split(' ')[2] || 'UTC');
|
||||
const isDark = ref(false);
|
||||
const { isDark, toggleTheme } = useTheme();
|
||||
const refreshKey = ref(0);
|
||||
const isSidebarOpen = ref(false);
|
||||
const isCompact = ref(false);
|
||||
@@ -151,7 +148,11 @@ const router = useRouter();
|
||||
const { status: pkiStatus, refresh: refreshPkiStatus } = usePkiStatus();
|
||||
const toast = useToast();
|
||||
|
||||
const isAuthenticated = computed(() => route.name !== 'Login');
|
||||
// Signed in: a stored token on a non-public page (the token is not reactive: it is re-read on every navigation)
|
||||
const isAuthenticated = computed(() => {
|
||||
void route.fullPath;
|
||||
return !route.meta.public && !!localStorage.getItem('ovpmon_token');
|
||||
});
|
||||
const username = ref(localStorage.getItem('ovpmon_user') || '');
|
||||
|
||||
// Keep the header name in sync with the server (login, rename, stale session)
|
||||
@@ -183,13 +184,6 @@ const handleLogout = () => {
|
||||
router.push('/login');
|
||||
};
|
||||
|
||||
const toggleTheme = () => {
|
||||
isDark.value = !isDark.value;
|
||||
const theme = isDark.value ? 'dark' : 'light';
|
||||
document.documentElement.setAttribute('data-theme', theme);
|
||||
localStorage.setItem('theme', theme);
|
||||
};
|
||||
|
||||
const toggleSidebar = () => {
|
||||
isCompact.value = !isCompact.value;
|
||||
localStorage.setItem('sidebarCompact', isCompact.value);
|
||||
@@ -202,7 +196,7 @@ const refreshPage = () => {
|
||||
// Close sidebar on route change
|
||||
watch(() => route.path, () => {
|
||||
isSidebarOpen.value = false;
|
||||
if (route.name !== 'Login') {
|
||||
if (isAuthenticated.value) {
|
||||
syncUsername();
|
||||
refreshPkiStatus();
|
||||
}
|
||||
@@ -211,15 +205,10 @@ watch(() => route.path, () => {
|
||||
onMounted(async () => {
|
||||
await loadConfig();
|
||||
window.addEventListener('ovpmon-user-changed', onUserChanged);
|
||||
if (route.name !== 'Login') {
|
||||
if (isAuthenticated.value) {
|
||||
syncUsername();
|
||||
refreshPkiStatus();
|
||||
}
|
||||
|
||||
// Init Theme
|
||||
const savedTheme = localStorage.getItem('theme') || 'light';
|
||||
isDark.value = savedTheme === 'dark';
|
||||
document.documentElement.setAttribute('data-theme', savedTheme);
|
||||
|
||||
// Init Sidebar
|
||||
const savedCompact = localStorage.getItem('sidebarCompact');
|
||||
|
||||
Reference in new issue
Block a user