@quillsql/react 2.13.18 → 2.13.19
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/cjs/Chart.d.ts +2 -2
- package/dist/cjs/Chart.d.ts.map +1 -1
- package/dist/cjs/Chart.js +53 -175
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +3 -3
- package/dist/cjs/Context.d.ts +24 -3
- package/dist/cjs/Context.d.ts.map +1 -1
- package/dist/cjs/Context.js +323 -7
- package/dist/cjs/Dashboard.js +1 -1
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +0 -2
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +1 -4
- package/dist/cjs/Table.d.ts.map +1 -1
- package/dist/cjs/Table.js +34 -32
- package/dist/cjs/components/Dashboard/DashboardFilter.js +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.d.ts +4 -2
- package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.js +141 -57
- package/dist/cjs/hooks/useDashboard.d.ts.map +1 -1
- package/dist/cjs/hooks/useDashboard.js +2 -49
- package/dist/cjs/hooks/useQuill.d.ts.map +1 -1
- package/dist/cjs/hooks/useQuill.js +66 -42
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.js +0 -1
- package/dist/cjs/models/Report.d.ts +4 -3
- package/dist/cjs/models/Report.d.ts.map +1 -1
- package/dist/cjs/utils/columnProcessing.d.ts +2 -1
- package/dist/cjs/utils/columnProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/columnProcessing.js +2 -2
- package/dist/cjs/utils/dataProcessing.js +2 -2
- package/dist/cjs/utils/filterProcessing.d.ts +6 -1
- package/dist/cjs/utils/filterProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/filterProcessing.js +81 -3
- package/dist/cjs/utils/pivotConstructor.js +1 -1
- package/dist/cjs/utils/queryConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/queryConstructor.js +0 -1
- package/dist/cjs/utils/report.d.ts +13 -1
- package/dist/cjs/utils/report.d.ts.map +1 -1
- package/dist/cjs/utils/report.js +81 -51
- package/dist/esm/Chart.d.ts +2 -2
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +66 -179
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +3 -3
- package/dist/esm/Context.d.ts +24 -3
- package/dist/esm/Context.d.ts.map +1 -1
- package/dist/esm/Context.js +322 -6
- package/dist/esm/Dashboard.js +1 -1
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +0 -2
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +1 -4
- package/dist/esm/Table.d.ts.map +1 -1
- package/dist/esm/Table.js +34 -32
- package/dist/esm/components/Dashboard/DashboardFilter.js +1 -1
- package/dist/esm/components/Dashboard/DataLoader.d.ts +4 -2
- package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.js +142 -58
- package/dist/esm/hooks/useDashboard.d.ts.map +1 -1
- package/dist/esm/hooks/useDashboard.js +3 -50
- package/dist/esm/hooks/useQuill.d.ts.map +1 -1
- package/dist/esm/hooks/useQuill.js +68 -44
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.js +0 -1
- package/dist/esm/models/Report.d.ts +4 -3
- package/dist/esm/models/Report.d.ts.map +1 -1
- package/dist/esm/utils/columnProcessing.d.ts +2 -1
- package/dist/esm/utils/columnProcessing.d.ts.map +1 -1
- package/dist/esm/utils/columnProcessing.js +2 -2
- package/dist/esm/utils/dataProcessing.js +2 -2
- package/dist/esm/utils/filterProcessing.d.ts +6 -1
- package/dist/esm/utils/filterProcessing.d.ts.map +1 -1
- package/dist/esm/utils/filterProcessing.js +78 -2
- package/dist/esm/utils/pivotConstructor.js +1 -1
- package/dist/esm/utils/queryConstructor.d.ts.map +1 -1
- package/dist/esm/utils/queryConstructor.js +0 -1
- package/dist/esm/utils/report.d.ts +13 -1
- package/dist/esm/utils/report.d.ts.map +1 -1
- package/dist/esm/utils/report.js +79 -51
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ const QuillDateRangePicker_1 = require("../../DateRangePicker/QuillDateRangePick
|
|
|
7
7
|
const QuillMultiSelect_1 = require("../QuillMultiSelect");
|
|
8
8
|
const QuillSelect_1 = require("../QuillSelect");
|
|
9
9
|
function DashboardFilter({ filter, onChangeFilter, SelectComponent = QuillSelect_1.QuillSelectComponent, MultiSelectComponent = QuillMultiSelect_1.QuillMultiSelectComponent, DateRangePickerComponent = QuillDateRangePicker_1.QuillDateRangePicker, theme, isLoading, }) {
|
|
10
|
-
if (!filter.options && !isLoading) {
|
|
10
|
+
if (!filter.options && !isLoading && !(filter.filterType === 'date_range')) {
|
|
11
11
|
return null;
|
|
12
12
|
}
|
|
13
13
|
if (filter.filterType === 'string') {
|
|
@@ -14,11 +14,12 @@ export type DataLoaderChildProps = {
|
|
|
14
14
|
rowCount?: number;
|
|
15
15
|
rowCountIsLoading?: boolean;
|
|
16
16
|
};
|
|
17
|
-
export default function DataLoader({ item, children, filters, userFilters, additionalProcessing: defaultAdditionalProcessing, }: {
|
|
17
|
+
export default function DataLoader({ item, children, filters, userFilters, additionalProcessing: defaultAdditionalProcessing, reportMode, }: {
|
|
18
18
|
item: QuillReport;
|
|
19
19
|
filters: DashboardFilter[];
|
|
20
20
|
userFilters?: InternalFilter[];
|
|
21
21
|
additionalProcessing: AdditionalProcessing;
|
|
22
|
+
reportMode?: boolean;
|
|
22
23
|
children: ({ isLoading, error, onPageChange, onSortChange, data, }: DataLoaderChildProps) => JSX.Element;
|
|
23
24
|
}): JSX.Element;
|
|
24
25
|
type ColorMapType = {
|
|
@@ -39,13 +40,14 @@ export type ChartDataLoaderChildProps = {
|
|
|
39
40
|
rowCount?: number;
|
|
40
41
|
rowCountIsLoading?: boolean;
|
|
41
42
|
};
|
|
42
|
-
export declare const ChartDataLoader: ({ item, children, dateBucket, additionalProcessing, filters, userFilters, }: {
|
|
43
|
+
export declare const ChartDataLoader: ({ item, children, dateBucket, additionalProcessing, filters, userFilters, reportMode, }: {
|
|
43
44
|
item: QuillReport;
|
|
44
45
|
dateBucket?: string;
|
|
45
46
|
mapColorsToFields?: (_report: QuillReport, _theme: QuillTheme) => ColorMapType;
|
|
46
47
|
additionalProcessing: AdditionalProcessing;
|
|
47
48
|
filters: DashboardFilter[];
|
|
48
49
|
userFilters?: InternalFilter[];
|
|
50
|
+
reportMode?: boolean;
|
|
49
51
|
children: ({ isLoading, error, data, dateBucket, rowCount, rowCountIsLoading, }: ChartDataLoaderChildProps) => JSX.Element;
|
|
50
52
|
}) => JSX.Element;
|
|
51
53
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataLoader.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/DataLoader.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DataLoader.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/DataLoader.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,WAAW,EAAuB,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAajD,OAAO,EACL,oBAAoB,EAErB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AA2BtE,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,YAAY,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACnE,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAuFF,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,WAAW,EACX,oBAAoB,EAAE,2BAA2B,EACjD,UAAkB,GACnB,EAAE;IACD,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,WAAW,CAAC,EAAE,cAAc,EAAE,CAAC;IAC/B,oBAAoB,EAAE,oBAAoB,CAAC;IAC3C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,CAAC,EACT,SAAS,EACT,KAAK,EACL,YAAY,EACZ,YAAY,EACZ,IAAI,GACL,EAAE,oBAAoB,KAAK,GAAG,CAAC,OAAO,CAAC;CACzC,GAAG,GAAG,CAAC,OAAO,CAwTd;AAED,KAAK,YAAY,GAAG;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,uBAAuB,CAAC,EAAE,MAAM,CAAC;QACjC,sBAAsB,CAAC,EAAE,MAAM,CAAC;KACjC,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,WAAW,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAIF,eAAO,MAAM,eAAe,4FAQzB;IACD,IAAI,EAAE,WAAW,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,CAClB,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,UAAU,KACf,YAAY,CAAC;IAClB,oBAAoB,EAAE,oBAAoB,CAAC;IAC3C,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,WAAW,CAAC,EAAE,cAAc,EAAE,CAAC;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,CAAC,EACT,SAAS,EACT,KAAK,EACL,IAAI,EACJ,UAAU,EACV,QAAQ,EACR,iBAAiB,GAClB,EAAE,yBAAyB,KAAK,GAAG,CAAC,OAAO,CAAC;CAC9C,KAAG,GAAG,CAAC,OAgKP,CAAC"}
|
|
@@ -57,8 +57,8 @@ function filterValuesEquivalent(filters1, filters2) {
|
|
|
57
57
|
mappedFilters1[key].label !== mappedFilters2[key]?.label ||
|
|
58
58
|
mappedFilters1[key].table !== mappedFilters2[key]?.table ||
|
|
59
59
|
mappedFilters1[key].filterType !== mappedFilters2[key]?.filterType ||
|
|
60
|
-
mappedFilters1[key].startDate
|
|
61
|
-
mappedFilters1[key].endDate
|
|
60
|
+
!(0, fast_deep_equal_1.default)(mappedFilters1[key].startDate, mappedFilters2[key]?.startDate) ||
|
|
61
|
+
!(0, fast_deep_equal_1.default)(mappedFilters1[key].endDate, mappedFilters2[key]?.endDate) ||
|
|
62
62
|
!(0, fast_deep_equal_1.default)(mappedFilters1[key].comparisonRange, mappedFilters2[key]?.comparisonRange)) {
|
|
63
63
|
return false;
|
|
64
64
|
}
|
|
@@ -86,7 +86,7 @@ function userFilterValuesEquivalent(filters1, filters2) {
|
|
|
86
86
|
return acc;
|
|
87
87
|
}, {});
|
|
88
88
|
for (const key in mappedFilters1) {
|
|
89
|
-
if (mappedFilters1[key]?.value
|
|
89
|
+
if (!(0, fast_deep_equal_1.default)(mappedFilters1[key]?.value, mappedFilters2[key]?.value) ||
|
|
90
90
|
mappedFilters1[key]?.operator !== mappedFilters2[key]?.operator ||
|
|
91
91
|
mappedFilters1[key]?.fieldType !== mappedFilters2[key]?.fieldType ||
|
|
92
92
|
mappedFilters1[key]?.filterType !== mappedFilters2[key]?.filterType) {
|
|
@@ -95,19 +95,35 @@ function userFilterValuesEquivalent(filters1, filters2) {
|
|
|
95
95
|
}
|
|
96
96
|
return true;
|
|
97
97
|
}
|
|
98
|
-
function DataLoader({ item, children, filters, userFilters, additionalProcessing: defaultAdditionalProcessing, }) {
|
|
98
|
+
function DataLoader({ item, children, filters, userFilters, additionalProcessing: defaultAdditionalProcessing, reportMode = false, }) {
|
|
99
99
|
const [client] = (0, react_1.useContext)(Context_1.ClientContext);
|
|
100
100
|
const [dashboard, dispatch] = (0, react_1.useContext)(Context_1.DashboardContext);
|
|
101
101
|
const { dashboardFilters } = (0, react_1.useContext)(Context_1.DashboardFiltersContext);
|
|
102
|
+
const { reports, reportsDispatch, fetchIndividualReport } = (0, react_1.useContext)(Context_1.ReportsContext);
|
|
103
|
+
const { reportFilters } = (0, react_1.useContext)(Context_1.ReportFiltersContext);
|
|
104
|
+
const contextFilters = () => {
|
|
105
|
+
return reportMode
|
|
106
|
+
? Object.values(reportFilters[item.id] ?? {}).map((f) => f.filter)
|
|
107
|
+
: Object.values(dashboardFilters[item.dashboardName] ?? {}).map((f) => f.filter);
|
|
108
|
+
};
|
|
102
109
|
const [schemaData] = (0, react_1.useContext)(Context_1.SchemaDataContext);
|
|
103
110
|
const [loading, setLoading] = (0, react_1.useState)(!dashboard[item.id]);
|
|
104
111
|
const [error, setError] = (0, react_1.useState)(undefined);
|
|
105
112
|
const [previousPage, setPreviousPage] = (0, react_1.useState)(0);
|
|
106
113
|
const [additionalProcessing, setAdditionalProcessing] = (0, react_1.useState)(defaultAdditionalProcessing);
|
|
107
114
|
const chartReport = (0, react_1.useMemo)(() => {
|
|
108
|
-
const report = dashboard[item.id]
|
|
109
|
-
|
|
110
|
-
|
|
115
|
+
const report = (reportMode ? reports : dashboard)[item.id];
|
|
116
|
+
if (report) {
|
|
117
|
+
return (0, report_1.convertInternalReportToReport)((0, merge_1.mergeComparisonRange)(report), contextFilters());
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
return constructReportFromItem(item);
|
|
121
|
+
}
|
|
122
|
+
}, [
|
|
123
|
+
(reportMode ? reports : dashboard)[item.id],
|
|
124
|
+
reportFilters,
|
|
125
|
+
dashboardFilters,
|
|
126
|
+
]);
|
|
111
127
|
const previousFilters = (0, react_1.useRef)(null);
|
|
112
128
|
const previousUserFilters = (0, react_1.useRef)(null);
|
|
113
129
|
const [rowCountIsLoading, setRowCountIsLoading] = (0, react_1.useState)(false);
|
|
@@ -130,11 +146,20 @@ function DataLoader({ item, children, filters, userFilters, additionalProcessing
|
|
|
130
146
|
const rowCount = await (0, report_1.fetchReportRowCount)(item.id, client, true, (0, filterProcessing_1.mergeCustomFilters)(filters, userFilters ?? []), processing, schemaData.customFields, rowCountAbortController.current.signal);
|
|
131
147
|
rowCountAbortController.current = null;
|
|
132
148
|
if (rowCount) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
149
|
+
if (reportMode) {
|
|
150
|
+
reportsDispatch({
|
|
151
|
+
type: 'UPDATE_REPORT',
|
|
152
|
+
id: item.id,
|
|
153
|
+
data: { rowCount },
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
dispatch({
|
|
158
|
+
type: 'UPDATE_DASHBOARD_ITEM',
|
|
159
|
+
id: item.id,
|
|
160
|
+
data: { rowCount },
|
|
161
|
+
});
|
|
162
|
+
}
|
|
138
163
|
}
|
|
139
164
|
}
|
|
140
165
|
catch (e) {
|
|
@@ -165,7 +190,7 @@ function DataLoader({ item, children, filters, userFilters, additionalProcessing
|
|
|
165
190
|
}
|
|
166
191
|
};
|
|
167
192
|
const onSortChange = (sort) => {
|
|
168
|
-
const report = dashboard[item.id];
|
|
193
|
+
const report = (reportMode ? reports : dashboard)[item.id];
|
|
169
194
|
if ((0, paginationProcessing_1.shouldSortInMemory)(additionalProcessing.page ?? paginationProcessing_1.DEFAULT_PAGINATION, report?.rowCount, !!report?.pivot)) {
|
|
170
195
|
return;
|
|
171
196
|
}
|
|
@@ -192,17 +217,27 @@ function DataLoader({ item, children, filters, userFilters, additionalProcessing
|
|
|
192
217
|
throw new Error('Error fetching chart');
|
|
193
218
|
}
|
|
194
219
|
let tempRows = [
|
|
195
|
-
...(dashboard[item.id]?.rows ?? []),
|
|
220
|
+
...((reportMode ? reports : dashboard)[item.id]?.rows ?? []),
|
|
196
221
|
...paginatedRows.rows,
|
|
197
222
|
];
|
|
198
223
|
if (resetRows) {
|
|
199
224
|
tempRows = paginatedRows.rows;
|
|
200
225
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
226
|
+
if (reportMode) {
|
|
227
|
+
reportsDispatch({
|
|
228
|
+
type: 'UPDATE_REPORT',
|
|
229
|
+
id: item.id,
|
|
230
|
+
data: { rows: tempRows },
|
|
231
|
+
filtersApplied: userFilters,
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
dispatch({
|
|
236
|
+
type: 'UPDATE_DASHBOARD_ITEM',
|
|
237
|
+
id: item.id,
|
|
238
|
+
data: { rows: tempRows },
|
|
239
|
+
});
|
|
240
|
+
}
|
|
206
241
|
setAdditionalProcessing(updatedProcessing);
|
|
207
242
|
}
|
|
208
243
|
catch (e) {
|
|
@@ -221,7 +256,7 @@ function DataLoader({ item, children, filters, userFilters, additionalProcessing
|
|
|
221
256
|
}
|
|
222
257
|
const fetchRowsRequestId = rowsRequestId.current + 1;
|
|
223
258
|
rowsRequestId.current = fetchRowsRequestId;
|
|
224
|
-
const tempReport = dashboard[item.id];
|
|
259
|
+
const tempReport = (reportMode ? reports : dashboard)[item.id];
|
|
225
260
|
if (tempReport &&
|
|
226
261
|
!(0, Chart_1.didFiltersChange)(tempReport, filters) &&
|
|
227
262
|
userFilterValuesEquivalent(userFilters ?? [], previousUserFilters.current ?? []) &&
|
|
@@ -234,16 +269,30 @@ function DataLoader({ item, children, filters, userFilters, additionalProcessing
|
|
|
234
269
|
rowsAbortController.current?.abort();
|
|
235
270
|
rowsAbortController.current = new AbortController();
|
|
236
271
|
try {
|
|
237
|
-
|
|
238
|
-
|
|
272
|
+
if (reportMode) {
|
|
273
|
+
try {
|
|
274
|
+
await fetchIndividualReport(item.id, 'Chart', true, filters, userFilters, processing, undefined, rowsAbortController.current || undefined);
|
|
275
|
+
setError(undefined);
|
|
276
|
+
}
|
|
277
|
+
catch (e) {
|
|
278
|
+
setError(e.message ?? 'Error fetching report');
|
|
279
|
+
}
|
|
280
|
+
rowsAbortController.current = null;
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
const { report: fetchedReport, error } = await (0, report_1.fetchReport)(item.id, client, true, (0, filterProcessing_1.mergeCustomFilters)(filters, userFilters ?? []), processing, undefined, schemaData.customFields, true, false, rowsAbortController.current.signal);
|
|
284
|
+
rowsAbortController.current = null;
|
|
285
|
+
dispatch({
|
|
286
|
+
type: 'ADD_DASHBOARD_ITEM',
|
|
287
|
+
id: item.id,
|
|
288
|
+
data: { ...fetchedReport, triggerReload: false, rowCount: 0 }, // rowCount 0 indicates it's still loading if row length is nonzero
|
|
289
|
+
appliedFilters: userFilters,
|
|
290
|
+
loading: false,
|
|
291
|
+
});
|
|
292
|
+
setError(error);
|
|
293
|
+
}
|
|
239
294
|
fetchRowCount(processing);
|
|
240
|
-
dispatch({
|
|
241
|
-
type: 'ADD_DASHBOARD_ITEM',
|
|
242
|
-
id: item.id,
|
|
243
|
-
data: { ...fetchedReport, triggerReload: false, rowCount: 0 }, // rowCount 0 indicates it's still loading if row length is nonzero
|
|
244
|
-
});
|
|
245
295
|
setAdditionalProcessing(processing);
|
|
246
|
-
setError(error);
|
|
247
296
|
}
|
|
248
297
|
catch (e) {
|
|
249
298
|
if (e instanceof Error && e.name === 'AbortError') {
|
|
@@ -261,9 +310,9 @@ function DataLoader({ item, children, filters, userFilters, additionalProcessing
|
|
|
261
310
|
if (!filters) {
|
|
262
311
|
return;
|
|
263
312
|
}
|
|
264
|
-
if ((previousFilters.current ||
|
|
265
|
-
|
|
266
|
-
|
|
313
|
+
if ((previousFilters.current ||
|
|
314
|
+
(reportMode ? reports : dashboard)[item.id]?.rows?.length) &&
|
|
315
|
+
filterValuesEquivalent(previousFilters.current ?? contextFilters(), filters) &&
|
|
267
316
|
userFilterValuesEquivalent(previousUserFilters.current ?? [], userFilters ?? [])) {
|
|
268
317
|
previousFilters.current = filters;
|
|
269
318
|
return;
|
|
@@ -273,26 +322,33 @@ function DataLoader({ item, children, filters, userFilters, additionalProcessing
|
|
|
273
322
|
fetchReportHelper(additionalProcessing);
|
|
274
323
|
}, [filters, userFilters, item.id]);
|
|
275
324
|
(0, react_1.useEffect)(() => {
|
|
276
|
-
if (dashboard[item.id]?.triggerReload) {
|
|
325
|
+
if ((reportMode ? reports : dashboard)[item.id]?.triggerReload) {
|
|
277
326
|
fetchReportHelper(additionalProcessing);
|
|
278
327
|
}
|
|
279
|
-
}, [dashboard[item.id]]);
|
|
328
|
+
}, [(reportMode ? reports : dashboard)[item.id]]);
|
|
280
329
|
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({
|
|
281
330
|
isLoading: loading,
|
|
282
331
|
error,
|
|
283
332
|
onPageChange,
|
|
284
333
|
onSortChange,
|
|
285
334
|
data: chartReport,
|
|
286
|
-
rowCount: chartReport
|
|
335
|
+
rowCount: chartReport?.rowCount,
|
|
287
336
|
rowCountIsLoading,
|
|
288
337
|
}) }));
|
|
289
338
|
}
|
|
290
339
|
// The same data-loader pattern as above, but with special logic for charts
|
|
291
340
|
// At some point these may be able to get merged into one function.
|
|
292
|
-
const ChartDataLoader = ({ item, children, dateBucket, additionalProcessing, filters, userFilters, }) => {
|
|
341
|
+
const ChartDataLoader = ({ item, children, dateBucket, additionalProcessing, filters, userFilters, reportMode = false, }) => {
|
|
293
342
|
const [dashboard, dispatch] = (0, react_1.useContext)(Context_1.DashboardContext);
|
|
294
343
|
const { dashboardFilters } = (0, react_1.useContext)(Context_1.DashboardFiltersContext);
|
|
295
|
-
const
|
|
344
|
+
const { reports, fetchIndividualReport } = (0, react_1.useContext)(Context_1.ReportsContext);
|
|
345
|
+
const { reportFilters } = (0, react_1.useContext)(Context_1.ReportFiltersContext);
|
|
346
|
+
const contextFilters = () => {
|
|
347
|
+
return reportMode
|
|
348
|
+
? Object.values(reportFilters[item.id] ?? {}).map((f) => f.filter)
|
|
349
|
+
: Object.values(dashboardFilters[item.dashboardName] ?? {}).map((f) => f.filter);
|
|
350
|
+
};
|
|
351
|
+
const [loading, setLoading] = (0, react_1.useState)(!(reportMode ? reports : dashboard)[item.id]);
|
|
296
352
|
const [error, setError] = (0, react_1.useState)(undefined);
|
|
297
353
|
const [client] = (0, react_1.useContext)(Context_1.ClientContext);
|
|
298
354
|
const [schemaData] = (0, react_1.useContext)(Context_1.SchemaDataContext);
|
|
@@ -301,14 +357,24 @@ const ChartDataLoader = ({ item, children, dateBucket, additionalProcessing, fil
|
|
|
301
357
|
const previousDateBucket = (0, react_1.useRef)(undefined);
|
|
302
358
|
const fetchReportAbortController = (0, react_1.useRef)(null);
|
|
303
359
|
const chartReport = (0, react_1.useMemo)(() => {
|
|
304
|
-
const report =
|
|
305
|
-
|
|
306
|
-
|
|
360
|
+
const report = reportMode ? reports[item.id] : dashboard[item.id];
|
|
361
|
+
if (!report) {
|
|
362
|
+
return constructReportFromItem(item);
|
|
363
|
+
}
|
|
364
|
+
return (0, report_1.convertInternalReportToReport)((0, merge_1.mergeComparisonRange)(report), contextFilters());
|
|
365
|
+
}, [
|
|
366
|
+
(reportMode ? reports : dashboard)[item.id],
|
|
367
|
+
reportFilters,
|
|
368
|
+
dashboardFilters,
|
|
369
|
+
]);
|
|
370
|
+
(0, react_1.useEffect)(() => {
|
|
371
|
+
console.log('chartReport memo', chartReport);
|
|
372
|
+
}, [chartReport]);
|
|
307
373
|
const fetchReportHelper = async (useReportTask = true) => {
|
|
308
374
|
if (!client || !filters) {
|
|
309
375
|
return;
|
|
310
376
|
}
|
|
311
|
-
const tempReport = dashboard[item.id];
|
|
377
|
+
const tempReport = (reportMode ? reports : dashboard)[item.id];
|
|
312
378
|
if (tempReport &&
|
|
313
379
|
!(0, Chart_1.didFiltersChange)(tempReport, filters) &&
|
|
314
380
|
userFilterValuesEquivalent(userFilters ?? [], previousUserFilters.current ?? []) &&
|
|
@@ -323,17 +389,34 @@ const ChartDataLoader = ({ item, children, dateBucket, additionalProcessing, fil
|
|
|
323
389
|
fetchReportAbortController.current?.abort();
|
|
324
390
|
fetchReportAbortController.current = new AbortController();
|
|
325
391
|
try {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
392
|
+
if (reportMode) {
|
|
393
|
+
try {
|
|
394
|
+
await fetchIndividualReport(item.id, 'Chart', true, filters, userFilters, {
|
|
395
|
+
...additionalProcessing,
|
|
396
|
+
...(item.pivot ? {} : { page: paginationProcessing_1.DEFAULT_PAGINATION }),
|
|
397
|
+
}, dateBucket, fetchReportAbortController.current);
|
|
398
|
+
setError(undefined);
|
|
399
|
+
}
|
|
400
|
+
catch (e) {
|
|
401
|
+
setError(e.message ?? 'Error fetching report');
|
|
402
|
+
}
|
|
403
|
+
fetchReportAbortController.current = null;
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
const { report, error } = await (0, report_1.fetchReport)(item.id, client, useReportTask, (0, filterProcessing_1.mergeCustomFilters)(filters, userFilters ?? []), {
|
|
407
|
+
...additionalProcessing,
|
|
408
|
+
...(item.pivot ? {} : { page: paginationProcessing_1.DEFAULT_PAGINATION }),
|
|
409
|
+
}, dateBucket, schemaData.customFields, undefined, undefined, fetchReportAbortController.current.signal);
|
|
410
|
+
fetchReportAbortController.current = null;
|
|
411
|
+
dispatch({
|
|
412
|
+
type: 'ADD_DASHBOARD_ITEM',
|
|
413
|
+
id: item.id,
|
|
414
|
+
data: { ...report, triggerReload: false },
|
|
415
|
+
appliedFilters: userFilters,
|
|
416
|
+
loading: false,
|
|
417
|
+
});
|
|
418
|
+
setError(error);
|
|
419
|
+
}
|
|
337
420
|
}
|
|
338
421
|
catch (e) {
|
|
339
422
|
if (e instanceof Error && e.name === 'AbortError') {
|
|
@@ -349,9 +432,9 @@ const ChartDataLoader = ({ item, children, dateBucket, additionalProcessing, fil
|
|
|
349
432
|
if (!filters) {
|
|
350
433
|
return;
|
|
351
434
|
}
|
|
352
|
-
if ((previousFilters.current ||
|
|
353
|
-
|
|
354
|
-
|
|
435
|
+
if ((previousFilters.current ||
|
|
436
|
+
(reportMode ? reports : dashboard)[item.id]?.rows?.length) &&
|
|
437
|
+
filterValuesEquivalent(previousFilters.current ?? contextFilters(), filters) &&
|
|
355
438
|
userFilterValuesEquivalent(previousUserFilters.current ?? [], userFilters ?? []) &&
|
|
356
439
|
previousDateBucket.current === dateBucket) {
|
|
357
440
|
previousFilters.current = filters;
|
|
@@ -361,13 +444,14 @@ const ChartDataLoader = ({ item, children, dateBucket, additionalProcessing, fil
|
|
|
361
444
|
fetchReportHelper();
|
|
362
445
|
}, [filters, userFilters, item.id, dateBucket]);
|
|
363
446
|
(0, react_1.useEffect)(() => {
|
|
364
|
-
const tempReport = dashboard[item.id];
|
|
447
|
+
const tempReport = (reportMode ? reports : dashboard)[item.id];
|
|
365
448
|
if (tempReport && tempReport.triggerReload) {
|
|
366
449
|
fetchReportHelper();
|
|
367
450
|
}
|
|
368
|
-
}, [dashboard[item.id]]);
|
|
451
|
+
}, [(reportMode ? reports : dashboard)[item.id]]);
|
|
452
|
+
console.log('chartReport', chartReport);
|
|
369
453
|
return children({
|
|
370
|
-
isLoading: loading,
|
|
454
|
+
isLoading: !chartReport || loading,
|
|
371
455
|
data: chartReport,
|
|
372
456
|
error,
|
|
373
457
|
dateBucket,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDashboard.d.ts","sourceRoot":"","sources":["../../../src/hooks/useDashboard.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"useDashboard.d.ts","sourceRoot":"","sources":["../../../src/hooks/useDashboard.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEpE,OAAO,EACL,eAAe,EAEf,cAAc,EACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,eAAO,MAAM,UAAU;uCAYR,CAAC,MAAM,EAAE,mBAAmB,KAAK,OAAO;CAYtD,CAAC;AAEF,eAAO,MAAM,YAAY,kBACR,MAAM,GAAG,IAAI,kBACZ,cAAc,EAAE;;;;2CA8Gc,MAAM;qCApF1B,MAAM,4CAEf;QACb,MAAM,EAAE,WAAW,GAAG;YAAE,EAAE,EAAE,MAAM,CAAA;SAAE,CAAC;QACrC,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAAC;KAC7B,oBACiB;QAChB,OAAO,EAAE,eAAe,EAAE,CAAC;QAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC5B;CA8FJ,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;sDAuBrB;QACD,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,eAAe,EAAE,CAAC;QAC3B,UAAU,CAAC,EAAE,eAAe,CAAC;KAC9B;4BA+CO,MAAM,oDAMT;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,eAAe,EAAE,CAAC;QAC3B,UAAU,CAAC,EAAE,eAAe,CAAC;QAC7B,aAAa,CAAC,EAAE,cAAc,EAAE,CAAC;KAClC;4BA2FkC,MAAM;CA8B5C,CAAC"}
|
|
@@ -5,6 +5,7 @@ const react_1 = require("react");
|
|
|
5
5
|
const Context_1 = require("../Context");
|
|
6
6
|
const dateRangePickerUtils_1 = require("../DateRangePicker/dateRangePickerUtils");
|
|
7
7
|
const Filter_1 = require("../models/Filter");
|
|
8
|
+
const filterProcessing_1 = require("../utils/filterProcessing");
|
|
8
9
|
const useReports = () => {
|
|
9
10
|
const [dashboard, dispatch] = (0, react_1.useContext)(Context_1.DashboardContext);
|
|
10
11
|
const reloadReport = (id) => {
|
|
@@ -73,56 +74,8 @@ const useDashboard = (dashboardName, customFilters) => {
|
|
|
73
74
|
filter.filter.options)) {
|
|
74
75
|
return;
|
|
75
76
|
}
|
|
76
|
-
const getComparisonRange = (dateFilter, rangeType) => {
|
|
77
|
-
const range = dateFilter?.presetRanges?.find((range) => range.value === dateFilter?.primaryRange?.value) ?? dateRangePickerUtils_1.PRIMARY_RANGE[dateFilter?.primaryRange?.value ?? 'LAST_30_DAYS'];
|
|
78
|
-
return (dateFilter?.comparisonRange?.[rangeType] ??
|
|
79
|
-
dateRangePickerUtils_1.COMPARISON_RANGE[dateFilter?.defaultComparisonRange ??
|
|
80
|
-
'NO_COMPARISON']({
|
|
81
|
-
startDate: !range.startDate || range.startDate instanceof Date
|
|
82
|
-
? range.startDate
|
|
83
|
-
: new Date(range.startDate), // when range.startDate is a string
|
|
84
|
-
endDate: !range.endDate || range.endDate instanceof Date
|
|
85
|
-
? range.endDate
|
|
86
|
-
: new Date(range.endDate), // when range.endDate is a string
|
|
87
|
-
})?.[rangeType]);
|
|
88
|
-
};
|
|
89
|
-
const comparisonRangeStart = getComparisonRange(dashboard?.dateFilter, 'startDate');
|
|
90
|
-
const comparisonRangeEnd = getComparisonRange(dashboard?.dateFilter, 'endDate');
|
|
91
|
-
const range = dashboard?.dateFilter?.presetRanges?.find((range) => range.value === dashboard?.dateFilter?.primaryRange?.value) ??
|
|
92
|
-
dateRangePickerUtils_1.PRIMARY_RANGE[dashboard?.dateFilter?.primaryRange?.value ?? 'LAST_30_DAYS'] ??
|
|
93
|
-
dateRangePickerUtils_1.PRIMARY_RANGE['LAST_30_DAYS'];
|
|
94
77
|
const dateFilter = dashboard?.dateFilter
|
|
95
|
-
? {
|
|
96
|
-
...dashboard?.dateFilter,
|
|
97
|
-
startDate: !range.startDate || range.startDate instanceof Date
|
|
98
|
-
? range.startDate
|
|
99
|
-
: new Date(range.startDate), // when range.startDate is a string
|
|
100
|
-
endDate: !range.endDate || range.endDate instanceof Date
|
|
101
|
-
? range.endDate
|
|
102
|
-
: new Date(range.endDate), // when range.endDate is a string
|
|
103
|
-
filterType: Filter_1.DashboardFilterType.Date,
|
|
104
|
-
dateField: [
|
|
105
|
-
...new Map(Object.values(dashboard?.sections ?? {})
|
|
106
|
-
.flat()
|
|
107
|
-
.map((report) => {
|
|
108
|
-
const key = JSON.stringify(report.dateField);
|
|
109
|
-
return [key, report.dateField];
|
|
110
|
-
})).values(),
|
|
111
|
-
],
|
|
112
|
-
preset: dashboard?.dateFilter.primaryRange,
|
|
113
|
-
dashboardName: overrideDashboardName ?? dashboardName,
|
|
114
|
-
comparisonRange: dashboard?.dateFilter.comparison &&
|
|
115
|
-
comparisonRangeStart &&
|
|
116
|
-
comparisonRangeEnd
|
|
117
|
-
? {
|
|
118
|
-
startDate: comparisonRangeStart,
|
|
119
|
-
endDate: comparisonRangeEnd,
|
|
120
|
-
value: dashboard?.dateFilter.comparisonRange?.value ??
|
|
121
|
-
dashboard.dateFilter?.defaultComparisonRange ??
|
|
122
|
-
'NO_COMPARISON',
|
|
123
|
-
}
|
|
124
|
-
: undefined,
|
|
125
|
-
}
|
|
78
|
+
? (0, filterProcessing_1.createDefaultDateFilter)(dashboard?.dateFilter, Object.values(dashboard?.sections ?? {}).flat(), dashboardName)
|
|
126
79
|
: undefined;
|
|
127
80
|
// Append dateFilter to the filters unless it's undefined
|
|
128
81
|
loadFiltersForDashboard(dashboardName, [...(dateFilter ? [dateFilter] : []), ...(dashboard?.filters ?? [])], undefined, customFilters);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQuill.d.ts","sourceRoot":"","sources":["../../../src/hooks/useQuill.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useQuill.d.ts","sourceRoot":"","sources":["../../../src/hooks/useQuill.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,WAAW,EAIZ,MAAM,yBAAyB,CAAC;AAIjC,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,QAAQ,cACR,MAAM,eACJ;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,KAC3D;IACD,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD,SAAS,EACL,CAAC,CAAC,QAAQ,EAAE,WAAW,KAAK,MAAM,GAAG,SAAS,CAAC,GAC/C,CAAC,MAAM,SAAS,CAAC,CAAC;CA8MvB,CAAC"}
|
|
@@ -9,49 +9,55 @@ const tableProcessing_1 = require("../utils/tableProcessing");
|
|
|
9
9
|
const dataProcessing_1 = require("../utils/dataProcessing");
|
|
10
10
|
const merge_1 = require("../utils/merge");
|
|
11
11
|
const useQuill = (reportId, pagination) => {
|
|
12
|
-
const
|
|
12
|
+
const { reports, reportsDispatch, fetchIndividualReport } = (0, react_1.useContext)(Context_1.ReportsContext);
|
|
13
|
+
const [dashboard] = (0, react_1.useContext)(Context_1.DashboardContext);
|
|
13
14
|
const { dashboardFilters } = (0, react_1.useContext)(Context_1.DashboardFiltersContext);
|
|
15
|
+
const { reportFilters, reportFiltersDispatch } = (0, react_1.useContext)(Context_1.ReportFiltersContext);
|
|
14
16
|
const specificDashboardFilters = (0, react_1.useMemo)(() => {
|
|
15
17
|
if (!reportId)
|
|
16
18
|
return [];
|
|
17
|
-
const dashboardName =
|
|
19
|
+
const dashboardName = reports[reportId]?.dashboardName;
|
|
18
20
|
if (!dashboardName)
|
|
19
21
|
return [];
|
|
20
22
|
return Object.values(dashboardFilters[dashboardName] ?? {}).map((f) => f.filter);
|
|
21
23
|
}, [dashboardFilters, reportId, dashboard]);
|
|
24
|
+
const specificReportFilters = (0, react_1.useMemo)(() => {
|
|
25
|
+
if (!reportId)
|
|
26
|
+
return [];
|
|
27
|
+
return Object.values(reportFilters[reportId] ?? []).map((f) => f.filter);
|
|
28
|
+
}, [reportFilters, reportId]);
|
|
22
29
|
const [schemaData] = (0, react_1.useContext)(Context_1.SchemaDataContext);
|
|
23
30
|
const [client] = (0, react_1.useContext)(Context_1.ClientContext);
|
|
24
|
-
const [data, setData] = (0, react_1.useState)(null);
|
|
25
31
|
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
26
32
|
const [error, setError] = (0, react_1.useState)(undefined);
|
|
27
33
|
const [previousPage, setPreviousPage] = (0, react_1.useState)(0);
|
|
28
34
|
const processedReport = (0, react_1.useMemo)(() => {
|
|
29
|
-
return reportId && dashboard[reportId]
|
|
30
|
-
? (0, report_1.convertInternalReportToReport)((0, merge_1.mergeComparisonRange)(dashboard[reportId]))
|
|
35
|
+
return reportId && (reports[reportId] || dashboard[reportId])
|
|
36
|
+
? (0, report_1.convertInternalReportToReport)((0, merge_1.mergeComparisonRange)(reports[reportId] || dashboard[reportId]), specificReportFilters)
|
|
31
37
|
: undefined;
|
|
32
|
-
}, [
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
}, [
|
|
39
|
+
reportId,
|
|
40
|
+
reportId && (reports[reportId] || dashboard[reportId]),
|
|
41
|
+
specificReportFilters,
|
|
42
|
+
]);
|
|
37
43
|
const [additionalProcessing, setAdditionProcessing] = (0, react_1.useState)(pagination
|
|
38
44
|
? {
|
|
39
45
|
page: pagination,
|
|
40
46
|
}
|
|
41
47
|
: undefined);
|
|
42
48
|
function calculateFunction(calcType, options) {
|
|
43
|
-
if (!
|
|
49
|
+
if (!processedReport || !processedReport.rows) {
|
|
44
50
|
return undefined;
|
|
45
51
|
}
|
|
46
52
|
switch (calcType) {
|
|
47
53
|
case 'SIMPLE_PERCENTAGE_CHANGE':
|
|
48
|
-
return (0, dataProcessing_1.getSimplePercentageChange)(
|
|
54
|
+
return (0, dataProcessing_1.getSimplePercentageChange)(processedReport);
|
|
49
55
|
case 'POINT_TO_POINT_PERCENTAGE_CHANGE':
|
|
50
|
-
return (0, dataProcessing_1.getPointToPointPercentageChange)(
|
|
56
|
+
return (0, dataProcessing_1.getPointToPointPercentageChange)(processedReport);
|
|
51
57
|
case 'SUM':
|
|
52
|
-
return (0, dataProcessing_1.getSumOfFields)(
|
|
58
|
+
return (0, dataProcessing_1.getSumOfFields)(processedReport, options?.comparison ? true : false);
|
|
53
59
|
default:
|
|
54
|
-
return (0, dataProcessing_1.getSimplePercentageChange)(
|
|
60
|
+
return (0, dataProcessing_1.getSimplePercentageChange)(processedReport);
|
|
55
61
|
}
|
|
56
62
|
}
|
|
57
63
|
const fetchMore = (page) => {
|
|
@@ -86,19 +92,26 @@ const useQuill = (reportId, pagination) => {
|
|
|
86
92
|
if (!client) {
|
|
87
93
|
return;
|
|
88
94
|
}
|
|
89
|
-
if (!loading && reportId &&
|
|
95
|
+
if (!loading && reportId && processedReport) {
|
|
90
96
|
setLoading(true);
|
|
91
97
|
try {
|
|
92
98
|
const updatedProcessing = { ...additionalProcessing, ...processing };
|
|
93
|
-
const paginatedRows = await (0, tableProcessing_1.fetchResultsByReport)(reportId, client, updatedProcessing,
|
|
99
|
+
const paginatedRows = await (0, tableProcessing_1.fetchResultsByReport)(reportId, client, updatedProcessing, reportFilters[reportId], schemaData.customFields);
|
|
94
100
|
if (paginatedRows.error) {
|
|
95
101
|
throw new Error('Error fetching chart');
|
|
96
102
|
}
|
|
97
|
-
let tempRows = [...
|
|
103
|
+
let tempRows = [...processedReport.rows, ...paginatedRows.rows];
|
|
98
104
|
if (resetRows) {
|
|
99
105
|
tempRows = paginatedRows.rows;
|
|
100
106
|
}
|
|
101
|
-
|
|
107
|
+
reportsDispatch({
|
|
108
|
+
type: 'UPDATE_REPORT',
|
|
109
|
+
id: reportId,
|
|
110
|
+
data: {
|
|
111
|
+
...reports[reportId],
|
|
112
|
+
rows: tempRows,
|
|
113
|
+
},
|
|
114
|
+
});
|
|
102
115
|
setTimeout(() => {
|
|
103
116
|
setLoading(false);
|
|
104
117
|
}, 200);
|
|
@@ -109,47 +122,58 @@ const useQuill = (reportId, pagination) => {
|
|
|
109
122
|
}
|
|
110
123
|
}
|
|
111
124
|
};
|
|
112
|
-
const fetchReportHelper = async (curReportId,
|
|
125
|
+
const fetchReportHelper = async (curReportId, additionalProcessing) => {
|
|
113
126
|
if (!client) {
|
|
114
127
|
return;
|
|
115
128
|
}
|
|
116
|
-
if
|
|
117
|
-
|
|
129
|
+
//FIXME: these two early returns don't check if the pagination lines up
|
|
130
|
+
if (reports[curReportId]) {
|
|
131
|
+
setLoading(false);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (dashboard[curReportId]) {
|
|
135
|
+
reportsDispatch({
|
|
136
|
+
type: 'ADD_REPORT',
|
|
137
|
+
id: curReportId,
|
|
138
|
+
data: reports[curReportId],
|
|
139
|
+
});
|
|
118
140
|
setLoading(false);
|
|
119
141
|
return;
|
|
120
142
|
}
|
|
143
|
+
if (specificDashboardFilters.length && !specificReportFilters.length) {
|
|
144
|
+
reportFiltersDispatch({
|
|
145
|
+
type: 'ADD_REPORT_FILTERS',
|
|
146
|
+
id: curReportId,
|
|
147
|
+
data: Object.values(dashboardFilters[curReportId] ?? []),
|
|
148
|
+
});
|
|
149
|
+
}
|
|
121
150
|
setLoading(true);
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
setError(error);
|
|
134
|
-
setLoading(false);
|
|
151
|
+
try {
|
|
152
|
+
fetchIndividualReport(curReportId, 'useQuill', true, specificReportFilters, [], additionalProcessing).then(() => {
|
|
153
|
+
console.log('fetched report', reports[curReportId]);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
setError(error.message ?? 'Error fetching report');
|
|
158
|
+
}
|
|
159
|
+
finally {
|
|
160
|
+
setLoading(false);
|
|
161
|
+
}
|
|
135
162
|
};
|
|
136
163
|
(0, react_1.useEffect)(() => {
|
|
137
164
|
if (reportId) {
|
|
138
|
-
fetchReportHelper(reportId,
|
|
165
|
+
fetchReportHelper(reportId, {
|
|
139
166
|
page: pagination,
|
|
140
167
|
});
|
|
141
168
|
}
|
|
142
|
-
}, [reportId
|
|
143
|
-
(0, react_1.useEffect)(() => {
|
|
144
|
-
setCalculate(() => calculateFunction);
|
|
145
|
-
}, [data]);
|
|
169
|
+
}, [reportId]);
|
|
146
170
|
return {
|
|
147
|
-
data: processedReport ??
|
|
171
|
+
data: processedReport ?? null,
|
|
148
172
|
loading,
|
|
149
173
|
error,
|
|
150
174
|
fetchMore,
|
|
151
175
|
setSort,
|
|
152
|
-
calculate,
|
|
176
|
+
calculate: calculateFunction,
|
|
153
177
|
};
|
|
154
178
|
};
|
|
155
179
|
exports.useQuill = useQuill;
|