@antelopejs/dms-api 0.0.1
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/LICENSE +190 -0
- package/README.md +61 -0
- package/dist/automation/get-api-health.d.ts +10 -0
- package/dist/automation/get-api-health.js +53 -0
- package/dist/automation/get-api-health.js.map +1 -0
- package/dist/automation/index.d.ts +2 -0
- package/dist/automation/index.js +19 -0
- package/dist/automation/index.js.map +1 -0
- package/dist/automation/query-request-logs.d.ts +18 -0
- package/dist/automation/query-request-logs.js +50 -0
- package/dist/automation/query-request-logs.js.map +1 -0
- package/dist/automation/route-unhealthy.d.ts +9 -0
- package/dist/automation/route-unhealthy.js +102 -0
- package/dist/automation/route-unhealthy.js.map +1 -0
- package/dist/automation/scope.d.ts +2 -0
- package/dist/automation/scope.js +18 -0
- package/dist/automation/scope.js.map +1 -0
- package/dist/config.d.ts +12 -0
- package/dist/config.js +38 -0
- package/dist/config.js.map +1 -0
- package/dist/db/index.d.ts +2 -0
- package/dist/db/index.js +19 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/models/api_settings.model.d.ts +23 -0
- package/dist/db/models/api_settings.model.js +13 -0
- package/dist/db/models/api_settings.model.js.map +1 -0
- package/dist/db/models/index.d.ts +4 -0
- package/dist/db/models/index.js +21 -0
- package/dist/db/models/index.js.map +1 -0
- package/dist/db/models/request_log.model.d.ts +47 -0
- package/dist/db/models/request_log.model.js +127 -0
- package/dist/db/models/request_log.model.js.map +1 -0
- package/dist/db/models/routes.model.d.ts +22 -0
- package/dist/db/models/routes.model.js +9 -0
- package/dist/db/models/routes.model.js.map +1 -0
- package/dist/db/models/routes_statistics.model.d.ts +23 -0
- package/dist/db/models/routes_statistics.model.js +13 -0
- package/dist/db/models/routes_statistics.model.js.map +1 -0
- package/dist/db/tables/api_settings.table.d.ts +10 -0
- package/dist/db/tables/api_settings.table.js +47 -0
- package/dist/db/tables/api_settings.table.js.map +1 -0
- package/dist/db/tables/index.d.ts +4 -0
- package/dist/db/tables/index.js +21 -0
- package/dist/db/tables/index.js.map +1 -0
- package/dist/db/tables/request_log.table.d.ts +29 -0
- package/dist/db/tables/request_log.table.js +107 -0
- package/dist/db/tables/request_log.table.js.map +1 -0
- package/dist/db/tables/routes.table.d.ts +11 -0
- package/dist/db/tables/routes.table.js +50 -0
- package/dist/db/tables/routes.table.js.map +1 -0
- package/dist/db/tables/routes_statistics.table.d.ts +9 -0
- package/dist/db/tables/routes_statistics.table.js +38 -0
- package/dist/db/tables/routes_statistics.table.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -0
- package/dist/middlewares/index.d.ts +1 -0
- package/dist/middlewares/index.js +18 -0
- package/dist/middlewares/index.js.map +1 -0
- package/dist/middlewares/request-log-capture.d.ts +1 -0
- package/dist/middlewares/request-log-capture.js +6 -0
- package/dist/middlewares/request-log-capture.js.map +1 -0
- package/dist/pages/all.d.ts +4 -0
- package/dist/pages/all.js +21 -0
- package/dist/pages/all.js.map +1 -0
- package/dist/pages/index.d.ts +4 -0
- package/dist/pages/index.js +21 -0
- package/dist/pages/index.js.map +1 -0
- package/dist/pages/logs/page.d.ts +9 -0
- package/dist/pages/logs/page.js +29 -0
- package/dist/pages/logs/page.js.map +1 -0
- package/dist/pages/module.d.ts +1 -0
- package/dist/pages/module.js +12 -0
- package/dist/pages/module.js.map +1 -0
- package/dist/pages/routes/page.d.ts +9 -0
- package/dist/pages/routes/page.js +29 -0
- package/dist/pages/routes/page.js.map +1 -0
- package/dist/pages/settings/form.d.ts +3 -0
- package/dist/pages/settings/form.js +80 -0
- package/dist/pages/settings/form.js.map +1 -0
- package/dist/pages/settings/page.d.ts +9 -0
- package/dist/pages/settings/page.js +26 -0
- package/dist/pages/settings/page.js.map +1 -0
- package/dist/pages/summary/page.d.ts +9 -0
- package/dist/pages/summary/page.js +29 -0
- package/dist/pages/summary/page.js.map +1 -0
- package/dist/routes/index.d.ts +5 -0
- package/dist/routes/index.js +22 -0
- package/dist/routes/index.js.map +1 -0
- package/dist/routes/logs.d.ts +7 -0
- package/dist/routes/logs.js +128 -0
- package/dist/routes/logs.js.map +1 -0
- package/dist/routes/monitoring.d.ts +17 -0
- package/dist/routes/monitoring.js +101 -0
- package/dist/routes/monitoring.js.map +1 -0
- package/dist/routes/routes.d.ts +37 -0
- package/dist/routes/routes.js +153 -0
- package/dist/routes/routes.js.map +1 -0
- package/dist/routes/settings.d.ts +24 -0
- package/dist/routes/settings.js +92 -0
- package/dist/routes/settings.js.map +1 -0
- package/dist/routes/summary.d.ts +32 -0
- package/dist/routes/summary.js +181 -0
- package/dist/routes/summary.js.map +1 -0
- package/dist/services/index.d.ts +11 -0
- package/dist/services/index.js +28 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/introspection/auth.d.ts +4 -0
- package/dist/services/introspection/auth.js +33 -0
- package/dist/services/introspection/auth.js.map +1 -0
- package/dist/services/introspection/errors.d.ts +6 -0
- package/dist/services/introspection/errors.js +50 -0
- package/dist/services/introspection/errors.js.map +1 -0
- package/dist/services/introspection/index.d.ts +53 -0
- package/dist/services/introspection/index.js +141 -0
- package/dist/services/introspection/index.js.map +1 -0
- package/dist/services/introspection/probe.d.ts +18 -0
- package/dist/services/introspection/probe.js +155 -0
- package/dist/services/introspection/probe.js.map +1 -0
- package/dist/services/period.d.ts +11 -0
- package/dist/services/period.js +68 -0
- package/dist/services/period.js.map +1 -0
- package/dist/services/request-log/capture.d.ts +10 -0
- package/dist/services/request-log/capture.js +189 -0
- package/dist/services/request-log/capture.js.map +1 -0
- package/dist/services/request-log/index.d.ts +3 -0
- package/dist/services/request-log/index.js +12 -0
- package/dist/services/request-log/index.js.map +1 -0
- package/dist/services/request-log/prune.d.ts +2 -0
- package/dist/services/request-log/prune.js +10 -0
- package/dist/services/request-log/prune.js.map +1 -0
- package/dist/services/request-log/read.d.ts +6 -0
- package/dist/services/request-log/read.js +26 -0
- package/dist/services/request-log/read.js.map +1 -0
- package/dist/services/request-log/redaction.d.ts +4 -0
- package/dist/services/request-log/redaction.js +53 -0
- package/dist/services/request-log/redaction.js.map +1 -0
- package/dist/services/request-log/util.d.ts +13 -0
- package/dist/services/request-log/util.js +114 -0
- package/dist/services/request-log/util.js.map +1 -0
- package/dist/services/routes-sync.d.ts +5 -0
- package/dist/services/routes-sync.js +63 -0
- package/dist/services/routes-sync.js.map +1 -0
- package/dist/services/scope.d.ts +7 -0
- package/dist/services/scope.js +40 -0
- package/dist/services/scope.js.map +1 -0
- package/dist/services/settings.d.ts +20 -0
- package/dist/services/settings.js +86 -0
- package/dist/services/settings.js.map +1 -0
- package/dist/services/statistics-aggregate.d.ts +67 -0
- package/dist/services/statistics-aggregate.js +340 -0
- package/dist/services/statistics-aggregate.js.map +1 -0
- package/dist/services/statistics-prune.d.ts +2 -0
- package/dist/services/statistics-prune.js +25 -0
- package/dist/services/statistics-prune.js.map +1 -0
- package/dist/services/statistics-read.d.ts +4 -0
- package/dist/services/statistics-read.js +48 -0
- package/dist/services/statistics-read.js.map +1 -0
- package/dist/services/statistics-utils.d.ts +14 -0
- package/dist/services/statistics-utils.js +65 -0
- package/dist/services/statistics-utils.js.map +1 -0
- package/dist/services/statistics-write.d.ts +3 -0
- package/dist/services/statistics-write.js +84 -0
- package/dist/services/statistics-write.js.map +1 -0
- package/dist/services/tree.d.ts +10 -0
- package/dist/services/tree.js +128 -0
- package/dist/services/tree.js.map +1 -0
- package/dist/types/charts.d.ts +9 -0
- package/dist/types/charts.js +3 -0
- package/dist/types/charts.js.map +1 -0
- package/dist/types/constants.d.ts +31 -0
- package/dist/types/constants.js +49 -0
- package/dist/types/constants.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +20 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/statistics.d.ts +17 -0
- package/dist/types/statistics.js +3 -0
- package/dist/types/statistics.js.map +1 -0
- package/frontend-vue/.editorconfig +12 -0
- package/frontend-vue/.prettierrc +12 -0
- package/frontend-vue/.vscode/settings.json +26 -0
- package/frontend-vue/app/components/ConfigurationView.vue +187 -0
- package/frontend-vue/app/components/DocumentationView.vue +224 -0
- package/frontend-vue/app/components/LogDetailDrawer.vue +178 -0
- package/frontend-vue/app/components/LogsView.vue +347 -0
- package/frontend-vue/app/components/RouteDetailTabs.vue +179 -0
- package/frontend-vue/app/components/RouteTree.vue +196 -0
- package/frontend-vue/app/components/RoutesView.vue +82 -0
- package/frontend-vue/app/components/StatsView.vue +268 -0
- package/frontend-vue/app/components/SummaryView.vue +657 -0
- package/frontend-vue/app/components/TesterPanel.vue +499 -0
- package/frontend-vue/app/components/internal/ApiMethodBadge.vue +33 -0
- package/frontend-vue/app/components/internal/ApiStatusBadge.vue +28 -0
- package/frontend-vue/app/components/internal/PeriodSelect.vue +58 -0
- package/frontend-vue/app/components/internal/RouteTreeNode.vue +168 -0
- package/frontend-vue/app/components/internal/StatusBreakdownBars.vue +162 -0
- package/frontend-vue/app/components/internal/StatusDonut.vue +84 -0
- package/frontend-vue/app/components/internal/UnitAreaChart.vue +73 -0
- package/frontend-vue/app/composables/useApiIntrospection.ts +344 -0
- package/frontend-vue/app/composables/useLogDetailDrawer.ts +50 -0
- package/frontend-vue/app/composables/useSelectedPeriod.ts +107 -0
- package/frontend-vue/app/composables/useStatsPeriods.ts +139 -0
- package/frontend-vue/app/custom-layouts/.gitkeep +0 -0
- package/frontend-vue/app/custom-pages/.gitkeep +0 -0
- package/frontend-vue/app/utils/httpMethod.ts +49 -0
- package/frontend-vue/app/utils/statusClass.ts +49 -0
- package/frontend-vue/app/utils/testerRequest.ts +50 -0
- package/frontend-vue/dms.frontend.ts +25 -0
- package/frontend-vue/eslint.config.mjs +16 -0
- package/frontend-vue/i18n/locales/en-GB.json +240 -0
- package/frontend-vue/i18n/locales/fr-FR.json +240 -0
- package/frontend-vue/package.json +35 -0
- package/frontend-vue/pnpm-lock.yaml +5796 -0
- package/frontend-vue/pnpm-workspace.yaml +2 -0
- package/frontend-vue/public/.gitkeep +0 -0
- package/frontend-vue/server/.gitkeep +0 -0
- package/frontend-vue/tests/periods.test.ts +145 -0
- package/frontend-vue/tests/persistence.test.ts +45 -0
- package/frontend-vue/tests/registration.test.ts +28 -0
- package/frontend-vue/tests/testerRequest.test.ts +95 -0
- package/frontend-vue/tsconfig.json +13 -0
- package/frontend-vue/vitest.config.ts +8 -0
- package/package.json +67 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import type {
|
|
4
|
+
ApiTreeNode,
|
|
5
|
+
TreeNodeStats,
|
|
6
|
+
} from '../../composables/useApiIntrospection'
|
|
7
|
+
import ApiMethodBadge from './ApiMethodBadge.vue'
|
|
8
|
+
// Recurses into branch folders via its Nuxt auto-import name
|
|
9
|
+
// (<DmsApiRouteTreeNode>) — no explicit self-import needed.
|
|
10
|
+
|
|
11
|
+
// One folder node of the routes tree. The backend builds the tree one folder
|
|
12
|
+
// per path segment, so most routes bottom out in a *terminal* folder whose only
|
|
13
|
+
// children are method leaves (e.g. `home/pagelayout` → GET). To match the DMS
|
|
14
|
+
// maquette — which lists routes as flat "method + name + health icons" leaves —
|
|
15
|
+
// we flatten those terminal sub-folders into route rows and only keep folders
|
|
16
|
+
// that still branch (have sub-folders) as expandable nodes.
|
|
17
|
+
const props = defineProps<{
|
|
18
|
+
node: ApiTreeNode
|
|
19
|
+
depth: number
|
|
20
|
+
expanded: Set<string>
|
|
21
|
+
forceExpand: boolean
|
|
22
|
+
activeRouteId?: string
|
|
23
|
+
}>()
|
|
24
|
+
|
|
25
|
+
const emit = defineEmits<{
|
|
26
|
+
toggle: [path: string]
|
|
27
|
+
selectRoute: [routeId: string]
|
|
28
|
+
}>()
|
|
29
|
+
|
|
30
|
+
const path = computed(() => props.node.value ?? '')
|
|
31
|
+
const isOpen = computed(
|
|
32
|
+
() => props.forceExpand || props.expanded.has(path.value),
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
interface RouteRow {
|
|
36
|
+
routeId: string
|
|
37
|
+
method: string
|
|
38
|
+
name: string
|
|
39
|
+
stats?: TreeNodeStats
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function isFolder(n: ApiTreeNode): boolean {
|
|
43
|
+
return n.expandable === true
|
|
44
|
+
}
|
|
45
|
+
function isTerminal(folder: ApiTreeNode): boolean {
|
|
46
|
+
return (folder.children ?? []).every((c) => !isFolder(c))
|
|
47
|
+
}
|
|
48
|
+
function leafRows(folder: ApiTreeNode, name: string): RouteRow[] {
|
|
49
|
+
return (folder.children ?? [])
|
|
50
|
+
.filter((c) => !isFolder(c))
|
|
51
|
+
.map((leaf) => ({
|
|
52
|
+
routeId: leaf.value as string,
|
|
53
|
+
method: leaf.label,
|
|
54
|
+
name,
|
|
55
|
+
stats: leaf.customData as TreeNodeStats | undefined,
|
|
56
|
+
}))
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Route rows shown directly under this folder: this folder's own method leaves
|
|
60
|
+
// (named after this folder) + every terminal sub-folder's leaves (named after
|
|
61
|
+
// that sub-folder).
|
|
62
|
+
const routeRows = computed<RouteRow[]>(() => {
|
|
63
|
+
const own = leafRows(props.node, props.node.label)
|
|
64
|
+
const fromTerminal = (props.node.children ?? [])
|
|
65
|
+
.filter((c) => isFolder(c) && isTerminal(c))
|
|
66
|
+
.flatMap((f) => leafRows(f, f.label))
|
|
67
|
+
return [...own, ...fromTerminal]
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
// Sub-folders that still branch — rendered as nested expandable folders.
|
|
71
|
+
const branchFolders = computed(() =>
|
|
72
|
+
(props.node.children ?? []).filter((c) => isFolder(c) && !isTerminal(c)),
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
// Health indicators: an orange timer when the route is slow, a warning
|
|
76
|
+
// triangle when it errors. Healthy / no-traffic routes show nothing.
|
|
77
|
+
interface HealthIcon {
|
|
78
|
+
name: string
|
|
79
|
+
class: string
|
|
80
|
+
title: string
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Error rate (0-1) above which the node shows a warning icon.
|
|
84
|
+
const ELEVATED_ERROR_RATE = 0.05
|
|
85
|
+
|
|
86
|
+
function healthIcons(stats?: TreeNodeStats): HealthIcon[] {
|
|
87
|
+
if (!stats || stats.requestsCount === 0) return []
|
|
88
|
+
const icons: HealthIcon[] = []
|
|
89
|
+
if (stats.errorRate > ELEVATED_ERROR_RATE) {
|
|
90
|
+
icons.push({
|
|
91
|
+
name: 'i-ph-warning',
|
|
92
|
+
class: 'text-error',
|
|
93
|
+
title: `${(stats.errorRate * 100).toFixed(0)}% err`,
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
if (stats.slow) {
|
|
97
|
+
icons.push({
|
|
98
|
+
name: 'i-ph-timer',
|
|
99
|
+
class: 'text-warning',
|
|
100
|
+
title: 'slow',
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
return icons
|
|
104
|
+
}
|
|
105
|
+
</script>
|
|
106
|
+
|
|
107
|
+
<template>
|
|
108
|
+
<div>
|
|
109
|
+
<!-- folder row -->
|
|
110
|
+
<button
|
|
111
|
+
type="button"
|
|
112
|
+
class="group flex w-full items-center gap-1.5 rounded-md py-1.5 pr-2 text-left text-sm text-toned transition-colors hover:bg-elevated/60"
|
|
113
|
+
:style="{ paddingLeft: `${depth * 14 + 8}px` }"
|
|
114
|
+
@click="emit('toggle', path)"
|
|
115
|
+
>
|
|
116
|
+
<UIcon
|
|
117
|
+
name="i-ph-caret-right"
|
|
118
|
+
class="size-3.5 shrink-0 text-dimmed transition-transform duration-150"
|
|
119
|
+
:class="{ 'rotate-90': isOpen }"
|
|
120
|
+
/>
|
|
121
|
+
<UIcon name="i-ph-folder" class="size-4 shrink-0 text-dimmed" />
|
|
122
|
+
<span class="truncate font-medium">{{ node.label }}</span>
|
|
123
|
+
</button>
|
|
124
|
+
|
|
125
|
+
<div v-show="isOpen">
|
|
126
|
+
<!-- route rows (this folder's routes + flattened terminal sub-folders) -->
|
|
127
|
+
<button
|
|
128
|
+
v-for="row in routeRows"
|
|
129
|
+
:key="row.routeId"
|
|
130
|
+
type="button"
|
|
131
|
+
class="flex w-full items-center gap-2 rounded-md py-1.5 pr-2 text-left transition-colors"
|
|
132
|
+
:class="
|
|
133
|
+
activeRouteId === row.routeId
|
|
134
|
+
? 'bg-primary/10 text-primary'
|
|
135
|
+
: 'text-toned hover:bg-elevated/60'
|
|
136
|
+
"
|
|
137
|
+
:style="{ paddingLeft: `${(depth + 1) * 14 + 10}px` }"
|
|
138
|
+
@click="emit('selectRoute', row.routeId)"
|
|
139
|
+
>
|
|
140
|
+
<ApiMethodBadge :method="row.method" size="sm" />
|
|
141
|
+
<span class="truncate font-mono text-xs">{{ row.name }}</span>
|
|
142
|
+
<span class="ml-auto flex shrink-0 items-center gap-1">
|
|
143
|
+
<UIcon
|
|
144
|
+
v-for="icon in healthIcons(row.stats)"
|
|
145
|
+
:key="icon.name"
|
|
146
|
+
:name="icon.name"
|
|
147
|
+
class="size-3.5"
|
|
148
|
+
:class="icon.class"
|
|
149
|
+
:title="icon.title"
|
|
150
|
+
/>
|
|
151
|
+
</span>
|
|
152
|
+
</button>
|
|
153
|
+
|
|
154
|
+
<!-- nested branch folders (recursion via Nuxt auto-import) -->
|
|
155
|
+
<DmsApiRouteTreeNode
|
|
156
|
+
v-for="folder in branchFolders"
|
|
157
|
+
:key="folder.value ?? folder.label"
|
|
158
|
+
:node="folder"
|
|
159
|
+
:depth="depth + 1"
|
|
160
|
+
:expanded="expanded"
|
|
161
|
+
:force-expand="forceExpand"
|
|
162
|
+
:active-route-id="activeRouteId"
|
|
163
|
+
@toggle="emit('toggle', $event)"
|
|
164
|
+
@select-route="emit('selectRoute', $event)"
|
|
165
|
+
/>
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
</template>
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import type { HistoryPoint } from '../../composables/useApiIntrospection'
|
|
4
|
+
import { STATUS_CLASSES } from '../../utils/statusClass'
|
|
5
|
+
|
|
6
|
+
// "By day" view of the status breakdown (DMS apiv2-overview): one horizontal
|
|
7
|
+
// stacked bar per day, split by status class on a rounded track — with a
|
|
8
|
+
// "high error day" warning badge on days whose error rate clears the
|
|
9
|
+
// threshold, an x-axis scale and a legend. ApexCharts can't render the
|
|
10
|
+
// per-row badges or rounded tracks, so this is a hand-built bar chart.
|
|
11
|
+
const props = defineProps<{
|
|
12
|
+
history: HistoryPoint[]
|
|
13
|
+
highErrorThreshold?: number
|
|
14
|
+
}>()
|
|
15
|
+
|
|
16
|
+
const threshold = computed(() => props.highErrorThreshold ?? 0.3)
|
|
17
|
+
|
|
18
|
+
interface DaySegment {
|
|
19
|
+
key: string
|
|
20
|
+
color: string
|
|
21
|
+
count: number
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface DayRow {
|
|
25
|
+
label: string
|
|
26
|
+
segments: DaySegment[]
|
|
27
|
+
total: number
|
|
28
|
+
errorRate: number
|
|
29
|
+
high: boolean
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Only non-zero segments are drawn — a zero-width div would still take the 3px
|
|
34
|
+
* minimum below. No per-segment corner radius: the track clips them.
|
|
35
|
+
*
|
|
36
|
+
* Segments render in STATUS_CLASSES order, so a stacked bar always reads
|
|
37
|
+
* success → client → server, left to right, and in the same colours the donut
|
|
38
|
+
* beside it uses.
|
|
39
|
+
*/
|
|
40
|
+
function buildSegments(counts: Record<string, number>): DaySegment[] {
|
|
41
|
+
return STATUS_CLASSES.filter((s) => counts[s.key] > 0).map((s) => ({
|
|
42
|
+
key: s.key,
|
|
43
|
+
color: s.color,
|
|
44
|
+
count: counts[s.key],
|
|
45
|
+
}))
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const rows = computed<DayRow[]>(() =>
|
|
49
|
+
props.history.map((p) => {
|
|
50
|
+
const counts = {
|
|
51
|
+
success: p.success,
|
|
52
|
+
clientErrors: p.clientErrors,
|
|
53
|
+
serverErrors: p.serverErrors,
|
|
54
|
+
}
|
|
55
|
+
const errors = counts.clientErrors + counts.serverErrors
|
|
56
|
+
const total = counts.success + errors
|
|
57
|
+
const errorRate = total > 0 ? errors / total : 0
|
|
58
|
+
return {
|
|
59
|
+
label: p.label,
|
|
60
|
+
segments: buildSegments(counts),
|
|
61
|
+
total,
|
|
62
|
+
errorRate,
|
|
63
|
+
high: errorRate >= threshold.value,
|
|
64
|
+
}
|
|
65
|
+
}),
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
// Pick a "nice" axis: three even ticks whose step comes from the 1/2/5
|
|
69
|
+
// sequence so the scale reads 0 / step / 2·step / 3·step (e.g. 0/1k/2k/3k).
|
|
70
|
+
function niceStep(x: number): number {
|
|
71
|
+
if (x <= 0) return 1
|
|
72
|
+
const pow = 10 ** Math.floor(Math.log10(x))
|
|
73
|
+
const frac = x / pow
|
|
74
|
+
const nice = frac <= 1 ? 1 : frac <= 2 ? 2 : frac <= 5 ? 5 : 10
|
|
75
|
+
return nice * pow
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const maxTotal = computed(() => Math.max(0, ...rows.value.map((r) => r.total)))
|
|
79
|
+
const step = computed(() => niceStep(Math.max(1, maxTotal.value) / 3))
|
|
80
|
+
const scale = computed(() => step.value * 3)
|
|
81
|
+
const ticks = computed(() => [0, step.value, 2 * step.value, 3 * step.value])
|
|
82
|
+
|
|
83
|
+
function pct(v: number): number {
|
|
84
|
+
return scale.value > 0 ? (v / scale.value) * 100 : 0
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function fmtTick(v: number): string {
|
|
88
|
+
return v >= 1000 ? `${+(v / 1000).toFixed(1)}k` : String(v)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function fmtPct(rate: number): string {
|
|
92
|
+
return `${Math.round(rate * 100)}%`
|
|
93
|
+
}
|
|
94
|
+
</script>
|
|
95
|
+
|
|
96
|
+
<template>
|
|
97
|
+
<div class="flex flex-col gap-3 px-3 py-2">
|
|
98
|
+
<!-- per-day rows -->
|
|
99
|
+
<div class="flex max-h-[320px] flex-col gap-3.5 overflow-y-auto pr-1">
|
|
100
|
+
<div
|
|
101
|
+
v-for="row in rows"
|
|
102
|
+
:key="row.label"
|
|
103
|
+
class="grid grid-cols-[2.75rem_1fr_3.5rem] items-center gap-3"
|
|
104
|
+
>
|
|
105
|
+
<span class="text-right font-mono text-xs text-dimmed">{{ row.label }}</span>
|
|
106
|
+
|
|
107
|
+
<!-- track -->
|
|
108
|
+
<div class="h-7 overflow-hidden rounded-md bg-elevated/40">
|
|
109
|
+
<div class="flex h-full">
|
|
110
|
+
<div
|
|
111
|
+
v-for="segment in row.segments"
|
|
112
|
+
:key="segment.key"
|
|
113
|
+
class="h-full"
|
|
114
|
+
:style="{
|
|
115
|
+
width: `max(${pct(segment.count)}%, 3px)`,
|
|
116
|
+
background: segment.color,
|
|
117
|
+
}"
|
|
118
|
+
/>
|
|
119
|
+
</div>
|
|
120
|
+
</div>
|
|
121
|
+
|
|
122
|
+
<!-- high-error badge gutter (always reserved so tracks stay aligned) -->
|
|
123
|
+
<div class="flex justify-end">
|
|
124
|
+
<UBadge v-if="row.high" color="warning" variant="subtle" size="sm">
|
|
125
|
+
<UIcon name="i-ph-warning" class="size-3.5" />
|
|
126
|
+
{{ fmtPct(row.errorRate) }}
|
|
127
|
+
</UBadge>
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
|
|
132
|
+
<!-- x-axis -->
|
|
133
|
+
<div class="grid grid-cols-[2.75rem_1fr_3.5rem] gap-3">
|
|
134
|
+
<span />
|
|
135
|
+
<div class="flex justify-between font-mono text-[10px] text-dimmed">
|
|
136
|
+
<span v-for="t in ticks" :key="t">{{ fmtTick(t) }}</span>
|
|
137
|
+
</div>
|
|
138
|
+
<span />
|
|
139
|
+
</div>
|
|
140
|
+
|
|
141
|
+
<!-- legend -->
|
|
142
|
+
<div
|
|
143
|
+
class="flex flex-wrap items-center justify-center gap-4 pt-1 text-xs text-muted"
|
|
144
|
+
>
|
|
145
|
+
<span
|
|
146
|
+
v-for="segment in STATUS_CLASSES"
|
|
147
|
+
:key="segment.key"
|
|
148
|
+
class="flex items-center gap-1.5"
|
|
149
|
+
>
|
|
150
|
+
<span
|
|
151
|
+
class="size-2.5 rounded-full"
|
|
152
|
+
:style="{ background: segment.color }"
|
|
153
|
+
/>
|
|
154
|
+
{{ $t(segment.i18nKey) }}
|
|
155
|
+
</span>
|
|
156
|
+
<span class="flex items-center gap-1.5">
|
|
157
|
+
<UIcon name="i-ph-warning" class="size-3.5 text-warning" />
|
|
158
|
+
{{ $t('page.api.summary.breakdown.high_error_day') }}
|
|
159
|
+
</span>
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
</template>
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
|
|
4
|
+
// Status-breakdown donut (DMS apiv2-overview): a flat conic-gradient ring with
|
|
5
|
+
// a masked centre (total + "responses") and a column legend (dot + name +
|
|
6
|
+
// value + percent) to its right. Built by hand to match the maquette exactly —
|
|
7
|
+
// ApexCharts' donut renders a different ring/legend layout.
|
|
8
|
+
interface DonutSegment {
|
|
9
|
+
label: string
|
|
10
|
+
value: number
|
|
11
|
+
color: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const props = defineProps<{
|
|
15
|
+
segments: DonutSegment[]
|
|
16
|
+
total: number
|
|
17
|
+
centerSubLabel: string
|
|
18
|
+
}>()
|
|
19
|
+
|
|
20
|
+
const ring = computed(() => {
|
|
21
|
+
if (props.total <= 0) return 'transparent'
|
|
22
|
+
let acc = 0
|
|
23
|
+
const stops = props.segments.map((s) => {
|
|
24
|
+
const from = (acc / props.total) * 100
|
|
25
|
+
acc += s.value
|
|
26
|
+
const to = (acc / props.total) * 100
|
|
27
|
+
return `${s.color} ${from.toFixed(2)}% ${to.toFixed(2)}%`
|
|
28
|
+
})
|
|
29
|
+
return `conic-gradient(${stops.join(',')})`
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
function fmtCount(n: number): string {
|
|
33
|
+
return n >= 1000 ? `${(n / 1000).toFixed(1)}k` : String(n)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function pct(value: number): string {
|
|
37
|
+
return props.total > 0 ? `${((value / props.total) * 100).toFixed(1)}%` : '0%'
|
|
38
|
+
}
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<template>
|
|
42
|
+
<div class="flex flex-col items-center gap-7 px-2 py-2 pb-4 sm:flex-row sm:gap-7">
|
|
43
|
+
<!-- ring -->
|
|
44
|
+
<div class="relative size-[168px] shrink-0">
|
|
45
|
+
<div
|
|
46
|
+
class="absolute inset-0 rounded-full"
|
|
47
|
+
:style="{
|
|
48
|
+
background: ring,
|
|
49
|
+
'-webkit-mask': 'radial-gradient(circle, transparent 56%, #000 57%)',
|
|
50
|
+
mask: 'radial-gradient(circle, transparent 56%, #000 57%)',
|
|
51
|
+
}"
|
|
52
|
+
/>
|
|
53
|
+
<div class="absolute inset-0 flex flex-col items-center justify-center gap-0.5 text-center">
|
|
54
|
+
<b class="text-2xl font-semibold leading-none text-highlighted">
|
|
55
|
+
{{ fmtCount(total) }}
|
|
56
|
+
</b>
|
|
57
|
+
<small class="font-mono text-[10px] uppercase tracking-widest text-dimmed">
|
|
58
|
+
{{ centerSubLabel }}
|
|
59
|
+
</small>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
|
|
63
|
+
<!-- legend -->
|
|
64
|
+
<div class="flex w-full flex-1 flex-col gap-3">
|
|
65
|
+
<div
|
|
66
|
+
v-for="s in segments"
|
|
67
|
+
:key="s.label"
|
|
68
|
+
class="flex items-center gap-3"
|
|
69
|
+
>
|
|
70
|
+
<span
|
|
71
|
+
class="size-[11px] shrink-0 rounded-[3px]"
|
|
72
|
+
:style="{ background: s.color }"
|
|
73
|
+
/>
|
|
74
|
+
<span class="flex-1 text-[13px] text-muted">{{ s.label }}</span>
|
|
75
|
+
<span class="font-mono text-[13px] font-semibold text-highlighted">
|
|
76
|
+
{{ fmtCount(s.value) }}
|
|
77
|
+
</span>
|
|
78
|
+
<span class="min-w-[46px] text-right font-mono text-[11px] text-dimmed">
|
|
79
|
+
{{ pct(s.value) }}
|
|
80
|
+
</span>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
</template>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Area chart whose values carry a unit (e.g. "7.52 ms").
|
|
6
|
+
*
|
|
7
|
+
* <DmsChart> has no unit/suffix option: the only formatter it wires into
|
|
8
|
+
* ApexCharts comes from a parent <DmsChartCard>'s `valueFormat`, whose formats
|
|
9
|
+
* are number / currency / percent / compact — none of which can express a
|
|
10
|
+
* duration. Its `rawOptions` escape hatch is JSON-parsed, so a formatter
|
|
11
|
+
* function cannot be passed through it either.
|
|
12
|
+
*
|
|
13
|
+
* So this renders through the same two pieces <DmsChart> itself uses —
|
|
14
|
+
* `useApexChart` for the themed options and <DmsApexChartHost> for the canvas —
|
|
15
|
+
* and supplies the one field <DmsChart> never sets, `yAxisFormatter`. That
|
|
16
|
+
* formatter drives both the y-axis labels and the tooltip values, so the unit
|
|
17
|
+
* shows up in both.
|
|
18
|
+
*/
|
|
19
|
+
interface Series {
|
|
20
|
+
name: string
|
|
21
|
+
data: Array<{ x: string; y: number }>
|
|
22
|
+
color: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const props = withDefaults(
|
|
26
|
+
defineProps<{
|
|
27
|
+
series: Series[]
|
|
28
|
+
unit: string
|
|
29
|
+
colors: string[]
|
|
30
|
+
height?: string
|
|
31
|
+
}>(),
|
|
32
|
+
{ height: '240px' },
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
const themeRevision = useThemeRevision()
|
|
36
|
+
const { locale } = useI18n()
|
|
37
|
+
|
|
38
|
+
// Intl so the decimal separator follows the admin's locale, like every other
|
|
39
|
+
// number the DMS renders.
|
|
40
|
+
const format = computed(() => {
|
|
41
|
+
const nf = new Intl.NumberFormat(locale.value)
|
|
42
|
+
return (value: number) => `${nf.format(value)} ${props.unit}`
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
const apex = useApexChart(() => ({
|
|
46
|
+
type: 'area',
|
|
47
|
+
height: props.height,
|
|
48
|
+
smooth: true,
|
|
49
|
+
showLegend: true,
|
|
50
|
+
series: props.series,
|
|
51
|
+
colors: props.colors,
|
|
52
|
+
themeRevision: themeRevision.value,
|
|
53
|
+
yAxisFormatter: format.value,
|
|
54
|
+
}))
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<template>
|
|
58
|
+
<!-- Same frame classes <DmsChart> puts on a standalone chart, so a card
|
|
59
|
+
holding one of each renders the two identically. -->
|
|
60
|
+
<div class="dms-chart dms-card p-5 sm:p-6">
|
|
61
|
+
<ClientOnly>
|
|
62
|
+
<DmsApexChartHost
|
|
63
|
+
:apex-type="apex.apexType.value"
|
|
64
|
+
:height="height"
|
|
65
|
+
:options="apex.options.value"
|
|
66
|
+
:series="apex.series.value"
|
|
67
|
+
/>
|
|
68
|
+
<template #fallback>
|
|
69
|
+
<USkeleton class="w-full" :style="{ height }" />
|
|
70
|
+
</template>
|
|
71
|
+
</ClientOnly>
|
|
72
|
+
</div>
|
|
73
|
+
</template>
|