@quazardous/qdadm 2.41.0 → 2.43.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.
@@ -1,8 +1,10 @@
1
1
  <script setup lang="ts">
2
2
  /**
3
3
  * CardsDashboard — a zone's blocks as cards each user arranges (#4320):
4
- * reorder (drag or keyboard), hide, pin at the top. The arrangement is kept in
5
- * localStorage per dashboard and per user (useCardsArrangement).
4
+ * reorder (drag or keyboard), hide, pin at the top. The arrangement is kept
5
+ * per dashboard and per user, in localStorage or in the storage the app
6
+ * provides (`storage` prop or configureDashboards, #4338), saved once when an
7
+ * edit ends (Done, Reset).
6
8
  *
7
9
  * A card is any block with an id, so one block serves both a classic Zone and
8
10
  * this dashboard. Its optional `card` field adds the title and what the app
@@ -25,7 +27,15 @@ import QdButton from '../base/QdButton.vue'
25
27
  import { DASHBOARD_ZONES } from '../../zones/zones'
26
28
  import { useAuth } from '../../composables/useAuth'
27
29
  import { useI18n } from '../../i18n/useI18n'
28
- import { useCardsArrangement, moveCard, type CardDef, type CardsArrangement } from '../../composables/useCardsArrangement'
30
+ import {
31
+ useCardsArrangement,
32
+ moveCard,
33
+ localArrangementStorage,
34
+ type CardDef,
35
+ type CardsArrangement,
36
+ type CardsArrangementStorage,
37
+ } from '../../composables/useCardsArrangement'
38
+ import { getDashboardsConfig } from '../../dashboard/dashboardConfig'
29
39
  import type { ZoneRegistry, BlockConfig } from '../../zones/ZoneRegistry'
30
40
 
31
41
  const props = withDefaults(
@@ -40,14 +50,19 @@ const props = withDefaults(
40
50
  editable?: boolean
41
51
  /** How the edit mode's tray shows hidden cards by default: whole, or as chips; the user's toggle wins */
42
52
  hiddenView?: 'cards' | 'compact'
53
+ /** Where the arrangement is kept (default: configureDashboards's, else localStorage) */
54
+ storage?: CardsArrangementStorage | null
55
+ /** Ms an async load may take before the default order shows (default 150) */
56
+ loadGrace?: number | null
43
57
  }>(),
44
- { zone: DASHBOARD_ZONES.WIDGETS, id: null, minCardWidth: '18rem', editable: true, hiddenView: 'cards' }
58
+ { zone: DASHBOARD_ZONES.WIDGETS, id: null, minCardWidth: '18rem', editable: true, hiddenView: 'cards', storage: null, loadGrace: null }
45
59
  )
46
60
 
47
61
  const registry = inject<ZoneRegistry | null>('qdadmZoneRegistry', null)
48
62
  const version = registry?.getVersionRef?.()
49
63
  const { user } = useAuth()
50
64
  const { tOr } = useI18n()
65
+ const orchestrator = inject<{ toast: { error: (summary: string, detail?: string, source?: string) => void } } | null>('qdadmOrchestrator', null)
51
66
 
