@quazardous/qdadm 2.40.0 → 2.42.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.
@@ -93,6 +93,9 @@ export default `core:
93
93
  wrap: Wrap long lines
94
94
  follow: Follow the end of the log
95
95
  download: Download the log
96
+ copy: Copy the whole log
97
+ copied: "Copied ({count} line) | Copied ({count} lines)"
98
+ copyFailed: "Copy failed: {error}"
96
99
  newLines: "{count} new line, resume | {count} new lines, resume"
97
100
  empty: No output yet
98
101
  # EntityTimeline (#4111)
@@ -182,6 +185,8 @@ export default `core:
182
185
  noSso: No sign-in flow configured for this button
183
186
  # CardsDashboard (#4320)
184
187
  cardsDashboard:
188
+ saveFailed: Could not save the arrangement
189
+ saveFailedDetail: It stays as shown; try again.
185
190
  customise: Customise
186
191
  done: Done
187
192
  reset: Reset
@@ -204,6 +209,39 @@ export default `core:
204
209
  trayView: Show hidden cards as
205
210
  viewCards: Cards
206
211
  viewCompact: Compact
212
+ # SessionsModule (#4336)
213
+ sessions:
214
+ title: Sessions
215
+ banner: "Also signed in: {list}"
216
+ bannerOne: "{name} (since {since})"
217
+ present: Signed in now
218
+ refresh: Refresh
219
+ nobody: Nobody is signed in.
220
+ who: Who
221
+ via: Via
222
+ since: Since
223
+ seen: Last seen
224
+ tabs: Tabs
225
+ origin: Origin
226
+ mine: you
227
+ close: Close
228
+ closeTitle: "Close the session of {name}"
229
+ reasonPrompt: Why? It goes into the history.
230
+ cancel: Cancel
231
+ history: History
232
+ noHistory: No history yet.
233
+ when: When
234
+ event:
235
+ login: Signed in
236
+ logout: Signed out
237
+ refused: Refused
238
+ closed: Closed
239
+ expired: Expired
240
+ by: By
241
+ reason: Reason
242
+ source: Source
243
+ newer: Newer
244
+ older: Older
207
245
  # NotificationPanel and NotificationBadge (#4171)
208
246
  notifications:
209
247
  title: Notifications
@@ -91,6 +91,9 @@ core:
91
91
  wrap: Wrap long lines
92
92
  follow: Follow the end of the log
93
93
  download: Download the log
94
+ copy: Copy the whole log
95
+ copied: "Copied ({count} line) | Copied ({count} lines)"
96
+ copyFailed: "Copy failed: {error}"
94
97
  newLines: "{count} new line, resume | {count} new lines, resume"
95
98
  empty: No output yet
96
99
  # EntityTimeline (#4111)
@@ -180,6 +183,8 @@ core:
180
183
  noSso: No sign-in flow configured for this button
181
184
  # CardsDashboard (#4320)
182
185
  cardsDashboard:
186
+ saveFailed: Could not save the arrangement
187
+ saveFailedDetail: It stays as shown; try again.
183
188
  customise: Customise
184
189
  done: Done
185
190
  reset: Reset
@@ -202,6 +207,39 @@ core:
202
207
  trayView: Show hidden cards as
203
208
  viewCards: Cards
204
209
  viewCompact: Compact
210
+ # SessionsModule (#4336)
211
+ sessions:
212
+ title: Sessions
213
+ banner: "Also signed in: {list}"
214
+ bannerOne: "{name} (since {since})"
215
+ present: Signed in now
216
+ refresh: Refresh
217
+ nobody: Nobody is signed in.
218
+ who: Who
219
+ via: Via
220
+ since: Since
221
+ seen: Last seen
222
+ tabs: Tabs
223
+ origin: Origin
224
+ mine: you
225
+ close: Close
226
+ closeTitle: "Close the session of {name}"
227
+ reasonPrompt: Why? It goes into the history.
228
+ cancel: Cancel
229
+ history: History
230
+ noHistory: No history yet.
231
+ when: When
232
+ event:
233
+ login: Signed in
234
+ logout: Signed out
235
+ refused: Refused
236
+ closed: Closed
237
+ expired: Expired
238
+ by: By
239
+ reason: Reason
240
+ source: Source
241
+ newer: Newer
242
+ older: Older
205
243
  # NotificationPanel and NotificationBadge (#4171)
206
244
  notifications:
207
245
  title: Notifications
@@ -93,6 +93,9 @@ export default `core:
93
93
  wrap: Couper les lignes longues
