@quazardous/qdadm 2.33.1 → 2.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/components/dialogs/MultiStepDialog.vue +15 -12
- package/src/components/display/EntityTimeline.vue +9 -7
- package/src/components/display/LogStream.vue +11 -0
- package/src/components/layout/AppLayout.vue +88 -32
- package/src/components/layout/PageNav.vue +4 -2
- package/src/components/layout/defaults/DefaultUserInfo.vue +45 -37
- package/src/components/pages/NotFoundPage.vue +5 -3
- package/src/components/tasks/TaskDialog.vue +1 -1
- package/src/components/tasks/TaskHost.vue +2 -1
- package/src/composables/index.ts +1 -0
- package/src/composables/useBreadcrumb.ts +21 -14
- package/src/composables/useEntityItemFormPage.ts +9 -6
- package/src/composables/useEntityItemShowPage.ts +8 -6
- package/src/composables/useListPage.ts +9 -6
- package/src/composables/useNavContext.ts +4 -6
- package/src/composables/useUserBox.ts +119 -0
- package/src/i18n/__tests__/I18n.test.ts +14 -0
- package/src/i18n/defaults/__tests__/generated-sync.test.ts +2 -2
- package/src/i18n/defaults/core.en.generated.ts +24 -10
- package/src/i18n/defaults/core.en.yml +24 -10
- package/src/i18n/defaults/core.fr.generated.ts +24 -10
- package/src/i18n/defaults/core.fr.yml +24 -10
- package/src/i18n/useI18n.ts +12 -0
- package/src/index.ts +1 -0
- package/src/kernel/Kernel.types.ts +6 -1
- package/src/plugin.ts +6 -1
- package/src/tasks/taskStore.ts +22 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quazardous/qdadm",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.35.0",
|
|
4
4
|
"description": "Vue 3 framework for admin dashboards with PrimeVue",
|
|
5
5
|
"author": "quazardous",
|
|
6
6
|
"license": "MIT",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"dist/styles"
|
|
63
63
|
],
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@quazardous/qdcore": "^1.
|
|
65
|
+
"@quazardous/qdcore": "^1.3.0",
|
|
66
66
|
"@quazardous/qddebug": "^1.3.0",
|
|
67
67
|
"@quazardous/quarkernel": "^2.1.0",
|
|
68
68
|
"yaml": "^2.8.4"
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
* - loading: boolean - shows loading state on submit button
|
|
40
40
|
* - width: string - dialog width (default: '800px')
|
|
41
41
|
* - linear: boolean - require validation before next step (default: true)
|
|
42
|
-
* - submitLabel: string - label for submit button (default:
|
|
43
|
-
* - cancelLabel: string - label for cancel button (default:
|
|
44
|
-
* - nextLabel: string - label for next button (default:
|
|
45
|
-
* - backLabel: string - label for back button (default:
|
|
42
|
+
* - submitLabel: string - label for submit button (default: core.actions.submit)
|
|
43
|
+
* - cancelLabel: string - label for cancel button (default: core.actions.cancel)
|
|
44
|
+
* - nextLabel: string - label for next button (default: core.actions.next)
|
|
45
|
+
* - backLabel: string - label for back button (default: core.actions.back)
|
|
46
46
|
* - showBackOnFirst: boolean - show back button on first step (default: false)
|
|
47
47
|
* - hideStepIndicator: boolean - hide the step indicator (default: false)
|
|
48
48
|
*
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
import { computed, watch, type PropType } from 'vue'
|
|
60
60
|
import Dialog from 'primevue/dialog'
|
|
61
61
|
import QdButton from '../base/QdButton.vue'
|
|
62
|
+
import { useI18n } from '../../i18n/useI18n'
|
|
62
63
|
import Stepper from 'primevue/stepper'
|
|
63
64
|
import StepList from 'primevue/steplist'
|
|
64
65
|
import Step from 'primevue/step'
|
|
@@ -88,6 +89,8 @@ export interface SlotActions {
|
|
|
88
89
|
cancel: () => void
|
|
89
90
|
}
|
|
90
91
|
|
|
92
|
+
const { tOr } = useI18n()
|
|
93
|
+
|
|
91
94
|
const props = defineProps({
|
|
92
95
|
visible: {
|
|
93
96
|
type: Boolean,
|
|
@@ -120,19 +123,19 @@ const props = defineProps({
|
|
|
120
123
|
},
|
|
121
124
|
submitLabel: {
|
|
122
125
|
type: String,
|
|
123
|
-
default: '
|
|
126
|
+
default: ''
|
|
124
127
|
},
|
|
125
128
|
cancelLabel: {
|
|
126
129
|
type: String,
|
|
127
|
-
default: '
|
|
130
|
+
default: ''
|
|
128
131
|
},
|
|
129
132
|
nextLabel: {
|
|
130
133
|
type: String,
|
|
131
|
-
default: '
|
|
134
|
+
default: ''
|
|
132
135
|
},
|
|
133
136
|
backLabel: {
|
|
134
137
|
type: String,
|
|
135
|
-
default: '
|
|
138
|
+
default: ''
|
|
136
139
|
},
|
|
137
140
|
showBackOnFirst: {
|
|
138
141
|
type: Boolean,
|
|
@@ -286,7 +289,7 @@ const slotActions = computed<SlotActions>(() => ({
|
|
|
286
289
|
<!-- Back button -->
|
|
287
290
|
<QdButton
|
|
288
291
|
v-if="!isFirstStep || showBackOnFirst"
|
|
289
|
-
:label="backLabel"
|
|
292
|
+
:label="backLabel || tOr('core.actions.back', 'Back')"
|
|
290
293
|
icon="pi pi-arrow-left"
|
|
291
294
|
severity="secondary"
|
|
292
295
|
@click="goPrev"
|
|
@@ -295,7 +298,7 @@ const slotActions = computed<SlotActions>(() => ({
|
|
|
295
298
|
|
|
296
299
|
<!-- Cancel button -->
|
|
297
300
|
<QdButton
|
|
298
|
-
:label="cancelLabel"
|
|
301
|
+
:label="cancelLabel || tOr('core.actions.cancel', 'Cancel')"
|
|
299
302
|
severity="secondary"
|
|
300
303
|
@click="cancel"
|
|
301
304
|
:disabled="loading"
|
|
@@ -304,7 +307,7 @@ const slotActions = computed<SlotActions>(() => ({
|
|
|
304
307
|
<!-- Next button (not on last step) -->
|
|
305
308
|
<QdButton
|
|
306
309
|
v-if="!isLastStep"
|
|
307
|
-
:label="nextLabel"
|
|
310
|
+
:label="nextLabel || tOr('core.actions.next', 'Next')"
|
|
308
311
|
icon="pi pi-arrow-right"
|
|
309
312
|
iconPos="right"
|
|
310
313
|
@click="goNext"
|
|
@@ -314,7 +317,7 @@ const slotActions = computed<SlotActions>(() => ({
|
|
|
314
317
|
<!-- Submit button (only on last step) -->
|
|
315
318
|
<QdButton
|
|
316
319
|
v-if="isLastStep"
|
|
317
|
-
:label="submitLabel"
|
|
320
|
+
:label="submitLabel || tOr('core.actions.submit', 'Submit')"
|
|
318
321
|
icon="pi pi-check"
|
|
319
322
|
@click="submit"
|
|
320
323
|
:loading="loading"
|
|
@@ -258,20 +258,22 @@ const fullFormat = computed(() => new Intl.DateTimeFormat(locale.value, { dateSt
|
|
|
258
258
|
|
|
259
259
|
const rows = computed<Row[]>(() => {
|
|
260
260
|
const visible = chronological.value.filter((e) => !e.item.actor || !hiddenActors.value.has(e.item.actor))
|
|
261
|
-
const
|
|
262
|
-
entry,
|
|
263
|
-
since: props.gaps === true && i > 0 ? duration(entry.time - visible[i - 1]!.time) : null,
|
|
264
|
-
}))
|
|
265
|
-
const ordered = currentOrder.value === 'desc' ? [...withSince].reverse() : withSince
|
|
261
|
+
const ordered = currentOrder.value === 'desc' ? [...visible].reverse() : visible
|
|
266
262
|
const out: Row[] = []
|
|
267
263
|
let lastDay = ''
|
|
268
|
-
|
|
264
|
+
let previous: (typeof visible)[number] | null = null
|
|
265
|
+
for (const entry of ordered) {
|
|
269
266
|
const day = dayFormat.value.format(entry.time)
|
|
270
|
-
|
|
267
|
+
const newDay = day !== lastDay
|
|
268
|
+
if (newDay) {
|
|
271
269
|
out.push({ type: 'day', key: `day:${day}`, day })
|
|
272
270
|
lastDay = day
|
|
273
271
|
}
|
|
272
|
+
// The gap sits above an event and reads from the row above it, in either
|
|
273
|
+
// order. Under a day separator it is left out: the date says it.
|
|
274
|
+
const since = props.gaps === true && previous && !newDay ? duration(Math.abs(entry.time - previous.time)) : null
|
|
274
275
|
out.push({ type: 'event', key: entry.key, entry, since })
|
|
276
|
+
previous = entry
|
|
275
277
|
}
|
|
276
278
|
return out
|
|
277
279
|
})
|
|
@@ -58,6 +58,11 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
58
58
|
maxLines: 100_000,
|
|
59
59
|
})
|
|
60
60
|
|
|
61
|
+
const emit = defineEmits<{
|
|
62
|
+
/** The source reported the end of the log. */
|
|
63
|
+
done: []
|
|
64
|
+
}>()
|
|
65
|
+
|
|
61
66
|
const { t } = useI18n()
|
|
62
67
|
|
|
63
68
|
const log: UseLogStreamReturn =
|
|
@@ -272,6 +277,12 @@ function download(): void {
|
|
|
272
277
|
|
|
273
278
|
// --- Status ---
|
|
274
279
|
|
|
280
|
+
watch(
|
|
281
|
+
() => log.status.value,
|
|
282
|
+
(status) => status === 'done' && emit('done'),
|
|
283
|
+
{ immediate: true }
|
|
284
|
+
)
|
|
285
|
+
|
|
275
286
|
const statusLabel = computed(() => {
|
|
276
287
|
switch (log.status.value) {
|
|
277
288
|
case 'streaming':
|
|
@@ -16,9 +16,10 @@ import { ref, watch, onMounted, onUnmounted, computed, inject, provide, useSlots
|
|
|
16
16
|
import { SIDEBAR_COLLAPSED_KEY } from '../../composables/useSidebarState'
|
|
17
17
|
import { RouterLink, RouterView, useRouter, useRoute } from 'vue-router'
|
|
18
18
|
import { useNavigation, type NavSection } from '../../composables/useNavigation'
|
|
19
|
-
import { prettifyRole } from '../../utils/formatters'
|
|
20
19
|
import { useApp } from '../../composables/useApp'
|
|
21
20
|
import { useAuth } from '../../composables/useAuth'
|
|
21
|
+
import { useUserBox } from '../../composables/useUserBox'
|
|
22
|
+
import { useI18n } from '../../i18n/useI18n'
|
|
22
23
|
import { useGuardDialog, GUARD_DIALOG_HOST } from '../../composables/useGuardStore'
|
|
23
24
|
import { useNavContext, type BreadcrumbItem, type NavLinkItem } from '../../composables/useNavContext'
|
|
24
25
|
import QdButton from '../base/QdButton.vue'
|
|
@@ -45,14 +46,6 @@ interface SignalBus {
|
|
|
45
46
|
[key: string]: unknown
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
interface UserData {
|
|
49
|
-
username?: string
|
|
50
|
-
name?: string
|
|
51
|
-
email?: string
|
|
52
|
-
role?: string
|
|
53
|
-
[key: string]: unknown
|
|
54
|
-
}
|
|
55
|
-
|
|
56
49
|
const features = inject<FeaturesConfig>('qdadmFeatures', { poweredBy: true, breadcrumb: true })
|
|
57
50
|
const homeRoute = inject<string>('qdadmHomeRoute', 'home')
|
|
58
51
|
|
|
@@ -68,7 +61,9 @@ const app = useApp()
|
|
|
68
61
|
// nested in a plain object stays a ref object (always truthy) in v-if (#1382)
|
|
69
62
|
const appVersion = app.version
|
|
70
63
|
const { navSections, isNavActive, sectionHasActiveItem, handleNavClick } = useNavigation()
|
|
71
|
-
const {
|
|
64
|
+
const { logout, authEnabled } = useAuth()
|
|
65
|
+
const { displayName: userDisplayName, subtitle: userSubtitle, initials: userInitials, avatarUrl, avatarFailed, userRoute, userLink } = useUserBox()
|
|
66
|
+
const { tOr } = useI18n()
|
|
72
67
|
const signals = inject<SignalBus | null>('qdadmSignals', null)
|
|
73
68
|
|
|
74
69
|
// LocalStorage key for collapsed sections state (namespaced by app)
|
|
@@ -201,25 +196,6 @@ watch(() => route.path, () => {
|
|
|
201
196
|
}
|
|
202
197
|
})
|
|
203
198
|
|
|
204
|
-
const userInitials = computed<string>(() => {
|
|
205
|
-
const userData = user.value as UserData | null
|
|
206
|
-
const username = userData?.username
|
|
207
|
-
if (!username) return '?'
|
|
208
|
-
return username.substring(0, 2).toUpperCase()
|
|
209
|
-
})
|
|
210
|
-
|
|
211
|
-
const userDisplayName = computed<string>(() => {
|
|
212
|
-
const userData = user.value as UserData | null
|
|
213
|
-
return userData?.username || userData?.name || 'User'
|
|
214
|
-
})
|
|
215
|
-
|
|
216
|
-
const userSubtitle = computed<string>(() => {
|
|
217
|
-
const userData = user.value as UserData | null
|
|
218
|
-
if (userData?.email) return userData.email
|
|
219
|
-
// raw ROLE_* constants are ugly by default — prettify (#1388)
|
|
220
|
-
return userData?.role ? prettifyRole(userData.role) : ''
|
|
221
|
-
})
|
|
222
|
-
|
|
223
199
|
async function handleLogout(): Promise<void> {
|
|
224
200
|
logout()
|
|
225
201
|
await router.push({ name: 'login' })
|
|
@@ -350,16 +326,47 @@ const showBreadcrumb = computed<boolean>(() => {
|
|
|
350
326
|
<!-- Running tasks (#4114): shown while there is one -->
|
|
351
327
|
<TaskTray />
|
|
352
328
|
|
|
329
|
+
<!-- With app.userRoute (#4157): name and avatar open the profile, only the glyph logs out -->
|
|
330
|
+
<SidebarBox
|
|
331
|
+
v-if="authEnabled && userRoute"
|
|
332
|
+
id="user-zone"
|
|
333
|
+
class="user-zone--linked"
|
|
334
|
+
:title="userDisplayName"
|
|
335
|
+
:subtitle="userSubtitle"
|
|
336
|
+
>
|
|
337
|
+
<template #icon>
|
|
338
|
+
<button
|
|
339
|
+
type="button"
|
|
340
|
+
class="user-zone-logout"
|
|
341
|
+
:aria-label="tOr('core.actions.logout', 'Logout')"
|
|
342
|
+
v-tooltip.top="tOr('core.actions.logout', 'Logout')"
|
|
343
|
+
@click="handleLogout"
|
|
344
|
+
>
|
|
345
|
+
<i class="pi pi-sign-out"></i>
|
|
346
|
+
</button>
|
|
347
|
+
</template>
|
|
348
|
+
<component
|
|
349
|
+
:is="userLink!.is === 'a' ? 'a' : RouterLink"
|
|
350
|
+
v-bind="userLink!.attrs"
|
|
351
|
+
class="user-zone-link"
|
|
352
|
+
:aria-label="`${userDisplayName} — ${tOr('core.actions.profile', 'My profile')}`"
|
|
353
|
+
v-tooltip.top="tOr('core.actions.profile', 'My profile')"
|
|
354
|
+
>
|
|
355
|
+
<img v-if="avatarUrl" class="user-avatar user-avatar--image" :src="avatarUrl" alt="" referrerpolicy="no-referrer" @error="avatarFailed" />
|
|
356
|
+
<span v-else class="user-avatar">{{ userInitials }}</span>
|
|
357
|
+
</component>
|
|
358
|
+
</SidebarBox>
|
|
353
359
|
<SidebarBox
|
|
354
|
-
v-if="authEnabled"
|
|
360
|
+
v-else-if="authEnabled"
|
|
355
361
|
id="user-zone"
|
|
356
362
|
icon="pi-sign-out"
|
|
357
363
|
:title="userDisplayName"
|
|
358
364
|
:subtitle="userSubtitle"
|
|
359
365
|
@click="handleLogout"
|
|
360
|
-
v-tooltip.top="'Logout'"
|
|
366
|
+
v-tooltip.top="tOr('core.actions.logout', 'Logout')"
|
|
361
367
|
>
|
|
362
|
-
<
|
|
368
|
+
<img v-if="avatarUrl" class="user-avatar user-avatar--image" :src="avatarUrl" alt="" referrerpolicy="no-referrer" @error="avatarFailed" />
|
|
369
|
+
<div v-else class="user-avatar">{{ userInitials }}</div>
|
|
363
370
|
</SidebarBox>
|
|
364
371
|
|
|
365
372
|
<SidebarBox v-if="features.poweredBy" id="powered-by">
|
|
@@ -665,7 +672,55 @@ const showBreadcrumb = computed<boolean>(() => {
|
|
|
665
672
|
transition: opacity 0.1s ease 0.2s;
|
|
666
673
|
}
|
|
667
674
|
|
|
675
|
+
#user-zone .user-avatar--image {
|
|
676
|
+
object-fit: cover;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
/* With app.userRoute (#4157): the link covers the text and the avatar,
|
|
680
|
+
the glyph on the left stays the logout button */
|
|
681
|
+
#user-zone.user-zone--linked {
|
|
682
|
+
cursor: default;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
#user-zone .user-zone-link {
|
|
686
|
+
position: absolute;
|
|
687
|
+
inset: 0 0 0 2.25rem;
|
|
688
|
+
color: inherit;
|
|
689
|
+
border-radius: var(--fad-radius-sm, 4px);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
#user-zone .user-zone-link:focus-visible {
|
|
693
|
+
outline: 2px solid var(--p-primary-color, #3b82f6);
|
|
694
|
+
outline-offset: -2px;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
#user-zone.user-zone--linked:has(.user-zone-link.router-link-active) {
|
|
698
|
+
background: var(--p-surface-700, #334155);
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
#user-zone .user-zone-logout {
|
|
702
|
+
width: 100%;
|
|
703
|
+
height: 100%;
|
|
704
|
+
padding: 0;
|
|
705
|
+
border: none;
|
|
706
|
+
border-radius: 50%;
|
|
707
|
+
background: transparent;
|
|
708
|
+
color: inherit;
|
|
709
|
+
font: inherit;
|
|
710
|
+
cursor: pointer;
|
|
711
|
+
display: flex;
|
|
712
|
+
align-items: center;
|
|
713
|
+
justify-content: center;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
#user-zone .user-zone-logout:hover,
|
|
717
|
+
#user-zone .user-zone-logout:focus-visible {
|
|
718
|
+
color: var(--p-surface-0, #fff);
|
|
719
|
+
background: var(--p-surface-600, #475569);
|
|
720
|
+
}
|
|
721
|
+
|
|
668
722
|
/* Avatar: disappear IMMEDIATELY when closing */
|
|
723
|
+
.sidebar--collapsed #user-zone .user-zone-link,
|
|
669
724
|
.sidebar--collapsed #user-zone .user-avatar {
|
|
670
725
|
opacity: 0;
|
|
671
726
|
visibility: hidden;
|
|
@@ -974,6 +1029,7 @@ const showBreadcrumb = computed<boolean>(() => {
|
|
|
974
1029
|
}
|
|
975
1030
|
|
|
976
1031
|
.sidebar.sidebar--collapsed #user-zone .user-avatar,
|
|
1032
|
+
.sidebar.sidebar--collapsed #user-zone .user-zone-link,
|
|
977
1033
|
.sidebar.sidebar--collapsed .sidebar-box-content {
|
|
978
1034
|
opacity: 1;
|
|
979
1035
|
width: auto;
|
|
@@ -19,6 +19,7 @@ import { computed, watch, inject, type Ref } from 'vue'
|
|
|
19
19
|
import { useRoute, useRouter } from 'vue-router'
|
|
20
20
|
import { getSiblingRoutes, getChildRoutes, routeParamsSatisfied, type ModuleRoute, type ParentConfig } from '../../module/moduleRegistry'
|
|
21
21
|
import { useOrchestrator } from '../../orchestrator/useOrchestrator.js'
|
|
22
|
+
import { useI18n } from '../../i18n/useI18n'
|
|
22
23
|
import type { EntityManager } from '../../entity/EntityManager'
|
|
23
24
|
import type { EntityRecord } from '../../types'
|
|
24
25
|
|
|
@@ -39,6 +40,7 @@ const props = defineProps<{
|
|
|
39
40
|
const route = useRoute()
|
|
40
41
|
const router = useRouter()
|
|
41
42
|
const { getManager } = useOrchestrator()
|
|
43
|
+
const { tOr } = useI18n()
|
|
42
44
|
|
|
43
45
|
// Parent config from route meta
|
|
44
46
|
const parentConfig = computed<ParentConfig | undefined>(() => route.meta?.parent as ParentConfig | undefined)
|
|
@@ -156,7 +158,7 @@ const allNavlinks = computed<NavLink[]>(() => {
|
|
|
156
158
|
|
|
157
159
|
// Details link to parent item page
|
|
158
160
|
const detailsLink: NavLink = {
|
|
159
|
-
label: 'Details',
|
|
161
|
+
label: tOr('breadcrumb.details', 'Details'),
|
|
160
162
|
to: { name: parentRouteName ?? undefined, params: { [parentManager.idField]: parentId } },
|
|
161
163
|
active: isOnParentRoute
|
|
162
164
|
}
|
|
@@ -172,7 +174,7 @@ const allNavlinks = computed<NavLink[]>(() => {
|
|
|
172
174
|
// Details link is optional since breadcrumb already shows current page
|
|
173
175
|
if (props.showDetailsLink) {
|
|
174
176
|
const detailsLink: NavLink = {
|
|
175
|
-
label: 'Details',
|
|
177
|
+
label: tOr('breadcrumb.details', 'Details'),
|
|
176
178
|
to: { name: route.name as string | undefined, params: route.params as Record<string, unknown> },
|
|
177
179
|
active: true
|
|
178
180
|
}
|
|
@@ -7,41 +7,16 @@
|
|
|
7
7
|
*
|
|
8
8
|
* This component is used when auth is enabled.
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
11
|
-
import { useRouter } from 'vue-router'
|
|
12
|
-
import { prettifyRole } from '../../../utils/formatters'
|
|
10
|
+
import { useRouter, RouterLink } from 'vue-router'
|
|
13
11
|
import { useAuth } from '../../../composables/useAuth'
|
|
12
|
+
import { useUserBox } from '../../../composables/useUserBox'
|
|
13
|
+
import { useI18n } from '../../../i18n/useI18n'
|
|
14
14
|
import QdButton from '../../base/QdButton.vue'
|
|
15
15
|
|
|
16
|
-
interface UserData {
|
|
17
|
-
username?: string
|
|
18
|
-
name?: string
|
|
19
|
-
email?: string
|
|
20
|
-
role?: string
|
|
21
|
-
[key: string]: unknown
|
|
22
|
-
}
|
|
23
|
-
|
|
24
16
|
const router = useRouter()
|
|
25
|
-
const {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const userData = computed<UserData | null>(() => user.value as UserData | null)
|
|
29
|
-
|
|
30
|
-
const userInitials: ComputedRef<string> = computed(() => {
|
|
31
|
-
const username = userData.value?.username
|
|
32
|
-
if (!username) return '?'
|
|
33
|
-
return username.substring(0, 2).toUpperCase()
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
const userDisplayName: ComputedRef<string> = computed(() => {
|
|
37
|
-
return userData.value?.username || userData.value?.name || 'User'
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
const userSubtitle: ComputedRef<string> = computed(() => {
|
|
41
|
-
if (userData.value?.email) return userData.value.email
|
|
42
|
-
// raw ROLE_* constants are ugly by default — prettify (#1388)
|
|
43
|
-
return userData.value?.role ? prettifyRole(userData.value.role) : ''
|
|
44
|
-
})
|
|
17
|
+
const { logout, authEnabled } = useAuth()
|
|
18
|
+
const { displayName: userDisplayName, subtitle: userSubtitle, initials: userInitials, avatarUrl, avatarFailed, userLink } = useUserBox()
|
|
19
|
+
const { tOr } = useI18n()
|
|
45
20
|
|
|
46
21
|
function handleLogout(): void {
|
|
47
22
|
logout()
|
|
@@ -51,18 +26,28 @@ function handleLogout(): void {
|
|
|
51
26
|
|
|
52
27
|
<template>
|
|
53
28
|
<div v-if="authEnabled" class="default-user-info">
|
|
54
|
-
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
29
|
+
<!-- With app.userRoute (#4157): avatar and name open the profile -->
|
|
30
|
+
<component
|
|
31
|
+
:is="!userLink ? 'div' : userLink.is === 'a' ? 'a' : RouterLink"
|
|
32
|
+
v-bind="userLink ? { ...userLink.attrs, title: tOr('core.actions.profile', 'My profile') } : {}"
|
|
33
|
+
class="user-identity"
|
|
34
|
+
:class="{ 'user-identity--link': userLink }"
|
|
35
|
+
>
|
|
36
|
+
<img v-if="avatarUrl" class="user-avatar user-avatar--image" :src="avatarUrl" alt="" referrerpolicy="no-referrer" @error="avatarFailed" />
|
|
37
|
+
<div v-else class="user-avatar">{{ userInitials }}</div>
|
|
38
|
+
<div class="user-details">
|
|
39
|
+
<div class="user-name">{{ userDisplayName }}</div>
|
|
40
|
+
<div class="user-role">{{ userSubtitle }}</div>
|
|
41
|
+
</div>
|
|
42
|
+
</component>
|
|
59
43
|
<QdButton
|
|
60
44
|
icon="pi pi-sign-out"
|
|
61
45
|
severity="secondary"
|
|
62
46
|
text
|
|
63
47
|
rounded
|
|
48
|
+
:aria-label="tOr('core.actions.logout', 'Logout')"
|
|
64
49
|
@click="handleLogout"
|
|
65
|
-
v-tooltip.top="'Logout'"
|
|
50
|
+
v-tooltip.top="tOr('core.actions.logout', 'Logout')"
|
|
66
51
|
/>
|
|
67
52
|
</div>
|
|
68
53
|
</template>
|
|
@@ -80,7 +65,26 @@ function handleLogout(): void {
|
|
|
80
65
|
border-top: 1px solid var(--p-surface-700, #334155);
|
|
81
66
|
}
|
|
82
67
|
|
|
68
|
+
.user-identity {
|
|
69
|
+
display: flex;
|
|
70
|
+
align-items: center;
|
|
71
|
+
gap: 0.75rem;
|
|
72
|
+
flex: 1;
|
|
73
|
+
min-width: 0;
|
|
74
|
+
color: inherit;
|
|
75
|
+
text-decoration: none;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.user-identity--link {
|
|
79
|
+
border-radius: 6px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.user-identity--link:hover .user-name {
|
|
83
|
+
text-decoration: underline;
|
|
84
|
+
}
|
|
85
|
+
|
|
83
86
|
.user-avatar {
|
|
87
|
+
flex-shrink: 0;
|
|
84
88
|
width: 36px;
|
|
85
89
|
height: 36px;
|
|
86
90
|
border-radius: 50%;
|
|
@@ -93,6 +97,10 @@ function handleLogout(): void {
|
|
|
93
97
|
color: var(--p-surface-0, white);
|
|
94
98
|
}
|
|
95
99
|
|
|
100
|
+
.user-avatar--image {
|
|
101
|
+
object-fit: cover;
|
|
102
|
+
}
|
|
103
|
+
|
|
96
104
|
.user-details {
|
|
97
105
|
flex: 1;
|
|
98
106
|
min-width: 0;
|
|
@@ -6,8 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { computed, type ComputedRef } from 'vue'
|
|
8
8
|
import { useRouter, type RouteRecordName } from 'vue-router'
|
|
9
|
+
import { useI18n } from '../../i18n/useI18n'
|
|
9
10
|
|
|
10
11
|
const router = useRouter()
|
|
12
|
+
const { tOr } = useI18n()
|
|
11
13
|
|
|
12
14
|
const homeRoute: ComputedRef<RouteRecordName | string> = computed(() => {
|
|
13
15
|
// Find home route (first route or named 'home'/'dashboard')
|
|
@@ -29,11 +31,11 @@ function goHome(): void {
|
|
|
29
31
|
<div class="not-found-page">
|
|
30
32
|
<div class="not-found-content">
|
|
31
33
|
<div class="not-found-code">404</div>
|
|
32
|
-
<h1>Page not found</h1>
|
|
33
|
-
<p>The page you're looking for doesn't exist or has been moved
|
|
34
|
+
<h1>{{ tOr('core.notFound.title', 'Page not found') }}</h1>
|
|
35
|
+
<p>{{ tOr('core.notFound.message', "The page you're looking for doesn't exist or has been moved.") }}</p>
|
|
34
36
|
<button class="home-link" @click="goHome">
|
|
35
37
|
<i class="pi pi-home"></i>
|
|
36
|
-
Back to Home
|
|
38
|
+
{{ tOr('core.notFound.home', 'Back to Home') }}
|
|
37
39
|
</button>
|
|
38
40
|
</div>
|
|
39
41
|
</div>
|
|
@@ -69,7 +69,7 @@ const elapsed = computed(() => {
|
|
|
69
69
|
<div v-if="run.step" class="qd-task-step">{{ run.step }}</div>
|
|
70
70
|
|
|
71
71
|
<LogStream v-if="logSource" :key="run.id" class="qd-task-log" :source="logSource" height="16rem"
|
|
72
|
-
error-pattern="error|fatal|failed" />
|
|
72
|
+
error-pattern="error|fatal|failed" @done="store.poke(run.id)" />
|
|
73
73
|
|
|
74
74
|
<div v-if="run.status === 'failed' && run.error" class="qd-task-error"><i class="pi pi-exclamation-triangle" /> {{ run.error }}</div>
|
|
75
75
|
<div v-else-if="!final && run.error" class="qd-task-warning">{{ t('core.task.readError', { error: run.error }) }}</div>
|
|
@@ -27,12 +27,13 @@ const typed = ref('')
|
|
|
27
27
|
watch(pending, () => (typed.value = ''))
|
|
28
28
|
const expected = computed(() => pending.value?.confirm.typed ?? null)
|
|
29
29
|
const confirmable = computed(() => expected.value === null || typed.value === expected.value)
|
|
30
|
+
const severity = computed(() => pending.value?.confirm.severity ?? (expected.value !== null ? 'danger' : 'primary'))
|
|
30
31
|
</script>
|
|
31
32
|
|
|
32
33
|
<template>
|
|
33
34
|
<TaskDialog :run-id="store.state.openId" @close="store.open(null)" />
|
|
34
35
|
<SimpleDialog :visible="!!pending" :title="pending?.label ?? ''" :confirm-label="pending?.confirm.accept ?? t('core.task.start')"
|
|
35
|
-
confirm-severity="
|
|
36
|
+
:confirm-severity="severity" :confirm-disabled="!confirmable" :cancel-label="t('core.task.dontStart')"
|
|
36
37
|
@confirm="store.answerConfirm(true)" @cancel="store.answerConfirm(false)"
|
|
37
38
|
@update:visible="(v: boolean) => !v && pending && store.answerConfirm(false)">
|
|
38
39
|
<p v-if="pending?.confirm.message" class="qd-task-confirm-message">{{ pending.confirm.message }}</p>
|
package/src/composables/index.ts
CHANGED
|
@@ -50,6 +50,7 @@ export {
|
|
|
50
50
|
export { usePageTitle, type UsePageTitleReturn, type TitleParts, type TitleInput } from './usePageTitle'
|
|
51
51
|
export { useApp, type UseAppReturn } from './useApp'
|
|
52
52
|
export { useAuth, type UseAuthReturn } from './useAuth'
|
|
53
|
+
export { useUserBox, resolveUserAvatar, isExternalUserLink, type UseUserBoxReturn, type UserAvatarResolver, type UserBoxUser } from './useUserBox'
|
|
53
54
|
export { useSecurity, type UseSecurityReturn } from './useSecurity'
|
|
54
55
|
export {
|
|
55
56
|
useEntityItemPage,
|
|
@@ -2,6 +2,7 @@ import { computed, inject, type ComputedRef, type Ref } from 'vue'
|
|
|
2
2
|
import { useRouter } from 'vue-router'
|
|
3
3
|
import { useSemanticBreadcrumb, type SemanticBreadcrumbItem } from './useSemanticBreadcrumb'
|
|
4
4
|
import { useStackHydrator, type HydratedLevel } from '../chain/useStackHydrator'
|
|
5
|
+
import { useI18n } from '../i18n/useI18n'
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Breadcrumb display item
|
|
@@ -59,14 +60,21 @@ export function useBreadcrumb(options: UseBreadcrumbOptions = {}): UseBreadcrumb
|
|
|
59
60
|
// Get hydrator for parent entity labels
|
|
60
61
|
const hydrator = useStackHydrator()
|
|
61
62
|
|
|
62
|
-
// Default
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
// Default labels, from the i18n catalog (a custom labelMap entry wins)
|
|
64
|
+
const { tOr } = useI18n()
|
|
65
|
+
const defaultLabels: Record<string, [string, string]> = {
|
|
66
|
+
home: ['breadcrumb.home', 'Home'],
|
|
67
|
+
dashboard: ['breadcrumb.dashboard', 'Dashboard'],
|
|
68
|
+
create: ['core.actions.create', 'Create'],
|
|
69
|
+
edit: ['core.actions.edit', 'Edit'],
|
|
70
|
+
show: ['core.actions.view', 'View'],
|
|
71
|
+
delete: ['core.actions.delete', 'Delete'],
|
|
72
|
+
}
|
|
73
|
+
function label(key: string): string | undefined {
|
|
74
|
+
const custom = options.labelMap?.[key]
|
|
75
|
+
if (custom) return custom
|
|
76
|
+
const def = defaultLabels[key]
|
|
77
|
+
return def ? tOr(def[0], def[1]) : undefined
|
|
70
78
|
}
|
|
71
79
|
|
|
72
80
|
// Default icon mapping for entities
|
|
@@ -80,7 +88,6 @@ export function useBreadcrumb(options: UseBreadcrumbOptions = {}): UseBreadcrumb
|
|
|
80
88
|
}
|
|
81
89
|
|
|
82
90
|
// Merge with custom mappings
|
|
83
|
-
const labelMap = { ...defaultLabelMap, ...options.labelMap }
|
|
84
91
|
const iconMap = { ...defaultIconMap, ...options.iconMap }
|
|
85
92
|
|
|
86
93
|
/**
|
|
@@ -133,7 +140,7 @@ export function useBreadcrumb(options: UseBreadcrumbOptions = {}): UseBreadcrumb
|
|
|
133
140
|
if (item.kind === 'route') {
|
|
134
141
|
// Generic route
|
|
135
142
|
const routeName = item.route!
|
|
136
|
-
displayItem.label = item.label ||
|
|
143
|
+
displayItem.label = item.label || label(routeName) || capitalize(routeName)
|
|
137
144
|
displayItem.to = isLast ? null : routeExists(routeName) ? { name: routeName } : null
|
|
138
145
|
if (routeName === 'home') {
|
|
139
146
|
displayItem.icon = 'pi pi-home'
|
|
@@ -144,7 +151,7 @@ export function useBreadcrumb(options: UseBreadcrumbOptions = {}): UseBreadcrumb
|
|
|
144
151
|
|
|
145
152
|
if (item.kind === 'entity-list') {
|
|
146
153
|
// Entity list - use plural label
|
|
147
|
-
displayItem.label =
|
|
154
|
+
displayItem.label = label(entityName) || capitalize(entityName)
|
|
148
155
|
displayItem.icon = index === 1 ? iconMap[entityName] || null : null
|
|
149
156
|
const routeName = getEntityRouteName(entityName, item.kind)
|
|
150
157
|
displayItem.to = isLast ? null : routeExists(routeName) ? { name: routeName } : null
|
|
@@ -177,7 +184,7 @@ export function useBreadcrumb(options: UseBreadcrumbOptions = {}): UseBreadcrumb
|
|
|
177
184
|
}
|
|
178
185
|
} else if (item.kind === 'entity-create') {
|
|
179
186
|
// Create page - label as action
|
|
180
|
-
displayItem.label =
|
|
187
|
+
displayItem.label = label('create')!
|
|
181
188
|
}
|
|
182
189
|
}
|
|
183
190
|
|
|
@@ -190,7 +197,7 @@ export function useBreadcrumb(options: UseBreadcrumbOptions = {}): UseBreadcrumb
|
|
|
190
197
|
function getHomeItem(): BreadcrumbDisplayItem | null {
|
|
191
198
|
if (!homeRouteName || !routeExists(homeRouteName)) return null
|
|
192
199
|
return {
|
|
193
|
-
label:
|
|
200
|
+
label: label('home')!,
|
|
194
201
|
to: { name: homeRouteName },
|
|
195
202
|
icon: 'pi pi-home',
|
|
196
203
|
}
|
|
@@ -237,7 +244,7 @@ export function useBreadcrumb(options: UseBreadcrumbOptions = {}): UseBreadcrumb
|
|
|
237
244
|
*/
|
|
238
245
|
function setBreadcrumb(items: BreadcrumbDisplayItem[]): BreadcrumbDisplayItem[] {
|
|
239
246
|
const homeItem: BreadcrumbDisplayItem = {
|
|
240
|
-
label:
|
|
247
|
+
label: label('home')!,
|
|
241
248
|
to: { name: homeRouteName! },
|
|
242
249
|
icon: 'pi pi-home',
|
|
243
250
|
}
|