52
67
  const blocks = computed<BlockConfig[]>(() => {
53
68
  if (version) void version.value
@@ -74,10 +89,26 @@ const userKey = computed(() => {
74
89
  return String(u?.id ?? u?.username ?? 'anonymous')
75
90
  })
76
91
  const storageKey = computed(() => `qdadm.dashboard.${props.id ?? props.zone}.${userKey.value}`)
77
- const state = useCardsArrangement(storageKey, cards)
92
+ const state = useCardsArrangement(storageKey, cards, {
93
+ storage: () => props.storage ?? getDashboardsConfig().storage ?? localArrangementStorage,
94
+ autoSave: false,
95
+ loadGrace: props.loadGrace ?? getDashboardsConfig().loadGrace,
96
+ })
78
97
 
79
98
  const editing = ref(false)
80
99
 
100
+ function saveFailed(): void {
101
+ const text = tOr('core.cardsDashboard.saveFailed', 'Could not save the arrangement')
102
+ announce(text)
103
+ orchestrator?.toast.error(text, tOr('core.cardsDashboard.saveFailedDetail', 'It stays as shown; try again.'), 'CardsDashboard')
104
+ }
105
+
106
+ /** Done: one save for the whole edit; on failure the edit stays open to try again */
107
+ async function finish(): Promise<void> {
108
+ if (state.dirty.value && !(await state.commit())) return saveFailed()
109
+ editing.value = false
110
+ }
111
+
81
112
  // The hidden tray's view (#4320): whole cards or chips, the user's choice kept beside the arrangement
82
113
  const trayKey = computed(() => `${storageKey.value}.tray`)
83
114
  function readTray(): 'cards' | 'compact' {
@@ -159,8 +190,8 @@ function restore(c: CardDef): void {
159
190
  void focusHandle(c.id)
160
191
  }
161
192
 
162
- function reset(): void {
163
- state.reset()
193
+ async function reset(): Promise<void> {
194
+ if (!(await state.reset())) return saveFailed()
164
195
  announce(tOr('core.cardsDashboard.resetDone', 'Default arrangement restored'))
165
196
  }
166
197
 
@@ -214,7 +245,6 @@ function onPointerUp(): void {
214
245
  const c = dragged
215
246
  if (!c) return
216
247
  stopDrag()
217
- state.commit()
218
248
  announcePosition(c)
219
249
  }
220
250
 
@@ -232,7 +262,11 @@ function onDragKey(event: KeyboardEvent): void {
232
262
  if (event.key === 'Escape' && dragged) cancelDrag()
233
263
  }
234
264
 
235
- onBeforeUnmount(stopDrag)
265
+ onBeforeUnmount(() => {
266
+ stopDrag()
267
+ // Left in the middle of an edit: keep what was arranged
268
+ if (editing.value && state.dirty.value) void state.commit()
269
+ })
236
270
 
237
271
  // A block with wrappers renders through them, as in Zone
238
272
  function render(block: BlockConfig): Component {
@@ -261,9 +295,17 @@ function render(block: BlockConfig): Component {
261
295
  text
262
296
  icon="pi pi-undo"
263
297
  :label="tOr('core.cardsDashboard.reset', 'Reset')"
298
+ :disabled="state.saving.value"
264
299
  @click="reset"
265
300
  />
266
- <QdButton type="button" size="small" icon="pi pi-check" :label="tOr('core.cardsDashboard.done', 'Done')" @click="editing = false" />
301
+ <QdButton
302
+ type="button"
303
+ size="small"
304
+ icon="pi pi-check"
305
+ :label="tOr('core.cardsDashboard.done', 'Done')"
306
+ :loading="state.saving.value"
307
+ @click="finish"
308
+ />
267
309
  </template>
268
310
  <QdButton
269
311
  v-else
@@ -276,7 +318,7 @@ function render(block: BlockConfig): Component {
276
318
  />
277
319
  </div>
278
320
 
279
- <div class="qd-cards-grid" :style="{ '--qd-card-min': minCardWidth }">
321
+ <div class="qd-cards-grid" :class="{ 'qd-cards-loading': state.loading.value }" :aria-busy="state.loading.value || undefined" :style="{ '--qd-card-min': minCardWidth }">
280
322
  <div
281
323
  v-for="c in visible"
282
324
  :key="c.id"
@@ -23,12 +23,14 @@
23
23
  * - url: clickable link
24
24
  * - json: formatted JSON
25
25
  * - currency: formatted currency
26
+ * - bytes: a file size ("1,4 Mo"), in the app's language
26
27
  * - badge: styled tag
27
28
  */
28
29
  import { computed, type PropType } from 'vue'
29
30
  import { RouterLink, type RouteLocationRaw } from 'vue-router'
30
31
  import Tag from 'primevue/tag'
31
- import { formatDate, formatNumber, formatCurrency, getEmptyPlaceholder } from '../../utils/formatters'
32
+ import { formatDate, formatNumber, formatCurrency, formatBytes, getEmptyPlaceholder } from '../../utils/formatters'
33
+ import { useFormatBytes } from '../../composables/useFormatBytes'
32
34
 
33
35
  type DisplayType =
34
36
  | 'text'
@@ -45,6 +47,7 @@ type DisplayType =
45
47
  | 'url'
46
48
  | 'json'
47
49
  | 'currency'
50
+ | 'bytes'
48
51
  | 'badge'
49
52
 
50
53
  type DisplayValue = string | number | boolean | Date | null | undefined | unknown
@@ -128,6 +131,15 @@ const currencyValue = computed(() => {
128
131
  return formatCurrency(num, props.field.currencyCode || 'USD', props.field.locale)
129
132
  })
130
133
 
134
+ // Format a size in bytes: the app's language and catalogue units, or the field's locale
135
+ const appBytes = useFormatBytes()
136
+ const bytesValue = computed(() => {
137
+ if (isEmpty.value) return emptyText.value
138
+ const num = Number(props.value)
139
+ if (isNaN(num)) return String(props.value)
140
+ return props.field.locale ? formatBytes(num, props.field.locale) : appBytes(num)
141
+ })
142
+
131
143
  // Format boolean value
132
144
  const booleanValue = computed(() => {
133
145
  if (isEmpty.value) return emptyText.value
@@ -268,6 +280,11 @@ const imageStyle = computed(() => ({
268
280
  {{ currencyValue }}
269
281
  </span>
270
282
 
283
+ <!-- Size in bytes -->
284
+ <span v-else-if="displayType === 'bytes'" class="show-display show-display--bytes">
285
+ {{ bytesValue }}
286
+ </span>
287
+
271
288
  <!-- Boolean (icon) -->
272
289
  <span v-else-if="displayType === 'boolean'" class="show-display show-display--boolean" :class="booleanIconClass">
273
290
  <i :class="['pi', booleanIcon]"></i>
@@ -45,6 +45,12 @@ const run = computed(() => (props.runId ? store.state.runs.find((r) => r.id ===
45
45
  const def = computed(() => (props.runId ? store.definition(props.runId) : undefined))
46
46
  const final = computed(() => (run.value ? store.isFinal(run.value.status) : false))
47
47
  const logSource = computed(() => (run.value?.taskId != null && def.value?.log ? def.value.log(run.value.taskId) : null))
48
+ /** The log's download name: the kind and the task, e.g. "deploy-42.log" */
49
+ const logFilename = computed(() => {
50
+ const r = run.value
51
+ const name = `${r?.kind ?? 'task'}-${r?.taskId ?? r?.id ?? 'log'}`.replace(/[^\w.-]+/g, '_')
52
+ return `${name}.log`
53
+ })
48
54
  const link = computed(() => (run.value?.taskId != null && def.value?.to ? def.value.to(run.value.taskId) : null))
49
55
  const canCancel = computed(() => !!def.value?.cancel && !final.value && run.value?.taskId != null)
50
56
  const resultIsObject = computed(() => run.value?.result !== null && typeof run.value?.result === 'object')
@@ -238,8 +244,8 @@ onBeforeUnmount(() => {
238
244
  <component :is="slotComponent('before-log')!" v-bind="slotProps" />
239
245
  </slot>
240
246
  </div>
241
- <LogStream v-if="logSource" :key="run.id" class="qd-task-log" :source="logSource" height="16rem"
242
- error-pattern="error|fatal|failed" @done="store.poke(run.id)" />
247
+ <LogStream v-if="logSource" :key="run.id" class="qd-task-log" :source="logSource" :filename="logFilename" height="16rem"
248
+ :error-pattern="ui.logPatterns.errorPattern" :timestamp-pattern="ui.logPatterns.timestampPattern" @done="store.poke(run.id)" />
243
249
  <div v-if="has('after-log')" class="qd-task-after-log">
244
250
  <slot name="after-log" v-bind="slotProps">
245
251
  <component :is="slotComponent('after-log')!" v-bind="slotProps" />
@@ -91,6 +91,8 @@ export const SHOW_TYPE_MAPPINGS: Record<string, string> = {
91
91
  float: 'number',
92
92
  decimal: 'number',
93
93
  currency: 'currency',
94
+ bytes: 'bytes',
95
+ filesize: 'bytes',
94
96
  boolean: 'boolean',
95
97
  bool: 'boolean',
96
98
  date: 'date',
@@ -48,6 +48,7 @@ export {
48
48
  type BulkStatusActionReturn,
49
49
  } from './useListPage'
50
50
  export { usePageTitle, type UsePageTitleReturn, type TitleParts, type TitleInput } from './usePageTitle'
51
+ export { useFormatBytes } from './useFormatBytes'
51
52
  export { useApp, type UseAppReturn } from './useApp'
52
53
  export { useAuth, type UseAuthReturn } from './useAuth'
53
54
  export { useUserBox, resolveUserAvatar, isExternalUserLink, type UseUserBoxReturn, type UserAvatarResolver, type UserBoxUser } from './useUserBox'
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * useCardsArrangement — the user's arrangement of a card dashboard (#4320):
3
- * order, hidden, pinned, kept in localStorage per dashboard and per user.
3
+ * order, hidden, pinned, kept per dashboard and per user in a storage the app
4
+ * may provide (#4338: the server, per account); localStorage by default.
4
5
  *
5
6
  * The saved arrangement is reconciled with the cards the app declares on every
6
7
  * load: unknown ids are dropped, a new card takes its default place, a
@@ -8,7 +9,7 @@
8
9
  *
9
10
  * The functions are pure; the composable wraps them with a ref and storage.
10
11
  */
11
- import { computed, ref, watch, type ComputedRef, type Ref } from 'vue'
12
+ import { computed, onScopeDispose, ref, watch, type ComputedRef, type Ref } from 'vue'
12
13
  import type { BlockCard } from '../zones/ZoneRegistry'
13
14
 
14
15
  /** A card as the dashboard knows it: its id and its declaration, in default order. */
@@ -152,69 +153,204 @@ export function setHidden(arrangement: CardsArrangement, cards: CardDef[], id: s
152
153
  return { ...arrangement, hidden: hidden ? [...arrangement.hidden, id] : arrangement.hidden.filter((h) => h !== id) }
153
154
  }
154
155
 
155
- function readStorage(key: string): unknown {
156
- try {
157
- const raw = globalThis.localStorage?.getItem(key)
158
- return raw ? JSON.parse(raw) : null
159
- } catch {
160
- return null
161
- }
156
+ /**
157
+ * Where arrangements are kept (#4338). `load` may answer at once (localStorage)
158
+ * or with a promise (a server); whatever it gives back is reconciled with the
159
+ * declared cards, so an old or partial shape is fine. `save(key, null)`: back
160
+ * to the defaults.
161
+ */
162
+ export interface CardsArrangementStorage {
163
+ load(key: string): unknown | Promise<unknown>
164
+ save(key: string, arrangement: CardsArrangement | null): void | Promise<void>
162
165
  }
163
166
 
164
- function writeStorage(key: string, value: CardsArrangement | null): void {
165
- try {
166
- if (value) globalThis.localStorage?.setItem(key, JSON.stringify(value))
167
- else globalThis.localStorage?.removeItem(key)
168
- } catch {
169
- // No storage (private window, quota, blocked): the arrangement lasts the page
170
- }
167
+ /** The default storage: localStorage; no storage at all (private window, blocked): the arrangement lasts the page */
168
+ export const localArrangementStorage: CardsArrangementStorage = {
169
+ load(key) {
170
+ try {
171
+ const raw = globalThis.localStorage?.getItem(key)
172
+ return raw ? JSON.parse(raw) : null
173
+ } catch {
174
+ return null
175
+ }
176
+ },
177
+ save(key, value) {
178
+ try {
179
+ if (value) globalThis.localStorage?.setItem(key, JSON.stringify(value))
180
+ else globalThis.localStorage?.removeItem(key)
181
+ } catch {
182
+ // Quota or blocked: the arrangement lasts the page
183
+ }
184
+ },
185
+ }
186
+
187
+ const isThenable = (v: unknown): v is PromiseLike<unknown> => !!v && typeof (v as { then?: unknown }).then === 'function'
188
+
189
+ export interface UseCardsArrangementOptions {
190
+ /** The storage, or a getter read at each load and save (default: localArrangementStorage) */
191
+ storage?: CardsArrangementStorage | (() => CardsArrangementStorage)
192
+ /** Save at each change (default true); false: only `commit()` and `reset()` save */
193
+ autoSave?: boolean
194
+ /** Ms an async load may take while `loading` holds the cards back (default 150) */
195
+ loadGrace?: number
196
+ /** A load or a save failed (default: a console warning) */
197
+ onError?: (op: 'load' | 'save', error: unknown) => void
171
198
  }
172
199
 
173
200
  export interface UseCardsArrangementReturn {
174
201
  arrangement: Ref<CardsArrangement>
175
202
  groups: ComputedRef<CardsGroups>
203
+ /** An async load is in its grace: hold the cards back rather than show the defaults */
204
+ loading: Ref<boolean>
205
+ saving: Ref<boolean>
206
+ /** What is shown differs from what the storage holds */
207
+ dirty: ComputedRef<boolean>
176
208
  move: (id: string, toIndex: number) => boolean
177
209
  pin: (id: string, pinned: boolean) => boolean
178
210
  hide: (id: string, hidden: boolean) => boolean
179
211
  /** Replace the arrangement without saving (a drag in progress) */
180
212
  preview: (next: CardsArrangement) => void
181
- /** Save what is shown */
182
- commit: () => void
183
- reset: () => void
213
+ /** Save what is shown; false when the storage failed */
214
+ commit: () => Promise<boolean>
215
+ /** Back to the defaults, in the storage too; false when the storage failed */
216
+ reset: () => Promise<boolean>
184
217
  }
185
218
 
186
219
  /**
187
- * @param storageKey - the localStorage key (dashboard and user in it)
220
+ * @param storageKey - the storage key (dashboard and user in it)
188
221
  * @param cards - the declared cards, in default order
189
222
  */
190
- export function useCardsArrangement(storageKey: Ref<string>, cards: Ref<CardDef[]>): UseCardsArrangementReturn {
191
- const arrangement = ref<CardsArrangement>(reconcileArrangement(readStorage(storageKey.value), cards.value))
192
- // A new user or a changed set of cards: read again, reconciled
193
- watch([storageKey, cards], () => {
194
- arrangement.value = reconcileArrangement(readStorage(storageKey.value), cards.value)
223
+ export function useCardsArrangement(
224
+ storageKey: Ref<string>,
225
+ cards: Ref<CardDef[]>,
226
+ options: UseCardsArrangementOptions = {}
227
+ ): UseCardsArrangementReturn {
228
+ const storage = (): CardsArrangementStorage =>
229
+ (typeof options.storage === 'function' ? options.storage() : options.storage) ?? localArrangementStorage
230
+ const autoSave = options.autoSave ?? true
231
+ const onError =
232
+ options.onError ?? ((op, err) => console.warn(`[qdadm] CardsDashboard: the arrangement could not ${op === 'load' ? 'be loaded' : 'be saved'}:`, err))
233
+
234
+ /** What the storage holds, as it gave it (reconciled again when the cards change) */
235
+ let stored: unknown = null
236
+ /** The user changed something since the last load: a late answer must not undo it */
237
+ let touched = false
238
+ let loadToken = 0
239
+ let graceTimer: ReturnType<typeof setTimeout> | null = null
240
+
241
+ const arrangement = ref<CardsArrangement>(defaultArrangement(cards.value))
242
+ const savedJson = ref(JSON.stringify(arrangement.value))
243
+ const loading = ref(false)
244
+ const saving = ref(false)
245
+ const dirty = computed(() => JSON.stringify(arrangement.value) !== savedJson.value)
246
+
247
+ function settle(raw: unknown): void {
248
+ stored = raw
249
+ arrangement.value = reconcileArrangement(raw, cards.value)
250
+ savedJson.value = JSON.stringify(arrangement.value)
251
+ }
252
+
253
+ function stopGrace(): void {
254
+ if (graceTimer) clearTimeout(graceTimer)
255
+ graceTimer = null
256
+ loading.value = false
257
+ }
258
+
259
+ function load(): void {
260
+ const token = ++loadToken
261
+ const key = storageKey.value
262
+ touched = false
263
+ stopGrace()
264
+ let answer: unknown
265
+ try {
266
+ answer = storage().load(key)
267
+ } catch (err) {
268
+ onError('load', err)
269
+ settle(null)
270
+ return
271
+ }
272
+ if (!isThenable(answer)) return settle(answer)
273
+ // Async: the defaults wait out the grace, then show until the answer
274
+ settle(null)
275
+ loading.value = true
276
+ graceTimer = setTimeout(stopGrace, options.loadGrace ?? 150)
277
+ Promise.resolve(answer).then(
278
+ (raw) => {
279
+ if (token !== loadToken) return // another key since
280
+ stopGrace()
281
+ if (touched) {
282
+ stored = raw
283
+ savedJson.value = JSON.stringify(reconcileArrangement(raw, cards.value))
284
+ } else settle(raw)
285
+ },
286
+ (err) => {
287
+ if (token !== loadToken) return
288
+ stopGrace()
289
+ onError('load', err)
290
+ }
291
+ )
292
+ }
293
+
294
+ load()
295
+ // A new user: load again
296
+ watch(storageKey, load)
297
+ // A changed set of cards: reconciled again, from what is shown if the user changed it
298
+ watch(cards, () => {
299
+ const saved = reconcileArrangement(stored, cards.value)
300
+ savedJson.value = JSON.stringify(saved)
301
+ arrangement.value = touched ? reconcileArrangement(arrangement.value, cards.value) : saved
195
302
  })
303
+ onScopeDispose(() => {
304
+ loadToken++
305
+ stopGrace()
306
+ })
307
+
308
+ async function write(value: CardsArrangement | null): Promise<boolean> {
309
+ const key = storageKey.value
310
+ saving.value = true
311
+ try {
312
+ await storage().save(key, value)
313
+ if (key === storageKey.value) {
314
+ stored = value
315
+ savedJson.value = JSON.stringify(value ?? defaultArrangement(cards.value))
316
+ }
317
+ return true
318
+ } catch (err) {
319
+ onError('save', err)
320
+ return false
321
+ } finally {
322
+ saving.value = false
323
+ }
324
+ }
325
+
196
326
  const groups = computed(() => groupCards(arrangement.value, cards.value))
197
327
 
198
328
  const apply = (next: CardsArrangement): boolean => {
199
329
  if (next === arrangement.value) return false
330
+ touched = true
200
331
  arrangement.value = next
201
- writeStorage(storageKey.value, next)
332
+ if (autoSave) void write(next)
202
333
  return true
203
334
  }
204
335
 
205
336
  return {
206
337
  arrangement,
207
338
  groups,
339
+ loading,
340
+ saving,
341
+ dirty,
208
342
  move: (id, toIndex) => apply(moveCard(arrangement.value, cards.value, id, toIndex)),
209
343
  pin: (id, pinned) => apply(setPinned(arrangement.value, cards.value, id, pinned)),
210
344
  hide: (id, hidden) => apply(setHidden(arrangement.value, cards.value, id, hidden)),
211
345
  preview: (next) => {
346
+ touched = true
212
347
  arrangement.value = next
213
348
  },
214
- commit: () => writeStorage(storageKey.value, arrangement.value),
349
+ commit: () => write(arrangement.value),
215
350
  reset: () => {
216
- writeStorage(storageKey.value, null)
351
+ touched = true
217
352
  arrangement.value = defaultArrangement(cards.value)
353
+ return write(null)
218
354
  },
219
355
  }
220
356
  }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * useFormatBytes (#4384): formatBytes in the app's language, with the unit
3
+ * labels of the catalogue (core.units.bytes.*), so an app can rename them.
4
+ *
5
+ * const formatBytes = useFormatBytes()
6
+ * formatBytes(1468006) // "1,4 Mo" in French
7
+ */
8
+ import { useI18n } from '../i18n/useI18n'
9
+ import { byteUnits, formatBytes } from '../utils/formatters'
10
+
11
+ const KEYS = ['b', 'kb', 'mb', 'gb', 'tb']
12
+
13
+ export function useFormatBytes(): (bytes: number | null | undefined) => string {
14
+ const { tOr, locale } = useI18n()
15
+ return (bytes) => {
16
+ const fallback = byteUnits(locale.value)
17
+ const units = KEYS.map((key, i) => tOr(`core.units.bytes.${key}`, fallback[i]!))
18
+ return formatBytes(bytes, locale.value, units)
19
+ }
20
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The app's card dashboards (#4338): where arrangements are kept, set once at
3
+ * boot. A CardsDashboard's own `storage` / `load-grace` props win.
4
+ *
5
+ * configureDashboards({
6
+ * storage: {
7
+ * load: (key) => api.get(`/me/dashboards/${key}`).then((r) => r.data, () => null),
8
+ * save: (key, arrangement) => api.put(`/me/dashboards/${key}`, arrangement),
9
+ * },
10
+ * })
11
+ */
12
+ import type { CardsArrangementStorage } from '../composables/useCardsArrangement'
13
+
14
+ export interface DashboardsOptions {
15
+ /** Where arrangements are kept (default: localStorage) */
16
+ storage?: CardsArrangementStorage
17
+ /** Ms an async load may take before the default order shows (default 150) */
18
+ loadGrace?: number
19
+ }
20
+
21
+ const app: DashboardsOptions = {}
22
+
23
+ /** Later calls merge over earlier ones. */
24
+ export function configureDashboards(options: DashboardsOptions): void {
25
+ Object.assign(app, options)
26
+ }
27
+
28
+ export function getDashboardsConfig(): Readonly<DashboardsOptions> {
29
+ return app
30
+ }
31
+
32
+ /** For tests: back to qdadm's defaults. */
33
+ export function resetDashboards(): void {
34
+ delete app.storage
35
+ delete app.loadGrace
36
+ }
@@ -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
@@ -257,13 +262,25 @@ export default `core:
257
262
  next: Next message
258
263
  position: "{index} of {count}"
259
264
  close: Close this message
265
+ # formatBytes in qdadm's own components (#4384)
266
+ units:
267
+ bytes:
268
+ b: B
269
+ kb: KB
270
+ mb: MB
271
+ gb: GB
272
+ tb: TB
260
273
  # VanillaYamlEditor and YamlConfigEditor (#4303)
261
274
  yamlEditor:
262
275
  text: Text
263
- tree: Form
276
+ tree: Tree
277
+ form: Form
264
278
  modes: View
265
- syntaxBlocked: Fix the syntax errors before switching to the form
279
+ syntaxBlocked: "Fix the syntax errors before switching to the tree or the form"
266
280
  syntaxErrors: "{count} syntax error | {count} syntax errors"
281
+ warnings: "{count} warning | {count} warnings"
282
+ colonKey: 'The key is "{key}": did you mean "{suggestion}:"?'
283
+ spacedKey: 'The key "{key}" starts or ends with a space'
267
284
  addItem: Add item
268
285
  addKey: Add
269
286
  newKey: new key
@@ -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
@@ -255,13 +260,25 @@ core:
255
260
  next: Next message
256
261
  position: "{index} of {count}"
257
262
  close: Close this message
263
+ # formatBytes in qdadm's own components (#4384)
264
+ units:
265
+ bytes:
266
+ b: B
267
+ kb: KB
268
+ mb: MB
269
+ gb: GB
270
+ tb: TB
258
271
  # VanillaYamlEditor and YamlConfigEditor (#4303)
259
272
  yamlEditor:
260
273
  text: Text
261
- tree: Form
274
+ tree: Tree
275
+ form: Form
262
276
  modes: View
263
- syntaxBlocked: Fix the syntax errors before switching to the form
277
+ syntaxBlocked: "Fix the syntax errors before switching to the tree or the form"
264
278
  syntaxErrors: "{count} syntax error | {count} syntax errors"
279
+ warnings: "{count} warning | {count} warnings"
280
+ colonKey: 'The key is "{key}": did you mean "{suggestion}:"?'
281
+ spacedKey: 'The key "{key}" starts or ends with a space'
265
282
  addItem: Add item
266
283
  addKey: Add
267
284
  newKey: new key