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
@@ -1,11 +1,15 @@
|
||||
<template>
|
||||
<BaseModal id="newClientModal" title="Create New Client" ref="modal">
|
||||
<BaseModal id="newClientModal" title="Create New Client" ref="modal" @opened="inputRef?.focus()">
|
||||
<template #body>
|
||||
<div class="mb-3">
|
||||
<label for="clientName" class="form-label small text-muted text-uppercase fw-bold">Client Name</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-user"></i></span>
|
||||
<input type="text" class="form-control" id="clientName" v-model="clientName" placeholder="e.g. laptop-user" @keyup.enter="confirm" ref="inputRef">
|
||||
<input type="text" class="form-control" :class="{ 'is-invalid': clientName && !isValid }" id="clientName"
|
||||
v-model="clientName" placeholder="e.g. laptop-user" maxlength="64" autocomplete="off" @keyup.enter="confirm" ref="inputRef">
|
||||
</div>
|
||||
<div v-if="clientName && !isValid" class="text-danger small mt-2">
|
||||
Letters, digits, dashes and underscores only; the first character must be a letter or a digit.
|
||||
</div>
|
||||
<div class="form-text mt-2 text-muted small">
|
||||
<i class="fas fa-info-circle me-1"></i> Use only alphanumeric characters, dashes, or underscores.
|
||||
@@ -14,7 +18,7 @@
|
||||
</template>
|
||||
<template #footer>
|
||||
<button type="button" class="btn-action btn-action-secondary" @click="close">Cancel</button>
|
||||
<button type="button" class="btn-action btn-action-save" @click="confirm" :disabled="!clientName">
|
||||
<button type="button" class="btn-action btn-action-save" @click="confirm" :disabled="!isValid">
|
||||
Create Client
|
||||
</button>
|
||||
</template>
|
||||
@@ -22,7 +26,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { ref, computed } from 'vue';
|
||||
import BaseModal from './BaseModal.vue';
|
||||
|
||||
const emit = defineEmits(['create']);
|
||||
@@ -30,10 +34,13 @@ const modal = ref(null);
|
||||
const clientName = ref('');
|
||||
const inputRef = ref(null);
|
||||
|
||||
// Same rule as the profiler API (without dots): 1-64 characters, no leading dash or underscore
|
||||
const NAME_RE = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
|
||||
const isValid = computed(() => NAME_RE.test(clientName.value));
|
||||
|
||||
const open = () => {
|
||||
clientName.value = '';
|
||||
modal.value.show();
|
||||
setTimeout(() => inputRef.value?.focus(), 500);
|
||||
modal.value.show(); // the input is focused on the opened event
|
||||
};
|
||||
|
||||
const close = () => {
|
||||
@@ -41,7 +48,7 @@ const close = () => {
|
||||
};
|
||||
|
||||
const confirm = () => {
|
||||
if (clientName.value) {
|
||||
if (isValid.value) {
|
||||
emit('create', clientName.value);
|
||||
close();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user