@solidxai/core-ui 0.1.5-beta.6 → 0.1.5-beta.9
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/dist/components/auth/SolidOTPVerify.d.ts +3 -0
- package/dist/components/auth/SolidOTPVerify.d.ts.map +1 -0
- package/dist/components/auth/SolidOTPVerify.js +67 -0
- package/dist/components/auth/SolidOTPVerify.js.map +1 -0
- package/dist/components/auth/SolidOTPVerify.tsx +133 -0
- package/dist/components/common/AuthBanner.js.map +1 -1
- package/dist/components/core/chatter/SolidChatterDateDivider.d.ts.map +1 -1
- package/dist/components/core/chatter/SolidChatterDateDivider.js +4 -1
- package/dist/components/core/chatter/SolidChatterDateDivider.js.map +1 -1
- package/dist/components/core/chatter/SolidChatterDateDivider.tsx +5 -1
- package/dist/components/core/common/LoadDynamicJsxComponent.d.ts +2 -0
- package/dist/components/core/common/LoadDynamicJsxComponent.d.ts.map +1 -0
- package/dist/components/core/common/LoadDynamicJsxComponent.js +50 -0
- package/dist/components/core/common/LoadDynamicJsxComponent.js.map +1 -0
- package/dist/components/core/common/LoadDynamicJsxComponent.tsx +70 -0
- package/dist/components/core/dashboard/DashboardFilter.js +1 -1
- package/dist/components/core/dashboard/DashboardFilter.js.map +1 -1
- package/dist/components/core/dashboard/DashboardFilter.tsx +5 -5
- package/dist/components/core/dashboard/PrimeDataTableWrapper.d.ts +3 -0
- package/dist/components/core/dashboard/PrimeDataTableWrapper.d.ts.map +1 -0
- package/dist/components/core/dashboard/PrimeDataTableWrapper.js +21 -0
- package/dist/components/core/dashboard/PrimeDataTableWrapper.js.map +1 -0
- package/dist/components/core/dashboard/PrimeDataTableWrapper.tsx +40 -0
- package/dist/components/core/dashboard/SolidDashboard.d.ts +0 -1
- package/dist/components/core/dashboard/SolidDashboard.d.ts.map +1 -1
- package/dist/components/core/dashboard/SolidDashboard.js +50 -26
- package/dist/components/core/dashboard/SolidDashboard.js.map +1 -1
- package/dist/components/core/dashboard/SolidDashboard.module.css +6 -2
- package/dist/components/core/dashboard/SolidDashboard.tsx +112 -65
- package/dist/components/core/dashboard/SolidDashboardBody.d.ts +13 -1
- package/dist/components/core/dashboard/SolidDashboardBody.d.ts.map +1 -1
- package/dist/components/core/dashboard/SolidDashboardBody.js +134 -48
- package/dist/components/core/dashboard/SolidDashboardBody.js.map +1 -1
- package/dist/components/core/dashboard/SolidDashboardBody.tsx +143 -91
- package/dist/components/core/dashboard/SolidQuestionRenderer.d.ts.map +1 -1
- package/dist/components/core/dashboard/SolidQuestionRenderer.js +1 -1
- package/dist/components/core/dashboard/SolidQuestionRenderer.js.map +1 -1
- package/dist/components/core/dashboard/SolidQuestionRenderer.tsx +12 -10
- package/dist/components/core/dashboard/chart-renderers/ChartJsRenderer.d.ts.map +1 -1
- package/dist/components/core/dashboard/chart-renderers/ChartJsRenderer.js +29 -2
- package/dist/components/core/dashboard/chart-renderers/ChartJsRenderer.js.map +1 -1
- package/dist/components/core/dashboard/chart-renderers/ChartJsRenderer.tsx +33 -3
- package/dist/components/core/extension/solid-core/dashboard/dashboardFormViewChangeHandler.d.ts +10 -0
- package/dist/components/core/extension/solid-core/dashboard/dashboardFormViewChangeHandler.d.ts.map +1 -0
- package/dist/components/core/extension/solid-core/dashboard/dashboardFormViewChangeHandler.js +16 -0
- package/dist/components/core/extension/solid-core/dashboard/dashboardFormViewChangeHandler.js.map +1 -0
- package/dist/components/core/extension/solid-core/dashboard/dashboardFormViewChangeHandler.ts +19 -0
- package/dist/components/core/extension/solid-core/dashboard/dashboardQuestionFieldChangeHandler.d.ts +8 -0
- package/dist/components/core/extension/solid-core/dashboard/dashboardQuestionFieldChangeHandler.d.ts.map +1 -0
- package/dist/components/core/extension/solid-core/dashboard/dashboardQuestionFieldChangeHandler.js +64 -0
- package/dist/components/core/extension/solid-core/dashboard/dashboardQuestionFieldChangeHandler.js.map +1 -0
- package/dist/components/core/extension/solid-core/dashboard/dashboardQuestionFieldChangeHandler.ts +30 -0
- package/dist/components/core/extension/solid-core/dashboard/dashboardQuestionOnFormLoadHandler.d.ts +8 -0
- package/dist/components/core/extension/solid-core/dashboard/dashboardQuestionOnFormLoadHandler.d.ts.map +1 -0
- package/dist/components/core/extension/solid-core/dashboard/dashboardQuestionOnFormLoadHandler.js +62 -0
- package/dist/components/core/extension/solid-core/dashboard/dashboardQuestionOnFormLoadHandler.js.map +1 -0
- package/dist/components/core/extension/solid-core/dashboard/dashboardQuestionOnFormLoadHandler.ts +29 -0
- package/dist/components/core/extension/solid-core/modelMetadata/list/DeleteModelRowAction.js +2 -2
- package/dist/components/core/extension/solid-core/modelMetadata/list/DeleteModelRowAction.js.map +1 -1
- package/dist/components/core/extension/solid-core/modelMetadata/list/DeleteModelRowAction.tsx +2 -2
- package/dist/constants/error-messages.d.ts +3 -0
- package/dist/constants/error-messages.d.ts.map +1 -1
- package/dist/constants/error-messages.js +3 -0
- package/dist/constants/error-messages.js.map +1 -1
- package/dist/constants/error-messages.ts +24 -20
- package/dist/helpers/registry.d.ts.map +1 -1
- package/dist/helpers/registry.js +7 -0
- package/dist/helpers/registry.js.map +1 -1
- package/dist/helpers/registry.ts +8 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/index.ts +8 -0
- package/dist/nextAuth/authProviders.d.ts +4 -0
- package/dist/nextAuth/authProviders.d.ts.map +1 -0
- package/dist/nextAuth/authProviders.js +198 -0
- package/dist/nextAuth/authProviders.js.map +1 -0
- package/dist/nextAuth/authProviders.tsx +232 -0
- package/dist/nextAuth/handleLogout.d.ts +2 -0
- package/dist/nextAuth/handleLogout.d.ts.map +1 -0
- package/dist/nextAuth/handleLogout.js +36 -0
- package/dist/nextAuth/handleLogout.js.map +1 -0
- package/dist/nextAuth/handleLogout.tsx +39 -0
- package/dist/nextAuth/refreshAccessToken.d.ts +2 -0
- package/dist/nextAuth/refreshAccessToken.d.ts.map +1 -0
- package/dist/nextAuth/refreshAccessToken.js +24 -0
- package/dist/nextAuth/refreshAccessToken.js.map +1 -0
- package/dist/nextAuth/refreshAccessToken.tsx +28 -0
- package/dist/redux/api/dashboardLayoutApi.d.ts +24 -0
- package/dist/redux/api/dashboardLayoutApi.d.ts.map +1 -0
- package/dist/redux/api/dashboardLayoutApi.js +34 -0
- package/dist/redux/api/dashboardLayoutApi.js.map +1 -0
- package/dist/redux/api/dashboardLayoutApi.ts +55 -0
- package/dist/redux/features/settingsSlice.d.ts +20 -0
- package/dist/redux/features/settingsSlice.d.ts.map +1 -0
- package/dist/redux/features/settingsSlice.js +39 -0
- package/dist/redux/features/settingsSlice.js.map +1 -0
- package/dist/redux/features/settingsSlice.ts +60 -0
- package/dist/redux/store/defaultStoreConfig.d.ts +4 -0
- package/dist/redux/store/defaultStoreConfig.d.ts.map +1 -1
- package/dist/redux/store/defaultStoreConfig.js +3 -2
- package/dist/redux/store/defaultStoreConfig.js.map +1 -1
- package/dist/redux/store/defaultStoreConfig.ts +4 -2
- package/dist/routes/pages/admin/core/DashboardPage.d.ts.map +1 -1
- package/dist/routes/pages/admin/core/DashboardPage.js +3 -7
- package/dist/routes/pages/admin/core/DashboardPage.js.map +1 -1
- package/dist/routes/pages/admin/core/DashboardPage.tsx +2 -5
- package/dist/routes/solidRoutes.js +1 -1
- package/dist/routes/solidRoutes.js.map +1 -1
- package/dist/routes/solidRoutes.tsx +1 -1
- package/package.json +13 -11
|
@@ -4,113 +4,165 @@ import { GridStackOptions, GridStackWidget } from 'gridstack';
|
|
|
4
4
|
import styles from './SolidDashboard.module.css'
|
|
5
5
|
import { SolidQuestionRenderer } from './SolidQuestionRenderer';
|
|
6
6
|
import { SqlExpression } from '../../../types/solid-core';
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
7
|
+
import ReactGridLayout, { useContainerWidth, Layout, LayoutItem } from "react-grid-layout";
|
|
8
|
+
import { useEffect, useRef, useState } from 'react';
|
|
9
|
+
import PrimeDataTableWrapper from './PrimeDataTableWrapper';
|
|
10
|
+
import 'react-grid-layout/css/styles.css';
|
|
11
|
+
import 'react-resizable/css/styles.css';
|
|
12
|
+
import { useLazyGetUserDashboardLayoutByDashboardIdQuery } from '../../../redux/api/dashboardLayoutApi';
|
|
13
|
+
import showToast from '../../../helpers/showToast';
|
|
14
|
+
import { ERROR_MESSAGES } from '../../../constants/error-messages';
|
|
15
|
+
import { Toast } from 'primereact/toast';
|
|
11
16
|
|
|
12
17
|
export interface SolidDashboardBodyProps {
|
|
13
18
|
dashboardOptions?: GridStackOptions;
|
|
14
19
|
widgetOptions?: GridStackWidget[];
|
|
15
20
|
// Replace `any` with a proper `Question` type when available
|
|
21
|
+
dashboardId: string;
|
|
16
22
|
questions: any[];
|
|
17
23
|
filters: SqlExpression[];
|
|
24
|
+
dashboardLayout: GridItem[];
|
|
25
|
+
setDashboardLayout: (dashboardLayout: GridItem[]) => void;
|
|
18
26
|
}
|
|
19
27
|
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
export type GridItem = {
|
|
29
|
+
i: string;
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
w: number;
|
|
33
|
+
h: number;
|
|
34
|
+
};
|
|
22
35
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// // Cleanup on unmount
|
|
40
|
-
// return () => {
|
|
41
|
-
// grid.destroy(false);
|
|
42
|
-
// };
|
|
43
|
-
// }, [dashboardOptions, widgetOptions]);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// Fallback sequencing
|
|
47
|
-
const questionsWithDefaultIndex = questions.map((q, index) => ({
|
|
48
|
-
...q,
|
|
49
|
-
defaultIndex: index + 1,
|
|
50
|
-
}));
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const sortedQuestions = [...questionsWithDefaultIndex].sort((a, b) => {
|
|
54
|
-
const aSeq = a.sequenceNumber ?? a.defaultIndex;
|
|
55
|
-
const bSeq = b.sequenceNumber ?? b.defaultIndex;
|
|
56
|
-
return aSeq - bSeq;
|
|
36
|
+
// Layout is Layout[] at runtime in v2 — the type definition is misleading
|
|
37
|
+
type LayoutArray = LayoutItem[];
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
const generateDefaultLayout = (questions: any[]): GridItem[] => {
|
|
41
|
+
return questions.map((q, index) => {
|
|
42
|
+
const col = index % 3;
|
|
43
|
+
const row = Math.floor(index / 3);
|
|
44
|
+
return {
|
|
45
|
+
i: String(q.name),
|
|
46
|
+
x: col * 4, // 0, 4, 8 in a 12-col grid
|
|
47
|
+
y: row * 4,
|
|
48
|
+
w: 4,
|
|
49
|
+
h: 4,
|
|
50
|
+
};
|
|
57
51
|
});
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
const SolidDashboardBody = ({ dashboardId, questions, filters = [], dashboardLayout, setDashboardLayout }: SolidDashboardBodyProps) => {
|
|
56
|
+
const toast = useRef<Toast>(null);
|
|
57
|
+
|
|
58
|
+
const sortedQuestions = [...questions]
|
|
59
|
+
.map((q, index) => ({ ...q, defaultIndex: index + 1 }))
|
|
60
|
+
.sort((a, b) => (a.sequenceNumber ?? a.defaultIndex) - (b.sequenceNumber ?? b.defaultIndex));
|
|
61
|
+
|
|
62
|
+
const { width, containerRef, mounted } = useContainerWidth();
|
|
63
|
+
const isLayoutReady = useRef(false);
|
|
64
|
+
|
|
65
|
+
const [fetchUserLayout, { data: userLayoutData, isSuccess, isLoading }] =
|
|
66
|
+
useLazyGetUserDashboardLayoutByDashboardIdQuery();
|
|
67
|
+
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (!dashboardId || questions.length === 0) return;
|
|
70
|
+
const loadLayout = async () => {
|
|
71
|
+
try {
|
|
72
|
+
const response = await fetchUserLayout(dashboardId).unwrap();
|
|
73
|
+
const raw = response?.data?.layout;
|
|
74
|
+
const savedLayout = typeof raw === 'string' ? JSON.parse(raw) : raw;
|
|
75
|
+
|
|
76
|
+
const layout = savedLayout
|
|
77
|
+
? sortedQuestions.map((q) => {
|
|
78
|
+
const saved = (savedLayout as GridItem[]).find(s => s.i === String(q.name));
|
|
79
|
+
return saved ?? generateDefaultLayout([q])[0];
|
|
80
|
+
})
|
|
81
|
+
: generateDefaultLayout(sortedQuestions);
|
|
82
|
+
|
|
83
|
+
setDashboardLayout(layout);
|
|
84
|
+
setTimeout(() => { isLayoutReady.current = true; }, 100);
|
|
85
|
+
} catch (error: any) {
|
|
86
|
+
if (error.status === 403) {
|
|
87
|
+
showToast(toast, "error", ERROR_MESSAGES.FORBIDDEN_ERROR, ERROR_MESSAGES.FORBIDDEN_ERROR);
|
|
88
|
+
} else {
|
|
89
|
+
showToast(toast, "error", ERROR_MESSAGES.SOMETHING_WRONG, ERROR_MESSAGES.SOMETHING_WRONG);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
loadLayout();
|
|
95
|
+
}, [questions, dashboardId]);
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
// useEffect(() => {
|
|
99
|
+
// if (questions.length === 0) return;
|
|
100
|
+
// const saved = getSavedLayout();
|
|
101
|
+
// setDashboardLayout(generateLayout(sortedQuestions, saved));
|
|
102
|
+
// // Delay the ready flag so onLayoutChange doesn't fire before we're set
|
|
103
|
+
// setTimeout(() => { isLayoutReady.current = true; }, 100);
|
|
104
|
+
// }, [questions]);
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
const handleLayoutChange = (newLayout: Layout) => {
|
|
108
|
+
if (!isLayoutReady.current) return;
|
|
109
|
+
|
|
110
|
+
// v2 passes LayoutItem[] at runtime despite the type saying Layout
|
|
111
|
+
const layoutArray = newLayout as unknown as LayoutItem[];
|
|
112
|
+
|
|
113
|
+
const updated: GridItem[] = layoutArray.map(item => ({
|
|
114
|
+
i: item.i,
|
|
115
|
+
x: item.x,
|
|
116
|
+
y: item.y,
|
|
117
|
+
w: item.w,
|
|
118
|
+
h: item.h,
|
|
119
|
+
}));
|
|
58
120
|
|
|
121
|
+
setDashboardLayout(updated);
|
|
122
|
+
// saving is handled by the parent/caller
|
|
123
|
+
};
|
|
59
124
|
|
|
60
125
|
return (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
<div
|
|
64
|
-
{
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return (
|
|
97
|
-
<div className="col-12 p-3" key={question.id}>
|
|
98
|
-
<div className={`${styles.SolidChartCardWrapper} p-4`} style={{ maxHeight: '40vh', overflowY: 'scroll' }}>
|
|
99
|
-
<div className={`font-medium text-${textAlign} ${styles.SolidChartTitle}`}>{question.name}</div>
|
|
100
|
-
<div className={`mt-2 font-bold text-3xl text-${textAlign} ${styles.SolidChartTitle}`}>{questionData.data.kpi}</div>
|
|
101
|
-
<div className='mt-3'>
|
|
102
|
-
|
|
103
|
-
<PrimeReactDatatableRenderer
|
|
104
|
-
options={JSON.parse(question?.chartOptions)}
|
|
105
|
-
visualizationData={questionData?.data?.visualizationData}
|
|
106
|
-
/>
|
|
107
|
-
</div>
|
|
108
|
-
</div>
|
|
126
|
+
<>
|
|
127
|
+
<Toast ref={toast} />
|
|
128
|
+
<div
|
|
129
|
+
ref={containerRef as React.RefObject<HTMLDivElement>}
|
|
130
|
+
className={`p-4 ${styles.SolidDashboardContentWrapper}`}
|
|
131
|
+
style={{ width: '100%', overflowY: 'auto', minHeight: 0 }}
|
|
132
|
+
|
|
133
|
+
>
|
|
134
|
+
{mounted && dashboardLayout.length > 0 && (
|
|
135
|
+
<ReactGridLayout
|
|
136
|
+
width={width}
|
|
137
|
+
layout={dashboardLayout}
|
|
138
|
+
gridConfig={{
|
|
139
|
+
cols: 12,
|
|
140
|
+
rowHeight: 120,
|
|
141
|
+
}}
|
|
142
|
+
dragConfig={{
|
|
143
|
+
handle: ".drag-handle",
|
|
144
|
+
}}
|
|
145
|
+
resizeConfig={{
|
|
146
|
+
enabled: true,
|
|
147
|
+
}}
|
|
148
|
+
onLayoutChange={handleLayoutChange}
|
|
149
|
+
>
|
|
150
|
+
{sortedQuestions.map((question: any) => (
|
|
151
|
+
<div key={String(question.name)} className="drag-handle cursor-move rounded shadow p-2 overflow-hidden" style={{ backgroundColor: 'transparent' }}>
|
|
152
|
+
{/* <div className=" mb-2 font-bold">
|
|
153
|
+
{question.name}
|
|
154
|
+
</div> */}
|
|
155
|
+
{question.visualisedAs === "prime-datatable" ? (
|
|
156
|
+
<PrimeDataTableWrapper question={question} filters={filters} />
|
|
157
|
+
) : (
|
|
158
|
+
<SolidQuestionRenderer question={question} filters={filters} isPreview={false} />
|
|
159
|
+
)}
|
|
109
160
|
</div>
|
|
110
|
-
)
|
|
111
|
-
|
|
161
|
+
))}
|
|
162
|
+
</ReactGridLayout>
|
|
163
|
+
)}
|
|
112
164
|
</div>
|
|
113
|
-
|
|
165
|
+
</>
|
|
114
166
|
);
|
|
115
167
|
};
|
|
116
168
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolidQuestionRenderer.d.ts","sourceRoot":"","sources":["../../../../src/components/core/dashboard/SolidQuestionRenderer.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAS1D,KAAK,0BAA0B,GAAG;IAC9B,QAAQ,EAAE,GAAG,CAAC;IACd,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;CACtB,CAAC;AAQF,eAAO,MAAM,qBAAqB,qCAAmD,0BAA0B,
|
|
1
|
+
{"version":3,"file":"SolidQuestionRenderer.d.ts","sourceRoot":"","sources":["../../../../src/components/core/dashboard/SolidQuestionRenderer.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAS1D,KAAK,0BAA0B,GAAG;IAC9B,QAAQ,EAAE,GAAG,CAAC;IACd,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;CACtB,CAAC;AAQF,eAAO,MAAM,qBAAqB,qCAAmD,0BAA0B,4CAwD9G,CAAA"}
|
|
@@ -32,6 +32,6 @@ export var SolidQuestionRenderer = function (_a) {
|
|
|
32
32
|
// const visualizationData = questionData.data.visualizationData;
|
|
33
33
|
// const visualizedAs = question.data.visualisedAs;
|
|
34
34
|
return (_jsxs(_Fragment, { children: [questionDataIsLoading && _jsx(ProgressSpinner, {}), !questionDataIsLoading &&
|
|
35
|
-
_jsxs("div", { className: "".concat(styles.SolidChartCardWrapper, " p-4
|
|
35
|
+
_jsxs("div", { className: "".concat(styles.SolidChartCardWrapper, " h-full"), children: [_jsxs("div", { className: 'flex flex-col p-4 pb-3', style: { borderBottom: "1px solid #e4e3e3" }, children: [_jsx("div", { className: "font-medium text-".concat(textAlign, " ").concat(styles.SolidChartTitle), children: question.name }), _jsx("div", { className: "mt-2 font-bold text-3xl text-".concat(textAlign, " ").concat(styles.SolidChartTitle), children: questionData.data.kpi })] }), _jsxs("div", { className: 'mt-3 flex-1 min-h-0 p-4 pt-2', children: [['bar', 'line', 'pie'].includes(question.visualisedAs) && _jsx(ChartJsRenderer, { options: options, visualizationData: questionData.data.visualizationData, visualizedAs: question.visualisedAs }), question.visualisedAs === 'prime-meter-group' && _jsx(MeterGroup, { values: questionData.data.visualizationData.dataset, max: (_e = (_d = (_c = questionData === null || questionData === void 0 ? void 0 : questionData.data) === null || _c === void 0 ? void 0 : _c.visualizationData) === null || _d === void 0 ? void 0 : _d.dataset) === null || _e === void 0 ? void 0 : _e.reduce(function (total, item) { return total + item.value; }, 0) }), question.visualisedAs === 'prime-datatable' && _jsx(PrimeReactDatatableRenderer, { options: options, visualizationData: questionData.data.visualizationData })] })] })] }));
|
|
36
36
|
};
|
|
37
37
|
//# sourceMappingURL=SolidQuestionRenderer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolidQuestionRenderer.js","sourceRoot":"","sources":["../../../../src/components/core/dashboard/SolidQuestionRenderer.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,oCAAoC,EAAE,MAAM,yCAAyC,CAAC;AAE/F,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,2BAA2B,MAAM,+CAA+C,CAAC;AACxF,OAAO,MAAM,MAAM,6BAA6B,CAAC;AAcjD,MAAM,CAAC,IAAM,qBAAqB,GAAG,UAAC,EAAyE;;QAAvE,QAAQ,cAAA,EAAE,eAAY,EAAZ,OAAO,mBAAG,EAAE,KAAA,EAAE,iBAAiB,EAAjB,SAAS,mBAAG,KAAK,KAAA;IAC7E,IAAI,CAAC,QAAQ,EAAE;QACX,OAAO,CACH,cAAK,SAAS,EAAE,UAAG,MAAM,CAAC,qBAAqB,SAAM,YACjD,KAAC,OAAO,IAAC,IAAI,EAAC,qBAAqB,GAAG,GACpC,CACT,CAAC;KACL;IAED,IAAM,SAAS,GAAG,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,SAAS,mCAAI,OAAO,CAAA;IAChD,IAAI,CAAC,QAAQ,EAAE;QACX,OAAO,CACH,4BACI,KAAC,OAAO,IAAC,IAAI,EAAC,qBAAqB,GAAG,GACvC,CACN,CAAA;KACJ;IACD,+EAA+E;IAE/E,0BAA0B;IAC1B,IAAM,WAAW,GAAG,EAAE,CAAC,SAAS,CAC5B;QACI,SAAS,WAAA;QACT,OAAO,SAAA;KACV,CAGJ,CAAC;IACI,IAAA,KAAqF,oCAAoC,CAAC,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,EAAvJ,YAAY,UAAA,EAAa,qBAAqB,eAAA,EAAS,iBAAiB,WAA+E,CAAC;IAGtK,6DAA6D;IAC7D,iFAAiF;IACjF,wEAAwE;IACxE,IAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,YAAY,CAAC,CAAC;IACnD,qCAAqC;IACrC,iEAAiE;IACjE,mDAAmD;IACnD,OAAO,CACH,8BACK,qBAAqB,IAAI,KAAC,eAAe,KAAG,EAC5C,CAAC,qBAAqB;
|
|
1
|
+
{"version":3,"file":"SolidQuestionRenderer.js","sourceRoot":"","sources":["../../../../src/components/core/dashboard/SolidQuestionRenderer.tsx"],"names":[],"mappings":"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","sourcesContent":["\nimport { useGetDashboardQuestionDataByIdQuery } from '../../../redux/api/dashboardQuestionApi';\nimport { SqlExpression } from '../../../types/solid-core';\nimport { Message } from 'primereact/message';\nimport { MeterGroup } from 'primereact/metergroup';\nimport { ProgressSpinner } from 'primereact/progressspinner';\nimport qs from 'qs';\nimport { ChartJsRenderer } from './chart-renderers/ChartJsRenderer';\nimport PrimeReactDatatableRenderer from './chart-renderers/PrimeReactDatatableRenderer';\nimport styles from './SolidDashboard.module.css';\n\ntype SolidQuestionRendererProps = {\n question: any;\n filters: SqlExpression[];\n isPreview: boolean;\n};\n\ntype DataItem = {\n value: number;\n label?: string | HTMLElement;\n color?: string;\n}\n\nexport const SolidQuestionRenderer = ({ question, filters = [], isPreview = false }: SolidQuestionRendererProps) => {\n if (!question) {\n return (\n <div className={`${styles.SolidChartCardWrapper} p-4`}>\n <Message text=\"Preview Unavailable\" />\n </div>\n );\n }\n\n const textAlign = question?.textAlign ?? 'start'\n if (!question) {\n return (\n <>\n <Message text=\"Preview Unavailable\" />\n </>\n )\n }\n // console.log(`Rendering BarChartRenderer using question id: ${question.id}`);\n\n // load the question data.\n const queryParams = qs.stringify(\n {\n isPreview,\n filters,\n },\n // ensures proper handling of arrays\n // { arrayFormat: 'indices' }\n );\n const { data: questionData, isLoading: questionDataIsLoading, error: questionDataError } = useGetDashboardQuestionDataByIdQuery({ id: question.id, qs: queryParams });\n\n\n // console.log(`Question data: `); console.log(questionData);\n // console.log(`Question data is loading: `); console.log(questionDataIsLoading);\n // console.log(`Question data error: `); console.log(questionDataError);\n const options = JSON.parse(question?.chartOptions);\n // const kpi = questionData.data.kpi;\n // const visualizationData = questionData.data.visualizationData;\n // const visualizedAs = question.data.visualisedAs;\n return (\n <>\n {questionDataIsLoading && <ProgressSpinner />}\n {!questionDataIsLoading &&\n <div className={`${styles.SolidChartCardWrapper} h-full`}>\n <div className='flex flex-col p-4 pb-3' style={{ borderBottom: \"1px solid #e4e3e3\" }}>\n <div className={`font-medium text-${textAlign} ${styles.SolidChartTitle}`}>{question.name}</div>\n <div className={`mt-2 font-bold text-3xl text-${textAlign} ${styles.SolidChartTitle}`}>{questionData.data.kpi}</div>\n </div>\n <div className='mt-3 flex-1 min-h-0 p-4 pt-2'>\n {['bar', 'line', 'pie'].includes(question.visualisedAs) && <ChartJsRenderer options={options} visualizationData={questionData.data.visualizationData} visualizedAs={question.visualisedAs} />}\n {question.visualisedAs === 'prime-meter-group' && <MeterGroup values={questionData.data.visualizationData.dataset} max={questionData?.data?.visualizationData?.dataset?.reduce((total: number, item: DataItem) => total + item.value, 0)} />}\n {question.visualisedAs === 'prime-datatable' && <PrimeReactDatatableRenderer options={options} visualizationData={questionData.data.visualizationData} />}\n </div>\n </div>\n }\n </>\n )\n}"]}
|
|
@@ -15,7 +15,7 @@ type SolidQuestionRendererProps = {
|
|
|
15
15
|
isPreview: boolean;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
type DataItem= {
|
|
18
|
+
type DataItem = {
|
|
19
19
|
value: number;
|
|
20
20
|
label?: string | HTMLElement;
|
|
21
21
|
color?: string;
|
|
@@ -63,16 +63,18 @@ export const SolidQuestionRenderer = ({ question, filters = [], isPreview = fals
|
|
|
63
63
|
<>
|
|
64
64
|
{questionDataIsLoading && <ProgressSpinner />}
|
|
65
65
|
{!questionDataIsLoading &&
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
66
|
+
<div className={`${styles.SolidChartCardWrapper} h-full`}>
|
|
67
|
+
<div className='flex flex-col p-4 pb-3' style={{ borderBottom: "1px solid #e4e3e3" }}>
|
|
68
|
+
<div className={`font-medium text-${textAlign} ${styles.SolidChartTitle}`}>{question.name}</div>
|
|
69
|
+
<div className={`mt-2 font-bold text-3xl text-${textAlign} ${styles.SolidChartTitle}`}>{questionData.data.kpi}</div>
|
|
70
|
+
</div>
|
|
71
|
+
<div className='mt-3 flex-1 min-h-0 p-4 pt-2'>
|
|
72
|
+
{['bar', 'line', 'pie'].includes(question.visualisedAs) && <ChartJsRenderer options={options} visualizationData={questionData.data.visualizationData} visualizedAs={question.visualisedAs} />}
|
|
73
|
+
{question.visualisedAs === 'prime-meter-group' && <MeterGroup values={questionData.data.visualizationData.dataset} max={questionData?.data?.visualizationData?.dataset?.reduce((total: number, item: DataItem) => total + item.value, 0)} />}
|
|
74
|
+
{question.visualisedAs === 'prime-datatable' && <PrimeReactDatatableRenderer options={options} visualizationData={questionData.data.visualizationData} />}
|
|
75
|
+
</div>
|
|
73
76
|
</div>
|
|
74
|
-
|
|
75
|
-
}
|
|
77
|
+
}
|
|
76
78
|
</>
|
|
77
79
|
)
|
|
78
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartJsRenderer.d.ts","sourceRoot":"","sources":["../../../../../src/components/core/dashboard/chart-renderers/ChartJsRenderer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ChartJsRenderer.d.ts","sourceRoot":"","sources":["../../../../../src/components/core/dashboard/chart-renderers/ChartJsRenderer.tsx"],"names":[],"mappings":"AAEA,OAAO,oEAAoE,CAAC;AAI5E,KAAK,oBAAoB,GAAG;IACxB,OAAO,EAAE,GAAG,CAAC;IACb,iBAAiB,EAAE,GAAG,CAAC;IACvB,YAAY,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,CAAC;CACxC,CAAC;AACF,eAAO,MAAM,eAAe,iDAAkD,oBAAoB,4CAoCjG,CAAA"}
|
|
@@ -1,8 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
import { useEffect, useRef } from "react";
|
|
2
14
|
import "../../../../components/core/dashboard/chart-renderers/init-chartjs";
|
|
3
15
|
import { Bar, Line, Pie } from "react-chartjs-2";
|
|
4
16
|
export var ChartJsRenderer = function (_a) {
|
|
5
17
|
var options = _a.options, visualizationData = _a.visualizationData, visualizedAs = _a.visualizedAs;
|
|
6
|
-
|
|
18
|
+
var chartRef = useRef(null);
|
|
19
|
+
var containerRef = useRef(null);
|
|
20
|
+
useEffect(function () {
|
|
21
|
+
if (!containerRef.current)
|
|
22
|
+
return;
|
|
23
|
+
var observer = new ResizeObserver(function () {
|
|
24
|
+
if (chartRef.current) {
|
|
25
|
+
chartRef.current.resize(); // ✅ tell Chart.js to refit
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
observer.observe(containerRef.current);
|
|
29
|
+
return function () { return observer.disconnect(); };
|
|
30
|
+
}, []);
|
|
31
|
+
// Merge in responsive options
|
|
32
|
+
var mergedOptions = __assign(__assign({}, options), { responsive: true, maintainAspectRatio: false });
|
|
33
|
+
return (_jsx(_Fragment, { children: _jsxs("div", { ref: containerRef, style: { position: "relative", width: "100%", height: "100%" }, children: [visualizedAs === 'bar' && _jsx(Bar, { ref: chartRef, options: mergedOptions, data: visualizationData }), visualizedAs === 'line' && _jsx(Line, { ref: chartRef, options: mergedOptions, data: visualizationData }), visualizedAs === 'pie' && _jsx(Pie, { ref: chartRef, options: mergedOptions, data: visualizationData })] }) }));
|
|
7
34
|
};
|
|
8
35
|
//# sourceMappingURL=ChartJsRenderer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartJsRenderer.js","sourceRoot":"","sources":["../../../../../src/components/core/dashboard/chart-renderers/ChartJsRenderer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ChartJsRenderer.js","sourceRoot":"","sources":["../../../../../src/components/core/dashboard/chart-renderers/ChartJsRenderer.tsx"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,oEAAoE,CAAC;AAC5E,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAQjD,MAAM,CAAC,IAAM,eAAe,GAAG,UAAC,EAAkE;QAAhE,OAAO,aAAA,EAAE,iBAAiB,uBAAA,EAAE,YAAY,kBAAA;IAEtE,IAAM,QAAQ,GAAG,MAAM,CAAqB,IAAI,CAAC,CAAC;IAClD,IAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAElD,SAAS,CAAC;QACN,IAAI,CAAC,YAAY,CAAC,OAAO;YAAE,OAAO;QAElC,IAAM,QAAQ,GAAG,IAAI,cAAc,CAAC;YAChC,IAAI,QAAQ,CAAC,OAAO,EAAE;gBAClB,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAE,2BAA2B;aAC1D;QACL,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QACvC,OAAO,cAAM,OAAA,QAAQ,CAAC,UAAU,EAAE,EAArB,CAAqB,CAAC;IACvC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,8BAA8B;IAC9B,IAAM,aAAa,yBACZ,OAAO,KACV,UAAU,EAAE,IAAI,EAChB,mBAAmB,EAAE,KAAK,GAC7B,CAAC;IAGF,OAAO,CACH,4BACI,eAAK,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAEjF,YAAY,KAAK,KAAK,IAAI,KAAC,GAAG,IAAC,GAAG,EAAE,QAAe,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,iBAAiB,GAAI,EACxG,YAAY,KAAK,MAAM,IAAI,KAAC,IAAI,IAAC,GAAG,EAAE,QAAe,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,iBAAiB,GAAI,EAC1G,YAAY,KAAK,KAAK,IAAI,KAAC,GAAG,IAAC,GAAG,EAAE,QAAe,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,iBAAiB,GAAI,IACvG,GACP,CACN,CAAC;AACN,CAAC,CAAA","sourcesContent":["\nimport { useEffect, useRef } from \"react\";\nimport \"../../../../components/core/dashboard/chart-renderers/init-chartjs\";\nimport { Bar, Line, Pie } from \"react-chartjs-2\";\nimport { ChartJSOrUndefined } from \"node_modules/react-chartjs-2/dist/types\";\n\ntype ChartJsRendererProps = {\n options: any;\n visualizationData: any;\n visualizedAs: 'bar' | 'line' | 'pie';\n};\nexport const ChartJsRenderer = ({ options, visualizationData, visualizedAs }: ChartJsRendererProps) => {\n\n const chartRef = useRef<ChartJSOrUndefined>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (!containerRef.current) return;\n\n const observer = new ResizeObserver(() => {\n if (chartRef.current) {\n chartRef.current.resize(); // ✅ tell Chart.js to refit\n }\n });\n\n observer.observe(containerRef.current);\n return () => observer.disconnect();\n }, []);\n\n // Merge in responsive options\n const mergedOptions = {\n ...options,\n responsive: true,\n maintainAspectRatio: false, // ✅ allows chart to fill container height\n };\n\n\n return (\n <>\n <div ref={containerRef} style={{ position: \"relative\", width: \"100%\", height: \"100%\" }}>\n\n {visualizedAs === 'bar' && <Bar ref={chartRef as any} options={mergedOptions} data={visualizationData} />}\n {visualizedAs === 'line' && <Line ref={chartRef as any} options={mergedOptions} data={visualizationData} />}\n {visualizedAs === 'pie' && <Pie ref={chartRef as any} options={mergedOptions} data={visualizationData} />}\n </div>\n </>\n );\n}"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
2
3
|
import "../../../../components/core/dashboard/chart-renderers/init-chartjs";
|
|
3
4
|
import { Bar, Line, Pie } from "react-chartjs-2";
|
|
5
|
+
import { ChartJSOrUndefined } from "node_modules/react-chartjs-2/dist/types";
|
|
4
6
|
|
|
5
7
|
type ChartJsRendererProps = {
|
|
6
8
|
options: any;
|
|
@@ -8,11 +10,39 @@ type ChartJsRendererProps = {
|
|
|
8
10
|
visualizedAs: 'bar' | 'line' | 'pie';
|
|
9
11
|
};
|
|
10
12
|
export const ChartJsRenderer = ({ options, visualizationData, visualizedAs }: ChartJsRendererProps) => {
|
|
13
|
+
|
|
14
|
+
const chartRef = useRef<ChartJSOrUndefined>(null);
|
|
15
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (!containerRef.current) return;
|
|
19
|
+
|
|
20
|
+
const observer = new ResizeObserver(() => {
|
|
21
|
+
if (chartRef.current) {
|
|
22
|
+
chartRef.current.resize(); // ✅ tell Chart.js to refit
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
observer.observe(containerRef.current);
|
|
27
|
+
return () => observer.disconnect();
|
|
28
|
+
}, []);
|
|
29
|
+
|
|
30
|
+
// Merge in responsive options
|
|
31
|
+
const mergedOptions = {
|
|
32
|
+
...options,
|
|
33
|
+
responsive: true,
|
|
34
|
+
maintainAspectRatio: false, // ✅ allows chart to fill container height
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
|
|
11
38
|
return (
|
|
12
39
|
<>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
40
|
+
<div ref={containerRef} style={{ position: "relative", width: "100%", height: "100%" }}>
|
|
41
|
+
|
|
42
|
+
{visualizedAs === 'bar' && <Bar ref={chartRef as any} options={mergedOptions} data={visualizationData} />}
|
|
43
|
+
{visualizedAs === 'line' && <Line ref={chartRef as any} options={mergedOptions} data={visualizationData} />}
|
|
44
|
+
{visualizedAs === 'pie' && <Pie ref={chartRef as any} options={mergedOptions} data={visualizationData} />}
|
|
45
|
+
</div>
|
|
16
46
|
</>
|
|
17
47
|
);
|
|
18
48
|
}
|
package/dist/components/core/extension/solid-core/dashboard/dashboardFormViewChangeHandler.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SolidUiEvent } from "../../../../../types";
|
|
2
|
+
declare const dashboardFormViewChangeHandler: (event: SolidUiEvent) => {
|
|
3
|
+
layoutChanged: boolean;
|
|
4
|
+
dataChanged: boolean;
|
|
5
|
+
newFormData: {
|
|
6
|
+
name: any;
|
|
7
|
+
};
|
|
8
|
+
} | undefined;
|
|
9
|
+
export default dashboardFormViewChangeHandler;
|
|
10
|
+
//# sourceMappingURL=dashboardFormViewChangeHandler.d.ts.map
|
package/dist/components/core/extension/solid-core/dashboard/dashboardFormViewChangeHandler.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboardFormViewChangeHandler.d.ts","sourceRoot":"","sources":["../../../../../../src/components/core/extension/solid-core/dashboard/dashboardFormViewChangeHandler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,QAAA,MAAM,8BAA8B,UAAW,YAAY;;;;;;aAc1D,CAAA;AACD,eAAe,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getSingularAndPlural } from "../../../../../helpers/helpers";
|
|
2
|
+
var dashboardFormViewChangeHandler = function (event) {
|
|
3
|
+
var modifiedField = event.modifiedField, modifiedFieldValue = event.modifiedFieldValue, formData = event.formData;
|
|
4
|
+
var toKebabCase = getSingularAndPlural(modifiedFieldValue).toKebabCase;
|
|
5
|
+
if (modifiedField === 'displayName') {
|
|
6
|
+
return {
|
|
7
|
+
layoutChanged: false,
|
|
8
|
+
dataChanged: true,
|
|
9
|
+
newFormData: {
|
|
10
|
+
name: toKebabCase
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export default dashboardFormViewChangeHandler;
|
|
16
|
+
//# sourceMappingURL=dashboardFormViewChangeHandler.js.map
|
package/dist/components/core/extension/solid-core/dashboard/dashboardFormViewChangeHandler.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboardFormViewChangeHandler.js","sourceRoot":"","sources":["../../../../../../src/components/core/extension/solid-core/dashboard/dashboardFormViewChangeHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAGtE,IAAM,8BAA8B,GAAG,UAAC,KAAmB;IAE/C,IAAA,aAAa,GAAmC,KAAK,cAAxC,EAAE,kBAAkB,GAAe,KAAK,mBAApB,EAAE,QAAQ,GAAK,KAAK,SAAV,CAAW;IACtD,IAAA,WAAW,GAAK,oBAAoB,CAAC,kBAAkB,CAAC,YAA7C,CAA8C;IAEjE,IAAI,aAAa,KAAK,aAAa,EAAE;QACjC,OAAO;YACH,aAAa,EAAE,KAAK;YACpB,WAAW,EAAE,IAAI;YACjB,WAAW,EAAE;gBACT,IAAI,EAAE,WAAW;aACpB;SACJ,CAAA;KACJ;AACL,CAAC,CAAA;AACD,eAAe,8BAA8B,CAAC","sourcesContent":["import { getSingularAndPlural } from \"../../../../../helpers/helpers\";\nimport { SolidUiEvent } from \"../../../../../types\";\n\nconst dashboardFormViewChangeHandler = (event: SolidUiEvent) => {\n\n const { modifiedField, modifiedFieldValue, formData } = event;\n const { toKebabCase } = getSingularAndPlural(modifiedFieldValue);\n\n if (modifiedField === 'displayName') {\n return {\n layoutChanged: false,\n dataChanged: true,\n newFormData: {\n name: toKebabCase\n },\n }\n }\n}\nexport default dashboardFormViewChangeHandler;\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getSingularAndPlural } from "../../../../../helpers/helpers";
|
|
2
|
+
import { SolidUiEvent } from "../../../../../types";
|
|
3
|
+
|
|
4
|
+
const dashboardFormViewChangeHandler = (event: SolidUiEvent) => {
|
|
5
|
+
|
|
6
|
+
const { modifiedField, modifiedFieldValue, formData } = event;
|
|
7
|
+
const { toKebabCase } = getSingularAndPlural(modifiedFieldValue);
|
|
8
|
+
|
|
9
|
+
if (modifiedField === 'displayName') {
|
|
10
|
+
return {
|
|
11
|
+
layoutChanged: false,
|
|
12
|
+
dataChanged: true,
|
|
13
|
+
newFormData: {
|
|
14
|
+
name: toKebabCase
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export default dashboardFormViewChangeHandler;
|
package/dist/components/core/extension/solid-core/dashboard/dashboardQuestionFieldChangeHandler.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SolidUiEvent } from "../../../../../types";
|
|
2
|
+
declare const dashboardQuestionFieldChangeHandler: (event: SolidUiEvent) => Promise<{
|
|
3
|
+
layoutChanged: boolean;
|
|
4
|
+
dataChanged: boolean;
|
|
5
|
+
newLayout: import("../../../../../types").LayoutNode;
|
|
6
|
+
}>;
|
|
7
|
+
export default dashboardQuestionFieldChangeHandler;
|
|
8
|
+
//# sourceMappingURL=dashboardQuestionFieldChangeHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboardQuestionFieldChangeHandler.d.ts","sourceRoot":"","sources":["../../../../../../src/components/core/extension/solid-core/dashboard/dashboardQuestionFieldChangeHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,QAAA,MAAM,mCAAmC,UAAiB,YAAY;;;;EAuBrE,CAAA;AAGD,eAAe,mCAAmC,CAAC"}
|
package/dist/components/core/extension/solid-core/dashboard/dashboardQuestionFieldChangeHandler.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { SolidViewLayoutManager } from "../../../../../components/core/common/SolidViewLayoutManager";
|
|
38
|
+
var dashboardQuestionFieldChangeHandler = function (event) { return __awaiter(void 0, void 0, void 0, function () {
|
|
39
|
+
var modifiedField, modifiedFieldValue, formViewLayout, layout, layoutManager;
|
|
40
|
+
return __generator(this, function (_a) {
|
|
41
|
+
modifiedField = event.modifiedField, modifiedFieldValue = event.modifiedFieldValue, formViewLayout = event.formViewLayout;
|
|
42
|
+
layout = formViewLayout;
|
|
43
|
+
layoutManager = new SolidViewLayoutManager(layout);
|
|
44
|
+
if (modifiedField === 'sourceType') {
|
|
45
|
+
if (modifiedFieldValue.value === 'sql') {
|
|
46
|
+
layoutManager.updateNodeAttributes('labelSql', { visible: true });
|
|
47
|
+
layoutManager.updateNodeAttributes('kpiSql', { visible: true });
|
|
48
|
+
layoutManager.updateNodeAttributes('providerName', { visible: false });
|
|
49
|
+
}
|
|
50
|
+
if (modifiedFieldValue.value === 'provider') {
|
|
51
|
+
layoutManager.updateNodeAttributes('labelSql', { visible: false });
|
|
52
|
+
layoutManager.updateNodeAttributes('kpiSql', { visible: false });
|
|
53
|
+
layoutManager.updateNodeAttributes('providerName', { visible: true });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return [2 /*return*/, {
|
|
57
|
+
layoutChanged: true,
|
|
58
|
+
dataChanged: false,
|
|
59
|
+
newLayout: layoutManager.getLayout(),
|
|
60
|
+
}];
|
|
61
|
+
});
|
|
62
|
+
}); };
|
|
63
|
+
export default dashboardQuestionFieldChangeHandler;
|
|
64
|
+
//# sourceMappingURL=dashboardQuestionFieldChangeHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboardQuestionFieldChangeHandler.js","sourceRoot":"","sources":["../../../../../../src/components/core/extension/solid-core/dashboard/dashboardQuestionFieldChangeHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,8DAA8D,CAAC;AAEtG,IAAM,mCAAmC,GAAG,UAAO,KAAmB;;;QAC1D,aAAa,GAAyC,KAAK,cAA9C,EAAE,kBAAkB,GAAqB,KAAK,mBAA1B,EAAE,cAAc,GAAK,KAAK,eAAV,CAAW;QAE9D,MAAM,GAAG,cAAc,CAAC;QAExB,aAAa,GAAG,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAC;QACzD,IAAI,aAAa,KAAK,YAAY,EAAE;YAChC,IAAI,kBAAkB,CAAC,KAAK,KAAK,KAAK,EAAE;gBACpC,aAAa,CAAC,oBAAoB,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;gBAClE,aAAa,CAAC,oBAAoB,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;gBAChE,aAAa,CAAC,oBAAoB,CAAC,cAAc,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;aAC1E;YACD,IAAI,kBAAkB,CAAC,KAAK,KAAK,UAAU,EAAE;gBACzC,aAAa,CAAC,oBAAoB,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;gBACnE,aAAa,CAAC,oBAAoB,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;gBACjE,aAAa,CAAC,oBAAoB,CAAC,cAAc,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;aACzE;SACJ;QACD,sBAAO;gBACH,aAAa,EAAE,IAAI;gBACnB,WAAW,EAAE,KAAK;gBAClB,SAAS,EAAE,aAAa,CAAC,SAAS,EAAE;aACvC,EAAA;;KACJ,CAAA;AAGD,eAAe,mCAAmC,CAAC","sourcesContent":["import { SolidUiEvent } from \"../../../../../types\";\nimport { SolidViewLayoutManager } from \"../../../../../components/core/common/SolidViewLayoutManager\";\n\nconst dashboardQuestionFieldChangeHandler = async (event: SolidUiEvent) => {\n const { modifiedField, modifiedFieldValue, formViewLayout } = event;\n\n const layout = formViewLayout;\n\n const layoutManager = new SolidViewLayoutManager(layout);\n if (modifiedField === 'sourceType') {\n if (modifiedFieldValue.value === 'sql') {\n layoutManager.updateNodeAttributes('labelSql', { visible: true });\n layoutManager.updateNodeAttributes('kpiSql', { visible: true });\n layoutManager.updateNodeAttributes('providerName', { visible: false });\n }\n if (modifiedFieldValue.value === 'provider') {\n layoutManager.updateNodeAttributes('labelSql', { visible: false });\n layoutManager.updateNodeAttributes('kpiSql', { visible: false });\n layoutManager.updateNodeAttributes('providerName', { visible: true });\n }\n }\n return {\n layoutChanged: true,\n dataChanged: false,\n newLayout: layoutManager.getLayout(),\n }\n}\n\n\nexport default dashboardQuestionFieldChangeHandler;\n"]}
|