@adminforth/dashboard 1.4.1 → 1.4.2
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/package.json +1 -0
- package/dist/custom/api/dashboardApi.js +2 -6
- package/dist/custom/composables/useElementSize.js +7 -10
- package/dist/custom/model/dashboard.types.js +2 -6
- package/dist/custom/model/dashboardTopics.js +3 -7
- package/dist/custom/package.json +1 -0
- package/dist/custom/queries/useDashboardConfig.js +9 -12
- package/dist/custom/queries/useWidgetData.js +9 -12
- package/dist/custom/widgets/chart/chart.types.js +1 -2
- package/dist/custom/widgets/chart/chart.utils.js +6 -14
- package/dist/custom/widgets/registry.js +14 -22
- package/package.json +1 -1
package/custom/package.json
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,16 +7,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
exports.dashboardApi = exports.DashboardApiError = void 0;
|
|
13
|
-
class DashboardApiError extends Error {
|
|
10
|
+
export class DashboardApiError extends Error {
|
|
14
11
|
constructor(message, validationErrors = []) {
|
|
15
12
|
super(message);
|
|
16
13
|
this.name = 'DashboardApiError';
|
|
17
14
|
this.validationErrors = validationErrors;
|
|
18
15
|
}
|
|
19
16
|
}
|
|
20
|
-
exports.DashboardApiError = DashboardApiError;
|
|
21
17
|
function normalizeValidationErrors(response) {
|
|
22
18
|
if (Array.isArray(response === null || response === void 0 ? void 0 : response.validationErrors)) {
|
|
23
19
|
return response.validationErrors;
|
|
@@ -97,7 +93,7 @@ function callDashboardWidgetDataApi(path, body) {
|
|
|
97
93
|
};
|
|
98
94
|
});
|
|
99
95
|
}
|
|
100
|
-
|
|
96
|
+
export const dashboardApi = {
|
|
101
97
|
getDashboardConfig(slug) {
|
|
102
98
|
return __awaiter(this, void 0, void 0, function* () {
|
|
103
99
|
return callDashboardApi('/adminapi/v1/dashboard/get-config', { slug });
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
const el = (0, vue_1.shallowRef)(null);
|
|
7
|
-
const width = (0, vue_1.ref)(0);
|
|
8
|
-
const height = (0, vue_1.ref)(0);
|
|
1
|
+
import { onBeforeUnmount, onMounted, ref, shallowRef } from 'vue';
|
|
2
|
+
export function useElementSize() {
|
|
3
|
+
const el = shallowRef(null);
|
|
4
|
+
const width = ref(0);
|
|
5
|
+
const height = ref(0);
|
|
9
6
|
let observer;
|
|
10
7
|
let frameId;
|
|
11
|
-
|
|
8
|
+
onMounted(() => {
|
|
12
9
|
observer = new ResizeObserver(([entry]) => {
|
|
13
10
|
if (!entry) {
|
|
14
11
|
return;
|
|
@@ -28,7 +25,7 @@ function useElementSize() {
|
|
|
28
25
|
observer.observe(el.value);
|
|
29
26
|
}
|
|
30
27
|
});
|
|
31
|
-
|
|
28
|
+
onBeforeUnmount(() => {
|
|
32
29
|
if (frameId !== undefined) {
|
|
33
30
|
cancelAnimationFrame(frameId);
|
|
34
31
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
2
|
var t = {};
|
|
4
3
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -10,13 +9,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
9
|
}
|
|
11
10
|
return t;
|
|
12
11
|
};
|
|
13
|
-
|
|
14
|
-
exports.serializeDashboardWidgetConfigForEditor = serializeDashboardWidgetConfigForEditor;
|
|
15
|
-
exports.getFieldRefField = getFieldRefField;
|
|
16
|
-
function serializeDashboardWidgetConfigForEditor(widget) {
|
|
12
|
+
export function serializeDashboardWidgetConfigForEditor(widget) {
|
|
17
13
|
const { id: _id, group_id: _groupId, order: _order } = widget, editableWidget = __rest(widget, ["id", "group_id", "order"]);
|
|
18
14
|
return editableWidget;
|
|
19
15
|
}
|
|
20
|
-
function getFieldRefField(value) {
|
|
16
|
+
export function getFieldRefField(value) {
|
|
21
17
|
return typeof value === 'string' ? value : value === null || value === void 0 ? void 0 : value.field;
|
|
22
18
|
}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.getDashboardConfigUpdatedTopic = getDashboardConfigUpdatedTopic;
|
|
5
|
-
exports.DASHBOARD_CONFIG_UPDATED_TOPIC_PREFIX = '/opentopic/dashboard-config-updated';
|
|
6
|
-
function getDashboardConfigUpdatedTopic(slug) {
|
|
7
|
-
return `${exports.DASHBOARD_CONFIG_UPDATED_TOPIC_PREFIX}/${slug}`;
|
|
1
|
+
export const DASHBOARD_CONFIG_UPDATED_TOPIC_PREFIX = '/opentopic/dashboard-config-updated';
|
|
2
|
+
export function getDashboardConfigUpdatedTopic(slug) {
|
|
3
|
+
return `${DASHBOARD_CONFIG_UPDATED_TOPIC_PREFIX}/${slug}`;
|
|
8
4
|
}
|
package/dist/custom/package.json
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,15 +7,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const isFetching = (0, vue_1.ref)(false);
|
|
19
|
-
const error = (0, vue_1.ref)(null);
|
|
10
|
+
import { ref, watch } from 'vue';
|
|
11
|
+
import { dashboardApi } from '../api/dashboardApi.js';
|
|
12
|
+
export function useDashboardConfig(slug) {
|
|
13
|
+
const data = ref(null);
|
|
14
|
+
const isLoading = ref(false);
|
|
15
|
+
const isFetching = ref(false);
|
|
16
|
+
const error = ref(null);
|
|
20
17
|
function refetch() {
|
|
21
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
19
|
if (!slug.value) {
|
|
@@ -29,7 +26,7 @@ function useDashboardConfig(slug) {
|
|
|
29
26
|
isLoading.value = true;
|
|
30
27
|
}
|
|
31
28
|
try {
|
|
32
|
-
const response = yield
|
|
29
|
+
const response = yield dashboardApi.getDashboardConfig(slug.value);
|
|
33
30
|
data.value = response;
|
|
34
31
|
error.value = null;
|
|
35
32
|
return response;
|
|
@@ -44,7 +41,7 @@ function useDashboardConfig(slug) {
|
|
|
44
41
|
}
|
|
45
42
|
});
|
|
46
43
|
}
|
|
47
|
-
|
|
44
|
+
watch(slug, () => {
|
|
48
45
|
void refetch();
|
|
49
46
|
}, { immediate: true });
|
|
50
47
|
return {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,15 +7,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const isFetching = (0, vue_1.ref)(false);
|
|
19
|
-
const error = (0, vue_1.ref)(null);
|
|
10
|
+
import { ref, watch } from 'vue';
|
|
11
|
+
import { dashboardApi } from '../api/dashboardApi.js';
|
|
12
|
+
export function useWidgetData(slug, widgetId, request) {
|
|
13
|
+
const data = ref(null);
|
|
14
|
+
const isLoading = ref(false);
|
|
15
|
+
const isFetching = ref(false);
|
|
16
|
+
const error = ref(null);
|
|
20
17
|
function refetch() {
|
|
21
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
19
|
if (!slug.value || !widgetId.value) {
|
|
@@ -29,7 +26,7 @@ function useWidgetData(slug, widgetId, request) {
|
|
|
29
26
|
isLoading.value = true;
|
|
30
27
|
}
|
|
31
28
|
try {
|
|
32
|
-
const response = yield
|
|
29
|
+
const response = yield dashboardApi.getDashboardWidgetData(slug.value, widgetId.value, request === null || request === void 0 ? void 0 : request.value);
|
|
33
30
|
data.value = response;
|
|
34
31
|
error.value = null;
|
|
35
32
|
return response;
|
|
@@ -44,7 +41,7 @@ function useWidgetData(slug, widgetId, request) {
|
|
|
44
41
|
}
|
|
45
42
|
});
|
|
46
43
|
}
|
|
47
|
-
|
|
44
|
+
watch(request ? [slug, widgetId, request] : [slug, widgetId], () => {
|
|
48
45
|
void refetch();
|
|
49
46
|
}, { immediate: true });
|
|
50
47
|
return {
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CHART_COLORS = void 0;
|
|
4
|
-
exports.toFiniteNumber = toFiniteNumber;
|
|
5
|
-
exports.formatChartValue = formatChartValue;
|
|
6
|
-
exports.getChartYAxisWidth = getChartYAxisWidth;
|
|
7
|
-
exports.formatChartLabel = formatChartLabel;
|
|
8
|
-
exports.formatChartAxisLabel = formatChartAxisLabel;
|
|
9
|
-
exports.CHART_COLORS = [
|
|
1
|
+
export const CHART_COLORS = [
|
|
10
2
|
'#2563eb',
|
|
11
3
|
'#16a34a',
|
|
12
4
|
'#f97316',
|
|
@@ -16,20 +8,20 @@ exports.CHART_COLORS = [
|
|
|
16
8
|
'#ca8a04',
|
|
17
9
|
'#db2777',
|
|
18
10
|
];
|
|
19
|
-
function toFiniteNumber(value) {
|
|
11
|
+
export function toFiniteNumber(value) {
|
|
20
12
|
const numberValue = typeof value === 'number' ? value : Number(value);
|
|
21
13
|
return Number.isFinite(numberValue) ? numberValue : 0;
|
|
22
14
|
}
|
|
23
|
-
function formatChartValue(value, options = {}) {
|
|
15
|
+
export function formatChartValue(value, options = {}) {
|
|
24
16
|
return new Intl.NumberFormat(undefined, options).format(value);
|
|
25
17
|
}
|
|
26
|
-
function getChartYAxisWidth(values, chartWidth) {
|
|
18
|
+
export function getChartYAxisWidth(values, chartWidth) {
|
|
27
19
|
const maxLabelLength = Math.max(...values.map((value) => formatChartValue(value).length), 1);
|
|
28
20
|
const estimatedWidth = Math.ceil(maxLabelLength * 6.5) + 18;
|
|
29
21
|
const responsiveMaxWidth = Math.max(Math.floor(chartWidth * 0.36), 38);
|
|
30
22
|
return Math.min(Math.max(estimatedWidth, 38), responsiveMaxWidth, 120);
|
|
31
23
|
}
|
|
32
|
-
function formatChartLabel(value) {
|
|
24
|
+
export function formatChartLabel(value) {
|
|
33
25
|
if (typeof value !== 'string') {
|
|
34
26
|
return String(value);
|
|
35
27
|
}
|
|
@@ -43,7 +35,7 @@ function formatChartLabel(value) {
|
|
|
43
35
|
day: '2-digit',
|
|
44
36
|
}).format(new Date(timestamp));
|
|
45
37
|
}
|
|
46
|
-
function formatChartAxisLabel(value, maxLength = 12) {
|
|
38
|
+
export function formatChartAxisLabel(value, maxLength = 12) {
|
|
47
39
|
const rawLabel = typeof value === 'string' ? value : String(value);
|
|
48
40
|
const timestamp = Date.parse(rawLabel);
|
|
49
41
|
const label = Number.isFinite(timestamp)
|
|
@@ -1,47 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.getWidgetRegistration = getWidgetRegistration;
|
|
8
|
-
exports.getWidgetLabel = getWidgetLabel;
|
|
9
|
-
const ChartWidget_vue_1 = __importDefault(require("./chart/ChartWidget.vue"));
|
|
10
|
-
const GaugeCardWidget_vue_1 = __importDefault(require("./gauge-card/GaugeCardWidget.vue"));
|
|
11
|
-
const KpiCardWidget_vue_1 = __importDefault(require("./kpi-card/KpiCardWidget.vue"));
|
|
12
|
-
const PivotTableWidget_vue_1 = __importDefault(require("./pivot-table/PivotTableWidget.vue"));
|
|
13
|
-
const TableWidget_vue_1 = __importDefault(require("./table/TableWidget.vue"));
|
|
14
|
-
exports.widgetRegistry = [
|
|
1
|
+
import ChartWidget from './chart/ChartWidget.vue';
|
|
2
|
+
import GaugeCardWidget from './gauge-card/GaugeCardWidget.vue';
|
|
3
|
+
import KpiCardWidget from './kpi-card/KpiCardWidget.vue';
|
|
4
|
+
import PivotTableWidget from './pivot-table/PivotTableWidget.vue';
|
|
5
|
+
import TableWidget from './table/TableWidget.vue';
|
|
6
|
+
export const widgetRegistry = [
|
|
15
7
|
{
|
|
16
8
|
type: 'table',
|
|
17
9
|
label: 'Table',
|
|
18
|
-
component:
|
|
10
|
+
component: TableWidget,
|
|
19
11
|
},
|
|
20
12
|
{
|
|
21
13
|
type: 'chart',
|
|
22
14
|
label: 'Chart',
|
|
23
|
-
component:
|
|
15
|
+
component: ChartWidget,
|
|
24
16
|
},
|
|
25
17
|
{
|
|
26
18
|
type: 'kpi_card',
|
|
27
19
|
label: 'KPI Card',
|
|
28
|
-
component:
|
|
20
|
+
component: KpiCardWidget,
|
|
29
21
|
},
|
|
30
22
|
{
|
|
31
23
|
type: 'pivot_table',
|
|
32
24
|
label: 'Pivot Table',
|
|
33
|
-
component:
|
|
25
|
+
component: PivotTableWidget,
|
|
34
26
|
},
|
|
35
27
|
{
|
|
36
28
|
type: 'gauge_card',
|
|
37
29
|
label: 'Gauge Card',
|
|
38
|
-
component:
|
|
30
|
+
component: GaugeCardWidget,
|
|
39
31
|
},
|
|
40
32
|
];
|
|
41
|
-
function getWidgetRegistration(type) {
|
|
42
|
-
return
|
|
33
|
+
export function getWidgetRegistration(type) {
|
|
34
|
+
return widgetRegistry.find((widget) => widget.type === type);
|
|
43
35
|
}
|
|
44
|
-
function getWidgetLabel(type) {
|
|
36
|
+
export function getWidgetLabel(type) {
|
|
45
37
|
var _a;
|
|
46
38
|
return ((_a = getWidgetRegistration(type)) === null || _a === void 0 ? void 0 : _a.label) || type.replaceAll('_', ' ');
|
|
47
39
|
}
|