@quillsql/react 2.12.46 → 2.12.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Chart.d.ts.map +1 -1
- package/dist/cjs/Chart.js +16 -7
- package/dist/cjs/ChartBuilder.d.ts +10 -11
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +78 -81
- package/dist/cjs/ChartEditor.d.ts +3 -1
- package/dist/cjs/ChartEditor.d.ts.map +1 -1
- package/dist/cjs/ChartEditor.js +26 -10
- package/dist/cjs/Context.d.ts +2 -3
- package/dist/cjs/Context.d.ts.map +1 -1
- package/dist/cjs/Context.js +42 -28
- package/dist/cjs/Dashboard.d.ts +12 -12
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/Dashboard.js +61 -69
- package/dist/cjs/QuillProvider.d.ts +2 -0
- package/dist/cjs/QuillProvider.d.ts.map +1 -1
- package/dist/cjs/QuillProvider.js +1 -15
- package/dist/cjs/ReportBuilder.d.ts +9 -9
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +116 -179
- package/dist/cjs/SQLEditor.d.ts +20 -11
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +157 -90
- package/dist/cjs/Table.js +3 -3
- package/dist/cjs/components/Chart/BarChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/BarChart.js +6 -25
- package/dist/cjs/components/Chart/BarList.js +1 -1
- package/dist/cjs/components/Chart/ChartError.d.ts +5 -2
- package/dist/cjs/components/Chart/ChartError.d.ts.map +1 -1
- package/dist/cjs/components/Chart/ChartError.js +7 -10
- package/dist/cjs/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/LineChart.js +16 -1
- package/dist/cjs/components/Chart/PieChart.js +1 -1
- package/dist/cjs/components/Dashboard/ChartComponent.d.ts +1 -1
- package/dist/cjs/components/Dashboard/ChartComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/ChartComponent.js +46 -47
- package/dist/cjs/components/Dashboard/DashboardFilter.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DashboardFilter.js +2 -1
- package/dist/cjs/components/Dashboard/DataLoader.d.ts +2 -2
- package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.js +19 -13
- package/dist/cjs/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/MetricComponent.js +16 -26
- package/dist/cjs/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/TableComponent.js +16 -25
- package/dist/cjs/components/QuillMultiSelectWithCombo.d.ts.map +1 -1
- package/dist/cjs/components/QuillMultiSelectWithCombo.js +31 -1
- package/dist/cjs/components/QuillSelect.js +1 -1
- package/dist/cjs/components/QuillTable.d.ts +1 -1
- package/dist/cjs/components/QuillTable.d.ts.map +1 -1
- package/dist/cjs/components/QuillTable.js +115 -105
- package/dist/cjs/components/ReportBuilder/AddColumnModal.d.ts +3 -3
- package/dist/cjs/components/ReportBuilder/AddColumnModal.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddColumnModal.js +2 -2
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.d.ts +2 -2
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.js +28 -9
- package/dist/cjs/components/ReportBuilder/FilterModal.d.ts +1 -1
- package/dist/cjs/components/ReportBuilder/FilterModal.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/FilterModal.js +178 -114
- package/dist/cjs/components/ReportBuilder/convert.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/convert.js +1 -2
- package/dist/cjs/components/ReportBuilder/ui.d.ts +9 -1
- package/dist/cjs/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/ui.js +37 -3
- package/dist/cjs/components/ReportBuilder/util.d.ts +5 -1
- package/dist/cjs/components/ReportBuilder/util.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/util.js +26 -12
- package/dist/cjs/components/UiComponents.d.ts +17 -3
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +160 -29
- package/dist/cjs/hooks/useAskQuill.d.ts.map +1 -1
- package/dist/cjs/hooks/useAskQuill.js +7 -7
- package/dist/cjs/hooks/useAstToFilterTree.d.ts +4 -1
- package/dist/cjs/hooks/useAstToFilterTree.d.ts.map +1 -1
- package/dist/cjs/hooks/useAstToFilterTree.js +4 -1
- package/dist/cjs/hooks/useDashboard.d.ts +5 -1
- package/dist/cjs/hooks/useDashboard.d.ts.map +1 -1
- package/dist/cjs/hooks/useDashboard.js +28 -4
- package/dist/cjs/hooks/useOnClickOutside.js +2 -2
- package/dist/cjs/hooks/useQuill.js +4 -4
- package/dist/cjs/hooks/useVirtualTables.d.ts +10 -0
- package/dist/cjs/hooks/useVirtualTables.d.ts.map +1 -0
- package/dist/cjs/hooks/useVirtualTables.js +29 -0
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +4 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.js +45 -21
- package/dist/cjs/models/Client.d.ts +3 -0
- package/dist/cjs/models/Client.d.ts.map +1 -1
- package/dist/cjs/models/Report.d.ts +2 -0
- package/dist/cjs/models/Report.d.ts.map +1 -1
- package/dist/cjs/models/Schema.d.ts +7 -0
- package/dist/cjs/models/Schema.d.ts.map +1 -0
- package/dist/cjs/models/Schema.js +2 -0
- package/dist/cjs/models/Tables.d.ts +2 -0
- package/dist/cjs/models/Tables.d.ts.map +1 -1
- package/dist/cjs/utils/astFilterProcessing.d.ts +4 -0
- package/dist/cjs/utils/astFilterProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/astFilterProcessing.js +47 -44
- package/dist/cjs/utils/astProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/astProcessing.js +8 -8
- package/dist/cjs/utils/client.d.ts.map +1 -1
- package/dist/cjs/utils/client.js +1 -0
- package/dist/cjs/utils/columnProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/columnProcessing.js +88 -5
- package/dist/cjs/utils/dataFetcher.d.ts.map +1 -1
- package/dist/cjs/utils/dataFetcher.js +7 -3
- package/dist/cjs/utils/filterProcessing.d.ts +25 -0
- package/dist/cjs/utils/filterProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/filterProcessing.js +121 -1
- package/dist/cjs/utils/paginationProcessing.js +2 -2
- package/dist/cjs/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/pivotConstructor.js +10 -6
- package/dist/cjs/utils/queryConstructor.d.ts +1 -0
- package/dist/cjs/utils/queryConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/queryConstructor.js +37 -11
- package/dist/cjs/utils/report.d.ts +5 -0
- package/dist/cjs/utils/report.d.ts.map +1 -1
- package/dist/cjs/utils/report.js +63 -9
- package/dist/cjs/utils/schema.js +22 -20
- package/dist/cjs/utils/tableProcessing.d.ts +1 -0
- package/dist/cjs/utils/tableProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/tableProcessing.js +22 -1
- package/dist/cjs/utils/validation.d.ts.map +1 -1
- package/dist/cjs/utils/validation.js +4 -0
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +17 -8
- package/dist/esm/ChartBuilder.d.ts +10 -11
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +81 -84
- package/dist/esm/ChartEditor.d.ts +3 -1
- package/dist/esm/ChartEditor.d.ts.map +1 -1
- package/dist/esm/ChartEditor.js +27 -11
- package/dist/esm/Context.d.ts +2 -3
- package/dist/esm/Context.d.ts.map +1 -1
- package/dist/esm/Context.js +42 -28
- package/dist/esm/Dashboard.d.ts +12 -12
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/Dashboard.js +63 -71
- package/dist/esm/QuillProvider.d.ts +2 -0
- package/dist/esm/QuillProvider.d.ts.map +1 -1
- package/dist/esm/QuillProvider.js +2 -16
- package/dist/esm/ReportBuilder.d.ts +9 -9
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +122 -185
- package/dist/esm/SQLEditor.d.ts +20 -11
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +160 -93
- package/dist/esm/Table.js +4 -4
- package/dist/esm/components/Chart/BarChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/BarChart.js +7 -26
- package/dist/esm/components/Chart/BarList.js +1 -1
- package/dist/esm/components/Chart/ChartError.d.ts +5 -2
- package/dist/esm/components/Chart/ChartError.d.ts.map +1 -1
- package/dist/esm/components/Chart/ChartError.js +7 -10
- package/dist/esm/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/LineChart.js +16 -1
- package/dist/esm/components/Chart/PieChart.js +1 -1
- package/dist/esm/components/Dashboard/ChartComponent.d.ts +1 -1
- package/dist/esm/components/Dashboard/ChartComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/ChartComponent.js +46 -47
- package/dist/esm/components/Dashboard/DashboardFilter.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DashboardFilter.js +2 -1
- package/dist/esm/components/Dashboard/DataLoader.d.ts +2 -2
- package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.js +20 -14
- package/dist/esm/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/MetricComponent.js +16 -26
- package/dist/esm/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/TableComponent.js +16 -25
- package/dist/esm/components/QuillMultiSelectWithCombo.d.ts.map +1 -1
- package/dist/esm/components/QuillMultiSelectWithCombo.js +31 -1
- package/dist/esm/components/QuillSelect.js +1 -1
- package/dist/esm/components/QuillTable.d.ts +1 -1
- package/dist/esm/components/QuillTable.d.ts.map +1 -1
- package/dist/esm/components/QuillTable.js +115 -105
- package/dist/esm/components/ReportBuilder/AddColumnModal.d.ts +3 -3
- package/dist/esm/components/ReportBuilder/AddColumnModal.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddColumnModal.js +2 -2
- package/dist/esm/components/ReportBuilder/AddLimitPopover.d.ts +2 -2
- package/dist/esm/components/ReportBuilder/AddLimitPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddLimitPopover.js +28 -9
- package/dist/esm/components/ReportBuilder/FilterModal.d.ts +1 -1
- package/dist/esm/components/ReportBuilder/FilterModal.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/FilterModal.js +178 -114
- package/dist/esm/components/ReportBuilder/convert.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/convert.js +1 -2
- package/dist/esm/components/ReportBuilder/ui.d.ts +9 -1
- package/dist/esm/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/ui.js +38 -4
- package/dist/esm/components/ReportBuilder/util.d.ts +5 -1
- package/dist/esm/components/ReportBuilder/util.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/util.js +26 -12
- package/dist/esm/components/UiComponents.d.ts +17 -3
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +158 -28
- package/dist/esm/hooks/useAskQuill.d.ts.map +1 -1
- package/dist/esm/hooks/useAskQuill.js +8 -8
- package/dist/esm/hooks/useAstToFilterTree.d.ts +4 -1
- package/dist/esm/hooks/useAstToFilterTree.d.ts.map +1 -1
- package/dist/esm/hooks/useAstToFilterTree.js +4 -1
- package/dist/esm/hooks/useDashboard.d.ts +5 -1
- package/dist/esm/hooks/useDashboard.d.ts.map +1 -1
- package/dist/esm/hooks/useDashboard.js +28 -5
- package/dist/esm/hooks/useOnClickOutside.js +2 -2
- package/dist/esm/hooks/useQuill.js +5 -5
- package/dist/esm/hooks/useVirtualTables.d.ts +10 -0
- package/dist/esm/hooks/useVirtualTables.d.ts.map +1 -0
- package/dist/esm/hooks/useVirtualTables.js +25 -0
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.js +44 -23
- package/dist/esm/models/Client.d.ts +3 -0
- package/dist/esm/models/Client.d.ts.map +1 -1
- package/dist/esm/models/Report.d.ts +2 -0
- package/dist/esm/models/Report.d.ts.map +1 -1
- package/dist/esm/models/Schema.d.ts +7 -0
- package/dist/esm/models/Schema.d.ts.map +1 -0
- package/dist/esm/models/Schema.js +1 -0
- package/dist/esm/models/Tables.d.ts +2 -0
- package/dist/esm/models/Tables.d.ts.map +1 -1
- package/dist/esm/utils/astFilterProcessing.d.ts +4 -0
- package/dist/esm/utils/astFilterProcessing.d.ts.map +1 -1
- package/dist/esm/utils/astFilterProcessing.js +45 -43
- package/dist/esm/utils/astProcessing.d.ts.map +1 -1
- package/dist/esm/utils/astProcessing.js +8 -8
- package/dist/esm/utils/client.d.ts.map +1 -1
- package/dist/esm/utils/client.js +1 -0
- package/dist/esm/utils/columnProcessing.d.ts.map +1 -1
- package/dist/esm/utils/columnProcessing.js +88 -5
- package/dist/esm/utils/dataFetcher.d.ts.map +1 -1
- package/dist/esm/utils/dataFetcher.js +7 -3
- package/dist/esm/utils/filterProcessing.d.ts +25 -0
- package/dist/esm/utils/filterProcessing.d.ts.map +1 -1
- package/dist/esm/utils/filterProcessing.js +116 -0
- package/dist/esm/utils/paginationProcessing.js +2 -2
- package/dist/esm/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/esm/utils/pivotConstructor.js +10 -6
- package/dist/esm/utils/queryConstructor.d.ts +1 -0
- package/dist/esm/utils/queryConstructor.d.ts.map +1 -1
- package/dist/esm/utils/queryConstructor.js +35 -10
- package/dist/esm/utils/report.d.ts +5 -0
- package/dist/esm/utils/report.d.ts.map +1 -1
- package/dist/esm/utils/report.js +61 -8
- package/dist/esm/utils/schema.js +22 -20
- package/dist/esm/utils/tableProcessing.d.ts +1 -0
- package/dist/esm/utils/tableProcessing.d.ts.map +1 -1
- package/dist/esm/utils/tableProcessing.js +21 -1
- package/dist/esm/utils/validation.d.ts.map +1 -1
- package/dist/esm/utils/validation.js +4 -0
- package/package.json +3 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useContext, useEffect, useRef, useState, } from 'react';
|
|
2
|
+
import { useCallback, useContext, useEffect, useRef, useState, } from 'react';
|
|
3
3
|
import { DEFAULT_TAB_OPTIONS, MemoizedButton, MemoizedDeleteButton, MemoizedHeader, MemoizedLabel, MemoizedSecondaryButton, MemoizedText, MemoizedPopover, QuillTabs, MemoizedModal, QuillChartBuilderInputRowContainer, QuillChartBuilderInputColumnContainer, MemoizedSubHeader, QuillErrorMessageComponent, QuillPivotRowContainer, QuillPivotColumnContainer, QuillColumnSearchEmptyState, QuillChartBuilderFormContainer, QuillLoadingComponent, QuillTableSQLEditorComponent, } from './components/UiComponents';
|
|
4
4
|
import { DndContext, closestCenter, KeyboardSensor, PointerSensor, useSensor, useSensors, } from '@dnd-kit/core';
|
|
5
5
|
import { arrayMove, SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy, useSortable, } from '@dnd-kit/sortable';
|
|
6
6
|
import { CSS as DND_CSS } from '@dnd-kit/utilities';
|
|
7
|
-
import { ClientContext,
|
|
8
|
-
import { getTableNames, isNumericColumnType,
|
|
7
|
+
import { ClientContext, DashboardContext, SchemaDataContext, ThemeContext, } from './Context';
|
|
8
|
+
import { getTableNames, isNumericColumnType, } from './components/ReportBuilder/ast';
|
|
9
9
|
import { ChartBuilderWithModal } from './ChartBuilder';
|
|
10
10
|
import { QuillTextInput } from './components/UiComponents';
|
|
11
11
|
import { QuillSidebar, CustomContainer, QuillSelectColumn, QuillDraggableColumn, QuillSidebarHeading, QuillFilterPopover, QuillSortPopover, QuillLimitPopover, FilterPopoverWrapper, } from './components/ReportBuilder/ui';
|
|
@@ -22,18 +22,18 @@ import { QuillSelectComponent } from './components/QuillSelect';
|
|
|
22
22
|
import { QuillCard } from './components/QuillCard';
|
|
23
23
|
import { DATE_FORMAT_TYPES, quillFormat } from './utils/valueFormatter';
|
|
24
24
|
import { pivotToSql } from './utils/pivotProcessing';
|
|
25
|
-
import { getUniqueValuesByColumns, getDateRangeByColumns,
|
|
25
|
+
import { getUniqueValuesByColumns, getDateRangeByColumns, fetchTableByQuery, getUniqueStringValues, } from './utils/tableProcessing';
|
|
26
26
|
import { fetchAndProcessASTFromPrompt, fetchASTFromQuillReport, getAllPossibleColumns, } from './utils/astProcessing';
|
|
27
27
|
import PivotForm from './internals/ReportBuilder/PivotForm';
|
|
28
|
-
import { getSchemaInfoWithCustomFields } from './utils/schema';
|
|
29
28
|
import { getDateBucketFromRange } from './utils/dates';
|
|
30
29
|
import FilterModal from './components/ReportBuilder/FilterModal';
|
|
31
|
-
import { filterToAst, filterTreeToAst, } from './utils/astFilterProcessing';
|
|
30
|
+
import { astToFilterTree, filterToAst, filterTreeToAst, } from './utils/astFilterProcessing';
|
|
32
31
|
import useAstToFilterTree from './hooks/useAstToFilterTree';
|
|
33
|
-
import { filterSentence } from './utils/filterProcessing';
|
|
32
|
+
import { filterSentence, filterStackToFilterTree, uniqueValuesToStringMap, } from './utils/filterProcessing';
|
|
34
33
|
import { QuillMultiSelectComponentWithCombo } from './components/QuillMultiSelectWithCombo';
|
|
35
34
|
import { shouldFetchMore, DEFAULT_PAGINATION, shouldSortInMemory, } from './utils/paginationProcessing';
|
|
36
35
|
import { EMPTY_INTERNAL_REPORT, fetchReportBuilderDataFromAST, formatRowsFromReport, } from './utils/report';
|
|
36
|
+
import equal from 'fast-deep-equal';
|
|
37
37
|
export const QUILL_SERVER = (typeof process !== 'undefined' && process?.env?.QUILL_SERVER_HOST) ||
|
|
38
38
|
'https://quill-344421.uc.r.appspot.com';
|
|
39
39
|
/**
|
|
@@ -67,11 +67,11 @@ export const QUILL_SERVER = (typeof process !== 'undefined' && process?.env?.QUI
|
|
|
67
67
|
* ### Report Builder API
|
|
68
68
|
* @see https://docs.quillsql.com/components/report-builder
|
|
69
69
|
*/
|
|
70
|
-
export default function ReportBuilder({ initialTableName = '', onSubmitEditReport = () => void null, onSubmitCreateReport = () => void null, destinationDashboard = undefined, organizationName = '', ButtonComponent = MemoizedButton, SecondaryButtonComponent = MemoizedSecondaryButton, DeleteButtonComponent = MemoizedDeleteButton, ModalComponent = MemoizedModal, TextInputComponent = QuillTextInput, SelectComponent = QuillSelectComponent, MultiSelectComponent = QuillMultiSelectComponentWithCombo, TableComponent = QuillTableSQLEditorComponent, PopoverComponent = MemoizedPopover, TabsComponent = QuillTabs,
|
|
70
|
+
export default function ReportBuilder({ initialTableName = '', onSubmitEditReport = () => void null, onSubmitCreateReport = () => void null, onDiscardChanges = undefined, onSaveChanges = undefined, destinationDashboard = undefined, organizationName = '', ButtonComponent = MemoizedButton, SecondaryButtonComponent = MemoizedSecondaryButton, DeleteButtonComponent = MemoizedDeleteButton, ModalComponent = MemoizedModal, TextInputComponent = QuillTextInput, SelectComponent = QuillSelectComponent, MultiSelectComponent = QuillMultiSelectComponentWithCombo, TableComponent = QuillTableSQLEditorComponent, PopoverComponent = MemoizedPopover, TabsComponent = QuillTabs,
|
|
71
71
|
// CheckboxComponent = MemoizedCheckbox,
|
|
72
72
|
SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectColumnComponent = QuillSelectColumn, DraggableColumnComponent = QuillDraggableColumn, SidebarHeadingComponent = QuillSidebarHeading, FilterPopoverComponent = QuillFilterPopover, SortPopoverComponent = QuillSortPopover, LimitPopoverComponent = QuillLimitPopover, CardComponent = QuillCard, LabelComponent = MemoizedLabel, HeaderComponent = MemoizedHeader, SubHeaderComponent = MemoizedSubHeader, TextComponent = MemoizedText, ErrorMessageComponent = QuillErrorMessageComponent, ChartBuilderInputRowContainer = QuillChartBuilderInputRowContainer, ChartBuilderInputColumnContainer = QuillChartBuilderInputColumnContainer, PivotRowContainer = QuillPivotRowContainer, PivotColumnContainer = QuillPivotColumnContainer, LoadingComponent = QuillLoadingComponent, ColumnSearchEmptyState = QuillColumnSearchEmptyState, ChartBuilderFormContainer = QuillChartBuilderFormContainer, ChartBuilderModalComponent = MemoizedModal, isAdminEnabled = false, isAIEnabled = true, showChartBuilderTableFormatOptions = true, containerStyle, className, pivotRecommendationsEnabled = true, reportId, hideCopySQL = true, isChartBuilderHorizontalView = true, onClickChartElement, }) {
|
|
73
73
|
const [dashboard] = useContext(DashboardContext);
|
|
74
|
-
const [
|
|
74
|
+
const [schemaData] = useContext(SchemaDataContext);
|
|
75
75
|
const [reportInfo, setReportInfo] = useState(null);
|
|
76
76
|
const [aiPrompt, setAiPrompt] = useState('');
|
|
77
77
|
const [errorMessage, setErrorMessage] = useState('');
|
|
@@ -85,7 +85,6 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
85
85
|
const [activePath, setActivePath] = useState(null);
|
|
86
86
|
const [openPopover, setOpenPopover] = useState(null);
|
|
87
87
|
const [loading, setLoading] = useState(!!initialTableName);
|
|
88
|
-
const [loadingSchema, setLoadingSchema] = useState(false);
|
|
89
88
|
const [isChartBuilderOpen, setIsChartBuilderOpen] = useState(false);
|
|
90
89
|
const [, setIsPending] = useState(false);
|
|
91
90
|
const [isCopying, setIsCopying] = useState(false);
|
|
@@ -121,9 +120,10 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
121
120
|
const [client] = useContext(ClientContext);
|
|
122
121
|
// JANK: This is temp and stupid
|
|
123
122
|
const [overrideRecommendations, setOverrideRecommendations] = useState(true);
|
|
124
|
-
const [customFields, setCustomFields] = useContext(CustomFieldContext);
|
|
125
123
|
const [fieldValuesMap, setFieldValuesMap] = useState({}); // Mapping of unique values per field, used in string filter 'in' and 'not in'
|
|
126
|
-
const
|
|
124
|
+
const [globalUniqueValues, setGlobalUniqueValues] = useState({});
|
|
125
|
+
const { filterTree, filterStack } = useAstToFilterTree(formData, client); // Stores the state of filters
|
|
126
|
+
const [removingFilter, setRemovingFilter] = useState(false);
|
|
127
127
|
useEffect(() => {
|
|
128
128
|
if (!client) {
|
|
129
129
|
return;
|
|
@@ -131,8 +131,8 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
131
131
|
if (client.publicKey === '663416663aa9bc716e59a89d') {
|
|
132
132
|
setOverrideRecommendations(false);
|
|
133
133
|
}
|
|
134
|
-
if (!
|
|
135
|
-
|
|
134
|
+
if (!initialLoad && client.publicKey) {
|
|
135
|
+
clearAllState();
|
|
136
136
|
}
|
|
137
137
|
}, [client]);
|
|
138
138
|
useEffect(() => {
|
|
@@ -198,7 +198,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
198
198
|
label: pivot.columnField,
|
|
199
199
|
format: 'string',
|
|
200
200
|
},
|
|
201
|
-
], activeQuery, [], client, customFields);
|
|
201
|
+
], activeQuery, [], client, schemaData.customFields ?? []);
|
|
202
202
|
}
|
|
203
203
|
const pivotedData = await generatePivotTable(pivot, rows, undefined, false, -1, undefined, dateBucket, tempReport, client, distinctValuesForQuery);
|
|
204
204
|
setPivotData(pivotedData || []);
|
|
@@ -247,14 +247,19 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
247
247
|
setRecommendedPivots([]);
|
|
248
248
|
}, 0);
|
|
249
249
|
};
|
|
250
|
+
const fetchGlobalUniqueValues = async (columns, currentTable, client) => {
|
|
251
|
+
const global = await getUniqueStringValues(columns, currentTable, client);
|
|
252
|
+
setGlobalUniqueValues(uniqueValuesToStringMap(global));
|
|
253
|
+
};
|
|
254
|
+
const uniqueValuesDependenciesRef = useRef({ client, columns, currentTable });
|
|
255
|
+
const memoizedFetchGlobalUniqueValues = useCallback(fetchGlobalUniqueValues, []);
|
|
250
256
|
useEffect(() => {
|
|
251
|
-
|
|
252
|
-
|
|
257
|
+
const hasChanged = !equal({ client, columns, currentTable }, uniqueValuesDependenciesRef.current);
|
|
258
|
+
if (hasChanged && client && columns && currentTable) {
|
|
259
|
+
memoizedFetchGlobalUniqueValues(columns, currentTable, client);
|
|
260
|
+
uniqueValuesDependenciesRef.current = { client, columns, currentTable };
|
|
253
261
|
}
|
|
254
|
-
|
|
255
|
-
clearAllState();
|
|
256
|
-
}
|
|
257
|
-
}, [client]);
|
|
262
|
+
}, [client, columns, currentTable, memoizedFetchGlobalUniqueValues]);
|
|
258
263
|
const formatRows = (rows, columns, pivot, aggregationType) => {
|
|
259
264
|
const copiedRows = deepCopy(rows);
|
|
260
265
|
if (pivot) {
|
|
@@ -353,18 +358,6 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
353
358
|
console.error(error);
|
|
354
359
|
}
|
|
355
360
|
};
|
|
356
|
-
const getUniqueStringValues = async (columns, tableName) => {
|
|
357
|
-
const convertedStringColumns = columns.filter((column) => {
|
|
358
|
-
return isTextColumnType(column.fieldType);
|
|
359
|
-
});
|
|
360
|
-
const stringNames = convertedStringColumns.map((column) => column.field);
|
|
361
|
-
const smallStringColumns = await getCountsByColumns(convertedStringColumns, `Select ${stringNames.join(', ')} from ${tableName}`, client, customFields);
|
|
362
|
-
const smallStringNames = smallStringColumns.map((column) => column.field);
|
|
363
|
-
const newUniqueValues = await getUniqueValuesByColumns(smallStringColumns, `Select ${smallStringNames.join(', ')} from ${tableName}`, [], client, customFields);
|
|
364
|
-
const joinedUniqueValues = deepCopy(uniqueValues);
|
|
365
|
-
joinedUniqueValues[tableName] = newUniqueValues;
|
|
366
|
-
return joinedUniqueValues;
|
|
367
|
-
};
|
|
368
361
|
const getDateRanges = async (columns, tableName) => {
|
|
369
362
|
const dateColumns = columns.filter((column) => {
|
|
370
363
|
return column.fieldType === 'date';
|
|
@@ -375,7 +368,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
375
368
|
const dateColumnNames = dateColumns.map((column) => {
|
|
376
369
|
return column.field;
|
|
377
370
|
});
|
|
378
|
-
const dateRanges = await getDateRangeByColumns(dateColumns, `Select ${dateColumnNames.join(', ')} from ${tableName}`, client, customFields);
|
|
371
|
+
const dateRanges = await getDateRangeByColumns(dateColumns, `Select ${dateColumnNames.join(', ')} from ${tableName}`, client, schemaData.customFields ?? []);
|
|
379
372
|
return dateRanges;
|
|
380
373
|
};
|
|
381
374
|
// It's just like getColumnsInPivot but we expand the columnField
|
|
@@ -399,12 +392,12 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
399
392
|
return result.filter(Boolean);
|
|
400
393
|
};
|
|
401
394
|
const loadTable = async (tables) => {
|
|
402
|
-
if (!tables?.length || !schema?.length)
|
|
395
|
+
if (!tables?.length || !schemaData.schema?.length)
|
|
403
396
|
return;
|
|
404
397
|
setLoading(true);
|
|
405
398
|
const tableInfo = tables.find((tableInfo) => tableInfo.name === initialTableName);
|
|
406
399
|
if (tableInfo) {
|
|
407
|
-
const newUniqueValues = await getUniqueStringValues(tableInfo.columns, initialTableName);
|
|
400
|
+
const newUniqueValues = await getUniqueStringValues(tableInfo.columns, initialTableName, client, schemaData.customFields, uniqueValues);
|
|
408
401
|
if (hashCode(uniqueValues) !== hashCode(newUniqueValues)) {
|
|
409
402
|
setUniqueValues(newUniqueValues);
|
|
410
403
|
updateFieldValuesMap(newUniqueValues, initialTableName);
|
|
@@ -433,13 +426,9 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
433
426
|
await fetchAstFromPromptHelper(`get ${columnsForTable} from ${initialTableName}`);
|
|
434
427
|
setInitialLoad(false);
|
|
435
428
|
};
|
|
436
|
-
const
|
|
429
|
+
const onSchemaChange = async () => {
|
|
437
430
|
try {
|
|
438
|
-
|
|
439
|
-
const { schemaData, customFieldsByTable } = await getSchemaInfoWithCustomFields(client, 'rb');
|
|
440
|
-
setCustomFields(customFieldsByTable);
|
|
441
|
-
setSchema(schemaData ?? []);
|
|
442
|
-
setOrderedColumnNames((schemaData ?? []).flatMap((table) => table.columns
|
|
431
|
+
setOrderedColumnNames((schemaData.schema ?? []).flatMap((table) => table.columns
|
|
443
432
|
.map((c) => `${table.name}.${c.field}`)
|
|
444
433
|
.sort((a, b) => {
|
|
445
434
|
const aIsId = a.endsWith('.id') ||
|
|
@@ -457,11 +446,9 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
457
446
|
return 0;
|
|
458
447
|
})));
|
|
459
448
|
if (initialTableName) {
|
|
460
|
-
await loadTable(schemaData);
|
|
449
|
+
await loadTable(schemaData.schema);
|
|
461
450
|
}
|
|
462
|
-
setLoadingSchema(false);
|
|
463
451
|
setInitialLoad(false);
|
|
464
|
-
return schemaData;
|
|
465
452
|
}
|
|
466
453
|
catch (error) {
|
|
467
454
|
console.error(error);
|
|
@@ -478,11 +465,13 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
478
465
|
if (!report || report.referencedTables?.length !== 1) {
|
|
479
466
|
throw new Error('Report not found');
|
|
480
467
|
}
|
|
481
|
-
const { ast: newAst, pivot: newPivot, schema: curSchema, } = await fetchASTFromQuillReport(report, client, schema);
|
|
468
|
+
const { ast: newAst, pivot: newPivot, schema: curSchema, } = await fetchASTFromQuillReport(report, client, schemaData.schema);
|
|
482
469
|
setBaseAst({ ...newAst, where: null });
|
|
483
470
|
await fetchReportFromASTHelper({ ...newAst, where: null }, newAst.where, newPivot, curSchema, report);
|
|
484
|
-
await
|
|
471
|
+
await onSchemaChange();
|
|
485
472
|
setReportInfo(report);
|
|
473
|
+
const query = await fetchSqlQuery(newAst, null, false);
|
|
474
|
+
setActiveQuery(query);
|
|
486
475
|
}
|
|
487
476
|
catch (err) {
|
|
488
477
|
setInitialChartLoad(false);
|
|
@@ -491,10 +480,8 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
491
480
|
loadChart();
|
|
492
481
|
}, [dashboard[reportId || '']]);
|
|
493
482
|
useEffect(() => {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
}
|
|
497
|
-
}, [schema, initialTableName, reportId]);
|
|
483
|
+
onSchemaChange();
|
|
484
|
+
}, [schemaData.schema, initialTableName, reportId]);
|
|
498
485
|
const updateFormData = (updates, { isDeletion = false, isInsertion = false, isReplaceSubtree = false, isAddVariant = false, isDeleteVariant = false, topLevelBinOp = 'OR', isCondition = undefined, }) => {
|
|
499
486
|
// Function to immutably update or delete nodes based on their path
|
|
500
487
|
// TODO: fix the following horible code
|
|
@@ -512,7 +499,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
512
499
|
...defaultAST,
|
|
513
500
|
...baseAst,
|
|
514
501
|
...(!baseAst?.columns && {
|
|
515
|
-
columns: getAllPossibleColumns(baseAst, schema).map((c) => {
|
|
502
|
+
columns: getAllPossibleColumns(baseAst, schemaData.schema).map((c) => {
|
|
516
503
|
const newColumn = deepCopy(defaultColumn);
|
|
517
504
|
newColumn.expr.column = c.field;
|
|
518
505
|
return newColumn;
|
|
@@ -532,7 +519,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
532
519
|
...defaultAST,
|
|
533
520
|
...baseAst,
|
|
534
521
|
...(!baseAst?.columns && {
|
|
535
|
-
columns: getAllPossibleColumns(baseAst, schema).map((c) => {
|
|
522
|
+
columns: getAllPossibleColumns(baseAst, schemaData.schema).map((c) => {
|
|
536
523
|
const newColumn = deepCopy(defaultColumn);
|
|
537
524
|
newColumn.expr.column = c.field;
|
|
538
525
|
return newColumn;
|
|
@@ -633,7 +620,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
633
620
|
...defaultAST,
|
|
634
621
|
...baseAst,
|
|
635
622
|
...(!baseAst?.columns && {
|
|
636
|
-
columns: getAllPossibleColumns(baseAst, schema).map((c) => {
|
|
623
|
+
columns: getAllPossibleColumns(baseAst, schemaData.schema).map((c) => {
|
|
637
624
|
const newColumn = deepCopy(defaultColumn);
|
|
638
625
|
newColumn.expr.column = c.field;
|
|
639
626
|
return newColumn;
|
|
@@ -724,7 +711,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
724
711
|
try {
|
|
725
712
|
setErrorMessage('');
|
|
726
713
|
setTableLoading(true);
|
|
727
|
-
const tableInfo = await fetchTableByQuery(activeQuery, client, processing, customFields);
|
|
714
|
+
const tableInfo = await fetchTableByQuery(activeQuery, client, processing, schemaData.customFields);
|
|
728
715
|
if (tableInfo.error) {
|
|
729
716
|
throw new Error(tableInfo.error);
|
|
730
717
|
}
|
|
@@ -752,75 +739,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
752
739
|
return;
|
|
753
740
|
}
|
|
754
741
|
};
|
|
755
|
-
|
|
756
|
-
* @param filterTree
|
|
757
|
-
* Returns a list of filters to be displayed
|
|
758
|
-
* Replaces the functionality of renderNodes in the context of filters
|
|
759
|
-
*/
|
|
760
|
-
const renderFilters = (filterTree) => {
|
|
761
|
-
let tree = filterTree;
|
|
762
|
-
let filterStack = [];
|
|
763
|
-
/**
|
|
764
|
-
* Function that takes in a FilterTree and flattens it into an array using in order traversal
|
|
765
|
-
*/
|
|
766
|
-
function traverseTree(node) {
|
|
767
|
-
if (!node) {
|
|
768
|
-
return;
|
|
769
|
-
}
|
|
770
|
-
if (node.leaf) {
|
|
771
|
-
filterStack.push(node);
|
|
772
|
-
}
|
|
773
|
-
else {
|
|
774
|
-
traverseTree(node.leftNode);
|
|
775
|
-
filterStack.push(node);
|
|
776
|
-
traverseTree(node.rightNode);
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
/**
|
|
780
|
-
* Given an array of Filters (presumed to be in in-order state), generate
|
|
781
|
-
* the corresponding Filter tree. Essentially the reverse of what traverseTree does
|
|
782
|
-
*/
|
|
783
|
-
function filterStackToFilterTree(stack) {
|
|
784
|
-
function buildTree(i) {
|
|
785
|
-
const newNode = {
|
|
786
|
-
leaf: false,
|
|
787
|
-
operator: null,
|
|
788
|
-
leftNode: null,
|
|
789
|
-
rightNode: null,
|
|
790
|
-
};
|
|
791
|
-
if (i >= stack.length) {
|
|
792
|
-
return null;
|
|
793
|
-
}
|
|
794
|
-
else if (stack[i].leaf) {
|
|
795
|
-
if (i < stack.length - 1) {
|
|
796
|
-
// more nodes later
|
|
797
|
-
newNode.operator = stack[i + 1].operator;
|
|
798
|
-
newNode.leftNode = {
|
|
799
|
-
leaf: true,
|
|
800
|
-
leftNode: null,
|
|
801
|
-
rightNode: null,
|
|
802
|
-
operator: null,
|
|
803
|
-
value: stack[i].value,
|
|
804
|
-
};
|
|
805
|
-
newNode.rightNode = buildTree(i + 2);
|
|
806
|
-
}
|
|
807
|
-
else {
|
|
808
|
-
newNode.leaf = true;
|
|
809
|
-
newNode.value = stack[i].value;
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
return newNode;
|
|
813
|
-
}
|
|
814
|
-
return buildTree(0);
|
|
815
|
-
}
|
|
816
|
-
traverseTree(tree);
|
|
817
|
-
// Remove null (invalid) filters from filter stack
|
|
818
|
-
filterStack = filterStack.filter((filter) => {
|
|
819
|
-
return ((!filter.leaf &&
|
|
820
|
-
filter.rightNode &&
|
|
821
|
-
(!filter.rightNode.leaf || filter.rightNode.value)) ||
|
|
822
|
-
(filter.leaf && filter.value));
|
|
823
|
-
});
|
|
742
|
+
const renderFilters = () => {
|
|
824
743
|
// Render filterStack
|
|
825
744
|
return (_jsx("div", { style: {
|
|
826
745
|
display: 'flex',
|
|
@@ -840,14 +759,14 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
840
759
|
item.operator = 'and';
|
|
841
760
|
}
|
|
842
761
|
let newFormData = null;
|
|
843
|
-
if (
|
|
844
|
-
newFormData = filterTreeToAst(
|
|
762
|
+
if (filterTree) {
|
|
763
|
+
newFormData = filterTreeToAst(filterTree, client.databaseType.toLowerCase());
|
|
845
764
|
}
|
|
846
765
|
const newAst = deepCopy({
|
|
847
766
|
...defaultAST,
|
|
848
767
|
...baseAst,
|
|
849
768
|
...(!baseAst?.columns && {
|
|
850
|
-
columns: getAllPossibleColumns(baseAst, schema).map((c) => {
|
|
769
|
+
columns: getAllPossibleColumns(baseAst, schemaData.schema).map((c) => {
|
|
851
770
|
const newColumn = deepCopy(defaultColumn);
|
|
852
771
|
newColumn.expr.column = c.field;
|
|
853
772
|
return newColumn;
|
|
@@ -863,18 +782,18 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
863
782
|
fetchSqlQuery(newAst, newFormData);
|
|
864
783
|
} }) }, index));
|
|
865
784
|
}
|
|
866
|
-
else {
|
|
867
|
-
return (_jsx(FilterPopoverWrapper, { schema: schema.find((s) => s.name === currentTable || s.displayName === currentTable) ?? schema[0], filter: item.value, filterLabel: item.value ? filterSentence(item.value) : '', index: index, FilterTagComponent: FilterPopoverComponent, FilterModal: FilterModal, fieldValuesMap:
|
|
785
|
+
else if (item.value) {
|
|
786
|
+
return (_jsx(FilterPopoverWrapper, { schema: schemaData.schema.find((s) => s.name === currentTable || s.displayName === currentTable) ?? schemaData.schema[0], filter: item.value, filterLabel: item.value ? filterSentence(item.value) : '', index: index, FilterTagComponent: FilterPopoverComponent, FilterModal: FilterModal, fieldValuesMap: globalUniqueValues, priorFilters: filterStack.slice(0, index > 0 ? index - 1 : 0), columns: columns, client: client, customFields: schemaData.customFields, baseAst: baseAst, endpoint: QUILL_SERVER, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, MultiSelectComponent: MultiSelectComponent, handleFilterSave: (filter) => {
|
|
868
787
|
item.value = filter;
|
|
869
788
|
let newFormData = null;
|
|
870
|
-
if (
|
|
871
|
-
newFormData = filterTreeToAst(
|
|
789
|
+
if (filterTree) {
|
|
790
|
+
newFormData = filterTreeToAst(filterTree, client.databaseType.toLowerCase());
|
|
872
791
|
}
|
|
873
792
|
const newAst = deepCopy({
|
|
874
793
|
...defaultAST,
|
|
875
794
|
...baseAst,
|
|
876
795
|
...(!baseAst?.columns && {
|
|
877
|
-
columns: getAllPossibleColumns(baseAst, schema).map((c) => {
|
|
796
|
+
columns: getAllPossibleColumns(baseAst, schemaData.schema).map((c) => {
|
|
878
797
|
const newColumn = deepCopy(defaultColumn);
|
|
879
798
|
newColumn.expr.column = c.field;
|
|
880
799
|
return newColumn;
|
|
@@ -889,41 +808,46 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
889
808
|
setFormData(newFormData);
|
|
890
809
|
fetchSqlQuery(newAst, newFormData);
|
|
891
810
|
}, handleFilterDelete: (i) => {
|
|
892
|
-
if (
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
filterStack.splice(i, 2);
|
|
811
|
+
if (!removingFilter) {
|
|
812
|
+
setRemovingFilter(true);
|
|
813
|
+
const newStack = filterStack;
|
|
814
|
+
if (i > 0) {
|
|
815
|
+
newStack.splice(i - 1, 2);
|
|
898
816
|
}
|
|
899
817
|
else {
|
|
900
|
-
filterStack.
|
|
818
|
+
if (filterStack.length > 1) {
|
|
819
|
+
newStack.splice(i, 2);
|
|
820
|
+
}
|
|
821
|
+
else {
|
|
822
|
+
newStack.splice(i, 1);
|
|
823
|
+
}
|
|
901
824
|
}
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
825
|
+
const tree = filterStackToFilterTree(newStack);
|
|
826
|
+
let newFormData = null;
|
|
827
|
+
if (tree) {
|
|
828
|
+
newFormData = filterTreeToAst(tree, client.databaseType.toLowerCase());
|
|
829
|
+
}
|
|
830
|
+
const newAst = deepCopy({
|
|
831
|
+
...defaultAST,
|
|
832
|
+
...baseAst,
|
|
833
|
+
...(!baseAst?.columns && {
|
|
834
|
+
columns: getAllPossibleColumns(baseAst, schemaData.schema).map((c) => {
|
|
835
|
+
const newColumn = deepCopy(defaultColumn);
|
|
836
|
+
newColumn.expr.column = c.field;
|
|
837
|
+
return newColumn;
|
|
838
|
+
}),
|
|
916
839
|
}),
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
840
|
+
...(!baseAst?.from && {
|
|
841
|
+
from: [{ ...defaultTable, table: initialTableName }],
|
|
842
|
+
}),
|
|
843
|
+
where: newFormData,
|
|
844
|
+
});
|
|
845
|
+
setBaseAst(newAst);
|
|
846
|
+
setFormData(newFormData);
|
|
847
|
+
fetchSqlQuery(newAst, newFormData);
|
|
848
|
+
setRemovingFilter(false);
|
|
849
|
+
}
|
|
850
|
+
} }, `filter_${index}_${item.value ? filterSentence(item.value) : ''}`));
|
|
927
851
|
}
|
|
928
852
|
}) }));
|
|
929
853
|
};
|
|
@@ -955,7 +879,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
955
879
|
let reportBuilderInfo = undefined;
|
|
956
880
|
try {
|
|
957
881
|
setLoading(true);
|
|
958
|
-
reportBuilderInfo = await fetchReportBuilderDataFromAST(baseAst, curFormData, curSchema ?? schema, client, curPivot ?? pivot, formData, currentTable, { uniqueStrings: uniqueValues, dateRanges: dateRanges ?? {} }, previousReport ?? reportInfo ?? undefined, customFields);
|
|
882
|
+
reportBuilderInfo = await fetchReportBuilderDataFromAST(baseAst, curFormData, curSchema ?? schemaData.schema, client, curPivot ?? pivot, formData, currentTable, { uniqueStrings: uniqueValues, dateRanges: dateRanges ?? {} }, previousReport ?? reportInfo ?? undefined, schemaData.customFields);
|
|
959
883
|
if (reportBuilderInfo.error) {
|
|
960
884
|
throw new Error(reportBuilderInfo.error);
|
|
961
885
|
}
|
|
@@ -1010,7 +934,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1010
934
|
}
|
|
1011
935
|
try {
|
|
1012
936
|
setLoading(true);
|
|
1013
|
-
astInfo = await fetchAndProcessASTFromPrompt(prompt, schema, client, pivot, activeQuery);
|
|
937
|
+
astInfo = await fetchAndProcessASTFromPrompt(prompt, schemaData.schema, client, pivot, activeQuery);
|
|
1014
938
|
if (astInfo.error) {
|
|
1015
939
|
throw new Error(astInfo.error);
|
|
1016
940
|
}
|
|
@@ -1022,10 +946,16 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1022
946
|
}
|
|
1023
947
|
return;
|
|
1024
948
|
}
|
|
949
|
+
// parse the whereAst first
|
|
950
|
+
const filterTree = astToFilterTree(astInfo.whereAST, client.databaseType?.toLowerCase());
|
|
951
|
+
const cleanAst = filterTree
|
|
952
|
+
? filterTreeToAst(filterTree, client.databaseType?.toLowerCase())
|
|
953
|
+
: null;
|
|
954
|
+
setFormData(cleanAst);
|
|
955
|
+
astInfo.ast.where = cleanAst;
|
|
1025
956
|
setBaseAst(astInfo.ast);
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
await fetchReportFromASTHelper(astInfo.ast, astInfo.whereAST, astInfo.pivot);
|
|
957
|
+
fetchSqlQuery(astInfo.ast, cleanAst, false);
|
|
958
|
+
await fetchReportFromASTHelper(astInfo.ast, cleanAst, astInfo.pivot);
|
|
1029
959
|
};
|
|
1030
960
|
const handleDeleteColumn = (name) => {
|
|
1031
961
|
if (!baseAst || !baseAst.columns.length || selectedColumns.length === 1) {
|
|
@@ -1136,6 +1066,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1136
1066
|
gap: 8,
|
|
1137
1067
|
}, children: [columnNamesInAst.map((name) => (_jsx(DraggableItem, { id: name, label: name, onDelete: () => handleDeleteColumn(name) }, name))), columnNamesInAst?.length > 0 && _jsx("div", { style: { height: 6 } })] }) }) }));
|
|
1138
1068
|
}
|
|
1069
|
+
// TODO: Refactor this part
|
|
1139
1070
|
if (loading || initialChartLoad) {
|
|
1140
1071
|
return (_jsxs("div", { style: {
|
|
1141
1072
|
display: 'flex',
|
|
@@ -1163,12 +1094,12 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1163
1094
|
}, orderedColumnNames: orderedColumnNames, setOrderedColumnNames: setOrderedColumnNames, selectedColumns: selectedColumns, setSelectedColumns: setSelectedColumns, isSelectedAllColumns: isSelectedAllColumns, clearAllState: clearAllState, nameToColumn: nameToColumn, baseAst: baseAst, setBaseAst: (ast) => {
|
|
1164
1095
|
setBaseAst(ast);
|
|
1165
1096
|
fetchSqlQuery(ast);
|
|
1166
|
-
}, pivot: pivot, initialTableName: initialTableName, defaultAST: defaultAST, defaultTable: defaultTable, setPivot: setPivot,
|
|
1097
|
+
}, pivot: pivot, initialTableName: initialTableName, defaultAST: defaultAST, defaultTable: defaultTable, setPivot: setPivot, TextInputComponent: TextInputComponent, SelectColumn: SelectColumnComponent, SecondaryButton: SecondaryButtonComponent, Button: ButtonComponent, ColumnSearchEmptyState: ColumnSearchEmptyState, LoadingComponent: LoadingComponent }) })] }), _jsxs("div", { style: { width: '100%' }, children: [_jsx(SidebarHeadingComponent, { label: "Filters" }), formData && (_jsx("div", { style: {
|
|
1167
1098
|
display: 'flex',
|
|
1168
1099
|
flexDirection: 'column',
|
|
1169
1100
|
gap: 8,
|
|
1170
1101
|
marginBottom: 12,
|
|
1171
|
-
}, children:
|
|
1102
|
+
}, children: renderFilters() })), _jsxs("div", { style: {
|
|
1172
1103
|
display: 'flex',
|
|
1173
1104
|
flexDirection: 'column',
|
|
1174
1105
|
alignItems: 'flex-start',
|
|
@@ -1209,8 +1140,8 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1209
1140
|
setActiveEditItem(null);
|
|
1210
1141
|
}, 300);
|
|
1211
1142
|
}
|
|
1212
|
-
}, popoverTitle: 'Add filter', popoverChildren: _jsx(FilterModal, { schema: schema.find((s) => s.name === currentTable ||
|
|
1213
|
-
s.displayName === currentTable) ?? schema[0], fieldValuesMap: uniqueValues[getTableNames(baseAst).length === 1
|
|
1143
|
+
}, popoverTitle: 'Add filter', popoverChildren: _jsx(FilterModal, { schema: schemaData.schema.find((s) => s.name === currentTable ||
|
|
1144
|
+
s.displayName === currentTable) ?? schemaData.schema[0], fieldValuesMap: uniqueValues[getTableNames(baseAst).length === 1
|
|
1214
1145
|
? getTableNames(baseAst)[0]
|
|
1215
1146
|
: initialTableName], onSubmitFilter: (filter) => {
|
|
1216
1147
|
setOpenPopover(null);
|
|
@@ -1353,7 +1284,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1353
1284
|
setActivePath(null);
|
|
1354
1285
|
setOpenPopover(null);
|
|
1355
1286
|
}
|
|
1356
|
-
}, popoverTitle: "Add limit", popoverChildren: _jsx(AddLimitPopover, {
|
|
1287
|
+
}, popoverTitle: "Add limit", popoverChildren: _jsx(AddLimitPopover, { TextInputComponent: TextInputComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent, onSave: () => { } }) })] }))] })] }), _jsxs(ContainerComponent, { children: [isAIEnabled && (_jsx("form", { ref: askAILoadingContainerRef, onSubmit: (event) => {
|
|
1357
1288
|
event.preventDefault();
|
|
1358
1289
|
}, style: {
|
|
1359
1290
|
display: 'flex',
|
|
@@ -1368,11 +1299,13 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1368
1299
|
? askAIInputWidth
|
|
1369
1300
|
: askAILoadingContainerWidth, value: aiPrompt, onChange: () => { } }), _jsx(ButtonComponent, { onClick: () => { }, label: "Ask AI" }), ((baseAst && dataDisplayed) ||
|
|
1370
1301
|
initialLoad ||
|
|
1371
|
-
initialChartLoad) &&
|
|
1302
|
+
initialChartLoad) &&
|
|
1303
|
+
!reportId && (_jsx(SecondaryButtonComponent, { onClick: () => { }, label: "New report" }))] }) })), _jsxs(_Fragment, { children: [_jsx(TableComponent, { isLoading: true, rows: [], columns: [] }), baseAst && dataDisplayed && !initialChartLoad && (_jsxs("div", { style: {
|
|
1372
1304
|
display: 'flex',
|
|
1373
1305
|
flexDirection: 'row',
|
|
1374
1306
|
gap: '12px',
|
|
1375
|
-
|
|
1307
|
+
marginTop: 'auto',
|
|
1308
|
+
}, children: [_jsx("div", { style: { width: '100%' } }), onDiscardChanges && (_jsx(SecondaryButtonComponent, { onClick: onDiscardChanges, label: "Discard changes" })), !hideCopySQL && (_jsx(SecondaryButtonComponent, { onClick: () => copySQLToClipboard(), label: isCopying ? 'Copied' : 'Copy SQL' })), _jsx(ButtonComponent, { label: reportInfo ? 'Save changes' : 'Add to dashboard', onClick: () => { } })] }))] })] }), _jsx("style", { children: `body{margin:0;}` })] }));
|
|
1376
1309
|
}
|
|
1377
1310
|
return (_jsxs("div", { style: { backgroundColor: theme?.backgroundColor, ...containerStyle }, className: className, children: [(!isChartBuilderHorizontalView ||
|
|
1378
1311
|
(isChartBuilderHorizontalView && !isChartBuilderOpen)) && (_jsxs("div", { ref: parentRef, style: {
|
|
@@ -1406,12 +1339,12 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1406
1339
|
}, orderedColumnNames: orderedColumnNames, setOrderedColumnNames: setOrderedColumnNames, selectedColumns: selectedColumns, setSelectedColumns: setSelectedColumns, isSelectedAllColumns: isSelectedAllColumns, clearAllState: clearAllState, nameToColumn: nameToColumn, baseAst: baseAst, setBaseAst: (ast) => {
|
|
1407
1340
|
setBaseAst(ast);
|
|
1408
1341
|
fetchSqlQuery(ast);
|
|
1409
|
-
}, pivot: pivot, initialTableName: initialTableName, defaultAST: defaultAST, defaultTable: defaultTable, schemaLoading:
|
|
1342
|
+
}, pivot: pivot, initialTableName: initialTableName, defaultAST: defaultAST, defaultTable: defaultTable, schemaLoading: schemaData.isSchemaLoading, setPivot: setPivot, TextInputComponent: TextInputComponent, SelectColumn: SelectColumnComponent, SecondaryButton: SecondaryButtonComponent, Button: ButtonComponent, ColumnSearchEmptyState: ColumnSearchEmptyState, LoadingComponent: LoadingComponent }) })] }), _jsxs("div", { style: { width: '100%' }, children: [_jsx(SidebarHeadingComponent, { label: "Filters" }), formData && (_jsx("div", { style: {
|
|
1410
1343
|
display: 'flex',
|
|
1411
1344
|
flexDirection: 'column',
|
|
1412
1345
|
gap: 8,
|
|
1413
1346
|
marginBottom: 12,
|
|
1414
|
-
}, children:
|
|
1347
|
+
}, children: renderFilters() })), _jsxs("div", { style: {
|
|
1415
1348
|
display: 'flex',
|
|
1416
1349
|
flexDirection: 'column',
|
|
1417
1350
|
alignItems: 'flex-start',
|
|
@@ -1453,8 +1386,8 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1453
1386
|
setActiveEditItem(null);
|
|
1454
1387
|
}, 300);
|
|
1455
1388
|
}
|
|
1456
|
-
}, popoverTitle: "Add filter", popoverChildren: _jsx(FilterModal, { schema: schema.find((s) => s.name === currentTable ||
|
|
1457
|
-
s.displayName === currentTable) ?? schema[0], fieldValuesMap: fieldValuesMap, onSubmitFilter: (filter) => {
|
|
1389
|
+
}, popoverTitle: "Add filter", popoverChildren: _jsx(FilterModal, { schema: schemaData.schema.find((s) => s.name === currentTable ||
|
|
1390
|
+
s.displayName === currentTable) ?? schemaData.schema[0], fieldValuesMap: fieldValuesMap, onSubmitFilter: (filter) => {
|
|
1458
1391
|
setOpenPopover(null);
|
|
1459
1392
|
setIsPending(false);
|
|
1460
1393
|
const item = filterToAst(filter, client.databaseType.toLowerCase());
|
|
@@ -1727,7 +1660,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1727
1660
|
setActivePath(null);
|
|
1728
1661
|
setOpenPopover(null);
|
|
1729
1662
|
}
|
|
1730
|
-
}, popoverTitle: "Add limit", popoverChildren: _jsx(AddLimitPopover, {
|
|
1663
|
+
}, popoverTitle: "Add limit", popoverChildren: _jsx(AddLimitPopover, { TextInputComponent: TextInputComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent, onSave: (limit) => {
|
|
1731
1664
|
const newAst = { ...baseAst };
|
|
1732
1665
|
newAst.limit = {
|
|
1733
1666
|
seperator: '',
|
|
@@ -1756,20 +1689,23 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1756
1689
|
? 'Ask a follow-up question...'
|
|
1757
1690
|
: 'Ask a question...' }), _jsx(ButtonComponent, { onClick: () => {
|
|
1758
1691
|
fetchAstFromPromptHelper();
|
|
1759
|
-
}, label: 'Ask AI' }), ((baseAst && dataDisplayed) || initialLoad) && (_jsx(SecondaryButtonComponent, { label: 'New report', onClick: clearAllState }))] }) })), baseAst && (_jsx(TableComponent, { isLoading: tableLoading ||
|
|
1692
|
+
}, label: 'Ask AI' }), ((baseAst && dataDisplayed) || initialLoad) && !reportId && (_jsx(SecondaryButtonComponent, { label: 'New report', onClick: clearAllState }))] }) })), baseAst && (_jsx(TableComponent, { isLoading: tableLoading ||
|
|
1760
1693
|
(loading && errorMessage.length === 0) ||
|
|
1761
|
-
initialChartLoad, rows: formattedRows, rowCount: pivot ? undefined : numberOfRows, columns: pivot
|
|
1694
|
+
initialChartLoad, rows: formattedRows, rowCount: pivot ? undefined : numberOfRows, rowsPerPage: 20, columns: pivot
|
|
1762
1695
|
? pivotData?.columns || emptyPivotColumns()
|
|
1763
1696
|
: enforceOrderOnColumns(Object.keys(rows[0] ?? {})).map((c) => {
|
|
1764
1697
|
return {
|
|
1765
1698
|
label: snakeAndCamelCaseToTitleCase(c),
|
|
1766
1699
|
field: c,
|
|
1767
1700
|
};
|
|
1768
|
-
}), onPageChange: onPageChange, onSortChange: onSortChange
|
|
1701
|
+
}), onPageChange: onPageChange, onSortChange: onSortChange, containerStyle: {
|
|
1702
|
+
maxHeight: Math.max(window.innerHeight - 290, 75 + Math.min(Math.max(10, rows.length), 20) * 37),
|
|
1703
|
+
} })), _jsxs("div", { style: {
|
|
1769
1704
|
display: 'flex',
|
|
1770
1705
|
flexDirection: 'row',
|
|
1771
1706
|
gap: '12px',
|
|
1772
1707
|
width: '100%',
|
|
1708
|
+
marginTop: 'auto',
|
|
1773
1709
|
}, children: [errorMessage ? (_jsxs("div", { style: {
|
|
1774
1710
|
display: 'flex',
|
|
1775
1711
|
flexDirection: 'row',
|
|
@@ -1779,7 +1715,8 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1779
1715
|
alignItems: 'center',
|
|
1780
1716
|
}, children: [_jsx(ErrorMessageComponent, { errorMessage: errorMessage }), _jsx(SecondaryButtonComponent, { onClick: () => {
|
|
1781
1717
|
fetchAstFromPromptHelper();
|
|
1782
|
-
}, label: 'Retry' })] })) : (_jsx("div", { style: { width: '100%' } })), baseAst && dataDisplayed && !initialChartLoad && (_jsxs(_Fragment, { children: [!hideCopySQL && (_jsx(SecondaryButtonComponent, { label: isCopying ? '
|
|
1718
|
+
}, label: 'Retry' })] })) : (_jsx("div", { style: { width: '100%' } })), baseAst && dataDisplayed && !initialChartLoad && (_jsxs(_Fragment, { children: [onDiscardChanges && (_jsx(SecondaryButtonComponent, { onClick: onDiscardChanges, label: "Discard changes" })), !hideCopySQL && (_jsx(SecondaryButtonComponent, { label: isCopying ? 'Copied' : 'Copy SQL', onClick: () => copySQLToClipboard() })), _jsx(ButtonComponent, { onClick: () => {
|
|
1719
|
+
onSaveChanges && onSaveChanges();
|
|
1783
1720
|
setIsChartBuilderOpen(true);
|
|
1784
1721
|
}, disabled: !!errorMessage, label: reportId ? 'Save changes' : 'Add to dashboard' })] }))] })] }), _jsx("style", { children: `body{margin:0;}` })] })), (!isChartBuilderHorizontalView || isChartBuilderOpen) && (_jsx(ChartBuilderWithModal, { report: reportInfo
|
|
1785
1722
|
? {
|
|
@@ -1795,5 +1732,5 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1795
1732
|
queryString: activeQuery,
|
|
1796
1733
|
rows: rows,
|
|
1797
1734
|
}
|
|
1798
|
-
: tempReport, rows: rows, columns: columns, pivot: pivot, query: activeQuery, showTableFormatOptions: showChartBuilderTableFormatOptions, showDateFieldOptions: isAdminEnabled, showAccessControlOptions: isAdminEnabled, title: reportId ? 'Save changes' : 'Add to dashboard', isHorizontalView: true, isOpen: isChartBuilderOpen, setIsOpen: setIsChartBuilderOpen, onAddToDashboardComplete: reportId ? onSubmitEditReport : onSubmitCreateReport, destinationDashboard: destinationDashboard, organizationName: organizationName, pivotData: pivotData, initialUniqueValues: uniqueValues[currentTable], pivotRecommendationsEnabled: pivotRecommendationsEnabled && overrideRecommendations, SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, HeaderComponent: HeaderComponent, SubHeaderComponent: SubHeaderComponent, LabelComponent: LabelComponent, TextComponent: TextComponent, CardComponent: CardComponent, ModalComponent: ChartBuilderModalComponent, PopoverComponent: PopoverComponent, TableComponent: TableComponent, DeleteButtonComponent: DeleteButtonComponent, LoadingComponent: LoadingComponent, ChartBuilderInputRowContainer: ChartBuilderInputRowContainer, ChartBuilderInputColumnContainer: ChartBuilderInputColumnContainer, FormContainer: ChartBuilderFormContainer, hideDateRangeFilter: true, buttonLabel: !!reportId ? 'Save changes' : 'Add to dashboard', onClickChartElement: onClickChartElement, rowCount: numberOfRows, onPageChange: onPageChange, onSortChange: onSortChange, isLoading: tableLoading }))] }));
|
|
1735
|
+
: tempReport, rows: rows, columns: columns, pivot: pivot, query: activeQuery, showTableFormatOptions: showChartBuilderTableFormatOptions, showDateFieldOptions: isAdminEnabled, showAccessControlOptions: isAdminEnabled, isAdmin: isAdminEnabled, title: reportId ? 'Save changes' : 'Add to dashboard', isHorizontalView: true, isOpen: isChartBuilderOpen, setIsOpen: setIsChartBuilderOpen, onAddToDashboardComplete: reportId ? onSubmitEditReport : onSubmitCreateReport, destinationDashboard: destinationDashboard, organizationName: organizationName, pivotData: pivotData, initialUniqueValues: uniqueValues[currentTable], pivotRecommendationsEnabled: pivotRecommendationsEnabled && overrideRecommendations, SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, HeaderComponent: HeaderComponent, SubHeaderComponent: SubHeaderComponent, LabelComponent: LabelComponent, TextComponent: TextComponent, CardComponent: CardComponent, ModalComponent: ChartBuilderModalComponent, PopoverComponent: PopoverComponent, TableComponent: TableComponent, DeleteButtonComponent: DeleteButtonComponent, LoadingComponent: LoadingComponent, ChartBuilderInputRowContainer: ChartBuilderInputRowContainer, ChartBuilderInputColumnContainer: ChartBuilderInputColumnContainer, FormContainer: ChartBuilderFormContainer, hideDateRangeFilter: true, buttonLabel: !!reportId ? 'Save changes' : 'Add to dashboard', onClickChartElement: onClickChartElement, rowCount: numberOfRows, onPageChange: onPageChange, onSortChange: onSortChange, isLoading: tableLoading, isEditingMode: true }))] }));
|
|
1799
1736
|
}
|