@quillsql/react 2.13.18 → 2.13.20
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 +3 -3
- package/dist/cjs/Chart.d.ts.map +1 -1
- package/dist/cjs/Chart.js +83 -187
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +3 -5
- package/dist/cjs/Context.d.ts +24 -3
- package/dist/cjs/Context.d.ts.map +1 -1
- package/dist/cjs/Context.js +316 -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 +136 -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 +64 -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 +79 -51
- package/dist/esm/Chart.d.ts +3 -3
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +88 -196
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +3 -5
- package/dist/esm/Context.d.ts +24 -3
- package/dist/esm/Context.d.ts.map +1 -1
- package/dist/esm/Context.js +315 -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 +137 -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 +66 -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 +77 -51
- package/package.json +1 -1
|
@@ -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,CAuTd;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,OA2JP,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,26 @@ 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, filtersApplied: userFilters },
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
dispatch({
|
|
235
|
+
type: 'UPDATE_DASHBOARD_ITEM',
|
|
236
|
+
id: item.id,
|
|
237
|
+
data: { rows: tempRows },
|
|
238
|
+
});
|
|
239
|
+
}
|
|
206
240
|
setAdditionalProcessing(updatedProcessing);
|
|
207
241
|
}
|
|
208
242
|
catch (e) {
|
|
@@ -221,7 +255,7 @@ function DataLoader({ item, children, filters, userFilters, additionalProcessing
|
|
|
221
255
|
}
|
|
222
256
|
const fetchRowsRequestId = rowsRequestId.current + 1;
|
|
223
257
|
rowsRequestId.current = fetchRowsRequestId;
|
|
224
|
-
const tempReport = dashboard[item.id];
|
|
258
|
+
const tempReport = (reportMode ? reports : dashboard)[item.id];
|
|
225
259
|
if (tempReport &&
|
|
226
260
|
!(0, Chart_1.didFiltersChange)(tempReport, filters) &&
|
|
227
261
|
userFilterValuesEquivalent(userFilters ?? [], previousUserFilters.current ?? []) &&
|
|
@@ -234,16 +268,30 @@ function DataLoader({ item, children, filters, userFilters, additionalProcessing
|
|
|
234
268
|
rowsAbortController.current?.abort();
|
|
235
269
|
rowsAbortController.current = new AbortController();
|
|
236
270
|
try {
|
|
237
|
-
|
|
238
|
-
|
|
271
|
+
if (reportMode) {
|
|
272
|
+
try {
|
|
273
|
+
await fetchIndividualReport(item.id, 'Chart', true, filters, userFilters, processing, undefined, rowsAbortController.current || undefined);
|
|
274
|
+
setError(undefined);
|
|
275
|
+
}
|
|
276
|
+
catch (e) {
|
|
277
|
+
setError(e.message ?? 'Error fetching report');
|
|
278
|
+
}
|
|
279
|
+
rowsAbortController.current = null;
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
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);
|
|
283
|
+
rowsAbortController.current = null;
|
|
284
|
+
dispatch({
|
|
285
|
+
type: 'ADD_DASHBOARD_ITEM',
|
|
286
|
+
id: item.id,
|
|
287
|
+
data: { ...fetchedReport, triggerReload: false, rowCount: 0 }, // rowCount 0 indicates it's still loading if row length is nonzero
|
|
288
|
+
appliedFilters: userFilters,
|
|
289
|
+
loading: false,
|
|
290
|
+
});
|
|
291
|
+
setError(error);
|
|
292
|
+
}
|
|
239
293
|
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
294
|
setAdditionalProcessing(processing);
|
|
246
|
-
setError(error);
|
|
247
295
|
}
|
|
248
296
|
catch (e) {
|
|
249
297
|
if (e instanceof Error && e.name === 'AbortError') {
|
|
@@ -261,9 +309,9 @@ function DataLoader({ item, children, filters, userFilters, additionalProcessing
|
|
|
261
309
|
if (!filters) {
|
|
262
310
|
return;
|
|
263
311
|
}
|
|
264
|
-
if ((previousFilters.current ||
|
|
265
|
-
|
|
266
|
-
|
|
312
|
+
if ((previousFilters.current ||
|
|
313
|
+
(reportMode ? reports : dashboard)[item.id]?.rows?.length) &&
|
|
314
|
+
filterValuesEquivalent(previousFilters.current ?? contextFilters(), filters) &&
|
|
267
315
|
userFilterValuesEquivalent(previousUserFilters.current ?? [], userFilters ?? [])) {
|
|
268
316
|
previousFilters.current = filters;
|
|
269
317
|
return;
|
|
@@ -273,26 +321,33 @@ function DataLoader({ item, children, filters, userFilters, additionalProcessing
|
|
|
273
321
|
fetchReportHelper(additionalProcessing);
|
|
274
322
|
}, [filters, userFilters, item.id]);
|
|
275
323
|
(0, react_1.useEffect)(() => {
|
|
276
|
-
if (dashboard[item.id]?.triggerReload) {
|
|
324
|
+
if ((reportMode ? reports : dashboard)[item.id]?.triggerReload) {
|
|
277
325
|
fetchReportHelper(additionalProcessing);
|
|
278
326
|
}
|
|
279
|
-
}, [dashboard[item.id]]);
|
|
327
|
+
}, [(reportMode ? reports : dashboard)[item.id]]);
|
|
280
328
|
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({
|
|
281
329
|
isLoading: loading,
|
|
282
330
|
error,
|
|
283
331
|
onPageChange,
|
|
284
332
|
onSortChange,
|
|
285
333
|
data: chartReport,
|
|
286
|
-
rowCount: chartReport
|
|
334
|
+
rowCount: chartReport?.rowCount,
|
|
287
335
|
rowCountIsLoading,
|
|
288
336
|
}) }));
|
|
289
337
|
}
|
|
290
338
|
// The same data-loader pattern as above, but with special logic for charts
|
|
291
339
|
// At some point these may be able to get merged into one function.
|
|
292
|
-
const ChartDataLoader = ({ item, children, dateBucket, additionalProcessing, filters, userFilters, }) => {
|
|
340
|
+
const ChartDataLoader = ({ item, children, dateBucket, additionalProcessing, filters, userFilters, reportMode = false, }) => {
|
|
293
341
|
const [dashboard, dispatch] = (0, react_1.useContext)(Context_1.DashboardContext);
|
|
294
342
|
const { dashboardFilters } = (0, react_1.useContext)(Context_1.DashboardFiltersContext);
|
|
295
|
-
const
|
|
343
|
+
const { reports, fetchIndividualReport } = (0, react_1.useContext)(Context_1.ReportsContext);
|
|
344
|
+
const { reportFilters } = (0, react_1.useContext)(Context_1.ReportFiltersContext);
|
|
345
|
+
const contextFilters = () => {
|
|
346
|
+
return reportMode
|
|
347
|
+
? Object.values(reportFilters[item.id] ?? {}).map((f) => f.filter)
|
|
348
|
+
: Object.values(dashboardFilters[item.dashboardName] ?? {}).map((f) => f.filter);
|
|
349
|
+
};
|
|
350
|
+
const [loading, setLoading] = (0, react_1.useState)(!(reportMode ? reports : dashboard)[item.id]);
|
|
296
351
|
const [error, setError] = (0, react_1.useState)(undefined);
|
|
297
352
|
const [client] = (0, react_1.useContext)(Context_1.ClientContext);
|
|
298
353
|
const [schemaData] = (0, react_1.useContext)(Context_1.SchemaDataContext);
|
|
@@ -301,14 +356,21 @@ const ChartDataLoader = ({ item, children, dateBucket, additionalProcessing, fil
|
|
|
301
356
|
const previousDateBucket = (0, react_1.useRef)(undefined);
|
|
302
357
|
const fetchReportAbortController = (0, react_1.useRef)(null);
|
|
303
358
|
const chartReport = (0, react_1.useMemo)(() => {
|
|
304
|
-
const report =
|
|
305
|
-
|
|
306
|
-
|
|
359
|
+
const report = reportMode ? reports[item.id] : dashboard[item.id];
|
|
360
|
+
if (!report) {
|
|
361
|
+
return constructReportFromItem(item);
|
|
362
|
+
}
|
|
363
|
+
return (0, report_1.convertInternalReportToReport)((0, merge_1.mergeComparisonRange)(report), contextFilters());
|
|
364
|
+
}, [
|
|
365
|
+
(reportMode ? reports : dashboard)[item.id],
|
|
366
|
+
reportFilters,
|
|
367
|
+
dashboardFilters,
|
|
368
|
+
]);
|
|
307
369
|
const fetchReportHelper = async (useReportTask = true) => {
|
|
308
370
|
if (!client || !filters) {
|
|
309
371
|
return;
|
|
310
372
|
}
|
|
311
|
-
const tempReport = dashboard[item.id];
|
|
373
|
+
const tempReport = (reportMode ? reports : dashboard)[item.id];
|
|
312
374
|
if (tempReport &&
|
|
313
375
|
!(0, Chart_1.didFiltersChange)(tempReport, filters) &&
|
|
314
376
|
userFilterValuesEquivalent(userFilters ?? [], previousUserFilters.current ?? []) &&
|
|
@@ -323,17 +385,34 @@ const ChartDataLoader = ({ item, children, dateBucket, additionalProcessing, fil
|
|
|
323
385
|
fetchReportAbortController.current?.abort();
|
|
324
386
|
fetchReportAbortController.current = new AbortController();
|
|
325
387
|
try {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
388
|
+
if (reportMode) {
|
|
389
|
+
try {
|
|
390
|
+
await fetchIndividualReport(item.id, 'Chart', true, filters, userFilters, {
|
|
391
|
+
...additionalProcessing,
|
|
392
|
+
...(item.pivot ? {} : { page: paginationProcessing_1.DEFAULT_PAGINATION }),
|
|
393
|
+
}, dateBucket, fetchReportAbortController.current);
|
|
394
|
+
setError(undefined);
|
|
395
|
+
}
|
|
396
|
+
catch (e) {
|
|
397
|
+
setError(e.message ?? 'Error fetching report');
|
|
398
|
+
}
|
|
399
|
+
fetchReportAbortController.current = null;
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
const { report, error } = await (0, report_1.fetchReport)(item.id, client, useReportTask, (0, filterProcessing_1.mergeCustomFilters)(filters, userFilters ?? []), {
|
|
403
|
+
...additionalProcessing,
|
|
404
|
+
...(item.pivot ? {} : { page: paginationProcessing_1.DEFAULT_PAGINATION }),
|
|
405
|
+
}, dateBucket, schemaData.customFields, undefined, undefined, fetchReportAbortController.current.signal);
|
|
406
|
+
fetchReportAbortController.current = null;
|
|
407
|
+
dispatch({
|
|
408
|
+
type: 'ADD_DASHBOARD_ITEM',
|
|
409
|
+
id: item.id,
|
|
410
|
+
data: { ...report, triggerReload: false },
|
|
411
|
+
appliedFilters: userFilters,
|
|
412
|
+
loading: false,
|
|
413
|
+
});
|
|
414
|
+
setError(error);
|
|
415
|
+
}
|
|
337
416
|
}
|
|
338
417
|
catch (e) {
|
|
339
418
|
if (e instanceof Error && e.name === 'AbortError') {
|
|
@@ -349,9 +428,9 @@ const ChartDataLoader = ({ item, children, dateBucket, additionalProcessing, fil
|
|
|
349
428
|
if (!filters) {
|
|
350
429
|
return;
|
|
351
430
|
}
|
|
352
|
-
if ((previousFilters.current ||
|
|
353
|
-
|
|
354
|
-
|
|
431
|
+
if ((previousFilters.current ||
|
|
432
|
+
(reportMode ? reports : dashboard)[item.id]?.rows?.length) &&
|
|
433
|
+
filterValuesEquivalent(previousFilters.current ?? contextFilters(), filters) &&
|
|
355
434
|
userFilterValuesEquivalent(previousUserFilters.current ?? [], userFilters ?? []) &&
|
|
356
435
|
previousDateBucket.current === dateBucket) {
|
|
357
436
|
previousFilters.current = filters;
|
|
@@ -361,13 +440,13 @@ const ChartDataLoader = ({ item, children, dateBucket, additionalProcessing, fil
|
|
|
361
440
|
fetchReportHelper();
|
|
362
441
|
}, [filters, userFilters, item.id, dateBucket]);
|
|
363
442
|
(0, react_1.useEffect)(() => {
|
|
364
|
-
const tempReport = dashboard[item.id];
|
|
443
|
+
const tempReport = (reportMode ? reports : dashboard)[item.id];
|
|
365
444
|
if (tempReport && tempReport.triggerReload) {
|
|
366
445
|
fetchReportHelper();
|
|
367
446
|
}
|
|
368
|
-
}, [dashboard[item.id]]);
|
|
447
|
+
}, [(reportMode ? reports : dashboard)[item.id]]);
|
|
369
448
|
return children({
|
|
370
|
-
isLoading: loading,
|
|
449
|
+
isLoading: !chartReport || loading,
|
|
371
450
|
data: chartReport,
|
|
372
451
|
error,
|
|
373
452
|
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;CA4MvB,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,56 @@ 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
|
-
setData((0, report_1.convertInternalReportToReport)((0, merge_1.mergeComparisonRange)(report)));
|
|
133
|
-
setError(error);
|
|
134
|
-
setLoading(false);
|
|
151
|
+
try {
|
|
152
|
+
await fetchIndividualReport(curReportId, 'useQuill', true, specificReportFilters, [], additionalProcessing);
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
setError(error.message ?? 'Error fetching report');
|
|
156
|
+
}
|
|
157
|
+
finally {
|
|
158
|
+
setLoading(false);
|
|
159
|
+
}
|
|
135
160
|
};
|
|
136
161
|
(0, react_1.useEffect)(() => {
|
|
137
162
|
if (reportId) {
|
|
138
|
-
fetchReportHelper(reportId,
|
|
163
|
+
fetchReportHelper(reportId, {
|
|
139
164
|
page: pagination,
|
|
140
165
|
});
|
|
141
166
|
}
|
|
142
|
-
}, [reportId
|
|
143
|
-
(0, react_1.useEffect)(() => {
|
|
144
|
-
setCalculate(() => calculateFunction);
|
|
145
|
-
}, [data]);
|
|
167
|
+
}, [reportId]);
|
|
146
168
|
return {
|
|
147
|
-
data: processedReport ??
|
|
169
|
+
data: processedReport ?? null,
|
|
148
170
|
loading,
|
|
149
171
|
error,
|
|
150
172
|
fetchMore,
|
|
151
173
|
setSort,
|
|
152
|
-
calculate,
|
|
174
|
+
calculate: calculateFunction,
|
|
153
175
|
};
|
|
154
176
|
};
|
|
155
177
|
exports.useQuill = useQuill;
|
|
@@ -110,7 +110,7 @@ export declare function getDateString(value: string, dateRange?: {
|
|
|
110
110
|
start: Date;
|
|
111
111
|
end: Date;
|
|
112
112
|
}, dateBucket?: string): string;
|
|
113
|
-
export declare function isDateField(fieldType: string): fieldType is "MMM_dd" | "MMM_yyyy" | "MMM_dd_yyyy" | "hh_ap_pm" | "MMM_dd_hh:mm_ap_pm" | "
|
|
113
|
+
export declare function isDateField(fieldType: string): fieldType is "date" | "MMM_dd" | "MMM_yyyy" | "MMM_dd_yyyy" | "hh_ap_pm" | "MMM_dd_hh:mm_ap_pm" | "datetime" | "timestamp" | "timestamptz";
|
|
114
114
|
export declare function generatePivotTable({ pivot, rowLimit, dateBucket, report, client, uniqueValues, }: {
|
|
115
115
|
pivot: Pivot;
|
|
116
116
|
rowLimit?: number;
|