@quillsql/react 2.13.19 → 2.13.21
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 +1 -1
- package/dist/cjs/Chart.d.ts.map +1 -1
- package/dist/cjs/Chart.js +209 -43
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +0 -2
- package/dist/cjs/Context.d.ts.map +1 -1
- package/dist/cjs/Context.js +13 -15
- package/dist/cjs/components/Dashboard/DashboardFilter.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DashboardFilter.js +19 -1
- package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.js +5 -11
- package/dist/cjs/hooks/useExport.d.ts.map +1 -1
- package/dist/cjs/hooks/useExport.js +101 -70
- package/dist/cjs/hooks/useQuill.d.ts.map +1 -1
- package/dist/cjs/hooks/useQuill.js +21 -23
- package/dist/cjs/utils/filterProcessing.d.ts +2 -1
- package/dist/cjs/utils/filterProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/filterProcessing.js +16 -0
- package/dist/cjs/utils/queryConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/queryConstructor.js +2 -1
- package/dist/cjs/utils/report.d.ts +1 -1
- package/dist/cjs/utils/report.d.ts.map +1 -1
- package/dist/cjs/utils/report.js +6 -6
- package/dist/esm/Chart.d.ts +1 -1
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +214 -61
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +0 -2
- package/dist/esm/Context.d.ts.map +1 -1
- package/dist/esm/Context.js +13 -15
- package/dist/esm/components/Dashboard/DashboardFilter.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DashboardFilter.js +20 -2
- package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.js +5 -11
- package/dist/esm/hooks/useExport.d.ts.map +1 -1
- package/dist/esm/hooks/useExport.js +102 -71
- package/dist/esm/hooks/useQuill.d.ts.map +1 -1
- package/dist/esm/hooks/useQuill.js +21 -23
- package/dist/esm/utils/filterProcessing.d.ts +2 -1
- package/dist/esm/utils/filterProcessing.d.ts.map +1 -1
- package/dist/esm/utils/filterProcessing.js +15 -0
- package/dist/esm/utils/queryConstructor.d.ts.map +1 -1
- package/dist/esm/utils/queryConstructor.js +2 -1
- package/dist/esm/utils/report.d.ts +1 -1
- package/dist/esm/utils/report.d.ts.map +1 -1
- package/dist/esm/utils/report.js +6 -6
- package/package.json +4 -4
|
@@ -7,7 +7,6 @@ import { fetchResultsByReport, } from '../../utils/tableProcessing';
|
|
|
7
7
|
import { didFiltersChange } from '../../Chart';
|
|
8
8
|
import { mergeComparisonRange } from '../../utils/merge';
|
|
9
9
|
import equal from 'fast-deep-equal';
|
|
10
|
-
import { mergeCustomFilters } from '../../utils/filterProcessing';
|
|
11
10
|
const constructReportFromItem = (item) => {
|
|
12
11
|
return {
|
|
13
12
|
...EMPTY_INTERNAL_REPORT,
|
|
@@ -136,7 +135,7 @@ export default function DataLoader({ item, children, filters, userFilters, addit
|
|
|
136
135
|
rowCountAbortController.current?.abort();
|
|
137
136
|
rowCountAbortController.current = new AbortController();
|
|
138
137
|
try {
|
|
139
|
-
const rowCount = await fetchReportRowCount(item.id, client, true,
|
|
138
|
+
const rowCount = await fetchReportRowCount(item.id, client, true, filters.concat(userFilters ?? []), processing, schemaData.customFields, rowCountAbortController.current.signal);
|
|
140
139
|
rowCountAbortController.current = null;
|
|
141
140
|
if (rowCount) {
|
|
142
141
|
if (reportMode) {
|
|
@@ -204,7 +203,7 @@ export default function DataLoader({ item, children, filters, userFilters, addit
|
|
|
204
203
|
updateTableRowsAbortController.current?.abort();
|
|
205
204
|
updateTableRowsAbortController.current = new AbortController();
|
|
206
205
|
const updatedProcessing = { ...additionalProcessing, ...processing };
|
|
207
|
-
const paginatedRows = await fetchResultsByReport(item.id, client, updatedProcessing,
|
|
206
|
+
const paginatedRows = await fetchResultsByReport(item.id, client, updatedProcessing, filters.concat(userFilters ?? []), schemaData.customFields, true, undefined, updateTableRowsAbortController.current.signal);
|
|
208
207
|
updateTableRowsAbortController.current = null;
|
|
209
208
|
if (paginatedRows.error) {
|
|
210
209
|
throw new Error('Error fetching chart');
|
|
@@ -220,8 +219,7 @@ export default function DataLoader({ item, children, filters, userFilters, addit
|
|
|
220
219
|
reportsDispatch({
|
|
221
220
|
type: 'UPDATE_REPORT',
|
|
222
221
|
id: item.id,
|
|
223
|
-
data: { rows: tempRows },
|
|
224
|
-
filtersApplied: userFilters,
|
|
222
|
+
data: { rows: tempRows, filtersApplied: userFilters },
|
|
225
223
|
});
|
|
226
224
|
}
|
|
227
225
|
else {
|
|
@@ -273,7 +271,7 @@ export default function DataLoader({ item, children, filters, userFilters, addit
|
|
|
273
271
|
rowsAbortController.current = null;
|
|
274
272
|
}
|
|
275
273
|
else {
|
|
276
|
-
const { report: fetchedReport, error } = await fetchReport(item.id, client, true,
|
|
274
|
+
const { report: fetchedReport, error } = await fetchReport(item.id, client, true, filters.concat(userFilters ?? []), processing, undefined, schemaData.customFields, true, false, rowsAbortController.current.signal);
|
|
277
275
|
rowsAbortController.current = null;
|
|
278
276
|
dispatch({
|
|
279
277
|
type: 'ADD_DASHBOARD_ITEM',
|
|
@@ -360,9 +358,6 @@ export const ChartDataLoader = ({ item, children, dateBucket, additionalProcessi
|
|
|
360
358
|
reportFilters,
|
|
361
359
|
dashboardFilters,
|
|
362
360
|
]);
|
|
363
|
-
useEffect(() => {
|
|
364
|
-
console.log('chartReport memo', chartReport);
|
|
365
|
-
}, [chartReport]);
|
|
366
361
|
const fetchReportHelper = async (useReportTask = true) => {
|
|
367
362
|
if (!client || !filters) {
|
|
368
363
|
return;
|
|
@@ -396,7 +391,7 @@ export const ChartDataLoader = ({ item, children, dateBucket, additionalProcessi
|
|
|
396
391
|
fetchReportAbortController.current = null;
|
|
397
392
|
}
|
|
398
393
|
else {
|
|
399
|
-
const { report, error } = await fetchReport(item.id, client, useReportTask,
|
|
394
|
+
const { report, error } = await fetchReport(item.id, client, useReportTask, filters.concat(userFilters ?? []), {
|
|
400
395
|
...additionalProcessing,
|
|
401
396
|
...(item.pivot ? {} : { page: DEFAULT_PAGINATION }),
|
|
402
397
|
}, dateBucket, schemaData.customFields, undefined, undefined, fetchReportAbortController.current.signal);
|
|
@@ -442,7 +437,6 @@ export const ChartDataLoader = ({ item, children, dateBucket, additionalProcessi
|
|
|
442
437
|
fetchReportHelper();
|
|
443
438
|
}
|
|
444
439
|
}, [(reportMode ? reports : dashboard)[item.id]]);
|
|
445
|
-
console.log('chartReport', chartReport);
|
|
446
440
|
return children({
|
|
447
441
|
isLoading: !chartReport || loading,
|
|
448
442
|
data: chartReport,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useExport.d.ts","sourceRoot":"","sources":["../../../src/hooks/useExport.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useExport.d.ts","sourceRoot":"","sources":["../../../src/hooks/useExport.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AA0D/C,eAAO,MAAM,SAAS,cACT,MAAM,mEAMd;IACD,uBAAuB,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,GAAG,CAAC,OAAO,CAAC;IAChE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;;;;;;;;;;;;CAyOF,CAAC;AAEF,UAAU,aAAa;IACrB,MAAM,EAAE,WAAW,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;CAC5B"}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { downloadCSV } from '../utils/csv';
|
|
3
3
|
import { useContext, useMemo, useState } from 'react';
|
|
4
4
|
import { getData } from '../utils/dataFetcher';
|
|
5
|
-
import { ClientContext, DashboardContext, DashboardFiltersContext, } from '../Context';
|
|
5
|
+
import { ClientContext, DashboardContext, DashboardFiltersContext, ReportFiltersContext, } from '../Context';
|
|
6
6
|
import { cleanDashboardItem } from '../utils/dashboard';
|
|
7
7
|
import { defaultQuillTheme } from '../QuillProvider';
|
|
8
8
|
import { createRoot } from 'react-dom/client';
|
|
@@ -51,6 +51,7 @@ export const useExport = (reportId, { CustomDocumentComponent = QuillCustomDocum
|
|
|
51
51
|
sectionField, } = {}) => {
|
|
52
52
|
const { dashboardFilters } = useContext(DashboardFiltersContext);
|
|
53
53
|
const [dashboard] = useContext(DashboardContext);
|
|
54
|
+
const { reportFilters } = useContext(ReportFiltersContext);
|
|
54
55
|
const specificDashboardFilters = useMemo(() => {
|
|
55
56
|
if (!reportId) {
|
|
56
57
|
return [];
|
|
@@ -64,6 +65,11 @@ sectionField, } = {}) => {
|
|
|
64
65
|
return dashboardFilter.filter;
|
|
65
66
|
});
|
|
66
67
|
}, [dashboardFilters, dashboard, reportId]);
|
|
68
|
+
const specificReportFilters = useMemo(() => {
|
|
69
|
+
if (!reportId)
|
|
70
|
+
return [];
|
|
71
|
+
return Object.values(reportFilters[reportId] ?? []).map((f) => f.filter);
|
|
72
|
+
}, [reportFilters, reportId]);
|
|
67
73
|
// const [theme] = useContext(ThemeContext);
|
|
68
74
|
const [client] = useContext(ClientContext);
|
|
69
75
|
const [isCSVLoading, setIsCSVLoading] = useState(false);
|
|
@@ -77,7 +83,9 @@ sectionField, } = {}) => {
|
|
|
77
83
|
return;
|
|
78
84
|
}
|
|
79
85
|
setIsCSVLoading(true);
|
|
80
|
-
const resp = await getExportData(client,
|
|
86
|
+
const resp = await getExportData(client, specificReportFilters.length > 0
|
|
87
|
+
? specificReportFilters
|
|
88
|
+
: specificDashboardFilters, reportId);
|
|
81
89
|
downloadCSV({
|
|
82
90
|
rows: resp.pivot && resp.pivotRows ? resp.pivotRows : resp.rows,
|
|
83
91
|
fields: resp.pivot && resp.pivotColumns ? resp.pivotColumns : resp.columns,
|
|
@@ -87,22 +95,11 @@ sectionField, } = {}) => {
|
|
|
87
95
|
},
|
|
88
96
|
downloadPDF: async () => {
|
|
89
97
|
setIsPDFLoading(true);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
// @ts-ignore
|
|
96
|
-
dashboardFilters[dashboard[reportId].dashboardName]) {
|
|
97
|
-
const { report: fetchedReport } = await fetchReport(reportId, client, true, Object.values(
|
|
98
|
-
// @ts-ignore
|
|
99
|
-
dashboardFilters[dashboard[reportId].dashboardName]).map((elem) => elem.filter));
|
|
100
|
-
report = fetchedReport;
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
const { report: fetchedReport } = await fetchReport(reportId, client, true, []);
|
|
104
|
-
report = fetchedReport;
|
|
105
|
-
}
|
|
98
|
+
const filters = specificReportFilters.length > 0
|
|
99
|
+
? specificReportFilters
|
|
100
|
+
: specificDashboardFilters;
|
|
101
|
+
const { report: fetchedReport } = await fetchReport(reportId, client, true, filters);
|
|
102
|
+
const report = fetchedReport;
|
|
106
103
|
let groupedRows = {};
|
|
107
104
|
if (sectionField) {
|
|
108
105
|
groupedRows = (report?.rows || []).reduce((acc, row) => {
|
|
@@ -122,65 +119,99 @@ sectionField, } = {}) => {
|
|
|
122
119
|
let currentPage = {};
|
|
123
120
|
let currentCount = 0;
|
|
124
121
|
let pageNumber = 1;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
122
|
+
if (sectionField) {
|
|
123
|
+
// Iterate over each group of rows
|
|
124
|
+
for (const groupKey in groupedRows) {
|
|
125
|
+
// @ts-ignore
|
|
126
|
+
const rows = groupedRows[groupKey];
|
|
127
|
+
let groupIndex = 0;
|
|
128
|
+
while (groupIndex < rows.length) {
|
|
129
|
+
const remainingRows = rows.length - groupIndex;
|
|
130
|
+
const availableSpace = maximumRowsPerPage - currentCount;
|
|
131
|
+
const rowsToAdd = Math.min(remainingRows, availableSpace);
|
|
132
|
+
// @ts-ignore
|
|
133
|
+
currentPage[groupKey] = (currentPage[groupKey] || []).concat(rows.slice(groupIndex, groupIndex + rowsToAdd));
|
|
134
|
+
currentCount += rowsToAdd;
|
|
135
|
+
groupIndex += rowsToAdd;
|
|
136
|
+
if (currentCount === maximumRowsPerPage) {
|
|
137
|
+
if (Object.keys(currentPage).length > 0) {
|
|
138
|
+
pageNumber++;
|
|
139
|
+
const div = document.createElement('div');
|
|
140
|
+
const root = createRoot(div);
|
|
141
|
+
flushSync(() => {
|
|
142
|
+
root.render(_jsx(CustomDocumentComponent, { report: {
|
|
143
|
+
// @ts-ignore
|
|
144
|
+
...report,
|
|
145
|
+
// @ts-ignore
|
|
146
|
+
sections: currentPage,
|
|
147
|
+
filters,
|
|
148
|
+
}, pageNumber: pageNumber, numberOfPages: numberOfPages, maximumRowsPerPage: maximumRowsPerPage }));
|
|
149
|
+
});
|
|
150
|
+
// const divContentBuffer = Buffer.from(div.innerHTML, 'utf-8');
|
|
151
|
+
// htmlBuffer = Buffer.concat([htmlBuffer, divContentBuffer]);
|
|
152
|
+
html += div.innerHTML;
|
|
153
|
+
currentPage = {};
|
|
154
|
+
currentCount = 0;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
// Add the last page if it has remaining rows
|
|
160
|
+
if (Object.keys(currentPage).length > 0) {
|
|
161
|
+
pageNumber++;
|
|
162
|
+
const div = document.createElement('div');
|
|
163
|
+
const root = createRoot(div);
|
|
164
|
+
flushSync(() => {
|
|
165
|
+
root.render(_jsx(CustomDocumentComponent, { report: {
|
|
166
|
+
// @ts-ignore
|
|
167
|
+
...report,
|
|
168
|
+
// @ts-ignore
|
|
169
|
+
sections: currentPage,
|
|
170
|
+
filters,
|
|
171
|
+
}, pageNumber: pageNumber, numberOfPages: numberOfPages, maximumRowsPerPage: maximumRowsPerPage }));
|
|
172
|
+
});
|
|
173
|
+
// const divContentBuffer = Buffer.from(div.innerHTML, 'utf-8');
|
|
174
|
+
// htmlBuffer = Buffer.concat([htmlBuffer, divContentBuffer]);
|
|
175
|
+
html += div.innerHTML;
|
|
176
|
+
currentPage = {};
|
|
177
|
+
currentCount = 0;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
const rows = report.rows;
|
|
182
|
+
for (let i = 0; i < rows.length; i += maximumRowsPerPage) {
|
|
183
|
+
const remainingRows = rows.length - i * maximumRowsPerPage;
|
|
132
184
|
const availableSpace = maximumRowsPerPage - currentCount;
|
|
133
185
|
const rowsToAdd = Math.min(remainingRows, availableSpace);
|
|
134
|
-
// @ts-ignore
|
|
135
|
-
currentPage[groupKey] = (currentPage[groupKey] || []).concat(rows.slice(groupIndex, groupIndex + rowsToAdd));
|
|
136
186
|
currentCount += rowsToAdd;
|
|
137
|
-
groupIndex += rowsToAdd;
|
|
138
187
|
if (currentCount === maximumRowsPerPage) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
// @ts-ignore
|
|
151
|
-
dashboardFilters[report.dashboardName]).map((elem) => elem.filter),
|
|
152
|
-
}, pageNumber: pageNumber, numberOfPages: numberOfPages, maximumRowsPerPage: maximumRowsPerPage }));
|
|
153
|
-
});
|
|
154
|
-
// const divContentBuffer = Buffer.from(div.innerHTML, 'utf-8');
|
|
155
|
-
// htmlBuffer = Buffer.concat([htmlBuffer, divContentBuffer]);
|
|
156
|
-
html += div.innerHTML;
|
|
157
|
-
currentPage = {};
|
|
158
|
-
currentCount = 0;
|
|
159
|
-
}
|
|
188
|
+
pageNumber++;
|
|
189
|
+
const div = document.createElement('div');
|
|
190
|
+
const root = createRoot(div);
|
|
191
|
+
flushSync(() => {
|
|
192
|
+
root.render(_jsx(CustomDocumentComponent, { report: report, pageNumber: pageNumber, numberOfPages: numberOfPages, maximumRowsPerPage: maximumRowsPerPage }));
|
|
193
|
+
});
|
|
194
|
+
// const divContentBuffer = Buffer.from(div.innerHTML, 'utf-8');
|
|
195
|
+
// htmlBuffer = Buffer.concat([htmlBuffer, divContentBuffer]);
|
|
196
|
+
html += div.innerHTML;
|
|
197
|
+
console.log('html', html);
|
|
198
|
+
currentCount = 0;
|
|
160
199
|
}
|
|
161
200
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
dashboardFilters[report.dashboardName]).map((elem) => elem.filter),
|
|
177
|
-
}, pageNumber: pageNumber, numberOfPages: numberOfPages, maximumRowsPerPage: maximumRowsPerPage }));
|
|
178
|
-
});
|
|
179
|
-
// const divContentBuffer = Buffer.from(div.innerHTML, 'utf-8');
|
|
180
|
-
// htmlBuffer = Buffer.concat([htmlBuffer, divContentBuffer]);
|
|
181
|
-
html += div.innerHTML;
|
|
182
|
-
currentPage = {};
|
|
183
|
-
currentCount = 0;
|
|
201
|
+
// Add the last page if it has remaining rows
|
|
202
|
+
if (currentCount < maximumRowsPerPage) {
|
|
203
|
+
pageNumber++;
|
|
204
|
+
const div = document.createElement('div');
|
|
205
|
+
const root = createRoot(div);
|
|
206
|
+
flushSync(() => {
|
|
207
|
+
root.render(_jsx(CustomDocumentComponent, { report: report, pageNumber: pageNumber, numberOfPages: numberOfPages, maximumRowsPerPage: maximumRowsPerPage }));
|
|
208
|
+
});
|
|
209
|
+
// const divContentBuffer = Buffer.from(div.innerHTML, 'utf-8');
|
|
210
|
+
// htmlBuffer = Buffer.concat([htmlBuffer, divContentBuffer]);
|
|
211
|
+
html += div.innerHTML;
|
|
212
|
+
currentPage = {};
|
|
213
|
+
currentCount = 0;
|
|
214
|
+
}
|
|
184
215
|
}
|
|
185
216
|
const doc = new jsPDF('landscape', 'pt', 'a4');
|
|
186
217
|
// const htmlStringFromBuffer = htmlBuffer.toString('utf-8');
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;CA+MvB,CAAC"}
|
|
@@ -10,17 +10,9 @@ export const useQuill = (reportId, pagination) => {
|
|
|
10
10
|
const [dashboard] = useContext(DashboardContext);
|
|
11
11
|
const { dashboardFilters } = useContext(DashboardFiltersContext);
|
|
12
12
|
const { reportFilters, reportFiltersDispatch } = useContext(ReportFiltersContext);
|
|
13
|
-
const specificDashboardFilters = useMemo(() => {
|
|
14
|
-
if (!reportId)
|
|
15
|
-
return [];
|
|
16
|
-
const dashboardName = reports[reportId]?.dashboardName;
|
|
17
|
-
if (!dashboardName)
|
|
18
|
-
return [];
|
|
19
|
-
return Object.values(dashboardFilters[dashboardName] ?? {}).map((f) => f.filter);
|
|
20
|
-
}, [dashboardFilters, reportId, dashboard]);
|
|
21
13
|
const specificReportFilters = useMemo(() => {
|
|
22
14
|
if (!reportId)
|
|
23
|
-
return
|
|
15
|
+
return null;
|
|
24
16
|
return Object.values(reportFilters[reportId] ?? []).map((f) => f.filter);
|
|
25
17
|
}, [reportFilters, reportId]);
|
|
26
18
|
const [schemaData] = useContext(SchemaDataContext);
|
|
@@ -30,7 +22,7 @@ export const useQuill = (reportId, pagination) => {
|
|
|
30
22
|
const [previousPage, setPreviousPage] = useState(0);
|
|
31
23
|
const processedReport = useMemo(() => {
|
|
32
24
|
return reportId && (reports[reportId] || dashboard[reportId])
|
|
33
|
-
? convertInternalReportToReport(mergeComparisonRange(reports[reportId] || dashboard[reportId]), specificReportFilters)
|
|
25
|
+
? convertInternalReportToReport(mergeComparisonRange(reports[reportId] || dashboard[reportId]), specificReportFilters ?? [], 'useQuill')
|
|
34
26
|
: undefined;
|
|
35
27
|
}, [
|
|
36
28
|
reportId,
|
|
@@ -137,18 +129,9 @@ export const useQuill = (reportId, pagination) => {
|
|
|
137
129
|
setLoading(false);
|
|
138
130
|
return;
|
|
139
131
|
}
|
|
140
|
-
if (specificDashboardFilters.length && !specificReportFilters.length) {
|
|
141
|
-
reportFiltersDispatch({
|
|
142
|
-
type: 'ADD_REPORT_FILTERS',
|
|
143
|
-
id: curReportId,
|
|
144
|
-
data: Object.values(dashboardFilters[curReportId] ?? []),
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
132
|
setLoading(true);
|
|
148
133
|
try {
|
|
149
|
-
fetchIndividualReport(curReportId, 'useQuill', true, specificReportFilters, [], additionalProcessing)
|
|
150
|
-
console.log('fetched report', reports[curReportId]);
|
|
151
|
-
});
|
|
134
|
+
await fetchIndividualReport(curReportId, 'useQuill', true, specificReportFilters || [], [], additionalProcessing);
|
|
152
135
|
}
|
|
153
136
|
catch (error) {
|
|
154
137
|
setError(error.message ?? 'Error fetching report');
|
|
@@ -158,15 +141,30 @@ export const useQuill = (reportId, pagination) => {
|
|
|
158
141
|
}
|
|
159
142
|
};
|
|
160
143
|
useEffect(() => {
|
|
161
|
-
if (reportId) {
|
|
144
|
+
if (reportId && specificReportFilters) {
|
|
162
145
|
fetchReportHelper(reportId, {
|
|
163
146
|
page: pagination,
|
|
164
147
|
});
|
|
165
148
|
}
|
|
166
|
-
|
|
149
|
+
// if we don't have report filters, we need set those
|
|
150
|
+
if (reportId && !specificReportFilters) {
|
|
151
|
+
// should always resolve to some dashboard name given that spacificDashboardFilters is not empty
|
|
152
|
+
const dashboardName = reportId && reports[reportId]
|
|
153
|
+
? reports[reportId].dashboardName
|
|
154
|
+
: '';
|
|
155
|
+
reportFiltersDispatch({
|
|
156
|
+
type: 'ADD_REPORT_FILTERS',
|
|
157
|
+
id: reportId,
|
|
158
|
+
data: dashboardName
|
|
159
|
+
? Object.values(dashboardFilters[dashboardName] ?? {})
|
|
160
|
+
: [],
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}, [reportId, specificReportFilters]);
|
|
167
164
|
return {
|
|
168
165
|
data: processedReport ?? null,
|
|
169
|
-
loading
|
|
166
|
+
// rows is undefined sometimes when loading is false ??? @sam
|
|
167
|
+
loading: !processedReport || !processedReport.rows || loading,
|
|
170
168
|
error,
|
|
171
169
|
fetchMore,
|
|
172
170
|
setSort,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldType, InternalFilter, DashboardFilter, DashboardDateFilter } from '../models/Filter';
|
|
1
|
+
import { FieldType, InternalFilter, DashboardFilter, DashboardDateFilter, Filter } from '../models/Filter';
|
|
2
2
|
import { QuillReport } from '../models/Report';
|
|
3
3
|
import { UniqueValuesByColumn } from '../models/Tables';
|
|
4
4
|
import { FilterTreeNode } from './astFilterProcessing';
|
|
@@ -28,6 +28,7 @@ export declare function buildQueryFromFilters(baseAst: any, filters: FilterTreeN
|
|
|
28
28
|
error?: string;
|
|
29
29
|
}>;
|
|
30
30
|
export declare function mergeCustomFilters(filters: DashboardFilter[], customFilters: InternalFilter[]): any[];
|
|
31
|
+
export declare function applyCustomFilterToDashDateFilter(customDateFilter: Filter, dashboardDateFilter: DashboardDateFilter): DashboardDateFilter;
|
|
31
32
|
export declare function filtersAreEquivalent(filters1?: InternalFilter[], filters2?: InternalFilter[]): boolean;
|
|
32
33
|
/**
|
|
33
34
|
* Helper function that converts a UniqueValuesByColumn interface to a string map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterProcessing.d.ts","sourceRoot":"","sources":["../../../src/utils/filterProcessing.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,SAAS,EACT,cAAc,EAEd,eAAe,EAEf,mBAAmB,
|
|
1
|
+
{"version":3,"file":"filterProcessing.d.ts","sourceRoot":"","sources":["../../../src/utils/filterProcessing.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,SAAS,EACT,cAAc,EAEd,eAAe,EAEf,mBAAmB,EACnB,MAAM,EACP,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAmB,MAAM,uBAAuB,CAAC;AAGxE,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,GAAG,CAoB5D;AAMD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,GAAG,OAkBnD;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,GAAG,EACX,KAAK,EAAE,GAAU,EACjB,UAAU,EAAE,GAAU,EACtB,aAAa,EAAE,MAAM,OAmGtB;AAGD,eAAO,MAAM,OAAO,MAAO,MAAM,6EAwDhC,CAAC;AAEF;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAwB7D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,GAAG,GAAG,cAAc,EAAE,CAoCrE;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,GAAG,EAAE,yBAgCnD;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,GAAG,EACZ,OAAO,EAAE,cAAc,EAAE,EACzB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,GAAG,GACV,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA2B/D;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,eAAe,EAAE,EAC1B,aAAa,EAAE,cAAc,EAAE,GAC9B,GAAG,EAAE,CAsCP;AAED,wBAAgB,iCAAiC,CAC/C,gBAAgB,EAAE,MAAM,EACxB,mBAAmB,EAAE,mBAAmB,GACvC,mBAAmB,CAiBrB;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,CAAC,EAAE,cAAc,EAAE,EAC3B,QAAQ,CAAC,EAAE,cAAc,EAAE,GAC1B,OAAO,CA+BT;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,oBAAoB,GAAG;IAC3E,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACzB,CASA;AAED,eAAO,MAAM,uBAAuB,WAC1B,mBAAmB,WAClB,WAAW,EAAE,iBACP,MAAM,KACpB,CAAC,mBAAmB,GAAG;IAAE,SAAS,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,GAAG,SAqDpD,CAAC"}
|
|
@@ -364,6 +364,21 @@ export function mergeCustomFilters(filters, customFilters) {
|
|
|
364
364
|
])
|
|
365
365
|
.concat(customWithoutDate);
|
|
366
366
|
}
|
|
367
|
+
export function applyCustomFilterToDashDateFilter(customDateFilter, dashboardDateFilter) {
|
|
368
|
+
if (customDateFilter.value &&
|
|
369
|
+
typeof customDateFilter.value === 'object' &&
|
|
370
|
+
'startDate' in customDateFilter.value &&
|
|
371
|
+
'endDate' in customDateFilter.value) {
|
|
372
|
+
const startDate = customDateFilter.value.startDate;
|
|
373
|
+
const endDate = customDateFilter.value.endDate;
|
|
374
|
+
return {
|
|
375
|
+
...dashboardDateFilter,
|
|
376
|
+
startDate: new Date(startDate),
|
|
377
|
+
endDate: new Date(endDate),
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
return dashboardDateFilter;
|
|
381
|
+
}
|
|
367
382
|
export function filtersAreEquivalent(filters1, filters2) {
|
|
368
383
|
if (!filters1 && !filters2) {
|
|
369
384
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryConstructor.d.ts","sourceRoot":"","sources":["../../../src/utils/queryConstructor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAoBxC,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,cAAc,CAAC,EAAE,MAAM,EAEvB,uBAAuB,CAAC,EAAE,OAAO,EACjC,sBAAsB,CAAC,EAAE,OAAO,UAqEjC;AAED,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM,UAE1D;AAwDD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EAAE,EAChB,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,UAsBrB;AAED,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,MAAM,EAAE,EACtB,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,UAYrB;AAiDD,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,MAAM,EAAE,EACtB,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"queryConstructor.d.ts","sourceRoot":"","sources":["../../../src/utils/queryConstructor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAoBxC,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,cAAc,CAAC,EAAE,MAAM,EAEvB,uBAAuB,CAAC,EAAE,OAAO,EACjC,sBAAsB,CAAC,EAAE,OAAO,UAqEjC;AAED,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM,UAE1D;AAwDD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EAAE,EAChB,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,UAsBrB;AAED,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,MAAM,EAAE,EACtB,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,UAYrB;AAiDD,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,MAAM,EAAE,EACtB,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,UAcrB;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,MAAM,EAAE,EACrB,YAAY,EAAE,MAAM,EACpB,kBAAkB,CAAC,EAAE,MAAM,EAC3B,eAAe,CAAC,EAAE,MAAM,EAAE,EAC1B,UAAU,CAAC,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,GAAG,SAAS,CAgCpB"}
|
|
@@ -183,11 +183,12 @@ function generateDistinctQuerySnowflake(stringFields, query) {
|
|
|
183
183
|
}
|
|
184
184
|
export function generateMinMaxRangeQueries(columnFields, query, databaseType) {
|
|
185
185
|
const max = databaseType.toLowerCase() === 'snowflake' ? 'GREATEST' : 'MAX';
|
|
186
|
+
const min = databaseType.toLowerCase() === 'snowflake' ? 'LEAST' : 'MIN';
|
|
186
187
|
const distinctQueries = columnFields.map((field) => {
|
|
187
188
|
const wrappedField = ['postgresql'].includes(databaseType.toLowerCase())
|
|
188
189
|
? `"${field}"`
|
|
189
190
|
: field;
|
|
190
|
-
return `SELECT '${field}' AS field,
|
|
191
|
+
return `SELECT '${field}' AS field, ${min}(${wrappedField}) AS min_range, ${max}(${wrappedField}) AS max_range FROM querytable`;
|
|
191
192
|
});
|
|
192
193
|
const distinctQuery = distinctQueries.join(' UNION ALL ');
|
|
193
194
|
return `WITH querytable AS (${query.replace(';', '')}) ` + distinctQuery;
|
|
@@ -46,7 +46,7 @@ export declare function saveReport({ report, dashboardItemId, client, }: {
|
|
|
46
46
|
client: QuillProviderClient;
|
|
47
47
|
}): Promise<any>;
|
|
48
48
|
export declare const formatRowsFromReport: (report: any) => any;
|
|
49
|
-
export declare function convertInternalReportToReport(report: QuillReportInternal, dashboardFilters: DashboardFilter[]): QuillReport;
|
|
49
|
+
export declare function convertInternalReportToReport(report: QuillReportInternal, dashboardFilters: DashboardFilter[], initiator?: string): QuillReport;
|
|
50
50
|
export declare const fetchReportBuilderDataFromAST: (baseAst: any, formData: any, schema: Table[], client: QuillProviderClient, pivot?: Pivot, previousFormData?: any, currentTable?: string, previousRelevant?: {
|
|
51
51
|
uniqueStrings: UniqueValuesByTable;
|
|
52
52
|
dateRanges: DateRangesByColumn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../src/utils/report.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAU,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../src/utils/report.ts"],"names":[],"mappings":"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"}
|
package/dist/esm/utils/report.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createInitialFormData } from '../ChartBuilder';
|
|
2
2
|
import { getTableNames } from '../components/ReportBuilder/ast';
|
|
3
3
|
import { generatePivotTable } from '../internals/ReportBuilder/PivotModal';
|
|
4
|
+
import { FilterType } from '../models/Filter';
|
|
4
5
|
import { createBasicSelectASTFromColumns } from './astProcessing';
|
|
5
6
|
import { getYAxisFields } from './columnProcessing';
|
|
6
7
|
import { cleanDashboardItem } from './dashboard';
|
|
@@ -133,7 +134,7 @@ export async function fetchReport(reportId, client, useReportTask = true, filter
|
|
|
133
134
|
export async function processReportResponse({ resp, client, filters, dateBucket, additionalProcessing, }) {
|
|
134
135
|
const dashboardItem = {
|
|
135
136
|
...resp,
|
|
136
|
-
filtersApplied: filters,
|
|
137
|
+
filtersApplied: filters?.filter((filter) => filter.filterType in FilterType),
|
|
137
138
|
};
|
|
138
139
|
if (resp.errorMessage) {
|
|
139
140
|
throw new DataLoadError(resp?.errorMessage, {
|
|
@@ -150,10 +151,7 @@ export async function processReportResponse({ resp, client, filters, dateBucket,
|
|
|
150
151
|
parseValueFromBigQueryDates(dashboardItem.compareRows, resp.fields);
|
|
151
152
|
}
|
|
152
153
|
}
|
|
153
|
-
console.log('dashboardItem', dashboardItem);
|
|
154
|
-
console.log('filters', filters);
|
|
155
154
|
const reportInfo = await cleanDashboardItem(dashboardItem, filters, client, dateBucket);
|
|
156
|
-
console.log('reportInfo', reportInfo);
|
|
157
155
|
if (additionalProcessing) {
|
|
158
156
|
reportInfo.pagination = additionalProcessing.page;
|
|
159
157
|
reportInfo.sort = additionalProcessing.sort;
|
|
@@ -274,7 +272,7 @@ export const formatRowsFromReport = (report) => {
|
|
|
274
272
|
}, {});
|
|
275
273
|
});
|
|
276
274
|
};
|
|
277
|
-
export function convertInternalReportToReport(report, dashboardFilters) {
|
|
275
|
+
export function convertInternalReportToReport(report, dashboardFilters, initiator) {
|
|
278
276
|
try {
|
|
279
277
|
if (!report) {
|
|
280
278
|
return EMPTY_REPORT;
|
|
@@ -282,7 +280,9 @@ export function convertInternalReportToReport(report, dashboardFilters) {
|
|
|
282
280
|
const formattedReport = {
|
|
283
281
|
...report,
|
|
284
282
|
};
|
|
285
|
-
if (formattedReport.pivot &&
|
|
283
|
+
if (formattedReport.pivot &&
|
|
284
|
+
isValidPivot(formattedReport.pivot) &&
|
|
285
|
+
initiator !== 'useQuill') {
|
|
286
286
|
let columns = report.pivotColumns ?? report.columns;
|
|
287
287
|
let rows = report.pivotRows ?? report.rows;
|
|
288
288
|
if (report.chartType === 'table') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quillsql/react",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.21",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": {
|
|
6
6
|
"import": "./dist/esm/index.js",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build": "rm -rf dist && tsc -p tsconfig.json && tsc -p tsconfig.esm.json",
|
|
17
17
|
"dev": "concurrently \"npm run dev:types\" \"npm run dev:esm\" \"npm run dev:cjs\"",
|
|
18
|
-
"dev:types": "tsc --emitDeclarationOnly -w",
|
|
19
|
-
"dev:esm": "babel src --out-dir dist/esm --extensions \".ts,.tsx\" --copy-files --watch --env-name esm",
|
|
20
18
|
"dev:cjs": "babel src --out-dir dist/cjs --extensions \".ts,.tsx\" --copy-files --watch --env-name cjs",
|
|
19
|
+
"dev:esm": "babel src --out-dir dist/esm --extensions \".ts,.tsx\" --copy-files --watch --env-name esm",
|
|
20
|
+
"dev:types": "tsc --emitDeclarationOnly -w",
|
|
21
21
|
"lint": "eslint . --max-warnings 0",
|
|
22
22
|
"pub": "rm -rf dist && tsc -p tsconfig.json && tsc -p tsconfig.esm.json && npm publish --access public"
|
|
23
23
|
},
|
|
@@ -56,4 +56,4 @@
|
|
|
56
56
|
"react-dom": "^18"
|
|
57
57
|
},
|
|
58
58
|
"access": "public"
|
|
59
|
-
}
|
|
59
|
+
}
|