@quillsql/react 2.13.35 → 2.13.36
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 +0 -1
- package/dist/cjs/Chart.d.ts.map +1 -1
- package/dist/cjs/Chart.js +17 -14
- package/dist/cjs/ChartBuilder.d.ts +1 -0
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +178 -96
- package/dist/cjs/Context.d.ts.map +1 -1
- package/dist/cjs/Context.js +6 -8
- package/dist/cjs/Dashboard.js +17 -7
- package/dist/cjs/ReportBuilder.d.ts +2 -0
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +398 -271
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +33 -11
- package/dist/cjs/Table.d.ts.map +1 -1
- package/dist/cjs/Table.js +17 -1
- package/dist/cjs/components/Chart/InternalChart.d.ts +0 -1
- package/dist/cjs/components/Chart/InternalChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/InternalChart.js +6 -7
- package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.js +75 -30
- package/dist/cjs/components/QuillMultiSelectSectionList.d.ts.map +1 -1
- package/dist/cjs/components/QuillMultiSelectSectionList.js +21 -16
- package/dist/cjs/components/QuillMultiSelectWithCombo.js +18 -8
- package/dist/cjs/components/QuillSelectWithCombo.js +17 -7
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.d.ts +1 -1
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.js +2 -2
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts +16 -4
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddSortPopover.js +9 -18
- package/dist/cjs/components/UiComponents.d.ts +2 -1
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +44 -28
- package/dist/cjs/hooks/useAskQuill.d.ts.map +1 -1
- package/dist/cjs/hooks/useAskQuill.js +28 -4
- package/dist/cjs/hooks/useQuill.d.ts.map +1 -1
- package/dist/cjs/hooks/useQuill.js +9 -1
- package/dist/cjs/hooks/useVirtualTables.d.ts.map +1 -1
- package/dist/cjs/hooks/useVirtualTables.js +11 -35
- package/dist/cjs/internals/ReportBuilder/PivotForm.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotForm.js +14 -2
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts +12 -11
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.js +63 -18
- package/dist/cjs/models/Client.d.ts +4 -5
- package/dist/cjs/models/Client.d.ts.map +1 -1
- package/dist/cjs/models/Pivot.d.ts +10 -0
- package/dist/cjs/models/Pivot.d.ts.map +1 -1
- package/dist/cjs/models/Report.d.ts +13 -1
- package/dist/cjs/models/Report.d.ts.map +1 -1
- package/dist/cjs/utils/astFilterProcessing.d.ts +1 -1
- package/dist/cjs/utils/astFilterProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/astFilterProcessing.js +799 -64
- package/dist/cjs/utils/astProcessing.d.ts +4 -1
- package/dist/cjs/utils/astProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/astProcessing.js +2 -2
- package/dist/cjs/utils/client.d.ts.map +1 -1
- package/dist/cjs/utils/client.js +6 -3
- package/dist/cjs/utils/columnProcessing.d.ts +1 -0
- package/dist/cjs/utils/columnProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/columnProcessing.js +1 -0
- package/dist/cjs/utils/dashboard.d.ts +2 -1
- package/dist/cjs/utils/dashboard.d.ts.map +1 -1
- package/dist/cjs/utils/dashboard.js +38 -10
- package/dist/cjs/utils/filterProcessing.d.ts +1 -1
- package/dist/cjs/utils/filterProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/merge.d.ts +16 -0
- package/dist/cjs/utils/merge.d.ts.map +1 -1
- package/dist/cjs/utils/merge.js +210 -0
- package/dist/cjs/utils/paginationProcessing.d.ts +1 -1
- package/dist/cjs/utils/paginationProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/paginationProcessing.js +3 -2
- package/dist/cjs/utils/pivotConstructor.d.ts +19 -9
- package/dist/cjs/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/pivotConstructor.js +90 -34
- package/dist/cjs/utils/queryConstructor.d.ts +8 -1
- package/dist/cjs/utils/queryConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/queryConstructor.js +276 -310
- package/dist/cjs/utils/report.d.ts +25 -12
- package/dist/cjs/utils/report.d.ts.map +1 -1
- package/dist/cjs/utils/report.js +13 -7
- package/dist/cjs/utils/schema.d.ts +1 -1
- package/dist/cjs/utils/schema.d.ts.map +1 -1
- package/dist/cjs/utils/schema.js +3 -32
- package/dist/cjs/utils/tableProcessing.d.ts +43 -13
- package/dist/cjs/utils/tableProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/tableProcessing.js +140 -75
- package/dist/cjs/utils/textProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/textProcessing.js +10 -1
- package/dist/cjs/utils/valueFormatter.d.ts +2 -1
- package/dist/cjs/utils/valueFormatter.d.ts.map +1 -1
- package/dist/cjs/utils/valueFormatter.js +18 -14
- package/dist/esm/Chart.d.ts +0 -1
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +0 -6
- package/dist/esm/ChartBuilder.d.ts +1 -0
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +179 -97
- package/dist/esm/Context.d.ts.map +1 -1
- package/dist/esm/Context.js +7 -9
- package/dist/esm/ReportBuilder.d.ts +2 -0
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +399 -272
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +33 -11
- package/dist/esm/Table.d.ts.map +1 -1
- package/dist/esm/Table.js +17 -1
- package/dist/esm/components/Chart/InternalChart.d.ts +0 -1
- package/dist/esm/components/Chart/InternalChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/InternalChart.js +6 -6
- package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.js +75 -30
- package/dist/esm/components/QuillMultiSelectSectionList.d.ts.map +1 -1
- package/dist/esm/components/QuillMultiSelectSectionList.js +5 -12
- package/dist/esm/components/QuillMultiSelectWithCombo.js +1 -1
- package/dist/esm/components/ReportBuilder/AddLimitPopover.d.ts +1 -1
- package/dist/esm/components/ReportBuilder/AddLimitPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddLimitPopover.js +2 -2
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts +16 -4
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddSortPopover.js +9 -18
- package/dist/esm/components/UiComponents.d.ts +2 -1
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +27 -21
- package/dist/esm/hooks/useAskQuill.d.ts.map +1 -1
- package/dist/esm/hooks/useAskQuill.js +28 -4
- package/dist/esm/hooks/useQuill.d.ts.map +1 -1
- package/dist/esm/hooks/useQuill.js +10 -2
- package/dist/esm/hooks/useVirtualTables.d.ts.map +1 -1
- package/dist/esm/hooks/useVirtualTables.js +12 -36
- package/dist/esm/internals/ReportBuilder/PivotForm.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotForm.js +14 -2
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts +12 -11
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.js +63 -18
- package/dist/esm/models/Client.d.ts +4 -5
- package/dist/esm/models/Client.d.ts.map +1 -1
- package/dist/esm/models/Pivot.d.ts +10 -0
- package/dist/esm/models/Pivot.d.ts.map +1 -1
- package/dist/esm/models/Report.d.ts +13 -1
- package/dist/esm/models/Report.d.ts.map +1 -1
- package/dist/esm/utils/astFilterProcessing.d.ts +1 -1
- package/dist/esm/utils/astFilterProcessing.d.ts.map +1 -1
- package/dist/esm/utils/astFilterProcessing.js +799 -64
- package/dist/esm/utils/astProcessing.d.ts +4 -1
- package/dist/esm/utils/astProcessing.d.ts.map +1 -1
- package/dist/esm/utils/astProcessing.js +2 -2
- package/dist/esm/utils/client.d.ts.map +1 -1
- package/dist/esm/utils/client.js +6 -3
- package/dist/esm/utils/columnProcessing.d.ts +1 -0
- package/dist/esm/utils/columnProcessing.d.ts.map +1 -1
- package/dist/esm/utils/columnProcessing.js +1 -1
- package/dist/esm/utils/dashboard.d.ts +2 -1
- package/dist/esm/utils/dashboard.d.ts.map +1 -1
- package/dist/esm/utils/dashboard.js +39 -11
- package/dist/esm/utils/filterProcessing.d.ts +1 -1
- package/dist/esm/utils/filterProcessing.d.ts.map +1 -1
- package/dist/esm/utils/merge.d.ts +16 -0
- package/dist/esm/utils/merge.d.ts.map +1 -1
- package/dist/esm/utils/merge.js +207 -0
- package/dist/esm/utils/paginationProcessing.d.ts +1 -1
- package/dist/esm/utils/paginationProcessing.d.ts.map +1 -1
- package/dist/esm/utils/paginationProcessing.js +3 -2
- package/dist/esm/utils/pivotConstructor.d.ts +19 -9
- package/dist/esm/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/esm/utils/pivotConstructor.js +91 -35
- package/dist/esm/utils/queryConstructor.d.ts +8 -1
- package/dist/esm/utils/queryConstructor.d.ts.map +1 -1
- package/dist/esm/utils/queryConstructor.js +274 -314
- package/dist/esm/utils/report.d.ts +25 -12
- package/dist/esm/utils/report.d.ts.map +1 -1
- package/dist/esm/utils/report.js +13 -7
- package/dist/esm/utils/schema.d.ts +1 -1
- package/dist/esm/utils/schema.d.ts.map +1 -1
- package/dist/esm/utils/schema.js +1 -30
- package/dist/esm/utils/tableProcessing.d.ts +43 -13
- package/dist/esm/utils/tableProcessing.d.ts.map +1 -1
- package/dist/esm/utils/tableProcessing.js +140 -75
- package/dist/esm/utils/textProcessing.d.ts.map +1 -1
- package/dist/esm/utils/textProcessing.js +10 -1
- package/dist/esm/utils/valueFormatter.d.ts +2 -1
- package/dist/esm/utils/valueFormatter.d.ts.map +1 -1
- package/dist/esm/utils/valueFormatter.js +18 -14
- package/package.json +1 -1
|
@@ -31,7 +31,7 @@ import { astToFilterTree, filterTreeToAst, getFieldFromExpression, } from './uti
|
|
|
31
31
|
import useAstToFilterTree from './hooks/useAstToFilterTree';
|
|
32
32
|
import { filterStackToFilterTree, uniqueValuesToStringMap, } from './utils/filterProcessing';
|
|
33
33
|
import { QuillMultiSelectComponentWithCombo } from './components/QuillMultiSelectWithCombo';
|
|
34
|
-
import { DEFAULT_PAGINATION, shouldFetchMore,
|
|
34
|
+
import { DEFAULT_PAGINATION, shouldFetchMore, } from './utils/paginationProcessing';
|
|
35
35
|
import { EMPTY_INTERNAL_REPORT, fetchReportBuilderDataFromAST, formatRowsFromReport, } from './utils/report';
|
|
36
36
|
import { TEMP_REPORT_ID, } from './models/Report';
|
|
37
37
|
import equal from 'fast-deep-equal';
|
|
@@ -102,7 +102,15 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
102
102
|
const [rows, setRows] = useState([]);
|
|
103
103
|
const [formattedRows, setFormattedRows] = useState([]);
|
|
104
104
|
const [columns, setColumns] = useState([]);
|
|
105
|
-
const
|
|
105
|
+
const REPORT_BUILDER_PAGINATION = {
|
|
106
|
+
page: 0,
|
|
107
|
+
rowsPerPage: 20,
|
|
108
|
+
rowsPerRequest: 100,
|
|
109
|
+
};
|
|
110
|
+
const [tempReport, setTempReport] = useState({
|
|
111
|
+
...EMPTY_INTERNAL_REPORT,
|
|
112
|
+
pagination: REPORT_BUILDER_PAGINATION,
|
|
113
|
+
});
|
|
106
114
|
const [uniqueValues, setUniqueValues] = useState({});
|
|
107
115
|
const [uniqueValuesIsLoading, setUniqueValuesIsLoading] = useState(false);
|
|
108
116
|
const [pivot, setPivot] = useState(null);
|
|
@@ -138,11 +146,6 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
138
146
|
const { filterTree, filterStack } = useAstToFilterTree(formData, client, columns); // Stores the state of filters
|
|
139
147
|
const [removingFilter, setRemovingFilter] = useState(false);
|
|
140
148
|
const [pivotRecommendationsEnabledState, setPivotRecommendationsEnabledState,] = useState(pivotRecommendationsEnabled);
|
|
141
|
-
const REPORT_BUILDER_PAGINATION = {
|
|
142
|
-
page: 0,
|
|
143
|
-
rowsPerPage: 20,
|
|
144
|
-
rowsPerRequest: 1000,
|
|
145
|
-
};
|
|
146
149
|
const [unresolvedReportMessage, setUnresolvedReportMessage] = useState('');
|
|
147
150
|
const dashboardName = useMemo(() => {
|
|
148
151
|
if (destinationDashboard) {
|
|
@@ -154,12 +157,20 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
154
157
|
return dashboard[reportId]?.dashboardName;
|
|
155
158
|
}, [reportId, dashboard, destinationDashboard]);
|
|
156
159
|
const [filtersEnabled, setFiltersEnabled] = useState(!!reportId);
|
|
160
|
+
const mssqlSortWarning = useMemo(() => {
|
|
161
|
+
if (!client || client?.databaseType !== 'mssql') {
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
else if (!pivot && !baseAst?.top) {
|
|
165
|
+
return 'Please add a limit.';
|
|
166
|
+
}
|
|
167
|
+
}, [client, baseAst, pivot]);
|
|
157
168
|
useEffect(() => {
|
|
158
169
|
if (!client) {
|
|
159
170
|
return;
|
|
160
171
|
}
|
|
161
|
-
if (client.recommendedPivotsDisabled !== undefined) {
|
|
162
|
-
setPivotRecommendationsEnabledState(!client.recommendedPivotsDisabled);
|
|
172
|
+
if (client.featureFlags?.['recommendedPivotsDisabled'] !== undefined) {
|
|
173
|
+
setPivotRecommendationsEnabledState(!client.featureFlags?.['recommendedPivotsDisabled']);
|
|
163
174
|
}
|
|
164
175
|
if (!initialLoad && client.publicKey) {
|
|
165
176
|
clearAllState();
|
|
@@ -205,6 +216,14 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
205
216
|
setPivotError(undefined);
|
|
206
217
|
// @ts-ignore
|
|
207
218
|
newPivot[fieldKey] = changeField;
|
|
219
|
+
if (fieldKey === 'columnField' &&
|
|
220
|
+
!changeField &&
|
|
221
|
+
pivotValueField === pivotValueField2) {
|
|
222
|
+
setPivotValueField2(undefined);
|
|
223
|
+
newPivot.valueField2 = undefined;
|
|
224
|
+
}
|
|
225
|
+
newPivot.rowLimit = undefined;
|
|
226
|
+
newPivot.sort = undefined;
|
|
208
227
|
if (fieldKey === 'rowField') {
|
|
209
228
|
// check to see if the new rowField value is a date field
|
|
210
229
|
const column = columns.find((c) => c.field === changeField);
|
|
@@ -220,11 +239,15 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
220
239
|
newPivot.sort = undefined;
|
|
221
240
|
}
|
|
222
241
|
}
|
|
242
|
+
setPivot(newPivot);
|
|
223
243
|
const { valid, reason } = isValidPivot(newPivot);
|
|
224
244
|
if (!valid) {
|
|
225
245
|
setPivotError(reason);
|
|
226
246
|
return;
|
|
227
247
|
}
|
|
248
|
+
resetLimit();
|
|
249
|
+
resetSort();
|
|
250
|
+
setPreviousPage(0);
|
|
228
251
|
setTableLoading(true);
|
|
229
252
|
let dateBucket = undefined;
|
|
230
253
|
const tempDateRange = dateRanges && dateRanges[newPivot.rowField || ''];
|
|
@@ -234,16 +257,20 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
234
257
|
let distinctValuesForQuery = {};
|
|
235
258
|
const prevPivot = pivot;
|
|
236
259
|
const prevPivotData = pivotData;
|
|
237
|
-
setPivot(newPivot);
|
|
238
260
|
setPivotHint('');
|
|
239
261
|
if (newPivot.columnField) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
262
|
+
if (uniqueValues?.[newPivot.columnField]) {
|
|
263
|
+
distinctValuesForQuery = uniqueValues;
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
distinctValuesForQuery = await getUniqueValuesByColumns([
|
|
267
|
+
{
|
|
268
|
+
field: newPivot.columnField,
|
|
269
|
+
label: newPivot.columnField,
|
|
270
|
+
format: 'string',
|
|
271
|
+
},
|
|
272
|
+
], activeQuery, [], client, tenants, schemaData.customFields ?? [], undefined, dashboardName);
|
|
273
|
+
}
|
|
247
274
|
}
|
|
248
275
|
try {
|
|
249
276
|
const pivotedData = await generatePivotTable({
|
|
@@ -254,7 +281,9 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
254
281
|
uniqueValues: distinctValuesForQuery,
|
|
255
282
|
dashboardName,
|
|
256
283
|
tenants,
|
|
284
|
+
additionalProcessing: { page: REPORT_BUILDER_PAGINATION },
|
|
257
285
|
});
|
|
286
|
+
resetProcessing();
|
|
258
287
|
setPivotData(pivotedData || []);
|
|
259
288
|
const formattedRows = formatRows(pivotedData.rows, columns, true, newPivot.aggregationType);
|
|
260
289
|
setFormattedRows(formattedRows);
|
|
@@ -286,6 +315,65 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
286
315
|
setTableLoading(false);
|
|
287
316
|
}
|
|
288
317
|
};
|
|
318
|
+
const resetLimit = (fetchData) => {
|
|
319
|
+
const newAst = {
|
|
320
|
+
...baseAst,
|
|
321
|
+
limit: null,
|
|
322
|
+
top: null,
|
|
323
|
+
orderby: client?.databaseType === 'mssql' ? null : baseAst.orderby,
|
|
324
|
+
};
|
|
325
|
+
setBaseAst((prevAst) => ({
|
|
326
|
+
...prevAst,
|
|
327
|
+
limit: null,
|
|
328
|
+
top: null,
|
|
329
|
+
orderby: client?.databaseType === 'mssql' ? null : prevAst.orderby,
|
|
330
|
+
}));
|
|
331
|
+
setPivot((oldPivot) => {
|
|
332
|
+
if (!oldPivot)
|
|
333
|
+
return null;
|
|
334
|
+
return {
|
|
335
|
+
...oldPivot,
|
|
336
|
+
rowLimit: undefined,
|
|
337
|
+
};
|
|
338
|
+
});
|
|
339
|
+
if (fetchData) {
|
|
340
|
+
fetchReportFromASTHelper({
|
|
341
|
+
baseAst: newAst,
|
|
342
|
+
curPivot: pivot ? { ...pivot, rowLimit: undefined } : undefined,
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
const resetSort = (fetchData) => {
|
|
347
|
+
if (pivot) {
|
|
348
|
+
setPivot((oldPivot) => {
|
|
349
|
+
if (!oldPivot)
|
|
350
|
+
return null;
|
|
351
|
+
return {
|
|
352
|
+
...oldPivot,
|
|
353
|
+
sort: undefined,
|
|
354
|
+
sortField: undefined,
|
|
355
|
+
sortDirection: undefined,
|
|
356
|
+
sortFieldType: undefined,
|
|
357
|
+
};
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
const newAst = { ...baseAst, orderby: null };
|
|
361
|
+
setBaseAst((prevAst) => ({ ...prevAst, orderby: null }));
|
|
362
|
+
if (fetchData) {
|
|
363
|
+
fetchReportFromASTHelper({
|
|
364
|
+
baseAst: newAst,
|
|
365
|
+
curPivot: pivot
|
|
366
|
+
? {
|
|
367
|
+
...pivot,
|
|
368
|
+
sort: undefined,
|
|
369
|
+
sortField: undefined,
|
|
370
|
+
sortDirection: undefined,
|
|
371
|
+
sortFieldType: undefined,
|
|
372
|
+
}
|
|
373
|
+
: undefined,
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
};
|
|
289
377
|
const enforceOrderOnColumns = (columnNames) => {
|
|
290
378
|
if (pivot) {
|
|
291
379
|
const rowName = pivot.rowField;
|
|
@@ -434,7 +522,10 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
434
522
|
const data = await response.json();
|
|
435
523
|
setActiveQuery(data.query);
|
|
436
524
|
if (fetchData) {
|
|
437
|
-
fetchReportFromASTHelper(
|
|
525
|
+
fetchReportFromASTHelper({
|
|
526
|
+
baseAst: ast,
|
|
527
|
+
newFormData: formData,
|
|
528
|
+
});
|
|
438
529
|
}
|
|
439
530
|
return data.query;
|
|
440
531
|
}
|
|
@@ -554,7 +645,13 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
554
645
|
}
|
|
555
646
|
const { ast: newAst, pivot: newPivot, schema: curSchema, } = await fetchASTFromQuillReport(report, client, schemaData.schema);
|
|
556
647
|
setBaseAst({ ...newAst, where: null });
|
|
557
|
-
await fetchReportFromASTHelper({
|
|
648
|
+
await fetchReportFromASTHelper({
|
|
649
|
+
baseAst: { ...newAst, where: null },
|
|
650
|
+
newFormData: newAst.where,
|
|
651
|
+
curPivot: newPivot,
|
|
652
|
+
curSchema,
|
|
653
|
+
previousReport: report,
|
|
654
|
+
});
|
|
558
655
|
await onSchemaChange();
|
|
559
656
|
setReportInfo(report);
|
|
560
657
|
const query = await fetchSqlQuery(newAst, null, false);
|
|
@@ -636,7 +733,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
636
733
|
];
|
|
637
734
|
}
|
|
638
735
|
else {
|
|
639
|
-
return [{ label: snakeAndCamelCaseToTitleCase(pivot
|
|
736
|
+
return [{ label: snakeAndCamelCaseToTitleCase(pivot?.valueField || '') }];
|
|
640
737
|
}
|
|
641
738
|
};
|
|
642
739
|
const [previousPage, setPreviousPage] = useState(0);
|
|
@@ -646,12 +743,15 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
646
743
|
const [numberOfRows, setNumberOfRows] = useState(0);
|
|
647
744
|
const [rowCountIsLoading, setRowCountIsLoading] = useState(false);
|
|
648
745
|
const [tableLoading, setTableLoading] = useState(false);
|
|
746
|
+
const resetProcessing = () => {
|
|
747
|
+
setCurrentProcessing({ page: REPORT_BUILDER_PAGINATION });
|
|
748
|
+
};
|
|
649
749
|
const onPageChange = (page, initiator = 'ReportBuilder') => {
|
|
650
750
|
const pagination = initiator === 'ReportBuilder'
|
|
651
751
|
? REPORT_BUILDER_PAGINATION
|
|
652
752
|
: DEFAULT_PAGINATION;
|
|
653
753
|
if (currentProcessing.page &&
|
|
654
|
-
shouldFetchMore(pagination, page, previousPage)) {
|
|
754
|
+
shouldFetchMore(pagination, page, previousPage, pivotData ? pivotData.rows.length : rows.length)) {
|
|
655
755
|
const newPagination = { ...currentProcessing.page, page };
|
|
656
756
|
const updatedProcessing = { ...currentProcessing, page: newPagination };
|
|
657
757
|
setCurrentProcessing(updatedProcessing);
|
|
@@ -661,40 +761,130 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
661
761
|
setPreviousPage(page);
|
|
662
762
|
}
|
|
663
763
|
};
|
|
664
|
-
const onSortChange = (sort) => {
|
|
665
|
-
if (
|
|
666
|
-
|
|
667
|
-
|
|
764
|
+
const onSortChange = (sort, isDelete) => {
|
|
765
|
+
if (pivot) {
|
|
766
|
+
let newPivot = null;
|
|
767
|
+
if (isDelete) {
|
|
768
|
+
setPivot((oldPivot) => {
|
|
769
|
+
if (!oldPivot)
|
|
770
|
+
return null;
|
|
771
|
+
newPivot = {
|
|
772
|
+
...oldPivot,
|
|
773
|
+
sort: undefined,
|
|
774
|
+
sortField: undefined,
|
|
775
|
+
sortDirection: undefined,
|
|
776
|
+
sortFieldType: undefined,
|
|
777
|
+
};
|
|
778
|
+
return newPivot;
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
else {
|
|
782
|
+
setPivot((oldPivot) => {
|
|
783
|
+
if (!oldPivot)
|
|
784
|
+
return null;
|
|
785
|
+
newPivot = {
|
|
786
|
+
...oldPivot,
|
|
787
|
+
sort: true,
|
|
788
|
+
sortField: sort.field,
|
|
789
|
+
sortDirection: sort.direction,
|
|
790
|
+
sortFieldType: getColumnTypeByName(sort.field),
|
|
791
|
+
};
|
|
792
|
+
return newPivot;
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
fetchReportFromASTHelper({
|
|
796
|
+
baseAst: baseAst,
|
|
797
|
+
curPivot: newPivot,
|
|
798
|
+
});
|
|
668
799
|
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
newAst.orderby
|
|
800
|
+
else {
|
|
801
|
+
const newAst = { ...baseAst };
|
|
802
|
+
if (!newAst.orderby) {
|
|
803
|
+
newAst.orderby = [];
|
|
804
|
+
}
|
|
805
|
+
const existingSortIndex = newAst.orderby.findIndex((item) => getFieldFromExpression(item.expr) === sort.field);
|
|
806
|
+
if (isDelete) {
|
|
807
|
+
if (existingSortIndex !== -1) {
|
|
808
|
+
newAst.orderby.splice(existingSortIndex, 1);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
else if (existingSortIndex !== -1) {
|
|
812
|
+
newAst.orderby[existingSortIndex] = {
|
|
813
|
+
expr: { type: 'column_ref', column: sort.field },
|
|
814
|
+
type: sort.direction.toUpperCase(),
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
else {
|
|
818
|
+
newAst.orderby.push({
|
|
819
|
+
expr: { type: 'column_ref', column: sort.field },
|
|
820
|
+
type: sort.direction.toUpperCase(),
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
setBaseAst(deepCopy(newAst));
|
|
824
|
+
fetchReportFromASTHelper({
|
|
825
|
+
baseAst: newAst,
|
|
826
|
+
});
|
|
827
|
+
setPreviousPage(0);
|
|
672
828
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
829
|
+
};
|
|
830
|
+
const onLimitChange = (limit) => {
|
|
831
|
+
if (limit) {
|
|
832
|
+
if (pivot) {
|
|
833
|
+
setPivot((oldPivot) => {
|
|
834
|
+
if (!oldPivot)
|
|
835
|
+
return null;
|
|
836
|
+
const newPivot = { ...oldPivot, rowLimit: limit };
|
|
837
|
+
fetchReportFromASTHelper({ baseAst, curPivot: newPivot });
|
|
838
|
+
return newPivot;
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
else {
|
|
842
|
+
const newAst = { ...baseAst };
|
|
843
|
+
if (client.databaseType.toLowerCase() === 'mssql') {
|
|
844
|
+
newAst.top = {
|
|
845
|
+
value: limit,
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
else {
|
|
849
|
+
newAst.limit = {
|
|
850
|
+
seperator: '',
|
|
851
|
+
value: [
|
|
852
|
+
{
|
|
853
|
+
type: 'number',
|
|
854
|
+
value: limit,
|
|
855
|
+
},
|
|
856
|
+
],
|
|
857
|
+
};
|
|
858
|
+
}
|
|
859
|
+
setBaseAst(deepCopy(newAst));
|
|
860
|
+
fetchSqlQuery(deepCopy(newAst), undefined, true);
|
|
861
|
+
}
|
|
679
862
|
}
|
|
680
863
|
else {
|
|
681
|
-
|
|
682
|
-
expr: { type: 'column_ref', column: sort.field },
|
|
683
|
-
type: sort.direction.toUpperCase(),
|
|
684
|
-
});
|
|
864
|
+
resetLimit(true);
|
|
685
865
|
}
|
|
686
|
-
|
|
687
|
-
fetchReportFromASTHelper(newAst, newAst.where);
|
|
688
|
-
setPreviousPage(0);
|
|
866
|
+
setOpenPopover(null);
|
|
689
867
|
};
|
|
690
868
|
const fetchRowCount = async (processing, includeFilters) => {
|
|
691
869
|
if (!client || !activeQuery) {
|
|
692
870
|
return;
|
|
693
871
|
}
|
|
694
872
|
setRowCountIsLoading(true);
|
|
695
|
-
const tableInfo = await fetchResultsByQuery(
|
|
696
|
-
|
|
697
|
-
|
|
873
|
+
const tableInfo = await fetchResultsByQuery({
|
|
874
|
+
query: activeQuery,
|
|
875
|
+
client,
|
|
876
|
+
tenants,
|
|
877
|
+
processing,
|
|
878
|
+
customFields: schemaData.customFields,
|
|
879
|
+
filters: includeFilters ? specificDashboardFilters : undefined,
|
|
880
|
+
dateField: includeFilters
|
|
881
|
+
? (tempReport.dateField ?? reportInfo?.dateField)
|
|
882
|
+
: undefined,
|
|
883
|
+
rowsOnly: false,
|
|
884
|
+
rowCountOnly: true,
|
|
885
|
+
filterMap: undefined,
|
|
886
|
+
dashboardName,
|
|
887
|
+
});
|
|
698
888
|
if (tableInfo.rowCount) {
|
|
699
889
|
setNumberOfRows(tableInfo.rowCount);
|
|
700
890
|
// @ts-ignore
|
|
@@ -720,29 +910,62 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
720
910
|
};
|
|
721
911
|
const handleRunQuery = async (processing, resetRows = false, includeFilters = false) => {
|
|
722
912
|
try {
|
|
913
|
+
const isPivotPagination = !!(pivot && pivotData);
|
|
723
914
|
setErrorMessage('');
|
|
724
915
|
setTableLoading(true);
|
|
725
|
-
const tableInfo = await fetchResultsByQuery(
|
|
916
|
+
const tableInfo = await fetchResultsByQuery({
|
|
917
|
+
query: isPivotPagination ? pivotData.pivotQuery : activeQuery,
|
|
918
|
+
comparisonQuery: pivot && pivotData ? pivotData.comparisonPivotQuery : undefined,
|
|
919
|
+
client,
|
|
920
|
+
tenants,
|
|
921
|
+
processing,
|
|
922
|
+
customFields: schemaData.customFields,
|
|
923
|
+
rowsOnly: true,
|
|
924
|
+
dashboardName,
|
|
925
|
+
pivot: pivot,
|
|
926
|
+
getPivotRowCount: false,
|
|
927
|
+
});
|
|
726
928
|
if (tableInfo.error) {
|
|
727
929
|
throw new Error(tableInfo.error);
|
|
728
930
|
}
|
|
729
931
|
else if (tableInfo.rows.length === 0) {
|
|
730
932
|
throw new Error('No data found');
|
|
731
933
|
}
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
tempRows = tableInfo.rows;
|
|
736
|
-
|
|
934
|
+
if (!isPivotPagination) {
|
|
935
|
+
// fetching row count for non-pivot query
|
|
936
|
+
fetchRowCount(processing, includeFilters);
|
|
937
|
+
let tempRows = [...rows, ...tableInfo.rows];
|
|
938
|
+
if (resetRows) {
|
|
939
|
+
tempRows = tableInfo.rows;
|
|
940
|
+
setPreviousPage(0);
|
|
941
|
+
}
|
|
942
|
+
setRows(tempRows);
|
|
943
|
+
setFormattedRows(formatRowsFromReport({ rows: tempRows, columns: tableInfo.columns }));
|
|
944
|
+
setTempReport((tempReport) => ({
|
|
945
|
+
...tempReport,
|
|
946
|
+
rows: tempRows,
|
|
947
|
+
rowCount: tableInfo.rowCount ?? tempReport.rowCount,
|
|
948
|
+
}));
|
|
949
|
+
setColumns(tableInfo.columns);
|
|
950
|
+
}
|
|
951
|
+
else {
|
|
952
|
+
let tempRows = [...pivotData.rows, ...tableInfo.rows];
|
|
953
|
+
if (resetRows) {
|
|
954
|
+
tempRows = tableInfo.rows;
|
|
955
|
+
setPreviousPage(0);
|
|
956
|
+
}
|
|
957
|
+
setPivotData((oldPivotData) => {
|
|
958
|
+
if (oldPivotData) {
|
|
959
|
+
return {
|
|
960
|
+
...oldPivotData,
|
|
961
|
+
rows: tempRows,
|
|
962
|
+
columns: tableInfo.columns,
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
return null;
|
|
966
|
+
});
|
|
967
|
+
setFormattedRows(formatRowsFromReport({ rows: tempRows, columns: tableInfo.columns }));
|
|
737
968
|
}
|
|
738
|
-
setRows(tempRows);
|
|
739
|
-
setFormattedRows(formatRowsFromReport({ rows: tempRows, columns: tableInfo.columns }));
|
|
740
|
-
setTempReport((tempReport) => ({
|
|
741
|
-
...tempReport,
|
|
742
|
-
rows: tempRows,
|
|
743
|
-
rowCount: tableInfo.rowCount ?? tempReport.rowCount,
|
|
744
|
-
}));
|
|
745
|
-
setColumns(tableInfo.columns);
|
|
746
969
|
setTableLoading(false);
|
|
747
970
|
}
|
|
748
971
|
catch (e) {
|
|
@@ -783,12 +1006,31 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
783
1006
|
updateFieldValuesMap(uniqueStringsObj, table);
|
|
784
1007
|
return uniqueStringsObj;
|
|
785
1008
|
};
|
|
786
|
-
const fetchReportFromASTHelper = async (baseAst, newFormData, curPivot, curSchema, previousReport, keepPivotHint = false) => {
|
|
1009
|
+
const fetchReportFromASTHelper = async ({ baseAst, newFormData, curPivot, curSchema, previousReport, keepPivotHint = false, }) => {
|
|
787
1010
|
const curFormData = newFormData !== undefined ? newFormData : formData;
|
|
788
1011
|
let reportBuilderInfo = undefined;
|
|
789
1012
|
try {
|
|
790
1013
|
setLoading(true);
|
|
791
|
-
reportBuilderInfo = await fetchReportBuilderDataFromAST(
|
|
1014
|
+
reportBuilderInfo = await fetchReportBuilderDataFromAST({
|
|
1015
|
+
baseAst,
|
|
1016
|
+
formData: curFormData,
|
|
1017
|
+
schema: curSchema ?? schemaData.schema,
|
|
1018
|
+
client,
|
|
1019
|
+
tenants,
|
|
1020
|
+
pivot: curPivot ?? pivot,
|
|
1021
|
+
previousFormData: formData,
|
|
1022
|
+
currentTable,
|
|
1023
|
+
previousRelevant: {
|
|
1024
|
+
uniqueStrings: uniqueValues,
|
|
1025
|
+
dateRanges: dateRanges ?? {},
|
|
1026
|
+
},
|
|
1027
|
+
report: previousReport ?? reportInfo ?? undefined,
|
|
1028
|
+
customFields: schemaData.customFields,
|
|
1029
|
+
skipUniqueValues: true,
|
|
1030
|
+
skipRowCount: true,
|
|
1031
|
+
processing: { page: REPORT_BUILDER_PAGINATION },
|
|
1032
|
+
dashboardName,
|
|
1033
|
+
});
|
|
792
1034
|
if (reportBuilderInfo.error) {
|
|
793
1035
|
throw new Error(reportBuilderInfo.error);
|
|
794
1036
|
}
|
|
@@ -808,7 +1050,10 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
808
1050
|
setErrorMessage('Failed to fetch');
|
|
809
1051
|
return;
|
|
810
1052
|
}
|
|
811
|
-
setTempReport(
|
|
1053
|
+
setTempReport({
|
|
1054
|
+
...reportBuilderInfo.report,
|
|
1055
|
+
pagination: REPORT_BUILDER_PAGINATION,
|
|
1056
|
+
});
|
|
812
1057
|
fetchRowCountFromAST(baseAst, curFormData);
|
|
813
1058
|
const reportTable = reportBuilderInfo.table;
|
|
814
1059
|
const reportBuilderInfoColumns = reportBuilderInfo.columns.map((column) => {
|
|
@@ -826,7 +1071,6 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
826
1071
|
if (prevTable !== reportBuilderInfo.table) {
|
|
827
1072
|
setSelectedOrderedColumns([]); // reset selected ordered columns
|
|
828
1073
|
}
|
|
829
|
-
setNumberOfRows(reportBuilderInfo.rowCount);
|
|
830
1074
|
setPivot(reportBuilderInfo.pivot);
|
|
831
1075
|
if (!keepPivotHint) {
|
|
832
1076
|
setPivotHint('');
|
|
@@ -902,7 +1146,14 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
902
1146
|
}
|
|
903
1147
|
setUniqueValuesIsLoading(false);
|
|
904
1148
|
if (pivotChanged) {
|
|
905
|
-
fetchReportFromASTHelper(
|
|
1149
|
+
fetchReportFromASTHelper({
|
|
1150
|
+
baseAst,
|
|
1151
|
+
newFormData: curFormData,
|
|
1152
|
+
curPivot: newPivot,
|
|
1153
|
+
curSchema,
|
|
1154
|
+
previousReport,
|
|
1155
|
+
keepPivotHint: true,
|
|
1156
|
+
});
|
|
906
1157
|
}
|
|
907
1158
|
else {
|
|
908
1159
|
setLoading(false);
|
|
@@ -934,7 +1185,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
934
1185
|
setLoading(true);
|
|
935
1186
|
setAskAILoading(true);
|
|
936
1187
|
setErrorMessage('');
|
|
937
|
-
astInfo = await fetchAndProcessASTFromPrompt(prompt, schemaData.schema, client, pivot, activeQuery, currentTable, dashboardName);
|
|
1188
|
+
astInfo = await fetchAndProcessASTFromPrompt(prompt, schemaData.schema, client, pivot ?? undefined, activeQuery, currentTable, dashboardName, tenants);
|
|
938
1189
|
if (astInfo.error) {
|
|
939
1190
|
throw new Error(astInfo.error);
|
|
940
1191
|
}
|
|
@@ -969,7 +1220,11 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
969
1220
|
setBaseAst(astInfo.ast);
|
|
970
1221
|
fetchSqlQuery(astInfo.ast, cleanAst, false);
|
|
971
1222
|
setAskAILoading(false);
|
|
972
|
-
await fetchReportFromASTHelper(
|
|
1223
|
+
await fetchReportFromASTHelper({
|
|
1224
|
+
baseAst: astInfo.ast,
|
|
1225
|
+
newFormData: cleanAst,
|
|
1226
|
+
curPivot: astInfo.pivot,
|
|
1227
|
+
});
|
|
973
1228
|
};
|
|
974
1229
|
const makePivotValid = (pivot, uniqueValuesForPivot, reportTable, reportColumns) => {
|
|
975
1230
|
if (!pivot) {
|
|
@@ -1173,6 +1428,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1173
1428
|
ast.where = null;
|
|
1174
1429
|
ast.orderby = null;
|
|
1175
1430
|
ast.limit = null;
|
|
1431
|
+
ast.top = null;
|
|
1176
1432
|
setBaseAst(ast);
|
|
1177
1433
|
fetchSqlQuery(ast, null);
|
|
1178
1434
|
}
|
|
@@ -1231,23 +1487,29 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1231
1487
|
setPivot(null);
|
|
1232
1488
|
setPivotHint('');
|
|
1233
1489
|
setPivotData(null);
|
|
1490
|
+
resetLimit();
|
|
1491
|
+
resetSort(true);
|
|
1492
|
+
setPreviousPage(0);
|
|
1234
1493
|
const formattedRows = formatRows(rows, columns, false);
|
|
1235
1494
|
setFormattedRows(formattedRows);
|
|
1236
1495
|
}, selectPivot: async (selectedPivot, uniqueValues, dateRange, pivotTable) => {
|
|
1237
1496
|
if (!selectedPivot)
|
|
1238
1497
|
return;
|
|
1239
|
-
const newAst = { ...baseAst };
|
|
1240
|
-
newAst.orderby = null;
|
|
1498
|
+
// const newAst = { ...baseAst };
|
|
1499
|
+
// newAst.orderby = null;
|
|
1241
1500
|
if (selectedPivot.rowFieldType === 'date') {
|
|
1242
1501
|
selectedPivot['sort'] = true;
|
|
1243
1502
|
selectedPivot['sortDirection'] = 'ASC';
|
|
1244
1503
|
}
|
|
1245
|
-
setBaseAst(newAst); // trigger refetch
|
|
1504
|
+
// setBaseAst(newAst); // trigger refetch
|
|
1246
1505
|
let dateBucket = undefined;
|
|
1247
1506
|
if (dateRange) {
|
|
1248
1507
|
dateBucket = getDateBucketFromRange(dateRange);
|
|
1249
1508
|
}
|
|
1250
1509
|
setPivot(selectedPivot);
|
|
1510
|
+
resetLimit();
|
|
1511
|
+
resetSort();
|
|
1512
|
+
setPreviousPage(0);
|
|
1251
1513
|
setPivotHint('');
|
|
1252
1514
|
try {
|
|
1253
1515
|
if (!pivotTable) {
|
|
@@ -1260,8 +1522,12 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1260
1522
|
uniqueValues,
|
|
1261
1523
|
dashboardName,
|
|
1262
1524
|
tenants,
|
|
1525
|
+
additionalProcessing: {
|
|
1526
|
+
page: REPORT_BUILDER_PAGINATION,
|
|
1527
|
+
},
|
|
1263
1528
|
});
|
|
1264
1529
|
}
|
|
1530
|
+
resetProcessing();
|
|
1265
1531
|
setPivotData(pivotTable || []);
|
|
1266
1532
|
const formattedRows = formatRows(pivotTable.rows, columns, true, selectedPivot.aggregationType, dateBucket);
|
|
1267
1533
|
setFormattedRows(formattedRows);
|
|
@@ -1299,167 +1565,48 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1299
1565
|
setPivot(null);
|
|
1300
1566
|
setPivotError(undefined);
|
|
1301
1567
|
setPivotHint('');
|
|
1302
|
-
setPivotData(
|
|
1568
|
+
setPivotData(null);
|
|
1569
|
+
resetLimit();
|
|
1570
|
+
resetSort();
|
|
1571
|
+
setPreviousPage(0);
|
|
1303
1572
|
const formattedRows = formatRows(rows, columns, false);
|
|
1304
1573
|
setFormattedRows(formattedRows);
|
|
1305
|
-
}, isLoading: tableLoading || loading, pivotRowField: pivotRowField, pivotColumnField: pivotColumnField, pivotValueField: pivotValueField, pivotValueField2: pivotValueField2, pivotAggregation: pivotAggregation, SecondaryButtonComponent: SecondaryButtonComponent, SelectComponent: SelectComponent, PivotColumnContainer: PivotColumnContainer, pivotHint: pivotHint }))] }), _jsxs("div", { style: { width: '100%' }, children: [_jsx(SidebarHeadingComponent, { label: "Sort" }), pivot && pivot.sort && (_jsx("div", { style: {
|
|
1574
|
+
}, isLoading: tableLoading || loading, pivotRowField: pivotRowField, pivotColumnField: pivotColumnField, pivotValueField: pivotValueField, pivotValueField2: pivotValueField2, pivotAggregation: pivotAggregation, SecondaryButtonComponent: SecondaryButtonComponent, SelectComponent: SelectComponent, PivotColumnContainer: PivotColumnContainer, pivotHint: pivotHint }))] }), _jsxs("div", { style: { width: '100%' }, children: [_jsx(SidebarHeadingComponent, { label: "Sort" }), pivot && pivot.sort && pivot.sortField && (_jsx("div", { style: {
|
|
1306
1575
|
display: 'flex',
|
|
1307
1576
|
flexDirection: 'column',
|
|
1308
1577
|
gap: 8,
|
|
1309
1578
|
marginBottom: 12,
|
|
1310
|
-
}, children: _jsx(SortSentence, {
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
? [`.${pivot.rowField}`]
|
|
1316
|
-
: [
|
|
1317
|
-
`.${pivot.rowField}`,
|
|
1318
|
-
`.${pivot.valueField || 'count'}`,
|
|
1319
|
-
]
|
|
1320
|
-
: selectedColumns, setIsPending: () => { }, setEditPopoverKey: () => { }, setActiveEditItem: setActiveEditItem, setOpenPopover: setOpenPopover, SortPopover: SortPopoverComponent, EditPopover: AddSortPopover, handleDelete: async () => {
|
|
1321
|
-
if (!pivot) {
|
|
1322
|
-
setBaseAst(deepCopy(baseAst));
|
|
1323
|
-
fetchSqlQuery(deepCopy(baseAst));
|
|
1324
|
-
return;
|
|
1325
|
-
}
|
|
1326
|
-
const tempPivot = { ...pivot, sort: false };
|
|
1327
|
-
let dateBucket = undefined;
|
|
1328
|
-
const tempDateRange = dateRanges &&
|
|
1329
|
-
pivot.rowField &&
|
|
1330
|
-
dateRanges[pivot.rowField];
|
|
1331
|
-
if (tempDateRange) {
|
|
1332
|
-
dateBucket = getDateBucketFromRange(tempDateRange.dateRange);
|
|
1333
|
-
}
|
|
1334
|
-
setPivot(tempPivot);
|
|
1335
|
-
setPivotHint('');
|
|
1336
|
-
try {
|
|
1337
|
-
const pivotedData = await generatePivotTable({
|
|
1338
|
-
pivot: tempPivot,
|
|
1339
|
-
rowLimit: -1,
|
|
1340
|
-
dateBucket,
|
|
1341
|
-
report: tempReport,
|
|
1342
|
-
client,
|
|
1343
|
-
uniqueValues: uniqueValues[currentTable],
|
|
1344
|
-
dashboardName,
|
|
1345
|
-
tenants,
|
|
1346
|
-
});
|
|
1347
|
-
setPivotData(pivotedData || []);
|
|
1348
|
-
const formattedRows = formatRows(pivotedData.rows, columns, true, pivot.aggregationType, dateBucket);
|
|
1349
|
-
setFormattedRows(formattedRows);
|
|
1350
|
-
setErrorMessage('');
|
|
1351
|
-
}
|
|
1352
|
-
catch (e) {
|
|
1353
|
-
if (e instanceof Error)
|
|
1354
|
-
setPivotError(e.message);
|
|
1355
|
-
}
|
|
1356
|
-
finally {
|
|
1357
|
-
setTableLoading(false);
|
|
1358
|
-
}
|
|
1579
|
+
}, children: _jsx(SortSentence, { sortField: pivot.sortField, sortDirection: pivot.sortDirection || 'ASC', columns: pivotData?.columns ?? [], setIsPending: () => { }, setEditPopoverKey: () => { }, setActiveEditItem: setActiveEditItem, setOpenPopover: setOpenPopover, SortPopover: SortPopoverComponent, EditPopover: AddSortPopover, handleDelete: async () => {
|
|
1580
|
+
onSortChange({
|
|
1581
|
+
field: pivot.sortField ?? '',
|
|
1582
|
+
direction: pivot.sortDirection ?? 'ASC',
|
|
1583
|
+
}, true);
|
|
1359
1584
|
}, onSave: async (column, direction) => {
|
|
1360
|
-
|
|
1361
|
-
setOpenPopover(null);
|
|
1362
|
-
setBaseAst(deepCopy(baseAst));
|
|
1363
|
-
fetchSqlQuery(deepCopy(baseAst));
|
|
1364
|
-
return;
|
|
1365
|
-
}
|
|
1366
|
-
const sortFieldType = column === (pivot.valueField || 'count')
|
|
1367
|
-
? 'number'
|
|
1368
|
-
: pivot.rowFieldType;
|
|
1369
|
-
const tempPivot = {
|
|
1370
|
-
...pivot,
|
|
1371
|
-
sort: true,
|
|
1372
|
-
sortDirection: direction,
|
|
1373
|
-
sortField: column,
|
|
1374
|
-
sortFieldType: sortFieldType,
|
|
1375
|
-
};
|
|
1376
|
-
setPivot(tempPivot);
|
|
1377
|
-
setPivotHint('');
|
|
1378
|
-
let dateBucket = undefined;
|
|
1379
|
-
const tempDateRange = dateRanges &&
|
|
1380
|
-
pivot.rowField &&
|
|
1381
|
-
dateRanges[pivot.rowField];
|
|
1382
|
-
if (tempDateRange) {
|
|
1383
|
-
dateBucket = getDateBucketFromRange(tempDateRange.dateRange);
|
|
1384
|
-
}
|
|
1385
|
-
try {
|
|
1386
|
-
const pivotedData = await generatePivotTable({
|
|
1387
|
-
pivot: tempPivot,
|
|
1388
|
-
rowLimit: -1,
|
|
1389
|
-
dateBucket,
|
|
1390
|
-
report: tempReport,
|
|
1391
|
-
client,
|
|
1392
|
-
uniqueValues: uniqueValues[currentTable],
|
|
1393
|
-
dashboardName,
|
|
1394
|
-
tenants,
|
|
1395
|
-
});
|
|
1396
|
-
setPivotData(pivotedData || []);
|
|
1397
|
-
const formattedRows = formatRows(pivotedData.rows, columns, true, pivot.aggregationType, dateBucket);
|
|
1398
|
-
setFormattedRows(formattedRows);
|
|
1399
|
-
setErrorMessage('');
|
|
1400
|
-
}
|
|
1401
|
-
catch (e) {
|
|
1402
|
-
if (e instanceof Error)
|
|
1403
|
-
setPivotError(e.message);
|
|
1404
|
-
}
|
|
1585
|
+
onSortChange({ field: column, direction });
|
|
1405
1586
|
}, Select: SelectComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent, disabled: tableLoading || loading }, `sort-sentence-pivot`) })), baseAst && baseAst.orderby && baseAst.orderby.length > 0 && (_jsx("div", { style: {
|
|
1406
1587
|
display: 'flex',
|
|
1407
1588
|
flexDirection: 'column',
|
|
1408
1589
|
gap: 8,
|
|
1409
1590
|
marginBottom: 12,
|
|
1410
|
-
}, children: baseAst.orderby.map((sortData, id) => (_jsx(SortSentence, { sortData: sortData, columns:
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
}
|
|
1416
|
-
const newAst = { ...baseAst };
|
|
1417
|
-
newAst.orderby.splice(id, 1);
|
|
1418
|
-
if (newAst.orderby.length === 0) {
|
|
1419
|
-
newAst.orderby = null;
|
|
1420
|
-
}
|
|
1421
|
-
setBaseAst(deepCopy(newAst));
|
|
1422
|
-
fetchSqlQuery(deepCopy(newAst));
|
|
1591
|
+
}, children: baseAst.orderby.map((sortData, id) => (_jsx(SortSentence, { sortField: sortData.expr?.column || sortData.expr?.value, sortDirection: sortData.type, columns: columns, setIsPending: () => { }, setEditPopoverKey: () => { }, setActiveEditItem: setActiveEditItem, setOpenPopover: setOpenPopover, SortPopover: SortPopoverComponent, EditPopover: AddSortPopover, handleDelete: () => {
|
|
1592
|
+
onSortChange({
|
|
1593
|
+
field: sortData.expr?.column || sortData.expr?.value,
|
|
1594
|
+
direction: sortData.type,
|
|
1595
|
+
}, true);
|
|
1423
1596
|
}, onSave: (column, direction) => {
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
sort: true,
|
|
1431
|
-
sortDirection: direction,
|
|
1432
|
-
sortField: column,
|
|
1433
|
-
sortFieldType: sortFieldType,
|
|
1434
|
-
});
|
|
1435
|
-
setPivotHint('');
|
|
1436
|
-
return;
|
|
1437
|
-
}
|
|
1438
|
-
setActiveEditItem(null);
|
|
1439
|
-
setOpenPopover(null);
|
|
1440
|
-
if (column === '')
|
|
1441
|
-
return;
|
|
1442
|
-
const newAst = { ...baseAst };
|
|
1443
|
-
newAst.orderby[id] = {
|
|
1444
|
-
expr: {
|
|
1445
|
-
type: 'column_ref',
|
|
1446
|
-
table: null,
|
|
1447
|
-
column: column,
|
|
1448
|
-
},
|
|
1449
|
-
type: direction,
|
|
1450
|
-
};
|
|
1451
|
-
// look through the columns
|
|
1452
|
-
setOpenPopover(null);
|
|
1453
|
-
setBaseAst(deepCopy(newAst));
|
|
1454
|
-
fetchSqlQuery(deepCopy(newAst));
|
|
1455
|
-
}, Select: SelectComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent, disabled: tableLoading || loading }, `sort-sentence-${id}`))) })), _jsx(SecondaryButtonComponent, { disabled: !baseAst || !dataDisplayed || loading || tableLoading, onClick: () => {
|
|
1597
|
+
onSortChange({ field: column, direction });
|
|
1598
|
+
}, Select: SelectComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent, disabled: tableLoading || loading }, `sort-sentence-${id}`))) })), _jsx(SecondaryButtonComponent, { disabled: !baseAst ||
|
|
1599
|
+
!dataDisplayed ||
|
|
1600
|
+
loading ||
|
|
1601
|
+
tableLoading ||
|
|
1602
|
+
mssqlSortWarning, onClick: () => {
|
|
1456
1603
|
if (!selectedColumns || selectedColumns.length === 0) {
|
|
1457
1604
|
return;
|
|
1458
1605
|
}
|
|
1459
1606
|
if (!openPopover) {
|
|
1460
1607
|
setOpenPopover('AddSortPopover');
|
|
1461
1608
|
}
|
|
1462
|
-
}, label: 'Add sort' }), _jsx("div", { style: {
|
|
1609
|
+
}, label: 'Add sort', tooltipText: mssqlSortWarning }), _jsx("div", { style: {
|
|
1463
1610
|
position: 'relative',
|
|
1464
1611
|
...(openPopover === 'AddSortPopover' && { top: 12 }),
|
|
1465
1612
|
}, children: _jsx(PopoverComponent, { isOpen: openPopover === 'AddSortPopover', setIsOpen: (isOpen) => {
|
|
@@ -1467,14 +1614,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1467
1614
|
setActiveEditItem(null);
|
|
1468
1615
|
setOpenPopover(null);
|
|
1469
1616
|
}
|
|
1470
|
-
}, popoverTitle: "Sort by", popoverChildren: _jsx(AddSortPopover, { columns:
|
|
1471
|
-
? pivot.columnField
|
|
1472
|
-
? [`.${pivot.rowField}`]
|
|
1473
|
-
: [
|
|
1474
|
-
`.${pivot.rowField}`,
|
|
1475
|
-
`.${pivot.valueField || 'count'}`,
|
|
1476
|
-
]
|
|
1477
|
-
: selectedColumns, Select: SelectComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent, onSave: async (column, direction) => {
|
|
1617
|
+
}, popoverTitle: "Sort by", popoverChildren: _jsx(AddSortPopover, { columns: pivotData ? pivotData.columns : columns, Select: SelectComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent, onSave: async (column, direction) => {
|
|
1478
1618
|
if (column === '')
|
|
1479
1619
|
return;
|
|
1480
1620
|
if (pivot) {
|
|
@@ -1506,7 +1646,11 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1506
1646
|
uniqueValues: uniqueValues[currentTable],
|
|
1507
1647
|
dashboardName,
|
|
1508
1648
|
tenants,
|
|
1649
|
+
additionalProcessing: {
|
|
1650
|
+
page: REPORT_BUILDER_PAGINATION,
|
|
1651
|
+
},
|
|
1509
1652
|
});
|
|
1653
|
+
resetProcessing();
|
|
1510
1654
|
setErrorMessage('');
|
|
1511
1655
|
setPivotData(pivotedData || []);
|
|
1512
1656
|
const formattedRows = formatRows(pivotedData.rows, columns, true, pivot.aggregationType, dateBucket);
|
|
@@ -1520,50 +1664,43 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1520
1664
|
setBaseAst(deepCopy(baseAst));
|
|
1521
1665
|
return;
|
|
1522
1666
|
}
|
|
1523
|
-
const newAst = { ...baseAst };
|
|
1524
|
-
if (!newAst.orderby)
|
|
1525
|
-
newAst.orderby = [];
|
|
1526
|
-
const existingSortIndex = newAst.orderby.findIndex((item) => getFieldFromExpression(item.expr) === column);
|
|
1527
|
-
if (existingSortIndex !== -1) {
|
|
1528
|
-
newAst.orderby[existingSortIndex] = {
|
|
1529
|
-
expr: { type: 'column_ref', column },
|
|
1530
|
-
type: direction,
|
|
1531
|
-
};
|
|
1532
|
-
}
|
|
1533
1667
|
else {
|
|
1534
|
-
newAst
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1668
|
+
const newAst = { ...baseAst };
|
|
1669
|
+
if (!newAst.orderby)
|
|
1670
|
+
newAst.orderby = [];
|
|
1671
|
+
const existingSortIndex = newAst.orderby.findIndex((item) => getFieldFromExpression(item.expr) === column);
|
|
1672
|
+
if (existingSortIndex !== -1) {
|
|
1673
|
+
newAst.orderby[existingSortIndex] = {
|
|
1674
|
+
expr: { type: 'column_ref', column },
|
|
1675
|
+
type: direction,
|
|
1676
|
+
};
|
|
1677
|
+
}
|
|
1678
|
+
else {
|
|
1679
|
+
newAst.orderby.push({
|
|
1680
|
+
expr: { type: 'column_ref', column },
|
|
1681
|
+
type: direction,
|
|
1682
|
+
});
|
|
1683
|
+
}
|
|
1684
|
+
// look through the columns
|
|
1685
|
+
setOpenPopover(null);
|
|
1686
|
+
setBaseAst(deepCopy(newAst));
|
|
1687
|
+
fetchSqlQuery(deepCopy(newAst));
|
|
1538
1688
|
}
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
} }) }) })] }), _jsxs("div", { style: { width: '100%' }, children: [_jsx(SidebarHeadingComponent, { label: "Limit" }), baseAst && baseAst.limit && baseAst.limit.value?.length > 0 ? (_jsx("div", { style: {
|
|
1689
|
+
} }) }) })] }), _jsxs("div", { style: { width: '100%' }, children: [_jsx(SidebarHeadingComponent, { label: "Limit" }), (baseAst &&
|
|
1690
|
+
((baseAst.limit && baseAst.limit.value?.length > 0) ||
|
|
1691
|
+
(baseAst.top && baseAst.top.value))) ||
|
|
1692
|
+
pivot?.rowLimit ? (_jsx("div", { style: {
|
|
1544
1693
|
display: 'flex',
|
|
1545
1694
|
flexDirection: 'column',
|
|
1546
1695
|
gap: 8,
|
|
1547
1696
|
marginBottom: 12,
|
|
1548
|
-
}, children: _jsx(LimitSentence, { limit: baseAst.limit
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1697
|
+
}, children: _jsx(LimitSentence, { limit: baseAst.limit?.value?.[0]?.value ||
|
|
1698
|
+
baseAst.top?.value ||
|
|
1699
|
+
pivot?.rowLimit ||
|
|
1700
|
+
0, setOpenPopover: setOpenPopover, LimitPopover: LimitPopoverComponent, EditPopover: AddLimitPopover, handleDelete: () => {
|
|
1701
|
+
onLimitChange(null);
|
|
1553
1702
|
}, onSave: (limit) => {
|
|
1554
|
-
|
|
1555
|
-
newAst.limit = {
|
|
1556
|
-
seperator: '',
|
|
1557
|
-
value: [
|
|
1558
|
-
{
|
|
1559
|
-
type: 'number',
|
|
1560
|
-
value: limit,
|
|
1561
|
-
},
|
|
1562
|
-
],
|
|
1563
|
-
};
|
|
1564
|
-
setOpenPopover(null);
|
|
1565
|
-
setBaseAst(deepCopy(newAst));
|
|
1566
|
-
fetchSqlQuery(deepCopy(newAst));
|
|
1703
|
+
onLimitChange(limit);
|
|
1567
1704
|
}, TextInput: TextInputComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent, disabled: tableLoading || loading }) })) : (_jsxs(_Fragment, { children: [_jsx(SecondaryButtonComponent, { disabled: !baseAst || !dataDisplayed || loading || tableLoading, onClick: () => {
|
|
1568
1705
|
if (!selectedColumns || selectedColumns.length === 0) {
|
|
1569
1706
|
return;
|
|
@@ -1583,19 +1720,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1583
1720
|
setOpenPopover(null);
|
|
1584
1721
|
}
|
|
1585
1722
|
}, popoverTitle: "Add limit", popoverChildren: _jsx(AddLimitPopover, { TextInputComponent: TextInputComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent, onSave: (limit) => {
|
|
1586
|
-
|
|
1587
|
-
newAst.limit = {
|
|
1588
|
-
seperator: '',
|
|
1589
|
-
value: [
|
|
1590
|
-
{
|
|
1591
|
-
type: 'number',
|
|
1592
|
-
value: Number(limit),
|
|
1593
|
-
},
|
|
1594
|
-
],
|
|
1595
|
-
};
|
|
1596
|
-
setOpenPopover(null);
|
|
1597
|
-
setBaseAst(deepCopy(newAst));
|
|
1598
|
-
fetchSqlQuery(deepCopy(newAst));
|
|
1723
|
+
onLimitChange(limit);
|
|
1599
1724
|
} }) }) })] }))] })] }), _jsxs(ContainerComponent, { children: [isAIEnabled && (_jsx("form", { ref: askAIContainerRef, onSubmit: (event) => {
|
|
1600
1725
|
event.preventDefault();
|
|
1601
1726
|
}, style: {
|
|
@@ -1611,7 +1736,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1611
1736
|
? 'Ask a follow-up question...'
|
|
1612
1737
|
: 'Ask a question...' }), _jsx(ButtonComponent, { onClick: () => {
|
|
1613
1738
|
fetchAstFromPromptHelper();
|
|
1614
|
-
}, isLoading: askAILoading && !baseAst, label: 'Ask AI' }), ((baseAst && dataDisplayed) || initialLoad) && !reportId && (_jsx(SecondaryButtonComponent, { label: 'New report', onClick: clearAllState }))] }) })), baseAst && (_jsx(TableComponent, { isLoading: tableLoading || (loading && errorMessage.length === 0), rows: formattedRows, rowCount: pivot ?
|
|
1739
|
+
}, isLoading: askAILoading && !baseAst, label: 'Ask AI' }), ((baseAst && dataDisplayed) || initialLoad) && !reportId && (_jsx(SecondaryButtonComponent, { label: 'New report', onClick: clearAllState }))] }) })), baseAst && (_jsx(TableComponent, { isLoading: tableLoading || (loading && errorMessage.length === 0), rows: formattedRows, rowCount: pivot ? pivotData?.rowCount : numberOfRows, rowCountIsLoading: rowCountIsLoading, rowsPerPage: 20, columns: pivot
|
|
1615
1740
|
? pivotData?.columns || emptyPivotColumns()
|
|
1616
1741
|
: enforceOrderOnColumns(Object.keys(rows[0] ?? {})).map((c) => {
|
|
1617
1742
|
return {
|
|
@@ -1620,7 +1745,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1620
1745
|
};
|
|
1621
1746
|
}), onPageChange: onPageChange, onSortChange: (sort) => {
|
|
1622
1747
|
onSortChange(sort);
|
|
1623
|
-
}, containerStyle: {
|
|
1748
|
+
}, disableSort: !!mssqlSortWarning, containerStyle: {
|
|
1624
1749
|
maxHeight: Math.max(window.innerHeight - 290, 75 + Math.min(Math.max(10, rows.length), 20) * 37),
|
|
1625
1750
|
} })), _jsxs("div", { style: {
|
|
1626
1751
|
display: 'flex',
|
|
@@ -1668,8 +1793,10 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1668
1793
|
rows: rows,
|
|
1669
1794
|
pivotRows: pivotData?.rows,
|
|
1670
1795
|
pivotColumns: pivotData?.columns,
|
|
1671
|
-
|
|
1672
|
-
|
|
1796
|
+
pivotRowCount: pivotData?.rowCount,
|
|
1797
|
+
pivotQuery: pivotData?.pivotQuery,
|
|
1798
|
+
comparisonPivotQuery: pivotData?.comparisonPivotQuery,
|
|
1799
|
+
flags: reportInfo?.flags ?? tempReport?.flags,
|
|
1673
1800
|
}
|
|
1674
1801
|
: {
|
|
1675
1802
|
...tempReport,
|