@adminforth/dashboard 1.4.2 → 1.6.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/custom/api/dashboardApi.ts +137 -5
- package/custom/model/dashboard.types.ts +32 -22
- package/custom/runtime/DashboardRuntime.vue +2 -3
- package/custom/skills/adminforth-dashboard/SKILL.md +165 -179
- package/custom/widgets/KpiCardWidget.vue +172 -9
- package/custom/widgets/chart/ChartWidget.vue +5 -5
- package/custom/widgets/registry.ts +4 -4
- package/dist/custom/api/dashboardApi.d.ts +46 -2
- package/dist/custom/api/dashboardApi.js +90 -5
- package/dist/custom/api/dashboardApi.ts +137 -5
- package/dist/custom/model/dashboard.types.d.ts +30 -14
- package/dist/custom/model/dashboard.types.js +2 -2
- package/dist/custom/model/dashboard.types.ts +32 -22
- package/dist/custom/queries/useDashboardConfig.d.ts +106 -104
- package/dist/custom/queries/useWidgetData.d.ts +106 -104
- package/dist/custom/runtime/DashboardRuntime.vue +2 -3
- package/dist/custom/skills/adminforth-dashboard/SKILL.md +165 -179
- package/dist/custom/widgets/KpiCardWidget.vue +172 -9
- package/dist/custom/widgets/chart/ChartWidget.vue +5 -5
- package/dist/custom/widgets/registry.js +4 -4
- package/dist/custom/widgets/registry.ts +4 -4
- package/dist/endpoint/dashboard.d.ts +2 -4
- package/dist/endpoint/dashboard.js +1 -21
- package/dist/endpoint/groups.d.ts +1 -0
- package/dist/endpoint/groups.js +61 -48
- package/dist/endpoint/widgets.d.ts +1 -0
- package/dist/endpoint/widgets.js +167 -64
- package/dist/schema/api.d.ts +11710 -2785
- package/dist/schema/api.js +118 -26
- package/dist/schema/widget.d.ts +425 -1980
- package/dist/schema/widget.js +13 -374
- package/dist/schema/widgets/charts.d.ts +1689 -0
- package/dist/schema/widgets/charts.js +92 -0
- package/dist/schema/widgets/common.d.ts +275 -0
- package/dist/schema/widgets/common.js +171 -0
- package/dist/schema/widgets/gauge-card.d.ts +172 -0
- package/dist/schema/widgets/gauge-card.js +28 -0
- package/dist/schema/widgets/kpi-card.d.ts +212 -0
- package/dist/schema/widgets/kpi-card.js +43 -0
- package/dist/schema/widgets/pivot-table.d.ts +196 -0
- package/dist/schema/widgets/pivot-table.js +17 -0
- package/dist/schema/widgets/table.d.ts +130 -0
- package/dist/schema/widgets/table.js +12 -0
- package/dist/services/dashboardConfigService.d.ts +4 -0
- package/dist/services/dashboardConfigService.js +46 -0
- package/dist/services/widgetDataService.js +96 -2
- package/endpoint/dashboard.ts +2 -33
- package/endpoint/groups.ts +91 -72
- package/endpoint/widgets.ts +260 -87
- package/package.json +1 -1
- package/schema/api.ts +148 -28
- package/schema/widget.ts +43 -425
- package/schema/widgets/charts.ts +113 -0
- package/schema/widgets/common.ts +194 -0
- package/schema/widgets/gauge-card.ts +34 -0
- package/schema/widgets/kpi-card.ts +49 -0
- package/schema/widgets/pivot-table.ts +24 -0
- package/schema/widgets/table.ts +18 -0
- package/services/dashboardConfigService.ts +73 -0
- package/services/widgetDataService.ts +129 -3
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
DashboardConfig,
|
|
3
3
|
EditableDashboardGroupConfig,
|
|
4
|
-
EditableDashboardWidgetConfig,
|
|
5
4
|
DashboardGroupMoveDirection,
|
|
5
|
+
ChartDashboardWidgetConfig,
|
|
6
6
|
DashboardWidgetConfig,
|
|
7
7
|
DashboardWidgetConfigValidationError,
|
|
8
8
|
DashboardWidgetMoveDirection,
|
|
9
|
+
GaugeCardWidgetConfig,
|
|
10
|
+
KpiCardWidgetConfig,
|
|
11
|
+
PivotTableWidgetConfig,
|
|
12
|
+
TableWidgetConfig,
|
|
9
13
|
} from '../model/dashboard.types.js'
|
|
10
14
|
|
|
11
15
|
export type DashboardResponse = {
|
|
@@ -28,6 +32,18 @@ export type DashboardWidgetDataRequest = {
|
|
|
28
32
|
}
|
|
29
33
|
}
|
|
30
34
|
|
|
35
|
+
export type ConfigurableTableWidgetConfig = Omit<TableWidgetConfig, 'id' | 'group_id' | 'order'>
|
|
36
|
+
export type ConfigurableKpiCardWidgetConfig = Omit<KpiCardWidgetConfig, 'id' | 'group_id' | 'order'>
|
|
37
|
+
export type ConfigurableGaugeCardWidgetConfig = Omit<GaugeCardWidgetConfig, 'id' | 'group_id' | 'order'>
|
|
38
|
+
export type ConfigurableChartWidgetConfig = Omit<ChartDashboardWidgetConfig, 'id' | 'group_id' | 'order'>
|
|
39
|
+
export type ConfigurableLineChartWidgetConfig = ConfigurableChartWidgetConfig & { chart: { type: 'line' } }
|
|
40
|
+
export type ConfigurableBarChartWidgetConfig = ConfigurableChartWidgetConfig & { chart: { type: 'bar' } }
|
|
41
|
+
export type ConfigurableStackedBarChartWidgetConfig = ConfigurableChartWidgetConfig & { chart: { type: 'stacked_bar' } }
|
|
42
|
+
export type ConfigurablePieChartWidgetConfig = ConfigurableChartWidgetConfig & { chart: { type: 'pie' } }
|
|
43
|
+
export type ConfigurableHistogramChartWidgetConfig = ConfigurableChartWidgetConfig & { chart: { type: 'histogram' } }
|
|
44
|
+
export type ConfigurableFunnelChartWidgetConfig = ConfigurableChartWidgetConfig & { chart: { type: 'funnel' } }
|
|
45
|
+
export type ConfigurablePivotTableWidgetConfig = Omit<PivotTableWidgetConfig, 'id' | 'group_id' | 'order'>
|
|
46
|
+
|
|
31
47
|
export class DashboardApiError extends Error {
|
|
32
48
|
validationErrors: DashboardWidgetConfigValidationError[]
|
|
33
49
|
|
|
@@ -140,10 +156,6 @@ export const dashboardApi = {
|
|
|
140
156
|
return callDashboardApi('/adminapi/v1/dashboard/get-config', { slug })
|
|
141
157
|
},
|
|
142
158
|
|
|
143
|
-
async setDashboardConfig(slug: string, config: unknown): Promise<DashboardResponse> {
|
|
144
|
-
return callDashboardApi('/adminapi/v1/dashboard/set_dashboard_config', { slug, config })
|
|
145
|
-
},
|
|
146
|
-
|
|
147
159
|
async addDashboardGroup(slug: string): Promise<DashboardResponse> {
|
|
148
160
|
return callDashboardApi('/adminapi/v1/dashboard/add_dashboard_group', { slug })
|
|
149
161
|
},
|
|
@@ -209,6 +221,126 @@ export const dashboardApi = {
|
|
|
209
221
|
})
|
|
210
222
|
},
|
|
211
223
|
|
|
224
|
+
async configureTableWidget(
|
|
225
|
+
slug: string,
|
|
226
|
+
widgetId: string,
|
|
227
|
+
config: ConfigurableTableWidgetConfig,
|
|
228
|
+
): Promise<DashboardResponse> {
|
|
229
|
+
return callDashboardApi('/adminapi/v1/dashboard/configure_table_widget', {
|
|
230
|
+
slug,
|
|
231
|
+
widgetId,
|
|
232
|
+
config,
|
|
233
|
+
})
|
|
234
|
+
},
|
|
235
|
+
|
|
236
|
+
async configureKpiCardWidget(
|
|
237
|
+
slug: string,
|
|
238
|
+
widgetId: string,
|
|
239
|
+
config: ConfigurableKpiCardWidgetConfig,
|
|
240
|
+
): Promise<DashboardResponse> {
|
|
241
|
+
return callDashboardApi('/adminapi/v1/dashboard/configure_kpi_card_widget', {
|
|
242
|
+
slug,
|
|
243
|
+
widgetId,
|
|
244
|
+
config,
|
|
245
|
+
})
|
|
246
|
+
},
|
|
247
|
+
|
|
248
|
+
async configureGaugeCardWidget(
|
|
249
|
+
slug: string,
|
|
250
|
+
widgetId: string,
|
|
251
|
+
config: ConfigurableGaugeCardWidgetConfig,
|
|
252
|
+
): Promise<DashboardResponse> {
|
|
253
|
+
return callDashboardApi('/adminapi/v1/dashboard/configure_gauge_card_widget', {
|
|
254
|
+
slug,
|
|
255
|
+
widgetId,
|
|
256
|
+
config,
|
|
257
|
+
})
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
async configureLineChartWidget(
|
|
261
|
+
slug: string,
|
|
262
|
+
widgetId: string,
|
|
263
|
+
config: ConfigurableLineChartWidgetConfig,
|
|
264
|
+
): Promise<DashboardResponse> {
|
|
265
|
+
return callDashboardApi('/adminapi/v1/dashboard/configure_line_chart_widget', {
|
|
266
|
+
slug,
|
|
267
|
+
widgetId,
|
|
268
|
+
config,
|
|
269
|
+
})
|
|
270
|
+
},
|
|
271
|
+
|
|
272
|
+
async configureBarChartWidget(
|
|
273
|
+
slug: string,
|
|
274
|
+
widgetId: string,
|
|
275
|
+
config: ConfigurableBarChartWidgetConfig,
|
|
276
|
+
): Promise<DashboardResponse> {
|
|
277
|
+
return callDashboardApi('/adminapi/v1/dashboard/configure_bar_chart_widget', {
|
|
278
|
+
slug,
|
|
279
|
+
widgetId,
|
|
280
|
+
config,
|
|
281
|
+
})
|
|
282
|
+
},
|
|
283
|
+
|
|
284
|
+
async configureStackedBarChartWidget(
|
|
285
|
+
slug: string,
|
|
286
|
+
widgetId: string,
|
|
287
|
+
config: ConfigurableStackedBarChartWidgetConfig,
|
|
288
|
+
): Promise<DashboardResponse> {
|
|
289
|
+
return callDashboardApi('/adminapi/v1/dashboard/configure_stacked_bar_chart_widget', {
|
|
290
|
+
slug,
|
|
291
|
+
widgetId,
|
|
292
|
+
config,
|
|
293
|
+
})
|
|
294
|
+
},
|
|
295
|
+
|
|
296
|
+
async configurePieChartWidget(
|
|
297
|
+
slug: string,
|
|
298
|
+
widgetId: string,
|
|
299
|
+
config: ConfigurablePieChartWidgetConfig,
|
|
300
|
+
): Promise<DashboardResponse> {
|
|
301
|
+
return callDashboardApi('/adminapi/v1/dashboard/configure_pie_chart_widget', {
|
|
302
|
+
slug,
|
|
303
|
+
widgetId,
|
|
304
|
+
config,
|
|
305
|
+
})
|
|
306
|
+
},
|
|
307
|
+
|
|
308
|
+
async configureHistogramChartWidget(
|
|
309
|
+
slug: string,
|
|
310
|
+
widgetId: string,
|
|
311
|
+
config: ConfigurableHistogramChartWidgetConfig,
|
|
312
|
+
): Promise<DashboardResponse> {
|
|
313
|
+
return callDashboardApi('/adminapi/v1/dashboard/configure_histogram_chart_widget', {
|
|
314
|
+
slug,
|
|
315
|
+
widgetId,
|
|
316
|
+
config,
|
|
317
|
+
})
|
|
318
|
+
},
|
|
319
|
+
|
|
320
|
+
async configureFunnelChartWidget(
|
|
321
|
+
slug: string,
|
|
322
|
+
widgetId: string,
|
|
323
|
+
config: ConfigurableFunnelChartWidgetConfig,
|
|
324
|
+
): Promise<DashboardResponse> {
|
|
325
|
+
return callDashboardApi('/adminapi/v1/dashboard/configure_funnel_chart_widget', {
|
|
326
|
+
slug,
|
|
327
|
+
widgetId,
|
|
328
|
+
config,
|
|
329
|
+
})
|
|
330
|
+
},
|
|
331
|
+
|
|
332
|
+
async configurePivotTableWidget(
|
|
333
|
+
slug: string,
|
|
334
|
+
widgetId: string,
|
|
335
|
+
config: ConfigurablePivotTableWidgetConfig,
|
|
336
|
+
): Promise<DashboardResponse> {
|
|
337
|
+
return callDashboardApi('/adminapi/v1/dashboard/configure_pivot_table_widget', {
|
|
338
|
+
slug,
|
|
339
|
+
widgetId,
|
|
340
|
+
config,
|
|
341
|
+
})
|
|
342
|
+
},
|
|
343
|
+
|
|
212
344
|
async getDashboardWidgetData(
|
|
213
345
|
slug: string,
|
|
214
346
|
widgetId: string,
|
|
@@ -36,6 +36,7 @@ export type QueryAggregateOperation = 'sum' | 'count' | 'count_distinct' | 'avg'
|
|
|
36
36
|
export type TimeGrain = 'day' | 'week' | 'month' | 'year'
|
|
37
37
|
export type ValueFormat =
|
|
38
38
|
| 'number'
|
|
39
|
+
| 'integer'
|
|
39
40
|
| 'compact_number'
|
|
40
41
|
| 'currency'
|
|
41
42
|
| 'percent'
|
|
@@ -119,21 +120,17 @@ export type QueryOrderByItem = {
|
|
|
119
120
|
export type QueryConfig = {
|
|
120
121
|
resource: string
|
|
121
122
|
select?: QuerySelectItem[]
|
|
123
|
+
sparkline?: {
|
|
124
|
+
field: string
|
|
125
|
+
grain: TimeGrain
|
|
126
|
+
as: string
|
|
127
|
+
fill_missing?: Record<string, JsonValue>
|
|
128
|
+
}
|
|
122
129
|
filters?: FilterExpression
|
|
123
130
|
group_by?: QueryGroupByItem[]
|
|
124
131
|
order_by?: QueryOrderByItem[]
|
|
125
132
|
limit?: number
|
|
126
133
|
offset?: number
|
|
127
|
-
time_series?: {
|
|
128
|
-
field: string
|
|
129
|
-
grain: TimeGrain
|
|
130
|
-
timezone?: string
|
|
131
|
-
}
|
|
132
|
-
period?: {
|
|
133
|
-
field: string
|
|
134
|
-
gte?: JsonValue
|
|
135
|
-
lt?: JsonValue
|
|
136
|
-
}
|
|
137
134
|
bucket?: {
|
|
138
135
|
field: string
|
|
139
136
|
buckets: Array<{ label: string, min?: number, max?: number }>
|
|
@@ -178,8 +175,29 @@ export type KpiCardViewConfig = {
|
|
|
178
175
|
text?: string
|
|
179
176
|
field?: string
|
|
180
177
|
}
|
|
181
|
-
comparison?:
|
|
182
|
-
|
|
178
|
+
comparison?: {
|
|
179
|
+
field: string
|
|
180
|
+
format?: ValueFormat
|
|
181
|
+
positive_is_good?: boolean
|
|
182
|
+
compact?: {
|
|
183
|
+
show?: boolean
|
|
184
|
+
template?: string
|
|
185
|
+
}
|
|
186
|
+
tooltip?: {
|
|
187
|
+
label?: string
|
|
188
|
+
template?: string
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
sparkline?: {
|
|
192
|
+
type?: 'line'
|
|
193
|
+
field: string
|
|
194
|
+
x: string
|
|
195
|
+
show_axes?: boolean
|
|
196
|
+
show_labels?: boolean
|
|
197
|
+
fill?: {
|
|
198
|
+
type?: 'gradient' | 'solid'
|
|
199
|
+
}
|
|
200
|
+
}
|
|
183
201
|
}
|
|
184
202
|
|
|
185
203
|
export type GaugeCardViewConfig = {
|
|
@@ -257,14 +275,6 @@ export type DashboardWidgetConfig =
|
|
|
257
275
|
| GaugeCardWidgetConfig
|
|
258
276
|
| PivotTableWidgetConfig
|
|
259
277
|
|
|
260
|
-
export type EditableDashboardWidgetConfig =
|
|
261
|
-
| Omit<EmptyWidgetConfig, 'id' | 'group_id' | 'order'>
|
|
262
|
-
| Omit<TableWidgetConfig, 'id' | 'group_id' | 'order'>
|
|
263
|
-
| Omit<ChartDashboardWidgetConfig, 'id' | 'group_id' | 'order'>
|
|
264
|
-
| Omit<KpiCardWidgetConfig, 'id' | 'group_id' | 'order'>
|
|
265
|
-
| Omit<GaugeCardWidgetConfig, 'id' | 'group_id' | 'order'>
|
|
266
|
-
| Omit<PivotTableWidgetConfig, 'id' | 'group_id' | 'order'>
|
|
267
|
-
|
|
268
278
|
export type DashboardWidgetTableData = {
|
|
269
279
|
kind?: 'table'
|
|
270
280
|
columns: string[]
|
|
@@ -299,10 +309,10 @@ export function serializeDashboardWidgetConfigForEditor(
|
|
|
299
309
|
id: _id,
|
|
300
310
|
group_id: _groupId,
|
|
301
311
|
order: _order,
|
|
302
|
-
...
|
|
312
|
+
...editableWidgetConfig
|
|
303
313
|
} = widget
|
|
304
314
|
|
|
305
|
-
return
|
|
315
|
+
return editableWidgetConfig
|
|
306
316
|
}
|
|
307
317
|
|
|
308
318
|
export function getFieldRefField(value: FieldRef | undefined) {
|
|
@@ -208,7 +208,6 @@ import type {
|
|
|
208
208
|
DashboardConfig,
|
|
209
209
|
DashboardGroupConfig,
|
|
210
210
|
EditableDashboardGroupConfig,
|
|
211
|
-
EditableDashboardWidgetConfig,
|
|
212
211
|
DashboardGroupMoveDirection,
|
|
213
212
|
DashboardWidgetConfig,
|
|
214
213
|
DashboardWidgetMoveDirection,
|
|
@@ -414,13 +413,13 @@ async function saveWidgetConfig() {
|
|
|
414
413
|
try {
|
|
415
414
|
widgetConfigError.value = ''
|
|
416
415
|
widgetConfigFieldErrors.value = []
|
|
417
|
-
const widgetConfig = parseYaml(widgetConfigCode.value) as
|
|
416
|
+
const widgetConfig = parseYaml(widgetConfigCode.value) as DashboardWidgetConfig
|
|
418
417
|
|
|
419
418
|
applyDashboardResponse(
|
|
420
419
|
await dashboardApi.setWidgetConfig(
|
|
421
420
|
props.dashboardSlug,
|
|
422
421
|
editingWidgetId.value,
|
|
423
|
-
widgetConfig,
|
|
422
|
+
serializeDashboardWidgetConfigForEditor(widgetConfig),
|
|
424
423
|
),
|
|
425
424
|
)
|
|
426
425
|
closeWidgetConfigEditor()
|