@quillsql/react 2.11.15 → 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 +195 -28
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +124 -63
- 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 -90
- 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 -34
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +551 -426
- package/dist/cjs/SQLEditor.d.ts +158 -29
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +52 -32
- 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 +30 -1
- package/dist/cjs/components/ReportBuilder/AddColumnPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddColumnPopover.js +33 -14
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.d.ts +25 -2
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.js +19 -19
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts +22 -2
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddSortPopover.js +18 -20
- 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 -19
- package/dist/cjs/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/ui.js +68 -121
- package/dist/cjs/components/ReportBuilder/util.d.ts +3 -1
- package/dist/cjs/components/ReportBuilder/util.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/util.js +34 -8
- package/dist/cjs/components/UiComponents.d.ts +98 -97
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +132 -112
- 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/cjs/utils/width.d.ts +12 -0
- package/dist/cjs/utils/width.d.ts.map +1 -0
- package/dist/cjs/utils/width.js +25 -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 +195 -28
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +124 -63
- 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 -90
- 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 -34
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +553 -428
- package/dist/esm/SQLEditor.d.ts +158 -29
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +53 -33
- 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 +30 -1
- package/dist/esm/components/ReportBuilder/AddColumnPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddColumnPopover.js +34 -15
- package/dist/esm/components/ReportBuilder/AddLimitPopover.d.ts +25 -2
- package/dist/esm/components/ReportBuilder/AddLimitPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddLimitPopover.js +20 -20
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts +22 -2
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddSortPopover.js +20 -22
- 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 -19
- package/dist/esm/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/ui.js +67 -119
- package/dist/esm/components/ReportBuilder/util.d.ts +3 -1
- package/dist/esm/components/ReportBuilder/util.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/util.js +31 -7
- package/dist/esm/components/UiComponents.d.ts +98 -97
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +125 -110
- 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/dist/esm/utils/width.d.ts +12 -0
- package/dist/esm/utils/width.d.ts.map +1 -0
- package/dist/esm/utils/width.js +21 -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");
|
|
@@ -13,6 +14,7 @@ const date_fns_1 = require("date-fns");
|
|
|
13
14
|
const Context_1 = require("./Context");
|
|
14
15
|
const ast_1 = require("./components/ReportBuilder/ast");
|
|
15
16
|
const ChartBuilder_1 = require("./ChartBuilder");
|
|
17
|
+
const UiComponents_2 = require("./components/UiComponents");
|
|
16
18
|
const ui_1 = require("./components/ReportBuilder/ui");
|
|
17
19
|
const postgres_1 = require("./components/ReportBuilder/postgres");
|
|
18
20
|
const convert_1 = require("./components/ReportBuilder/convert");
|
|
@@ -24,10 +26,10 @@ const AddColumnPopover_1 = __importDefault(require("./components/ReportBuilder/A
|
|
|
24
26
|
const AddSortPopover_1 = require("./components/ReportBuilder/AddSortPopover");
|
|
25
27
|
const PivotModal_1 = require("./internals/ReportBuilder/PivotModal");
|
|
26
28
|
const PivotList_1 = require("./internals/ReportBuilder/PivotList");
|
|
27
|
-
const QuillTable_1 = __importDefault(require("./components/QuillTable"));
|
|
28
|
-
const QuillSelect_1 = require("./components/QuillSelect");
|
|
29
29
|
const textProcessing_1 = require("./utils/textProcessing");
|
|
30
30
|
const AddLimitPopover_1 = require("./components/ReportBuilder/AddLimitPopover");
|
|
31
|
+
const width_1 = require("./utils/width");
|
|
32
|
+
const QuillSelect_1 = require("./components/QuillSelect");
|
|
31
33
|
/**
|
|
32
34
|
* Quill Report Builder
|
|
33
35
|
*
|
|
@@ -35,8 +37,31 @@ const AddLimitPopover_1 = require("./components/ReportBuilder/AddLimitPopover");
|
|
|
35
37
|
* then edit them on the fly. Once users have constructed a query they like,
|
|
36
38
|
* they can click a button and add that report to their dashboard or export it
|
|
37
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
|
|
38
63
|
*/
|
|
39
|
-
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, }) {
|
|
40
65
|
const [aiPrompt, setAiPrompt] = (0, react_1.useState)('');
|
|
41
66
|
const [errorMessage, setErrorMessage] = (0, react_1.useState)('');
|
|
42
67
|
const [baseAst, setBaseAst] = (0, react_1.useState)(null);
|
|
@@ -49,6 +74,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
49
74
|
const [activePath, setActivePath] = (0, react_1.useState)(null);
|
|
50
75
|
const [openPopover, setOpenPopover] = (0, react_1.useState)(null);
|
|
51
76
|
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
77
|
+
const [loadingSchema, setLoadingSchema] = (0, react_1.useState)(false);
|
|
52
78
|
const [isChartBuilderOpen, setIsChartBuilderOpen] = (0, react_1.useState)(false);
|
|
53
79
|
const [isPending, setIsPending] = (0, react_1.useState)(false);
|
|
54
80
|
const [isCopying, setIsCopying] = (0, react_1.useState)(false);
|
|
@@ -68,6 +94,10 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
68
94
|
const [initialLoad, setInitialLoad] = (0, react_1.useState)(true);
|
|
69
95
|
const [currentTable, setCurrentTable] = (0, react_1.useState)(initialTableName || '');
|
|
70
96
|
const parentRef = (0, react_1.useRef)(null);
|
|
97
|
+
const askAIContainerRef = (0, react_1.useRef)(null);
|
|
98
|
+
const askAILoadingContainerRef = (0, react_1.useRef)(null);
|
|
99
|
+
const [askAIInputWidth, setAskAIInputWidth] = (0, react_1.useState)(200);
|
|
100
|
+
const [askAILoadingContainerWidth, setAskAILoadingContainerWidth] = (0, react_1.useState)(200);
|
|
71
101
|
const [theme] = (0, react_1.useContext)(Context_1.ThemeContext);
|
|
72
102
|
const [pivotRowField, setPivotRowField] = (0, react_1.useState)(undefined);
|
|
73
103
|
const [pivotColumnField, setPivotColumnField] = (0, react_1.useState)(undefined);
|
|
@@ -75,6 +105,19 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
75
105
|
const [pivotAggregation, setPivotAggregation] = (0, react_1.useState)(undefined);
|
|
76
106
|
// eslint-disable-next-line no-unused-vars
|
|
77
107
|
const [client, _setClient] = (0, react_1.useContext)(Context_1.ClientContext);
|
|
108
|
+
(0, react_1.useEffect)(() => {
|
|
109
|
+
// Since the TextInput component takes a required numeric width parameter,
|
|
110
|
+
// we dynamically calculate the width of this component here.
|
|
111
|
+
function handleResize() {
|
|
112
|
+
(0, width_1.updateFirstChildWidth)(askAIContainerRef, setAskAIInputWidth, { gap: 12 });
|
|
113
|
+
(0, width_1.updateFirstChildWidth)(askAILoadingContainerRef, setAskAILoadingContainerWidth, { gap: 12 });
|
|
114
|
+
}
|
|
115
|
+
handleResize();
|
|
116
|
+
window.addEventListener('resize', handleResize);
|
|
117
|
+
return () => {
|
|
118
|
+
window.removeEventListener('resize', handleResize);
|
|
119
|
+
};
|
|
120
|
+
}, [baseAst, loading]);
|
|
78
121
|
const enforceOrderOnColumns = (columnNames) => {
|
|
79
122
|
if (pivot) {
|
|
80
123
|
const rowName = pivot.rowField;
|
|
@@ -110,9 +153,9 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
110
153
|
setAiPrompt('');
|
|
111
154
|
setBaseAst(null);
|
|
112
155
|
setFormData(null);
|
|
113
|
-
setOrderedColumnNames([]);
|
|
114
156
|
setSelectedColumns([]);
|
|
115
157
|
setSchemaTables([]);
|
|
158
|
+
setOrderedColumnNames([]);
|
|
116
159
|
setActiveQuery('');
|
|
117
160
|
setActiveEditItem(null);
|
|
118
161
|
setActivePath(null);
|
|
@@ -123,6 +166,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
123
166
|
setFields([]);
|
|
124
167
|
setTopLevelBinaryOperator('AND');
|
|
125
168
|
setEditPopoverKey(null);
|
|
169
|
+
setErrorMessage('');
|
|
126
170
|
// setUniqueValues({});
|
|
127
171
|
setPivot(null);
|
|
128
172
|
setPivotData(null);
|
|
@@ -222,7 +266,9 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
222
266
|
const result = [];
|
|
223
267
|
const table = tables[0];
|
|
224
268
|
const { valueField, rowField, columnField } = pivot;
|
|
225
|
-
if (columnField &&
|
|
269
|
+
if (columnField &&
|
|
270
|
+
uniqueValues[table] &&
|
|
271
|
+
uniqueValues[table][columnField]) {
|
|
226
272
|
result.push(...Object.keys(uniqueValues[table][columnField]));
|
|
227
273
|
}
|
|
228
274
|
result.push(valueField, rowField);
|
|
@@ -260,8 +306,29 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
260
306
|
}
|
|
261
307
|
};
|
|
262
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
|
+
};
|
|
263
329
|
const fetchSchema = async () => {
|
|
264
330
|
try {
|
|
331
|
+
setLoadingSchema(true);
|
|
265
332
|
const response = await fetch(`${client.queryEndpoint}`, {
|
|
266
333
|
method: 'POST',
|
|
267
334
|
headers: {
|
|
@@ -284,8 +351,8 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
284
351
|
setOrderedColumnNames((tables ?? []).flatMap((table) => table.columns
|
|
285
352
|
.map((c) => `${table.name}.${c.name}`)
|
|
286
353
|
.sort((a, b) => {
|
|
287
|
-
const aIsId = a.endsWith('.id') || a.endsWith('_id');
|
|
288
|
-
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');
|
|
289
356
|
if (aIsId && !bIsId)
|
|
290
357
|
return 1;
|
|
291
358
|
if (bIsId && !aIsId)
|
|
@@ -293,14 +360,9 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
293
360
|
return 0;
|
|
294
361
|
})));
|
|
295
362
|
if (initialTableName && initialLoad) {
|
|
296
|
-
|
|
297
|
-
setLoading(true);
|
|
298
|
-
await getDistinctValues(initialTableName, tables);
|
|
299
|
-
const columnsForTable = tables
|
|
300
|
-
.find((t) => t.name === initialTableName)
|
|
301
|
-
?.columns.map((c) => c.name);
|
|
302
|
-
await handleAsk(`get ${columnsForTable} from ${initialTableName}`);
|
|
363
|
+
await loadTable(tables);
|
|
303
364
|
}
|
|
365
|
+
setLoadingSchema(false);
|
|
304
366
|
}
|
|
305
367
|
catch (error) {
|
|
306
368
|
console.error(error);
|
|
@@ -309,7 +371,10 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
309
371
|
if (schemaTables.length === 0) {
|
|
310
372
|
fetchSchema();
|
|
311
373
|
}
|
|
312
|
-
|
|
374
|
+
else if (initialLoad && initialTableName) {
|
|
375
|
+
loadTable(schemaTables);
|
|
376
|
+
}
|
|
377
|
+
}, [schemaTables, initialTableName]);
|
|
313
378
|
const updateFormData = (updates, { isDeletion = false, isInsertion = false, isReplaceSubtree = false, isAddVariant = false, isDeleteVariant = false, topLevelBinOp = 'OR', isCondition = undefined, }) => {
|
|
314
379
|
// Function to immutably update or delete nodes based on their path
|
|
315
380
|
// TODO: fix the following horible code
|
|
@@ -716,7 +781,9 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
716
781
|
// see onChange callback handleChange
|
|
717
782
|
// eslint-disable-next-line no-unused-vars
|
|
718
783
|
dateColumnPath, dateFilterType, intervalCount, intervalType, intervalPaths, } = (0, util_1.getDateFilterInfo)(node);
|
|
719
|
-
const isPlural = intervalCount
|
|
784
|
+
const isPlural = intervalCount !== 1 && dateFilterType !== 'in the current'
|
|
785
|
+
? 's'
|
|
786
|
+
: '';
|
|
720
787
|
// Pull off the string literal date for "equals" comparisons
|
|
721
788
|
const rawDateStringEquals = node.right?.value ??
|
|
722
789
|
node.right?.args?.value[1]?.column ??
|
|
@@ -726,50 +793,50 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
726
793
|
'node.right.args.value.1.column') ??
|
|
727
794
|
(node.right?.args?.value[1]?.value &&
|
|
728
795
|
'node.right.args.value.1.value');
|
|
729
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', gap: 20 }, children: [(0, jsx_runtime_1.jsx)(
|
|
730
|
-
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);
|
|
731
798
|
if ((0, ast_1.isDateishColumnType)(columnType)) {
|
|
732
799
|
// handleChange(value, keyPrefix + dateColumnPath, "text");
|
|
733
|
-
handleOperatorChange('IN_THE_LAST', node, keyPrefix, value);
|
|
800
|
+
handleOperatorChange('IN_THE_LAST', node, keyPrefix, event.target.value);
|
|
734
801
|
}
|
|
735
802
|
else if ((0, ast_1.isNumericColumnType)(columnType)) {
|
|
736
803
|
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultNumericComparison);
|
|
737
|
-
newSubtree.left.column = value;
|
|
804
|
+
newSubtree.left.column = event.target.value;
|
|
738
805
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
739
806
|
}
|
|
740
807
|
else {
|
|
741
808
|
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultEntry);
|
|
742
|
-
newSubtree.left.args.value[0].column = value;
|
|
809
|
+
newSubtree.left.args.value[0].column = event.target.value;
|
|
743
810
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
744
811
|
}
|
|
745
812
|
}, options: getAllPossibleColumns().map((column) => ({
|
|
746
813
|
label: (0, textProcessing_1.snakeCaseToTitleCase)(column.displayName),
|
|
747
814
|
value: column.name,
|
|
748
|
-
})) }), (0, jsx_runtime_1.jsx)(
|
|
749
|
-
if (value === dateFilterType)
|
|
815
|
+
})) }), (0, jsx_runtime_1.jsx)(SelectComponent, { value: dateFilterType, onChange: (event) => {
|
|
816
|
+
if (event.target.value === dateFilterType)
|
|
750
817
|
return null;
|
|
751
818
|
let newSubtree = {};
|
|
752
819
|
// TODO: implement one for each database type (eg. pg, snowflake, etc.)
|
|
753
|
-
if (value === 'in the last') {
|
|
820
|
+
if (event.target.value === 'in the last') {
|
|
754
821
|
newSubtree = (0, postgres_1.generateLastNPeriodsPostgres)({
|
|
755
822
|
dateField: dateColumn,
|
|
756
823
|
intervalPeriod: `${intervalCount ?? 1} ${intervalType}`,
|
|
757
824
|
});
|
|
758
825
|
}
|
|
759
|
-
else if (value === 'in the previous') {
|
|
826
|
+
else if (event.target.value === 'in the previous') {
|
|
760
827
|
newSubtree = (0, postgres_1.generatePreviousPeriodPostgres)({
|
|
761
828
|
dateField: dateColumn,
|
|
762
829
|
intervalPeriod: `${intervalCount ?? 1} ${intervalType}`,
|
|
763
830
|
currentPeriod: intervalType,
|
|
764
831
|
});
|
|
765
832
|
}
|
|
766
|
-
else if (value === 'in the current') {
|
|
833
|
+
else if (event.target.value === 'in the current') {
|
|
767
834
|
newSubtree = (0, postgres_1.generateCurrentPeriodPostgres)({
|
|
768
835
|
dateField: dateColumn,
|
|
769
836
|
currentPeriod: intervalType,
|
|
770
837
|
});
|
|
771
838
|
}
|
|
772
|
-
else if (value === 'equals') {
|
|
839
|
+
else if (event.target.value === 'equals') {
|
|
773
840
|
newSubtree = (0, postgres_1.generateEqualsPostgres)({
|
|
774
841
|
dateField: dateColumn,
|
|
775
842
|
currentPeriod: intervalType,
|
|
@@ -783,21 +850,25 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
783
850
|
{ label: 'in the previous', value: 'in the previous' },
|
|
784
851
|
{ label: 'in the current', value: 'in the current' },
|
|
785
852
|
{ label: 'equals', value: 'equals' },
|
|
786
|
-
] }), !['in the current', 'equals'].includes(dateFilterType) && ((0, jsx_runtime_1.jsx)(
|
|
787
|
-
|
|
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) => {
|
|
854
|
+
if (Number.isNaN(parseFloat(e.target.value || '0'))) {
|
|
855
|
+
alert('Please input a number.');
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
const isPluralNow = parseFloat(e.target.value || '0') !== 1 ? 's' : '';
|
|
788
859
|
intervalPaths.forEach((intervalPath) => handleChangeText([
|
|
789
860
|
{
|
|
790
|
-
value: `${e.target.value} ${intervalType}${isPluralNow}`,
|
|
861
|
+
value: `${e.target.value || 0} ${intervalType}${isPluralNow}`,
|
|
791
862
|
path: keyPrefix + intervalPath,
|
|
792
863
|
},
|
|
793
864
|
]));
|
|
794
|
-
} })), (0, jsx_runtime_1.jsx)(
|
|
865
|
+
} })), (0, jsx_runtime_1.jsx)(SelectComponent, { value: intervalType, onChange: (event) => {
|
|
795
866
|
if (intervalPaths.length === 1) {
|
|
796
867
|
handleChangeText([
|
|
797
868
|
{
|
|
798
869
|
value: intervalCount !== null
|
|
799
|
-
? `${intervalCount} ${value}${isPlural}`
|
|
800
|
-
: value,
|
|
870
|
+
? `${intervalCount} ${event.target.value}${isPlural}`
|
|
871
|
+
: event.target.value,
|
|
801
872
|
path: keyPrefix + intervalPaths[0],
|
|
802
873
|
},
|
|
803
874
|
]);
|
|
@@ -807,14 +878,14 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
807
878
|
if (dateFilterType === 'equals') {
|
|
808
879
|
newSubtree = (0, postgres_1.generateEqualsPostgres)({
|
|
809
880
|
dateField: dateColumn,
|
|
810
|
-
currentPeriod: value,
|
|
881
|
+
currentPeriod: event.target.value,
|
|
811
882
|
timestamp: rawDateStringEquals,
|
|
812
883
|
});
|
|
813
884
|
}
|
|
814
885
|
else {
|
|
815
886
|
newSubtree = (0, postgres_1.generateCurrentPeriodPostgres)({
|
|
816
887
|
dateField: dateColumn,
|
|
817
|
-
currentPeriod: value,
|
|
888
|
+
currentPeriod: event.target.value,
|
|
818
889
|
});
|
|
819
890
|
}
|
|
820
891
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
@@ -825,7 +896,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
825
896
|
{ label: `week${isPlural}`, value: 'week' },
|
|
826
897
|
{ label: `day${isPlural}`, value: 'day' },
|
|
827
898
|
{ label: `hour${isPlural}`, value: 'hour' },
|
|
828
|
-
] }), 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) => {
|
|
829
900
|
handleChangeText([
|
|
830
901
|
{
|
|
831
902
|
value: e.target.value,
|
|
@@ -840,44 +911,49 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
840
911
|
label: (0, textProcessing_1.snakeCaseToTitleCase)(column.displayName),
|
|
841
912
|
value: column.name,
|
|
842
913
|
}));
|
|
843
|
-
const plural = node.right.args.value[1].expr.value
|
|
914
|
+
const plural = node.right.args.value[1].expr.value !== 1 ? 's' : '';
|
|
844
915
|
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
845
916
|
display: 'flex',
|
|
846
917
|
flexDirection: 'row',
|
|
847
918
|
alignItems: 'center',
|
|
848
919
|
gap: 20,
|
|
849
|
-
}, children: [(0, jsx_runtime_1.jsx)(
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
handleOperatorChange(value, node, keyPrefix, dateColumn);
|
|
920
|
+
}, children: [(0, jsx_runtime_1.jsx)(SelectComponent, { value: node.left.column, onChange: (event) => {
|
|
921
|
+
const columnType = getColumnTypeByName(event.target.value);
|
|
922
|
+
if ((0, ast_1.isDateishColumnType)(columnType)) {
|
|
923
|
+
// handleChange(value, keyPrefix + dateColumnPath, "text");
|
|
924
|
+
handleOperatorChange('IN_THE_LAST', node, keyPrefix, event.target.value);
|
|
925
|
+
}
|
|
926
|
+
else if ((0, ast_1.isNumericColumnType)(columnType)) {
|
|
927
|
+
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultNumericComparison);
|
|
928
|
+
newSubtree.left.column = event.target.value;
|
|
929
|
+
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
930
|
+
}
|
|
931
|
+
else {
|
|
932
|
+
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultEntry);
|
|
933
|
+
newSubtree.left.args.value[0].column = event.target.value;
|
|
934
|
+
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
935
|
+
}
|
|
936
|
+
}, options: options }), (0, jsx_runtime_1.jsx)(SelectComponent, { value: 'IN_THE_LAST', onChange: (event) => {
|
|
937
|
+
handleOperatorChange(event.target.value, node, keyPrefix, dateColumn);
|
|
867
938
|
}, options: [
|
|
868
939
|
{ label: 'in the last', value: 'IN_THE_LAST' },
|
|
869
940
|
{ label: 'in the previous', value: 'IN_THE_PREVIOUS' },
|
|
870
941
|
{ label: 'in the current', value: 'IN_THE_CURRENT' },
|
|
942
|
+
{ label: 'is not null', value: 'IS NOT' },
|
|
943
|
+
{ label: 'is null', value: 'IS' },
|
|
871
944
|
// { label: 'equals', value: 'equals' },
|
|
872
|
-
] }), (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) => {
|
|
873
946
|
handleChange([
|
|
874
947
|
{
|
|
875
948
|
value: e.target.value,
|
|
876
949
|
path: keyPrefix + 'right.args.value||1.expr.value',
|
|
877
950
|
},
|
|
878
951
|
]);
|
|
879
|
-
} }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(
|
|
880
|
-
{
|
|
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
|
+
},
|
|
881
957
|
]), options: [
|
|
882
958
|
{ label: `year${plural}`, value: '* 365 DAY' },
|
|
883
959
|
{ label: `month${plural}`, value: '* 30 DAY' },
|
|
@@ -896,33 +972,41 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
896
972
|
flexDirection: 'row',
|
|
897
973
|
alignItems: 'center',
|
|
898
974
|
gap: 20,
|
|
899
|
-
}, children: [(0, jsx_runtime_1.jsx)(
|
|
900
|
-
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);
|
|
901
977
|
if ((0, ast_1.isDateishColumnType)(columnType)) {
|
|
902
978
|
// handleChange(value, keyPrefix + dateColumnPath, "text");
|
|
903
|
-
handleOperatorChange('IN_THE_LAST', node, keyPrefix, value);
|
|
979
|
+
handleOperatorChange('IN_THE_LAST', node, keyPrefix, event.target.value);
|
|
904
980
|
}
|
|
905
981
|
else if ((0, ast_1.isNumericColumnType)(columnType)) {
|
|
906
982
|
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultNumericComparison);
|
|
907
|
-
newSubtree.left.column = value;
|
|
983
|
+
newSubtree.left.column = event.target.value;
|
|
908
984
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
909
985
|
}
|
|
910
986
|
else {
|
|
911
987
|
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultEntry);
|
|
912
|
-
newSubtree.left.args.value[0].column = value;
|
|
988
|
+
newSubtree.left.args.value[0].column = event.target.value;
|
|
913
989
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
914
990
|
}
|
|
915
|
-
}, options: options }), (0, jsx_runtime_1.jsx)(
|
|
916
|
-
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);
|
|
917
993
|
}, options: [
|
|
918
994
|
{ label: 'in the last', value: 'IN_THE_LAST' },
|
|
919
995
|
{ label: 'in the previous', value: 'IN_THE_PREVIOUS' },
|
|
920
996
|
{ label: 'in the current', value: 'IN_THE_CURRENT' },
|
|
997
|
+
{ label: 'is not null', value: 'IS NOT' },
|
|
998
|
+
{ label: 'is null', value: 'IS' },
|
|
921
999
|
// { label: 'equals', value: 'equals' },
|
|
922
|
-
] }), (0, jsx_runtime_1.jsx)(
|
|
1000
|
+
] }), (0, jsx_runtime_1.jsx)(SelectComponent, { value: node.left.args.value[1].column, onChange: (event) => {
|
|
923
1001
|
handleChange([
|
|
924
|
-
{
|
|
925
|
-
|
|
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
|
+
},
|
|
926
1010
|
]);
|
|
927
1011
|
}, options: [
|
|
928
1012
|
{ label: `year`, value: 'YEAR' },
|
|
@@ -941,30 +1025,32 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
941
1025
|
flexDirection: 'row',
|
|
942
1026
|
alignItems: 'center',
|
|
943
1027
|
gap: 20,
|
|
944
|
-
}, children: [(0, jsx_runtime_1.jsx)(
|
|
945
|
-
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);
|
|
946
1030
|
if ((0, ast_1.isDateishColumnType)(columnType)) {
|
|
947
1031
|
// handleChange(value, keyPrefix + dateColumnPath, "text");
|
|
948
|
-
handleOperatorChange('IN_THE_LAST', node, keyPrefix, value);
|
|
1032
|
+
handleOperatorChange('IN_THE_LAST', node, keyPrefix, event.target.value);
|
|
949
1033
|
}
|
|
950
1034
|
else if ((0, ast_1.isNumericColumnType)(columnType)) {
|
|
951
1035
|
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultNumericComparison);
|
|
952
|
-
newSubtree.left.column = value;
|
|
1036
|
+
newSubtree.left.column = event.target.value;
|
|
953
1037
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
954
1038
|
}
|
|
955
1039
|
else {
|
|
956
1040
|
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultEntry);
|
|
957
|
-
newSubtree.left.args.value[0].column = value;
|
|
1041
|
+
newSubtree.left.args.value[0].column = event.target.value;
|
|
958
1042
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
959
1043
|
}
|
|
960
|
-
},
|
|
961
|
-
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);
|
|
962
1046
|
}, options: [
|
|
963
1047
|
{ label: 'in the last', value: 'IN_THE_LAST' },
|
|
964
1048
|
{ label: 'in the previous', value: 'IN_THE_PREVIOUS' },
|
|
965
1049
|
{ label: 'in the current', value: 'IN_THE_CURRENT' },
|
|
1050
|
+
{ label: 'is not null', value: 'IS NOT' },
|
|
1051
|
+
{ label: 'is null', value: 'IS' },
|
|
966
1052
|
// { label: 'equals', value: 'equals' },
|
|
967
|
-
] }), (0, jsx_runtime_1.jsx)(
|
|
1053
|
+
] }), (0, jsx_runtime_1.jsx)(SelectComponent, { value: node.left.args.value[1].column, onChange: (event) => {
|
|
968
1054
|
const dayConversion = {
|
|
969
1055
|
YEAR: 365,
|
|
970
1056
|
QUARTER: 90,
|
|
@@ -973,15 +1059,15 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
973
1059
|
};
|
|
974
1060
|
handleChange([
|
|
975
1061
|
{
|
|
976
|
-
value,
|
|
1062
|
+
value: event.target.value,
|
|
977
1063
|
path: 'left.args.value||1.column',
|
|
978
1064
|
},
|
|
979
1065
|
{
|
|
980
|
-
value,
|
|
1066
|
+
value: event.target.value,
|
|
981
1067
|
path: 'right.args.value||1.column',
|
|
982
1068
|
},
|
|
983
1069
|
{
|
|
984
|
-
value: dayConversion[value] || 30,
|
|
1070
|
+
value: dayConversion[event.target.value] || 30,
|
|
985
1071
|
path: 'right.args.value||0.args.value||1.expr.value',
|
|
986
1072
|
},
|
|
987
1073
|
]);
|
|
@@ -1006,7 +1092,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1006
1092
|
const tables = (0, ast_1.getTableNames)(baseAst);
|
|
1007
1093
|
const table = tables.length === 1 ? tables[0] : initialTableName;
|
|
1008
1094
|
const columnType = column?.fieldType;
|
|
1009
|
-
|
|
1095
|
+
let operatorOptions = [
|
|
1010
1096
|
...((0, ast_1.isNumericColumnType)(columnType)
|
|
1011
1097
|
? [
|
|
1012
1098
|
{ label: 'equal to', value: '=' },
|
|
@@ -1021,10 +1107,10 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1021
1107
|
: []),
|
|
1022
1108
|
...((0, ast_1.isTextColumnType)(columnType)
|
|
1023
1109
|
? [
|
|
1024
|
-
{ label: 'is', value: 'LIKE' },
|
|
1025
|
-
{ label: 'is not', value: 'NOT LIKE' },
|
|
1026
|
-
{ label: 'is
|
|
1027
|
-
{ 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' },
|
|
1028
1114
|
{ label: 'is not null', value: 'IS NOT' },
|
|
1029
1115
|
{ label: 'is null', value: 'IS' },
|
|
1030
1116
|
]
|
|
@@ -1043,6 +1129,10 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1043
1129
|
]
|
|
1044
1130
|
: []),
|
|
1045
1131
|
];
|
|
1132
|
+
if (client.databaseType === 'BigQuery' &&
|
|
1133
|
+
(0, ast_1.isDateishColumnType)(columnType)) {
|
|
1134
|
+
operatorOptions = operatorOptions.filter((option) => option.value !== 'equals');
|
|
1135
|
+
}
|
|
1046
1136
|
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
1047
1137
|
display: 'flex',
|
|
1048
1138
|
gap: 12,
|
|
@@ -1052,45 +1142,48 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1052
1142
|
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
|
|
1053
1143
|
display: 'flex',
|
|
1054
1144
|
gap: 20,
|
|
1055
|
-
// justifyContent: "space-between",
|
|
1056
1145
|
flexDirection: (0, util_1.showNodeAsRow)(node, formData)
|
|
1057
1146
|
? 'row'
|
|
1058
1147
|
: 'column',
|
|
1059
1148
|
width: '100%',
|
|
1060
|
-
}, children: [(0, jsx_runtime_1.jsx)(
|
|
1061
|
-
const columnType = getColumnTypeByName(value);
|
|
1149
|
+
}, children: [(0, jsx_runtime_1.jsx)(SelectComponent, { value: leftChildValue, onChange: (event) => {
|
|
1150
|
+
const columnType = getColumnTypeByName(event.target.value);
|
|
1062
1151
|
if ((0, ast_1.isDateishColumnType)(columnType)) {
|
|
1063
|
-
handleOperatorChange('IN_THE_LAST', node, keyPrefix, value);
|
|
1152
|
+
handleOperatorChange('IN_THE_LAST', node, keyPrefix, event.target.value);
|
|
1064
1153
|
}
|
|
1065
1154
|
else if ((0, ast_1.isNumericColumnType)(columnType)) {
|
|
1066
1155
|
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultNumericComparison);
|
|
1067
|
-
newSubtree.left.column = value;
|
|
1156
|
+
newSubtree.left.column = event.target.value;
|
|
1068
1157
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
1069
1158
|
}
|
|
1070
1159
|
else {
|
|
1071
1160
|
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultEntry);
|
|
1072
|
-
newSubtree.left.args.value[0].column = value;
|
|
1161
|
+
newSubtree.left.args.value[0].column = event.target.value;
|
|
1073
1162
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
1074
1163
|
}
|
|
1075
|
-
}, options: options }), operatorOptions.length > 0 && ((0, jsx_runtime_1.jsx)(
|
|
1076
|
-
handleOperatorChange(value, node, keyPrefix, leftChildValue);
|
|
1077
|
-
},
|
|
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 &&
|
|
1078
1167
|
node.right.type !== 'expr_list' &&
|
|
1079
1168
|
renderNode(node.right, keyPrefix + 'right.')] }, keyPrefix), node.right && node.right.type === 'expr_list' && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
1080
1169
|
display: 'grid',
|
|
1081
1170
|
gridTemplateColumns: 'repeat(2, 1fr)',
|
|
1082
1171
|
gap: 12,
|
|
1083
|
-
}, children:
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
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.'))] }));
|
|
1094
1187
|
}
|
|
1095
1188
|
else {
|
|
1096
1189
|
const columnName = node.left.column;
|
|
@@ -1102,9 +1195,9 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1102
1195
|
justifyContent: 'space-between',
|
|
1103
1196
|
flexDirection: (0, util_1.showNodeAsRow)(node, formData) ? 'row' : 'column',
|
|
1104
1197
|
width: '100%',
|
|
1105
|
-
}, children: [node.left && renderNode(node.left, keyPrefix + 'left.'), (0, jsx_runtime_1.jsx)(
|
|
1106
|
-
handleOperatorChange(value, node, keyPrefix);
|
|
1107
|
-
},
|
|
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: [
|
|
1108
1201
|
// { label: `and`, value: "AND" },
|
|
1109
1202
|
// { label: `or`, value: "OR" },
|
|
1110
1203
|
...((0, ast_1.isNumericColumnType)(columnType)
|
|
@@ -1121,10 +1214,10 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1121
1214
|
: []),
|
|
1122
1215
|
...((0, ast_1.isTextColumnType)(columnType)
|
|
1123
1216
|
? [
|
|
1124
|
-
{ label: 'is', value: 'LIKE' },
|
|
1125
|
-
{ label: 'is not', value: 'NOT LIKE' },
|
|
1126
|
-
{ label: 'is
|
|
1127
|
-
{ 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' },
|
|
1128
1221
|
{ label: 'is not null', value: 'IS NOT' },
|
|
1129
1222
|
{ label: 'is null', value: 'IS' },
|
|
1130
1223
|
]
|
|
@@ -1147,45 +1240,41 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1147
1240
|
label: (0, textProcessing_1.snakeCaseToTitleCase)(column.displayName),
|
|
1148
1241
|
value: column.name,
|
|
1149
1242
|
}));
|
|
1150
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
1151
|
-
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
|
+
]);
|
|
1152
1247
|
}, options: options }));
|
|
1153
1248
|
}
|
|
1154
1249
|
case 'expr_list': {
|
|
1155
1250
|
const len = node.value.length;
|
|
1156
1251
|
return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'row', gap: 12 }, children: [node.value.map((elem, index) => {
|
|
1157
1252
|
if (elem.value) {
|
|
1158
|
-
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([
|
|
1159
1254
|
{
|
|
1160
|
-
value:
|
|
1161
|
-
? parseFloat(e.target.value)
|
|
1162
|
-
: e.target.value,
|
|
1255
|
+
value: e.target.value,
|
|
1163
1256
|
path: keyPrefix + `value.${index}.`,
|
|
1164
1257
|
},
|
|
1165
1258
|
]) }, `input_${index}`));
|
|
1166
1259
|
}
|
|
1167
1260
|
return renderNode(elem, keyPrefix + `value.${index}.`);
|
|
1168
|
-
}), 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));
|
|
1169
1262
|
}
|
|
1170
1263
|
case 'double_quote_string':
|
|
1171
1264
|
case 'single_quote_string':
|
|
1172
|
-
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([
|
|
1173
1266
|
{
|
|
1174
|
-
value:
|
|
1175
|
-
? parseFloat(e.target.value)
|
|
1176
|
-
: e.target.value,
|
|
1267
|
+
value: e.target.value,
|
|
1177
1268
|
path: keyPrefix + 'value',
|
|
1178
1269
|
},
|
|
1179
1270
|
]) }));
|
|
1180
1271
|
case 'null':
|
|
1181
1272
|
return (0, jsx_runtime_1.jsx)("div", {});
|
|
1182
1273
|
case 'number':
|
|
1183
|
-
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) => {
|
|
1184
1275
|
handleChange([
|
|
1185
1276
|
{
|
|
1186
|
-
value:
|
|
1187
|
-
? parseFloat(e.target.value)
|
|
1188
|
-
: e.target.value,
|
|
1277
|
+
value: e.target.value,
|
|
1189
1278
|
path: keyPrefix + 'value',
|
|
1190
1279
|
},
|
|
1191
1280
|
]);
|
|
@@ -1212,6 +1301,22 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1212
1301
|
return null;
|
|
1213
1302
|
}
|
|
1214
1303
|
};
|
|
1304
|
+
const isValidPivot = (fields) => {
|
|
1305
|
+
let validPivot = true;
|
|
1306
|
+
if (pivot.rowField &&
|
|
1307
|
+
!fields.find((field) => field.name === pivot.rowField)) {
|
|
1308
|
+
validPivot = false;
|
|
1309
|
+
}
|
|
1310
|
+
if (pivot.valueField &&
|
|
1311
|
+
!fields.find((field) => field.name === pivot.valueField)) {
|
|
1312
|
+
validPivot = false;
|
|
1313
|
+
}
|
|
1314
|
+
if (pivot.columnField &&
|
|
1315
|
+
!fields.find((field) => field.name === pivot.columnField)) {
|
|
1316
|
+
validPivot = false;
|
|
1317
|
+
}
|
|
1318
|
+
return validPivot;
|
|
1319
|
+
};
|
|
1215
1320
|
const renderSentence = (formData, node, keyPrefix = '',
|
|
1216
1321
|
// @depreciated TODO: remove next update
|
|
1217
1322
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -1239,13 +1344,13 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1239
1344
|
const OPS = {
|
|
1240
1345
|
AND: 'and',
|
|
1241
1346
|
OR: 'or',
|
|
1242
|
-
LIKE: 'is',
|
|
1347
|
+
LIKE: 'is exactly',
|
|
1243
1348
|
BETWEEN: 'is between',
|
|
1244
|
-
IN: 'is
|
|
1245
|
-
'NOT IN': 'is not
|
|
1246
|
-
'NOT LIKE': 'is not',
|
|
1247
|
-
'!=': 'is not',
|
|
1248
|
-
'=': 'is',
|
|
1349
|
+
IN: 'is',
|
|
1350
|
+
'NOT IN': 'is not',
|
|
1351
|
+
'NOT LIKE': 'is not exactly',
|
|
1352
|
+
'!=': 'is not exactly',
|
|
1353
|
+
'=': 'is exactly',
|
|
1249
1354
|
'<': 'is less than',
|
|
1250
1355
|
'>': 'is greater than',
|
|
1251
1356
|
'<=': 'is less than or equal to',
|
|
@@ -1253,25 +1358,16 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1253
1358
|
'<>': 'is not',
|
|
1254
1359
|
'-': 'minus',
|
|
1255
1360
|
'IS NOT': 'is not',
|
|
1256
|
-
IS: 'is
|
|
1361
|
+
IS: 'is',
|
|
1257
1362
|
};
|
|
1258
1363
|
switch (node.type) {
|
|
1259
1364
|
case 'binary_expr':
|
|
1260
|
-
return ((0, jsx_runtime_1.jsx)(ui_1.TagWrapper, { keyPrefix: keyPrefix, formData: formData, activeEditItem: activeEditItem, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setCheckboxes: setCheckboxes, handleReplaceSubtree: handleReplaceSubtree, FilterPopover:
|
|
1261
|
-
display: 'flex',
|
|
1262
|
-
gap: 3,
|
|
1263
|
-
flexDirection: isRow ? 'row' : 'column',
|
|
1264
|
-
padding: '1px',
|
|
1265
|
-
border: isCard ? '1px solid black' : 'none',
|
|
1266
|
-
whiteSpace: 'nowrap',
|
|
1267
|
-
overflow: 'hidden',
|
|
1268
|
-
textOverflow: 'ellipsis',
|
|
1269
|
-
}, 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 ??
|
|
1270
1366
|
dateEqualityPartialMatch ??
|
|
1271
1367
|
isInTheCurrentIntervalSentence ??
|
|
1272
1368
|
isInTheLastIntervalSentence ??
|
|
1273
1369
|
isInThePreviousIntervalSentence ?? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [node.left &&
|
|
1274
|
-
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 &&
|
|
1275
1371
|
renderSentence(formData, node.right, keyPrefix + 'right.', false, false, isRow)] })) }));
|
|
1276
1372
|
case 'column_ref':
|
|
1277
1373
|
return (0, textProcessing_1.snakeCaseToTitleCase)(node.column);
|
|
@@ -1306,6 +1402,9 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1306
1402
|
if (node.args.value.length < 1)
|
|
1307
1403
|
return null;
|
|
1308
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
|
+
}
|
|
1309
1408
|
return (0, textProcessing_1.snakeCaseToTitleCase)(node.args.value[0].value.replaceAll('%', ''));
|
|
1310
1409
|
}
|
|
1311
1410
|
if (node.args.value[0].column)
|
|
@@ -1353,9 +1452,11 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1353
1452
|
}))
|
|
1354
1453
|
.sort((a, b) => {
|
|
1355
1454
|
const aIsId = a.name.toLowerCase() === 'id' ||
|
|
1356
|
-
a.name.toLowerCase().endsWith('_id')
|
|
1455
|
+
a.name.toLowerCase().endsWith('_id') ||
|
|
1456
|
+
a.name.endsWith('Id');
|
|
1357
1457
|
const bIsId = b.name.toLowerCase() === 'id' ||
|
|
1358
|
-
b.name.toLowerCase().endsWith('_id')
|
|
1458
|
+
b.name.toLowerCase().endsWith('_id') ||
|
|
1459
|
+
b.name.endsWith('Id');
|
|
1359
1460
|
if (aIsId && !bIsId)
|
|
1360
1461
|
return 1;
|
|
1361
1462
|
if (bIsId && !aIsId)
|
|
@@ -1372,7 +1473,8 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1372
1473
|
return false;
|
|
1373
1474
|
const allColumns = orderedColumnNames.filter((row) => {
|
|
1374
1475
|
const [table, _] = row.split('.');
|
|
1375
|
-
|
|
1476
|
+
const selectedTable = selectedColumns[0].split('.')[0];
|
|
1477
|
+
return selectedTable === table;
|
|
1376
1478
|
});
|
|
1377
1479
|
return selectedColumns.length === allColumns.length;
|
|
1378
1480
|
};
|
|
@@ -1391,12 +1493,12 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1391
1493
|
fontSize: 18,
|
|
1392
1494
|
margin: 0,
|
|
1393
1495
|
textAlign: 'left',
|
|
1394
|
-
}, 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: {
|
|
1395
1497
|
display: 'flex',
|
|
1396
1498
|
flexDirection: 'row',
|
|
1397
1499
|
gap: 8,
|
|
1398
1500
|
justifyContent: 'end',
|
|
1399
|
-
}, children: (0, jsx_runtime_1.jsx)(
|
|
1501
|
+
}, children: (0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: onSave, label: 'Add condition' }) })] }));
|
|
1400
1502
|
};
|
|
1401
1503
|
const fetchUponChange = async (baseAst, newFormData) => {
|
|
1402
1504
|
// if newFormData is null still use it
|
|
@@ -1415,26 +1517,24 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1415
1517
|
orgId: client.customerId,
|
|
1416
1518
|
}),
|
|
1417
1519
|
});
|
|
1520
|
+
const tables = (0, ast_1.getTableNames)(baseAst);
|
|
1521
|
+
const table = tables.length >= 1 ? tables[0] : initialTableName;
|
|
1522
|
+
if (table !== currentTable) {
|
|
1523
|
+
await getDistinctValues(table);
|
|
1524
|
+
setCurrentTable(table);
|
|
1525
|
+
}
|
|
1418
1526
|
const data2 = await res2.json();
|
|
1419
1527
|
if (data2.rows && data2.rows.length) {
|
|
1420
1528
|
const tables = (0, ast_1.getTableNames)(baseAst);
|
|
1421
|
-
const table = tables.length >= 1 ? tables[0] : initialTableName;
|
|
1422
|
-
if (table !== currentTable) {
|
|
1423
|
-
getDistinctValues(table);
|
|
1424
|
-
setCurrentTable(table);
|
|
1425
|
-
}
|
|
1426
|
-
const sortedFields = data2.fields.sort((a, b) => {
|
|
1427
|
-
const aIsId = a.name.toLowerCase() === 'id' ||
|
|
1428
|
-
a.name.toLowerCase().endsWith('_id');
|
|
1429
|
-
const bIsId = b.name.toLowerCase() === 'id' ||
|
|
1430
|
-
b.name.toLowerCase().endsWith('_id');
|
|
1431
|
-
if (aIsId && !bIsId)
|
|
1432
|
-
return 1;
|
|
1433
|
-
if (bIsId && !aIsId)
|
|
1434
|
-
return -1;
|
|
1435
|
-
return 0;
|
|
1436
|
-
});
|
|
1437
1529
|
if (pivot) {
|
|
1530
|
+
// check if any of the pivot fields aren't in the data2.fields array
|
|
1531
|
+
if (!isValidPivot(data2.fields)) {
|
|
1532
|
+
setPivot(null);
|
|
1533
|
+
setPivotData(null);
|
|
1534
|
+
setRows(data2.rows);
|
|
1535
|
+
setFields(data2.fields);
|
|
1536
|
+
return;
|
|
1537
|
+
}
|
|
1438
1538
|
// Do all of this to make sure we have the right unique columns when applying a pivot
|
|
1439
1539
|
let uniqueFormatted = {};
|
|
1440
1540
|
const uniqueRecords = Array.from(new Set(data2.rows.map((row) => row[pivot.columnField]))).reduce((acc, curr) => {
|
|
@@ -1659,11 +1759,10 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1659
1759
|
newAst = (0, convert_1.convertRemoveSimpleParentheses)(newAst);
|
|
1660
1760
|
const table = (0, ast_1.getTableNames)(newAst)[0] ?? initialTableName;
|
|
1661
1761
|
const tableAlias = (0, ast_1.getTableAliases)(newAst)[0] ?? initialTableName;
|
|
1662
|
-
newAst = (0, util_1.removeNonSelectedTableReferences)(newAst, tableAlias ?? table);
|
|
1762
|
+
newAst = (0, util_1.removeNonSelectedTableReferences)(newAst, tableAlias ?? table, getAllPossibleColumns().map((col) => col.name));
|
|
1663
1763
|
// newAst = convertDateComparison(newAst); // TODO
|
|
1664
|
-
ast = newAst; // so we fetch data for newAst later.
|
|
1665
1764
|
if (table !== currentTable) {
|
|
1666
|
-
getDistinctValues(table);
|
|
1765
|
+
await getDistinctValues(table);
|
|
1667
1766
|
setCurrentTable(table);
|
|
1668
1767
|
}
|
|
1669
1768
|
setPivotRowField(groupByPivot?.rowField);
|
|
@@ -1681,6 +1780,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1681
1780
|
}));
|
|
1682
1781
|
if (groupByPivot) {
|
|
1683
1782
|
setBaseAst((0, util_1.deepCopy)({ ...newAst, orderby: null, limit: null }));
|
|
1783
|
+
newAst = (0, util_1.deepCopy)({ ...newAst, orderby: null, limit: null });
|
|
1684
1784
|
}
|
|
1685
1785
|
else {
|
|
1686
1786
|
setBaseAst((0, util_1.deepCopy)({ ...newAst }));
|
|
@@ -1690,6 +1790,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1690
1790
|
// @ts-ignore
|
|
1691
1791
|
newAst?.where ? newAst?.where?.operator : 'AND');
|
|
1692
1792
|
}
|
|
1793
|
+
ast = newAst; // so we fetch data for newAst later.
|
|
1693
1794
|
const res2 = await fetch('https://quill-344421.uc.r.appspot.com/patterns', {
|
|
1694
1795
|
method: 'POST',
|
|
1695
1796
|
headers: {
|
|
@@ -1770,11 +1871,11 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1770
1871
|
fetchSqlQuery(newAst);
|
|
1771
1872
|
};
|
|
1772
1873
|
function TopLevelBooleanSwitch({ node, keyPrefix, handleOperatorChange, }) {
|
|
1773
|
-
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) => {
|
|
1774
1875
|
if (loading) {
|
|
1775
1876
|
return;
|
|
1776
1877
|
}
|
|
1777
|
-
handleOperatorChange(value, node, keyPrefix);
|
|
1878
|
+
handleOperatorChange(event.target.value, node, keyPrefix);
|
|
1778
1879
|
} }) }));
|
|
1779
1880
|
}
|
|
1780
1881
|
const DraggableItem = ({ id, label, onDelete }) => {
|
|
@@ -1783,9 +1884,9 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1783
1884
|
transform: utilities_1.CSS.Transform.toString(transform),
|
|
1784
1885
|
transition,
|
|
1785
1886
|
};
|
|
1786
|
-
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: {
|
|
1787
1888
|
cursor: 'grab',
|
|
1788
|
-
}, ...attributes, ...listeners, children: (0, jsx_runtime_1.jsx)(
|
|
1889
|
+
}, ...attributes, ...listeners, children: (0, jsx_runtime_1.jsx)(props.dragIcon, {}) })) }) }));
|
|
1789
1890
|
};
|
|
1790
1891
|
function DraggableColumns() {
|
|
1791
1892
|
const sensors = (0, core_1.useSensors)((0, core_1.useSensor)(core_1.PointerSensor), (0, core_1.useSensor)(core_1.KeyboardSensor, {
|
|
@@ -1795,8 +1896,8 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1795
1896
|
function handleDragEnd(event) {
|
|
1796
1897
|
const { active, over } = event;
|
|
1797
1898
|
if (active.id !== over.id) {
|
|
1798
|
-
const oldIndex = orderedColumnNames.findIndex((c) => c.endsWith(active.id));
|
|
1799
|
-
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}`));
|
|
1800
1901
|
const newOrder = (0, sortable_1.arrayMove)(orderedColumnNames, oldIndex, newIndex);
|
|
1801
1902
|
setOrderedColumnNames(newOrder);
|
|
1802
1903
|
const orderedSelectedColumns = [];
|
|
@@ -1851,23 +1952,27 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1851
1952
|
flexDirection: 'row',
|
|
1852
1953
|
height: '100%',
|
|
1853
1954
|
...containerStyle,
|
|
1854
|
-
}, ref: parentRef, children: [(0, jsx_runtime_1.jsxs)(
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
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: () => {
|
|
1864
1969
|
setActiveEditItem(null);
|
|
1865
1970
|
setActivePath(null);
|
|
1866
1971
|
setOpenPopover(null);
|
|
1867
1972
|
}, orderedColumnNames: orderedColumnNames, setOrderedColumnNames: setOrderedColumnNames, selectedColumns: selectedColumns, setSelectedColumns: setSelectedColumns, isSelectedAllColumns: isSelectedAllColumns, clearAllState: clearAllState, nameToColumn: nameToColumn, baseAst: baseAst, setBaseAst: (newAst) => {
|
|
1868
1973
|
setBaseAst(newAst);
|
|
1869
1974
|
fetchSqlQuery(newAst);
|
|
1870
|
-
}, 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: {
|
|
1871
1976
|
display: 'flex',
|
|
1872
1977
|
flexDirection: 'column',
|
|
1873
1978
|
gap: 8,
|
|
@@ -1877,37 +1982,41 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1877
1982
|
flexDirection: 'column',
|
|
1878
1983
|
gap: 2.5,
|
|
1879
1984
|
alignItems: 'flex-start',
|
|
1880
|
-
}, children: [(0, jsx_runtime_1.jsx)(
|
|
1881
|
-
|
|
1882
|
-
|
|
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);
|
|
1883
1999
|
}
|
|
1884
|
-
|
|
1885
|
-
const
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
if ((0, ast_1.isNumericColumnType)(columnType)) {
|
|
1889
|
-
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultNumericComparison);
|
|
1890
|
-
newSubtree.left.column = column;
|
|
1891
|
-
setActiveEditItem(newSubtree);
|
|
1892
|
-
}
|
|
1893
|
-
else {
|
|
1894
|
-
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultEntry);
|
|
1895
|
-
newSubtree.left.args.value[0].column = column;
|
|
1896
|
-
setActiveEditItem(newSubtree);
|
|
1897
|
-
}
|
|
1898
|
-
setOpenPopover('AddFilterPopover');
|
|
1899
|
-
setActivePath('');
|
|
1900
|
-
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);
|
|
1901
2004
|
}
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
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: () => {
|
|
1911
2020
|
if ((0, util_1.isNodeEmptyCollection)(activeEditItem)) {
|
|
1912
2021
|
setIsPending(false);
|
|
1913
2022
|
setActivePath(null);
|
|
@@ -1927,44 +2036,46 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1927
2036
|
setActiveEditItem(null);
|
|
1928
2037
|
}, 300);
|
|
1929
2038
|
}
|
|
1930
|
-
}, Button:
|
|
2039
|
+
}, Button: ButtonComponent, renderNode: renderNode, activeEditItem: activeEditItem }) }), baseAst?.where &&
|
|
1931
2040
|
false && ( // temp removed the AddConditionPopover
|
|
1932
|
-
(0, jsx_runtime_1.
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
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: () => {
|
|
1968
2079
|
setPivot(null);
|
|
1969
2080
|
setPivotData(null);
|
|
1970
2081
|
},
|
|
@@ -1978,7 +2089,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1978
2089
|
setPivot(pivot);
|
|
1979
2090
|
const pivotedData = (0, PivotModal_1.generatePivotTable)(pivot, rows, [null, null, null], false);
|
|
1980
2091
|
setPivotData(pivotedData || []);
|
|
1981
|
-
}, 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: {
|
|
1982
2093
|
pivot: pivot,
|
|
1983
2094
|
rows: pivotData?.rows || [],
|
|
1984
2095
|
columns: pivotData?.columns || [],
|
|
@@ -1990,11 +2101,11 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1990
2101
|
setPivotValueField(pivot?.valueField);
|
|
1991
2102
|
setPivotAggregation(pivot?.aggregationType);
|
|
1992
2103
|
setPivotPopUpTitle('Edit Pivot');
|
|
1993
|
-
}, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent:
|
|
2104
|
+
}, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent: ButtonComponent, HeaderComponent: HeaderComponent, showEdit: false, onClose: () => {
|
|
1994
2105
|
setPivot(null);
|
|
1995
2106
|
setPivotData(null);
|
|
1996
2107
|
setBaseAst((0, util_1.deepCopy)(baseAst)); // trigger refetch
|
|
1997
|
-
}, 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: {
|
|
1998
2109
|
display: 'flex',
|
|
1999
2110
|
flexDirection: 'column',
|
|
2000
2111
|
gap: 8,
|
|
@@ -2002,7 +2113,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2002
2113
|
}, children: (0, jsx_runtime_1.jsx)(AddSortPopover_1.SortSentence, { sortData: {
|
|
2003
2114
|
type: pivot.sortDirection,
|
|
2004
2115
|
expr: { type: 'column_ref', column: pivot.rowField },
|
|
2005
|
-
}, 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: () => {
|
|
2006
2117
|
setPivot({ ...pivot, sort: false });
|
|
2007
2118
|
setBaseAst((0, util_1.deepCopy)(baseAst));
|
|
2008
2119
|
if (!pivot) {
|
|
@@ -2015,7 +2126,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2015
2126
|
if (!pivot) {
|
|
2016
2127
|
fetchSqlQuery(baseAst);
|
|
2017
2128
|
}
|
|
2018
|
-
} }, `sort-sentence-pivot`) })), baseAst && baseAst.orderby && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
2129
|
+
}, Select: SelectComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent }, `sort-sentence-pivot`) })), baseAst && baseAst.orderby && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
2019
2130
|
display: 'flex',
|
|
2020
2131
|
flexDirection: 'column',
|
|
2021
2132
|
gap: 8,
|
|
@@ -2042,31 +2153,33 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2042
2153
|
if (!pivot) {
|
|
2043
2154
|
fetchSqlQuery(newAst);
|
|
2044
2155
|
}
|
|
2045
|
-
}, 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: () => {
|
|
2046
2157
|
const newAst = { ...baseAst };
|
|
2047
2158
|
newAst.orderby.splice(id, 1);
|
|
2048
2159
|
setBaseAst((0, util_1.deepCopy)(newAst));
|
|
2049
2160
|
if (!pivot) {
|
|
2050
2161
|
fetchSqlQuery(newAst);
|
|
2051
2162
|
}
|
|
2052
|
-
} }, `sort-sentence-${id}`))) })), (0, jsx_runtime_1.jsx)(
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
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: {
|
|
2065
2178
|
display: 'flex',
|
|
2066
2179
|
flexDirection: 'column',
|
|
2067
2180
|
gap: 8,
|
|
2068
2181
|
marginBottom: 12,
|
|
2069
|
-
}, 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: () => {
|
|
2070
2183
|
const newAst = { ...baseAst };
|
|
2071
2184
|
newAst.limit = null;
|
|
2072
2185
|
setBaseAst((0, util_1.deepCopy)(newAst));
|
|
@@ -2085,27 +2198,29 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2085
2198
|
setOpenPopover(null);
|
|
2086
2199
|
setBaseAst((0, util_1.deepCopy)(newAst));
|
|
2087
2200
|
fetchSqlQuery(newAst);
|
|
2088
|
-
} }) })) : ((0, jsx_runtime_1.
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
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) => {
|
|
2098
2213
|
event.preventDefault();
|
|
2099
2214
|
}, style: {
|
|
2100
2215
|
display: 'flex',
|
|
2101
2216
|
flexDirection: 'row',
|
|
2102
2217
|
gap: 12,
|
|
2103
2218
|
padding: 1,
|
|
2104
|
-
}, 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: {
|
|
2105
2220
|
display: 'flex',
|
|
2106
2221
|
flexDirection: 'row',
|
|
2107
2222
|
gap: '12px',
|
|
2108
|
-
}, 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;}` })] }));
|
|
2109
2224
|
}
|
|
2110
2225
|
return ((0, jsx_runtime_1.jsxs)("div", { ref: parentRef, style: {
|
|
2111
2226
|
display: 'flex',
|
|
@@ -2114,26 +2229,28 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2114
2229
|
overflowY: 'auto',
|
|
2115
2230
|
boxSizing: 'border-box',
|
|
2116
2231
|
...containerStyle,
|
|
2117
|
-
}, children: [(0, jsx_runtime_1.jsxs)(
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
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: () => {
|
|
2130
2247
|
setActiveEditItem(null);
|
|
2131
2248
|
setActivePath(null);
|
|
2132
2249
|
setOpenPopover(null);
|
|
2133
2250
|
}, orderedColumnNames: orderedColumnNames, setOrderedColumnNames: setOrderedColumnNames, selectedColumns: selectedColumns, setSelectedColumns: setSelectedColumns, isSelectedAllColumns: isSelectedAllColumns, clearAllState: clearAllState, nameToColumn: nameToColumn, baseAst: baseAst, setBaseAst: (ast) => {
|
|
2134
2251
|
setBaseAst(ast);
|
|
2135
2252
|
fetchSqlQuery(ast);
|
|
2136
|
-
}, 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: {
|
|
2137
2254
|
display: 'flex',
|
|
2138
2255
|
flexDirection: 'column',
|
|
2139
2256
|
gap: 8,
|
|
@@ -2143,50 +2260,42 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2143
2260
|
flexDirection: 'column',
|
|
2144
2261
|
gap: 2.5,
|
|
2145
2262
|
alignItems: 'flex-start',
|
|
2146
|
-
}, children: [(0, jsx_runtime_1.jsx)(
|
|
2147
|
-
|
|
2148
|
-
|
|
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);
|
|
2149
2275
|
}
|
|
2150
|
-
|
|
2151
|
-
const
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
if ((0, ast_1.isNumericColumnType)(columnType)) {
|
|
2155
|
-
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultNumericComparison);
|
|
2156
|
-
newSubtree.left.column = column;
|
|
2157
|
-
setActiveEditItem(newSubtree);
|
|
2158
|
-
}
|
|
2159
|
-
else {
|
|
2160
|
-
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultEntry);
|
|
2161
|
-
newSubtree.left.args.value[0].column = column;
|
|
2162
|
-
setActiveEditItem(newSubtree);
|
|
2163
|
-
}
|
|
2164
|
-
setOpenPopover('AddFilterPopover');
|
|
2165
|
-
setActivePath('');
|
|
2166
|
-
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);
|
|
2167
2280
|
}
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
}, 200);
|
|
2177
|
-
}, children: (0, jsx_runtime_1.jsx)(ui_1.AddFilterPopover, { onSave: () => {
|
|
2178
|
-
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(() => {
|
|
2179
2289
|
setIsPending(false);
|
|
2180
2290
|
setActivePath(null);
|
|
2181
2291
|
setOpenPopover(null);
|
|
2182
2292
|
clearCheckboxes();
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
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)) {
|
|
2188
2298
|
setIsPending(false);
|
|
2189
|
-
handleInsertion(activeEditItem, 'AND', false);
|
|
2190
2299
|
setActivePath(null);
|
|
2191
2300
|
setOpenPopover(null);
|
|
2192
2301
|
clearCheckboxes();
|
|
@@ -2194,45 +2303,57 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2194
2303
|
setActiveEditItem(null);
|
|
2195
2304
|
}, 300);
|
|
2196
2305
|
}
|
|
2197
|
-
|
|
2198
|
-
false && ( // temp removed the AddConditionPopover
|
|
2199
|
-
(0, jsx_runtime_1.jsx)(Popover, { isOpen: openPopover === 'AddConditionPopover', trigger: (0, jsx_runtime_1.jsx)(SecondaryButton, { onClick: () => {
|
|
2200
|
-
if (!openPopover) {
|
|
2201
|
-
setActiveEditItem((0, util_1.deepCopy)(constants_1.defaultEntry));
|
|
2202
|
-
setOpenPopover('AddConditionPopover');
|
|
2203
|
-
setActivePath('');
|
|
2204
|
-
setIsPending(true);
|
|
2205
|
-
}
|
|
2206
|
-
}, label: 'Add condition' }), onClose: () => {
|
|
2207
|
-
// delay onClose callback so onClick no-ops
|
|
2208
|
-
setTimeout(() => {
|
|
2209
|
-
setIsPending(false);
|
|
2210
|
-
setActiveEditItem(null);
|
|
2211
|
-
setActivePath(null);
|
|
2212
|
-
setOpenPopover(null);
|
|
2213
|
-
clearCheckboxes();
|
|
2214
|
-
}, 200);
|
|
2215
|
-
}, children: (0, jsx_runtime_1.jsx)(AddConditionPopover, { onSave: () => {
|
|
2216
|
-
if ((0, util_1.isNodeEmptyCollection)(activeEditItem)) {
|
|
2306
|
+
else {
|
|
2217
2307
|
setIsPending(false);
|
|
2218
|
-
|
|
2219
|
-
setActiveEditItem(null);
|
|
2220
|
-
}, 300);
|
|
2308
|
+
handleInsertion(activeEditItem, 'AND', false);
|
|
2221
2309
|
setActivePath(null);
|
|
2222
2310
|
setOpenPopover(null);
|
|
2223
2311
|
clearCheckboxes();
|
|
2224
|
-
}
|
|
2225
|
-
else {
|
|
2226
|
-
setIsPending(false);
|
|
2227
|
-
handleInsertion(activeEditItem, topLevelBinaryOperator, true);
|
|
2228
2312
|
setTimeout(() => {
|
|
2229
2313
|
setActiveEditItem(null);
|
|
2230
2314
|
}, 300);
|
|
2231
|
-
setActivePath(null);
|
|
2232
|
-
setOpenPopover(null);
|
|
2233
|
-
clearCheckboxes();
|
|
2234
2315
|
}
|
|
2235
|
-
}
|
|
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: () => {
|
|
2236
2357
|
setPivot(null);
|
|
2237
2358
|
setPivotData(null);
|
|
2238
2359
|
}, selectPivot: (pivot) => {
|
|
@@ -2248,7 +2369,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2248
2369
|
setPivot(pivot);
|
|
2249
2370
|
const pivotedData = (0, PivotModal_1.generatePivotTable)(pivot, rows, [null, null, null], false);
|
|
2250
2371
|
setPivotData(pivotedData || []);
|
|
2251
|
-
}, 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: {
|
|
2252
2373
|
pivot: pivot,
|
|
2253
2374
|
rows: pivotData?.rows || [],
|
|
2254
2375
|
columns: pivotData?.columns || [],
|
|
@@ -2260,11 +2381,11 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2260
2381
|
setPivotValueField(pivot?.valueField);
|
|
2261
2382
|
setPivotAggregation(pivot?.aggregationType);
|
|
2262
2383
|
setPivotPopUpTitle('Edit Pivot');
|
|
2263
|
-
}, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent:
|
|
2384
|
+
}, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent: ButtonComponent, HeaderComponent: HeaderComponent, showEdit: false, onClose: () => {
|
|
2264
2385
|
setPivot(null);
|
|
2265
2386
|
setPivotData(null);
|
|
2266
2387
|
setBaseAst((0, util_1.deepCopy)(baseAst));
|
|
2267
|
-
}, 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: {
|
|
2268
2389
|
display: 'flex',
|
|
2269
2390
|
flexDirection: 'column',
|
|
2270
2391
|
gap: 8,
|
|
@@ -2272,7 +2393,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2272
2393
|
}, children: (0, jsx_runtime_1.jsx)(AddSortPopover_1.SortSentence, { sortData: {
|
|
2273
2394
|
type: pivot.sortDirection,
|
|
2274
2395
|
expr: { type: 'column_ref', column: pivot.rowField },
|
|
2275
|
-
}, 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: () => {
|
|
2276
2397
|
if (pivot) {
|
|
2277
2398
|
setPivot({ ...pivot, sort: false });
|
|
2278
2399
|
const pivotedData = (0, PivotModal_1.generatePivotTable)({ ...pivot, sort: false }, rows, [null, null, null], false);
|
|
@@ -2291,12 +2412,12 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2291
2412
|
setOpenPopover(null);
|
|
2292
2413
|
setBaseAst((0, util_1.deepCopy)(baseAst));
|
|
2293
2414
|
fetchSqlQuery((0, util_1.deepCopy)(baseAst));
|
|
2294
|
-
} }, `sort-sentence-pivot`) })), baseAst && baseAst.orderby && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
2415
|
+
}, Select: SelectComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent }, `sort-sentence-pivot`) })), baseAst && baseAst.orderby && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
2295
2416
|
display: 'flex',
|
|
2296
2417
|
flexDirection: 'column',
|
|
2297
2418
|
gap: 8,
|
|
2298
2419
|
marginBottom: 12,
|
|
2299
|
-
}, 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: () => {
|
|
2300
2421
|
if (pivot) {
|
|
2301
2422
|
setPivot({ ...pivot, sort: false });
|
|
2302
2423
|
return;
|
|
@@ -2333,19 +2454,21 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2333
2454
|
setOpenPopover(null);
|
|
2334
2455
|
setBaseAst((0, util_1.deepCopy)(newAst));
|
|
2335
2456
|
fetchSqlQuery((0, util_1.deepCopy)(newAst));
|
|
2336
|
-
} }, `sort-sentence-${id}`))) })), (0, jsx_runtime_1.jsx)(
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
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) => {
|
|
2349
2472
|
if (column === '')
|
|
2350
2473
|
return;
|
|
2351
2474
|
if (pivot) {
|
|
@@ -2369,12 +2492,12 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2369
2492
|
setOpenPopover(null);
|
|
2370
2493
|
setBaseAst((0, util_1.deepCopy)(newAst));
|
|
2371
2494
|
fetchSqlQuery((0, util_1.deepCopy)(newAst));
|
|
2372
|
-
} }) }), (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: {
|
|
2373
2496
|
display: 'flex',
|
|
2374
2497
|
flexDirection: 'column',
|
|
2375
2498
|
gap: 8,
|
|
2376
2499
|
marginBottom: 12,
|
|
2377
|
-
}, 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: () => {
|
|
2378
2501
|
const newAst = { ...baseAst };
|
|
2379
2502
|
newAst.limit = null;
|
|
2380
2503
|
setBaseAst((0, util_1.deepCopy)(newAst));
|
|
@@ -2393,36 +2516,38 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2393
2516
|
setOpenPopover(null);
|
|
2394
2517
|
setBaseAst((0, util_1.deepCopy)(newAst));
|
|
2395
2518
|
fetchSqlQuery((0, util_1.deepCopy)(newAst));
|
|
2396
|
-
} }) })) : ((0, jsx_runtime_1.
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
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) => {
|
|
2426
2551
|
event.preventDefault();
|
|
2427
2552
|
handleAsk();
|
|
2428
2553
|
}, style: {
|
|
@@ -2430,14 +2555,14 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2430
2555
|
flexDirection: 'row',
|
|
2431
2556
|
gap: 12,
|
|
2432
2557
|
padding: 1,
|
|
2433
|
-
}, children: [(0, jsx_runtime_1.jsx)(
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
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: {
|
|
2441
2566
|
display: 'flex',
|
|
2442
2567
|
flexDirection: 'row',
|
|
2443
2568
|
gap: '12px',
|
|
@@ -2446,8 +2571,8 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2446
2571
|
fontSize: 14,
|
|
2447
2572
|
padding: '12px',
|
|
2448
2573
|
whiteSpace: 'nowrap',
|
|
2449
|
-
}, 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: () => {
|
|
2450
2575
|
setIsChartBuilderOpen(true);
|
|
2451
|
-
}, label: 'Add to dashboard' })] }))] })] }), (0, jsx_runtime_1.jsx)("style", { children: `body{margin:0;}` }), (0, jsx_runtime_1.jsx)(ChartBuilder_1.ChartBuilderWithModal, { rows:
|
|
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 })] }));
|
|
2452
2577
|
}
|
|
2453
2578
|
exports.default = ReportBuilder;
|