@adminforth/dashboard 1.2.0 → 1.4.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 -39
- package/custom/api/dashboardApi.ts +4 -0
- package/custom/composables/useElementSize.ts +17 -2
- package/custom/model/dashboard.types.ts +337 -236
- package/custom/skills/adminforth-dashboard/SKILL.md +113 -2
- package/custom/widgets/chart/ChartWidget.vue +38 -53
- package/custom/widgets/chart/bar/BarChart.vue +20 -12
- package/custom/widgets/chart/chart.types.ts +17 -66
- package/custom/widgets/chart/chart.utils.ts +11 -0
- package/custom/widgets/chart/funnel/FunnelChart.vue +6 -4
- package/custom/widgets/chart/line/LineChart.vue +23 -15
- package/custom/widgets/chart/stacked-bar/StackedBarChart.vue +28 -43
- package/custom/widgets/gauge-card/GaugeCardWidget.vue +7 -12
- package/custom/widgets/kpi-card/KpiCardWidget.vue +6 -8
- package/custom/widgets/pivot-table/PivotTableWidget.vue +8 -7
- package/custom/widgets/table/TableWidget.vue +8 -3
- package/dist/custom/api/dashboardApi.d.ts +1 -0
- package/dist/custom/api/dashboardApi.js +5 -0
- package/dist/custom/api/dashboardApi.ts +4 -0
- package/dist/custom/composables/useElementSize.js +14 -2
- package/dist/custom/composables/useElementSize.ts +17 -2
- package/dist/custom/model/dashboard.types.d.ts +181 -61
- package/dist/custom/model/dashboard.types.js +82 -93
- package/dist/custom/model/dashboard.types.ts +337 -236
- package/dist/custom/queries/useDashboardConfig.d.ts +852 -66
- package/dist/custom/queries/useWidgetData.d.ts +848 -62
- package/dist/custom/skills/adminforth-dashboard/SKILL.md +113 -2
- package/dist/custom/widgets/chart/ChartWidget.vue +38 -53
- package/dist/custom/widgets/chart/bar/BarChart.vue +20 -12
- package/dist/custom/widgets/chart/chart.types.d.ts +13 -22
- package/dist/custom/widgets/chart/chart.types.js +2 -25
- package/dist/custom/widgets/chart/chart.types.ts +17 -66
- package/dist/custom/widgets/chart/chart.utils.d.ts +1 -0
- package/dist/custom/widgets/chart/chart.utils.js +7 -0
- package/dist/custom/widgets/chart/chart.utils.ts +11 -0
- package/dist/custom/widgets/chart/funnel/FunnelChart.vue +6 -4
- package/dist/custom/widgets/chart/line/LineChart.vue +23 -15
- package/dist/custom/widgets/chart/stacked-bar/StackedBarChart.vue +28 -43
- package/dist/custom/widgets/gauge-card/GaugeCardWidget.vue +7 -12
- package/dist/custom/widgets/kpi-card/KpiCardWidget.vue +6 -8
- package/dist/custom/widgets/pivot-table/PivotTableWidget.vue +8 -7
- package/dist/custom/widgets/table/TableWidget.vue +8 -3
- package/dist/endpoint/dashboard.d.ts +7 -2
- package/dist/endpoint/dashboard.js +45 -1
- package/dist/endpoint/widgets.d.ts +2 -1
- package/dist/endpoint/widgets.js +6 -2
- package/dist/schema/api.d.ts +2773 -736
- package/dist/schema/api.js +5 -0
- package/dist/schema/widget.d.ts +1648 -476
- package/dist/schema/widget.js +208 -139
- package/dist/services/widgetConfigValidator.js +16 -40
- package/dist/services/widgetDataService.d.ts +2 -1
- package/dist/services/widgetDataService.js +389 -82
- package/endpoint/dashboard.ts +77 -4
- package/endpoint/widgets.ts +11 -4
- package/package.json +1 -1
- package/schema/api.ts +6 -0
- package/schema/widget.ts +225 -139
- package/services/widgetConfigValidator.ts +29 -53
- package/services/widgetDataService.ts +522 -100
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.normalizeDashboardConfig = normalizeDashboardConfig;
|
|
4
15
|
exports.normalizeDashboardWidgetConfig = normalizeDashboardWidgetConfig;
|
|
5
16
|
exports.serializeDashboardWidgetConfigForEditor = serializeDashboardWidgetConfigForEditor;
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.normalizePivotTableWidgetConfig = normalizePivotTableWidgetConfig;
|
|
17
|
+
exports.getFieldRefField = getFieldRefField;
|
|
18
|
+
exports.getFieldRefLabel = getFieldRefLabel;
|
|
9
19
|
function normalizeDashboardConfig(config) {
|
|
10
20
|
const value = isRecord(config) ? config : {};
|
|
11
21
|
return {
|
|
@@ -22,11 +32,17 @@ function normalizeDashboardWidgetConfig(config) {
|
|
|
22
32
|
}
|
|
23
33
|
const normalized = Object.assign({}, config);
|
|
24
34
|
normalizeWidgetLayoutConfig(normalized);
|
|
35
|
+
if (normalized.query !== undefined) {
|
|
36
|
+
normalized.query = normalizeQueryConfig(normalized.query);
|
|
37
|
+
}
|
|
25
38
|
if (normalized.table !== undefined) {
|
|
26
39
|
normalized.table = normalizeTableConfig(normalized.table);
|
|
27
40
|
}
|
|
28
|
-
if (normalized.
|
|
29
|
-
normalized.
|
|
41
|
+
if (normalized.card !== undefined) {
|
|
42
|
+
normalized.card = normalizeCardConfig(normalized.card);
|
|
43
|
+
}
|
|
44
|
+
if (normalized.pivot !== undefined) {
|
|
45
|
+
normalized.pivot = normalizePivotConfig(normalized.pivot);
|
|
30
46
|
}
|
|
31
47
|
const target = normalizeDashboardWidgetTarget(normalized.target);
|
|
32
48
|
if (target !== undefined) {
|
|
@@ -44,50 +60,25 @@ function serializeDashboardWidgetConfigForEditor(widget) {
|
|
|
44
60
|
serialized.max_width = widget.maxWidth;
|
|
45
61
|
delete serialized.maxWidth;
|
|
46
62
|
}
|
|
47
|
-
if (
|
|
63
|
+
if ('query' in widget) {
|
|
64
|
+
serialized.query = serializeQueryConfigForEditor(widget.query);
|
|
65
|
+
}
|
|
66
|
+
if ('table' in widget && widget.table !== undefined) {
|
|
48
67
|
serialized.table = serializeTableConfigForEditor(widget.table);
|
|
49
68
|
}
|
|
50
|
-
if (widget.
|
|
51
|
-
serialized.
|
|
52
|
-
|
|
69
|
+
if ('card' in widget && widget.card !== undefined) {
|
|
70
|
+
serialized.card = serializeCardConfigForEditor(widget.card);
|
|
71
|
+
}
|
|
72
|
+
if ('pivot' in widget && widget.pivot !== undefined) {
|
|
73
|
+
serialized.pivot = serializePivotConfigForEditor(widget.pivot);
|
|
53
74
|
}
|
|
54
75
|
return serialized;
|
|
55
76
|
}
|
|
56
|
-
function
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const valueField = getStringField(config, 'value_field');
|
|
62
|
-
const labelField = getStringField(config, 'label_field');
|
|
63
|
-
const prefix = getStringField(config, 'prefix');
|
|
64
|
-
const suffix = getStringField(config, 'suffix');
|
|
65
|
-
return Object.assign(Object.assign(Object.assign(Object.assign({}, (valueField !== undefined ? { valueField } : {})), (labelField !== undefined ? { labelField } : {})), (prefix !== undefined ? { prefix } : {})), (suffix !== undefined ? { suffix } : {}));
|
|
66
|
-
}
|
|
67
|
-
function normalizeGaugeCardWidgetConfig(value) {
|
|
68
|
-
const config = asWidgetConfigRecord(value);
|
|
69
|
-
if (!config) {
|
|
70
|
-
return undefined;
|
|
71
|
-
}
|
|
72
|
-
const valueField = getStringField(config, 'value_field');
|
|
73
|
-
const minField = getStringField(config, 'min_field');
|
|
74
|
-
const maxField = getStringField(config, 'max_field');
|
|
75
|
-
const suffix = getStringField(config, 'suffix');
|
|
76
|
-
const color = getStringField(config, 'color');
|
|
77
|
-
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (valueField !== undefined ? { valueField } : {})), (config.min !== undefined ? { min: config.min } : {})), (config.max !== undefined ? { max: config.max } : {})), (minField !== undefined ? { minField } : {})), (maxField !== undefined ? { maxField } : {})), (suffix !== undefined ? { suffix } : {})), (color !== undefined ? { color } : {}));
|
|
78
|
-
}
|
|
79
|
-
function normalizePivotTableWidgetConfig(value) {
|
|
80
|
-
const config = asWidgetConfigRecord(value);
|
|
81
|
-
if (!config) {
|
|
82
|
-
return undefined;
|
|
83
|
-
}
|
|
84
|
-
const rowField = getStringField(config, 'row_field');
|
|
85
|
-
const columnField = getStringField(config, 'column_field');
|
|
86
|
-
const valueField = getStringField(config, 'value_field');
|
|
87
|
-
const aggregation = config.aggregation === 'count' || config.aggregation === 'sum'
|
|
88
|
-
? config.aggregation
|
|
89
|
-
: undefined;
|
|
90
|
-
return Object.assign(Object.assign(Object.assign(Object.assign({}, (rowField !== undefined ? { rowField } : {})), (columnField !== undefined ? { columnField } : {})), (valueField !== undefined ? { valueField } : {})), (aggregation !== undefined ? { aggregation } : {}));
|
|
77
|
+
function getFieldRefField(value) {
|
|
78
|
+
return typeof value === 'string' ? value : value === null || value === void 0 ? void 0 : value.field;
|
|
79
|
+
}
|
|
80
|
+
function getFieldRefLabel(value) {
|
|
81
|
+
return typeof value === 'string' ? value : value === null || value === void 0 ? void 0 : value.label;
|
|
91
82
|
}
|
|
92
83
|
function normalizeDashboardWidgetTarget(value) {
|
|
93
84
|
switch (value) {
|
|
@@ -110,76 +101,74 @@ function normalizeWidgetLayoutConfig(value) {
|
|
|
110
101
|
value.maxWidth = value.max_width;
|
|
111
102
|
}
|
|
112
103
|
}
|
|
113
|
-
function
|
|
104
|
+
function normalizeQueryConfig(value) {
|
|
114
105
|
if (!isRecord(value)) {
|
|
115
106
|
return value;
|
|
116
107
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
108
|
+
if (Array.isArray(value.steps)) {
|
|
109
|
+
return removeUndefinedFields({
|
|
110
|
+
steps: value.steps.map((step) => normalizeFunnelQueryStep(step)),
|
|
111
|
+
calcs: Array.isArray(value.calcs) ? value.calcs : undefined,
|
|
112
|
+
});
|
|
120
113
|
}
|
|
121
|
-
return
|
|
114
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, value), (Array.isArray(value.group_by) ? { groupBy: value.group_by } : {})), (Array.isArray(value.order_by) ? { orderBy: value.order_by } : {})), (value.time_series !== undefined ? { timeSeries: value.time_series } : {}));
|
|
122
115
|
}
|
|
123
|
-
function
|
|
124
|
-
if (!isRecord(value)
|
|
116
|
+
function normalizeFunnelQueryStep(value) {
|
|
117
|
+
if (!isRecord(value)) {
|
|
125
118
|
return value;
|
|
126
119
|
}
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
: undefined;
|
|
130
|
-
if (value.type === 'resource') {
|
|
131
|
-
return Object.assign(Object.assign(Object.assign(Object.assign({ type: 'resource' }, (resourceId !== undefined ? { resourceId } : {})), (value.columns !== undefined ? { columns: value.columns } : {})), (value.filters !== undefined ? { filters: value.filters } : {})), (value.sort !== undefined ? { sort: value.sort } : {}));
|
|
132
|
-
}
|
|
133
|
-
if (value.type === 'aggregate') {
|
|
134
|
-
const groupBy = normalizeGroupByRule(value.group_by);
|
|
135
|
-
return Object.assign(Object.assign(Object.assign(Object.assign({ type: 'aggregate' }, (resourceId !== undefined ? { resourceId } : {})), (value.aggregations !== undefined ? { aggregations: value.aggregations } : {})), (groupBy !== undefined ? { groupBy } : {})), (value.filters !== undefined ? { filters: value.filters } : {}));
|
|
136
|
-
}
|
|
137
|
-
return value;
|
|
120
|
+
const { resource_id } = value, rest = __rest(value, ["resource_id"]);
|
|
121
|
+
return removeUndefinedFields(Object.assign(Object.assign({}, rest), { resource: typeof resource_id === 'string' ? resource_id : rest.resource }));
|
|
138
122
|
}
|
|
139
|
-
function
|
|
140
|
-
if (!isRecord(value)
|
|
123
|
+
function normalizeTableConfig(value) {
|
|
124
|
+
if (!isRecord(value)) {
|
|
141
125
|
return value;
|
|
142
126
|
}
|
|
143
|
-
|
|
144
|
-
return Object.assign({ type: 'field' }, (value.field !== undefined ? { field: value.field } : {}));
|
|
145
|
-
}
|
|
146
|
-
if (value.type === 'date_trunc') {
|
|
147
|
-
return Object.assign(Object.assign(Object.assign({ type: 'date_trunc' }, (value.field !== undefined ? { field: value.field } : {})), (value.truncation !== undefined ? { truncation: value.truncation } : {})), (value.timezone !== undefined ? { timezone: value.timezone } : {}));
|
|
148
|
-
}
|
|
149
|
-
return value;
|
|
127
|
+
return Object.assign(Object.assign({}, value), (value.page_size !== undefined ? { pageSize: value.page_size } : {}));
|
|
150
128
|
}
|
|
151
|
-
function
|
|
129
|
+
function normalizeCardConfig(value) {
|
|
152
130
|
if (!isRecord(value)) {
|
|
153
131
|
return value;
|
|
154
132
|
}
|
|
155
|
-
const
|
|
156
|
-
if (
|
|
157
|
-
|
|
158
|
-
delete serialized.pageSize;
|
|
133
|
+
const normalized = Object.assign({}, value);
|
|
134
|
+
if (isRecord(normalized.progress)) {
|
|
135
|
+
normalized.progress = Object.assign(Object.assign(Object.assign(Object.assign({}, normalized.progress), (normalized.progress.value_field !== undefined ? { valueField: normalized.progress.value_field } : {})), (normalized.progress.target_value !== undefined ? { targetValue: normalized.progress.target_value } : {})), (normalized.progress.target_field !== undefined ? { targetField: normalized.progress.target_field } : {}));
|
|
159
136
|
}
|
|
160
|
-
|
|
137
|
+
if (isRecord(normalized.comparison)) {
|
|
138
|
+
normalized.comparison = Object.assign(Object.assign({}, normalized.comparison), (normalized.comparison.positive_is_good !== undefined ? { positiveIsGood: normalized.comparison.positive_is_good } : {}));
|
|
139
|
+
}
|
|
140
|
+
return normalized;
|
|
161
141
|
}
|
|
162
|
-
function
|
|
163
|
-
|
|
164
|
-
|
|
142
|
+
function normalizePivotConfig(value) {
|
|
143
|
+
return value;
|
|
144
|
+
}
|
|
145
|
+
function serializeQueryConfigForEditor(value) {
|
|
146
|
+
if ('steps' in value) {
|
|
147
|
+
return removeUndefinedFields({
|
|
148
|
+
steps: value.steps.map((step) => (Object.assign(Object.assign({}, step), { resource_id: step.resource, resource: undefined }))).map((step) => removeUndefinedFields(step)),
|
|
149
|
+
calcs: value.calcs,
|
|
150
|
+
});
|
|
165
151
|
}
|
|
166
|
-
return Object.assign(Object.assign({
|
|
152
|
+
return removeUndefinedFields(Object.assign(Object.assign({}, value), { group_by: value.groupBy, groupBy: undefined, order_by: value.orderBy, orderBy: undefined, time_series: value.timeSeries, timeSeries: undefined }));
|
|
153
|
+
}
|
|
154
|
+
function serializeTableConfigForEditor(value) {
|
|
155
|
+
return removeUndefinedFields(Object.assign(Object.assign({}, value), { page_size: value.pageSize, pageSize: undefined }));
|
|
167
156
|
}
|
|
168
|
-
function
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
157
|
+
function serializeCardConfigForEditor(value) {
|
|
158
|
+
const serialized = Object.assign({}, value);
|
|
159
|
+
if (isRecord(serialized.progress)) {
|
|
160
|
+
serialized.progress = removeUndefinedFields(Object.assign(Object.assign({}, serialized.progress), { value_field: serialized.progress.valueField, valueField: undefined, target_value: serialized.progress.targetValue, targetValue: undefined, target_field: serialized.progress.targetField, targetField: undefined }));
|
|
161
|
+
}
|
|
162
|
+
if (isRecord(serialized.comparison)) {
|
|
163
|
+
serialized.comparison = removeUndefinedFields(Object.assign(Object.assign({}, serialized.comparison), { positive_is_good: serialized.comparison.positiveIsGood, positiveIsGood: undefined }));
|
|
174
164
|
}
|
|
175
|
-
return
|
|
165
|
+
return removeUndefinedFields(serialized);
|
|
176
166
|
}
|
|
177
|
-
function
|
|
178
|
-
return
|
|
167
|
+
function serializePivotConfigForEditor(value) {
|
|
168
|
+
return value;
|
|
179
169
|
}
|
|
180
|
-
function
|
|
181
|
-
|
|
182
|
-
return typeof value === 'string' ? value : undefined;
|
|
170
|
+
function removeUndefinedFields(value) {
|
|
171
|
+
return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== undefined));
|
|
183
172
|
}
|
|
184
173
|
function isRecord(value) {
|
|
185
174
|
return typeof value === 'object' && value !== null;
|