@adminforth/dashboard 1.0.0 → 1.1.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/README.md +116 -54
- package/custom/api/dashboardApi.ts +9 -0
- package/custom/model/dashboard.types.ts +158 -1
- package/custom/queries/useWidgetData.ts +8 -4
- package/custom/runtime/WidgetShell.vue +8 -4
- package/custom/widgets/chart/chart.utils.ts +2 -2
- package/custom/widgets/gauge-card/GaugeCardWidget.vue +94 -12
- package/custom/widgets/pivot-table/PivotTableWidget.vue +27 -5
- package/custom/widgets/table/TableWidget.vue +155 -30
- package/dist/custom/api/dashboardApi.d.ts +7 -1
- package/dist/custom/api/dashboardApi.js +4 -6
- package/dist/custom/api/dashboardApi.ts +9 -0
- package/dist/custom/model/dashboard.types.d.ts +45 -0
- package/dist/custom/model/dashboard.types.js +82 -1
- package/dist/custom/model/dashboard.types.ts +158 -1
- package/dist/custom/queries/useDashboardConfig.d.ts +42 -0
- package/dist/custom/queries/useWidgetData.d.ts +44 -1
- package/dist/custom/queries/useWidgetData.js +3 -3
- package/dist/custom/queries/useWidgetData.ts +8 -4
- package/dist/custom/runtime/WidgetShell.vue +8 -4
- package/dist/custom/widgets/chart/chart.utils.d.ts +1 -1
- package/dist/custom/widgets/chart/chart.utils.js +2 -2
- package/dist/custom/widgets/chart/chart.utils.ts +2 -2
- package/dist/custom/widgets/gauge-card/GaugeCardWidget.vue +94 -12
- package/dist/custom/widgets/pivot-table/PivotTableWidget.vue +27 -5
- package/dist/custom/widgets/table/TableWidget.vue +155 -30
- package/dist/endpoint/widgets.d.ts +6 -1
- package/dist/endpoint/widgets.js +22 -4
- package/dist/schema/api.d.ts +882 -212
- package/dist/schema/api.js +11 -2
- package/dist/schema/widget.d.ts +542 -4
- package/dist/schema/widget.js +111 -1
- package/dist/services/widgetConfigValidator.js +32 -6
- package/dist/services/widgetDataService.d.ts +8 -6
- package/dist/services/widgetDataService.js +133 -11
- package/endpoint/widgets.ts +31 -4
- package/package.json +1 -1
- package/schema/api.ts +11 -1
- package/schema/widget.ts +114 -1
- package/services/widgetConfigValidator.ts +45 -6
- package/services/widgetDataService.ts +201 -19
package/dist/endpoint/widgets.js
CHANGED
|
@@ -8,7 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { randomUUID } from 'crypto';
|
|
11
|
-
import {
|
|
11
|
+
import { normalizeDashboardWidgetConfig, } from '../custom/model/dashboard.types.js';
|
|
12
|
+
import { DashboardApiResponseSchema, DashboardWidgetDataResponseSchema, GroupIdRequestSchema, MoveWidgetRequestSchema, SetWidgetConfigRequestSchema, WidgetDataRequestSchema, WidgetIdRequestSchema, } from '../schema/api.js';
|
|
13
|
+
import { StoredWidgetConfigSchema } from '../schema/widget.js';
|
|
14
|
+
function formatWidgetConfigValidationErrors(error) {
|
|
15
|
+
return error.issues.map((issue) => ({
|
|
16
|
+
field: issue.path.length ? issue.path.map(String).join('.') : 'config',
|
|
17
|
+
message: issue.message,
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
12
20
|
export function registerWidgetEndpoints(server, ctx) {
|
|
13
21
|
server.endpoint({
|
|
14
22
|
method: 'POST',
|
|
@@ -140,7 +148,15 @@ export function registerWidgetEndpoints(server, ctx) {
|
|
|
140
148
|
response.setStatus(404);
|
|
141
149
|
return { error: 'Dashboard widget not found' };
|
|
142
150
|
}
|
|
143
|
-
const
|
|
151
|
+
const parsedWidgetConfig = StoredWidgetConfigSchema.safeParse(normalizeDashboardWidgetConfig(body.config));
|
|
152
|
+
if (!parsedWidgetConfig.success) {
|
|
153
|
+
response.setStatus(422);
|
|
154
|
+
return {
|
|
155
|
+
error: 'Invalid widget config',
|
|
156
|
+
validationErrors: formatWidgetConfigValidationErrors(parsedWidgetConfig.error),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
const typedWidgetConfig = parsedWidgetConfig.data;
|
|
144
160
|
const apiValidationErrors = ctx.validateDashboardWidgetApiConfig(typedWidgetConfig);
|
|
145
161
|
if (apiValidationErrors.length) {
|
|
146
162
|
response.setStatus(422);
|
|
@@ -157,7 +173,7 @@ export function registerWidgetEndpoints(server, ctx) {
|
|
|
157
173
|
method: 'POST',
|
|
158
174
|
path: '/dashboard/get_dashboard_widget_data',
|
|
159
175
|
description: 'Loads query result data for one dashboard widget by dashboard slug and widget id.',
|
|
160
|
-
request_schema:
|
|
176
|
+
request_schema: WidgetDataRequestSchema,
|
|
161
177
|
response_schema: DashboardWidgetDataResponseSchema,
|
|
162
178
|
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, response }) {
|
|
163
179
|
const slug = String((body === null || body === void 0 ? void 0 : body.slug) || 'default');
|
|
@@ -175,7 +191,9 @@ export function registerWidgetEndpoints(server, ctx) {
|
|
|
175
191
|
}
|
|
176
192
|
return {
|
|
177
193
|
widget,
|
|
178
|
-
data: yield ctx.getWidgetData(widget
|
|
194
|
+
data: yield ctx.getWidgetData(widget, {
|
|
195
|
+
pagination: body === null || body === void 0 ? void 0 : body.pagination,
|
|
196
|
+
}),
|
|
179
197
|
};
|
|
180
198
|
}),
|
|
181
199
|
});
|