94
94
  follow: Suivre la fin du log
95
95
  download: Télécharger le log
96
+ copy: Copier tout le log
97
+ copied: "Copié ({count} ligne) | Copié ({count} lignes)"
98
+ copyFailed: "Échec de la copie : {error}"
96
99
  newLines: "{count} nouvelle ligne, reprendre | {count} nouvelles lignes, reprendre"
97
100
  empty: Rien pour l'instant
98
101
  # EntityTimeline (#4111)
@@ -182,6 +185,8 @@ export default `core:
182
185
  noSso: Aucun parcours de connexion configuré pour ce bouton
183
186
  # CardsDashboard (#4320)
184
187
  cardsDashboard:
188
+ saveFailed: La disposition n'a pas pu être enregistrée
189
+ saveFailedDetail: Elle reste telle qu'affichée ; réessayez.
185
190
  customise: Personnaliser
186
191
  done: Terminé
187
192
  reset: Réinitialiser
@@ -204,6 +209,39 @@ export default `core:
204
209
  trayView: Afficher les cartes masquées en
205
210
  viewCards: Cartes
206
211
  viewCompact: Compact
212
+ # SessionsModule (#4336)
213
+ sessions:
214
+ title: Sessions
215
+ banner: "Aussi connecté : {list}"
216
+ bannerOne: "{name} (depuis {since})"
217
+ present: Connectés maintenant
218
+ refresh: Rafraîchir
219
+ nobody: Personne n'est connecté.
220
+ who: Qui
221
+ via: Via
222
+ since: Depuis
223
+ seen: Vu
224
+ tabs: Onglets
225
+ origin: Origine
226
+ mine: vous
227
+ close: Fermer
228
+ closeTitle: "Fermer la session de {name}"
229
+ reasonPrompt: Pourquoi ? Le motif va dans l'historique.
230
+ cancel: Annuler
231
+ history: Historique
232
+ noHistory: Pas encore d'historique.
233
+ when: Quand
234
+ event:
235
+ login: Connexion
236
+ logout: Déconnexion
237
+ refused: Refus
238
+ closed: Fermeture
239
+ expired: Expiration
240
+ by: Par
241
+ reason: Motif
242
+ source: Source
243
+ newer: Plus récent
244
+ older: Plus ancien
207
245
  # NotificationPanel and NotificationBadge (#4171)
208
246
  notifications:
209
247
  title: Notifications
@@ -91,6 +91,9 @@ core:
91
91
  wrap: Couper les lignes longues
92
92
  follow: Suivre la fin du log
93
93
  download: Télécharger le log
94
+ copy: Copier tout le log
95
+ copied: "Copié ({count} ligne) | Copié ({count} lignes)"
96
+ copyFailed: "Échec de la copie : {error}"
94
97
  newLines: "{count} nouvelle ligne, reprendre | {count} nouvelles lignes, reprendre"
95
98
  empty: Rien pour l'instant
96
99
  # EntityTimeline (#4111)
@@ -180,6 +183,8 @@ core:
180
183
  noSso: Aucun parcours de connexion configuré pour ce bouton
181
184
  # CardsDashboard (#4320)
182
185
  cardsDashboard:
