@quazardous/qdadm 2.51.0 → 2.53.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/dist/node/cards/tools/cardsTool.d.ts +32 -0
- package/dist/node/cards/tools/cardsTool.js +151 -0
- package/dist/node/cards/tools/cli.d.ts +2 -0
- package/dist/node/cards/tools/cli.js +38 -0
- package/dist/node/cards/validate.d.ts +35 -0
- package/dist/node/cards/validate.js +94 -0
- package/dist/styles/qdadm.css +1 -1
- package/package.json +7 -2
- package/src/board/QdBoardBlock.vue +67 -0
- package/src/board/QdDomainBoard.vue +64 -0
- package/src/board/blocks/BreakdownBlock.vue +44 -0
- package/src/board/blocks/KpiBlock.vue +31 -0
- package/src/board/blocks/TimelineBlock.vue +63 -0
- package/src/board/blocks/TopBlock.vue +57 -0
- package/src/board/blocks/schemas.ts +107 -0
- package/src/board/index.ts +31 -0
- package/src/board/registry.ts +33 -0
- package/src/board/types.ts +32 -0
- package/src/cards/QdCard.vue +175 -0
- package/src/cards/QdCardView.vue +53 -0
- package/src/cards/QdCardsGallery.vue +103 -0
- package/src/cards/QdFavoritesCard.vue +50 -0
- package/src/cards/QdRecentCard.vue +44 -0
- package/src/cards/builtin/agenda/AgendaCard.vue +37 -0
- package/src/cards/builtin/agenda/meta.json +60 -0
- package/src/cards/builtin/agenda/schema.json +48 -0
- package/src/cards/builtin/bullet/BulletCard.vue +76 -0
- package/src/cards/builtin/bullet/meta.json +38 -0
- package/src/cards/builtin/bullet/schema.json +18 -0
- package/src/cards/builtin/cards-index.json +1694 -0
- package/src/cards/builtin/compare/CompareCard.vue +47 -0
- package/src/cards/builtin/compare/meta.json +79 -0
- package/src/cards/builtin/compare/schema.json +40 -0
- package/src/cards/builtin/favorites/FavoritesCard.vue +50 -0
- package/src/cards/builtin/favorites/meta.json +33 -0
- package/src/cards/builtin/favorites/schema.json +20 -0
- package/src/cards/builtin/feed/FeedCard.vue +39 -0
- package/src/cards/builtin/feed/meta.json +64 -0
- package/src/cards/builtin/feed/schema.json +54 -0
- package/src/cards/builtin/funnel/FunnelCard.vue +44 -0
- package/src/cards/builtin/funnel/meta.json +53 -0
- package/src/cards/builtin/funnel/schema.json +37 -0
- package/src/cards/builtin/goal/GoalCard.vue +73 -0
- package/src/cards/builtin/goal/meta.json +43 -0
- package/src/cards/builtin/goal/schema.json +12 -0
- package/src/cards/builtin/heat/HeatCard.vue +46 -0
- package/src/cards/builtin/heat/meta.json +101 -0
- package/src/cards/builtin/heat/schema.json +39 -0
- package/src/cards/builtin/index.ts +71 -0
- package/src/cards/builtin/metric/MetricCard.vue +82 -0
- package/src/cards/builtin/metric/meta.json +109 -0
- package/src/cards/builtin/metric/schema.json +35 -0
- package/src/cards/builtin/pills.ts +36 -0
- package/src/cards/builtin/queue/QueueCard.vue +65 -0
- package/src/cards/builtin/queue/meta.json +47 -0
- package/src/cards/builtin/queue/schema.json +32 -0
- package/src/cards/builtin/ranking/RankingCard.vue +37 -0
- package/src/cards/builtin/ranking/meta.json +71 -0
- package/src/cards/builtin/ranking/schema.json +35 -0
- package/src/cards/builtin/recent/RecentCard.vue +41 -0
- package/src/cards/builtin/recent/meta.json +32 -0
- package/src/cards/builtin/recent/schema.json +21 -0
- package/src/cards/builtin/shared.ts +83 -0
- package/src/cards/builtin/split/SplitCard.vue +52 -0
- package/src/cards/builtin/split/meta.json +72 -0
- package/src/cards/builtin/split/schema.json +40 -0
- package/src/cards/builtin/trend/TrendCard.vue +75 -0
- package/src/cards/builtin/trend/meta.json +81 -0
- package/src/cards/builtin/trend/schema.json +58 -0
- package/src/cards/index.ts +29 -0
- package/src/cards/registry.ts +57 -0
- package/src/cards/tools/cardsTool.ts +181 -0
- package/src/cards/tools/cli.ts +35 -0
- package/src/cards/types.ts +111 -0
- package/src/cards/validate.ts +111 -0
- package/src/components/edit/FormActions.vue +9 -5
- package/src/components/edit/FormPage.vue +17 -2
- package/src/components/layout/AppLayout.vue +4 -0
- package/src/components/layout/BaseLayout.vue +4 -0
- package/src/components/layout/CardParamsForm.vue +157 -0
- package/src/components/layout/CardsDashboard.vue +276 -57
- package/src/components/layout/PageHeader.vue +22 -1
- package/src/components/layout/QdFavoriteStar.vue +71 -0
- package/src/components/layout/Zone.vue +2 -1
- package/src/components/lists/ListPage.vue +9 -1
- package/src/components/lists/QdSaveSearch.vue +79 -0
- package/src/components/pages/NotFoundPage.vue +5 -2
- package/src/components/run/QdRunBar.vue +99 -0
- package/src/components/show/ShowPage.vue +10 -1
- package/src/composables/useBreadcrumb.ts +1 -1
- package/src/composables/useCardsArrangement.ts +297 -27
- package/src/composables/useEntityItemFormPage.ts +39 -3
- package/src/composables/useEntityItemFormPage.types.ts +8 -0
- package/src/composables/useEntityItemShowPage.ts +22 -0
- package/src/composables/useListPage.ts +71 -0
- package/src/composables/useListPage.types.ts +6 -0
- package/src/composables/useUnsavedChangesGuard.ts +17 -1
- package/src/domain/QdBadge.vue +36 -0
- package/src/domain/QdDomainBar.vue +213 -0
- package/src/domain/QdDomainBarZone.vue +19 -0
- package/src/domain/index.ts +6 -0
- package/src/domain/registry.ts +122 -0
- package/src/favorites/index.ts +7 -0
- package/src/favorites/store.ts +172 -0
- package/src/favorites/useFavorites.ts +217 -0
- package/src/i18n/defaults/core.en.generated.ts +132 -0
- package/src/i18n/defaults/core.en.yml +132 -0
- package/src/i18n/defaults/core.fr.generated.ts +132 -0
- package/src/i18n/defaults/core.fr.yml +132 -0
- package/src/index.ts +23 -0
- package/src/kernel/Kernel.routing.ts +4 -15
- package/src/kernel/Kernel.types.ts +5 -1
- package/src/kernel/Kernel.vue.ts +2 -2
- package/src/kernel/KernelContext.routing.ts +10 -1
- package/src/kernel/KernelContext.ts +7 -0
- package/src/kernel/KernelContext.types.ts +2 -0
- package/src/kernel/homeRoute.ts +45 -0
- package/src/module/moduleRegistry.ts +4 -0
- package/src/run/index.ts +6 -0
- package/src/run/run.ts +162 -0
- package/src/run/useRun.ts +207 -0
- package/src/styles/_cards-dashboard.scss +190 -0
- package/src/styles/_qd-board.scss +359 -0
- package/src/styles/_qd-cards.scss +1197 -0
- package/src/styles/_qd-domain-bar.scss +159 -0
- package/src/styles/_qd-run.scss +135 -0
- package/src/styles/index.scss +4 -0
- package/src/zones/ZoneRegistry.ts +16 -0
- package/src/zones/index.ts +1 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* QdDomainBoard (#5352): a domain's board, the level between a dashboard and
|
|
4
|
+
* a list. The app declares typed blocks on a grid of 12 columns; the
|
|
5
|
+
* component knows only the types (kpi, breakdown, top, timeline, and any
|
|
6
|
+
* registered with registerBoardBlock).
|
|
7
|
+
*
|
|
8
|
+
* <QdDomainBoard :source="{ label: 'LegacyLog', freshness: readAt, to: 'https://…' }" :blocks="[
|
|
9
|
+
* { type: 'kpi', data: { label: 'Open', value: 69, note: 'signatures not handled' } },
|
|
10
|
+
* { type: 'breakdown', title: 'By kind', load: () => errors.byKind() },
|
|
11
|
+
* { type: 'top', title: 'Most frequent', load: () => errors.top(5), more: { label: 'All 69', to: { name: 'php-error' } } },
|
|
12
|
+
* ]" />
|
|
13
|
+
*
|
|
14
|
+
* Each block reads its own data and draws its own states.
|
|
15
|
+
*/
|
|
16
|
+
import { computed } from 'vue'
|
|
17
|
+
import { RouterLink } from 'vue-router'
|
|
18
|
+
import QdBoardBlock from './QdBoardBlock.vue'
|
|
19
|
+
import { useI18n } from '../i18n/useI18n'
|
|
20
|
+
import { relativeTime } from '../cards/builtin/shared'
|
|
21
|
+
import { getBoardBlock } from './registry'
|
|
22
|
+
import type { BoardBlock, BoardSource } from './types'
|
|
23
|
+
|
|
24
|
+
const props = withDefaults(defineProps<{ blocks: BoardBlock[]; source?: BoardSource | null }>(), { source: null })
|
|
25
|
+
const { tOr, locale } = useI18n()
|
|
26
|
+
|
|
27
|
+
const placed = computed(() =>
|
|
28
|
+
props.blocks.map((block, i) => ({
|
|
29
|
+
key: block.id ?? `${block.type}-${i}`,
|
|
30
|
+
block,
|
|
31
|
+
span: Math.max(1, Math.min(12, Math.round(block.span ?? getBoardBlock(block.type)?.span ?? 12))),
|
|
32
|
+
}))
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
const fresh = computed(() => {
|
|
36
|
+
const at = props.source?.freshness
|
|
37
|
+
if (at === undefined || at === null || at === '') return null
|
|
38
|
+
const date = at instanceof Date ? at : new Date(at)
|
|
39
|
+
if (Number.isNaN(date.getTime())) return { text: String(at), title: undefined }
|
|
40
|
+
return { text: relativeTime(date, locale.value), title: date.toLocaleString(locale.value) }
|
|
41
|
+
})
|
|
42
|
+
const external = computed(() => typeof props.source?.to === 'string' && /^[a-z]+:\/\//i.test(props.source.to))
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<template>
|
|
46
|
+
<div class="qd-board">
|
|
47
|
+
<p v-if="source" class="qd-board-source">
|
|
48
|
+
<span>{{ tOr('core.board.source', 'Source: {source}', { source: source.label }) }}</span>
|
|
49
|
+
<template v-if="fresh">
|
|
50
|
+
· <span :title="fresh.title">{{ tOr('core.board.readAt', 'read {when}', { when: fresh.text }) }}</span>
|
|
51
|
+
</template>
|
|
52
|
+
<template v-if="source.to">
|
|
53
|
+
·
|
|
54
|
+
<a v-if="external" :href="(source.to as string)" target="_blank" rel="noopener">{{ tOr('core.board.openSource', 'open {source}', { source: source.label }) }}</a>
|
|
55
|
+
<RouterLink v-else :to="source.to">{{ tOr('core.board.openSource', 'open {source}', { source: source.label }) }}</RouterLink>
|
|
56
|
+
</template>
|
|
57
|
+
</p>
|
|
58
|
+
<div class="qd-board-grid">
|
|
59
|
+
<div v-for="p in placed" :key="p.key" class="qd-board-cell" :style="{ '--qd-board-span': p.span }" :data-board-type="p.block.type">
|
|
60
|
+
<QdBoardBlock :block="p.block" />
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
</template>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* breakdown (#5352): how a whole splits, in one or more groups ("By kind",
|
|
4
|
+
* "By origin"). Each line a label, a bar scaled within its group and the
|
|
5
|
+
* value written; a line may open its filtered list.
|
|
6
|
+
*/
|
|
7
|
+
import { computed } from 'vue'
|
|
8
|
+
import { RouterLink, type RouteLocationRaw } from 'vue-router'
|
|
9
|
+
import { useI18n } from '../../i18n/useI18n'
|
|
10
|
+
import { formatNumber } from '../../cards/builtin/shared'
|
|
11
|
+
|
|
12
|
+
interface Row {
|
|
13
|
+
label: string
|
|
14
|
+
value: number
|
|
15
|
+
to?: RouteLocationRaw
|
|
16
|
+
}
|
|
17
|
+
const props = defineProps<{ data: { groups: Array<{ title?: string; rows: Row[] }>; note?: string } }>()
|
|
18
|
+
const { locale } = useI18n()
|
|
19
|
+
|
|
20
|
+
const groups = computed(() =>
|
|
21
|
+
props.data.groups.map((g) => {
|
|
22
|
+
const max = Math.max(0, ...g.rows.map((r) => r.value))
|
|
23
|
+
return { ...g, rows: g.rows.map((r) => ({ ...r, share: max ? (r.value / max) * 100 : 0, text: formatNumber(r.value, locale.value) })) }
|
|
24
|
+
})
|
|
25
|
+
)
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<template>
|
|
29
|
+
<div class="qd-board-breakdown">
|
|
30
|
+
<section v-for="(g, gi) in groups" :key="gi" class="qd-board-breakdown-group">
|
|
31
|
+
<h3 v-if="g.title" class="qd-board-subtitle">{{ g.title }}</h3>
|
|
32
|
+
<ul>
|
|
33
|
+
<li v-for="(r, ri) in g.rows" :key="ri">
|
|
34
|
+
<component :is="r.to ? RouterLink : 'div'" :to="r.to" class="qd-board-breakdown-row">
|
|
35
|
+
<span class="qd-board-breakdown-label">{{ r.label }}</span>
|
|
36
|
+
<span class="qd-board-breakdown-track" aria-hidden="true"><span class="qd-board-breakdown-bar" :style="{ width: `${r.share}%` }"></span></span>
|
|
37
|
+
<span class="qd-board-breakdown-value">{{ r.text }}</span>
|
|
38
|
+
</component>
|
|
39
|
+
</li>
|
|
40
|
+
</ul>
|
|
41
|
+
</section>
|
|
42
|
+
<p v-if="data.note" class="qd-board-note">{{ data.note }}</p>
|
|
43
|
+
</div>
|
|
44
|
+
</template>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* kpi (#5352): one number of the domain, its unit, a note, and a status
|
|
4
|
+
* drawn as a side bar and a word, never by the hue alone. `to` opens what
|
|
5
|
+
* the number counts.
|
|
6
|
+
*/
|
|
7
|
+
import { computed } from 'vue'
|
|
8
|
+
import { RouterLink, type RouteLocationRaw } from 'vue-router'
|
|
9
|
+
import { useI18n } from '../../i18n/useI18n'
|
|
10
|
+
import { formatNumber } from '../../cards/builtin/shared'
|
|
11
|
+
|
|
12
|
+
const props = defineProps<{
|
|
13
|
+
data: { label: string; value: number | string; unit?: string; decimals?: number; note?: string; status?: 'critical' | 'watch' | 'good' | 'info'; to?: RouteLocationRaw }
|
|
14
|
+
}>()
|
|
15
|
+
const { t, locale } = useI18n()
|
|
16
|
+
|
|
17
|
+
const value = computed(() =>
|
|
18
|
+
typeof props.data.value === 'number' ? formatNumber(props.data.value, locale.value, { decimals: props.data.decimals, unit: props.data.unit }) : props.data.value
|
|
19
|
+
)
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<template>
|
|
23
|
+
<div class="qd-board-kpi" :class="data.status ? `qd-board-kpi--${data.status}` : null">
|
|
24
|
+
<component :is="data.to ? RouterLink : 'div'" :to="data.to" class="qd-board-kpi-body">
|
|
25
|
+
<span class="qd-board-kpi-label">{{ data.label }}</span>
|
|
26
|
+
<span class="qd-board-kpi-value">{{ value }}</span>
|
|
27
|
+
<span v-if="data.status" class="qd-board-kpi-status">{{ t(`core.cards.status.${data.status}`) }}</span>
|
|
28
|
+
<span v-if="data.note" class="qd-board-kpi-note">{{ data.note }}</span>
|
|
29
|
+
</component>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* timeline (#5352): the volume over time. One bar per day (or hour), the
|
|
4
|
+
* latest marked; the total over the period and its change against the one
|
|
5
|
+
* before, signed and in words. Each bar's title gives its date and count.
|
|
6
|
+
*/
|
|
7
|
+
import { computed } from 'vue'
|
|
8
|
+
import { useI18n } from '../../i18n/useI18n'
|
|
9
|
+
import { formatNumber, formatDelta, deltaTone } from '../../cards/builtin/shared'
|
|
10
|
+
|
|
11
|
+
const props = defineProps<{
|
|
12
|
+
data: {
|
|
13
|
+
points: Array<{ at: string | number; value: number }>
|
|
14
|
+
bucket?: 'day' | 'hour'
|
|
15
|
+
label?: string
|
|
16
|
+
previous?: number
|
|
17
|
+
higherIs?: 'better' | 'worse' | 'neutral'
|
|
18
|
+
}
|
|
19
|
+
}>()
|
|
20
|
+
const { t, locale } = useI18n()
|
|
21
|
+
|
|
22
|
+
const total = computed(() => props.data.points.reduce((sum, p) => sum + p.value, 0))
|
|
23
|
+
const max = computed(() => Math.max(0, ...props.data.points.map((p) => p.value)))
|
|
24
|
+
const when = (at: string | number) => {
|
|
25
|
+
const d = new Date(at)
|
|
26
|
+
if (Number.isNaN(d.getTime())) return String(at)
|
|
27
|
+
return props.data.bucket === 'hour'
|
|
28
|
+
? d.toLocaleString(locale.value, { weekday: 'short', hour: '2-digit', minute: '2-digit' })
|
|
29
|
+
: d.toLocaleDateString(locale.value, { weekday: 'short', day: 'numeric', month: 'short' })
|
|
30
|
+
}
|
|
31
|
+
const bars = computed(() =>
|
|
32
|
+
props.data.points.map((p, i) => ({
|
|
33
|
+
height: max.value ? Math.max(2, (p.value / max.value) * 100) : 2,
|
|
34
|
+
latest: i === props.data.points.length - 1,
|
|
35
|
+
title: `${when(p.at)}: ${formatNumber(p.value, locale.value)}${props.data.label ? ` ${props.data.label}` : ''}`,
|
|
36
|
+
}))
|
|
37
|
+
)
|
|
38
|
+
const change = computed(() => {
|
|
39
|
+
if (props.data.previous === undefined) return null
|
|
40
|
+
const delta = total.value - props.data.previous
|
|
41
|
+
if (delta === 0) return { text: t('core.board.same'), tone: 'neutral' }
|
|
42
|
+
return { text: t('core.board.change', { change: formatDelta(delta, locale.value) }), tone: deltaTone(delta, props.data.higherIs ?? 'neutral') }
|
|
43
|
+
})
|
|
44
|
+
const first = computed(() => (props.data.points[0] ? when(props.data.points[0].at) : ''))
|
|
45
|
+
const last = computed(() => (props.data.points.length ? when(props.data.points[props.data.points.length - 1]!.at) : ''))
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<template>
|
|
49
|
+
<div class="qd-board-timeline">
|
|
50
|
+
<div class="qd-board-timeline-head">
|
|
51
|
+
<span class="qd-board-kpi-value">{{ formatNumber(total, locale) }}</span>
|
|
52
|
+
<span v-if="data.label" class="qd-board-timeline-label">{{ data.label }}</span>
|
|
53
|
+
<span v-if="change" class="qd-card-delta" :class="`qd-tone--${change.tone}`">{{ change.text }}</span>
|
|
54
|
+
</div>
|
|
55
|
+
<ol class="qd-board-timeline-bars" :aria-label="t('core.board.timelineBars', { from: first, to: last })">
|
|
56
|
+
<li v-for="(b, i) in bars" :key="i" :class="{ 'qd-board-timeline-latest': b.latest }" :title="b.title">
|
|
57
|
+
<span class="qd-board-timeline-bar" :style="{ height: `${b.height}%` }"></span>
|
|
58
|
+
<span class="qd-cards-sr">{{ b.title }}</span>
|
|
59
|
+
</li>
|
|
60
|
+
</ol>
|
|
61
|
+
<div class="qd-board-timeline-axis" aria-hidden="true"><span>{{ first }}</span><span>{{ last }}</span></div>
|
|
62
|
+
</div>
|
|
63
|
+
</template>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* top (#5352): the first items of the domain as a small table with declared
|
|
4
|
+
* columns (text, mono, tags, number, spark). A row with `to` opens its item:
|
|
5
|
+
* its first cell is the link, the others stay readable text.
|
|
6
|
+
*/
|
|
7
|
+
import { RouterLink, type RouteLocationRaw } from 'vue-router'
|
|
8
|
+
import { useI18n } from '../../i18n/useI18n'
|
|
9
|
+
import { formatNumber, seriesPaths } from '../../cards/builtin/shared'
|
|
10
|
+
|
|
11
|
+
type ColumnType = 'text' | 'mono' | 'tags' | 'number' | 'spark'
|
|
12
|
+
interface Column {
|
|
13
|
+
key: string
|
|
14
|
+
label: string
|
|
15
|
+
type?: ColumnType
|
|
16
|
+
}
|
|
17
|
+
interface Tag {
|
|
18
|
+
label: string
|
|
19
|
+
status?: 'critical' | 'watch' | 'good' | 'info'
|
|
20
|
+
}
|
|
21
|
+
defineProps<{ data: { columns: Column[]; rows: Array<{ values: Record<string, unknown>; to?: RouteLocationRaw }> } }>()
|
|
22
|
+
const { locale } = useI18n()
|
|
23
|
+
|
|
24
|
+
const tags = (v: unknown): Tag[] =>
|
|
25
|
+
(Array.isArray(v) ? v : v === undefined || v === null || v === '' ? [] : [v]).map((t) => (typeof t === 'object' && t ? (t as Tag) : { label: String(t) }))
|
|
26
|
+
const num = (v: unknown) => (typeof v === 'number' ? formatNumber(v, locale.value) : String(v ?? ''))
|
|
27
|
+
const spark = (v: unknown) => (Array.isArray(v) && v.every((n) => typeof n === 'number') ? seriesPaths(v as number[], 100, 24) : null)
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<template>
|
|
31
|
+
<div class="qd-board-top">
|
|
32
|
+
<table>
|
|
33
|
+
<thead>
|
|
34
|
+
<tr>
|
|
35
|
+
<th v-for="c in data.columns" :key="c.key" scope="col" :class="`qd-board-col--${c.type ?? 'text'}`">{{ c.label }}</th>
|
|
36
|
+
</tr>
|
|
37
|
+
</thead>
|
|
38
|
+
<tbody>
|
|
39
|
+
<tr v-for="(row, ri) in data.rows" :key="ri" :class="{ 'qd-board-top-linked': !!row.to }">
|
|
40
|
+
<td v-for="(c, ci) in data.columns" :key="c.key" :class="`qd-board-col--${c.type ?? 'text'}`">
|
|
41
|
+
<RouterLink v-if="ci === 0 && row.to" :to="row.to" class="qd-board-top-link">{{ row.values[c.key] }}</RouterLink>
|
|
42
|
+
<template v-else-if="c.type === 'tags'">
|
|
43
|
+
<span v-for="(tag, ti) in tags(row.values[c.key])" :key="ti" class="qd-card-tag" :class="tag.status ? `qd-tone--${tag.status}` : null">{{ tag.label }}</span>
|
|
44
|
+
</template>
|
|
45
|
+
<template v-else-if="c.type === 'number'">{{ num(row.values[c.key]) }}</template>
|
|
46
|
+
<template v-else-if="c.type === 'spark'">
|
|
47
|
+
<svg v-if="spark(row.values[c.key])" class="qd-board-spark" viewBox="0 0 100 24" preserveAspectRatio="none" aria-hidden="true">
|
|
48
|
+
<path :d="spark(row.values[c.key])!.line" vector-effect="non-scaling-stroke" />
|
|
49
|
+
</svg>
|
|
50
|
+
</template>
|
|
51
|
+
<template v-else>{{ row.values[c.key] }}</template>
|
|
52
|
+
</td>
|
|
53
|
+
</tr>
|
|
54
|
+
</tbody>
|
|
55
|
+
</table>
|
|
56
|
+
</div>
|
|
57
|
+
</template>
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The data each built-in block type draws (#5352), as JSON Schemas in the
|
|
3
|
+
* cards' subset: data that does not fit draws the block as invalid.
|
|
4
|
+
*/
|
|
5
|
+
import type { CardSchema } from '../../cards/validate'
|
|
6
|
+
|
|
7
|
+
const route: CardSchema = { type: ['string', 'object'], description: 'A route to open' }
|
|
8
|
+
const STATUS = ['critical', 'watch', 'good', 'info']
|
|
9
|
+
|
|
10
|
+
export const kpiSchema: CardSchema = {
|
|
11
|
+
type: 'object',
|
|
12
|
+
required: ['label', 'value'],
|
|
13
|
+
additionalProperties: false,
|
|
14
|
+
properties: {
|
|
15
|
+
label: { type: 'string' },
|
|
16
|
+
value: { type: ['number', 'string'] },
|
|
17
|
+
unit: { type: 'string' },
|
|
18
|
+
decimals: { type: 'integer', minimum: 0, maximum: 6 },
|
|
19
|
+
note: { type: 'string' },
|
|
20
|
+
status: { type: 'string', enum: STATUS },
|
|
21
|
+
to: route,
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const breakdownSchema: CardSchema = {
|
|
26
|
+
type: 'object',
|
|
27
|
+
required: ['groups'],
|
|
28
|
+
additionalProperties: false,
|
|
29
|
+
properties: {
|
|
30
|
+
groups: {
|
|
31
|
+
type: 'array',
|
|
32
|
+
items: {
|
|
33
|
+
type: 'object',
|
|
34
|
+
required: ['rows'],
|
|
35
|
+
additionalProperties: false,
|
|
36
|
+
properties: {
|
|
37
|
+
title: { type: 'string' },
|
|
38
|
+
rows: {
|
|
39
|
+
type: 'array',
|
|
40
|
+
items: {
|
|
41
|
+
type: 'object',
|
|
42
|
+
required: ['label', 'value'],
|
|
43
|
+
additionalProperties: false,
|
|
44
|
+
properties: { label: { type: 'string' }, value: { type: 'number', minimum: 0 }, to: route },
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
note: { type: 'string' },
|
|
51
|
+
},
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const topSchema: CardSchema = {
|
|
55
|
+
type: 'object',
|
|
56
|
+
required: ['columns', 'rows'],
|
|
57
|
+
additionalProperties: false,
|
|
58
|
+
properties: {
|
|
59
|
+
columns: {
|
|
60
|
+
type: 'array',
|
|
61
|
+
minItems: 1,
|
|
62
|
+
items: {
|
|
63
|
+
type: 'object',
|
|
64
|
+
required: ['key', 'label'],
|
|
65
|
+
additionalProperties: false,
|
|
66
|
+
properties: {
|
|
67
|
+
key: { type: 'string' },
|
|
68
|
+
label: { type: 'string' },
|
|
69
|
+
type: { type: 'string', enum: ['text', 'mono', 'tags', 'number', 'spark'] },
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
rows: {
|
|
74
|
+
type: 'array',
|
|
75
|
+
items: {
|
|
76
|
+
type: 'object',
|
|
77
|
+
required: ['values'],
|
|
78
|
+
additionalProperties: false,
|
|
79
|
+
properties: {
|
|
80
|
+
values: { type: 'object' },
|
|
81
|
+
to: route,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export const timelineSchema: CardSchema = {
|
|
89
|
+
type: 'object',
|
|
90
|
+
required: ['points'],
|
|
91
|
+
additionalProperties: false,
|
|
92
|
+
properties: {
|
|
93
|
+
points: {
|
|
94
|
+
type: 'array',
|
|
95
|
+
items: {
|
|
96
|
+
type: 'object',
|
|
97
|
+
required: ['at', 'value'],
|
|
98
|
+
additionalProperties: false,
|
|
99
|
+
properties: { at: { type: ['string', 'number'] }, value: { type: 'number', minimum: 0 } },
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
bucket: { type: 'string', enum: ['day', 'hour'], description: 'One bar per day (default) or per hour' },
|
|
103
|
+
label: { type: 'string', description: 'What is counted: "loans"' },
|
|
104
|
+
previous: { type: 'number', minimum: 0, description: 'The total of the period before, for the change' },
|
|
105
|
+
higherIs: { type: 'string', enum: ['better', 'worse', 'neutral'] },
|
|
106
|
+
},
|
|
107
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QdDomainBoard (#5352): a domain's board of typed blocks on a grid of 12.
|
|
3
|
+
*/
|
|
4
|
+
import { registerBoardBlock } from './registry'
|
|
5
|
+
import { kpiSchema, breakdownSchema, topSchema, timelineSchema } from './blocks/schemas'
|
|
6
|
+
import KpiBlock from './blocks/KpiBlock.vue'
|
|
7
|
+
import BreakdownBlock from './blocks/BreakdownBlock.vue'
|
|
8
|
+
import TopBlock from './blocks/TopBlock.vue'
|
|
9
|
+
import TimelineBlock from './blocks/TimelineBlock.vue'
|
|
10
|
+
|
|
11
|
+
export { default as QdDomainBoard } from './QdDomainBoard.vue'
|
|
12
|
+
export { default as QdBoardBlock } from './QdBoardBlock.vue'
|
|
13
|
+
export { registerBoardBlock, getBoardBlock, listBoardBlocks, type BoardBlockType } from './registry'
|
|
14
|
+
export type { BoardBlock, BoardSource } from './types'
|
|
15
|
+
|
|
16
|
+
/** qdadm's block types */
|
|
17
|
+
export const BOARD_BLOCKS = ['kpi', 'breakdown', 'top', 'timeline'] as const
|
|
18
|
+
|
|
19
|
+
export function registerBuiltinBoardBlocks(): void {
|
|
20
|
+
registerBoardBlock('kpi', { component: KpiBlock, schema: kpiSchema, span: 3 })
|
|
21
|
+
registerBoardBlock('breakdown', {
|
|
22
|
+
component: BreakdownBlock,
|
|
23
|
+
schema: breakdownSchema,
|
|
24
|
+
span: 5,
|
|
25
|
+
isEmpty: (d) => !((d as { groups?: Array<{ rows: unknown[] }> })?.groups ?? []).some((g) => g.rows?.length),
|
|
26
|
+
})
|
|
27
|
+
registerBoardBlock('top', { component: TopBlock, schema: topSchema, span: 7, isEmpty: (d) => !((d as { rows?: unknown[] })?.rows ?? []).length })
|
|
28
|
+
registerBoardBlock('timeline', { component: TimelineBlock, schema: timelineSchema, span: 12, isEmpty: (d) => !((d as { points?: unknown[] })?.points ?? []).length })
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
registerBuiltinBoardBlocks()
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QdDomainBoard's block types (#5352): kpi, breakdown, top, timeline, and the
|
|
3
|
+
* app's own. A type is a component drawing `data`, the JSON Schema `data`
|
|
4
|
+
* must fit, its default span on the grid of 12, and when its data counts as
|
|
5
|
+
* empty.
|
|
6
|
+
*/
|
|
7
|
+
import type { Component } from 'vue'
|
|
8
|
+
import type { CardSchema } from '../cards/validate'
|
|
9
|
+
|
|
10
|
+
export interface BoardBlockType {
|
|
11
|
+
type: string
|
|
12
|
+
component: Component
|
|
13
|
+
schema: CardSchema
|
|
14
|
+
/** Columns of 12 it takes by default */
|
|
15
|
+
span: number
|
|
16
|
+
/** Nothing to show: the block draws its empty state instead */
|
|
17
|
+
isEmpty?: (data: unknown) => boolean
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const types = new Map<string, BoardBlockType>()
|
|
21
|
+
|
|
22
|
+
/** Add a block type, or replace one */
|
|
23
|
+
export function registerBoardBlock(type: string, def: Omit<BoardBlockType, 'type'>): void {
|
|
24
|
+
types.set(type, { ...def, type })
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function getBoardBlock(type: string): BoardBlockType | undefined {
|
|
28
|
+
return types.get(type)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function listBoardBlocks(): BoardBlockType[] {
|
|
32
|
+
return [...types.values()]
|
|
33
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A block of QdDomainBoard, as the app declares it (#5352).
|
|
3
|
+
*/
|
|
4
|
+
import type { RouteLocationRaw } from 'vue-router'
|
|
5
|
+
|
|
6
|
+
export interface BoardBlock {
|
|
7
|
+
/** kpi, breakdown, top, timeline, or a type the app registered */
|
|
8
|
+
type: string
|
|
9
|
+
/** Its key (default its index) */
|
|
10
|
+
id?: string
|
|
11
|
+
/** Its heading; a kpi carries its own label */
|
|
12
|
+
title?: string
|
|
13
|
+
/** Columns of 12; default the type's */
|
|
14
|
+
span?: number
|
|
15
|
+
/** The data, when the app has it already */
|
|
16
|
+
data?: unknown
|
|
17
|
+
/** Or how to read it: the block waits alone, and says when it failed */
|
|
18
|
+
load?: () => unknown | Promise<unknown>
|
|
19
|
+
/** "All 69 →": the full list */
|
|
20
|
+
more?: { label: string; to: RouteLocationRaw }
|
|
21
|
+
/** What to say when there is nothing */
|
|
22
|
+
emptyText?: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Where the board's data comes from, and how fresh it is */
|
|
26
|
+
export interface BoardSource {
|
|
27
|
+
label: string
|
|
28
|
+
/** When it was read: a Date, an ISO string or a timestamp */
|
|
29
|
+
freshness?: string | number | Date
|
|
30
|
+
/** The source itself (an internal route or an outside address) */
|
|
31
|
+
to?: RouteLocationRaw
|
|
32
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* QdCard - the envelope every card shares (#5339)
|
|
4
|
+
*
|
|
5
|
+
* qdadm draws the frame, the card type draws the body (the default slot):
|
|
6
|
+
*
|
|
7
|
+
* <QdCard title="Commandes à traiter" status="critical" source="boutique" :freshness="readAt"
|
|
8
|
+
* :to="{ name: 'orders' }" :action="{ verb: 'Traiter la 1re', mode: 'next', to: firstOrder }">
|
|
9
|
+
* …the body…
|
|
10
|
+
* </QdCard>
|
|
11
|
+
*
|
|
12
|
+
* Two zones, one thing each: the surface (the title's link stretched over the
|
|
13
|
+
* card) opens the domain's board; the action button, and any link or button
|
|
14
|
+
* in the body, does its own gesture and stops there.
|
|
15
|
+
*
|
|
16
|
+
* The status is a hue, a side bar and a word: never the hue alone.
|
|
17
|
+
* States `loading`, `unreachable`, `empty` and `invalid` replace the body.
|
|
18
|
+
*/
|
|
19
|
+
import { computed, ref } from 'vue'
|
|
20
|
+
import { RouterLink, useRouter } from 'vue-router'
|
|
21
|
+
import { useI18n } from '../i18n/useI18n'
|
|
22
|
+
import type { CardAction, CardSize, CardState, CardStatus } from './types'
|
|
23
|
+
import type { SchemaProblem } from './validate'
|
|
24
|
+
import { useRun } from '../run/useRun'
|
|
25
|
+
import type { RouteLocationRaw } from 'vue-router'
|
|
26
|
+
|
|
27
|
+
const props = withDefaults(
|
|
28
|
+
defineProps<{
|
|
29
|
+
title: string
|
|
30
|
+
status?: CardStatus | null
|
|
31
|
+
source?: string | null
|
|
32
|
+
freshness?: string | number | Date | null
|
|
33
|
+
to?: RouteLocationRaw | null
|
|
34
|
+
action?: CardAction | null
|
|
35
|
+
state?: CardState
|
|
36
|
+
size?: CardSize
|
|
37
|
+
error?: string | null
|
|
38
|
+
emptyText?: string | null
|
|
39
|
+
/** `invalid`: what does not fit the schema */
|
|
40
|
+
problems?: SchemaProblem[]
|
|
41
|
+
}>(),
|
|
42
|
+
{
|
|
43
|
+
status: null,
|
|
44
|
+
source: null,
|
|
45
|
+
freshness: null,
|
|
46
|
+
to: null,
|
|
47
|
+
action: null,
|
|
48
|
+
state: 'ready',
|
|
49
|
+
size: 's',
|
|
50
|
+
error: null,
|
|
51
|
+
emptyText: null,
|
|
52
|
+
problems: () => [],
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
const { t, locale } = useI18n()
|
|
57
|
+
const router = useRouter()
|
|
58
|
+
const run = useRun()
|
|
59
|
+
|
|
60
|
+
const STATUS_ICONS: Record<CardStatus, string> = {
|
|
61
|
+
critical: 'pi pi-exclamation-circle',
|
|
62
|
+
watch: 'pi pi-exclamation-triangle',
|
|
63
|
+
good: 'pi pi-check-circle',
|
|
64
|
+
info: 'pi pi-info-circle',
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const span = computed(() => ({ s: 1, m: 2, l: 3 })[props.size] ?? 1)
|
|
68
|
+
|
|
69
|
+
/** "3 min ago", in the app's language */
|
|
70
|
+
const freshnessText = computed(() => {
|
|
71
|
+
if (props.freshness === null || props.freshness === undefined || props.freshness === '') return null
|
|
72
|
+
const at = props.freshness instanceof Date ? props.freshness : new Date(props.freshness)
|
|
73
|
+
if (Number.isNaN(at.getTime())) return String(props.freshness)
|
|
74
|
+
const seconds = Math.round((at.getTime() - Date.now()) / 1000)
|
|
75
|
+
const rtf = new Intl.RelativeTimeFormat(locale.value, { numeric: 'auto' })
|
|
76
|
+
const abs = Math.abs(seconds)
|
|
77
|
+
if (abs < 45) return rtf.format(0, 'second')
|
|
78
|
+
if (abs < 3600) return rtf.format(Math.round(seconds / 60), 'minute')
|
|
79
|
+
if (abs < 86400) return rtf.format(Math.round(seconds / 3600), 'hour')
|
|
80
|
+
return rtf.format(Math.round(seconds / 86400), 'day')
|
|
81
|
+
})
|
|
82
|
+
const freshnessTitle = computed(() => {
|
|
83
|
+
if (!props.freshness) return undefined
|
|
84
|
+
const at = props.freshness instanceof Date ? props.freshness : new Date(props.freshness)
|
|
85
|
+
return Number.isNaN(at.getTime()) ? undefined : at.toLocaleString(locale.value)
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
const running = ref(false)
|
|
89
|
+
async function onAction(): Promise<void> {
|
|
90
|
+
const action = props.action
|
|
91
|
+
if (!action || running.value) return
|
|
92
|
+
if (action.onClick) {
|
|
93
|
+
running.value = true
|
|
94
|
+
try {
|
|
95
|
+
await action.onClick()
|
|
96
|
+
} finally {
|
|
97
|
+
running.value = false
|
|
98
|
+
}
|
|
99
|
+
} else if (action.run) {
|
|
100
|
+
await run.start(action.run)
|
|
101
|
+
} else if (action.to) {
|
|
102
|
+
await router.push(action.to)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const actionIcon = computed(() => (props.action?.mode === 'list' ? 'pi pi-list' : 'pi pi-arrow-right'))
|
|
107
|
+
</script>
|
|
108
|
+
|
|
109
|
+
<template>
|
|
110
|
+
<article
|
|
111
|
+
class="qd-card"
|
|
112
|
+
:class="[status ? `qd-card--${status}` : null, `qd-card--${size}`, `qd-card--${state}`, { 'qd-card--link': !!to }]"
|
|
113
|
+
:style="{ '--qd-card-span': span }"
|
|
114
|
+
:aria-busy="state === 'loading' ? 'true' : undefined"
|
|
115
|
+
:data-card-state="state"
|
|
116
|
+
>
|
|
117
|
+
<header class="qd-card-head">
|
|
118
|
+
<h3 class="qd-card-title">
|
|
119
|
+
<RouterLink v-if="to" :to="to" class="qd-card-surface">{{ title }}</RouterLink>
|
|
120
|
+
<span v-else>{{ title }}</span>
|
|
121
|
+
</h3>
|
|
122
|
+
<span v-if="status" class="qd-card-status">
|
|
123
|
+
<i :class="STATUS_ICONS[status]" aria-hidden="true"></i>
|
|
124
|
+
{{ t(`core.cards.status.${status}`) }}
|
|
125
|
+
</span>
|
|
126
|
+
</header>
|
|
127
|
+
|
|
128
|
+
<div class="qd-card-body">
|
|
129
|
+
<div v-if="state === 'loading'" class="qd-card-placeholder qd-card-loading" role="status">
|
|
130
|
+
<span class="qd-card-skeleton qd-card-skeleton--big"></span>
|
|
131
|
+
<span class="qd-card-skeleton"></span>
|
|
132
|
+
<span class="qd-card-skeleton qd-card-skeleton--short"></span>
|
|
133
|
+
<span class="qd-card-sr">{{ t('core.cards.loading') }}</span>
|
|
134
|
+
</div>
|
|
135
|
+
<div v-else-if="state === 'unreachable'" class="qd-card-placeholder qd-card-unreachable" role="status">
|
|
136
|
+
<i class="pi pi-wifi" aria-hidden="true"></i>
|
|
137
|
+
<strong>{{ t('core.cards.unreachable') }}</strong>
|
|
138
|
+
<span v-if="error" class="qd-card-detail">{{ error }}</span>
|
|
139
|
+
</div>
|
|
140
|
+
<div v-else-if="state === 'empty'" class="qd-card-placeholder qd-card-empty" role="status">
|
|
141
|
+
<i class="pi pi-check" aria-hidden="true"></i>
|
|
142
|
+
<span>{{ emptyText || t('core.cards.empty') }}</span>
|
|
143
|
+
</div>
|
|
144
|
+
<div v-else-if="state === 'invalid'" class="qd-card-placeholder qd-card-invalid" role="alert">
|
|
145
|
+
<i class="pi pi-exclamation-triangle" aria-hidden="true"></i>
|
|
146
|
+
<strong>{{ t('core.cards.invalid') }}</strong>
|
|
147
|
+
<ul class="qd-card-problems">
|
|
148
|
+
<li v-for="(p, i) in problems.slice(0, 4)" :key="i"><code>{{ p.path }}</code> {{ p.message }}</li>
|
|
149
|
+
<li v-if="problems.length > 4">{{ t('core.cards.moreProblems', { count: problems.length - 4 }) }}</li>
|
|
150
|
+
</ul>
|
|
151
|
+
</div>
|
|
152
|
+
<slot v-else></slot>
|
|
153
|
+
</div>
|
|
154
|
+
|
|
155
|
+
<footer v-if="source || freshnessText || action" class="qd-card-foot">
|
|
156
|
+
<span class="qd-card-meta">
|
|
157
|
+
<span v-if="source" class="qd-card-source">{{ source }}</span>
|
|
158
|
+
<span v-if="source && freshnessText" aria-hidden="true"> · </span>
|
|
159
|
+
<time v-if="freshnessText" :title="freshnessTitle" class="qd-card-fresh">{{ freshnessText }}</time>
|
|
160
|
+
</span>
|
|
161
|
+
<button
|
|
162
|
+
v-if="action && state === 'ready'"
|
|
163
|
+
type="button"
|
|
164
|
+
class="qd-card-action"
|
|
165
|
+
:class="{ 'qd-card-action--busy': running }"
|
|
166
|
+
:disabled="running"
|
|
167
|
+
:data-mode="action.mode || 'next'"
|
|
168
|
+
@click="onAction"
|
|
169
|
+
>
|
|
170
|
+
<span>{{ action.verb }}</span>
|
|
171
|
+
<i :class="actionIcon" aria-hidden="true"></i>
|
|
172
|
+
</button>
|
|
173
|
+
</footer>
|
|
174
|
+
</article>
|
|
175
|
+
</template>
|