@quillsql/react 2.11.25 → 2.11.26
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.map +1 -1
- package/dist/cjs/Chart.js +15 -12
- package/dist/cjs/ChartBuilder.d.ts +7 -20
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +25 -25
- package/dist/cjs/ChartEditor.d.ts.map +1 -1
- package/dist/cjs/ChartEditor.js +3 -3
- package/dist/cjs/Dashboard.d.ts +2 -1
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.d.ts +6 -4
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +208 -126
- package/dist/cjs/SQLEditor.d.ts +4 -11
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +31 -97
- package/dist/cjs/components/Dashboard/DashboardFilter.js +1 -1
- package/dist/cjs/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/MetricComponent.js +9 -12
- package/dist/cjs/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/TableComponent.js +12 -10
- package/dist/cjs/components/QuillTable.d.ts +4 -1
- package/dist/cjs/components/QuillTable.d.ts.map +1 -1
- package/dist/cjs/components/QuillTable.js +1 -1
- package/dist/cjs/components/ReportBuilder/convert.d.ts +2 -2
- package/dist/cjs/internals/ReportBuilder/PivotList.d.ts +27 -24
- package/dist/cjs/internals/ReportBuilder/PivotList.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotList.js +9 -7
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts +9 -2
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.js +46 -41
- package/dist/cjs/models/Columns.d.ts +11 -0
- package/dist/cjs/models/Columns.d.ts.map +1 -0
- package/dist/cjs/models/Columns.js +2 -0
- package/dist/cjs/models/Tables.d.ts +0 -8
- package/dist/cjs/models/Tables.d.ts.map +1 -1
- package/dist/cjs/utils/astProcessing.d.ts +3 -0
- package/dist/cjs/utils/astProcessing.d.ts.map +1 -0
- package/dist/cjs/utils/astProcessing.js +20 -0
- package/dist/cjs/utils/columnProcessing.d.ts +9 -0
- package/dist/cjs/utils/columnProcessing.d.ts.map +1 -0
- package/dist/cjs/utils/columnProcessing.js +207 -0
- package/dist/cjs/utils/dashboard.js +9 -9
- package/dist/cjs/utils/pivotProcessing.d.ts +2 -1
- package/dist/cjs/utils/pivotProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/pivotProcessing.js +3 -8
- package/dist/cjs/utils/tableProcessing.d.ts +2 -2
- package/dist/cjs/utils/tableProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/tableProcessing.js +1 -3
- 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 +12 -1
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +15 -12
- package/dist/esm/ChartBuilder.d.ts +7 -20
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +25 -25
- package/dist/esm/ChartEditor.d.ts.map +1 -1
- package/dist/esm/ChartEditor.js +3 -3
- package/dist/esm/Dashboard.d.ts +2 -1
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.d.ts +6 -4
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +204 -122
- package/dist/esm/SQLEditor.d.ts +4 -11
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +30 -95
- package/dist/esm/components/Dashboard/DashboardFilter.js +1 -1
- package/dist/esm/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/MetricComponent.js +9 -12
- package/dist/esm/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/TableComponent.js +12 -10
- package/dist/esm/components/QuillTable.d.ts +4 -1
- package/dist/esm/components/QuillTable.d.ts.map +1 -1
- package/dist/esm/components/QuillTable.js +1 -1
- package/dist/esm/components/ReportBuilder/convert.d.ts +2 -2
- package/dist/esm/internals/ReportBuilder/PivotList.d.ts +27 -24
- package/dist/esm/internals/ReportBuilder/PivotList.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotList.js +9 -7
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts +9 -2
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.js +48 -43
- package/dist/esm/models/Columns.d.ts +11 -0
- package/dist/esm/models/Columns.d.ts.map +1 -0
- package/dist/esm/models/Columns.js +1 -0
- package/dist/esm/models/Tables.d.ts +0 -8
- package/dist/esm/models/Tables.d.ts.map +1 -1
- package/dist/esm/utils/astProcessing.d.ts +3 -0
- package/dist/esm/utils/astProcessing.d.ts.map +1 -0
- package/dist/esm/utils/astProcessing.js +16 -0
- package/dist/esm/utils/columnProcessing.d.ts +9 -0
- package/dist/esm/utils/columnProcessing.d.ts.map +1 -0
- package/dist/esm/utils/columnProcessing.js +201 -0
- package/dist/esm/utils/dashboard.js +9 -9
- package/dist/esm/utils/pivotProcessing.d.ts +2 -1
- package/dist/esm/utils/pivotProcessing.d.ts.map +1 -1
- package/dist/esm/utils/pivotProcessing.js +3 -8
- package/dist/esm/utils/tableProcessing.d.ts +2 -2
- package/dist/esm/utils/tableProcessing.d.ts.map +1 -1
- package/dist/esm/utils/tableProcessing.js +1 -3
- 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 +11 -0
- package/package.json +1 -1
- package/dist/cjs/utils/types.d.ts +0 -4
- package/dist/cjs/utils/types.d.ts.map +0 -1
- package/dist/cjs/utils/types.js +0 -52
- package/dist/cjs/utils/valueFormatterCSV.d.ts +0 -17
- package/dist/cjs/utils/valueFormatterCSV.d.ts.map +0 -1
- package/dist/cjs/utils/valueFormatterCSV.js +0 -99
- package/dist/esm/utils/types.d.ts +0 -4
- package/dist/esm/utils/types.d.ts.map +0 -1
- package/dist/esm/utils/types.js +0 -48
- package/dist/esm/utils/valueFormatterCSV.d.ts +0 -17
- package/dist/esm/utils/valueFormatterCSV.d.ts.map +0 -1
- package/dist/esm/utils/valueFormatterCSV.js +0 -95
|
@@ -32,12 +32,14 @@ const AddLimitPopover_1 = require("./components/ReportBuilder/AddLimitPopover");
|
|
|
32
32
|
const width_1 = require("./utils/width");
|
|
33
33
|
const QuillSelect_1 = require("./components/QuillSelect");
|
|
34
34
|
const QuillCard_1 = require("./components/QuillCard");
|
|
35
|
-
const SQLEditor_1 = require("./SQLEditor");
|
|
36
35
|
const dataFetcher_1 = require("./utils/dataFetcher");
|
|
37
36
|
const valueFormatter_1 = require("./utils/valueFormatter");
|
|
38
37
|
const pivotProcessing_1 = require("./utils/pivotProcessing");
|
|
39
38
|
const tableProcessing_1 = require("./utils/tableProcessing");
|
|
40
39
|
const useQuill_1 = require("./hooks/useQuill");
|
|
40
|
+
const dataFetcher_2 = require("./utils/dataFetcher");
|
|
41
|
+
const columnProcessing_1 = require("./utils/columnProcessing");
|
|
42
|
+
const astProcessing_1 = require("./utils/astProcessing");
|
|
41
43
|
exports.QUILL_SERVER = process.env.QUILL_SERVER_HOST ?? 'https://quill-344421.uc.r.appspot.com';
|
|
42
44
|
/**
|
|
43
45
|
* Quill Report Builder
|
|
@@ -70,8 +72,8 @@ exports.QUILL_SERVER = process.env.QUILL_SERVER_HOST ?? 'https://quill-344421.uc
|
|
|
70
72
|
* ### Report Builder API
|
|
71
73
|
* @see https://docs.quillsql.com/components/report-builder
|
|
72
74
|
*/
|
|
73
|
-
function ReportBuilder({ initialTableName = '',
|
|
74
|
-
const { data:
|
|
75
|
+
function ReportBuilder({ initialTableName = '', onSubmitEditReport = (_) => void null, onSubmitCreateReport = (_) => void null, destinationDashboard = undefined, organizationName = '', ButtonComponent = UiComponents_1.MemoizedButton, SecondaryButtonComponent = UiComponents_1.MemoizedSecondaryButton, DeleteButtonComponent = UiComponents_1.MemoizedDeleteButton, ModalComponent = UiComponents_1.MemoizedModal, TextInputComponent = UiComponents_2.QuillTextInput, SelectComponent = QuillSelect_1.QuillSelectComponent, TableComponent = UiComponents_1.QuillTableComponent, PopoverComponent = UiComponents_1.MemoizedPopover, TabsComponent = UiComponents_1.QuillTabs, CheckboxComponent = UiComponents_1.MemoizedCheckbox, SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer, SelectColumnComponent = ui_1.QuillSelectColumn, DraggableColumnComponent = ui_1.QuillDraggableColumn, SidebarHeadingComponent = ui_1.QuillSidebarHeading, FilterPopoverComponent = ui_1.QuillFilterPopover, SortPopoverComponent = ui_1.QuillSortPopover, LimitPopoverComponent = ui_1.QuillLimitPopover, CardComponent = QuillCard_1.QuillCard, LabelComponent = UiComponents_1.MemoizedLabel, HeaderComponent = UiComponents_1.MemoizedHeader, SubHeaderComponent = UiComponents_1.MemoizedSubHeader, TextComponent = UiComponents_1.MemoizedText, ErrorMessageComponent = UiComponents_1.QuillErrorMessageComponent, ChartBuilderInputRowContainer = UiComponents_1.QuillChartBuilderInputRowContainer, ChartBuilderInputColumnContainer = UiComponents_1.QuillChartBuilderInputColumnContainer, PivotRowContainer = UiComponents_1.QuillPivotRowContainer, PivotColumnContainer = UiComponents_1.QuillPivotColumnContainer, ColumnSearchEmptyState = UiComponents_1.QuillColumnSearchEmptyState, ChartBuilderFormContainer = UiComponents_1.QuillChartBuilderFormContainer, isAdminEnabled = false, isAIEnabled = true, showChartBuilderTableFormatOptions = true, containerStyle, className, pivotRecommendationsEnabled = true, initialReportId, }) {
|
|
76
|
+
const { data: dashboardItem } = (0, useQuill_1.useQuill)(initialReportId || '');
|
|
75
77
|
const [aiPrompt, setAiPrompt] = (0, react_1.useState)('');
|
|
76
78
|
const [errorMessage, setErrorMessage] = (0, react_1.useState)('');
|
|
77
79
|
const [baseAst, setBaseAst] = (0, react_1.useState)(null);
|
|
@@ -92,7 +94,7 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
92
94
|
const [dataDisplayed, setDataDisplayed] = (0, react_1.useState)(false);
|
|
93
95
|
const [rows, setRows] = (0, react_1.useState)([]);
|
|
94
96
|
const [formattedRows, setFormattedRows] = (0, react_1.useState)([]);
|
|
95
|
-
const [
|
|
97
|
+
const [columns, setColumns] = (0, react_1.useState)([]);
|
|
96
98
|
const [topLevelBinaryOperator, setTopLevelBinaryOperator] = (0, react_1.useState)('AND');
|
|
97
99
|
const [editPopoverKey, setEditPopoverKey] = (0, react_1.useState)(null);
|
|
98
100
|
const [uniqueValues, setUniqueValues] = (0, react_1.useState)({});
|
|
@@ -103,8 +105,9 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
103
105
|
const [pivotPopUpTitle, setPivotPopUpTitle] = (0, react_1.useState)('Add pivot');
|
|
104
106
|
const [showPivotPopover, setShowPivotPopover] = (0, react_1.useState)(false);
|
|
105
107
|
const [isEdittingPivot, setIsEdittingPivot] = (0, react_1.useState)(false);
|
|
108
|
+
const [initalChartLoad, setInitalChartLoad] = (0, react_1.useState)(false);
|
|
106
109
|
const [selectedPivotIndex, setSelectedPivotIndex] = (0, react_1.useState)(-1);
|
|
107
|
-
const [initialLoad, setInitialLoad] = (0, react_1.useState)(!!initialTableName || !!
|
|
110
|
+
const [initialLoad, setInitialLoad] = (0, react_1.useState)(!!initialTableName || !!initialReportId);
|
|
108
111
|
const [currentTable, setCurrentTable] = (0, react_1.useState)(initialTableName || '');
|
|
109
112
|
const parentRef = (0, react_1.useRef)(null);
|
|
110
113
|
const askAIContainerRef = (0, react_1.useRef)(null);
|
|
@@ -174,7 +177,7 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
174
177
|
setIsPending(false);
|
|
175
178
|
setDataDisplayed(false);
|
|
176
179
|
setRows([]);
|
|
177
|
-
|
|
180
|
+
setColumns([]);
|
|
178
181
|
setTopLevelBinaryOperator('AND');
|
|
179
182
|
setEditPopoverKey(null);
|
|
180
183
|
setErrorMessage('');
|
|
@@ -196,6 +199,50 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
196
199
|
setActiveEditItem(getByKey(formData, activePath));
|
|
197
200
|
}
|
|
198
201
|
}, [formData]);
|
|
202
|
+
const formatRows = (rows, columns, pivot, aggregationType) => {
|
|
203
|
+
const copiedRows = (0, util_1.deepCopy)(rows);
|
|
204
|
+
if (pivot) {
|
|
205
|
+
const formattedRows = copiedRows.map((row) => {
|
|
206
|
+
const formattedRow = row;
|
|
207
|
+
Object.keys(row).forEach((key, index) => {
|
|
208
|
+
let column = columns.find((c) => c.field === key);
|
|
209
|
+
let format = 'string';
|
|
210
|
+
if (!column) {
|
|
211
|
+
format =
|
|
212
|
+
aggregationType === 'count'
|
|
213
|
+
? 'whole_number'
|
|
214
|
+
: 'two_decimal_places';
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
format = valueFormatter_1.DATE_FORMAT_TYPES.includes(column.format)
|
|
218
|
+
? 'date'
|
|
219
|
+
: 'string';
|
|
220
|
+
}
|
|
221
|
+
const formattedValue = (0, valueFormatter_1.quillFormat)({
|
|
222
|
+
value: row[key],
|
|
223
|
+
format,
|
|
224
|
+
});
|
|
225
|
+
formattedRow[key] = formattedValue;
|
|
226
|
+
});
|
|
227
|
+
return formattedRow;
|
|
228
|
+
});
|
|
229
|
+
return formattedRows;
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
const formattedRows = copiedRows.map((row) => {
|
|
233
|
+
return columns.reduce((formattedRow, column) => {
|
|
234
|
+
// Apply the format function to each field in the row
|
|
235
|
+
const formattedValue = (0, valueFormatter_1.quillFormat)({
|
|
236
|
+
value: row[column.field],
|
|
237
|
+
format: column.format,
|
|
238
|
+
});
|
|
239
|
+
formattedRow[column.field] = formattedValue;
|
|
240
|
+
return formattedRow;
|
|
241
|
+
}, {});
|
|
242
|
+
});
|
|
243
|
+
return formattedRows;
|
|
244
|
+
}
|
|
245
|
+
};
|
|
199
246
|
const getByKey = (formData, path) => {
|
|
200
247
|
if (!path)
|
|
201
248
|
return (0, util_1.deepCopy)(formData);
|
|
@@ -265,7 +312,7 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
265
312
|
const data = await response.json();
|
|
266
313
|
setActiveQuery(data.query);
|
|
267
314
|
if (fetchData) {
|
|
268
|
-
fetchUponChange(ast, formData
|
|
315
|
+
fetchUponChange(ast, formData);
|
|
269
316
|
}
|
|
270
317
|
}
|
|
271
318
|
catch (error) {
|
|
@@ -329,42 +376,81 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
329
376
|
};
|
|
330
377
|
(0, react_1.useEffect)(() => {
|
|
331
378
|
const loadChart = async () => {
|
|
332
|
-
|
|
379
|
+
setInitalChartLoad(true);
|
|
380
|
+
if (!dashboardItem || dashboardItem.referencedTables.length !== 1) {
|
|
381
|
+
setInitalChartLoad(false);
|
|
333
382
|
return;
|
|
334
383
|
}
|
|
335
|
-
const
|
|
336
|
-
if (
|
|
384
|
+
const tableName = dashboardItem.referencedTables[0];
|
|
385
|
+
if (!tableName) {
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
const resp = await (0, dataFetcher_2.getDataFromCloud)(client, `astify`, {
|
|
389
|
+
query: dashboardItem.queryString,
|
|
390
|
+
});
|
|
391
|
+
const ast = resp.ast.select ? resp.ast.select : resp.ast;
|
|
392
|
+
const initialRows = await fetchUponChange(ast, undefined);
|
|
393
|
+
const convertedAst = (0, astProcessing_1.processStarColumn)(ast, dashboardItem.columns);
|
|
394
|
+
setBaseAst(convertedAst);
|
|
395
|
+
setFormData((0, util_1.deepCopy)(convertedAst.where));
|
|
396
|
+
setFormattedRows([]);
|
|
397
|
+
setActiveQuery(dashboardItem.queryString);
|
|
398
|
+
// const initialRows = await handleAsk(dashboardItem.queryString);
|
|
399
|
+
const stringColumns = dashboardItem.columns.filter((column) => {
|
|
400
|
+
return column.format === 'string';
|
|
401
|
+
});
|
|
402
|
+
if (stringColumns.length !== 0 && tableName) {
|
|
403
|
+
const stringNames = stringColumns.map((column) => column.field);
|
|
404
|
+
const newUniqueValues = await (0, tableProcessing_1.getUniqueValuesByColumns)(stringColumns, `Select ${stringNames.join(', ')} from ${tableName}`, [], client);
|
|
405
|
+
const joinedUniqueValues = (0, util_1.deepCopy)(uniqueValues);
|
|
406
|
+
joinedUniqueValues[tableName] = newUniqueValues;
|
|
407
|
+
setUniqueValues(joinedUniqueValues);
|
|
408
|
+
}
|
|
409
|
+
if (dashboardItem.pivot) {
|
|
337
410
|
// @ts-ignore
|
|
338
|
-
setPivotRowField(
|
|
411
|
+
setPivotRowField(dashboardItem.pivot.rowField);
|
|
339
412
|
// @ts-ignore
|
|
340
|
-
setPivotAggregation(
|
|
413
|
+
setPivotAggregation(dashboardItem.pivot.aggregationType);
|
|
341
414
|
// @ts-ignore
|
|
342
|
-
setPivotColumnField(
|
|
415
|
+
setPivotColumnField(dashboardItem.pivot.columnField);
|
|
343
416
|
// @ts-ignore
|
|
344
|
-
setPivotValueField(
|
|
345
|
-
setPivot(
|
|
346
|
-
const pivotedData = (0, PivotModal_1.generatePivotTable)(
|
|
347
|
-
//@ts-ignore
|
|
348
|
-
initialData.pivot, initialRows, [null, null, null], false);
|
|
417
|
+
setPivotValueField(dashboardItem.pivot.valueField);
|
|
418
|
+
setPivot(dashboardItem.pivot);
|
|
419
|
+
const pivotedData = (0, PivotModal_1.generatePivotTable)(dashboardItem.pivot, initialRows, undefined, false);
|
|
349
420
|
setPivotData(pivotedData || []);
|
|
421
|
+
const formattedRows = formatRows(pivotedData.rows, dashboardItem.columns, true,
|
|
422
|
+
// @ts-ignore
|
|
423
|
+
dashboardItem.pivot.aggregationType);
|
|
424
|
+
setFormattedRows(formattedRows);
|
|
350
425
|
}
|
|
426
|
+
else {
|
|
427
|
+
const formattedRows = formatRows(dashboardItem.rows, dashboardItem.columns);
|
|
428
|
+
setFormattedRows(formattedRows);
|
|
429
|
+
}
|
|
430
|
+
setCurrentTable(tableName);
|
|
431
|
+
// This handles a flashing issue
|
|
432
|
+
setTimeout(() => {
|
|
433
|
+
setInitalChartLoad(false);
|
|
434
|
+
}, 500);
|
|
351
435
|
};
|
|
352
|
-
if (
|
|
436
|
+
if (dashboardItem && dashboardItem.referencedTables.length === 1) {
|
|
353
437
|
loadChart();
|
|
354
438
|
}
|
|
355
|
-
}, [
|
|
439
|
+
}, [dashboardItem]);
|
|
356
440
|
(0, react_1.useEffect)(() => {
|
|
357
441
|
const loadTable = async (tables) => {
|
|
358
442
|
if (!tables)
|
|
359
443
|
return;
|
|
360
444
|
setLoading(true);
|
|
361
|
-
const tableInfo =
|
|
445
|
+
const tableInfo = tables.find((tableInfo) => tableInfo.name === initialTableName);
|
|
362
446
|
if (tableInfo) {
|
|
363
|
-
const
|
|
447
|
+
const convertedStringColumns = tableInfo.columns
|
|
448
|
+
.filter((column) => {
|
|
364
449
|
return (0, ast_1.isTextColumnType)(column.fieldType);
|
|
365
|
-
})
|
|
366
|
-
|
|
367
|
-
const
|
|
450
|
+
})
|
|
451
|
+
.map((column) => (0, columnProcessing_1.convertColumnInfoToColumnInternal)(column));
|
|
452
|
+
const stringNames = convertedStringColumns.map((column) => column.field);
|
|
453
|
+
const newUniqueValues = await (0, tableProcessing_1.getUniqueValuesByColumns)(convertedStringColumns, `Select ${stringNames.join(', ')} from ${initialTableName}`, [], client);
|
|
368
454
|
const joinedUniqueValues = (0, util_1.deepCopy)(uniqueValues);
|
|
369
455
|
joinedUniqueValues[initialTableName] = newUniqueValues;
|
|
370
456
|
if ((0, crypto_1.hashCode)(uniqueValues) !== (0, crypto_1.hashCode)(joinedUniqueValues)) {
|
|
@@ -431,7 +517,7 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
431
517
|
return -1;
|
|
432
518
|
return 0;
|
|
433
519
|
})));
|
|
434
|
-
if (initialTableName
|
|
520
|
+
if (initialTableName) {
|
|
435
521
|
await loadTable(tables);
|
|
436
522
|
}
|
|
437
523
|
setLoadingSchema(false);
|
|
@@ -444,7 +530,7 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
444
530
|
if (schemaTables.length === 0) {
|
|
445
531
|
fetchSchema();
|
|
446
532
|
}
|
|
447
|
-
}, [schemaTables, initialTableName,
|
|
533
|
+
}, [schemaTables, initialTableName, initialReportId]);
|
|
448
534
|
const updateFormData = (updates, { isDeletion = false, isInsertion = false, isReplaceSubtree = false, isAddVariant = false, isDeleteVariant = false, topLevelBinOp = 'OR', isCondition = undefined, }) => {
|
|
449
535
|
// Function to immutably update or delete nodes based on their path
|
|
450
536
|
// TODO: fix the following horible code
|
|
@@ -807,12 +893,7 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
807
893
|
* @returns the fieldType string or undefined if not found.
|
|
808
894
|
*/
|
|
809
895
|
const getColumnTypeByName = (columnName) => {
|
|
810
|
-
const
|
|
811
|
-
if (field)
|
|
812
|
-
return (0, util_1.getPostgresBasicType)(field);
|
|
813
|
-
const column = schemaTables
|
|
814
|
-
.flatMap((t) => t.columns)
|
|
815
|
-
.find((c) => c.name === columnName);
|
|
896
|
+
const column = columns.find((col) => col.field === columnName);
|
|
816
897
|
return column?.fieldType;
|
|
817
898
|
};
|
|
818
899
|
const emptyPivotColumns = () => {
|
|
@@ -1679,9 +1760,10 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
1679
1760
|
justifyContent: 'end',
|
|
1680
1761
|
}, children: (0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: onSave, label: 'Add condition' }) })] }));
|
|
1681
1762
|
};
|
|
1682
|
-
const fetchUponChange = async (baseAst, newFormData
|
|
1763
|
+
const fetchUponChange = async (baseAst, newFormData) => {
|
|
1683
1764
|
// if newFormData is null still use it
|
|
1684
1765
|
const curFormData = newFormData !== undefined ? newFormData : formData;
|
|
1766
|
+
let rows;
|
|
1685
1767
|
if ((curFormData || baseAst) && !loading) {
|
|
1686
1768
|
try {
|
|
1687
1769
|
setLoading(true);
|
|
@@ -1696,16 +1778,19 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
1696
1778
|
};
|
|
1697
1779
|
const cloudBody = {};
|
|
1698
1780
|
const data2 = await (0, dataFetcher_1.getData)(client, 'dashquery', 'same-origin', hostedBody, cloudBody);
|
|
1781
|
+
rows = data2.rows;
|
|
1699
1782
|
const tables = (0, ast_1.getTableNames)(baseAst);
|
|
1700
1783
|
const table = tables.length >= 1 ? tables[0] : initialTableName;
|
|
1701
1784
|
if (table !== currentTable) {
|
|
1702
1785
|
const tableInfo = schemaTables.find((tableInfo) => tableInfo.name === table);
|
|
1703
1786
|
if (tableInfo) {
|
|
1704
|
-
const
|
|
1787
|
+
const convertedStringColumns = tableInfo.columns
|
|
1788
|
+
.filter((column) => {
|
|
1705
1789
|
return (0, ast_1.isTextColumnType)(column.fieldType);
|
|
1706
|
-
})
|
|
1707
|
-
|
|
1708
|
-
const
|
|
1790
|
+
})
|
|
1791
|
+
.map((column) => (0, columnProcessing_1.convertColumnInfoToColumnInternal)(column));
|
|
1792
|
+
const stringNames = convertedStringColumns.map((column) => column.field);
|
|
1793
|
+
const newUniqueValues = await (0, tableProcessing_1.getUniqueValuesByColumns)(convertedStringColumns, `Select ${stringNames.join(', ')} from ${table}`, rows, client);
|
|
1709
1794
|
const joinedUniqueValues = (0, util_1.deepCopy)(uniqueValues);
|
|
1710
1795
|
joinedUniqueValues[table] = newUniqueValues;
|
|
1711
1796
|
if ((0, crypto_1.hashCode)(uniqueValues) !== (0, crypto_1.hashCode)(joinedUniqueValues)) {
|
|
@@ -1718,22 +1803,13 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
1718
1803
|
if (pivot) {
|
|
1719
1804
|
// check if any of the pivot fields aren't in the data2.fields array
|
|
1720
1805
|
if (!isValidPivot(data2.fields)) {
|
|
1721
|
-
const processedFields = data2.fields.map((elem) => (0,
|
|
1806
|
+
const processedFields = data2.fields.map((elem) => (0, columnProcessing_1.convertPostgresColumn)(elem));
|
|
1722
1807
|
setPivot(null);
|
|
1723
1808
|
setPivotData(null);
|
|
1724
1809
|
setRows(data2.rows);
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
// Apply the format function to each field in the row
|
|
1729
|
-
const formattedValue = (0, valueFormatter_1.quillFormat)({
|
|
1730
|
-
value: row[column.field],
|
|
1731
|
-
format: column.format,
|
|
1732
|
-
});
|
|
1733
|
-
formattedRow[column.field] = formattedValue;
|
|
1734
|
-
return formattedRow;
|
|
1735
|
-
}, {});
|
|
1736
|
-
}));
|
|
1810
|
+
setColumns(processedFields);
|
|
1811
|
+
const formattedRows = formatRows(data2.rows, processedFields, false);
|
|
1812
|
+
setFormattedRows(formattedRows);
|
|
1737
1813
|
return;
|
|
1738
1814
|
}
|
|
1739
1815
|
// Do all of this to make sure we have the right unique columns when applying a pivot
|
|
@@ -1743,39 +1819,27 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
1743
1819
|
return acc;
|
|
1744
1820
|
}, {});
|
|
1745
1821
|
uniqueFormatted[pivot.columnField] = uniqueRecords;
|
|
1746
|
-
const pivotedData = (0, PivotModal_1.generatePivotTable)(pivot, data2.rows,
|
|
1822
|
+
const pivotedData = (0, PivotModal_1.generatePivotTable)(pivot, data2.rows, undefined, false);
|
|
1747
1823
|
console.info(`%c[Pivot]: ${JSON.stringify(pivot)}`, 'color: dimgray');
|
|
1748
|
-
const processedFields = data2.fields.map((elem) => (0,
|
|
1749
|
-
setPivotData(pivotedData
|
|
1824
|
+
const processedFields = data2.fields.map((elem) => (0, columnProcessing_1.convertPostgresColumn)(elem));
|
|
1825
|
+
setPivotData(pivotedData);
|
|
1750
1826
|
setRows(data2.rows);
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
const formattedValue = (0, valueFormatter_1.quillFormat)({
|
|
1756
|
-
value: row[column.field],
|
|
1757
|
-
format: column.format,
|
|
1758
|
-
});
|
|
1759
|
-
formattedRow[column.field] = formattedValue;
|
|
1760
|
-
return formattedRow;
|
|
1761
|
-
}, {});
|
|
1827
|
+
setColumns(processedFields);
|
|
1828
|
+
const formattedRows = formatRows(pivotedData.rows, processedFields, true, pivot.aggregationType);
|
|
1829
|
+
setSelectedColumns(processedFields.map((column) => {
|
|
1830
|
+
return `${table}.${column.field}`;
|
|
1762
1831
|
}));
|
|
1832
|
+
setFormattedRows(formattedRows);
|
|
1763
1833
|
}
|
|
1764
1834
|
else {
|
|
1765
|
-
const processedFields = data2.fields.map((elem) => (0,
|
|
1835
|
+
const processedFields = data2.fields.map((elem) => (0, columnProcessing_1.convertPostgresColumn)(elem));
|
|
1766
1836
|
setRows(data2.rows);
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
return
|
|
1770
|
-
// Apply the format function to each field in the row
|
|
1771
|
-
const formattedValue = (0, valueFormatter_1.quillFormat)({
|
|
1772
|
-
value: row[column.field],
|
|
1773
|
-
format: column.format,
|
|
1774
|
-
});
|
|
1775
|
-
formattedRow[column.field] = formattedValue;
|
|
1776
|
-
return formattedRow;
|
|
1777
|
-
}, {});
|
|
1837
|
+
setColumns(processedFields);
|
|
1838
|
+
setSelectedColumns(processedFields.map((column) => {
|
|
1839
|
+
return `${table}.${column.field}`;
|
|
1778
1840
|
}));
|
|
1841
|
+
const formattedRows = formatRows(data2.rows, processedFields, false);
|
|
1842
|
+
setFormattedRows(formattedRows);
|
|
1779
1843
|
if (data2.errorMessage) {
|
|
1780
1844
|
setErrorMessage(`Error: ${data2.errorMessage}`);
|
|
1781
1845
|
}
|
|
@@ -1783,7 +1847,7 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
1783
1847
|
}
|
|
1784
1848
|
else {
|
|
1785
1849
|
setRows([]);
|
|
1786
|
-
|
|
1850
|
+
setColumns([]);
|
|
1787
1851
|
setFormattedRows([]);
|
|
1788
1852
|
setPivotData(null);
|
|
1789
1853
|
}
|
|
@@ -1794,6 +1858,7 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
1794
1858
|
finally {
|
|
1795
1859
|
setLoading(false);
|
|
1796
1860
|
setDataDisplayed(true);
|
|
1861
|
+
return rows;
|
|
1797
1862
|
}
|
|
1798
1863
|
}
|
|
1799
1864
|
};
|
|
@@ -2009,11 +2074,13 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
2009
2074
|
if (table !== currentTable) {
|
|
2010
2075
|
const tableInfo = schemaTables.find((tableInfo) => tableInfo.name === table);
|
|
2011
2076
|
if (tableInfo) {
|
|
2012
|
-
const
|
|
2077
|
+
const convertedStringColumns = tableInfo.columns
|
|
2078
|
+
.filter((column) => {
|
|
2013
2079
|
return (0, ast_1.isTextColumnType)(column.fieldType);
|
|
2014
|
-
})
|
|
2015
|
-
|
|
2016
|
-
const
|
|
2080
|
+
})
|
|
2081
|
+
.map((column) => (0, columnProcessing_1.convertColumnInfoToColumnInternal)(column));
|
|
2082
|
+
const stringNames = convertedStringColumns.map((column) => column.field);
|
|
2083
|
+
const newUniqueValues = await (0, tableProcessing_1.getUniqueValuesByColumns)(convertedStringColumns, `Select ${stringNames.join(', ')} from ${table}`, rows, client);
|
|
2017
2084
|
currentUniqueValues[table] = newUniqueValues;
|
|
2018
2085
|
if ((0, crypto_1.hashCode)(uniqueValues) !== (0, crypto_1.hashCode)(currentUniqueValues)) {
|
|
2019
2086
|
setUniqueValues(currentUniqueValues);
|
|
@@ -2022,7 +2089,7 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
2022
2089
|
setCurrentTable(table);
|
|
2023
2090
|
}
|
|
2024
2091
|
if (data2.rows && data2.rows.length) {
|
|
2025
|
-
const processedFields = data2.fields.map((elem) => (0,
|
|
2092
|
+
const processedFields = data2.fields.map((elem) => (0, columnProcessing_1.convertPostgresColumn)(elem));
|
|
2026
2093
|
let possiblePivot = true;
|
|
2027
2094
|
const possibleColumns = (0, pivotProcessing_1.getPossiblePivotFieldOptions)(processedFields, currentUniqueValues[table]);
|
|
2028
2095
|
if (groupByPivot &&
|
|
@@ -2064,48 +2131,28 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
2064
2131
|
setPivotColumnField(groupByPivot?.columnField);
|
|
2065
2132
|
setPivotValueField(groupByPivot?.valueField);
|
|
2066
2133
|
setPivotAggregation(groupByPivot?.aggregationType);
|
|
2067
|
-
const pivotedData = (0, PivotModal_1.generatePivotTable)(
|
|
2068
|
-
// @ts-ignore
|
|
2069
|
-
groupByPivot, data2.rows, [null, null, null], false);
|
|
2134
|
+
const pivotedData = (0, PivotModal_1.generatePivotTable)(groupByPivot, data2.rows, undefined, false);
|
|
2070
2135
|
console.info(`%c[Pivot]: ${JSON.stringify(groupByPivot)}`, 'color: dimgray');
|
|
2071
2136
|
setPivotData(pivotedData);
|
|
2072
2137
|
setPivot(groupByPivot);
|
|
2073
2138
|
setRows(data2.rows);
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
// Apply the format function to each field in the row
|
|
2078
|
-
const formattedValue = (0, valueFormatter_1.quillFormat)({
|
|
2079
|
-
value: row[column.field],
|
|
2080
|
-
format: column.format,
|
|
2081
|
-
});
|
|
2082
|
-
formattedRow[column.field] = formattedValue;
|
|
2083
|
-
return formattedRow;
|
|
2084
|
-
}, {});
|
|
2085
|
-
}));
|
|
2139
|
+
setColumns(processedFields);
|
|
2140
|
+
const formattedRows = formatRows(pivotedData.rows, processedFields, true, groupByPivot.aggregationType);
|
|
2141
|
+
setFormattedRows(formattedRows);
|
|
2086
2142
|
}
|
|
2087
2143
|
else {
|
|
2088
|
-
const processedFields = data2.fields.map((elem) => (0,
|
|
2144
|
+
const processedFields = data2.fields.map((elem) => (0, columnProcessing_1.convertPostgresColumn)(elem));
|
|
2089
2145
|
setRows(data2.rows);
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
// Apply the format function to each field in the row
|
|
2094
|
-
const formattedValue = (0, valueFormatter_1.quillFormat)({
|
|
2095
|
-
value: row[column.field],
|
|
2096
|
-
format: column.format,
|
|
2097
|
-
});
|
|
2098
|
-
formattedRow[column.field] = formattedValue;
|
|
2099
|
-
return formattedRow;
|
|
2100
|
-
}, {});
|
|
2101
|
-
}));
|
|
2146
|
+
setColumns(processedFields);
|
|
2147
|
+
const formattedRows = formatRows(data2.rows, processedFields, false);
|
|
2148
|
+
setFormattedRows(formattedRows);
|
|
2102
2149
|
}
|
|
2103
2150
|
return data2.rows;
|
|
2104
2151
|
}
|
|
2105
2152
|
else {
|
|
2106
2153
|
setPivotData([]);
|
|
2107
2154
|
setRows([]);
|
|
2108
|
-
|
|
2155
|
+
setColumns([]);
|
|
2109
2156
|
setFormattedRows([]);
|
|
2110
2157
|
}
|
|
2111
2158
|
if (data2.query) {
|
|
@@ -2229,7 +2276,7 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
2229
2276
|
gap: 8,
|
|
2230
2277
|
}, children: [columnNamesInAst.map((name) => ((0, jsx_runtime_1.jsx)(DraggableItem, { id: name, label: name, onDelete: () => handleDeleteColumn(name) }, name))), columnNamesInAst?.length > 0 && (0, jsx_runtime_1.jsx)("div", { style: { height: 6 } })] }) }) }));
|
|
2231
2278
|
}
|
|
2232
|
-
if (loading) {
|
|
2279
|
+
if (loading || initalChartLoad) {
|
|
2233
2280
|
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
2234
2281
|
display: 'flex',
|
|
2235
2282
|
flexDirection: 'row',
|
|
@@ -2360,9 +2407,11 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
2360
2407
|
setActivePath(null);
|
|
2361
2408
|
setOpenPopover(null);
|
|
2362
2409
|
}
|
|
2363
|
-
} }) })] }))] })] }), (0, jsx_runtime_1.jsxs)("div", { style: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(SidebarHeadingComponent, { label: "Pivot" }), (0, jsx_runtime_1.jsx)(PivotModal_1.PivotModal, { pivotRowField: pivotRowField, setPivotRowField: setPivotRowField, pivotColumnField: pivotColumnField, setPivotColumnField: setPivotColumnField, pivotValueField: pivotValueField, setPivotValueField: setPivotValueField, pivotAggregation: pivotAggregation, setPivotAggregation: setPivotAggregation, createdPivots: createdPivots, setCreatedPivots: setCreatedPivots, recommendedPivots: recommendedPivots, setRecommendedPivots: setRecommendedPivots, popUpTitle: pivotPopUpTitle, setPopUpTitle: setPivotPopUpTitle, selectedTable: initialTableName, CardComponent: CardComponent, SelectComponent: SelectComponent, ButtonComponent: ButtonComponent, PopoverComponent: PopoverComponent, TextComponent: TextComponent, ErrorMessageComponent: ErrorMessageComponent, PivotRowContainer: PivotRowContainer, PivotColumnContainer: PivotColumnContainer, isOpen: showPivotPopover, setIsOpen: setShowPivotPopover, showUpdatePivot: isEdittingPivot, setShowUpdatePivot: setIsEdittingPivot, parentRef: parentRef, data: rows, columns:
|
|
2410
|
+
} }) })] }))] })] }), (0, jsx_runtime_1.jsxs)("div", { style: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(SidebarHeadingComponent, { label: "Pivot" }), (0, jsx_runtime_1.jsx)(PivotModal_1.PivotModal, { pivotRowField: pivotRowField, setPivotRowField: setPivotRowField, pivotColumnField: pivotColumnField, setPivotColumnField: setPivotColumnField, pivotValueField: pivotValueField, setPivotValueField: setPivotValueField, pivotAggregation: pivotAggregation, setPivotAggregation: setPivotAggregation, createdPivots: createdPivots, setCreatedPivots: setCreatedPivots, recommendedPivots: recommendedPivots, setRecommendedPivots: setRecommendedPivots, popUpTitle: pivotPopUpTitle, setPopUpTitle: setPivotPopUpTitle, selectedTable: initialTableName, CardComponent: CardComponent, SelectComponent: SelectComponent, ButtonComponent: ButtonComponent, PopoverComponent: PopoverComponent, TextComponent: TextComponent, ErrorMessageComponent: ErrorMessageComponent, PivotRowContainer: PivotRowContainer, PivotColumnContainer: PivotColumnContainer, isOpen: showPivotPopover, setIsOpen: setShowPivotPopover, showUpdatePivot: isEdittingPivot, setShowUpdatePivot: setIsEdittingPivot, parentRef: parentRef, data: rows, columns: columns, triggerButtonText: 'Add pivot', selectedPivotIndex: selectedPivotIndex, setSelectedPivotIndex: setSelectedPivotIndex, removePivot: () => {
|
|
2364
2411
|
setPivot(null);
|
|
2365
2412
|
setPivotData(null);
|
|
2413
|
+
const formattedRows = formatRows(rows, columns, false);
|
|
2414
|
+
setFormattedRows(formattedRows);
|
|
2366
2415
|
},
|
|
2367
2416
|
// TODOs
|
|
2368
2417
|
selectPivot: (pivot) => {
|
|
@@ -2372,9 +2421,11 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
2372
2421
|
newAst.orderby = null;
|
|
2373
2422
|
setBaseAst(newAst); // trigger refetch
|
|
2374
2423
|
setPivot(pivot);
|
|
2375
|
-
const pivotedData = (0, PivotModal_1.generatePivotTable)(pivot, rows,
|
|
2424
|
+
const pivotedData = (0, PivotModal_1.generatePivotTable)(pivot, rows, undefined, false);
|
|
2376
2425
|
setPivotData(pivotedData || []);
|
|
2377
|
-
|
|
2426
|
+
const formattedRows = formatRows(pivotedData.rows, columns, true, pivot.aggregationType);
|
|
2427
|
+
setFormattedRows(formattedRows);
|
|
2428
|
+
}, selectPivotOnEdit: true, showTrigger: !pivot, theme: theme, LabelComponent: LabelComponent, HeaderComponent: HeaderComponent, dateRange: undefined, pivotCountRequest: 4, SecondaryButtonComponent: SecondaryButtonComponent, query: activeQuery, initialUniqueValues: uniqueValues[currentTable], disabled: !loading && (!baseAst || !dataDisplayed), pivotRecommendationsEnabled: pivotRecommendationsEnabled && overrideRecommendations }), pivot && ((0, jsx_runtime_1.jsx)(PivotList_1.PivotCard, { pivotTable: {
|
|
2378
2429
|
pivot: pivot,
|
|
2379
2430
|
rows: pivotData?.rows || [],
|
|
2380
2431
|
columns: pivotData?.columns || [],
|
|
@@ -2389,6 +2440,8 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
2389
2440
|
}, selectedPivotIndex: -1, onEditPivot: () => { }, CardComponent: CardComponent, ButtonComponent: ButtonComponent, HeaderComponent: HeaderComponent, showEdit: false, onClose: () => {
|
|
2390
2441
|
setPivot(null);
|
|
2391
2442
|
setPivotData(null);
|
|
2443
|
+
const formattedRows = formatRows(rows, columns, false);
|
|
2444
|
+
setFormattedRows(formattedRows);
|
|
2392
2445
|
setBaseAst((0, util_1.deepCopy)(baseAst)); // trigger refetch
|
|
2393
2446
|
}, minHeight: 180, LabelComponent: LabelComponent, TextComponent: TextComponent }))] }), (0, jsx_runtime_1.jsxs)("div", { style: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(SidebarHeadingComponent, { label: "Sort" }), pivot && pivot.sort && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
2394
2447
|
display: 'flex',
|
|
@@ -2523,7 +2576,9 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
2523
2576
|
? 'Ask a follow-up question...'
|
|
2524
2577
|
: 'Ask a question...', width: askAIInputWidth !== -1
|
|
2525
2578
|
? askAIInputWidth
|
|
2526
|
-
: askAILoadingContainerWidth, value: aiPrompt, onChange: () => { } }), (0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: () => { }, label: "Ask AI" }), ((baseAst && dataDisplayed) ||
|
|
2579
|
+
: askAILoadingContainerWidth, value: aiPrompt, onChange: () => { } }), (0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: () => { }, label: "Ask AI" }), ((baseAst && dataDisplayed) ||
|
|
2580
|
+
initialLoad ||
|
|
2581
|
+
initalChartLoad) && ((0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: () => { }, label: "New report" }))] }) })), (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(TableComponent, { isLoading: true, rows: [], columns: [] }), baseAst && dataDisplayed && !initalChartLoad && ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
2527
2582
|
display: 'flex',
|
|
2528
2583
|
flexDirection: 'row',
|
|
2529
2584
|
gap: '12px',
|
|
@@ -2669,9 +2724,11 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
2669
2724
|
setOpenPopover(null);
|
|
2670
2725
|
clearCheckboxes();
|
|
2671
2726
|
}
|
|
2672
|
-
} }) })] }))] })] }), (0, jsx_runtime_1.jsxs)("div", { style: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(SidebarHeadingComponent, { label: "Pivot" }), (0, jsx_runtime_1.jsx)(PivotModal_1.PivotModal, { pivotRowField: pivotRowField, setPivotRowField: setPivotRowField, pivotColumnField: pivotColumnField, setPivotColumnField: setPivotColumnField, pivotValueField: pivotValueField, setPivotValueField: setPivotValueField, pivotAggregation: pivotAggregation, setPivotAggregation: setPivotAggregation, createdPivots: createdPivots, setCreatedPivots: setCreatedPivots, recommendedPivots: recommendedPivots, setRecommendedPivots: setRecommendedPivots, popUpTitle: pivotPopUpTitle, setPopUpTitle: setPivotPopUpTitle, selectedTable: initialTableName, SelectComponent: SelectComponent, ButtonComponent: ButtonComponent, CardComponent: CardComponent, SecondaryButtonComponent: SecondaryButtonComponent, PopoverComponent: PopoverComponent, TextComponent: TextComponent, ErrorMessageComponent: ErrorMessageComponent, PivotRowContainer: PivotRowContainer, PivotColumnContainer: PivotColumnContainer, isOpen: showPivotPopover, setIsOpen: setShowPivotPopover, showUpdatePivot: isEdittingPivot, setShowUpdatePivot: setIsEdittingPivot, parentRef: parentRef, data: rows, columns:
|
|
2727
|
+
} }) })] }))] })] }), (0, jsx_runtime_1.jsxs)("div", { style: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(SidebarHeadingComponent, { label: "Pivot" }), (0, jsx_runtime_1.jsx)(PivotModal_1.PivotModal, { pivotRowField: pivotRowField, setPivotRowField: setPivotRowField, pivotColumnField: pivotColumnField, setPivotColumnField: setPivotColumnField, pivotValueField: pivotValueField, setPivotValueField: setPivotValueField, pivotAggregation: pivotAggregation, setPivotAggregation: setPivotAggregation, createdPivots: createdPivots, setCreatedPivots: setCreatedPivots, recommendedPivots: recommendedPivots, setRecommendedPivots: setRecommendedPivots, popUpTitle: pivotPopUpTitle, setPopUpTitle: setPivotPopUpTitle, selectedTable: initialTableName, SelectComponent: SelectComponent, ButtonComponent: ButtonComponent, CardComponent: CardComponent, SecondaryButtonComponent: SecondaryButtonComponent, PopoverComponent: PopoverComponent, TextComponent: TextComponent, ErrorMessageComponent: ErrorMessageComponent, PivotRowContainer: PivotRowContainer, PivotColumnContainer: PivotColumnContainer, isOpen: showPivotPopover, setIsOpen: setShowPivotPopover, showUpdatePivot: isEdittingPivot, setShowUpdatePivot: setIsEdittingPivot, parentRef: parentRef, data: rows, columns: columns, triggerButtonText: 'Add pivot', selectedPivotIndex: selectedPivotIndex, setSelectedPivotIndex: setSelectedPivotIndex, removePivot: () => {
|
|
2673
2728
|
setPivot(null);
|
|
2674
2729
|
setPivotData(null);
|
|
2730
|
+
const formattedRows = formatRows(rows, columns, false);
|
|
2731
|
+
setFormattedRows(formattedRows);
|
|
2675
2732
|
}, selectPivot: (pivot) => {
|
|
2676
2733
|
if (!pivot)
|
|
2677
2734
|
return;
|
|
@@ -2683,10 +2740,12 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
2683
2740
|
}
|
|
2684
2741
|
setBaseAst(newAst); // trigger refetch
|
|
2685
2742
|
setPivot(pivot);
|
|
2686
|
-
const pivotedData = (0, PivotModal_1.generatePivotTable)(pivot, rows,
|
|
2743
|
+
const pivotedData = (0, PivotModal_1.generatePivotTable)(pivot, rows, undefined, false);
|
|
2687
2744
|
setPivotData(pivotedData || []);
|
|
2745
|
+
const formattedRows = formatRows(pivotedData.rows, columns, true, pivot.aggregationType);
|
|
2746
|
+
setFormattedRows(formattedRows);
|
|
2688
2747
|
setErrorMessage('');
|
|
2689
|
-
}, selectPivotOnEdit: true, showTrigger: !pivot, theme: theme, LabelComponent: LabelComponent, HeaderComponent: HeaderComponent, dateRange:
|
|
2748
|
+
}, selectPivotOnEdit: true, showTrigger: !pivot, theme: theme, LabelComponent: LabelComponent, HeaderComponent: HeaderComponent, dateRange: undefined, pivotCountRequest: 4, query: activeQuery, initialUniqueValues: uniqueValues[currentTable], disabled: !baseAst || !dataDisplayed, pivotRecommendationsEnabled: pivotRecommendationsEnabled && overrideRecommendations }), pivot && ((0, jsx_runtime_1.jsx)(PivotList_1.PivotCard, { pivotTable: {
|
|
2690
2749
|
pivot: pivot,
|
|
2691
2750
|
rows: pivotData?.rows || [],
|
|
2692
2751
|
columns: pivotData?.columns || [],
|
|
@@ -2701,6 +2760,8 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
2701
2760
|
}, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent: ButtonComponent, HeaderComponent: HeaderComponent, CardComponent: CardComponent, showEdit: false, onClose: () => {
|
|
2702
2761
|
setPivot(null);
|
|
2703
2762
|
setPivotData(null);
|
|
2763
|
+
const formattedRows = formatRows(rows, columns, false);
|
|
2764
|
+
setFormattedRows(formattedRows);
|
|
2704
2765
|
setBaseAst((0, util_1.deepCopy)(baseAst));
|
|
2705
2766
|
}, minHeight: 180, LabelComponent: LabelComponent, TextComponent: TextComponent }))] }), (0, jsx_runtime_1.jsxs)("div", { style: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(SidebarHeadingComponent, { label: "Sort" }), pivot && pivot.sort && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
2706
2767
|
display: 'flex',
|
|
@@ -2720,8 +2781,10 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
2720
2781
|
: selectedColumns, setIsPending: setIsPending, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setActivePath: setActivePath, setOpenPopover: setOpenPopover, SortPopover: SortPopoverComponent, EditPopover: AddSortPopover_1.AddSortPopover, handleDelete: () => {
|
|
2721
2782
|
if (pivot) {
|
|
2722
2783
|
setPivot({ ...pivot, sort: false });
|
|
2723
|
-
const pivotedData = (0, PivotModal_1.generatePivotTable)({ ...pivot, sort: false }, rows,
|
|
2784
|
+
const pivotedData = (0, PivotModal_1.generatePivotTable)({ ...pivot, sort: false }, rows, undefined, false);
|
|
2724
2785
|
setPivotData(pivotedData || []);
|
|
2786
|
+
const formattedRows = formatRows(pivotedData.rows, columns, true, pivot.aggregationType);
|
|
2787
|
+
setFormattedRows(formattedRows);
|
|
2725
2788
|
setErrorMessage('');
|
|
2726
2789
|
return;
|
|
2727
2790
|
}
|
|
@@ -2745,8 +2808,10 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
2745
2808
|
sortDirection: direction,
|
|
2746
2809
|
sortField: column,
|
|
2747
2810
|
sortFieldType: sortFieldType,
|
|
2748
|
-
}, rows,
|
|
2811
|
+
}, rows, undefined, false);
|
|
2749
2812
|
setPivotData(pivotedData || []);
|
|
2813
|
+
const formattedRows = formatRows(pivotedData.rows, columns, true, pivot.aggregationType);
|
|
2814
|
+
setFormattedRows(formattedRows);
|
|
2750
2815
|
setErrorMessage('');
|
|
2751
2816
|
return;
|
|
2752
2817
|
}
|
|
@@ -2844,9 +2909,11 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
2844
2909
|
sortDirection: direction,
|
|
2845
2910
|
sortField: column,
|
|
2846
2911
|
sortFieldType: sortFieldType,
|
|
2847
|
-
}, rows,
|
|
2912
|
+
}, rows, undefined, false);
|
|
2848
2913
|
setErrorMessage('');
|
|
2849
2914
|
setPivotData(pivotedData || []);
|
|
2915
|
+
const formattedRows = formatRows(pivotedData.rows, columns, true, pivot.aggregationType);
|
|
2916
|
+
setFormattedRows(formattedRows);
|
|
2850
2917
|
setActivePath(null);
|
|
2851
2918
|
setOpenPopover(null);
|
|
2852
2919
|
setBaseAst((0, util_1.deepCopy)(baseAst));
|
|
@@ -2934,7 +3001,7 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
2934
3001
|
: 'visible',
|
|
2935
3002
|
}, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(TextInputComponent, { id: "ask_ai_input_bar", value: aiPrompt, width: askAIInputWidth !== -1
|
|
2936
3003
|
? askAIInputWidth
|
|
2937
|
-
: askAILoadingContainerWidth, onChange: (e) => setAiPrompt(e.target.value), placeholder: baseAst ? 'Ask a follow-up question...' : 'Ask a question...' }), (0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: handleAsk, label: 'Ask AI' }), ((baseAst && dataDisplayed) || initialLoad) && ((0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { label: 'New report', onClick: clearAllState }))] }) })), baseAst && ((0, jsx_runtime_1.jsx)(TableComponent, { isLoading: loading && errorMessage.length === 0, rows:
|
|
3004
|
+
: askAILoadingContainerWidth, onChange: (e) => setAiPrompt(e.target.value), placeholder: baseAst ? 'Ask a follow-up question...' : 'Ask a question...' }), (0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: handleAsk, label: 'Ask AI' }), ((baseAst && dataDisplayed) || initialLoad) && ((0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { label: 'New report', onClick: clearAllState }))] }) })), baseAst && ((0, jsx_runtime_1.jsx)(TableComponent, { isLoading: (loading && errorMessage.length === 0) || initalChartLoad, rows: formattedRows, columns: pivot
|
|
2938
3005
|
? pivotData?.columns || emptyPivotColumns()
|
|
2939
3006
|
: enforceOrderOnColumns(Object.keys(rows[0] ?? {})).map((c) => {
|
|
2940
3007
|
return { label: (0, textProcessing_1.snakeCaseToTitleCase)(c), field: c };
|
|
@@ -2949,8 +3016,23 @@ function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = (_) => vo
|
|
|
2949
3016
|
overflow: 'hidden',
|
|
2950
3017
|
width: '100%',
|
|
2951
3018
|
gap: 12,
|
|
2952
|
-
}, children: [(0, jsx_runtime_1.jsx)(ErrorMessageComponent, { errorMessage: errorMessage }), (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: handleAsk, label: 'Retry' })] })) : ((0, jsx_runtime_1.jsx)("div", { style: { width: '100%' } })), baseAst && dataDisplayed && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { label: isCopying ? '✅ Copied' : 'Copy SQL', onClick: () => copyToClipboard(activeQuery) }), (0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: () => {
|
|
3019
|
+
}, children: [(0, jsx_runtime_1.jsx)(ErrorMessageComponent, { errorMessage: errorMessage }), (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: handleAsk, label: 'Retry' })] })) : ((0, jsx_runtime_1.jsx)("div", { style: { width: '100%' } })), baseAst && dataDisplayed && !initalChartLoad && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { label: isCopying ? '✅ Copied' : 'Copy SQL', onClick: () => copyToClipboard(activeQuery) }), (0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: () => {
|
|
2953
3020
|
setIsChartBuilderOpen(true);
|
|
2954
|
-
}, label: 'Add to dashboard' })] }))] })] }), (0, jsx_runtime_1.jsx)("style", { children: `body{margin:0;}` }), (0, jsx_runtime_1.jsx)(ChartBuilder_1.ChartBuilderWithModal, {
|
|
3021
|
+
}, label: 'Add to dashboard' })] }))] })] }), (0, jsx_runtime_1.jsx)("style", { children: `body{margin:0;}` }), (0, jsx_runtime_1.jsx)(ChartBuilder_1.ChartBuilderWithModal, { dashboardItem: dashboardItem
|
|
3022
|
+
? {
|
|
3023
|
+
...dashboardItem,
|
|
3024
|
+
pivot: pivot,
|
|
3025
|
+
yAxisFields: dashboardItem.pivot && !pivot
|
|
3026
|
+
? []
|
|
3027
|
+
: dashboardItem.yAxisFields,
|
|
3028
|
+
columns: dashboardItem.columns.filter((col) => {
|
|
3029
|
+
return columns.find((c) => {
|
|
3030
|
+
return col.field === c.field;
|
|
3031
|
+
});
|
|
3032
|
+
}),
|
|
3033
|
+
queryString: activeQuery,
|
|
3034
|
+
rows: rows,
|
|
3035
|
+
}
|
|
3036
|
+
: undefined, rows: rows, columns: columns, pivot: pivot, query: activeQuery, showTableFormatOptions: showChartBuilderTableFormatOptions, showDateFieldOptions: isAdminEnabled, showAccessControlOptions: isAdminEnabled, title: dashboardItem ? 'Edit Chart' : 'Add to dashboard', isHorizontalView: true, isOpen: isChartBuilderOpen, setIsOpen: setIsChartBuilderOpen, onAddToDashboardComplete: dashboardItem ? onSubmitEditReport : onSubmitCreateReport, destinationDashboard: destinationDashboard, organizationName: organizationName, pivotData: pivotData, initialUniqueValues: uniqueValues[currentTable], pivotRecommendationsEnabled: pivotRecommendationsEnabled && overrideRecommendations, SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, HeaderComponent: HeaderComponent, SubHeaderComponent: SubHeaderComponent, LabelComponent: LabelComponent, TextComponent: TextComponent, CardComponent: CardComponent, ModalComponent: ModalComponent, PopoverComponent: PopoverComponent, TableComponent: TableComponent, DeleteButtonComponent: DeleteButtonComponent, ChartBuilderInputRowContainer: ChartBuilderInputRowContainer, ChartBuilderInputColumnContainer: ChartBuilderInputColumnContainer, FormContainer: ChartBuilderFormContainer, hideDateRangeFilter: true, buttonLabel: dashboardItem ? 'Edit Chart' : 'Add to dashboard' })] }));
|
|
2955
3037
|
}
|
|
2956
3038
|
exports.default = ReportBuilder;
|