186
+ saveFailed: La disposition n'a pas pu être enregistrée
187
+ saveFailedDetail: Elle reste telle qu'affichée ; réessayez.
183
188
  customise: Personnaliser
184
189
  done: Terminé
185
190
  reset: Réinitialiser
@@ -202,6 +207,39 @@ core:
202
207
  trayView: Afficher les cartes masquées en
203
208
  viewCards: Cartes
204
209
  viewCompact: Compact
210
+ # SessionsModule (#4336)
211
+ sessions:
212
+ title: Sessions
213
+ banner: "Aussi connecté : {list}"
214
+ bannerOne: "{name} (depuis {since})"
215
+ present: Connectés maintenant
216
+ refresh: Rafraîchir
217
+ nobody: Personne n'est connecté.
218
+ who: Qui
219
+ via: Via
220
+ since: Depuis
221
+ seen: Vu
222
+ tabs: Onglets
223
+ origin: Origine
224
+ mine: vous
225
+ close: Fermer
226
+ closeTitle: "Fermer la session de {name}"
227
+ reasonPrompt: Pourquoi ? Le motif va dans l'historique.
228
+ cancel: Annuler
229
+ history: Historique
230
+ noHistory: Pas encore d'historique.
231
+ when: Quand
232
+ event:
233
+ login: Connexion
234
+ logout: Déconnexion
235
+ refused: Refus
236
+ closed: Fermeture
237
+ expired: Expiration
238
+ by: Par
239
+ reason: Motif
240
+ source: Source
241
+ newer: Plus récent
242
+ older: Plus ancien
205
243
  # NotificationPanel and NotificationBadge (#4171)
206
244
  notifications:
207
245
  title: Notifications
package/src/index.ts CHANGED
@@ -385,11 +385,15 @@ export {
385
385
  useCardsArrangement,
386
386
  reconcileArrangement,
387
387
  defaultArrangement,
388
+ localArrangementStorage,
389
+ type CardsArrangementStorage,
390
+ type UseCardsArrangementOptions,
388
391
  type CardDef,
389
392
  type CardsArrangement,
390
393
  type CardsGroups,
391
394
  type UseCardsArrangementReturn,
392
395
  } from './composables/useCardsArrangement'
