@quillsql/react 2.11.16 → 2.11.17
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 +117 -42
- package/dist/cjs/Chart.d.ts.map +1 -1
- package/dist/cjs/Chart.js +44 -18
- package/dist/cjs/ChartBuilder.d.ts +194 -30
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +122 -62
- package/dist/cjs/ChartEditor.d.ts +114 -18
- package/dist/cjs/ChartEditor.d.ts.map +1 -1
- package/dist/cjs/ChartEditor.js +47 -15
- package/dist/cjs/Dashboard.d.ts +148 -91
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/Dashboard.js +46 -152
- package/dist/cjs/DateRangePicker/QuillDateRangePicker.d.ts +21 -1
- package/dist/cjs/DateRangePicker/QuillDateRangePicker.d.ts.map +1 -1
- package/dist/cjs/DateRangePicker/QuillDateRangePicker.js +5 -2
- package/dist/cjs/DateRangePicker/dateRangePickerUtils.js +1 -1
- package/dist/cjs/QuillProvider.d.ts +105 -2
- package/dist/cjs/QuillProvider.d.ts.map +1 -1
- package/dist/cjs/QuillProvider.js +59 -0
- package/dist/cjs/ReportBuilder.d.ts +188 -42
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +466 -394
- package/dist/cjs/SQLEditor.d.ts +158 -23
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +35 -30
- package/dist/cjs/Table.d.ts +119 -15
- package/dist/cjs/Table.d.ts.map +1 -1
- package/dist/cjs/Table.js +37 -6
- package/dist/cjs/TableChart.d.ts.map +1 -1
- package/dist/cjs/TableChart.js +0 -194
- package/dist/cjs/{BarList.d.ts → components/Chart/BarList.d.ts} +1 -1
- package/dist/cjs/components/Chart/BarList.d.ts.map +1 -0
- package/dist/cjs/{BarList.js → components/Chart/BarList.js} +1 -1
- package/dist/cjs/components/Chart/LineChart.d.ts +2 -3
- package/dist/cjs/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/LineChart.js +3 -3
- package/dist/cjs/components/Chart/PieChart.d.ts.map +1 -0
- package/dist/cjs/{PieChart.js → components/Chart/PieChart.js} +1 -1
- package/dist/cjs/components/Dashboard/ChartComponent.d.ts +2 -1
- package/dist/cjs/components/Dashboard/ChartComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/ChartComponent.js +6 -7
- package/dist/cjs/components/Dashboard/DashboardFilter.d.ts +22 -0
- package/dist/cjs/components/Dashboard/DashboardFilter.d.ts.map +1 -0
- package/dist/cjs/components/Dashboard/DashboardFilter.js +75 -0
- package/dist/cjs/components/Dashboard/DataLoader.d.ts +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.js +1 -1
- package/dist/cjs/components/Dashboard/MetricComponent.d.ts +2 -12
- package/dist/cjs/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/MetricComponent.js +39 -17
- package/dist/cjs/components/Dashboard/TableComponent.d.ts +2 -1
- package/dist/cjs/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/TableComponent.js +6 -9
- package/dist/cjs/components/QuillSelect.d.ts +4 -1
- package/dist/cjs/components/QuillSelect.d.ts.map +1 -1
- package/dist/cjs/components/QuillSelect.js +13 -8
- package/dist/cjs/components/QuillTable.d.ts +16 -2
- package/dist/cjs/components/QuillTable.d.ts.map +1 -1
- package/dist/cjs/components/QuillTable.js +4 -4
- package/dist/cjs/components/ReportBuilder/AddColumnPopover.d.ts +9 -3
- package/dist/cjs/components/ReportBuilder/AddColumnPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddColumnPopover.js +8 -6
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.d.ts +13 -1
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.js +4 -14
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts +21 -1
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddSortPopover.js +15 -17
- package/dist/cjs/components/ReportBuilder/bigDateMap.js +1 -1
- package/dist/cjs/components/ReportBuilder/convert.d.ts +2 -1
- package/dist/cjs/components/ReportBuilder/convert.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/convert.js +40 -20
- package/dist/cjs/components/ReportBuilder/pivot.d.ts +2 -1
- package/dist/cjs/components/ReportBuilder/pivot.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/ui.d.ts +83 -18
- package/dist/cjs/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/ui.js +52 -100
- package/dist/cjs/components/ReportBuilder/util.d.ts +2 -1
- package/dist/cjs/components/ReportBuilder/util.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/util.js +16 -9
- package/dist/cjs/components/UiComponents.d.ts +86 -86
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +118 -103
- package/dist/cjs/hooks/index.d.ts +1 -0
- package/dist/cjs/hooks/index.d.ts.map +1 -1
- package/dist/cjs/hooks/index.js +3 -1
- package/dist/cjs/hooks/useTheme.d.ts +7 -0
- package/dist/cjs/hooks/useTheme.d.ts.map +1 -0
- package/dist/cjs/hooks/useTheme.js +12 -0
- package/dist/cjs/index.d.ts +10 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotList.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotList.js +10 -10
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts +29 -14
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.js +73 -49
- package/dist/cjs/utils/dataFetcher.d.ts.map +1 -1
- package/dist/cjs/utils/dataFetcher.js +2 -0
- package/dist/esm/Chart.d.ts +117 -42
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +45 -19
- package/dist/esm/ChartBuilder.d.ts +194 -30
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +122 -62
- package/dist/esm/ChartEditor.d.ts +114 -18
- package/dist/esm/ChartEditor.d.ts.map +1 -1
- package/dist/esm/ChartEditor.js +51 -19
- package/dist/esm/Dashboard.d.ts +148 -91
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/Dashboard.js +49 -153
- package/dist/esm/DateRangePicker/QuillDateRangePicker.d.ts +21 -1
- package/dist/esm/DateRangePicker/QuillDateRangePicker.d.ts.map +1 -1
- package/dist/esm/DateRangePicker/QuillDateRangePicker.js +6 -3
- package/dist/esm/DateRangePicker/dateRangePickerUtils.js +1 -1
- package/dist/esm/QuillProvider.d.ts +105 -2
- package/dist/esm/QuillProvider.d.ts.map +1 -1
- package/dist/esm/QuillProvider.js +59 -0
- package/dist/esm/ReportBuilder.d.ts +188 -42
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +468 -396
- package/dist/esm/SQLEditor.d.ts +158 -23
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +35 -30
- package/dist/esm/Table.d.ts +119 -15
- package/dist/esm/Table.d.ts.map +1 -1
- package/dist/esm/Table.js +38 -7
- package/dist/esm/TableChart.d.ts.map +1 -1
- package/dist/esm/TableChart.js +0 -194
- package/dist/esm/{BarList.d.ts → components/Chart/BarList.d.ts} +1 -1
- package/dist/esm/components/Chart/BarList.d.ts.map +1 -0
- package/dist/esm/{BarList.js → components/Chart/BarList.js} +1 -1
- package/dist/esm/components/Chart/LineChart.d.ts +2 -3
- package/dist/esm/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/LineChart.js +3 -3
- package/dist/esm/components/Chart/PieChart.d.ts.map +1 -0
- package/dist/esm/{PieChart.js → components/Chart/PieChart.js} +1 -1
- package/dist/esm/components/Dashboard/ChartComponent.d.ts +2 -1
- package/dist/esm/components/Dashboard/ChartComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/ChartComponent.js +5 -6
- package/dist/esm/components/Dashboard/DashboardFilter.d.ts +22 -0
- package/dist/esm/components/Dashboard/DashboardFilter.d.ts.map +1 -0
- package/dist/esm/components/Dashboard/DashboardFilter.js +71 -0
- package/dist/esm/components/Dashboard/DataLoader.d.ts +1 -1
- package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.js +1 -1
- package/dist/esm/components/Dashboard/MetricComponent.d.ts +2 -12
- package/dist/esm/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/MetricComponent.js +39 -17
- package/dist/esm/components/Dashboard/TableComponent.d.ts +2 -1
- package/dist/esm/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/TableComponent.js +6 -9
- package/dist/esm/components/QuillSelect.d.ts +4 -1
- package/dist/esm/components/QuillSelect.d.ts.map +1 -1
- package/dist/esm/components/QuillSelect.js +14 -9
- package/dist/esm/components/QuillTable.d.ts +16 -2
- package/dist/esm/components/QuillTable.d.ts.map +1 -1
- package/dist/esm/components/QuillTable.js +4 -4
- package/dist/esm/components/ReportBuilder/AddColumnPopover.d.ts +9 -3
- package/dist/esm/components/ReportBuilder/AddColumnPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddColumnPopover.js +8 -6
- package/dist/esm/components/ReportBuilder/AddLimitPopover.d.ts +13 -1
- package/dist/esm/components/ReportBuilder/AddLimitPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddLimitPopover.js +4 -14
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts +21 -1
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddSortPopover.js +17 -19
- package/dist/esm/components/ReportBuilder/bigDateMap.js +1 -1
- package/dist/esm/components/ReportBuilder/convert.d.ts +2 -1
- package/dist/esm/components/ReportBuilder/convert.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/convert.js +33 -13
- package/dist/esm/components/ReportBuilder/pivot.d.ts +2 -1
- package/dist/esm/components/ReportBuilder/pivot.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/ui.d.ts +83 -18
- package/dist/esm/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/ui.js +50 -98
- package/dist/esm/components/ReportBuilder/util.d.ts +2 -1
- package/dist/esm/components/ReportBuilder/util.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/util.js +14 -8
- package/dist/esm/components/UiComponents.d.ts +86 -86
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +111 -101
- package/dist/esm/hooks/index.d.ts +1 -0
- package/dist/esm/hooks/index.d.ts.map +1 -1
- package/dist/esm/hooks/index.js +1 -0
- package/dist/esm/hooks/useTheme.d.ts +7 -0
- package/dist/esm/hooks/useTheme.d.ts.map +1 -0
- package/dist/esm/hooks/useTheme.js +10 -0
- package/dist/esm/index.d.ts +10 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotList.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotList.js +10 -10
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts +29 -14
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.js +73 -49
- package/dist/esm/utils/dataFetcher.d.ts.map +1 -1
- package/dist/esm/utils/dataFetcher.js +2 -0
- package/package.json +1 -1
- package/dist/cjs/BarList.d.ts.map +0 -1
- package/dist/cjs/PieChart.d.ts.map +0 -1
- package/dist/esm/BarList.d.ts.map +0 -1
- package/dist/esm/PieChart.d.ts.map +0 -1
- /package/dist/cjs/{PieChart.d.ts → components/Chart/PieChart.d.ts} +0 -0
- /package/dist/esm/{PieChart.d.ts → components/Chart/PieChart.d.ts} +0 -0
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
/* eslint-disable no-unused-vars */
|
|
7
8
|
const react_1 = require("react");
|
|
8
9
|
const UiComponents_1 = require("./components/UiComponents");
|
|
9
10
|
const core_1 = require("@dnd-kit/core");
|
|
@@ -25,11 +26,10 @@ const AddColumnPopover_1 = __importDefault(require("./components/ReportBuilder/A
|
|
|
25
26
|
const AddSortPopover_1 = require("./components/ReportBuilder/AddSortPopover");
|
|
26
27
|
const PivotModal_1 = require("./internals/ReportBuilder/PivotModal");
|
|
27
28
|
const PivotList_1 = require("./internals/ReportBuilder/PivotList");
|
|
28
|
-
const QuillTable_1 = __importDefault(require("./components/QuillTable"));
|
|
29
|
-
const QuillSelect_1 = require("./components/QuillSelect");
|
|
30
29
|
const textProcessing_1 = require("./utils/textProcessing");
|
|
31
30
|
const AddLimitPopover_1 = require("./components/ReportBuilder/AddLimitPopover");
|
|
32
31
|
const width_1 = require("./utils/width");
|
|
32
|
+
const QuillSelect_1 = require("./components/QuillSelect");
|
|
33
33
|
/**
|
|
34
34
|
* Quill Report Builder
|
|
35
35
|
*
|
|
@@ -37,8 +37,31 @@ const width_1 = require("./utils/width");
|
|
|
37
37
|
* then edit them on the fly. Once users have constructed a query they like,
|
|
38
38
|
* they can click a button and add that report to their dashboard or export it
|
|
39
39
|
* as a CSV.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```js
|
|
43
|
+
* // Usage without custom components
|
|
44
|
+
* <ReportBuilder />
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```js
|
|
49
|
+
* // You can also pass your own components
|
|
50
|
+
* <ReportBuilder
|
|
51
|
+
* initialTableName="transactions"
|
|
52
|
+
* TableComponent={MyTable}
|
|
53
|
+
* SelectComponent={MySelect}
|
|
54
|
+
* ButtonComponent={MyButton}
|
|
55
|
+
* PopoverComponent={MyPopover}
|
|
56
|
+
* TextInputComponent={MyTextInput}
|
|
57
|
+
* containerStyle={{ backgroundColor: 'white', padding: '10px' }}
|
|
58
|
+
* />
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* ### Report Builder API
|
|
62
|
+
* @see https://docs.quillsql.com/components/report-builder
|
|
40
63
|
*/
|
|
41
|
-
function ReportBuilder({ initialTableName = '',
|
|
64
|
+
function ReportBuilder({ initialTableName = '', onSubmitChartBuilder = () => 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, LabelComponent = UiComponents_1.MemoizedLabel, HeaderComponent = UiComponents_1.MemoizedHeader, TextComponent = UiComponents_1.MemoizedText, isAdminEnabled = false, isAIEnabled = true, containerStyle, }) {
|
|
42
65
|
const [aiPrompt, setAiPrompt] = (0, react_1.useState)('');
|
|
43
66
|
const [errorMessage, setErrorMessage] = (0, react_1.useState)('');
|
|
44
67
|
const [baseAst, setBaseAst] = (0, react_1.useState)(null);
|
|
@@ -130,9 +153,9 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
130
153
|
setAiPrompt('');
|
|
131
154
|
setBaseAst(null);
|
|
132
155
|
setFormData(null);
|
|
133
|
-
setOrderedColumnNames([]);
|
|
134
156
|
setSelectedColumns([]);
|
|
135
157
|
setSchemaTables([]);
|
|
158
|
+
setOrderedColumnNames([]);
|
|
136
159
|
setActiveQuery('');
|
|
137
160
|
setActiveEditItem(null);
|
|
138
161
|
setActivePath(null);
|
|
@@ -143,6 +166,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
143
166
|
setFields([]);
|
|
144
167
|
setTopLevelBinaryOperator('AND');
|
|
145
168
|
setEditPopoverKey(null);
|
|
169
|
+
setErrorMessage('');
|
|
146
170
|
// setUniqueValues({});
|
|
147
171
|
setPivot(null);
|
|
148
172
|
setPivotData(null);
|
|
@@ -242,7 +266,9 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
242
266
|
const result = [];
|
|
243
267
|
const table = tables[0];
|
|
244
268
|
const { valueField, rowField, columnField } = pivot;
|
|
245
|
-
if (columnField &&
|
|
269
|
+
if (columnField &&
|
|
270
|
+
uniqueValues[table] &&
|
|
271
|
+
uniqueValues[table][columnField]) {
|
|
246
272
|
result.push(...Object.keys(uniqueValues[table][columnField]));
|
|
247
273
|
}
|
|
248
274
|
result.push(valueField, rowField);
|
|
@@ -280,6 +306,26 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
280
306
|
}
|
|
281
307
|
};
|
|
282
308
|
(0, react_1.useEffect)(() => {
|
|
309
|
+
const loadTable = async (tables) => {
|
|
310
|
+
if (!tables)
|
|
311
|
+
return;
|
|
312
|
+
setLoading(true);
|
|
313
|
+
await getDistinctValues(initialTableName, tables);
|
|
314
|
+
const columnsForTable = tables
|
|
315
|
+
.find((t) => t.name === initialTableName)
|
|
316
|
+
?.columns.map((c) => c.name)
|
|
317
|
+
.sort((a, b) => {
|
|
318
|
+
const aIsId = a.endsWith('.id') || a.endsWith('_id') || a.endsWith('Id');
|
|
319
|
+
const bIsId = b.endsWith('.id') || b.endsWith('_id') || b.endsWith('Id');
|
|
320
|
+
if (aIsId && !bIsId)
|
|
321
|
+
return 1;
|
|
322
|
+
if (bIsId && !aIsId)
|
|
323
|
+
return -1;
|
|
324
|
+
return 0;
|
|
325
|
+
});
|
|
326
|
+
await handleAsk(`get ${columnsForTable} from ${initialTableName}`);
|
|
327
|
+
setInitialLoad(false);
|
|
328
|
+
};
|
|
283
329
|
const fetchSchema = async () => {
|
|
284
330
|
try {
|
|
285
331
|
setLoadingSchema(true);
|
|
@@ -305,8 +351,8 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
305
351
|
setOrderedColumnNames((tables ?? []).flatMap((table) => table.columns
|
|
306
352
|
.map((c) => `${table.name}.${c.name}`)
|
|
307
353
|
.sort((a, b) => {
|
|
308
|
-
const aIsId = a.endsWith('.id') || a.endsWith('_id');
|
|
309
|
-
const bIsId = b.endsWith('.id') || b.endsWith('_id');
|
|
354
|
+
const aIsId = a.endsWith('.id') || a.endsWith('_id') || a.endsWith('Id');
|
|
355
|
+
const bIsId = b.endsWith('.id') || b.endsWith('_id') || b.endsWith('Id');
|
|
310
356
|
if (aIsId && !bIsId)
|
|
311
357
|
return 1;
|
|
312
358
|
if (bIsId && !aIsId)
|
|
@@ -314,13 +360,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
314
360
|
return 0;
|
|
315
361
|
})));
|
|
316
362
|
if (initialTableName && initialLoad) {
|
|
317
|
-
|
|
318
|
-
setLoading(true);
|
|
319
|
-
await getDistinctValues(initialTableName, tables);
|
|
320
|
-
const columnsForTable = tables
|
|
321
|
-
.find((t) => t.name === initialTableName)
|
|
322
|
-
?.columns.map((c) => c.name);
|
|
323
|
-
await handleAsk(`get ${columnsForTable} from ${initialTableName}`);
|
|
363
|
+
await loadTable(tables);
|
|
324
364
|
}
|
|
325
365
|
setLoadingSchema(false);
|
|
326
366
|
}
|
|
@@ -331,7 +371,10 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
331
371
|
if (schemaTables.length === 0) {
|
|
332
372
|
fetchSchema();
|
|
333
373
|
}
|
|
334
|
-
|
|
374
|
+
else if (initialLoad && initialTableName) {
|
|
375
|
+
loadTable(schemaTables);
|
|
376
|
+
}
|
|
377
|
+
}, [schemaTables, initialTableName]);
|
|
335
378
|
const updateFormData = (updates, { isDeletion = false, isInsertion = false, isReplaceSubtree = false, isAddVariant = false, isDeleteVariant = false, topLevelBinOp = 'OR', isCondition = undefined, }) => {
|
|
336
379
|
// Function to immutably update or delete nodes based on their path
|
|
337
380
|
// TODO: fix the following horible code
|
|
@@ -738,7 +781,9 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
738
781
|
// see onChange callback handleChange
|
|
739
782
|
// eslint-disable-next-line no-unused-vars
|
|
740
783
|
dateColumnPath, dateFilterType, intervalCount, intervalType, intervalPaths, } = (0, util_1.getDateFilterInfo)(node);
|
|
741
|
-
const isPlural = intervalCount !== 1
|
|
784
|
+
const isPlural = intervalCount !== 1 && dateFilterType !== 'in the current'
|
|
785
|
+
? 's'
|
|
786
|
+
: '';
|
|
742
787
|
// Pull off the string literal date for "equals" comparisons
|
|
743
788
|
const rawDateStringEquals = node.right?.value ??
|
|
744
789
|
node.right?.args?.value[1]?.column ??
|
|
@@ -748,50 +793,50 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
748
793
|
'node.right.args.value.1.column') ??
|
|
749
794
|
(node.right?.args?.value[1]?.value &&
|
|
750
795
|
'node.right.args.value.1.value');
|
|
751
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', gap: 20 }, children: [(0, jsx_runtime_1.jsx)(
|
|
752
|
-
const columnType = getColumnTypeByName(value);
|
|
796
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', gap: 20 }, children: [(0, jsx_runtime_1.jsx)(SelectComponent, { value: dateColumn, onChange: (event) => {
|
|
797
|
+
const columnType = getColumnTypeByName(event.target.value);
|
|
753
798
|
if ((0, ast_1.isDateishColumnType)(columnType)) {
|
|
754
799
|
// handleChange(value, keyPrefix + dateColumnPath, "text");
|
|
755
|
-
handleOperatorChange('IN_THE_LAST', node, keyPrefix, value);
|
|
800
|
+
handleOperatorChange('IN_THE_LAST', node, keyPrefix, event.target.value);
|
|
756
801
|
}
|
|
757
802
|
else if ((0, ast_1.isNumericColumnType)(columnType)) {
|
|
758
803
|
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultNumericComparison);
|
|
759
|
-
newSubtree.left.column = value;
|
|
804
|
+
newSubtree.left.column = event.target.value;
|
|
760
805
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
761
806
|
}
|
|
762
807
|
else {
|
|
763
808
|
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultEntry);
|
|
764
|
-
newSubtree.left.args.value[0].column = value;
|
|
809
|
+
newSubtree.left.args.value[0].column = event.target.value;
|
|
765
810
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
766
811
|
}
|
|
767
812
|
}, options: getAllPossibleColumns().map((column) => ({
|
|
768
813
|
label: (0, textProcessing_1.snakeCaseToTitleCase)(column.displayName),
|
|
769
814
|
value: column.name,
|
|
770
|
-
})) }), (0, jsx_runtime_1.jsx)(
|
|
771
|
-
if (value === dateFilterType)
|
|
815
|
+
})) }), (0, jsx_runtime_1.jsx)(SelectComponent, { value: dateFilterType, onChange: (event) => {
|
|
816
|
+
if (event.target.value === dateFilterType)
|
|
772
817
|
return null;
|
|
773
818
|
let newSubtree = {};
|
|
774
819
|
// TODO: implement one for each database type (eg. pg, snowflake, etc.)
|
|
775
|
-
if (value === 'in the last') {
|
|
820
|
+
if (event.target.value === 'in the last') {
|
|
776
821
|
newSubtree = (0, postgres_1.generateLastNPeriodsPostgres)({
|
|
777
822
|
dateField: dateColumn,
|
|
778
823
|
intervalPeriod: `${intervalCount ?? 1} ${intervalType}`,
|
|
779
824
|
});
|
|
780
825
|
}
|
|
781
|
-
else if (value === 'in the previous') {
|
|
826
|
+
else if (event.target.value === 'in the previous') {
|
|
782
827
|
newSubtree = (0, postgres_1.generatePreviousPeriodPostgres)({
|
|
783
828
|
dateField: dateColumn,
|
|
784
829
|
intervalPeriod: `${intervalCount ?? 1} ${intervalType}`,
|
|
785
830
|
currentPeriod: intervalType,
|
|
786
831
|
});
|
|
787
832
|
}
|
|
788
|
-
else if (value === 'in the current') {
|
|
833
|
+
else if (event.target.value === 'in the current') {
|
|
789
834
|
newSubtree = (0, postgres_1.generateCurrentPeriodPostgres)({
|
|
790
835
|
dateField: dateColumn,
|
|
791
836
|
currentPeriod: intervalType,
|
|
792
837
|
});
|
|
793
838
|
}
|
|
794
|
-
else if (value === 'equals') {
|
|
839
|
+
else if (event.target.value === 'equals') {
|
|
795
840
|
newSubtree = (0, postgres_1.generateEqualsPostgres)({
|
|
796
841
|
dateField: dateColumn,
|
|
797
842
|
currentPeriod: intervalType,
|
|
@@ -805,7 +850,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
805
850
|
{ label: 'in the previous', value: 'in the previous' },
|
|
806
851
|
{ label: 'in the current', value: 'in the current' },
|
|
807
852
|
{ label: 'equals', value: 'equals' },
|
|
808
|
-
] }), !['in the current', 'equals'].includes(dateFilterType) && ((0, jsx_runtime_1.jsx)(
|
|
853
|
+
] }), !['in the current', 'equals'].includes(dateFilterType) && ((0, jsx_runtime_1.jsx)(TextInputComponent, { id: "date_filter_interval_count", value: intervalCount?.toString() ?? '', width: 70, onChange: (e) => {
|
|
809
854
|
if (Number.isNaN(parseFloat(e.target.value || '0'))) {
|
|
810
855
|
alert('Please input a number.');
|
|
811
856
|
return;
|
|
@@ -817,13 +862,13 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
817
862
|
path: keyPrefix + intervalPath,
|
|
818
863
|
},
|
|
819
864
|
]));
|
|
820
|
-
} })), (0, jsx_runtime_1.jsx)(
|
|
865
|
+
} })), (0, jsx_runtime_1.jsx)(SelectComponent, { value: intervalType, onChange: (event) => {
|
|
821
866
|
if (intervalPaths.length === 1) {
|
|
822
867
|
handleChangeText([
|
|
823
868
|
{
|
|
824
869
|
value: intervalCount !== null
|
|
825
|
-
? `${intervalCount} ${value}${isPlural}`
|
|
826
|
-
: value,
|
|
870
|
+
? `${intervalCount} ${event.target.value}${isPlural}`
|
|
871
|
+
: event.target.value,
|
|
827
872
|
path: keyPrefix + intervalPaths[0],
|
|
828
873
|
},
|
|
829
874
|
]);
|
|
@@ -833,14 +878,14 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
833
878
|
if (dateFilterType === 'equals') {
|
|
834
879
|
newSubtree = (0, postgres_1.generateEqualsPostgres)({
|
|
835
880
|
dateField: dateColumn,
|
|
836
|
-
currentPeriod: value,
|
|
881
|
+
currentPeriod: event.target.value,
|
|
837
882
|
timestamp: rawDateStringEquals,
|
|
838
883
|
});
|
|
839
884
|
}
|
|
840
885
|
else {
|
|
841
886
|
newSubtree = (0, postgres_1.generateCurrentPeriodPostgres)({
|
|
842
887
|
dateField: dateColumn,
|
|
843
|
-
currentPeriod: value,
|
|
888
|
+
currentPeriod: event.target.value,
|
|
844
889
|
});
|
|
845
890
|
}
|
|
846
891
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
@@ -851,7 +896,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
851
896
|
{ label: `week${isPlural}`, value: 'week' },
|
|
852
897
|
{ label: `day${isPlural}`, value: 'day' },
|
|
853
898
|
{ label: `hour${isPlural}`, value: 'hour' },
|
|
854
|
-
] }), dateFilterType === 'equals' && ((0, jsx_runtime_1.jsx)(
|
|
899
|
+
] }), dateFilterType === 'equals' && ((0, jsx_runtime_1.jsx)(TextInputComponent, { id: "date_filter_equals_raw_date", value: rawDateStringEquals, width: 120, onChange: (e) => {
|
|
855
900
|
handleChangeText([
|
|
856
901
|
{
|
|
857
902
|
value: e.target.value,
|
|
@@ -872,24 +917,24 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
872
917
|
flexDirection: 'row',
|
|
873
918
|
alignItems: 'center',
|
|
874
919
|
gap: 20,
|
|
875
|
-
}, children: [(0, jsx_runtime_1.jsx)(
|
|
876
|
-
const columnType = getColumnTypeByName(value);
|
|
920
|
+
}, children: [(0, jsx_runtime_1.jsx)(SelectComponent, { value: node.left.column, onChange: (event) => {
|
|
921
|
+
const columnType = getColumnTypeByName(event.target.value);
|
|
877
922
|
if ((0, ast_1.isDateishColumnType)(columnType)) {
|
|
878
923
|
// handleChange(value, keyPrefix + dateColumnPath, "text");
|
|
879
|
-
handleOperatorChange('IN_THE_LAST', node, keyPrefix, value);
|
|
924
|
+
handleOperatorChange('IN_THE_LAST', node, keyPrefix, event.target.value);
|
|
880
925
|
}
|
|
881
926
|
else if ((0, ast_1.isNumericColumnType)(columnType)) {
|
|
882
927
|
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultNumericComparison);
|
|
883
|
-
newSubtree.left.column = value;
|
|
928
|
+
newSubtree.left.column = event.target.value;
|
|
884
929
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
885
930
|
}
|
|
886
931
|
else {
|
|
887
932
|
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultEntry);
|
|
888
|
-
newSubtree.left.args.value[0].column = value;
|
|
933
|
+
newSubtree.left.args.value[0].column = event.target.value;
|
|
889
934
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
890
935
|
}
|
|
891
|
-
}, options: options }), (0, jsx_runtime_1.jsx)(
|
|
892
|
-
handleOperatorChange(value, node, keyPrefix, dateColumn);
|
|
936
|
+
}, options: options }), (0, jsx_runtime_1.jsx)(SelectComponent, { value: 'IN_THE_LAST', onChange: (event) => {
|
|
937
|
+
handleOperatorChange(event.target.value, node, keyPrefix, dateColumn);
|
|
893
938
|
}, options: [
|
|
894
939
|
{ label: 'in the last', value: 'IN_THE_LAST' },
|
|
895
940
|
{ label: 'in the previous', value: 'IN_THE_PREVIOUS' },
|
|
@@ -897,15 +942,18 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
897
942
|
{ label: 'is not null', value: 'IS NOT' },
|
|
898
943
|
{ label: 'is null', value: 'IS' },
|
|
899
944
|
// { label: 'equals', value: 'equals' },
|
|
900
|
-
] }), (0, jsx_runtime_1.jsx)(
|
|
945
|
+
] }), (0, jsx_runtime_1.jsx)(TextInputComponent, { id: 'date_window_interval_count', value: node.right.args.value[1].expr.value, width: 120, onChange: (e) => {
|
|
901
946
|
handleChange([
|
|
902
947
|
{
|
|
903
948
|
value: e.target.value,
|
|
904
949
|
path: keyPrefix + 'right.args.value||1.expr.value',
|
|
905
950
|
},
|
|
906
951
|
]);
|
|
907
|
-
} }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(
|
|
908
|
-
{
|
|
952
|
+
} }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(SelectComponent, { value: node.right.args.value[1].unit, onChange: (event) => handleChange([
|
|
953
|
+
{
|
|
954
|
+
value: event.target.value,
|
|
955
|
+
path: keyPrefix + 'right.args.value||1.unit',
|
|
956
|
+
},
|
|
909
957
|
]), options: [
|
|
910
958
|
{ label: `year${plural}`, value: '* 365 DAY' },
|
|
911
959
|
{ label: `month${plural}`, value: '* 30 DAY' },
|
|
@@ -924,24 +972,24 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
924
972
|
flexDirection: 'row',
|
|
925
973
|
alignItems: 'center',
|
|
926
974
|
gap: 20,
|
|
927
|
-
}, children: [(0, jsx_runtime_1.jsx)(
|
|
928
|
-
const columnType = getColumnTypeByName(value);
|
|
975
|
+
}, children: [(0, jsx_runtime_1.jsx)(SelectComponent, { value: node.left.column, onChange: (event) => {
|
|
976
|
+
const columnType = getColumnTypeByName(event.target.value);
|
|
929
977
|
if ((0, ast_1.isDateishColumnType)(columnType)) {
|
|
930
978
|
// handleChange(value, keyPrefix + dateColumnPath, "text");
|
|
931
|
-
handleOperatorChange('IN_THE_LAST', node, keyPrefix, value);
|
|
979
|
+
handleOperatorChange('IN_THE_LAST', node, keyPrefix, event.target.value);
|
|
932
980
|
}
|
|
933
981
|
else if ((0, ast_1.isNumericColumnType)(columnType)) {
|
|
934
982
|
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultNumericComparison);
|
|
935
|
-
newSubtree.left.column = value;
|
|
983
|
+
newSubtree.left.column = event.target.value;
|
|
936
984
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
937
985
|
}
|
|
938
986
|
else {
|
|
939
987
|
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultEntry);
|
|
940
|
-
newSubtree.left.args.value[0].column = value;
|
|
988
|
+
newSubtree.left.args.value[0].column = event.target.value;
|
|
941
989
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
942
990
|
}
|
|
943
|
-
}, options: options }), (0, jsx_runtime_1.jsx)(
|
|
944
|
-
handleOperatorChange(value, node, keyPrefix, node.left.column);
|
|
991
|
+
}, options: options }), (0, jsx_runtime_1.jsx)(SelectComponent, { value: 'IN_THE_CURRENT', onChange: (event) => {
|
|
992
|
+
handleOperatorChange(event.target.value, node, keyPrefix, node.left.column);
|
|
945
993
|
}, options: [
|
|
946
994
|
{ label: 'in the last', value: 'IN_THE_LAST' },
|
|
947
995
|
{ label: 'in the previous', value: 'IN_THE_PREVIOUS' },
|
|
@@ -949,10 +997,16 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
949
997
|
{ label: 'is not null', value: 'IS NOT' },
|
|
950
998
|
{ label: 'is null', value: 'IS' },
|
|
951
999
|
// { label: 'equals', value: 'equals' },
|
|
952
|
-
] }), (0, jsx_runtime_1.jsx)(
|
|
1000
|
+
] }), (0, jsx_runtime_1.jsx)(SelectComponent, { value: node.left.args.value[1].column, onChange: (event) => {
|
|
953
1001
|
handleChange([
|
|
954
|
-
{
|
|
955
|
-
|
|
1002
|
+
{
|
|
1003
|
+
value: event.target.value,
|
|
1004
|
+
path: 'right.args.value||1.column',
|
|
1005
|
+
},
|
|
1006
|
+
{
|
|
1007
|
+
value: event.target.value,
|
|
1008
|
+
path: 'left.args.value||1.column',
|
|
1009
|
+
},
|
|
956
1010
|
]);
|
|
957
1011
|
}, options: [
|
|
958
1012
|
{ label: `year`, value: 'YEAR' },
|
|
@@ -971,24 +1025,24 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
971
1025
|
flexDirection: 'row',
|
|
972
1026
|
alignItems: 'center',
|
|
973
1027
|
gap: 20,
|
|
974
|
-
}, children: [(0, jsx_runtime_1.jsx)(
|
|
975
|
-
const columnType = getColumnTypeByName(value);
|
|
1028
|
+
}, children: [(0, jsx_runtime_1.jsx)(SelectComponent, { value: node.left.column, onChange: (event) => {
|
|
1029
|
+
const columnType = getColumnTypeByName(event.target.value);
|
|
976
1030
|
if ((0, ast_1.isDateishColumnType)(columnType)) {
|
|
977
1031
|
// handleChange(value, keyPrefix + dateColumnPath, "text");
|
|
978
|
-
handleOperatorChange('IN_THE_LAST', node, keyPrefix, value);
|
|
1032
|
+
handleOperatorChange('IN_THE_LAST', node, keyPrefix, event.target.value);
|
|
979
1033
|
}
|
|
980
1034
|
else if ((0, ast_1.isNumericColumnType)(columnType)) {
|
|
981
1035
|
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultNumericComparison);
|
|
982
|
-
newSubtree.left.column = value;
|
|
1036
|
+
newSubtree.left.column = event.target.value;
|
|
983
1037
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
984
1038
|
}
|
|
985
1039
|
else {
|
|
986
1040
|
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultEntry);
|
|
987
|
-
newSubtree.left.args.value[0].column = value;
|
|
1041
|
+
newSubtree.left.args.value[0].column = event.target.value;
|
|
988
1042
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
989
1043
|
}
|
|
990
|
-
}, options: options }), (0, jsx_runtime_1.jsx)(
|
|
991
|
-
handleOperatorChange(value, node, keyPrefix, node.left.column);
|
|
1044
|
+
}, options: options }), (0, jsx_runtime_1.jsx)(SelectComponent, { value: 'IN_THE_PREVIOUS', onChange: (event) => {
|
|
1045
|
+
handleOperatorChange(event.target.value, node, keyPrefix, node.left.column);
|
|
992
1046
|
}, options: [
|
|
993
1047
|
{ label: 'in the last', value: 'IN_THE_LAST' },
|
|
994
1048
|
{ label: 'in the previous', value: 'IN_THE_PREVIOUS' },
|
|
@@ -996,7 +1050,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
996
1050
|
{ label: 'is not null', value: 'IS NOT' },
|
|
997
1051
|
{ label: 'is null', value: 'IS' },
|
|
998
1052
|
// { label: 'equals', value: 'equals' },
|
|
999
|
-
] }), (0, jsx_runtime_1.jsx)(
|
|
1053
|
+
] }), (0, jsx_runtime_1.jsx)(SelectComponent, { value: node.left.args.value[1].column, onChange: (event) => {
|
|
1000
1054
|
const dayConversion = {
|
|
1001
1055
|
YEAR: 365,
|
|
1002
1056
|
QUARTER: 90,
|
|
@@ -1005,15 +1059,15 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1005
1059
|
};
|
|
1006
1060
|
handleChange([
|
|
1007
1061
|
{
|
|
1008
|
-
value,
|
|
1062
|
+
value: event.target.value,
|
|
1009
1063
|
path: 'left.args.value||1.column',
|
|
1010
1064
|
},
|
|
1011
1065
|
{
|
|
1012
|
-
value,
|
|
1066
|
+
value: event.target.value,
|
|
1013
1067
|
path: 'right.args.value||1.column',
|
|
1014
1068
|
},
|
|
1015
1069
|
{
|
|
1016
|
-
value: dayConversion[value] || 30,
|
|
1070
|
+
value: dayConversion[event.target.value] || 30,
|
|
1017
1071
|
path: 'right.args.value||0.args.value||1.expr.value',
|
|
1018
1072
|
},
|
|
1019
1073
|
]);
|
|
@@ -1053,10 +1107,10 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1053
1107
|
: []),
|
|
1054
1108
|
...((0, ast_1.isTextColumnType)(columnType)
|
|
1055
1109
|
? [
|
|
1056
|
-
{ label: 'is', value: 'LIKE' },
|
|
1057
|
-
{ label: 'is not', value: 'NOT LIKE' },
|
|
1058
|
-
{ label: 'is
|
|
1059
|
-
{ label: 'is not
|
|
1110
|
+
{ label: 'is exactly', value: 'LIKE' },
|
|
1111
|
+
{ label: 'is not exactly', value: 'NOT LIKE' },
|
|
1112
|
+
{ label: 'is', value: 'IN' },
|
|
1113
|
+
{ label: 'is not', value: 'NOT IN' },
|
|
1060
1114
|
{ label: 'is not null', value: 'IS NOT' },
|
|
1061
1115
|
{ label: 'is null', value: 'IS' },
|
|
1062
1116
|
]
|
|
@@ -1088,45 +1142,48 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1088
1142
|
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
|
|
1089
1143
|
display: 'flex',
|
|
1090
1144
|
gap: 20,
|
|
1091
|
-
// justifyContent: "space-between",
|
|
1092
1145
|
flexDirection: (0, util_1.showNodeAsRow)(node, formData)
|
|
1093
1146
|
? 'row'
|
|
1094
1147
|
: 'column',
|
|
1095
1148
|
width: '100%',
|
|
1096
|
-
}, children: [(0, jsx_runtime_1.jsx)(
|
|
1097
|
-
const columnType = getColumnTypeByName(value);
|
|
1149
|
+
}, children: [(0, jsx_runtime_1.jsx)(SelectComponent, { value: leftChildValue, onChange: (event) => {
|
|
1150
|
+
const columnType = getColumnTypeByName(event.target.value);
|
|
1098
1151
|
if ((0, ast_1.isDateishColumnType)(columnType)) {
|
|
1099
|
-
handleOperatorChange('IN_THE_LAST', node, keyPrefix, value);
|
|
1152
|
+
handleOperatorChange('IN_THE_LAST', node, keyPrefix, event.target.value);
|
|
1100
1153
|
}
|
|
1101
1154
|
else if ((0, ast_1.isNumericColumnType)(columnType)) {
|
|
1102
1155
|
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultNumericComparison);
|
|
1103
|
-
newSubtree.left.column = value;
|
|
1156
|
+
newSubtree.left.column = event.target.value;
|
|
1104
1157
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
1105
1158
|
}
|
|
1106
1159
|
else {
|
|
1107
1160
|
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultEntry);
|
|
1108
|
-
newSubtree.left.args.value[0].column = value;
|
|
1161
|
+
newSubtree.left.args.value[0].column = event.target.value;
|
|
1109
1162
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
1110
1163
|
}
|
|
1111
|
-
}, options: options }), operatorOptions.length > 0 && ((0, jsx_runtime_1.jsx)(
|
|
1112
|
-
handleOperatorChange(value, node, keyPrefix, leftChildValue);
|
|
1113
|
-
},
|
|
1164
|
+
}, options: options }), operatorOptions.length > 0 && ((0, jsx_runtime_1.jsx)(SelectComponent, { value: node.operator, onChange: (event) => {
|
|
1165
|
+
handleOperatorChange(event.target.value, node, keyPrefix, leftChildValue);
|
|
1166
|
+
}, options: operatorOptions })), node.right &&
|
|
1114
1167
|
node.right.type !== 'expr_list' &&
|
|
1115
1168
|
renderNode(node.right, keyPrefix + 'right.')] }, keyPrefix), node.right && node.right.type === 'expr_list' && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
1116
1169
|
display: 'grid',
|
|
1117
1170
|
gridTemplateColumns: 'repeat(2, 1fr)',
|
|
1118
1171
|
gap: 12,
|
|
1119
|
-
}, children:
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1172
|
+
}, children: uniqueValues[table] &&
|
|
1173
|
+
Object.keys(uniqueValues[table][leftChildValue] ?? {}).map((key) => ((0, jsx_runtime_1.jsxs)("label", { style: { display: 'flex', gap: 4 }, children: [(0, jsx_runtime_1.jsx)(CheckboxComponent, { isChecked: uniqueValues[table][leftChildValue][key], onChange: (event) => {
|
|
1174
|
+
const newValues = (0, util_1.deepCopy)(uniqueValues);
|
|
1175
|
+
newValues[table][leftChildValue][key] = event.target.checked;
|
|
1176
|
+
setUniqueValues(newValues);
|
|
1177
|
+
if (event.target.checked) {
|
|
1178
|
+
handleInsertVariant(keyPrefix + 'right.' + 'value', key);
|
|
1179
|
+
}
|
|
1180
|
+
else {
|
|
1181
|
+
handleDeleteVariant(keyPrefix + 'right.' + 'value', key);
|
|
1182
|
+
}
|
|
1183
|
+
} }), (0, jsx_runtime_1.jsx)("span", { style: {
|
|
1184
|
+
fontFamily: theme.fontFamily,
|
|
1185
|
+
margin: 'auto 0',
|
|
1186
|
+
}, children: key })] }, key))) }, keyPrefix + 'right.'))] }));
|
|
1130
1187
|
}
|
|
1131
1188
|
else {
|
|
1132
1189
|
const columnName = node.left.column;
|
|
@@ -1138,9 +1195,9 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1138
1195
|
justifyContent: 'space-between',
|
|
1139
1196
|
flexDirection: (0, util_1.showNodeAsRow)(node, formData) ? 'row' : 'column',
|
|
1140
1197
|
width: '100%',
|
|
1141
|
-
}, children: [node.left && renderNode(node.left, keyPrefix + 'left.'), (0, jsx_runtime_1.jsx)(
|
|
1142
|
-
handleOperatorChange(value, node, keyPrefix);
|
|
1143
|
-
},
|
|
1198
|
+
}, children: [node.left && renderNode(node.left, keyPrefix + 'left.'), (0, jsx_runtime_1.jsx)(SelectComponent, { value: node.operator, onChange: (event) => {
|
|
1199
|
+
handleOperatorChange(event.target.value, node, keyPrefix);
|
|
1200
|
+
}, options: [
|
|
1144
1201
|
// { label: `and`, value: "AND" },
|
|
1145
1202
|
// { label: `or`, value: "OR" },
|
|
1146
1203
|
...((0, ast_1.isNumericColumnType)(columnType)
|
|
@@ -1157,10 +1214,10 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1157
1214
|
: []),
|
|
1158
1215
|
...((0, ast_1.isTextColumnType)(columnType)
|
|
1159
1216
|
? [
|
|
1160
|
-
{ label: 'is', value: 'LIKE' },
|
|
1161
|
-
{ label: 'is not', value: 'NOT LIKE' },
|
|
1162
|
-
{ label: 'is
|
|
1163
|
-
{ label: 'is not
|
|
1217
|
+
{ label: 'is exactly', value: 'LIKE' },
|
|
1218
|
+
{ label: 'is not exactly', value: 'NOT LIKE' },
|
|
1219
|
+
{ label: 'is', value: 'IN' },
|
|
1220
|
+
{ label: 'is not', value: 'NOT IN' },
|
|
1164
1221
|
{ label: 'is not null', value: 'IS NOT' },
|
|
1165
1222
|
{ label: 'is null', value: 'IS' },
|
|
1166
1223
|
]
|
|
@@ -1183,15 +1240,17 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1183
1240
|
label: (0, textProcessing_1.snakeCaseToTitleCase)(column.displayName),
|
|
1184
1241
|
value: column.name,
|
|
1185
1242
|
}));
|
|
1186
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
1187
|
-
handleChange([
|
|
1243
|
+
return ((0, jsx_runtime_1.jsx)(SelectComponent, { value: node.column ?? options[0]?.value, onChange: (event) => {
|
|
1244
|
+
handleChange([
|
|
1245
|
+
{ value: event.target.value, path: keyPrefix + 'column' },
|
|
1246
|
+
]);
|
|
1188
1247
|
}, options: options }));
|
|
1189
1248
|
}
|
|
1190
1249
|
case 'expr_list': {
|
|
1191
1250
|
const len = node.value.length;
|
|
1192
1251
|
return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'row', gap: 12 }, children: [node.value.map((elem, index) => {
|
|
1193
1252
|
if (elem.value) {
|
|
1194
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
1253
|
+
return ((0, jsx_runtime_1.jsx)(TextInputComponent, { id: `expr_list_${index}`, width: 200, value: elem.value, onChange: (e) => handleChange([
|
|
1195
1254
|
{
|
|
1196
1255
|
value: e.target.value,
|
|
1197
1256
|
path: keyPrefix + `value.${index}.`,
|
|
@@ -1199,11 +1258,11 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1199
1258
|
]) }, `input_${index}`));
|
|
1200
1259
|
}
|
|
1201
1260
|
return renderNode(elem, keyPrefix + `value.${index}.`);
|
|
1202
|
-
}), len > 1 && ((0, jsx_runtime_1.jsx)(
|
|
1261
|
+
}), len > 1 && ((0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { label: '-', onClick: () => handleDeleteVariant(keyPrefix + 'value') })), (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: () => handleInsertVariant(keyPrefix + 'value'), label: '+' })] }, keyPrefix));
|
|
1203
1262
|
}
|
|
1204
1263
|
case 'double_quote_string':
|
|
1205
1264
|
case 'single_quote_string':
|
|
1206
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
1265
|
+
return ((0, jsx_runtime_1.jsx)(TextInputComponent, { id: 'quoted_string', value: node.value.replaceAll('%', ''), width: 120, onChange: (e) => handleChange([
|
|
1207
1266
|
{
|
|
1208
1267
|
value: e.target.value,
|
|
1209
1268
|
path: keyPrefix + 'value',
|
|
@@ -1212,7 +1271,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1212
1271
|
case 'null':
|
|
1213
1272
|
return (0, jsx_runtime_1.jsx)("div", {});
|
|
1214
1273
|
case 'number':
|
|
1215
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
1274
|
+
return ((0, jsx_runtime_1.jsx)(TextInputComponent, { id: "quill_number_input", value: node.value, width: 120, onChange: (e) => {
|
|
1216
1275
|
handleChange([
|
|
1217
1276
|
{
|
|
1218
1277
|
value: e.target.value,
|
|
@@ -1285,13 +1344,13 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1285
1344
|
const OPS = {
|
|
1286
1345
|
AND: 'and',
|
|
1287
1346
|
OR: 'or',
|
|
1288
|
-
LIKE: 'is',
|
|
1347
|
+
LIKE: 'is exactly',
|
|
1289
1348
|
BETWEEN: 'is between',
|
|
1290
|
-
IN: 'is
|
|
1291
|
-
'NOT IN': 'is not
|
|
1292
|
-
'NOT LIKE': 'is not',
|
|
1293
|
-
'!=': 'is not',
|
|
1294
|
-
'=': 'is',
|
|
1349
|
+
IN: 'is',
|
|
1350
|
+
'NOT IN': 'is not',
|
|
1351
|
+
'NOT LIKE': 'is not exactly',
|
|
1352
|
+
'!=': 'is not exactly',
|
|
1353
|
+
'=': 'is exactly',
|
|
1295
1354
|
'<': 'is less than',
|
|
1296
1355
|
'>': 'is greater than',
|
|
1297
1356
|
'<=': 'is less than or equal to',
|
|
@@ -1299,25 +1358,16 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1299
1358
|
'<>': 'is not',
|
|
1300
1359
|
'-': 'minus',
|
|
1301
1360
|
'IS NOT': 'is not',
|
|
1302
|
-
IS: 'is
|
|
1361
|
+
IS: 'is',
|
|
1303
1362
|
};
|
|
1304
1363
|
switch (node.type) {
|
|
1305
1364
|
case 'binary_expr':
|
|
1306
|
-
return ((0, jsx_runtime_1.jsx)(ui_1.TagWrapper, { keyPrefix: keyPrefix, formData: formData, activeEditItem: activeEditItem, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setCheckboxes: setCheckboxes, handleReplaceSubtree: handleReplaceSubtree, FilterPopover:
|
|
1307
|
-
display: 'flex',
|
|
1308
|
-
gap: 3,
|
|
1309
|
-
flexDirection: isRow ? 'row' : 'column',
|
|
1310
|
-
padding: '1px',
|
|
1311
|
-
border: isCard ? '1px solid black' : 'none',
|
|
1312
|
-
whiteSpace: 'nowrap',
|
|
1313
|
-
overflow: 'hidden',
|
|
1314
|
-
textOverflow: 'ellipsis',
|
|
1315
|
-
}, children: dateComparisonPartialMatch ??
|
|
1365
|
+
return ((0, jsx_runtime_1.jsx)(ui_1.TagWrapper, { keyPrefix: keyPrefix, formData: formData, activeEditItem: activeEditItem, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setCheckboxes: setCheckboxes, handleReplaceSubtree: handleReplaceSubtree, FilterPopover: FilterPopoverComponent, setActivePath: setActivePath, setOpenPopover: setOpenPopover, setIsPending: setIsPending, clearCheckboxes: clearCheckboxes, fetchSqlQuery: fetchSqlQuery, handleDelete: handleDelete, editPopoverKey: editPopoverKey, isCard: isCard, isRow: isRow, getByKey: getByKey, EditPopover: ui_1.EditPopover, Button: ButtonComponent, renderNode: renderNode, children: dateComparisonPartialMatch ??
|
|
1316
1366
|
dateEqualityPartialMatch ??
|
|
1317
1367
|
isInTheCurrentIntervalSentence ??
|
|
1318
1368
|
isInTheLastIntervalSentence ??
|
|
1319
1369
|
isInThePreviousIntervalSentence ?? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [node.left &&
|
|
1320
|
-
renderSentence(formData, node.left, keyPrefix + 'left.', false, false, isRow), isRow ? (' ' + OPS[node.operator] + ' ') : isTopLevel || topLevelBinaryOperator === 'OR' ? ((0, jsx_runtime_1.jsx)(TopLevelBooleanSwitch, { node: node, keyPrefix: keyPrefix, handleOperatorChange: handleOperatorChange, Select:
|
|
1370
|
+
renderSentence(formData, node.left, keyPrefix + 'left.', false, false, isRow), isRow ? (' ' + OPS[node.operator] + ' ') : isTopLevel || topLevelBinaryOperator === 'OR' ? ((0, jsx_runtime_1.jsx)(TopLevelBooleanSwitch, { node: node, keyPrefix: keyPrefix, handleOperatorChange: handleOperatorChange, Select: SelectComponent })) : null, node.right &&
|
|
1321
1371
|
renderSentence(formData, node.right, keyPrefix + 'right.', false, false, isRow)] })) }));
|
|
1322
1372
|
case 'column_ref':
|
|
1323
1373
|
return (0, textProcessing_1.snakeCaseToTitleCase)(node.column);
|
|
@@ -1352,6 +1402,9 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1352
1402
|
if (node.args.value.length < 1)
|
|
1353
1403
|
return null;
|
|
1354
1404
|
if (node.args.value[0].value) {
|
|
1405
|
+
if (node.args.value[0].type === 'single_quote_string') {
|
|
1406
|
+
return node.args.value[0].value.replaceAll('%', '');
|
|
1407
|
+
}
|
|
1355
1408
|
return (0, textProcessing_1.snakeCaseToTitleCase)(node.args.value[0].value.replaceAll('%', ''));
|
|
1356
1409
|
}
|
|
1357
1410
|
if (node.args.value[0].column)
|
|
@@ -1399,9 +1452,11 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1399
1452
|
}))
|
|
1400
1453
|
.sort((a, b) => {
|
|
1401
1454
|
const aIsId = a.name.toLowerCase() === 'id' ||
|
|
1402
|
-
a.name.toLowerCase().endsWith('_id')
|
|
1455
|
+
a.name.toLowerCase().endsWith('_id') ||
|
|
1456
|
+
a.name.endsWith('Id');
|
|
1403
1457
|
const bIsId = b.name.toLowerCase() === 'id' ||
|
|
1404
|
-
b.name.toLowerCase().endsWith('_id')
|
|
1458
|
+
b.name.toLowerCase().endsWith('_id') ||
|
|
1459
|
+
b.name.endsWith('Id');
|
|
1405
1460
|
if (aIsId && !bIsId)
|
|
1406
1461
|
return 1;
|
|
1407
1462
|
if (bIsId && !aIsId)
|
|
@@ -1418,7 +1473,8 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1418
1473
|
return false;
|
|
1419
1474
|
const allColumns = orderedColumnNames.filter((row) => {
|
|
1420
1475
|
const [table, _] = row.split('.');
|
|
1421
|
-
|
|
1476
|
+
const selectedTable = selectedColumns[0].split('.')[0];
|
|
1477
|
+
return selectedTable === table;
|
|
1422
1478
|
});
|
|
1423
1479
|
return selectedColumns.length === allColumns.length;
|
|
1424
1480
|
};
|
|
@@ -1437,12 +1493,12 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1437
1493
|
fontSize: 18,
|
|
1438
1494
|
margin: 0,
|
|
1439
1495
|
textAlign: 'left',
|
|
1440
|
-
}, children: "Add condition" }), (0, jsx_runtime_1.jsx)(
|
|
1496
|
+
}, children: "Add condition" }), (0, jsx_runtime_1.jsx)(TabsComponent, { value: topLevelBinaryOperator, options: UiComponents_1.DEFAULT_TAB_OPTIONS, onChange: (event) => setTopLevelBinaryOperator(event.target.value) }), activeEditItem && renderNode(activeEditItem), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
1441
1497
|
display: 'flex',
|
|
1442
1498
|
flexDirection: 'row',
|
|
1443
1499
|
gap: 8,
|
|
1444
1500
|
justifyContent: 'end',
|
|
1445
|
-
}, children: (0, jsx_runtime_1.jsx)(
|
|
1501
|
+
}, children: (0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: onSave, label: 'Add condition' }) })] }));
|
|
1446
1502
|
};
|
|
1447
1503
|
const fetchUponChange = async (baseAst, newFormData) => {
|
|
1448
1504
|
// if newFormData is null still use it
|
|
@@ -1703,9 +1759,8 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1703
1759
|
newAst = (0, convert_1.convertRemoveSimpleParentheses)(newAst);
|
|
1704
1760
|
const table = (0, ast_1.getTableNames)(newAst)[0] ?? initialTableName;
|
|
1705
1761
|
const tableAlias = (0, ast_1.getTableAliases)(newAst)[0] ?? initialTableName;
|
|
1706
|
-
newAst = (0, util_1.removeNonSelectedTableReferences)(newAst, tableAlias ?? table);
|
|
1762
|
+
newAst = (0, util_1.removeNonSelectedTableReferences)(newAst, tableAlias ?? table, getAllPossibleColumns().map((col) => col.name));
|
|
1707
1763
|
// newAst = convertDateComparison(newAst); // TODO
|
|
1708
|
-
ast = newAst; // so we fetch data for newAst later.
|
|
1709
1764
|
if (table !== currentTable) {
|
|
1710
1765
|
await getDistinctValues(table);
|
|
1711
1766
|
setCurrentTable(table);
|
|
@@ -1725,6 +1780,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1725
1780
|
}));
|
|
1726
1781
|
if (groupByPivot) {
|
|
1727
1782
|
setBaseAst((0, util_1.deepCopy)({ ...newAst, orderby: null, limit: null }));
|
|
1783
|
+
newAst = (0, util_1.deepCopy)({ ...newAst, orderby: null, limit: null });
|
|
1728
1784
|
}
|
|
1729
1785
|
else {
|
|
1730
1786
|
setBaseAst((0, util_1.deepCopy)({ ...newAst }));
|
|
@@ -1734,6 +1790,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1734
1790
|
// @ts-ignore
|
|
1735
1791
|
newAst?.where ? newAst?.where?.operator : 'AND');
|
|
1736
1792
|
}
|
|
1793
|
+
ast = newAst; // so we fetch data for newAst later.
|
|
1737
1794
|
const res2 = await fetch('https://quill-344421.uc.r.appspot.com/patterns', {
|
|
1738
1795
|
method: 'POST',
|
|
1739
1796
|
headers: {
|
|
@@ -1814,11 +1871,11 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1814
1871
|
fetchSqlQuery(newAst);
|
|
1815
1872
|
};
|
|
1816
1873
|
function TopLevelBooleanSwitch({ node, keyPrefix, handleOperatorChange, }) {
|
|
1817
|
-
return ((0, jsx_runtime_1.jsx)("div", { style: { width: 'fit-content' }, children: (0, jsx_runtime_1.jsx)(
|
|
1874
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: { width: 'fit-content' }, children: (0, jsx_runtime_1.jsx)(TabsComponent, { value: node.operator, options: UiComponents_1.DEFAULT_TAB_OPTIONS, onChange: (event) => {
|
|
1818
1875
|
if (loading) {
|
|
1819
1876
|
return;
|
|
1820
1877
|
}
|
|
1821
|
-
handleOperatorChange(value, node, keyPrefix);
|
|
1878
|
+
handleOperatorChange(event.target.value, node, keyPrefix);
|
|
1822
1879
|
} }) }));
|
|
1823
1880
|
}
|
|
1824
1881
|
const DraggableItem = ({ id, label, onDelete }) => {
|
|
@@ -1827,9 +1884,9 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1827
1884
|
transform: utilities_1.CSS.Transform.toString(transform),
|
|
1828
1885
|
transition,
|
|
1829
1886
|
};
|
|
1830
|
-
return ((0, jsx_runtime_1.jsx)("div", { style: { ...style }, ref: setNodeRef, children: (0, jsx_runtime_1.jsx)(
|
|
1887
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: { ...style }, ref: setNodeRef, children: (0, jsx_runtime_1.jsx)(DraggableColumnComponent, { label: (0, textProcessing_1.snakeCaseToTitleCase)(label), onDelete: onDelete, DragHandle: (props) => ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
1831
1888
|
cursor: 'grab',
|
|
1832
|
-
}, ...attributes, ...listeners, children: (0, jsx_runtime_1.jsx)(
|
|
1889
|
+
}, ...attributes, ...listeners, children: (0, jsx_runtime_1.jsx)(props.dragIcon, {}) })) }) }));
|
|
1833
1890
|
};
|
|
1834
1891
|
function DraggableColumns() {
|
|
1835
1892
|
const sensors = (0, core_1.useSensors)((0, core_1.useSensor)(core_1.PointerSensor), (0, core_1.useSensor)(core_1.KeyboardSensor, {
|
|
@@ -1839,8 +1896,8 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1839
1896
|
function handleDragEnd(event) {
|
|
1840
1897
|
const { active, over } = event;
|
|
1841
1898
|
if (active.id !== over.id) {
|
|
1842
|
-
const oldIndex = orderedColumnNames.findIndex((c) => c.endsWith(active.id));
|
|
1843
|
-
const newIndex = orderedColumnNames.findIndex((c) => c.endsWith(over.id));
|
|
1899
|
+
const oldIndex = orderedColumnNames.findIndex((c) => c.endsWith(`${currentTable}.${active.id}`));
|
|
1900
|
+
const newIndex = orderedColumnNames.findIndex((c) => c.endsWith(`${currentTable}.${over.id}`));
|
|
1844
1901
|
const newOrder = (0, sortable_1.arrayMove)(orderedColumnNames, oldIndex, newIndex);
|
|
1845
1902
|
setOrderedColumnNames(newOrder);
|
|
1846
1903
|
const orderedSelectedColumns = [];
|
|
@@ -1895,25 +1952,27 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1895
1952
|
flexDirection: 'row',
|
|
1896
1953
|
height: '100%',
|
|
1897
1954
|
...containerStyle,
|
|
1898
|
-
}, ref: parentRef, children: [(0, jsx_runtime_1.jsxs)(
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1955
|
+
}, ref: parentRef, children: [(0, jsx_runtime_1.jsxs)(SidebarComponent, { children: [(0, jsx_runtime_1.jsx)(SidebarHeadingComponent, { label: "Columns" }), (0, jsx_runtime_1.jsx)("div", { style: { height: 4, width: '100%' } }), (0, jsx_runtime_1.jsx)(DraggableColumns, {}), (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: () => {
|
|
1956
|
+
if (loadingSchema)
|
|
1957
|
+
return;
|
|
1958
|
+
if (!openPopover) {
|
|
1959
|
+
setOpenPopover('AddColumnPopover');
|
|
1960
|
+
}
|
|
1961
|
+
}, label: 'Select columns' }), (0, jsx_runtime_1.jsx)(PopoverComponent, { isOpen: openPopover === 'AddColumnPopover', setIsOpen: (isOpen) => {
|
|
1962
|
+
if (!isOpen) {
|
|
1963
|
+
setIsPending(false);
|
|
1964
|
+
setActiveEditItem(null);
|
|
1965
|
+
setActivePath(null);
|
|
1966
|
+
setOpenPopover(null);
|
|
1967
|
+
}
|
|
1968
|
+
}, popoverTitle: "Select columns", popoverChildren: (0, jsx_runtime_1.jsx)(AddColumnPopover_1.default, { onSave: () => {
|
|
1910
1969
|
setActiveEditItem(null);
|
|
1911
1970
|
setActivePath(null);
|
|
1912
1971
|
setOpenPopover(null);
|
|
1913
1972
|
}, orderedColumnNames: orderedColumnNames, setOrderedColumnNames: setOrderedColumnNames, selectedColumns: selectedColumns, setSelectedColumns: setSelectedColumns, isSelectedAllColumns: isSelectedAllColumns, clearAllState: clearAllState, nameToColumn: nameToColumn, baseAst: baseAst, setBaseAst: (newAst) => {
|
|
1914
1973
|
setBaseAst(newAst);
|
|
1915
1974
|
fetchSqlQuery(newAst);
|
|
1916
|
-
}, pivot: pivot, initialTableName: initialTableName, defaultAST: constants_1.defaultAST, defaultTable: constants_1.defaultTable, setPivot: setPivot, TextInput:
|
|
1975
|
+
}, pivot: pivot, initialTableName: initialTableName, defaultAST: constants_1.defaultAST, defaultTable: constants_1.defaultTable, setPivot: setPivot, TextInput: TextInputComponent, SelectColumn: SelectColumnComponent, SecondaryButton: SecondaryButtonComponent, Button: ButtonComponent }) }), (0, jsx_runtime_1.jsx)("div", { style: { height: 28, width: '100%' } }), (0, jsx_runtime_1.jsx)(SidebarHeadingComponent, { label: "Filters" }), (0, jsx_runtime_1.jsx)("div", { style: { height: 4, width: '100%' } }), formData && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
1917
1976
|
display: 'flex',
|
|
1918
1977
|
flexDirection: 'column',
|
|
1919
1978
|
gap: 8,
|
|
@@ -1923,39 +1982,41 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1923
1982
|
flexDirection: 'column',
|
|
1924
1983
|
gap: 2.5,
|
|
1925
1984
|
alignItems: 'flex-start',
|
|
1926
|
-
}, children: [(0, jsx_runtime_1.jsx)(
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1985
|
+
}, children: [(0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: () => {
|
|
1986
|
+
if (!selectedColumns ||
|
|
1987
|
+
selectedColumns.length === 0 ||
|
|
1988
|
+
loading) {
|
|
1989
|
+
return;
|
|
1990
|
+
}
|
|
1991
|
+
if (!openPopover) {
|
|
1992
|
+
const value = orderedColumnNames[0];
|
|
1993
|
+
const [_table, column] = value.split('.');
|
|
1994
|
+
const columnType = getColumnTypeByName(column);
|
|
1995
|
+
if ((0, ast_1.isNumericColumnType)(columnType)) {
|
|
1996
|
+
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultNumericComparison);
|
|
1997
|
+
newSubtree.left.column = column;
|
|
1998
|
+
setActiveEditItem(newSubtree);
|
|
1931
1999
|
}
|
|
1932
|
-
|
|
1933
|
-
const
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
if ((0, ast_1.isNumericColumnType)(columnType)) {
|
|
1937
|
-
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultNumericComparison);
|
|
1938
|
-
newSubtree.left.column = column;
|
|
1939
|
-
setActiveEditItem(newSubtree);
|
|
1940
|
-
}
|
|
1941
|
-
else {
|
|
1942
|
-
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultEntry);
|
|
1943
|
-
newSubtree.left.args.value[0].column = column;
|
|
1944
|
-
setActiveEditItem(newSubtree);
|
|
1945
|
-
}
|
|
1946
|
-
setOpenPopover('AddFilterPopover');
|
|
1947
|
-
setActivePath('');
|
|
1948
|
-
setIsPending(true);
|
|
2000
|
+
else {
|
|
2001
|
+
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultEntry);
|
|
2002
|
+
newSubtree.left.args.value[0].column = column;
|
|
2003
|
+
setActiveEditItem(newSubtree);
|
|
1949
2004
|
}
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
2005
|
+
setOpenPopover('AddFilterPopover');
|
|
2006
|
+
setActivePath('');
|
|
2007
|
+
setIsPending(true);
|
|
2008
|
+
}
|
|
2009
|
+
}, label: 'Add filter' }), (0, jsx_runtime_1.jsx)(PopoverComponent, { isOpen: openPopover === 'AddFilterPopover', setIsOpen: (isOpen) => {
|
|
2010
|
+
if (!isOpen) {
|
|
2011
|
+
setIsPending(false);
|
|
2012
|
+
setActivePath(null);
|
|
2013
|
+
setOpenPopover(null);
|
|
2014
|
+
clearCheckboxes();
|
|
2015
|
+
setTimeout(() => {
|
|
2016
|
+
setActiveEditItem(null);
|
|
2017
|
+
}, 300);
|
|
2018
|
+
}
|
|
2019
|
+
}, popoverTitle: 'Add filter', popoverChildren: (0, jsx_runtime_1.jsx)(ui_1.AddFilterPopover, { onSave: () => {
|
|
1959
2020
|
if ((0, util_1.isNodeEmptyCollection)(activeEditItem)) {
|
|
1960
2021
|
setIsPending(false);
|
|
1961
2022
|
setActivePath(null);
|
|
@@ -1975,44 +2036,46 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1975
2036
|
setActiveEditItem(null);
|
|
1976
2037
|
}, 300);
|
|
1977
2038
|
}
|
|
1978
|
-
}, Button:
|
|
2039
|
+
}, Button: ButtonComponent, renderNode: renderNode, activeEditItem: activeEditItem }) }), baseAst?.where &&
|
|
1979
2040
|
false && ( // temp removed the AddConditionPopover
|
|
1980
|
-
(0, jsx_runtime_1.
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2041
|
+
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: () => {
|
|
2042
|
+
if (!openPopover) {
|
|
2043
|
+
setActiveEditItem((0, util_1.deepCopy)(constants_1.defaultEntry));
|
|
2044
|
+
setOpenPopover('AddConditionPopover');
|
|
2045
|
+
setActivePath('');
|
|
2046
|
+
setIsPending(true);
|
|
2047
|
+
}
|
|
2048
|
+
}, label: "Add condition" }), (0, jsx_runtime_1.jsx)(PopoverComponent, { isOpen: openPopover === 'AddConditionPopover', setIsOpen: (isOpen) => {
|
|
2049
|
+
if (!isOpen) {
|
|
2050
|
+
setIsPending(false);
|
|
2051
|
+
setTimeout(() => {
|
|
2052
|
+
setActiveEditItem(null);
|
|
2053
|
+
}, 300);
|
|
2054
|
+
setActivePath(null);
|
|
2055
|
+
setOpenPopover(null);
|
|
2056
|
+
clearCheckboxes();
|
|
2057
|
+
}
|
|
2058
|
+
}, popoverTitle: "Add condition", popoverChildren: (0, jsx_runtime_1.jsx)(AddConditionPopover, { onSave: () => {
|
|
2059
|
+
if ((0, util_1.isNodeEmptyCollection)(activeEditItem)) {
|
|
2060
|
+
setIsPending(false);
|
|
2061
|
+
setTimeout(() => {
|
|
2062
|
+
setActiveEditItem(null);
|
|
2063
|
+
}, 300);
|
|
2064
|
+
setActivePath(null);
|
|
2065
|
+
setOpenPopover(null);
|
|
2066
|
+
clearCheckboxes();
|
|
2067
|
+
}
|
|
2068
|
+
else {
|
|
2069
|
+
setIsPending(false);
|
|
2070
|
+
handleInsertion(activeEditItem, topLevelBinaryOperator, true);
|
|
2071
|
+
setTimeout(() => {
|
|
2072
|
+
setActiveEditItem(null);
|
|
2073
|
+
}, 300);
|
|
2074
|
+
setActivePath(null);
|
|
2075
|
+
setOpenPopover(null);
|
|
2076
|
+
clearCheckboxes();
|
|
2077
|
+
}
|
|
2078
|
+
} }) })] }))] }), (0, jsx_runtime_1.jsx)("div", { style: { height: 28, width: '100%' } }), (0, jsx_runtime_1.jsx)(SidebarHeadingComponent, { label: "Pivot" }), (0, jsx_runtime_1.jsx)("div", { style: { height: 4, width: '100%' } }), (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, PopoverComponent: PopoverComponent, TextComponent: TextComponent, isOpen: showPivotPopover, setIsOpen: setShowPivotPopover, showUpdatePivot: isEdittingPivot, setShowUpdatePivot: setIsEdittingPivot, parentRef: parentRef, data: rows, columns: processColumnsForChartBuilder(Object.keys(rows[0] ?? {})), triggerButtonText: 'Add pivot', selectedPivotIndex: selectedPivotIndex, setSelectedPivotIndex: setSelectedPivotIndex, removePivot: () => {
|
|
2016
2079
|
setPivot(null);
|
|
2017
2080
|
setPivotData(null);
|
|
2018
2081
|
},
|
|
@@ -2026,7 +2089,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2026
2089
|
setPivot(pivot);
|
|
2027
2090
|
const pivotedData = (0, PivotModal_1.generatePivotTable)(pivot, rows, [null, null, null], false);
|
|
2028
2091
|
setPivotData(pivotedData || []);
|
|
2029
|
-
}, selectPivotOnEdit: true, showTrigger: !pivot, theme: theme, LabelComponent:
|
|
2092
|
+
}, selectPivotOnEdit: true, showTrigger: !pivot, theme: theme, LabelComponent: LabelComponent, HeaderComponent: HeaderComponent, dateRange: [null, null, null], recommendPivotCount: 3, SecondaryButtonComponent: SecondaryButtonComponent }), pivot && ((0, jsx_runtime_1.jsx)(PivotList_1.PivotCard, { pivotTable: {
|
|
2030
2093
|
pivot: pivot,
|
|
2031
2094
|
rows: pivotData?.rows || [],
|
|
2032
2095
|
columns: pivotData?.columns || [],
|
|
@@ -2038,11 +2101,11 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2038
2101
|
setPivotValueField(pivot?.valueField);
|
|
2039
2102
|
setPivotAggregation(pivot?.aggregationType);
|
|
2040
2103
|
setPivotPopUpTitle('Edit Pivot');
|
|
2041
|
-
}, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent:
|
|
2104
|
+
}, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent: ButtonComponent, HeaderComponent: HeaderComponent, showEdit: false, onClose: () => {
|
|
2042
2105
|
setPivot(null);
|
|
2043
2106
|
setPivotData(null);
|
|
2044
2107
|
setBaseAst((0, util_1.deepCopy)(baseAst)); // trigger refetch
|
|
2045
|
-
}, minHeight: 180, LabelComponent:
|
|
2108
|
+
}, minHeight: 180, LabelComponent: LabelComponent, TextComponent: TextComponent })), (0, jsx_runtime_1.jsx)("div", { style: { height: 28, width: '100%' } }), (0, jsx_runtime_1.jsx)(SidebarHeadingComponent, { label: "Sort" }), (0, jsx_runtime_1.jsx)("div", { style: { height: 4, width: '100%' } }), pivot && pivot.sort && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
2046
2109
|
display: 'flex',
|
|
2047
2110
|
flexDirection: 'column',
|
|
2048
2111
|
gap: 8,
|
|
@@ -2050,7 +2113,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2050
2113
|
}, children: (0, jsx_runtime_1.jsx)(AddSortPopover_1.SortSentence, { sortData: {
|
|
2051
2114
|
type: pivot.sortDirection,
|
|
2052
2115
|
expr: { type: 'column_ref', column: pivot.rowField },
|
|
2053
|
-
}, columns: selectedColumns, setIsPending: setIsPending, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setOpenPopover: setOpenPopover, SortPopover:
|
|
2116
|
+
}, columns: selectedColumns, setIsPending: setIsPending, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setActivePath: setActivePath, setOpenPopover: setOpenPopover, SortPopover: SortPopoverComponent, EditPopover: AddSortPopover_1.AddSortPopover, handleDelete: () => {
|
|
2054
2117
|
setPivot({ ...pivot, sort: false });
|
|
2055
2118
|
setBaseAst((0, util_1.deepCopy)(baseAst));
|
|
2056
2119
|
if (!pivot) {
|
|
@@ -2063,7 +2126,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2063
2126
|
if (!pivot) {
|
|
2064
2127
|
fetchSqlQuery(baseAst);
|
|
2065
2128
|
}
|
|
2066
|
-
}, Select:
|
|
2129
|
+
}, Select: SelectComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent }, `sort-sentence-pivot`) })), baseAst && baseAst.orderby && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
2067
2130
|
display: 'flex',
|
|
2068
2131
|
flexDirection: 'column',
|
|
2069
2132
|
gap: 8,
|
|
@@ -2090,31 +2153,33 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2090
2153
|
if (!pivot) {
|
|
2091
2154
|
fetchSqlQuery(newAst);
|
|
2092
2155
|
}
|
|
2093
|
-
}, setIsPending: setIsPending, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setOpenPopover: setOpenPopover, SortPopover:
|
|
2156
|
+
}, setIsPending: setIsPending, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setActivePath: setActivePath, setOpenPopover: setOpenPopover, SortPopover: SortPopoverComponent, EditPopover: AddSortPopover_1.AddSortPopover, handleDelete: () => {
|
|
2094
2157
|
const newAst = { ...baseAst };
|
|
2095
2158
|
newAst.orderby.splice(id, 1);
|
|
2096
2159
|
setBaseAst((0, util_1.deepCopy)(newAst));
|
|
2097
2160
|
if (!pivot) {
|
|
2098
2161
|
fetchSqlQuery(newAst);
|
|
2099
2162
|
}
|
|
2100
|
-
}, Select:
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2163
|
+
}, Select: SelectComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent }, `sort-sentence-${id}`))) })), (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: () => {
|
|
2164
|
+
if (!selectedColumns || selectedColumns.length === 0) {
|
|
2165
|
+
return;
|
|
2166
|
+
}
|
|
2167
|
+
if (!openPopover) {
|
|
2168
|
+
setOpenPopover('AddSortPopover');
|
|
2169
|
+
}
|
|
2170
|
+
}, label: "Add sort" }), (0, jsx_runtime_1.jsx)(PopoverComponent, { isOpen: openPopover === 'AddSortPopover', setIsOpen: (isOpen) => {
|
|
2171
|
+
if (!isOpen) {
|
|
2172
|
+
setIsPending(false);
|
|
2173
|
+
setActiveEditItem(null);
|
|
2174
|
+
setActivePath(null);
|
|
2175
|
+
setOpenPopover(null);
|
|
2176
|
+
}
|
|
2177
|
+
}, popoverTitle: "Sort by", popoverChildren: (0, jsx_runtime_1.jsx)(AddSortPopover_1.AddSortPopover, { columns: selectedColumns, Select: SelectComponent, Button: ButtonComponent, onSave: () => { } }) }), (0, jsx_runtime_1.jsx)("div", { style: { height: 28, width: '100%' } }), (0, jsx_runtime_1.jsx)(SidebarHeadingComponent, { label: "Limit" }), (0, jsx_runtime_1.jsx)("div", { style: { height: 4, width: '100%' } }), baseAst && baseAst.limit ? ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
2113
2178
|
display: 'flex',
|
|
2114
2179
|
flexDirection: 'column',
|
|
2115
2180
|
gap: 8,
|
|
2116
2181
|
marginBottom: 12,
|
|
2117
|
-
}, children: (0, jsx_runtime_1.jsx)(AddLimitPopover_1.LimitSentence, { limit: baseAst.limit, setOpenPopover: setOpenPopover, LimitPopover:
|
|
2182
|
+
}, children: (0, jsx_runtime_1.jsx)(AddLimitPopover_1.LimitSentence, { limit: baseAst.limit, setOpenPopover: setOpenPopover, LimitPopover: LimitPopoverComponent, EditPopover: AddLimitPopover_1.AddLimitPopover, handleDelete: () => {
|
|
2118
2183
|
const newAst = { ...baseAst };
|
|
2119
2184
|
newAst.limit = null;
|
|
2120
2185
|
setBaseAst((0, util_1.deepCopy)(newAst));
|
|
@@ -2133,27 +2198,29 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2133
2198
|
setOpenPopover(null);
|
|
2134
2199
|
setBaseAst((0, util_1.deepCopy)(newAst));
|
|
2135
2200
|
fetchSqlQuery(newAst);
|
|
2136
|
-
}, TextInput:
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2201
|
+
}, TextInput: TextInputComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent }) })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: () => {
|
|
2202
|
+
if (!openPopover) {
|
|
2203
|
+
setOpenPopover('AddLimitPopover');
|
|
2204
|
+
}
|
|
2205
|
+
}, label: 'Add limit' }), (0, jsx_runtime_1.jsx)(PopoverComponent, { isOpen: openPopover === 'AddLimitPopover', setIsOpen: (isOpen) => {
|
|
2206
|
+
if (!isOpen) {
|
|
2207
|
+
setIsPending(false);
|
|
2208
|
+
setActiveEditItem(null);
|
|
2209
|
+
setActivePath(null);
|
|
2210
|
+
setOpenPopover(null);
|
|
2211
|
+
}
|
|
2212
|
+
}, popoverTitle: "Limit", popoverChildren: (0, jsx_runtime_1.jsx)(TextInputComponent, { id: "loading_input_limit", value: '0', width: 120, onChange: () => { } }) })] }))] }), (0, jsx_runtime_1.jsxs)(ContainerComponent, { children: [isAIEnabled && ((0, jsx_runtime_1.jsxs)("form", { ref: askAILoadingContainerRef, onSubmit: (event) => {
|
|
2146
2213
|
event.preventDefault();
|
|
2147
2214
|
}, style: {
|
|
2148
2215
|
display: 'flex',
|
|
2149
2216
|
flexDirection: 'row',
|
|
2150
2217
|
gap: 12,
|
|
2151
2218
|
padding: 1,
|
|
2152
|
-
}, children: [(0, jsx_runtime_1.jsx)(
|
|
2219
|
+
}, children: [(0, jsx_runtime_1.jsx)(TextInputComponent, { id: "ask_ai_loading_bar", placeholder: baseAst ? 'Ask a follow-up question...' : 'Ask a question...', width: askAILoadingContainerWidth, value: aiPrompt, onChange: () => { } }), (0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: () => { }, label: "Ask AI" }), baseAst && ((0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: clearAllState, label: "New report" }))] })), (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(TableComponent, { isLoading: true, rows: [], columns: [] }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
2153
2220
|
display: 'flex',
|
|
2154
2221
|
flexDirection: 'row',
|
|
2155
2222
|
gap: '12px',
|
|
2156
|
-
}, children: [(0, jsx_runtime_1.jsx)("div", { style: { width: '100%' } }), (0, jsx_runtime_1.jsx)(
|
|
2223
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { style: { width: '100%' } }), (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: () => copyToClipboard(activeQuery), label: isCopying ? '✅ Copied' : 'Copy SQL' }), (0, jsx_runtime_1.jsx)(ButtonComponent, { label: 'Add to dashboard', onClick: () => { } })] })] })] }), (0, jsx_runtime_1.jsx)("style", { children: `body{margin:0;}` })] }));
|
|
2157
2224
|
}
|
|
2158
2225
|
return ((0, jsx_runtime_1.jsxs)("div", { ref: parentRef, style: {
|
|
2159
2226
|
display: 'flex',
|
|
@@ -2162,26 +2229,28 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2162
2229
|
overflowY: 'auto',
|
|
2163
2230
|
boxSizing: 'border-box',
|
|
2164
2231
|
...containerStyle,
|
|
2165
|
-
}, children: [(0, jsx_runtime_1.jsxs)(
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2232
|
+
}, children: [(0, jsx_runtime_1.jsxs)(SidebarComponent, { children: [(0, jsx_runtime_1.jsx)(SidebarHeadingComponent, { label: "Columns" }), (0, jsx_runtime_1.jsx)("div", { style: { height: 4, width: '100%' } }), (0, jsx_runtime_1.jsx)(DraggableColumns, {}), (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: () => {
|
|
2233
|
+
if (!openPopover) {
|
|
2234
|
+
setOpenPopover('AddColumnPopover');
|
|
2235
|
+
}
|
|
2236
|
+
}, label: "Select columns" }), (0, jsx_runtime_1.jsx)(PopoverComponent, { isOpen: openPopover === 'AddColumnPopover', setIsOpen: (isOpen) => {
|
|
2237
|
+
if (!isOpen) {
|
|
2238
|
+
// delay onClose callback so onClick no-ops
|
|
2239
|
+
setTimeout(() => {
|
|
2240
|
+
setIsPending(false);
|
|
2241
|
+
setActiveEditItem(null);
|
|
2242
|
+
setActivePath(null);
|
|
2243
|
+
setOpenPopover(null);
|
|
2244
|
+
}, 100);
|
|
2245
|
+
}
|
|
2246
|
+
}, popoverTitle: "Select columns", popoverChildren: (0, jsx_runtime_1.jsx)(AddColumnPopover_1.default, { onSave: () => {
|
|
2178
2247
|
setActiveEditItem(null);
|
|
2179
2248
|
setActivePath(null);
|
|
2180
2249
|
setOpenPopover(null);
|
|
2181
2250
|
}, orderedColumnNames: orderedColumnNames, setOrderedColumnNames: setOrderedColumnNames, selectedColumns: selectedColumns, setSelectedColumns: setSelectedColumns, isSelectedAllColumns: isSelectedAllColumns, clearAllState: clearAllState, nameToColumn: nameToColumn, baseAst: baseAst, setBaseAst: (ast) => {
|
|
2182
2251
|
setBaseAst(ast);
|
|
2183
2252
|
fetchSqlQuery(ast);
|
|
2184
|
-
}, pivot: pivot, initialTableName: initialTableName, defaultAST: constants_1.defaultAST, defaultTable: constants_1.defaultTable, setPivot: setPivot, TextInput:
|
|
2253
|
+
}, pivot: pivot, initialTableName: initialTableName, defaultAST: constants_1.defaultAST, defaultTable: constants_1.defaultTable, setPivot: setPivot, TextInput: TextInputComponent, SelectColumn: SelectColumnComponent, SecondaryButton: SecondaryButtonComponent, Button: ButtonComponent }) }), (0, jsx_runtime_1.jsx)("div", { style: { height: 28, width: '100%' } }), (0, jsx_runtime_1.jsx)(SidebarHeadingComponent, { label: "Filters" }), (0, jsx_runtime_1.jsx)("div", { style: { height: 4, width: '100%' } }), formData && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
2185
2254
|
display: 'flex',
|
|
2186
2255
|
flexDirection: 'column',
|
|
2187
2256
|
gap: 8,
|
|
@@ -2191,52 +2260,42 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2191
2260
|
flexDirection: 'column',
|
|
2192
2261
|
gap: 2.5,
|
|
2193
2262
|
alignItems: 'flex-start',
|
|
2194
|
-
}, children: [(0, jsx_runtime_1.jsx)(
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2263
|
+
}, children: [(0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: () => {
|
|
2264
|
+
if (!selectedColumns || selectedColumns.length === 0 || loading) {
|
|
2265
|
+
return;
|
|
2266
|
+
}
|
|
2267
|
+
if (!openPopover) {
|
|
2268
|
+
const value = orderedColumnNames[0];
|
|
2269
|
+
const [_table, column] = value.split('.');
|
|
2270
|
+
const columnType = getColumnTypeByName(column);
|
|
2271
|
+
if ((0, ast_1.isNumericColumnType)(columnType)) {
|
|
2272
|
+
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultNumericComparison);
|
|
2273
|
+
newSubtree.left.column = column;
|
|
2274
|
+
setActiveEditItem(newSubtree);
|
|
2199
2275
|
}
|
|
2200
|
-
|
|
2201
|
-
const
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
if ((0, ast_1.isNumericColumnType)(columnType)) {
|
|
2205
|
-
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultNumericComparison);
|
|
2206
|
-
newSubtree.left.column = column;
|
|
2207
|
-
setActiveEditItem(newSubtree);
|
|
2208
|
-
}
|
|
2209
|
-
else {
|
|
2210
|
-
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultEntry);
|
|
2211
|
-
newSubtree.left.args.value[0].column = column;
|
|
2212
|
-
setActiveEditItem(newSubtree);
|
|
2213
|
-
}
|
|
2214
|
-
setOpenPopover('AddFilterPopover');
|
|
2215
|
-
setActivePath('');
|
|
2216
|
-
setIsPending(true);
|
|
2276
|
+
else {
|
|
2277
|
+
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultEntry);
|
|
2278
|
+
newSubtree.left.args.value[0].column = column;
|
|
2279
|
+
setActiveEditItem(newSubtree);
|
|
2217
2280
|
}
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
}, 200);
|
|
2227
|
-
}, children: (0, jsx_runtime_1.jsx)(ui_1.AddFilterPopover, { onSave: () => {
|
|
2228
|
-
if ((0, util_1.isNodeEmptyCollection)(activeEditItem)) {
|
|
2281
|
+
setOpenPopover('AddFilterPopover');
|
|
2282
|
+
setActivePath('');
|
|
2283
|
+
setIsPending(true);
|
|
2284
|
+
}
|
|
2285
|
+
}, label: 'Add filter' }), (0, jsx_runtime_1.jsx)(PopoverComponent, { isOpen: openPopover === 'AddFilterPopover', setIsOpen: (isOpen) => {
|
|
2286
|
+
if (!isOpen) {
|
|
2287
|
+
// delay onClose callback so onClick no-ops
|
|
2288
|
+
setTimeout(() => {
|
|
2229
2289
|
setIsPending(false);
|
|
2230
2290
|
setActivePath(null);
|
|
2231
2291
|
setOpenPopover(null);
|
|
2232
2292
|
clearCheckboxes();
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2293
|
+
setActiveEditItem(null);
|
|
2294
|
+
}, 200);
|
|
2295
|
+
}
|
|
2296
|
+
}, popoverTitle: "Add filter", popoverChildren: (0, jsx_runtime_1.jsx)(ui_1.AddFilterPopover, { onSave: () => {
|
|
2297
|
+
if ((0, util_1.isNodeEmptyCollection)(activeEditItem)) {
|
|
2238
2298
|
setIsPending(false);
|
|
2239
|
-
handleInsertion(activeEditItem, 'AND', false);
|
|
2240
2299
|
setActivePath(null);
|
|
2241
2300
|
setOpenPopover(null);
|
|
2242
2301
|
clearCheckboxes();
|
|
@@ -2244,45 +2303,57 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2244
2303
|
setActiveEditItem(null);
|
|
2245
2304
|
}, 300);
|
|
2246
2305
|
}
|
|
2247
|
-
|
|
2248
|
-
false && ( // temp removed the AddConditionPopover
|
|
2249
|
-
(0, jsx_runtime_1.jsx)(Popover, { isOpen: openPopover === 'AddConditionPopover', trigger: (0, jsx_runtime_1.jsx)(SecondaryButton, { onClick: () => {
|
|
2250
|
-
if (!openPopover) {
|
|
2251
|
-
setActiveEditItem((0, util_1.deepCopy)(constants_1.defaultEntry));
|
|
2252
|
-
setOpenPopover('AddConditionPopover');
|
|
2253
|
-
setActivePath('');
|
|
2254
|
-
setIsPending(true);
|
|
2255
|
-
}
|
|
2256
|
-
}, label: 'Add condition' }), onClose: () => {
|
|
2257
|
-
// delay onClose callback so onClick no-ops
|
|
2258
|
-
setTimeout(() => {
|
|
2259
|
-
setIsPending(false);
|
|
2260
|
-
setActiveEditItem(null);
|
|
2261
|
-
setActivePath(null);
|
|
2262
|
-
setOpenPopover(null);
|
|
2263
|
-
clearCheckboxes();
|
|
2264
|
-
}, 200);
|
|
2265
|
-
}, children: (0, jsx_runtime_1.jsx)(AddConditionPopover, { onSave: () => {
|
|
2266
|
-
if ((0, util_1.isNodeEmptyCollection)(activeEditItem)) {
|
|
2306
|
+
else {
|
|
2267
2307
|
setIsPending(false);
|
|
2268
|
-
|
|
2269
|
-
setActiveEditItem(null);
|
|
2270
|
-
}, 300);
|
|
2308
|
+
handleInsertion(activeEditItem, 'AND', false);
|
|
2271
2309
|
setActivePath(null);
|
|
2272
2310
|
setOpenPopover(null);
|
|
2273
2311
|
clearCheckboxes();
|
|
2274
|
-
}
|
|
2275
|
-
else {
|
|
2276
|
-
setIsPending(false);
|
|
2277
|
-
handleInsertion(activeEditItem, topLevelBinaryOperator, true);
|
|
2278
2312
|
setTimeout(() => {
|
|
2279
2313
|
setActiveEditItem(null);
|
|
2280
2314
|
}, 300);
|
|
2281
|
-
setActivePath(null);
|
|
2282
|
-
setOpenPopover(null);
|
|
2283
|
-
clearCheckboxes();
|
|
2284
2315
|
}
|
|
2285
|
-
}
|
|
2316
|
+
}, Button: ButtonComponent, renderNode: renderNode, activeEditItem: activeEditItem }) }), baseAst?.where &&
|
|
2317
|
+
false && ( // temp removed the AddConditionPopover
|
|
2318
|
+
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: () => {
|
|
2319
|
+
if (!openPopover) {
|
|
2320
|
+
setActiveEditItem((0, util_1.deepCopy)(constants_1.defaultEntry));
|
|
2321
|
+
setOpenPopover('AddConditionPopover');
|
|
2322
|
+
setActivePath('');
|
|
2323
|
+
setIsPending(true);
|
|
2324
|
+
}
|
|
2325
|
+
}, label: 'Add condition' }), (0, jsx_runtime_1.jsx)(PopoverComponent, { isOpen: openPopover === 'AddConditionPopover', setIsOpen: (isOpen) => {
|
|
2326
|
+
if (!isOpen) {
|
|
2327
|
+
// delay onClose callback so onClick no-ops
|
|
2328
|
+
setTimeout(() => {
|
|
2329
|
+
setIsPending(false);
|
|
2330
|
+
setActiveEditItem(null);
|
|
2331
|
+
setActivePath(null);
|
|
2332
|
+
setOpenPopover(null);
|
|
2333
|
+
clearCheckboxes();
|
|
2334
|
+
}, 200);
|
|
2335
|
+
}
|
|
2336
|
+
}, popoverChildren: (0, jsx_runtime_1.jsx)(AddConditionPopover, { onSave: () => {
|
|
2337
|
+
if ((0, util_1.isNodeEmptyCollection)(activeEditItem)) {
|
|
2338
|
+
setIsPending(false);
|
|
2339
|
+
setTimeout(() => {
|
|
2340
|
+
setActiveEditItem(null);
|
|
2341
|
+
}, 300);
|
|
2342
|
+
setActivePath(null);
|
|
2343
|
+
setOpenPopover(null);
|
|
2344
|
+
clearCheckboxes();
|
|
2345
|
+
}
|
|
2346
|
+
else {
|
|
2347
|
+
setIsPending(false);
|
|
2348
|
+
handleInsertion(activeEditItem, topLevelBinaryOperator, true);
|
|
2349
|
+
setTimeout(() => {
|
|
2350
|
+
setActiveEditItem(null);
|
|
2351
|
+
}, 300);
|
|
2352
|
+
setActivePath(null);
|
|
2353
|
+
setOpenPopover(null);
|
|
2354
|
+
clearCheckboxes();
|
|
2355
|
+
}
|
|
2356
|
+
} }) })] }))] }), (0, jsx_runtime_1.jsx)("div", { style: { height: 28, width: '100%' } }), (0, jsx_runtime_1.jsx)(SidebarHeadingComponent, { label: "Pivot" }), (0, jsx_runtime_1.jsx)("div", { style: { height: 4, width: '100%' } }), (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, SecondaryButtonComponent: SecondaryButtonComponent, PopoverComponent: PopoverComponent, TextComponent: TextComponent, isOpen: showPivotPopover, setIsOpen: setShowPivotPopover, showUpdatePivot: isEdittingPivot, setShowUpdatePivot: setIsEdittingPivot, parentRef: parentRef, data: rows, columns: processColumnsForChartBuilder(Object.keys(rows[0] ?? {})), triggerButtonText: 'Add pivot', selectedPivotIndex: selectedPivotIndex, setSelectedPivotIndex: setSelectedPivotIndex, removePivot: () => {
|
|
2286
2357
|
setPivot(null);
|
|
2287
2358
|
setPivotData(null);
|
|
2288
2359
|
}, selectPivot: (pivot) => {
|
|
@@ -2298,7 +2369,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2298
2369
|
setPivot(pivot);
|
|
2299
2370
|
const pivotedData = (0, PivotModal_1.generatePivotTable)(pivot, rows, [null, null, null], false);
|
|
2300
2371
|
setPivotData(pivotedData || []);
|
|
2301
|
-
}, selectPivotOnEdit: true, showTrigger: !pivot, theme: theme, LabelComponent:
|
|
2372
|
+
}, selectPivotOnEdit: true, showTrigger: !pivot, theme: theme, LabelComponent: LabelComponent, HeaderComponent: HeaderComponent, dateRange: [null, null, null], recommendPivotCount: 3 }), pivot && ((0, jsx_runtime_1.jsx)(PivotList_1.PivotCard, { pivotTable: {
|
|
2302
2373
|
pivot: pivot,
|
|
2303
2374
|
rows: pivotData?.rows || [],
|
|
2304
2375
|
columns: pivotData?.columns || [],
|
|
@@ -2310,11 +2381,11 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2310
2381
|
setPivotValueField(pivot?.valueField);
|
|
2311
2382
|
setPivotAggregation(pivot?.aggregationType);
|
|
2312
2383
|
setPivotPopUpTitle('Edit Pivot');
|
|
2313
|
-
}, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent:
|
|
2384
|
+
}, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent: ButtonComponent, HeaderComponent: HeaderComponent, showEdit: false, onClose: () => {
|
|
2314
2385
|
setPivot(null);
|
|
2315
2386
|
setPivotData(null);
|
|
2316
2387
|
setBaseAst((0, util_1.deepCopy)(baseAst));
|
|
2317
|
-
}, minHeight: 180, LabelComponent:
|
|
2388
|
+
}, minHeight: 180, LabelComponent: LabelComponent, TextComponent: TextComponent })), (0, jsx_runtime_1.jsx)("div", { style: { height: 28, width: '100%' } }), (0, jsx_runtime_1.jsx)(SidebarHeadingComponent, { label: "Sort" }), (0, jsx_runtime_1.jsx)("div", { style: { height: 4, width: '100%' } }), pivot && pivot.sort && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
2318
2389
|
display: 'flex',
|
|
2319
2390
|
flexDirection: 'column',
|
|
2320
2391
|
gap: 8,
|
|
@@ -2322,7 +2393,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2322
2393
|
}, children: (0, jsx_runtime_1.jsx)(AddSortPopover_1.SortSentence, { sortData: {
|
|
2323
2394
|
type: pivot.sortDirection,
|
|
2324
2395
|
expr: { type: 'column_ref', column: pivot.rowField },
|
|
2325
|
-
}, columns: pivot ? [`.${pivot.rowField}`] : selectedColumns, setIsPending: setIsPending, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setOpenPopover: setOpenPopover, SortPopover:
|
|
2396
|
+
}, columns: pivot ? [`.${pivot.rowField}`] : selectedColumns, setIsPending: setIsPending, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setActivePath: setActivePath, setOpenPopover: setOpenPopover, SortPopover: SortPopoverComponent, EditPopover: AddSortPopover_1.AddSortPopover, handleDelete: () => {
|
|
2326
2397
|
if (pivot) {
|
|
2327
2398
|
setPivot({ ...pivot, sort: false });
|
|
2328
2399
|
const pivotedData = (0, PivotModal_1.generatePivotTable)({ ...pivot, sort: false }, rows, [null, null, null], false);
|
|
@@ -2341,12 +2412,12 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2341
2412
|
setOpenPopover(null);
|
|
2342
2413
|
setBaseAst((0, util_1.deepCopy)(baseAst));
|
|
2343
2414
|
fetchSqlQuery((0, util_1.deepCopy)(baseAst));
|
|
2344
|
-
}, Select:
|
|
2415
|
+
}, Select: SelectComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent }, `sort-sentence-pivot`) })), baseAst && baseAst.orderby && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
2345
2416
|
display: 'flex',
|
|
2346
2417
|
flexDirection: 'column',
|
|
2347
2418
|
gap: 8,
|
|
2348
2419
|
marginBottom: 12,
|
|
2349
|
-
}, children: baseAst.orderby.map((sortData, id) => ((0, jsx_runtime_1.jsx)(AddSortPopover_1.SortSentence, { sortData: sortData, columns: selectedColumns, setIsPending: setIsPending, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setOpenPopover: setOpenPopover, SortPopover:
|
|
2420
|
+
}, children: baseAst.orderby.map((sortData, id) => ((0, jsx_runtime_1.jsx)(AddSortPopover_1.SortSentence, { sortData: sortData, columns: selectedColumns, setIsPending: setIsPending, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setActivePath: setActivePath, setOpenPopover: setOpenPopover, SortPopover: SortPopoverComponent, EditPopover: AddSortPopover_1.AddSortPopover, handleDelete: () => {
|
|
2350
2421
|
if (pivot) {
|
|
2351
2422
|
setPivot({ ...pivot, sort: false });
|
|
2352
2423
|
return;
|
|
@@ -2383,19 +2454,21 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2383
2454
|
setOpenPopover(null);
|
|
2384
2455
|
setBaseAst((0, util_1.deepCopy)(newAst));
|
|
2385
2456
|
fetchSqlQuery((0, util_1.deepCopy)(newAst));
|
|
2386
|
-
}, Select:
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2457
|
+
}, Select: SelectComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent }, `sort-sentence-${id}`))) })), (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: () => {
|
|
2458
|
+
if (!selectedColumns || selectedColumns.length === 0) {
|
|
2459
|
+
return;
|
|
2460
|
+
}
|
|
2461
|
+
if (!openPopover) {
|
|
2462
|
+
setOpenPopover('AddSortPopover');
|
|
2463
|
+
}
|
|
2464
|
+
}, label: 'Add sort' }), (0, jsx_runtime_1.jsx)(PopoverComponent, { isOpen: openPopover === 'AddSortPopover', setIsOpen: (isOpen) => {
|
|
2465
|
+
if (!isOpen) {
|
|
2466
|
+
setIsPending(false);
|
|
2467
|
+
setActiveEditItem(null);
|
|
2468
|
+
setActivePath(null);
|
|
2469
|
+
setOpenPopover(null);
|
|
2470
|
+
}
|
|
2471
|
+
}, popoverTitle: "Sort by", popoverChildren: (0, jsx_runtime_1.jsx)(AddSortPopover_1.AddSortPopover, { columns: pivot ? [`.${pivot.rowField}`] : selectedColumns, Select: SelectComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent, onSave: (column, direction) => {
|
|
2399
2472
|
if (column === '')
|
|
2400
2473
|
return;
|
|
2401
2474
|
if (pivot) {
|
|
@@ -2419,12 +2492,12 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2419
2492
|
setOpenPopover(null);
|
|
2420
2493
|
setBaseAst((0, util_1.deepCopy)(newAst));
|
|
2421
2494
|
fetchSqlQuery((0, util_1.deepCopy)(newAst));
|
|
2422
|
-
} }) }), (0, jsx_runtime_1.jsx)("div", { style: { height: 28, width: '100%' } }), (0, jsx_runtime_1.jsx)(
|
|
2495
|
+
} }) }), (0, jsx_runtime_1.jsx)("div", { style: { height: 28, width: '100%' } }), (0, jsx_runtime_1.jsx)(SidebarHeadingComponent, { label: "Limit" }), (0, jsx_runtime_1.jsx)("div", { style: { height: 4, width: '100%' } }), baseAst && baseAst.limit ? ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
2423
2496
|
display: 'flex',
|
|
2424
2497
|
flexDirection: 'column',
|
|
2425
2498
|
gap: 8,
|
|
2426
2499
|
marginBottom: 12,
|
|
2427
|
-
}, children: (0, jsx_runtime_1.jsx)(AddLimitPopover_1.LimitSentence, { limit: baseAst.limit, setOpenPopover: setOpenPopover, LimitPopover:
|
|
2500
|
+
}, children: (0, jsx_runtime_1.jsx)(AddLimitPopover_1.LimitSentence, { limit: baseAst.limit, setOpenPopover: setOpenPopover, LimitPopover: LimitPopoverComponent, EditPopover: AddLimitPopover_1.AddLimitPopover, handleDelete: () => {
|
|
2428
2501
|
const newAst = { ...baseAst };
|
|
2429
2502
|
newAst.limit = null;
|
|
2430
2503
|
setBaseAst((0, util_1.deepCopy)(newAst));
|
|
@@ -2443,36 +2516,38 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2443
2516
|
setOpenPopover(null);
|
|
2444
2517
|
setBaseAst((0, util_1.deepCopy)(newAst));
|
|
2445
2518
|
fetchSqlQuery((0, util_1.deepCopy)(newAst));
|
|
2446
|
-
}, TextInput:
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2519
|
+
}, TextInput: TextInputComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent }) })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: () => {
|
|
2520
|
+
if (!selectedColumns || selectedColumns.length === 0) {
|
|
2521
|
+
return;
|
|
2522
|
+
}
|
|
2523
|
+
if (!baseAst) {
|
|
2524
|
+
return;
|
|
2525
|
+
}
|
|
2526
|
+
if (!openPopover) {
|
|
2527
|
+
setOpenPopover('AddLimitPopover');
|
|
2528
|
+
}
|
|
2529
|
+
}, label: 'Add limit' }), (0, jsx_runtime_1.jsx)(PopoverComponent, { isOpen: openPopover === 'AddLimitPopover', setIsOpen: (isOpen) => {
|
|
2530
|
+
if (!isOpen) {
|
|
2531
|
+
setIsPending(false);
|
|
2532
|
+
setActiveEditItem(null);
|
|
2533
|
+
setActivePath(null);
|
|
2534
|
+
setOpenPopover(null);
|
|
2535
|
+
}
|
|
2536
|
+
}, popoverTitle: "Limit", popoverChildren: (0, jsx_runtime_1.jsx)(AddLimitPopover_1.AddLimitPopover, { TextInput: TextInputComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent, onSave: (limit) => {
|
|
2537
|
+
const newAst = { ...baseAst };
|
|
2538
|
+
newAst.limit = {
|
|
2539
|
+
seperator: '',
|
|
2540
|
+
value: [
|
|
2541
|
+
{
|
|
2542
|
+
type: 'number',
|
|
2543
|
+
value: Number(limit),
|
|
2544
|
+
},
|
|
2545
|
+
],
|
|
2546
|
+
};
|
|
2547
|
+
setOpenPopover(null);
|
|
2548
|
+
setBaseAst((0, util_1.deepCopy)(newAst));
|
|
2549
|
+
fetchSqlQuery((0, util_1.deepCopy)(newAst));
|
|
2550
|
+
} }) })] }))] }), (0, jsx_runtime_1.jsxs)(ContainerComponent, { children: [isAIEnabled && ((0, jsx_runtime_1.jsxs)("form", { ref: askAIContainerRef, onSubmit: (event) => {
|
|
2476
2551
|
event.preventDefault();
|
|
2477
2552
|
handleAsk();
|
|
2478
2553
|
}, style: {
|
|
@@ -2480,14 +2555,14 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2480
2555
|
flexDirection: 'row',
|
|
2481
2556
|
gap: 12,
|
|
2482
2557
|
padding: 1,
|
|
2483
|
-
}, children: [(0, jsx_runtime_1.jsx)(
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2558
|
+
}, children: [(0, jsx_runtime_1.jsx)(TextInputComponent, { id: "ask_ai_input_bar", value: aiPrompt, width: askAIInputWidth, 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 && ((0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { label: 'New report', onClick: clearAllState }))] })), baseAst && ((0, jsx_runtime_1.jsx)(TableComponent, { isLoading: loading && errorMessage.length === 0, rows: applyFormatting({
|
|
2559
|
+
rows: pivotData?.rows || rows,
|
|
2560
|
+
fields: pivotData?.fields || fields,
|
|
2561
|
+
}, baseAst?.columns ?? []), columns: pivot
|
|
2562
|
+
? pivotData?.columns || emptyPivotColumns()
|
|
2563
|
+
: enforceOrderOnColumns(Object.keys(rows[0] ?? {})).map((c) => {
|
|
2564
|
+
return { label: (0, textProcessing_1.snakeCaseToTitleCase)(c), field: c };
|
|
2565
|
+
}) })), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
2491
2566
|
display: 'flex',
|
|
2492
2567
|
flexDirection: 'row',
|
|
2493
2568
|
gap: '12px',
|
|
@@ -2496,11 +2571,8 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2496
2571
|
fontSize: 14,
|
|
2497
2572
|
padding: '12px',
|
|
2498
2573
|
whiteSpace: 'nowrap',
|
|
2499
|
-
}, children: errorMessage })), (0, jsx_runtime_1.jsx)("div", { style: { width: '100%' } }), baseAst && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(
|
|
2574
|
+
}, children: errorMessage })), (0, jsx_runtime_1.jsx)("div", { style: { width: '100%' } }), baseAst && ((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: () => {
|
|
2500
2575
|
setIsChartBuilderOpen(true);
|
|
2501
|
-
}, label: 'Add to dashboard' })] }))] })] }), (0, jsx_runtime_1.jsx)("style", { children: `body{margin:0;}` }), (0, jsx_runtime_1.jsx)(ChartBuilder_1.ChartBuilderWithModal, { rows:
|
|
2502
|
-
// TODO: Modal={Modal}
|
|
2503
|
-
// TODO: Popover={Popover}
|
|
2504
|
-
DeleteButton: DeleteButton })] }));
|
|
2576
|
+
}, label: 'Add to dashboard' })] }))] })] }), (0, jsx_runtime_1.jsx)("style", { children: `body{margin:0;}` }), (0, jsx_runtime_1.jsx)(ChartBuilder_1.ChartBuilderWithModal, { rows: rows, columns: processColumnsForChartBuilder(Object.keys(rows[0] ?? {})), fields: fields, pivot: pivot, query: activeQuery, showTableFormatOptions: isAdminEnabled, showDateFieldOptions: isAdminEnabled, showAccessControlOptions: isAdminEnabled, title: "Add to dashboard", isOpen: isChartBuilderOpen, setIsOpen: setIsChartBuilderOpen, onAddToDashboardComplete: onSubmitChartBuilder, destinationDashboard: destinationDashboard, organizationName: organizationName, pivotData: pivotData, SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, HeaderComponent: HeaderComponent, LabelComponent: LabelComponent, TextComponent: TextComponent, ModalComponent: ModalComponent, PopoverComponent: PopoverComponent, DeleteButtonComponent: DeleteButtonComponent })] }));
|
|
2505
2577
|
}
|
|
2506
2578
|
exports.default = ReportBuilder;
|