@adminforth/dashboard 1.9.0 → 1.11.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 +73 -36
- package/custom/runtime/DashboardRuntime.vue +26 -22
- package/custom/skills/adminforth-dashboard/SKILL.md +305 -10
- package/dist/custom/api/dashboardApi.d.ts +24 -18
- package/dist/custom/api/dashboardApi.js +42 -18
- package/dist/custom/api/dashboardApi.ts +73 -36
- package/dist/custom/runtime/DashboardRuntime.vue +26 -22
- package/dist/custom/skills/adminforth-dashboard/SKILL.md +305 -10
- package/dist/endpoint/dashboard.d.ts +1 -0
- package/dist/endpoint/dashboard.js +15 -1
- package/dist/endpoint/groups.js +22 -20
- package/dist/endpoint/widgets.js +28 -26
- package/dist/schema/api.d.ts +151 -1869
- package/dist/schema/api.js +12 -12
- package/dist/services/calc-evaluator.d.ts +2 -1
- package/dist/services/calc-evaluator.js +29 -3
- package/dist/services/dashboardConfigService.d.ts +2 -0
- package/dist/services/dashboardConfigService.js +6 -0
- package/dist/services/widgetDataService.js +2 -2
- package/endpoint/dashboard.ts +17 -0
- package/endpoint/groups.ts +22 -20
- package/endpoint/widgets.ts +28 -26
- package/package.json +1 -1
- package/schema/api.ts +13 -12
- package/services/calc-evaluator.ts +41 -3
- package/services/dashboardConfigService.ts +9 -0
- package/services/widgetDataService.ts +2 -2
|
@@ -10,6 +10,12 @@ export type DashboardWidgetDataResponse = {
|
|
|
10
10
|
widget: DashboardWidgetConfig;
|
|
11
11
|
data: unknown;
|
|
12
12
|
};
|
|
13
|
+
export type DashboardMutationResponse = {
|
|
14
|
+
ok: boolean;
|
|
15
|
+
error?: string;
|
|
16
|
+
groupId?: string;
|
|
17
|
+
widgetId?: string;
|
|
18
|
+
};
|
|
13
19
|
export type DashboardWidgetDataRequest = {
|
|
14
20
|
pagination?: {
|
|
15
21
|
page: number;
|
|
@@ -57,23 +63,23 @@ export declare class DashboardApiError extends Error {
|
|
|
57
63
|
}
|
|
58
64
|
export declare const dashboardApi: {
|
|
59
65
|
getDashboardConfig(slug: string): Promise<DashboardResponse>;
|
|
60
|
-
addDashboardGroup(slug: string): Promise<
|
|
61
|
-
moveDashboardGroup(slug: string, groupId: string, direction: DashboardGroupMoveDirection): Promise<
|
|
62
|
-
removeDashboardGroup(slug: string, groupId: string): Promise<
|
|
63
|
-
setDashboardGroupConfig(slug: string, groupId: string, config: EditableDashboardGroupConfig): Promise<
|
|
64
|
-
addDashboardWidget(slug: string, groupId: string): Promise<
|
|
65
|
-
moveDashboardWidget(slug: string, widgetId: string, direction: DashboardWidgetMoveDirection): Promise<
|
|
66
|
-
removeDashboardWidget(slug: string, widgetId: string): Promise<
|
|
67
|
-
setWidgetConfig(slug: string, widgetId: string, config: unknown): Promise<
|
|
68
|
-
configureTableWidget(slug: string, widgetId: string, config: ConfigurableTableWidgetConfig): Promise<
|
|
69
|
-
configureKpiCardWidget(slug: string, widgetId: string, config: ConfigurableKpiCardWidgetConfig): Promise<
|
|
70
|
-
configureGaugeCardWidget(slug: string, widgetId: string, config: ConfigurableGaugeCardWidgetConfig): Promise<
|
|
71
|
-
configureLineChartWidget(slug: string, widgetId: string, config: ConfigurableLineChartWidgetConfig): Promise<
|
|
72
|
-
configureBarChartWidget(slug: string, widgetId: string, config: ConfigurableBarChartWidgetConfig): Promise<
|
|
73
|
-
configureStackedBarChartWidget(slug: string, widgetId: string, config: ConfigurableStackedBarChartWidgetConfig): Promise<
|
|
74
|
-
configurePieChartWidget(slug: string, widgetId: string, config: ConfigurablePieChartWidgetConfig): Promise<
|
|
75
|
-
configureHistogramChartWidget(slug: string, widgetId: string, config: ConfigurableHistogramChartWidgetConfig): Promise<
|
|
76
|
-
configureFunnelChartWidget(slug: string, widgetId: string, config: ConfigurableFunnelChartWidgetConfig): Promise<
|
|
77
|
-
configurePivotTableWidget(slug: string, widgetId: string, config: ConfigurablePivotTableWidgetConfig): Promise<
|
|
66
|
+
addDashboardGroup(slug: string): Promise<DashboardMutationResponse>;
|
|
67
|
+
moveDashboardGroup(slug: string, groupId: string, direction: DashboardGroupMoveDirection): Promise<DashboardMutationResponse>;
|
|
68
|
+
removeDashboardGroup(slug: string, groupId: string): Promise<DashboardMutationResponse>;
|
|
69
|
+
setDashboardGroupConfig(slug: string, groupId: string, config: EditableDashboardGroupConfig): Promise<DashboardMutationResponse>;
|
|
70
|
+
addDashboardWidget(slug: string, groupId: string): Promise<DashboardMutationResponse>;
|
|
71
|
+
moveDashboardWidget(slug: string, widgetId: string, direction: DashboardWidgetMoveDirection): Promise<DashboardMutationResponse>;
|
|
72
|
+
removeDashboardWidget(slug: string, widgetId: string): Promise<DashboardMutationResponse>;
|
|
73
|
+
setWidgetConfig(slug: string, widgetId: string, config: unknown): Promise<DashboardMutationResponse>;
|
|
74
|
+
configureTableWidget(slug: string, widgetId: string, config: ConfigurableTableWidgetConfig): Promise<DashboardMutationResponse>;
|
|
75
|
+
configureKpiCardWidget(slug: string, widgetId: string, config: ConfigurableKpiCardWidgetConfig): Promise<DashboardMutationResponse>;
|
|
76
|
+
configureGaugeCardWidget(slug: string, widgetId: string, config: ConfigurableGaugeCardWidgetConfig): Promise<DashboardMutationResponse>;
|
|
77
|
+
configureLineChartWidget(slug: string, widgetId: string, config: ConfigurableLineChartWidgetConfig): Promise<DashboardMutationResponse>;
|
|
78
|
+
configureBarChartWidget(slug: string, widgetId: string, config: ConfigurableBarChartWidgetConfig): Promise<DashboardMutationResponse>;
|
|
79
|
+
configureStackedBarChartWidget(slug: string, widgetId: string, config: ConfigurableStackedBarChartWidgetConfig): Promise<DashboardMutationResponse>;
|
|
80
|
+
configurePieChartWidget(slug: string, widgetId: string, config: ConfigurablePieChartWidgetConfig): Promise<DashboardMutationResponse>;
|
|
81
|
+
configureHistogramChartWidget(slug: string, widgetId: string, config: ConfigurableHistogramChartWidgetConfig): Promise<DashboardMutationResponse>;
|
|
82
|
+
configureFunnelChartWidget(slug: string, widgetId: string, config: ConfigurableFunnelChartWidgetConfig): Promise<DashboardMutationResponse>;
|
|
83
|
+
configurePivotTableWidget(slug: string, widgetId: string, config: ConfigurablePivotTableWidgetConfig): Promise<DashboardMutationResponse>;
|
|
78
84
|
getDashboardWidgetData(slug: string, widgetId: string, request?: DashboardWidgetDataRequest): Promise<DashboardWidgetDataResponse>;
|
|
79
85
|
};
|
|
@@ -70,6 +70,30 @@ function callDashboardApi(path, body) {
|
|
|
70
70
|
};
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
|
+
function callDashboardMutationApi(path, body) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
const rawResponse = yield fetch(path, {
|
|
76
|
+
method: 'POST',
|
|
77
|
+
headers: {
|
|
78
|
+
'Content-Type': 'application/json',
|
|
79
|
+
'accept-language': localStorage.getItem('af_lang') || 'en',
|
|
80
|
+
},
|
|
81
|
+
body: JSON.stringify(body),
|
|
82
|
+
});
|
|
83
|
+
const response = yield parseDashboardResponse(rawResponse);
|
|
84
|
+
if (!rawResponse.ok) {
|
|
85
|
+
throw new DashboardApiError((response === null || response === void 0 ? void 0 : response.error) || rawResponse.statusText || `Dashboard request failed (${rawResponse.status})`, normalizeValidationErrors(response));
|
|
86
|
+
}
|
|
87
|
+
if (!response || response.error || response.ok === false) {
|
|
88
|
+
throw new DashboardApiError((response === null || response === void 0 ? void 0 : response.error) || 'Dashboard request failed', normalizeValidationErrors(response));
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
ok: true,
|
|
92
|
+
groupId: response.groupId,
|
|
93
|
+
widgetId: response.widgetId,
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
}
|
|
73
97
|
function callDashboardWidgetDataApi(path, body) {
|
|
74
98
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
99
|
const rawResponse = yield fetch(path, {
|
|
@@ -101,12 +125,12 @@ export const dashboardApi = {
|
|
|
101
125
|
},
|
|
102
126
|
addDashboardGroup(slug) {
|
|
103
127
|
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
-
return
|
|
128
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/add_dashboard_group', { slug });
|
|
105
129
|
});
|
|
106
130
|
},
|
|
107
131
|
moveDashboardGroup(slug, groupId, direction) {
|
|
108
132
|
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
-
return
|
|
133
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/move_dashboard_group', {
|
|
110
134
|
slug,
|
|
111
135
|
groupId,
|
|
112
136
|
direction,
|
|
@@ -115,7 +139,7 @@ export const dashboardApi = {
|
|
|
115
139
|
},
|
|
116
140
|
removeDashboardGroup(slug, groupId) {
|
|
117
141
|
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
-
return
|
|
142
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/remove_dashboard_group', {
|
|
119
143
|
slug,
|
|
120
144
|
groupId,
|
|
121
145
|
});
|
|
@@ -123,7 +147,7 @@ export const dashboardApi = {
|
|
|
123
147
|
},
|
|
124
148
|
setDashboardGroupConfig(slug, groupId, config) {
|
|
125
149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
return
|
|
150
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/set_dashboard_group_config', {
|
|
127
151
|
slug,
|
|
128
152
|
groupId,
|
|
129
153
|
config,
|
|
@@ -132,7 +156,7 @@ export const dashboardApi = {
|
|
|
132
156
|
},
|
|
133
157
|
addDashboardWidget(slug, groupId) {
|
|
134
158
|
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
-
return
|
|
159
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/add_dashboard_widget', {
|
|
136
160
|
slug,
|
|
137
161
|
groupId,
|
|
138
162
|
});
|
|
@@ -140,7 +164,7 @@ export const dashboardApi = {
|
|
|
140
164
|
},
|
|
141
165
|
moveDashboardWidget(slug, widgetId, direction) {
|
|
142
166
|
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
-
return
|
|
167
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/move_dashboard_widget', {
|
|
144
168
|
slug,
|
|
145
169
|
widgetId,
|
|
146
170
|
direction,
|
|
@@ -149,7 +173,7 @@ export const dashboardApi = {
|
|
|
149
173
|
},
|
|
150
174
|
removeDashboardWidget(slug, widgetId) {
|
|
151
175
|
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
-
return
|
|
176
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/remove_dashboard_widget', {
|
|
153
177
|
slug,
|
|
154
178
|
widgetId,
|
|
155
179
|
});
|
|
@@ -157,7 +181,7 @@ export const dashboardApi = {
|
|
|
157
181
|
},
|
|
158
182
|
setWidgetConfig(slug, widgetId, config) {
|
|
159
183
|
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
-
return
|
|
184
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/set_widget_config', {
|
|
161
185
|
slug,
|
|
162
186
|
widgetId,
|
|
163
187
|
config,
|
|
@@ -166,7 +190,7 @@ export const dashboardApi = {
|
|
|
166
190
|
},
|
|
167
191
|
configureTableWidget(slug, widgetId, config) {
|
|
168
192
|
return __awaiter(this, void 0, void 0, function* () {
|
|
169
|
-
return
|
|
193
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/configure_table_widget', {
|
|
170
194
|
slug,
|
|
171
195
|
widgetId,
|
|
172
196
|
config,
|
|
@@ -175,7 +199,7 @@ export const dashboardApi = {
|
|
|
175
199
|
},
|
|
176
200
|
configureKpiCardWidget(slug, widgetId, config) {
|
|
177
201
|
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
-
return
|
|
202
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/configure_kpi_card_widget', {
|
|
179
203
|
slug,
|
|
180
204
|
widgetId,
|
|
181
205
|
config,
|
|
@@ -184,7 +208,7 @@ export const dashboardApi = {
|
|
|
184
208
|
},
|
|
185
209
|
configureGaugeCardWidget(slug, widgetId, config) {
|
|
186
210
|
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
-
return
|
|
211
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/configure_gauge_card_widget', {
|
|
188
212
|
slug,
|
|
189
213
|
widgetId,
|
|
190
214
|
config,
|
|
@@ -193,7 +217,7 @@ export const dashboardApi = {
|
|
|
193
217
|
},
|
|
194
218
|
configureLineChartWidget(slug, widgetId, config) {
|
|
195
219
|
return __awaiter(this, void 0, void 0, function* () {
|
|
196
|
-
return
|
|
220
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/configure_line_chart_widget', {
|
|
197
221
|
slug,
|
|
198
222
|
widgetId,
|
|
199
223
|
config,
|
|
@@ -202,7 +226,7 @@ export const dashboardApi = {
|
|
|
202
226
|
},
|
|
203
227
|
configureBarChartWidget(slug, widgetId, config) {
|
|
204
228
|
return __awaiter(this, void 0, void 0, function* () {
|
|
205
|
-
return
|
|
229
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/configure_bar_chart_widget', {
|
|
206
230
|
slug,
|
|
207
231
|
widgetId,
|
|
208
232
|
config,
|
|
@@ -211,7 +235,7 @@ export const dashboardApi = {
|
|
|
211
235
|
},
|
|
212
236
|
configureStackedBarChartWidget(slug, widgetId, config) {
|
|
213
237
|
return __awaiter(this, void 0, void 0, function* () {
|
|
214
|
-
return
|
|
238
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/configure_stacked_bar_chart_widget', {
|
|
215
239
|
slug,
|
|
216
240
|
widgetId,
|
|
217
241
|
config,
|
|
@@ -220,7 +244,7 @@ export const dashboardApi = {
|
|
|
220
244
|
},
|
|
221
245
|
configurePieChartWidget(slug, widgetId, config) {
|
|
222
246
|
return __awaiter(this, void 0, void 0, function* () {
|
|
223
|
-
return
|
|
247
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/configure_pie_chart_widget', {
|
|
224
248
|
slug,
|
|
225
249
|
widgetId,
|
|
226
250
|
config,
|
|
@@ -229,7 +253,7 @@ export const dashboardApi = {
|
|
|
229
253
|
},
|
|
230
254
|
configureHistogramChartWidget(slug, widgetId, config) {
|
|
231
255
|
return __awaiter(this, void 0, void 0, function* () {
|
|
232
|
-
return
|
|
256
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/configure_histogram_chart_widget', {
|
|
233
257
|
slug,
|
|
234
258
|
widgetId,
|
|
235
259
|
config,
|
|
@@ -238,7 +262,7 @@ export const dashboardApi = {
|
|
|
238
262
|
},
|
|
239
263
|
configureFunnelChartWidget(slug, widgetId, config) {
|
|
240
264
|
return __awaiter(this, void 0, void 0, function* () {
|
|
241
|
-
return
|
|
265
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/configure_funnel_chart_widget', {
|
|
242
266
|
slug,
|
|
243
267
|
widgetId,
|
|
244
268
|
config,
|
|
@@ -247,7 +271,7 @@ export const dashboardApi = {
|
|
|
247
271
|
},
|
|
248
272
|
configurePivotTableWidget(slug, widgetId, config) {
|
|
249
273
|
return __awaiter(this, void 0, void 0, function* () {
|
|
250
|
-
return
|
|
274
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/configure_pivot_table_widget', {
|
|
251
275
|
slug,
|
|
252
276
|
widgetId,
|
|
253
277
|
config,
|
|
@@ -25,6 +25,13 @@ export type DashboardWidgetDataResponse = {
|
|
|
25
25
|
data: unknown
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
export type DashboardMutationResponse = {
|
|
29
|
+
ok: boolean
|
|
30
|
+
error?: string
|
|
31
|
+
groupId?: string
|
|
32
|
+
widgetId?: string
|
|
33
|
+
}
|
|
34
|
+
|
|
28
35
|
export type DashboardWidgetDataRequest = {
|
|
29
36
|
pagination?: {
|
|
30
37
|
page: number
|
|
@@ -119,6 +126,36 @@ async function callDashboardApi(path: string, body: Record<string, unknown>): Pr
|
|
|
119
126
|
}
|
|
120
127
|
}
|
|
121
128
|
|
|
129
|
+
async function callDashboardMutationApi(path: string, body: Record<string, unknown>): Promise<DashboardMutationResponse> {
|
|
130
|
+
const rawResponse = await fetch(path, {
|
|
131
|
+
method: 'POST',
|
|
132
|
+
headers: {
|
|
133
|
+
'Content-Type': 'application/json',
|
|
134
|
+
'accept-language': localStorage.getItem('af_lang') || 'en',
|
|
135
|
+
},
|
|
136
|
+
body: JSON.stringify(body),
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
const response = await parseDashboardResponse(rawResponse)
|
|
140
|
+
|
|
141
|
+
if (!rawResponse.ok) {
|
|
142
|
+
throw new DashboardApiError(
|
|
143
|
+
response?.error || rawResponse.statusText || `Dashboard request failed (${rawResponse.status})`,
|
|
144
|
+
normalizeValidationErrors(response),
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (!response || response.error || response.ok === false) {
|
|
149
|
+
throw new DashboardApiError(response?.error || 'Dashboard request failed', normalizeValidationErrors(response))
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return {
|
|
153
|
+
ok: true,
|
|
154
|
+
groupId: response.groupId,
|
|
155
|
+
widgetId: response.widgetId,
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
122
159
|
async function callDashboardWidgetDataApi(
|
|
123
160
|
path: string,
|
|
124
161
|
body: Record<string, unknown>,
|
|
@@ -156,39 +193,39 @@ export const dashboardApi = {
|
|
|
156
193
|
return callDashboardApi('/adminapi/v1/dashboard/get-config', { slug })
|
|
157
194
|
},
|
|
158
195
|
|
|
159
|
-
async addDashboardGroup(slug: string): Promise<
|
|
160
|
-
return
|
|
196
|
+
async addDashboardGroup(slug: string): Promise<DashboardMutationResponse> {
|
|
197
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/add_dashboard_group', { slug })
|
|
161
198
|
},
|
|
162
199
|
|
|
163
200
|
async moveDashboardGroup(
|
|
164
201
|
slug: string,
|
|
165
202
|
groupId: string,
|
|
166
203
|
direction: DashboardGroupMoveDirection,
|
|
167
|
-
): Promise<
|
|
168
|
-
return
|
|
204
|
+
): Promise<DashboardMutationResponse> {
|
|
205
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/move_dashboard_group', {
|
|
169
206
|
slug,
|
|
170
207
|
groupId,
|
|
171
208
|
direction,
|
|
172
209
|
})
|
|
173
210
|
},
|
|
174
211
|
|
|
175
|
-
async removeDashboardGroup(slug: string, groupId: string): Promise<
|
|
176
|
-
return
|
|
212
|
+
async removeDashboardGroup(slug: string, groupId: string): Promise<DashboardMutationResponse> {
|
|
213
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/remove_dashboard_group', {
|
|
177
214
|
slug,
|
|
178
215
|
groupId,
|
|
179
216
|
})
|
|
180
217
|
},
|
|
181
218
|
|
|
182
|
-
async setDashboardGroupConfig(slug: string, groupId: string, config: EditableDashboardGroupConfig): Promise<
|
|
183
|
-
return
|
|
219
|
+
async setDashboardGroupConfig(slug: string, groupId: string, config: EditableDashboardGroupConfig): Promise<DashboardMutationResponse> {
|
|
220
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/set_dashboard_group_config', {
|
|
184
221
|
slug,
|
|
185
222
|
groupId,
|
|
186
223
|
config,
|
|
187
224
|
})
|
|
188
225
|
},
|
|
189
226
|
|
|
190
|
-
async addDashboardWidget(slug: string, groupId: string): Promise<
|
|
191
|
-
return
|
|
227
|
+
async addDashboardWidget(slug: string, groupId: string): Promise<DashboardMutationResponse> {
|
|
228
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/add_dashboard_widget', {
|
|
192
229
|
slug,
|
|
193
230
|
groupId,
|
|
194
231
|
})
|
|
@@ -198,23 +235,23 @@ export const dashboardApi = {
|
|
|
198
235
|
slug: string,
|
|
199
236
|
widgetId: string,
|
|
200
237
|
direction: DashboardWidgetMoveDirection,
|
|
201
|
-
): Promise<
|
|
202
|
-
return
|
|
238
|
+
): Promise<DashboardMutationResponse> {
|
|
239
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/move_dashboard_widget', {
|
|
203
240
|
slug,
|
|
204
241
|
widgetId,
|
|
205
242
|
direction,
|
|
206
243
|
})
|
|
207
244
|
},
|
|
208
245
|
|
|
209
|
-
async removeDashboardWidget(slug: string, widgetId: string): Promise<
|
|
210
|
-
return
|
|
246
|
+
async removeDashboardWidget(slug: string, widgetId: string): Promise<DashboardMutationResponse> {
|
|
247
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/remove_dashboard_widget', {
|
|
211
248
|
slug,
|
|
212
249
|
widgetId,
|
|
213
250
|
})
|
|
214
251
|
},
|
|
215
252
|
|
|
216
|
-
async setWidgetConfig(slug: string, widgetId: string, config: unknown): Promise<
|
|
217
|
-
return
|
|
253
|
+
async setWidgetConfig(slug: string, widgetId: string, config: unknown): Promise<DashboardMutationResponse> {
|
|
254
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/set_widget_config', {
|
|
218
255
|
slug,
|
|
219
256
|
widgetId,
|
|
220
257
|
config,
|
|
@@ -225,8 +262,8 @@ export const dashboardApi = {
|
|
|
225
262
|
slug: string,
|
|
226
263
|
widgetId: string,
|
|
227
264
|
config: ConfigurableTableWidgetConfig,
|
|
228
|
-
): Promise<
|
|
229
|
-
return
|
|
265
|
+
): Promise<DashboardMutationResponse> {
|
|
266
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/configure_table_widget', {
|
|
230
267
|
slug,
|
|
231
268
|
widgetId,
|
|
232
269
|
config,
|
|
@@ -237,8 +274,8 @@ export const dashboardApi = {
|
|
|
237
274
|
slug: string,
|
|
238
275
|
widgetId: string,
|
|
239
276
|
config: ConfigurableKpiCardWidgetConfig,
|
|
240
|
-
): Promise<
|
|
241
|
-
return
|
|
277
|
+
): Promise<DashboardMutationResponse> {
|
|
278
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/configure_kpi_card_widget', {
|
|
242
279
|
slug,
|
|
243
280
|
widgetId,
|
|
244
281
|
config,
|
|
@@ -249,8 +286,8 @@ export const dashboardApi = {
|
|
|
249
286
|
slug: string,
|
|
250
287
|
widgetId: string,
|
|
251
288
|
config: ConfigurableGaugeCardWidgetConfig,
|
|
252
|
-
): Promise<
|
|
253
|
-
return
|
|
289
|
+
): Promise<DashboardMutationResponse> {
|
|
290
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/configure_gauge_card_widget', {
|
|
254
291
|
slug,
|
|
255
292
|
widgetId,
|
|
256
293
|
config,
|
|
@@ -261,8 +298,8 @@ export const dashboardApi = {
|
|
|
261
298
|
slug: string,
|
|
262
299
|
widgetId: string,
|
|
263
300
|
config: ConfigurableLineChartWidgetConfig,
|
|
264
|
-
): Promise<
|
|
265
|
-
return
|
|
301
|
+
): Promise<DashboardMutationResponse> {
|
|
302
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/configure_line_chart_widget', {
|
|
266
303
|
slug,
|
|
267
304
|
widgetId,
|
|
268
305
|
config,
|
|
@@ -273,8 +310,8 @@ export const dashboardApi = {
|
|
|
273
310
|
slug: string,
|
|
274
311
|
widgetId: string,
|
|
275
312
|
config: ConfigurableBarChartWidgetConfig,
|
|
276
|
-
): Promise<
|
|
277
|
-
return
|
|
313
|
+
): Promise<DashboardMutationResponse> {
|
|
314
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/configure_bar_chart_widget', {
|
|
278
315
|
slug,
|
|
279
316
|
widgetId,
|
|
280
317
|
config,
|
|
@@ -285,8 +322,8 @@ export const dashboardApi = {
|
|
|
285
322
|
slug: string,
|
|
286
323
|
widgetId: string,
|
|
287
324
|
config: ConfigurableStackedBarChartWidgetConfig,
|
|
288
|
-
): Promise<
|
|
289
|
-
return
|
|
325
|
+
): Promise<DashboardMutationResponse> {
|
|
326
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/configure_stacked_bar_chart_widget', {
|
|
290
327
|
slug,
|
|
291
328
|
widgetId,
|
|
292
329
|
config,
|
|
@@ -297,8 +334,8 @@ export const dashboardApi = {
|
|
|
297
334
|
slug: string,
|
|
298
335
|
widgetId: string,
|
|
299
336
|
config: ConfigurablePieChartWidgetConfig,
|
|
300
|
-
): Promise<
|
|
301
|
-
return
|
|
337
|
+
): Promise<DashboardMutationResponse> {
|
|
338
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/configure_pie_chart_widget', {
|
|
302
339
|
slug,
|
|
303
340
|
widgetId,
|
|
304
341
|
config,
|
|
@@ -309,8 +346,8 @@ export const dashboardApi = {
|
|
|
309
346
|
slug: string,
|
|
310
347
|
widgetId: string,
|
|
311
348
|
config: ConfigurableHistogramChartWidgetConfig,
|
|
312
|
-
): Promise<
|
|
313
|
-
return
|
|
349
|
+
): Promise<DashboardMutationResponse> {
|
|
350
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/configure_histogram_chart_widget', {
|
|
314
351
|
slug,
|
|
315
352
|
widgetId,
|
|
316
353
|
config,
|
|
@@ -321,8 +358,8 @@ export const dashboardApi = {
|
|
|
321
358
|
slug: string,
|
|
322
359
|
widgetId: string,
|
|
323
360
|
config: ConfigurableFunnelChartWidgetConfig,
|
|
324
|
-
): Promise<
|
|
325
|
-
return
|
|
361
|
+
): Promise<DashboardMutationResponse> {
|
|
362
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/configure_funnel_chart_widget', {
|
|
326
363
|
slug,
|
|
327
364
|
widgetId,
|
|
328
365
|
config,
|
|
@@ -333,8 +370,8 @@ export const dashboardApi = {
|
|
|
333
370
|
slug: string,
|
|
334
371
|
widgetId: string,
|
|
335
372
|
config: ConfigurablePivotTableWidgetConfig,
|
|
336
|
-
): Promise<
|
|
337
|
-
return
|
|
373
|
+
): Promise<DashboardMutationResponse> {
|
|
374
|
+
return callDashboardMutationApi('/adminapi/v1/dashboard/configure_pivot_table_widget', {
|
|
338
375
|
slug,
|
|
339
376
|
widgetId,
|
|
340
377
|
config,
|
|
@@ -286,7 +286,8 @@ async function addGroup() {
|
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
try {
|
|
289
|
-
|
|
289
|
+
await dashboardApi.addDashboardGroup(props.dashboardSlug)
|
|
290
|
+
await refreshDashboardConfig()
|
|
290
291
|
} catch (error) {
|
|
291
292
|
console.error('Failed to add dashboard group', error)
|
|
292
293
|
}
|
|
@@ -298,7 +299,8 @@ async function addWidget(groupId: string) {
|
|
|
298
299
|
}
|
|
299
300
|
|
|
300
301
|
try {
|
|
301
|
-
|
|
302
|
+
await dashboardApi.addDashboardWidget(props.dashboardSlug, groupId)
|
|
303
|
+
await refreshDashboardConfig()
|
|
302
304
|
} catch (error) {
|
|
303
305
|
console.error('Failed to add dashboard widget', error)
|
|
304
306
|
}
|
|
@@ -310,9 +312,8 @@ async function moveGroup(groupId: string, direction: DashboardGroupMoveDirection
|
|
|
310
312
|
}
|
|
311
313
|
|
|
312
314
|
try {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
)
|
|
315
|
+
await dashboardApi.moveDashboardGroup(props.dashboardSlug, groupId, direction)
|
|
316
|
+
await refreshDashboardConfig()
|
|
316
317
|
} catch (error) {
|
|
317
318
|
console.error('Failed to move dashboard group', error)
|
|
318
319
|
}
|
|
@@ -324,7 +325,8 @@ async function removeGroup(groupId: string) {
|
|
|
324
325
|
}
|
|
325
326
|
|
|
326
327
|
try {
|
|
327
|
-
|
|
328
|
+
await dashboardApi.removeDashboardGroup(props.dashboardSlug, groupId)
|
|
329
|
+
await refreshDashboardConfig()
|
|
328
330
|
} catch (error) {
|
|
329
331
|
console.error('Failed to remove dashboard group', error)
|
|
330
332
|
}
|
|
@@ -348,13 +350,12 @@ async function saveGroupConfig() {
|
|
|
348
350
|
try {
|
|
349
351
|
const groupConfig = parseYaml(groupConfigCode.value) as EditableDashboardGroupConfig
|
|
350
352
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
groupConfig,
|
|
356
|
-
),
|
|
353
|
+
await dashboardApi.setDashboardGroupConfig(
|
|
354
|
+
props.dashboardSlug,
|
|
355
|
+
editingGroupId.value,
|
|
356
|
+
groupConfig,
|
|
357
357
|
)
|
|
358
|
+
await refreshDashboardConfig()
|
|
358
359
|
closeGroupConfigEditor()
|
|
359
360
|
} catch (error) {
|
|
360
361
|
groupConfigError.value = error instanceof Error ? error.message : 'Invalid group config'
|
|
@@ -373,9 +374,8 @@ async function moveWidget(widgetId: string, direction: DashboardWidgetMoveDirect
|
|
|
373
374
|
}
|
|
374
375
|
|
|
375
376
|
try {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
)
|
|
377
|
+
await dashboardApi.moveDashboardWidget(props.dashboardSlug, widgetId, direction)
|
|
378
|
+
await refreshDashboardConfig()
|
|
379
379
|
} catch (error) {
|
|
380
380
|
console.error('Failed to move dashboard widget', error)
|
|
381
381
|
}
|
|
@@ -387,7 +387,8 @@ async function removeWidget(widgetId: string) {
|
|
|
387
387
|
}
|
|
388
388
|
|
|
389
389
|
try {
|
|
390
|
-
|
|
390
|
+
await dashboardApi.removeDashboardWidget(props.dashboardSlug, widgetId)
|
|
391
|
+
await refreshDashboardConfig()
|
|
391
392
|
} catch (error) {
|
|
392
393
|
console.error('Failed to remove dashboard widget', error)
|
|
393
394
|
}
|
|
@@ -410,13 +411,12 @@ async function saveWidgetConfig() {
|
|
|
410
411
|
widgetConfigFieldErrors.value = []
|
|
411
412
|
const widgetConfig = parseYaml(widgetConfigCode.value) as DashboardWidgetConfig
|
|
412
413
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
serializeDashboardWidgetConfigForEditor(widgetConfig),
|
|
418
|
-
),
|
|
414
|
+
await dashboardApi.setWidgetConfig(
|
|
415
|
+
props.dashboardSlug,
|
|
416
|
+
editingWidgetId.value,
|
|
417
|
+
serializeDashboardWidgetConfigForEditor(widgetConfig),
|
|
419
418
|
)
|
|
419
|
+
await refreshDashboardConfig()
|
|
420
420
|
closeWidgetConfigEditor()
|
|
421
421
|
} catch (error) {
|
|
422
422
|
widgetConfigError.value = error instanceof Error ? error.message : 'Invalid widget config'
|
|
@@ -431,6 +431,10 @@ function closeWidgetConfigEditor() {
|
|
|
431
431
|
widgetConfigFieldErrors.value = []
|
|
432
432
|
}
|
|
433
433
|
|
|
434
|
+
async function refreshDashboardConfig() {
|
|
435
|
+
applyDashboardResponse(await dashboardApi.getDashboardConfig(props.dashboardSlug))
|
|
436
|
+
}
|
|
437
|
+
|
|
434
438
|
function applyDashboardResponse(response: DashboardResponse) {
|
|
435
439
|
draftConfig.value = cloneConfig(response.config)
|
|
436
440
|
currentRevision.value = response.revision
|