396
+ export { configureDashboards, getDashboardsConfig, resetDashboards, type DashboardsOptions } from './dashboard/dashboardConfig'
393
397
  export {
394
398
  useUserImpersonator,
395
399
  type UseUserImpersonatorOptions,
@@ -430,6 +434,33 @@ export { useSidebarState, SIDEBAR_COLLAPSED_KEY } from './composables/useSidebar
430
434
  export * from './components/index'
431
435
  export { useTaskRunner, taskAction } from './tasks/useTaskRunner'
432
436
  export { useTaskNotifications, useTaskTrayVisible, type TasksConfig } from './tasks/useTaskNotifications'
437
+ export {
438
+ SessionsModule,
439
+ createSessionsModule,
440
+ getSessionsRuntime,
441
+ sinceText,
442
+ SESSIONS_BANNER_ID,
443
+ type SessionsModuleOptions,
444
+ type SessionsLabel,
445
+ } from './sessions/SessionsModule'
446
+ export {
447
+ restSessionsAdapter,
448
+ type SessionsAdapter,
449
+ type SessionPresence,
450
+ type SessionInfo,
451
+ type SessionHistoryEntry,
452
+ type RestSessionsAdapterOptions,
453
+ } from './sessions/sessionsAdapter'
454
+ export { createPresence, tabId, type Presence, type PresenceOptions } from './sessions/presence'
455
+ export {
456
+ configureTasks,
457
+ getTaskUi,
458
+ resolveTaskUi,
459
+ TASK_DIALOG_DEFAULTS,
460
+ type TaskDialogOptions,
461
+ type TaskDialogSlotName,
462
+ type TaskUiOptions,
463
+ } from './tasks/taskUi'
433
464
  export {
434
465
  getTaskStore,
435
466
  registerTaskKind,
@@ -0,0 +1,152 @@
1
+ /**
2
+ * SessionsModule (#4336): who else has the admin open, and the sign-in
3
+ * history, over a SessionsAdapter.
4
+ *
5
+ * moduleDefs: [new SessionsModule({ base: '/api/sessions', permission: 'admin:sessions', bannerSeverity: 'warn' })]
6
+ * // or any transport:
7
+ * new SessionsModule({ adapter: mySessionsAdapter })
8
+ *
9
+ * - A heartbeat every `interval` seconds while the tab is visible and someone
10
+ * is signed in (stops on auth:logout).
11
+ * - The "Also signed in: X (since 10 min)" banner while the server reports others.
12
+ * - A "Sessions" page (route and menu entry under `permission`): present,
13
+ * paged history, Close with a reason (adapter.close and `closePermission`).
14
+ */
15
+ import { Module } from '../kernel/Module'
16
+ import type { I18n } from '../i18n/I18n'
17
+ import type { TranslateParams } from '../i18n'
18
+ import { getAppBannerStore } from '../composables/useAppBanner'
19
+ import type { AppBannerSeverity } from '../composables/useAppBanner'
20
+ import { restSessionsAdapter, type SessionPresence, type SessionsAdapter, type RestSessionsAdapterOptions } from './sessionsAdapter'
21
+ import { createPresence, type Presence } from './presence'
22
+
23
+ export const SESSIONS_BANNER_ID = 'qdadm.sessions.others'
24
+
25
+ /** A text the app replaces: a string (`{name}` placeholders) or a function of the params */
26
+ export type SessionsLabel = string | ((params: TranslateParams) => string)
27
+
28
+ export interface SessionsModuleOptions {
29
+ /** The transport; or `base` for restSessionsAdapter(base, rest) */
30
+ adapter?: SessionsAdapter
31
+ base?: string
32
+ rest?: RestSessionsAdapterOptions
33
+ /** Seconds between heartbeats (default 30) */
34
+ interval?: number
35
+ /** The banner's severity (default 'info'; 'warn' for a delivery admin) */
36
+ bannerSeverity?: AppBannerSeverity
37
+ /** No banner at all */
38
+ banner?: boolean
39
+ /** Who sees the Sessions page and its menu entry (the router refuses the others) */
40
+ permission?: string
41
+ /** Who may close a session (default: `permission`) */
42
+ closePermission?: string
43
+ /** The page's path (default 'sessions'); false: no page */
44
+ path?: string | false
45
+ nav?: { section?: string; icon?: string; label?: string } | false
46
+ /** Rows per history page (default 25) */
47
+ historyPageSize?: number
48
+ /** Texts: `banner` ({ list }), `bannerOne` ({ name, since }) and any core.sessions.<key> */
49
+ labels?: Record<string, SessionsLabel>
50
+ }
51
+
52
+ interface SessionsRuntime {
53
+ options: Required<Pick<SessionsModuleOptions, 'interval' | 'bannerSeverity' | 'historyPageSize'>> & SessionsModuleOptions
54
+ adapter: SessionsAdapter
55
+ presence: Presence | null
56
+ }
57
+
58
+ let runtime: SessionsRuntime | null = null
59
+
60
+ /** The module's adapter and options, for the Sessions page */
61
+ export function getSessionsRuntime(): SessionsRuntime | null {
62
+ return runtime
63
+ }
64
+
65
+ /** "10 min", "2 h", "3 d" since an ISO date */
66
+ export function sinceText(iso?: string, now = Date.now()): string {
67
+ const at = iso ? Date.parse(iso) : NaN
68
+ if (Number.isNaN(at)) return ''
69
+ const min = Math.max(0, Math.floor((now - at) / 60000))
70
+ if (min < 60) return `${min} min`
71
+ const h = Math.floor(min / 60)
72
+ return h < 48 ? `${h} h` : `${Math.floor(h / 24)} d`
73
+ }
74
+
75
+ export class SessionsModule extends Module {
76
+ static override moduleName = 'sessions'
77
+ static override requires: string[] = []
78
+
79
+ declare options: SessionsModuleOptions & Record<string, unknown>
80
+
81
+ constructor(options: SessionsModuleOptions = {}) {
82
+ super(options as Record<string, unknown>)
83
+ }
84
+
85
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
86
+ override async connect(ctx: any): Promise<void> {
87
+ const options = this.options as SessionsModuleOptions
88
+ const adapter = options.adapter ?? (options.base ? restSessionsAdapter(options.base, options.rest) : null)
89
+ if (!adapter) throw new Error('[qdadm] SessionsModule needs `adapter` or `base`')
90
+
91
+ const i18n = ctx.i18n as I18n | null
92
+ const label = (key: string, fallback: string, params: TranslateParams = {}): string => {
93
+ const custom = options.labels?.[key]
94
+ if (typeof custom === 'function') return custom(params)
95
+ if (typeof custom === 'string') return custom.replace(/\{(\w+)\}/g, (m, n) => (n in params ? String(params[n]) : m))
96
+ const trace = i18n?.resolve(`core.sessions.${key}`, params)
97
+ return trace?.hit ? trace.result : fallback.replace(/\{(\w+)\}/g, (m, n) => (n in params ? String(params[n]) : m))
98
+ }
99
+
100
+ const banners = getAppBannerStore()
101
+ const showOthers = (others: SessionPresence[]) => {
102
+ if (options.banner === false || !others.length) return banners.hide(SESSIONS_BANNER_ID)
103
+ const list = others
104
+ .map((o) => {
105
+ const since = sinceText(o.since)
106
+ return since ? label('bannerOne', '{name} (since {since})', { name: o.login, since }) : o.login
107
+ })
108
+ .join(', ')
109
+ banners.show({ id: SESSIONS_BANNER_ID, text: label('banner', 'Also signed in: {list}', { list }), severity: options.bannerSeverity ?? 'info' })
110
+ }
111
+
112
+ const presence = createPresence({ adapter, interval: options.interval ?? 30, onOthers: showOthers })
113
+ runtime = {
114
+ options: { interval: 30, bannerSeverity: 'info', historyPageSize: 25, ...options },
115
+ adapter,
116
+ presence,
117
+ }
118
+
119
+ // Beat while someone is signed in
120
+ const auth = ctx.auth as { isAuthenticated?: () => boolean } | null
121
+ if (!auth || auth.isAuthenticated?.() !== false) presence.start()
122
+ ctx.on('auth:login', () => presence.start())
123
+ ctx.on('auth:logout', () => presence.stop())
124
+
125
+ if (options.path !== false) {
126
+ const path = options.path ?? 'sessions'
127
+ ctx.routes(
128
+ path,
129
+ [{ path: '', name: 'qdadm-sessions', component: () => import('./SessionsPage.vue'), meta: { layout: 'page' } }],
130
+ { label: label('title', 'Sessions'), ...(options.permission ? { permission: options.permission } : {}) }
131
+ )
132
+ if (options.nav !== false) {
133
+ ctx.navItem({
134
+ section: options.nav?.section ?? 'Admin',
135
+ route: 'qdadm-sessions',
136
+ icon: options.nav?.icon ?? 'pi pi-users',
137
+ label: options.nav?.label ?? label('title', 'Sessions'),
138
+ })
139
+ }
140
+ }
141
+ }
142
+
143
+ override async disconnect(): Promise<void> {
144
+ runtime?.presence?.stop()
145
+ runtime = null
146
+ await super.disconnect()
147
+ }
148
+ }
149
+
150
+ export function createSessionsModule(options: SessionsModuleOptions): SessionsModule {
151
+ return new SessionsModule(options)
152
+ }
@@ -0,0 +1,228 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * SessionsPage (#4336): who is signed in now, the sign-in history, and Close
4
+ * for whoever may (adapter.close and the close permission). Registered by
5
+ * SessionsModule under its permission.
6
+ */
7
+ import { computed, inject, onMounted, ref } from 'vue'
8
+ import Card from 'primevue/card'
9
+ import Textarea from 'primevue/textarea'
10
+ import QdButton from '../components/base/QdButton.vue'
11
+ import QdMessage from '../components/base/QdMessage.vue'
12
+ import SimpleDialog from '../components/dialogs/SimpleDialog.vue'
13
+ import { useI18n } from '../i18n/useI18n'
14
+ import { usePageTitle } from '../composables/usePageTitle'
15
+ import { getSessionsRuntime, sinceText } from './SessionsModule'
16
+ import type { SessionHistoryEntry, SessionInfo } from './sessionsAdapter'
17
+ import type { TranslateParams } from '../i18n'
18
+
19
+ const rt = getSessionsRuntime()
20
+ const { tOr } = useI18n()
21
+ const security = inject<{ isGranted(attr: string): boolean } | null>('qdadmSecurityChecker', null)
22
+
23
+ /** core.sessions.<key>, or the module's `labels` */
24
+ function label(key: string, fallback: string, params: TranslateParams = {}): string {
25
+ const custom = rt?.options.labels?.[key]
26
+ if (typeof custom === 'function') return custom(params)
27
+ if (typeof custom === 'string') return custom.replace(/\{(\w+)\}/g, (m, n) => (n in params ? String(params[n]) : m))
28
+ return tOr(`core.sessions.${key}`, fallback, params)
29
+ }
30
+
31
+ usePageTitle(label('title', 'Sessions'))
32
+
33
+ const sessions = ref<SessionInfo[]>([])
34
+ const mine = ref<string | number | null>(null)
35
+ const loadError = ref<string | null>(null)
36
+ const history = ref<SessionHistoryEntry[]>([])
37
+ const notice = ref<string | null>(null)
38
+ const offset = ref(0)
39
+ const pageSize = computed(() => rt?.options.historyPageSize ?? 25)
40
+ const hasMore = ref(false)
41
+ const historyError = ref<string | null>(null)
42
+
43
+ const closePermission = computed(() => rt?.options.closePermission ?? rt?.options.permission)
44
+ const canClose = computed(
45
+ () => !!rt?.adapter.close && (!closePermission.value || !security || security.isGranted(closePermission.value))
46
+ )
47
+ const showIp = computed(() => sessions.value.some((s) => s.ip || s.agent))
48
+ const historyIp = computed(() => history.value.some((h) => h.ip || h.agent))
49
+
50
+ async function loadSessions(): Promise<void> {
51
+ if (!rt) return
52
+ try {
53
+ const res = await rt.adapter.list()
54
+ sessions.value = res.sessions
55
+ mine.value = res.mine ?? null
56
+ loadError.value = null
57
+ } catch (err) {
58
+ loadError.value = (err as Error).message
59
+ }
60
+ }
61
+
62
+ async function loadHistory(): Promise<void> {
63
+ if (!rt) return
64
+ try {
65
+ // One more row than shown tells whether a next page exists
66
+ const res = await rt.adapter.history({ limit: pageSize.value + 1, offset: offset.value })
67
+ hasMore.value = res.history.length > pageSize.value
68
+ history.value = res.history.slice(0, pageSize.value)
69
+ notice.value = res.notice ?? null
70
+ historyError.value = null
71
+ } catch (err) {
72
+ historyError.value = (err as Error).message
73
+ }
74
+ }
75
+
76
+ function page(delta: number): void {
77
+ offset.value = Math.max(0, offset.value + delta * pageSize.value)
78
+ void loadHistory()
79
+ }
80
+
81
+ const isMine = (s: SessionInfo) => mine.value !== null && String(s.id) === String(mine.value)
82
+ const when = (iso?: string) => (iso ? new Date(iso).toLocaleString() : '')
83
+ const eventLabel = (event: string) => label(`event.${event}`, event)
84
+
85
+ // Close, with a reason
86
+ const closing = ref<SessionInfo | null>(null)
87
+ const reason = ref('')
88
+ const closeBusy = ref(false)
89
+ const closeError = ref<string | null>(null)
90
+
91
+ function askClose(s: SessionInfo): void {
92
+ closing.value = s
93
+ reason.value = ''
94
+ closeError.value = null
95
+ }
96
+
97
+ async function confirmClose(): Promise<void> {
98
+ if (!rt?.adapter.close || !closing.value || !reason.value.trim()) return
99
+ closeBusy.value = true
100
+ try {
101
+ await rt.adapter.close(closing.value.id, reason.value.trim())
102
+ closing.value = null
103
+ await Promise.all([loadSessions(), loadHistory()])
104
+ } catch (err) {
105
+ closeError.value = (err as Error).message
106
+ } finally {
107
+ closeBusy.value = false
108
+ }
109
+ }
110
+
111
+ onMounted(() => {
112
+ void loadSessions()
113
+ void loadHistory()
114
+ })
115
+ </script>
116
+
117
+ <template>
118
+ <div class="qd-sessions">
119
+ <QdMessage v-if="!rt" severity="warn" :closable="false">SessionsModule is not loaded.</QdMessage>
120
+ <template v-else>
121
+ <Card class="qd-sessions-card">
122
+ <template #title>
123
+ <div class="qd-sessions-head">
124
+ <span>{{ label('present', 'Signed in now') }}</span>
125
+ <QdButton icon="pi pi-refresh" text rounded size="small" :aria-label="label('refresh', 'Refresh')" @click="loadSessions" />
126
+ </div>
127
+ </template>
128
+ <template #content>
129
+ <QdMessage v-if="loadError" severity="error" :closable="false">{{ loadError }}</QdMessage>
130
+ <p v-else-if="!sessions.length" class="qd-sessions-empty">{{ label('nobody', 'Nobody is signed in.') }}</p>
131
+ <table v-else class="qd-sessions-table">
132
+ <thead>
133
+ <tr>
134
+ <th>{{ label('who', 'Who') }}</th>
135
+ <th>{{ label('via', 'Via') }}</th>
136
+ <th>{{ label('since', 'Since') }}</th>
137
+ <th>{{ label('seen', 'Last seen') }}</th>
138
+ <th>{{ label('tabs', 'Tabs') }}</th>
139
+ <th v-if="showIp">{{ label('origin', 'Origin') }}</th>
140
+ <th v-if="canClose"></th>
141
+ </tr>
142
+ </thead>
143
+ <tbody>
144
+ <tr v-for="s in sessions" :key="String(s.id)" :class="{ 'qd-sessions-mine': isMine(s) }" :data-session-id="String(s.id)">
145
+ <td>
146
+ {{ s.login }}
147
+ <span v-if="isMine(s)" class="qd-sessions-badge">{{ label('mine', 'you') }}</span>
148
+ </td>
149
+ <td>{{ s.via }}</td>
150
+ <td :title="when(s.since)">{{ sinceText(s.since) }}</td>
151
+ <td :title="when(s.seen)">{{ sinceText(s.seen) }}</td>
152
+ <td>{{ s.tabs ?? '' }}</td>
153
+ <td v-if="showIp" class="qd-sessions-origin">{{ [s.ip, s.agent].filter(Boolean).join(' · ') }}</td>
154
+ <td v-if="canClose" class="qd-sessions-actions">
155
+ <QdButton
156
+ v-if="!isMine(s)"
157
+ size="small"
158
+ severity="danger"
159
+ text
160
+ icon="pi pi-sign-out"
161
+ :label="label('close', 'Close')"
162
+ @click="askClose(s)"
163
+ />
164
+ </td>
165
+ </tr>
166
+ </tbody>
167
+ </table>
168
+ </template>
169
+ </Card>
170
+
171
+ <Card class="qd-sessions-card">
172
+ <template #title>{{ label('history', 'History') }}</template>
173
+ <template #content>
174
+ <QdMessage v-if="notice" severity="warn" :closable="false" class="qd-sessions-notice">{{ notice }}</QdMessage>
175
+ <QdMessage v-if="historyError" severity="error" :closable="false">{{ historyError }}</QdMessage>
176
+ <p v-else-if="!history.length" class="qd-sessions-empty">{{ label('noHistory', 'No history yet.') }}</p>
177
+ <table v-else class="qd-sessions-table">
178
+ <thead>
179
+ <tr>
180
+ <th>{{ label('when', 'When') }}</th>
181
+ <th>{{ label('event', 'Event') }}</th>
182
+ <th>{{ label('who', 'Who') }}</th>
183
+ <th>{{ label('via', 'Via') }}</th>
184
+ <th>{{ label('by', 'By') }}</th>
185
+ <th>{{ label('reason', 'Reason') }}</th>
186
+ <th>{{ label('source', 'Source') }}</th>
187
+ <th v-if="historyIp">{{ label('origin', 'Origin') }}</th>
188
+ </tr>
189
+ </thead>
190
+ <tbody>
191
+ <tr v-for="(h, i) in history" :key="`${h.at}-${i}`" :class="`qd-sessions-event--${h.event}`">
192
+ <td>{{ when(h.at) }}</td>
193
+ <td><span class="qd-sessions-event">{{ eventLabel(h.event) }}</span></td>
194
+ <td>{{ h.login }}</td>
195
+ <td>{{ h.via }}</td>
196
+ <td>{{ h.by }}</td>
197
+ <td>{{ h.reason }}</td>
198
+ <td>{{ h.source }}</td>
199
+ <td v-if="historyIp" class="qd-sessions-origin">{{ [h.ip, h.agent].filter(Boolean).join(' · ') }}</td>
200
+ </tr>
201
+ </tbody>
202
+ </table>
203
+ <div class="qd-sessions-pager">
204
+ <QdButton size="small" text icon="pi pi-chevron-left" :label="label('newer', 'Newer')" :disabled="offset === 0" @click="page(-1)" />
205
+ <QdButton size="small" text icon="pi pi-chevron-right" icon-pos="right" :label="label('older', 'Older')" :disabled="!hasMore" @click="page(1)" />
206
+ </div>
207
+ </template>
208
+ </Card>
209
+
210
+ <SimpleDialog
211
+ :visible="!!closing"
212
+ :title="label('closeTitle', 'Close the session of {name}', { name: closing?.login ?? '' })"
213
+ :confirm-label="label('close', 'Close')"
214
+ confirm-severity="danger"
215
+ :confirm-disabled="!reason.trim()"
216
+ :loading="closeBusy"
217
+ :cancel-label="label('cancel', 'Cancel')"
218
+ @confirm="confirmClose"
219
+ @cancel="closing = null"
220
+ @update:visible="(v: boolean) => !v && (closing = null)"
221
+ >
222
+ <label for="qd-sessions-reason" class="qd-sessions-reason-label">{{ label('reasonPrompt', 'Why? It goes into the history.') }}</label>
223
+ <Textarea id="qd-sessions-reason" v-model="reason" rows="3" class="qd-sessions-reason" auto-resize />
224
+ <QdMessage v-if="closeError" severity="error" :closable="false">{{ closeError }}</QdMessage>
225
+ </SimpleDialog>
226
+ </template>
227
+ </div>
228
+ </template>