@quillsql/react 2.12.51 → 2.12.53
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.js +1 -1
- package/dist/cjs/ChartBuilder.d.ts +7 -3
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +55 -19
- package/dist/cjs/ChartEditor.d.ts +3 -1
- package/dist/cjs/ChartEditor.d.ts.map +1 -1
- package/dist/cjs/ChartEditor.js +42 -7
- package/dist/cjs/Context.d.ts +4 -5
- package/dist/cjs/Context.d.ts.map +1 -1
- package/dist/cjs/Context.js +22 -34
- package/dist/cjs/Dashboard.d.ts +4 -3
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/Dashboard.js +66 -39
- package/dist/cjs/DateRangePicker/QuillDateRangePicker.d.ts.map +1 -1
- package/dist/cjs/DateRangePicker/QuillDateRangePicker.js +8 -10
- package/dist/cjs/DateRangePicker/dateRangePickerUtils.d.ts +1 -0
- package/dist/cjs/DateRangePicker/dateRangePickerUtils.d.ts.map +1 -1
- package/dist/cjs/DateRangePicker/dateRangePickerUtils.js +1 -1
- package/dist/cjs/QuillProvider.js +1 -1
- package/dist/cjs/ReportBuilder.d.ts +8 -12
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +157 -83
- package/dist/cjs/SQLEditor.d.ts +8 -1
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +80 -28
- package/dist/cjs/Table.js +1 -1
- package/dist/cjs/assets/AdjustmentsIcon.d.ts +5 -0
- package/dist/cjs/assets/AdjustmentsIcon.d.ts.map +1 -0
- package/dist/cjs/assets/AdjustmentsIcon.js +5 -0
- package/dist/cjs/assets/ArrowDownHeadIcon.d.ts.map +1 -1
- package/dist/cjs/assets/index.d.ts +0 -1
- package/dist/cjs/assets/index.d.ts.map +1 -1
- package/dist/cjs/assets/index.js +1 -3
- package/dist/cjs/components/Chart/ChartError.js +2 -2
- package/dist/cjs/components/Dashboard/DashboardFilter.d.ts +8 -5
- package/dist/cjs/components/Dashboard/DashboardFilter.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DashboardFilter.js +24 -20
- package/dist/cjs/components/Dashboard/DashboardTemplate.d.ts +2 -2
- package/dist/cjs/components/Dashboard/DashboardTemplate.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.d.ts +5 -1
- package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.js +23 -4
- 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 +2 -2
- package/dist/cjs/components/Dashboard/util.d.ts +2 -2
- package/dist/cjs/components/Dashboard/util.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/util.js +2 -2
- package/dist/cjs/components/QuillMultiSelect.d.ts +1 -1
- package/dist/cjs/components/QuillMultiSelect.d.ts.map +1 -1
- package/dist/cjs/components/QuillMultiSelect.js +20 -14
- package/dist/cjs/components/QuillMultiSelectWithCombo.d.ts +1 -1
- package/dist/cjs/components/QuillMultiSelectWithCombo.d.ts.map +1 -1
- package/dist/cjs/components/QuillMultiSelectWithCombo.js +69 -46
- package/dist/cjs/components/QuillSelect.d.ts +1 -1
- package/dist/cjs/components/QuillSelect.d.ts.map +1 -1
- package/dist/cjs/components/QuillSelect.js +31 -8
- package/dist/cjs/components/QuillSelectWithCombo.d.ts +1 -1
- package/dist/cjs/components/QuillSelectWithCombo.d.ts.map +1 -1
- package/dist/cjs/components/QuillSelectWithCombo.js +50 -28
- package/dist/cjs/components/QuillTable.d.ts +2 -1
- package/dist/cjs/components/QuillTable.d.ts.map +1 -1
- package/dist/cjs/components/QuillTable.js +7 -4
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.d.ts +2 -1
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.js +2 -2
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts +2 -1
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddSortPopover.js +2 -2
- package/dist/cjs/components/ReportBuilder/FilterModal.d.ts +2 -1
- package/dist/cjs/components/ReportBuilder/FilterModal.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/FilterModal.js +17 -4
- package/dist/cjs/components/ReportBuilder/convert.d.ts +1 -1
- package/dist/cjs/components/ReportBuilder/ui.d.ts +13 -7
- package/dist/cjs/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/ui.js +14 -11
- package/dist/cjs/components/UiComponents.d.ts +15 -6
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +29 -23
- package/dist/cjs/hooks/useAstToFilterTree.d.ts +2 -2
- package/dist/cjs/hooks/useAstToFilterTree.d.ts.map +1 -1
- package/dist/cjs/hooks/useDashboard.d.ts +10 -2
- package/dist/cjs/hooks/useDashboard.d.ts.map +1 -1
- package/dist/cjs/hooks/useDashboard.js +85 -53
- package/dist/cjs/hooks/useExport.js +1 -1
- package/dist/cjs/hooks/useOnClickOutside.js +1 -1
- package/dist/cjs/hooks/useQuill.js +2 -2
- package/dist/cjs/hooks/useVirtualTables.d.ts +12 -3
- package/dist/cjs/hooks/useVirtualTables.d.ts.map +1 -1
- package/dist/cjs/hooks/useVirtualTables.js +105 -1
- package/dist/cjs/internals/ReportBuilder/PivotForm.d.ts +3 -1
- package/dist/cjs/internals/ReportBuilder/PivotForm.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotForm.js +9 -9
- package/dist/cjs/internals/ReportBuilder/PivotList.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotList.js +21 -15
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts +3 -2
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.js +9 -9
- package/dist/cjs/models/Client.d.ts +10 -2
- package/dist/cjs/models/Client.d.ts.map +1 -1
- package/dist/cjs/utils/astProcessing.d.ts +3 -3
- package/dist/cjs/utils/astProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/client.d.ts.map +1 -1
- package/dist/cjs/utils/client.js +2 -7
- package/dist/cjs/utils/dashboard.d.ts +5 -3
- package/dist/cjs/utils/dashboard.d.ts.map +1 -1
- package/dist/cjs/utils/dashboard.js +106 -6
- package/dist/cjs/utils/dataFetcher.d.ts +4 -4
- package/dist/cjs/utils/dataFetcher.d.ts.map +1 -1
- package/dist/cjs/utils/dataFetcher.js +1 -1
- package/dist/cjs/utils/filterProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/filterProcessing.js +2 -8
- package/dist/cjs/utils/paginationProcessing.js +1 -1
- package/dist/cjs/utils/pivotConstructor.d.ts +2 -2
- package/dist/cjs/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/pivotConstructor.js +1 -1
- package/dist/cjs/utils/pivotProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/pivotProcessing.js +6 -2
- package/dist/cjs/utils/queryConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/queryConstructor.js +12 -9
- package/dist/cjs/utils/report.d.ts +6 -5
- package/dist/cjs/utils/report.d.ts.map +1 -1
- package/dist/cjs/utils/report.js +69 -24
- package/dist/cjs/utils/schema.d.ts +3 -3
- package/dist/cjs/utils/schema.d.ts.map +1 -1
- package/dist/cjs/utils/schema.js +39 -35
- package/dist/cjs/utils/tableProcessing.d.ts +17 -10
- package/dist/cjs/utils/tableProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/tableProcessing.js +42 -23
- package/dist/esm/Chart.js +2 -2
- package/dist/esm/ChartBuilder.d.ts +7 -3
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +52 -19
- package/dist/esm/ChartEditor.d.ts +3 -1
- package/dist/esm/ChartEditor.d.ts.map +1 -1
- package/dist/esm/ChartEditor.js +43 -8
- package/dist/esm/Context.d.ts +4 -5
- package/dist/esm/Context.d.ts.map +1 -1
- package/dist/esm/Context.js +23 -35
- package/dist/esm/Dashboard.d.ts +4 -3
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/Dashboard.js +67 -40
- package/dist/esm/DateRangePicker/QuillDateRangePicker.d.ts.map +1 -1
- package/dist/esm/DateRangePicker/QuillDateRangePicker.js +8 -10
- package/dist/esm/DateRangePicker/dateRangePickerUtils.d.ts +1 -0
- package/dist/esm/DateRangePicker/dateRangePickerUtils.d.ts.map +1 -1
- package/dist/esm/DateRangePicker/dateRangePickerUtils.js +1 -1
- package/dist/esm/QuillProvider.js +1 -1
- package/dist/esm/ReportBuilder.d.ts +8 -12
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +160 -86
- package/dist/esm/SQLEditor.d.ts +8 -1
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +83 -31
- package/dist/esm/Table.js +2 -2
- package/dist/esm/assets/AdjustmentsIcon.d.ts +5 -0
- package/dist/esm/assets/AdjustmentsIcon.d.ts.map +1 -0
- package/dist/esm/assets/AdjustmentsIcon.js +3 -0
- package/dist/esm/assets/ArrowDownHeadIcon.d.ts.map +1 -1
- package/dist/esm/assets/index.d.ts +0 -1
- package/dist/esm/assets/index.d.ts.map +1 -1
- package/dist/esm/assets/index.js +0 -1
- package/dist/esm/components/Chart/ChartError.js +2 -2
- package/dist/esm/components/Dashboard/DashboardFilter.d.ts +8 -5
- package/dist/esm/components/Dashboard/DashboardFilter.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DashboardFilter.js +24 -20
- package/dist/esm/components/Dashboard/DashboardTemplate.d.ts +2 -2
- package/dist/esm/components/Dashboard/DashboardTemplate.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.d.ts +5 -1
- package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.js +25 -6
- 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 +2 -2
- package/dist/esm/components/Dashboard/util.d.ts +2 -2
- package/dist/esm/components/Dashboard/util.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/util.js +2 -2
- package/dist/esm/components/QuillMultiSelect.d.ts +1 -1
- package/dist/esm/components/QuillMultiSelect.d.ts.map +1 -1
- package/dist/esm/components/QuillMultiSelect.js +21 -15
- package/dist/esm/components/QuillMultiSelectWithCombo.d.ts +1 -1
- package/dist/esm/components/QuillMultiSelectWithCombo.d.ts.map +1 -1
- package/dist/esm/components/QuillMultiSelectWithCombo.js +70 -47
- package/dist/esm/components/QuillSelect.d.ts +1 -1
- package/dist/esm/components/QuillSelect.d.ts.map +1 -1
- package/dist/esm/components/QuillSelect.js +32 -9
- package/dist/esm/components/QuillSelectWithCombo.d.ts +1 -1
- package/dist/esm/components/QuillSelectWithCombo.d.ts.map +1 -1
- package/dist/esm/components/QuillSelectWithCombo.js +51 -29
- package/dist/esm/components/QuillTable.d.ts +2 -1
- package/dist/esm/components/QuillTable.d.ts.map +1 -1
- package/dist/esm/components/QuillTable.js +7 -4
- package/dist/esm/components/ReportBuilder/AddLimitPopover.d.ts +2 -1
- package/dist/esm/components/ReportBuilder/AddLimitPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddLimitPopover.js +2 -2
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts +2 -1
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddSortPopover.js +2 -2
- package/dist/esm/components/ReportBuilder/FilterModal.d.ts +2 -1
- package/dist/esm/components/ReportBuilder/FilterModal.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/FilterModal.js +17 -4
- package/dist/esm/components/ReportBuilder/convert.d.ts +1 -1
- package/dist/esm/components/ReportBuilder/ui.d.ts +13 -7
- package/dist/esm/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/ui.js +14 -11
- package/dist/esm/components/UiComponents.d.ts +15 -6
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +29 -23
- package/dist/esm/hooks/useAstToFilterTree.d.ts +2 -2
- package/dist/esm/hooks/useAstToFilterTree.d.ts.map +1 -1
- package/dist/esm/hooks/useDashboard.d.ts +10 -2
- package/dist/esm/hooks/useDashboard.d.ts.map +1 -1
- package/dist/esm/hooks/useDashboard.js +86 -54
- package/dist/esm/hooks/useExport.js +1 -1
- package/dist/esm/hooks/useOnClickOutside.js +1 -1
- package/dist/esm/hooks/useQuill.js +3 -3
- package/dist/esm/hooks/useVirtualTables.d.ts +12 -3
- package/dist/esm/hooks/useVirtualTables.d.ts.map +1 -1
- package/dist/esm/hooks/useVirtualTables.js +106 -2
- package/dist/esm/internals/ReportBuilder/PivotForm.d.ts +3 -1
- package/dist/esm/internals/ReportBuilder/PivotForm.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotForm.js +9 -9
- package/dist/esm/internals/ReportBuilder/PivotList.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotList.js +21 -15
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts +3 -2
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.js +9 -9
- package/dist/esm/models/Client.d.ts +10 -2
- package/dist/esm/models/Client.d.ts.map +1 -1
- package/dist/esm/utils/astProcessing.d.ts +3 -3
- package/dist/esm/utils/astProcessing.d.ts.map +1 -1
- package/dist/esm/utils/client.d.ts.map +1 -1
- package/dist/esm/utils/client.js +2 -7
- package/dist/esm/utils/dashboard.d.ts +5 -3
- package/dist/esm/utils/dashboard.d.ts.map +1 -1
- package/dist/esm/utils/dashboard.js +104 -5
- package/dist/esm/utils/dataFetcher.d.ts +4 -4
- package/dist/esm/utils/dataFetcher.d.ts.map +1 -1
- package/dist/esm/utils/dataFetcher.js +1 -1
- package/dist/esm/utils/filterProcessing.d.ts.map +1 -1
- package/dist/esm/utils/filterProcessing.js +2 -8
- package/dist/esm/utils/paginationProcessing.js +1 -1
- package/dist/esm/utils/pivotConstructor.d.ts +2 -2
- package/dist/esm/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/esm/utils/pivotConstructor.js +1 -1
- package/dist/esm/utils/pivotProcessing.d.ts.map +1 -1
- package/dist/esm/utils/pivotProcessing.js +6 -2
- package/dist/esm/utils/queryConstructor.d.ts.map +1 -1
- package/dist/esm/utils/queryConstructor.js +12 -9
- package/dist/esm/utils/report.d.ts +6 -5
- package/dist/esm/utils/report.d.ts.map +1 -1
- package/dist/esm/utils/report.js +68 -24
- package/dist/esm/utils/schema.d.ts +3 -3
- package/dist/esm/utils/schema.d.ts.map +1 -1
- package/dist/esm/utils/schema.js +39 -35
- package/dist/esm/utils/tableProcessing.d.ts +17 -10
- package/dist/esm/utils/tableProcessing.d.ts.map +1 -1
- package/dist/esm/utils/tableProcessing.js +39 -20
- package/package.json +1 -1
- package/dist/cjs/assets/LoadingSpinner.d.ts +0 -5
- package/dist/cjs/assets/LoadingSpinner.d.ts.map +0 -1
- package/dist/cjs/assets/LoadingSpinner.js +0 -5
- package/dist/esm/assets/LoadingSpinner.d.ts +0 -5
- package/dist/esm/assets/LoadingSpinner.d.ts.map +0 -1
- package/dist/esm/assets/LoadingSpinner.js +0 -3
|
@@ -73,11 +73,12 @@ exports.QUILL_SERVER = (typeof process !== 'undefined' && process?.env?.QUILL_SE
|
|
|
73
73
|
* ### Report Builder API
|
|
74
74
|
* @see https://docs.quillsql.com/components/report-builder
|
|
75
75
|
*/
|
|
76
|
-
function ReportBuilder({ initialTableName = '', onSubmitEditReport = () => void null, onSubmitCreateReport = () => void null, onDiscardChanges = undefined, onSaveChanges = undefined, 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, MultiSelectComponent = QuillMultiSelectWithCombo_1.QuillMultiSelectComponentWithCombo, TableComponent = UiComponents_1.QuillTableSQLEditorComponent, PopoverComponent = UiComponents_1.MemoizedPopover, TabsComponent = UiComponents_1.QuillTabs,
|
|
76
|
+
function ReportBuilder({ initialTableName = '', onSubmitEditReport = () => void null, onSubmitCreateReport = () => void null, onDiscardChanges = undefined, onSaveChanges = undefined, onCloseChartBuilder = undefined, 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, MultiSelectComponent = QuillMultiSelectWithCombo_1.QuillMultiSelectComponentWithCombo, TableComponent = UiComponents_1.QuillTableSQLEditorComponent, PopoverComponent = UiComponents_1.MemoizedPopover, TabsComponent = UiComponents_1.QuillTabs,
|
|
77
77
|
// CheckboxComponent = MemoizedCheckbox,
|
|
78
78
|
SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer, SelectColumnComponent = ui_1.QuillSelectColumn, DraggableColumnComponent = ui_1.QuillDraggableColumn, SidebarHeadingComponent = ui_1.QuillSidebarHeading, FilterPopoverComponent = ui_1.QuillFilterPopover, SortPopoverComponent = ui_1.QuillSortPopover, LimitPopoverComponent = ui_1.QuillLimitPopover, CardComponent = QuillCard_1.QuillCard, LabelComponent = UiComponents_1.MemoizedLabel, HeaderComponent = UiComponents_1.MemoizedHeader, SubHeaderComponent = UiComponents_1.MemoizedSubHeader, TextComponent = UiComponents_1.MemoizedText, ErrorMessageComponent = UiComponents_1.QuillErrorMessageComponent, ChartBuilderInputRowContainer = UiComponents_1.QuillChartBuilderInputRowContainer, ChartBuilderInputColumnContainer = UiComponents_1.QuillChartBuilderInputColumnContainer, PivotRowContainer = UiComponents_1.QuillPivotRowContainer, PivotColumnContainer = UiComponents_1.QuillPivotColumnContainer, LoadingComponent = UiComponents_1.QuillLoadingComponent, ColumnSearchEmptyState = UiComponents_1.QuillColumnSearchEmptyState, ChartBuilderFormContainer = UiComponents_1.QuillChartBuilderFormContainer, ChartBuilderModalComponent = UiComponents_1.MemoizedModal, isAdminEnabled = false, isAIEnabled = true, showChartBuilderTableFormatOptions = true, containerStyle, className, pivotRecommendationsEnabled = true, reportId, hideCopySQL = true, isChartBuilderHorizontalView = true, onClickChartElement, }) {
|
|
79
79
|
const [dashboard] = (0, react_1.useContext)(Context_1.DashboardContext);
|
|
80
80
|
const [schemaData] = (0, react_1.useContext)(Context_1.SchemaDataContext);
|
|
81
|
+
const { dashboardFilters } = (0, react_1.useContext)(Context_1.DashboardFiltersContext);
|
|
81
82
|
const [reportInfo, setReportInfo] = (0, react_1.useState)(null);
|
|
82
83
|
const [aiPrompt, setAiPrompt] = (0, react_1.useState)('');
|
|
83
84
|
const [errorMessage, setErrorMessage] = (0, react_1.useState)('');
|
|
@@ -92,7 +93,7 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
92
93
|
const [openPopover, setOpenPopover] = (0, react_1.useState)(null);
|
|
93
94
|
const [loading, setLoading] = (0, react_1.useState)(!!initialTableName);
|
|
94
95
|
const [isChartBuilderOpen, setIsChartBuilderOpen] = (0, react_1.useState)(false);
|
|
95
|
-
const [,
|
|
96
|
+
const [isAddLoading, setIsAddLoading] = (0, react_1.useState)(false);
|
|
96
97
|
const [isCopying, setIsCopying] = (0, react_1.useState)(false);
|
|
97
98
|
const [dataDisplayed, setDataDisplayed] = (0, react_1.useState)(false);
|
|
98
99
|
const [rows, setRows] = (0, react_1.useState)([]);
|
|
@@ -100,6 +101,7 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
100
101
|
const [columns, setColumns] = (0, react_1.useState)([]);
|
|
101
102
|
const [tempReport, setTempReport] = (0, react_1.useState)(report_1.EMPTY_INTERNAL_REPORT);
|
|
102
103
|
const [uniqueValues, setUniqueValues] = (0, react_1.useState)({});
|
|
104
|
+
const [uniqueValuesIsLoading, setUniqueValuesIsLoading] = (0, react_1.useState)(false);
|
|
103
105
|
const [pivot, setPivot] = (0, react_1.useState)(null);
|
|
104
106
|
const [pivotData, setPivotData] = (0, react_1.useState)(null);
|
|
105
107
|
const [createdPivots, setCreatedPivots] = (0, react_1.useState)([]);
|
|
@@ -124,18 +126,23 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
124
126
|
const [pivotAggregation, setPivotAggregation] = (0, react_1.useState)(undefined);
|
|
125
127
|
const [dateRanges, setDateRanges] = (0, react_1.useState)(null);
|
|
126
128
|
const [client] = (0, react_1.useContext)(Context_1.ClientContext);
|
|
127
|
-
// JANK: This is temp and stupid
|
|
128
|
-
const [overrideRecommendations, setOverrideRecommendations] = (0, react_1.useState)(true);
|
|
129
129
|
const [fieldValuesMap, setFieldValuesMap] = (0, react_1.useState)({}); // Mapping of unique values per field, used in string filter 'in' and 'not in'
|
|
130
130
|
const [globalUniqueValues, setGlobalUniqueValues] = (0, react_1.useState)({});
|
|
131
|
+
const [globalUniqueValuesIsLoading, setGlobalUniqueValuesIsLoading] = (0, react_1.useState)(false);
|
|
131
132
|
const { filterTree, filterStack } = (0, useAstToFilterTree_1.default)(formData, client); // Stores the state of filters
|
|
132
133
|
const [removingFilter, setRemovingFilter] = (0, react_1.useState)(false);
|
|
134
|
+
const [pivotRecommendationsEnabledState, setPivotRecommendationsEnabledState,] = (0, react_1.useState)(pivotRecommendationsEnabled);
|
|
135
|
+
const REPORT_BUILDER_PAGINATION = {
|
|
136
|
+
page: 0,
|
|
137
|
+
rowsPerPage: 20,
|
|
138
|
+
rowsPerRequest: 40,
|
|
139
|
+
};
|
|
133
140
|
(0, react_1.useEffect)(() => {
|
|
134
141
|
if (!client) {
|
|
135
142
|
return;
|
|
136
143
|
}
|
|
137
|
-
if (client.
|
|
138
|
-
|
|
144
|
+
if (client.recommendedPivotsDisabled !== undefined) {
|
|
145
|
+
setPivotRecommendationsEnabledState(!client.recommendedPivotsDisabled);
|
|
139
146
|
}
|
|
140
147
|
if (!initialLoad && client.publicKey) {
|
|
141
148
|
clearAllState();
|
|
@@ -145,13 +152,18 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
145
152
|
(0, width_1.updateFirstChildWidth)(askAIContainerRef, setAskAIInputWidth, { gap: 12 });
|
|
146
153
|
(0, width_1.updateFirstChildWidth)(askAILoadingContainerRef, setAskAILoadingContainerWidth, { gap: 12 });
|
|
147
154
|
}, [dataDisplayed]);
|
|
155
|
+
(0, react_1.useEffect)(() => {
|
|
156
|
+
if (isChartBuilderOpen === false) {
|
|
157
|
+
onCloseChartBuilder && onCloseChartBuilder();
|
|
158
|
+
}
|
|
159
|
+
}, [isChartBuilderOpen]);
|
|
148
160
|
// Whenever unique values changes, update the fieldValuesMap, used in FilterModals
|
|
149
|
-
const updateFieldValuesMap = (
|
|
161
|
+
const updateFieldValuesMap = (curUniqueValues, tableName) => {
|
|
150
162
|
const newFieldValues = {};
|
|
151
|
-
if (
|
|
152
|
-
for (const field of Object.keys(
|
|
163
|
+
if (curUniqueValues[tableName]) {
|
|
164
|
+
for (const field of Object.keys(curUniqueValues[tableName])) {
|
|
153
165
|
newFieldValues[field] = [];
|
|
154
|
-
for (const value of Object.keys(
|
|
166
|
+
for (const value of Object.keys(curUniqueValues[tableName][field])) {
|
|
155
167
|
newFieldValues[field]?.push(value);
|
|
156
168
|
}
|
|
157
169
|
}
|
|
@@ -172,7 +184,7 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
172
184
|
};
|
|
173
185
|
}, []);
|
|
174
186
|
const updatePivot = async (changeField, fieldKey) => {
|
|
175
|
-
const newPivot = pivot;
|
|
187
|
+
const newPivot = (0, util_1.deepCopy)(pivot);
|
|
176
188
|
setTableLoading(true);
|
|
177
189
|
// @ts-ignore
|
|
178
190
|
newPivot[fieldKey] = changeField;
|
|
@@ -197,19 +209,19 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
197
209
|
dateBucket = (0, dates_1.getDateBucketFromRange)(tempDateRange.dateRange);
|
|
198
210
|
}
|
|
199
211
|
let distinctValuesForQuery = {};
|
|
200
|
-
|
|
212
|
+
setPivot(newPivot);
|
|
213
|
+
if (newPivot.columnField) {
|
|
201
214
|
distinctValuesForQuery = await (0, tableProcessing_1.getUniqueValuesByColumns)([
|
|
202
215
|
{
|
|
203
|
-
field:
|
|
204
|
-
label:
|
|
216
|
+
field: newPivot.columnField,
|
|
217
|
+
label: newPivot.columnField,
|
|
205
218
|
format: 'string',
|
|
206
219
|
},
|
|
207
220
|
], activeQuery, [], client, schemaData.customFields ?? []);
|
|
208
221
|
}
|
|
209
|
-
const pivotedData = await (0, PivotModal_1.generatePivotTable)(
|
|
222
|
+
const pivotedData = await (0, PivotModal_1.generatePivotTable)(newPivot, rows, undefined, false, -1, undefined, dateBucket, tempReport, client, distinctValuesForQuery);
|
|
210
223
|
setPivotData(pivotedData || []);
|
|
211
224
|
const formattedRows = formatRows(pivotedData.rows, columns, true, newPivot.aggregationType);
|
|
212
|
-
setPivot(newPivot);
|
|
213
225
|
setFormattedRows(formattedRows);
|
|
214
226
|
setTableLoading(false);
|
|
215
227
|
};
|
|
@@ -241,7 +253,6 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
241
253
|
setActivePath(null);
|
|
242
254
|
setOpenPopover(null);
|
|
243
255
|
setLoading(false);
|
|
244
|
-
setIsPending(false);
|
|
245
256
|
setDataDisplayed(false);
|
|
246
257
|
setRows([]);
|
|
247
258
|
setColumns([]);
|
|
@@ -254,8 +265,10 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
254
265
|
}, 0);
|
|
255
266
|
};
|
|
256
267
|
const fetchGlobalUniqueValues = async (columns, currentTable, client) => {
|
|
257
|
-
|
|
268
|
+
setGlobalUniqueValuesIsLoading(true);
|
|
269
|
+
const global = await (0, tableProcessing_1.getUniqueStringValues)(columns, currentTable, client, schemaData.customFields, undefined, true);
|
|
258
270
|
setGlobalUniqueValues((0, filterProcessing_1.uniqueValuesToStringMap)(global));
|
|
271
|
+
setGlobalUniqueValuesIsLoading(false);
|
|
259
272
|
};
|
|
260
273
|
const uniqueValuesDependenciesRef = (0, react_1.useRef)({ client, columns, currentTable });
|
|
261
274
|
const memoizedFetchGlobalUniqueValues = (0, react_1.useCallback)(fetchGlobalUniqueValues, []);
|
|
@@ -403,11 +416,13 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
403
416
|
setLoading(true);
|
|
404
417
|
const tableInfo = tables.find((tableInfo) => tableInfo.name === initialTableName);
|
|
405
418
|
if (tableInfo) {
|
|
406
|
-
|
|
419
|
+
setUniqueValuesIsLoading(true);
|
|
420
|
+
const newUniqueValues = await (0, tableProcessing_1.getUniqueStringValues)(tableInfo.columns, initialTableName, client, schemaData.customFields, uniqueValues, true);
|
|
407
421
|
if ((0, crypto_1.hashCode)(uniqueValues) !== (0, crypto_1.hashCode)(newUniqueValues)) {
|
|
408
422
|
setUniqueValues(newUniqueValues);
|
|
409
423
|
updateFieldValuesMap(newUniqueValues, initialTableName);
|
|
410
424
|
}
|
|
425
|
+
setUniqueValuesIsLoading(false);
|
|
411
426
|
const dateRangesTemp = await getDateRanges(tableInfo.columns, initialTableName);
|
|
412
427
|
setDateRanges(dateRangesTemp);
|
|
413
428
|
}
|
|
@@ -688,13 +703,14 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
688
703
|
};
|
|
689
704
|
const [previousPage, setPreviousPage] = (0, react_1.useState)(0);
|
|
690
705
|
const [currentProcessing, setCurrentProcessing] = (0, react_1.useState)({
|
|
691
|
-
page:
|
|
706
|
+
page: REPORT_BUILDER_PAGINATION,
|
|
692
707
|
});
|
|
693
708
|
const [numberOfRows, setNumberOfRows] = (0, react_1.useState)(0);
|
|
709
|
+
const [rowCountIsLoading, setRowCountIsLoading] = (0, react_1.useState)(false);
|
|
694
710
|
const [tableLoading, setTableLoading] = (0, react_1.useState)(false);
|
|
695
711
|
const onPageChange = (page) => {
|
|
696
712
|
if (currentProcessing.page &&
|
|
697
|
-
(0, paginationProcessing_1.shouldFetchMore)(
|
|
713
|
+
(0, paginationProcessing_1.shouldFetchMore)(REPORT_BUILDER_PAGINATION, page, previousPage)) {
|
|
698
714
|
const newPagination = { ...currentProcessing.page, page };
|
|
699
715
|
const updatedProcessing = { ...currentProcessing, page: newPagination };
|
|
700
716
|
setCurrentProcessing(updatedProcessing);
|
|
@@ -705,28 +721,52 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
705
721
|
}
|
|
706
722
|
};
|
|
707
723
|
const onSortChange = (sort) => {
|
|
708
|
-
if ((0, paginationProcessing_1.shouldSortInMemory)(
|
|
724
|
+
if ((0, paginationProcessing_1.shouldSortInMemory)(REPORT_BUILDER_PAGINATION, numberOfRows, !!pivot)) {
|
|
709
725
|
return;
|
|
710
726
|
}
|
|
711
|
-
const updatedProcessing = { page:
|
|
727
|
+
const updatedProcessing = { page: REPORT_BUILDER_PAGINATION, sort };
|
|
712
728
|
handleRunQuery(updatedProcessing, true);
|
|
713
729
|
setCurrentProcessing(updatedProcessing);
|
|
714
730
|
setPreviousPage(0);
|
|
715
731
|
};
|
|
716
|
-
const
|
|
732
|
+
const onFilterPreviewChange = (preview) => {
|
|
733
|
+
handleRunQuery(currentProcessing, true, preview);
|
|
734
|
+
};
|
|
735
|
+
const fetchRowCount = async (processing, includeFilters) => {
|
|
736
|
+
if (!client || !activeQuery) {
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
setRowCountIsLoading(true);
|
|
740
|
+
const tableInfo = await (0, tableProcessing_1.fetchResultsByQuery)(activeQuery, client, processing, schemaData.customFields, includeFilters ? dashboardFilters : undefined, includeFilters
|
|
741
|
+
? tempReport.dateField ?? reportInfo?.dateField
|
|
742
|
+
: undefined, false, true);
|
|
743
|
+
if (tableInfo.rowCount) {
|
|
744
|
+
setNumberOfRows(tableInfo.rowCount);
|
|
745
|
+
}
|
|
746
|
+
setRowCountIsLoading(false);
|
|
747
|
+
};
|
|
748
|
+
const fetchRowCountFromAST = async (ast, where) => {
|
|
749
|
+
setRowCountIsLoading(true);
|
|
750
|
+
const tableData = await (0, tableProcessing_1.fetchTableByAST)({ ...ast, where }, client, { page: REPORT_BUILDER_PAGINATION }, undefined, false, true);
|
|
751
|
+
if (tableData.rowCount) {
|
|
752
|
+
setNumberOfRows(tableData.rowCount);
|
|
753
|
+
}
|
|
754
|
+
setRowCountIsLoading(false);
|
|
755
|
+
};
|
|
756
|
+
const handleRunQuery = async (processing, resetRows = false, includeFilters = false) => {
|
|
717
757
|
try {
|
|
718
758
|
setErrorMessage('');
|
|
719
759
|
setTableLoading(true);
|
|
720
|
-
const tableInfo = await (0, tableProcessing_1.
|
|
760
|
+
const tableInfo = await (0, tableProcessing_1.fetchResultsByQuery)(activeQuery, client, processing, schemaData.customFields, includeFilters
|
|
761
|
+
? dashboardFilters.filter((f) => f && destinationDashboard === f.dashboardName)
|
|
762
|
+
: undefined, includeFilters ? tempReport.dateField : undefined, true);
|
|
721
763
|
if (tableInfo.error) {
|
|
722
764
|
throw new Error(tableInfo.error);
|
|
723
765
|
}
|
|
724
766
|
else if (tableInfo.rows.length === 0) {
|
|
725
767
|
throw new Error('No data found');
|
|
726
768
|
}
|
|
727
|
-
|
|
728
|
-
setNumberOfRows(tableInfo.rowCount);
|
|
729
|
-
}
|
|
769
|
+
fetchRowCount(processing, includeFilters);
|
|
730
770
|
setCurrentProcessing(processing);
|
|
731
771
|
let tempRows = [...rows, ...tableInfo.rows];
|
|
732
772
|
if (resetRows) {
|
|
@@ -734,6 +774,11 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
734
774
|
}
|
|
735
775
|
setRows(tempRows);
|
|
736
776
|
setFormattedRows((0, report_1.formatRowsFromReport)({ rows: tempRows, columns: tableInfo.columns }));
|
|
777
|
+
setTempReport({
|
|
778
|
+
...tempReport,
|
|
779
|
+
rows: tempRows,
|
|
780
|
+
rowCount: tableInfo.rowCount ?? tempReport.rowCount,
|
|
781
|
+
});
|
|
737
782
|
setColumns(tableInfo.columns);
|
|
738
783
|
setTableLoading(false);
|
|
739
784
|
}
|
|
@@ -745,7 +790,7 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
745
790
|
return;
|
|
746
791
|
}
|
|
747
792
|
};
|
|
748
|
-
const renderFilters = () => {
|
|
793
|
+
const renderFilters = (actionsEnabled = true) => {
|
|
749
794
|
// Render filterStack
|
|
750
795
|
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
751
796
|
display: 'flex',
|
|
@@ -789,7 +834,7 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
789
834
|
} }) }, index));
|
|
790
835
|
}
|
|
791
836
|
else if (item.value) {
|
|
792
|
-
return ((0, jsx_runtime_1.jsx)(ui_1.FilterPopoverWrapper, { schema: schemaData.schema.find((s) => s.name === currentTable || s.displayName === currentTable) ?? schemaData.schema[0], filter: item.value, filterLabel: item.value ? (0, filterProcessing_1.filterSentence)(item.value) : '', index: index, FilterTagComponent: FilterPopoverComponent, FilterModal: FilterModal_1.default, fieldValuesMap: globalUniqueValues, priorFilters: filterStack.slice(0, index > 0 ? index - 1 : 0), columns: columns, client: client, customFields: schemaData.customFields, baseAst: baseAst, endpoint: exports.QUILL_SERVER, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, MultiSelectComponent: MultiSelectComponent, handleFilterSave: (filter) => {
|
|
837
|
+
return ((0, jsx_runtime_1.jsx)(ui_1.FilterPopoverWrapper, { schema: schemaData.schema.find((s) => s.name === currentTable || s.displayName === currentTable) ?? schemaData.schema[0], filter: item.value, filterLabel: item.value ? (0, filterProcessing_1.filterSentence)(item.value) : '', index: index, FilterTagComponent: FilterPopoverComponent, FilterModal: FilterModal_1.default, fieldValuesMap: globalUniqueValues, fieldValuesMapIsLoading: globalUniqueValuesIsLoading, priorFilters: filterStack.slice(0, index > 0 ? index - 1 : 0), columns: columns, client: client, customFields: schemaData.customFields, baseAst: baseAst, endpoint: exports.QUILL_SERVER, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, MultiSelectComponent: MultiSelectComponent, handleFilterSave: (filter) => {
|
|
793
838
|
item.value = filter;
|
|
794
839
|
let newFormData = null;
|
|
795
840
|
if (filterTree) {
|
|
@@ -853,7 +898,7 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
853
898
|
fetchSqlQuery(newAst, newFormData);
|
|
854
899
|
setRemovingFilter(false);
|
|
855
900
|
}
|
|
856
|
-
} }, `filter_${index}_${item.value ? (0, filterProcessing_1.filterSentence)(item.value) : ''}`));
|
|
901
|
+
}, disabled: !actionsEnabled }, `filter_${index}_${item.value ? (0, filterProcessing_1.filterSentence)(item.value) : ''}`));
|
|
857
902
|
}
|
|
858
903
|
}) }));
|
|
859
904
|
};
|
|
@@ -880,12 +925,18 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
880
925
|
},
|
|
881
926
|
as: null,
|
|
882
927
|
});
|
|
928
|
+
const updateUniqueValue = (uniqueStrings, table) => {
|
|
929
|
+
const uniqueStringsObj = {};
|
|
930
|
+
uniqueStringsObj[table] = uniqueStrings ?? {};
|
|
931
|
+
setUniqueValues(uniqueStringsObj);
|
|
932
|
+
updateFieldValuesMap(uniqueStringsObj, table);
|
|
933
|
+
};
|
|
883
934
|
const fetchReportFromASTHelper = async (baseAst, newFormData, curPivot, curSchema, previousReport) => {
|
|
884
935
|
const curFormData = newFormData !== undefined ? newFormData : formData;
|
|
885
936
|
let reportBuilderInfo = undefined;
|
|
886
937
|
try {
|
|
887
938
|
setLoading(true);
|
|
888
|
-
reportBuilderInfo = await (0, report_1.fetchReportBuilderDataFromAST)(baseAst, curFormData, curSchema ?? schemaData.schema, client, curPivot ?? pivot, formData, currentTable, { uniqueStrings: uniqueValues, dateRanges: dateRanges ?? {} }, previousReport ?? reportInfo ?? undefined, schemaData.customFields);
|
|
939
|
+
reportBuilderInfo = await (0, report_1.fetchReportBuilderDataFromAST)(baseAst, curFormData, curSchema ?? schemaData.schema, client, curPivot ?? pivot, formData, currentTable, { uniqueStrings: uniqueValues, dateRanges: dateRanges ?? {} }, previousReport ?? reportInfo ?? undefined, schemaData.customFields, true, true, { page: REPORT_BUILDER_PAGINATION });
|
|
889
940
|
if (reportBuilderInfo.error) {
|
|
890
941
|
throw new Error(reportBuilderInfo.error);
|
|
891
942
|
}
|
|
@@ -904,21 +955,22 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
904
955
|
setErrorMessage('Failed to fetch');
|
|
905
956
|
return;
|
|
906
957
|
}
|
|
958
|
+
fetchRowCountFromAST(baseAst, curFormData);
|
|
907
959
|
const reportTable = reportBuilderInfo.table;
|
|
908
960
|
const reportBuilderInfoColumns = reportBuilderInfo.columns.map((column) => {
|
|
909
961
|
return `${reportTable}.${column.field}`;
|
|
910
962
|
});
|
|
963
|
+
const prevFormData = formData;
|
|
964
|
+
const prevTable = currentTable;
|
|
911
965
|
setRows(reportBuilderInfo.rows);
|
|
912
966
|
setColumns(reportBuilderInfo.columns);
|
|
913
|
-
setNumberOfRows(reportBuilderInfo.rowCount);
|
|
967
|
+
// setNumberOfRows(reportBuilderInfo.rowCount);
|
|
914
968
|
setPivot(reportBuilderInfo.pivot);
|
|
915
969
|
setPivotData(reportBuilderInfo.pivotData);
|
|
970
|
+
setDateRanges(reportBuilderInfo.dateRanges);
|
|
916
971
|
setFormattedRows(reportBuilderInfo.formattedRows);
|
|
917
972
|
setTempReport(reportBuilderInfo.report);
|
|
918
973
|
setSelectedColumns(reportBuilderInfoColumns);
|
|
919
|
-
setUniqueValues(reportBuilderInfo.uniqueValues);
|
|
920
|
-
updateFieldValuesMap(reportBuilderInfo.uniqueValues, reportBuilderInfo.table);
|
|
921
|
-
setDateRanges(reportBuilderInfo.dateRanges);
|
|
922
974
|
setLoading(false);
|
|
923
975
|
setDataDisplayed(true);
|
|
924
976
|
setCurrentTable(reportBuilderInfo.table);
|
|
@@ -930,6 +982,31 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
930
982
|
setPivotValueField(reportBuilderInfo.pivot.valueField);
|
|
931
983
|
}
|
|
932
984
|
setReportInfo(reportBuilderInfo.report);
|
|
985
|
+
// fetch unique values after everything else since it is the most expensive
|
|
986
|
+
if (prevTable !== reportBuilderInfo.table ||
|
|
987
|
+
!(0, fast_deep_equal_1.default)(prevFormData, curFormData)) {
|
|
988
|
+
try {
|
|
989
|
+
setUniqueValuesIsLoading(true);
|
|
990
|
+
const schema = curSchema ?? schemaData.schema;
|
|
991
|
+
const tableInfo = schema.find((tableInfo) => tableInfo.name === reportBuilderInfo?.table);
|
|
992
|
+
if (!reportBuilderInfo.table || !tableInfo) {
|
|
993
|
+
throw new Error('No table found;');
|
|
994
|
+
}
|
|
995
|
+
const uniqueStrings = await (0, tableProcessing_1.getUniqueStringValues)(tableInfo.columns, reportBuilderInfo.table, client, schemaData.customFields, undefined, true, reportBuilderInfo.query);
|
|
996
|
+
updateUniqueValue(uniqueStrings, reportBuilderInfo.table);
|
|
997
|
+
setUniqueValuesIsLoading(false);
|
|
998
|
+
}
|
|
999
|
+
catch (err) {
|
|
1000
|
+
if (err instanceof Error) {
|
|
1001
|
+
setErrorMessage(err.message);
|
|
1002
|
+
setLoading(false);
|
|
1003
|
+
return { error: true, message: err.message, rows: [] };
|
|
1004
|
+
}
|
|
1005
|
+
setLoading(false);
|
|
1006
|
+
setErrorMessage('Failed to fetch');
|
|
1007
|
+
return { error: true, message: 'Failed to fetch', rows: [] };
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
933
1010
|
};
|
|
934
1011
|
const fetchAstFromPromptHelper = async (overridePrompt) => {
|
|
935
1012
|
let astInfo = {};
|
|
@@ -995,7 +1072,7 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
995
1072
|
};
|
|
996
1073
|
return ((0, jsx_runtime_1.jsx)("div", { style: { ...style }, ref: setNodeRef, children: (0, jsx_runtime_1.jsx)(DraggableColumnComponent, { label: (0, textProcessing_1.snakeAndCamelCaseToTitleCase)(label), onDelete: onDelete, DragHandle: (props) => ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
997
1074
|
cursor: 'grab',
|
|
998
|
-
}, ...attributes, ...listeners, children: (0, jsx_runtime_1.jsx)(props.dragIcon, {}) })) }) }));
|
|
1075
|
+
}, ...attributes, ...listeners, children: (0, jsx_runtime_1.jsx)(props.dragIcon, {}) })), deleteDisabled: loading }) }));
|
|
999
1076
|
};
|
|
1000
1077
|
function DraggableColumns() {
|
|
1001
1078
|
const sensors = (0, core_1.useSensors)((0, core_1.useSensor)(core_1.PointerSensor), (0, core_1.useSensor)(core_1.KeyboardSensor, {
|
|
@@ -1070,7 +1147,7 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
1070
1147
|
display: 'flex',
|
|
1071
1148
|
flexDirection: 'column',
|
|
1072
1149
|
gap: 8,
|
|
1073
|
-
}, children: [columnNamesInAst.map((name) => ((0, jsx_runtime_1.jsx)(DraggableItem, { id: name, label: name, onDelete: () => handleDeleteColumn(name) }, name))), columnNamesInAst?.length > 0 && (0, jsx_runtime_1.jsx)("div", { style: { height: 6 } })] }) }) }));
|
|
1150
|
+
}, children: [columnNamesInAst.map((name) => ((0, jsx_runtime_1.jsx)(DraggableItem, { id: name, label: name, onDelete: () => !loading && handleDeleteColumn(name) }, name))), columnNamesInAst?.length > 0 && (0, jsx_runtime_1.jsx)("div", { style: { height: 6 } })] }) }) }));
|
|
1074
1151
|
}
|
|
1075
1152
|
// TODO: Refactor this part
|
|
1076
1153
|
if (loading || initialChartLoad) {
|
|
@@ -1083,11 +1160,10 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
1083
1160
|
if (!openPopover) {
|
|
1084
1161
|
setOpenPopover('AddColumnModal');
|
|
1085
1162
|
}
|
|
1086
|
-
}, label: 'Select columns' }), (0, jsx_runtime_1.jsx)(ModalComponent, { isOpen: openPopover === 'AddColumnModal', setIsOpen: (isOpen) => {
|
|
1163
|
+
}, label: 'Select columns', disabled: true }), (0, jsx_runtime_1.jsx)(ModalComponent, { isOpen: openPopover === 'AddColumnModal', setIsOpen: (isOpen) => {
|
|
1087
1164
|
if (!isOpen) {
|
|
1088
1165
|
// delay onClose callback so onClick no-ops
|
|
1089
1166
|
setTimeout(() => {
|
|
1090
|
-
setIsPending(false);
|
|
1091
1167
|
setActiveEditItem(null);
|
|
1092
1168
|
setActivePath(null);
|
|
1093
1169
|
setOpenPopover(null);
|
|
@@ -1105,7 +1181,7 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
1105
1181
|
flexDirection: 'column',
|
|
1106
1182
|
gap: 8,
|
|
1107
1183
|
marginBottom: 12,
|
|
1108
|
-
}, children: renderFilters() })), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
1184
|
+
}, children: renderFilters(false) })), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
1109
1185
|
display: 'flex',
|
|
1110
1186
|
flexDirection: 'column',
|
|
1111
1187
|
alignItems: 'flex-start',
|
|
@@ -1131,14 +1207,12 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
1131
1207
|
}
|
|
1132
1208
|
setOpenPopover('AddFilterPopover');
|
|
1133
1209
|
setActivePath('');
|
|
1134
|
-
setIsPending(true);
|
|
1135
1210
|
}
|
|
1136
|
-
}, label: 'Add filter' }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
1211
|
+
}, label: 'Add filter', disabled: true }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
1137
1212
|
position: 'relative',
|
|
1138
1213
|
...(openPopover === 'AddFilterPopover' && { top: 12 }),
|
|
1139
1214
|
}, children: (0, jsx_runtime_1.jsx)(PopoverComponent, { isOpen: openPopover === 'AddFilterPopover', setIsOpen: (isOpen) => {
|
|
1140
1215
|
if (!isOpen) {
|
|
1141
|
-
setIsPending(false);
|
|
1142
1216
|
setActivePath(null);
|
|
1143
1217
|
setOpenPopover(null);
|
|
1144
1218
|
setTimeout(() => {
|
|
@@ -1149,9 +1223,8 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
1149
1223
|
}, popoverTitle: 'Add filter', popoverChildren: (0, jsx_runtime_1.jsx)(FilterModal_1.default, { schema: schemaData.schema.find((s) => s.name === currentTable ||
|
|
1150
1224
|
s.displayName === currentTable) ?? schemaData.schema[0], fieldValuesMap: uniqueValues[(0, ast_1.getTableNames)(baseAst).length === 1
|
|
1151
1225
|
? (0, ast_1.getTableNames)(baseAst)[0]
|
|
1152
|
-
: initialTableName], onSubmitFilter: (filter) => {
|
|
1226
|
+
: initialTableName], fieldValuesMapIsLoading: uniqueValuesIsLoading, onSubmitFilter: (filter) => {
|
|
1153
1227
|
setOpenPopover(null);
|
|
1154
|
-
setIsPending(false);
|
|
1155
1228
|
const item = (0, astFilterProcessing_1.filterToAst)(filter, client.databaseType.toLowerCase());
|
|
1156
1229
|
handleInsertion(item, 'AND', false);
|
|
1157
1230
|
}, onDeleteFilter: () => { }, ButtonComponent: ButtonComponent, SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, SecondaryButtonComponent: SecondaryButtonComponent, MultiSelectComponent: MultiSelectComponent }) }) })] })] }), (0, jsx_runtime_1.jsxs)("div", { style: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(SidebarHeadingComponent, { label: "Pivot" }), (0, jsx_runtime_1.jsx)(PivotModal_1.PivotModal, { pivotRowField: pivotRowField, setPivotRowField: setPivotRowField, pivotColumnField: pivotColumnField, setPivotColumnField: setPivotColumnField, pivotValueField: pivotValueField, setPivotValueField: setPivotValueField, pivotAggregation: pivotAggregation, setPivotAggregation: setPivotAggregation, createdPivots: createdPivots, setCreatedPivots: setCreatedPivots, recommendedPivots: recommendedPivots, setRecommendedPivots: setRecommendedPivots, popUpTitle: pivotPopUpTitle, setPopUpTitle: setPivotPopUpTitle, selectedTable: initialTableName, CardComponent: CardComponent, SelectComponent: SelectComponent, ButtonComponent: ButtonComponent, PopoverComponent: PopoverComponent, TextComponent: TextComponent, ErrorMessageComponent: ErrorMessageComponent, PivotRowContainer: PivotRowContainer, PivotColumnContainer: PivotColumnContainer, LoadingComponent: LoadingComponent, isOpen: showPivotPopover, setIsOpen: setShowPivotPopover, showUpdatePivot: isEditingPivot, setShowUpdatePivot: setIsEditingPivot, parentRef: parentRef, data: rows, columns: columns, triggerButtonText: 'Add pivot', selectedPivotIndex: selectedPivotIndex, setSelectedPivotIndex: setSelectedPivotIndex, removePivot: () => {
|
|
@@ -1163,14 +1236,14 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
1163
1236
|
// TODOs
|
|
1164
1237
|
selectPivot: () => {
|
|
1165
1238
|
return;
|
|
1166
|
-
}, selectPivotOnEdit: true, showTrigger: !pivot, theme: theme, LabelComponent: LabelComponent, HeaderComponent: HeaderComponent, dateRange: undefined, pivotCountRequest: 4, SecondaryButtonComponent: SecondaryButtonComponent, query: activeQuery, initialUniqueValues: uniqueValues[currentTable], disabled:
|
|
1239
|
+
}, selectPivotOnEdit: true, showTrigger: !pivot, theme: theme, LabelComponent: LabelComponent, HeaderComponent: HeaderComponent, dateRange: undefined, pivotCountRequest: 4, SecondaryButtonComponent: SecondaryButtonComponent, query: activeQuery, initialUniqueValues: uniqueValues[currentTable], disabled: true, pivotRecommendationsEnabled: pivotRecommendationsEnabledState, report: tempReport ?? reportInfo }), pivot && ((0, jsx_runtime_1.jsx)(PivotForm_1.default, { columns: columns, uniqueValues: uniqueValues[currentTable], uniqueValuesIsLoading: uniqueValuesIsLoading, setPivotRowField: (value) => {
|
|
1167
1240
|
setPivotRowField(value);
|
|
1168
1241
|
}, setPivotColumnField: setPivotColumnField, setPivotValueField: setPivotValueField, setPivotAggregation: setPivotAggregation, pivotRowField: pivotRowField, pivotColumnField: pivotColumnField, pivotValueField: pivotValueField, pivotAggregation: pivotAggregation, onDelete: () => {
|
|
1169
1242
|
setPivot(null);
|
|
1170
1243
|
setPivotData([]);
|
|
1171
1244
|
const formattedRows = formatRows(rows, columns, false);
|
|
1172
1245
|
setFormattedRows(formattedRows);
|
|
1173
|
-
}, SecondaryButtonComponent: SecondaryButtonComponent, SelectComponent: SelectComponent, PivotColumnContainer: PivotColumnContainer }))] }), (0, jsx_runtime_1.jsxs)("div", { style: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(SidebarHeadingComponent, { label: "Sort" }), pivot && pivot.sort && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
1246
|
+
}, isLoading: tableLoading, SecondaryButtonComponent: SecondaryButtonComponent, SelectComponent: SelectComponent, PivotColumnContainer: PivotColumnContainer }))] }), (0, jsx_runtime_1.jsxs)("div", { style: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(SidebarHeadingComponent, { label: "Sort" }), pivot && pivot.sort && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
1174
1247
|
display: 'flex',
|
|
1175
1248
|
flexDirection: 'column',
|
|
1176
1249
|
gap: 8,
|
|
@@ -1178,7 +1251,7 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
1178
1251
|
}, children: (0, jsx_runtime_1.jsx)(AddSortPopover_1.SortSentence, { sortData: {
|
|
1179
1252
|
type: pivot.sortDirection,
|
|
1180
1253
|
expr: { type: 'column_ref', column: pivot.sortField },
|
|
1181
|
-
}, columns: selectedColumns, setIsPending:
|
|
1254
|
+
}, columns: selectedColumns, setIsPending: () => { }, setEditPopoverKey: () => { }, setActiveEditItem: setActiveEditItem, setActivePath: setActivePath, setOpenPopover: setOpenPopover, SortPopover: SortPopoverComponent, EditPopover: AddSortPopover_1.AddSortPopover, handleDelete: () => {
|
|
1182
1255
|
setPivot({ ...pivot, sort: false });
|
|
1183
1256
|
setBaseAst((0, util_1.deepCopy)(baseAst));
|
|
1184
1257
|
if (!pivot) {
|
|
@@ -1206,7 +1279,6 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
1206
1279
|
gap: 8,
|
|
1207
1280
|
marginBottom: 12,
|
|
1208
1281
|
}, children: baseAst.orderby.map((sortData, id) => ((0, jsx_runtime_1.jsx)(AddSortPopover_1.SortSentence, { sortData: sortData, columns: selectedColumns, onSave: (column, direction) => {
|
|
1209
|
-
setIsPending(false);
|
|
1210
1282
|
setActiveEditItem(null);
|
|
1211
1283
|
setOpenPopover(null);
|
|
1212
1284
|
if (column === '')
|
|
@@ -1227,14 +1299,14 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
1227
1299
|
if (!pivot) {
|
|
1228
1300
|
fetchSqlQuery(newAst);
|
|
1229
1301
|
}
|
|
1230
|
-
}, setIsPending:
|
|
1302
|
+
}, setIsPending: () => { }, setEditPopoverKey: () => { }, setActiveEditItem: setActiveEditItem, setActivePath: setActivePath, setOpenPopover: setOpenPopover, SortPopover: SortPopoverComponent, EditPopover: AddSortPopover_1.AddSortPopover, handleDelete: () => {
|
|
1231
1303
|
const newAst = { ...baseAst };
|
|
1232
1304
|
newAst.orderby.splice(id, 1);
|
|
1233
1305
|
setBaseAst((0, util_1.deepCopy)(newAst));
|
|
1234
1306
|
if (!pivot) {
|
|
1235
1307
|
fetchSqlQuery(newAst);
|
|
1236
1308
|
}
|
|
1237
|
-
}, Select: SelectComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent }, `sort-sentence-${id}`))) })), (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: () => {
|
|
1309
|
+
}, Select: SelectComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent, disabled: true }, `sort-sentence-${id}`))) })), (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: () => {
|
|
1238
1310
|
if (!selectedColumns ||
|
|
1239
1311
|
selectedColumns.length === 0 ||
|
|
1240
1312
|
loading) {
|
|
@@ -1243,9 +1315,8 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
1243
1315
|
if (!openPopover) {
|
|
1244
1316
|
setOpenPopover('AddSortPopover');
|
|
1245
1317
|
}
|
|
1246
|
-
}, label: "Add sort" }), (0, jsx_runtime_1.jsx)(PopoverComponent, { isOpen: openPopover === 'AddSortPopover', setIsOpen: (isOpen) => {
|
|
1318
|
+
}, label: "Add sort", disabled: true }), (0, jsx_runtime_1.jsx)(PopoverComponent, { isOpen: openPopover === 'AddSortPopover', setIsOpen: (isOpen) => {
|
|
1247
1319
|
if (!isOpen) {
|
|
1248
|
-
setIsPending(false);
|
|
1249
1320
|
setActiveEditItem(null);
|
|
1250
1321
|
setActivePath(null);
|
|
1251
1322
|
setOpenPopover(null);
|
|
@@ -1274,7 +1345,7 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
1274
1345
|
setOpenPopover(null);
|
|
1275
1346
|
setBaseAst((0, util_1.deepCopy)(newAst));
|
|
1276
1347
|
fetchSqlQuery(newAst);
|
|
1277
|
-
}, TextInput: TextInputComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent }) })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: () => {
|
|
1348
|
+
}, TextInput: TextInputComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent, disabled: true }) })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: () => {
|
|
1278
1349
|
if (!selectedColumns ||
|
|
1279
1350
|
selectedColumns.length === 0 ||
|
|
1280
1351
|
loading) {
|
|
@@ -1283,9 +1354,8 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
1283
1354
|
if (!openPopover) {
|
|
1284
1355
|
setOpenPopover('AddLimitPopover');
|
|
1285
1356
|
}
|
|
1286
|
-
}, label: 'Add limit' }), (0, jsx_runtime_1.jsx)(PopoverComponent, { isOpen: openPopover === 'AddLimitPopover', setIsOpen: (isOpen) => {
|
|
1357
|
+
}, label: 'Add limit', disabled: true }), (0, jsx_runtime_1.jsx)(PopoverComponent, { isOpen: openPopover === 'AddLimitPopover', setIsOpen: (isOpen) => {
|
|
1287
1358
|
if (!isOpen) {
|
|
1288
|
-
setIsPending(false);
|
|
1289
1359
|
setActiveEditItem(null);
|
|
1290
1360
|
setActivePath(null);
|
|
1291
1361
|
setOpenPopover(null);
|
|
@@ -1332,7 +1402,6 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
1332
1402
|
if (!isOpen) {
|
|
1333
1403
|
// delay onClose callback so onClick no-ops
|
|
1334
1404
|
setTimeout(() => {
|
|
1335
|
-
setIsPending(false);
|
|
1336
1405
|
setActiveEditItem(null);
|
|
1337
1406
|
setActivePath(null);
|
|
1338
1407
|
setOpenPopover(null);
|
|
@@ -1376,7 +1445,6 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
1376
1445
|
}
|
|
1377
1446
|
setOpenPopover('AddFilterPopover');
|
|
1378
1447
|
setActivePath('');
|
|
1379
|
-
setIsPending(true);
|
|
1380
1448
|
}
|
|
1381
1449
|
}, label: 'Add filter' }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
1382
1450
|
position: 'relative',
|
|
@@ -1386,16 +1454,14 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
1386
1454
|
// delay onClose callback so onClick no-ops
|
|
1387
1455
|
setOpenPopover(null);
|
|
1388
1456
|
setTimeout(() => {
|
|
1389
|
-
setIsPending(false);
|
|
1390
1457
|
setActivePath(null);
|
|
1391
1458
|
clearCheckboxes();
|
|
1392
1459
|
setActiveEditItem(null);
|
|
1393
1460
|
}, 300);
|
|
1394
1461
|
}
|
|
1395
1462
|
}, popoverTitle: "Add filter", popoverChildren: (0, jsx_runtime_1.jsx)(FilterModal_1.default, { schema: schemaData.schema.find((s) => s.name === currentTable ||
|
|
1396
|
-
s.displayName === currentTable) ?? schemaData.schema[0], fieldValuesMap: fieldValuesMap, onSubmitFilter: (filter) => {
|
|
1463
|
+
s.displayName === currentTable) ?? schemaData.schema[0], fieldValuesMap: fieldValuesMap, fieldValuesMapIsLoading: uniqueValuesIsLoading, onSubmitFilter: (filter) => {
|
|
1397
1464
|
setOpenPopover(null);
|
|
1398
|
-
setIsPending(false);
|
|
1399
1465
|
const item = (0, astFilterProcessing_1.filterToAst)(filter, client.databaseType.toLowerCase());
|
|
1400
1466
|
handleInsertion(item, 'AND', false);
|
|
1401
1467
|
}, onDeleteFilter: () => { }, ButtonComponent: ButtonComponent, SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, MultiSelectComponent: MultiSelectComponent }) }) })] })] }), (0, jsx_runtime_1.jsxs)("div", { style: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(SidebarHeadingComponent, { label: "Pivot" }), (0, jsx_runtime_1.jsx)(PivotModal_1.PivotModal, { pivotRowField: pivotRowField, setPivotRowField: setPivotRowField, pivotColumnField: pivotColumnField, setPivotColumnField: setPivotColumnField, pivotValueField: pivotValueField, setPivotValueField: setPivotValueField, pivotAggregation: pivotAggregation, setPivotAggregation: setPivotAggregation, createdPivots: createdPivots, setCreatedPivots: setCreatedPivots, recommendedPivots: recommendedPivots, setRecommendedPivots: setRecommendedPivots, popUpTitle: pivotPopUpTitle, setPopUpTitle: setPivotPopUpTitle, selectedTable: initialTableName, SelectComponent: SelectComponent, ButtonComponent: ButtonComponent, CardComponent: CardComponent, SecondaryButtonComponent: SecondaryButtonComponent, PopoverComponent: PopoverComponent, TextComponent: TextComponent, ErrorMessageComponent: ErrorMessageComponent, PivotRowContainer: PivotRowContainer, PivotColumnContainer: PivotColumnContainer, LoadingComponent: LoadingComponent, isOpen: showPivotPopover, setIsOpen: setShowPivotPopover, showUpdatePivot: isEditingPivot, setShowUpdatePivot: setIsEditingPivot, parentRef: parentRef, data: rows, columns: columns, triggerButtonText: 'Add pivot', selectedPivotIndex: selectedPivotIndex, setSelectedPivotIndex: setSelectedPivotIndex, removePivot: () => {
|
|
@@ -1403,29 +1469,32 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
1403
1469
|
setPivotData(null);
|
|
1404
1470
|
const formattedRows = formatRows(rows, columns, false);
|
|
1405
1471
|
setFormattedRows(formattedRows);
|
|
1406
|
-
}, selectPivot: async (
|
|
1407
|
-
if (!
|
|
1472
|
+
}, selectPivot: async (selectedPivot, uniqueValues, dateRange, pivotTable) => {
|
|
1473
|
+
if (!selectedPivot)
|
|
1408
1474
|
return;
|
|
1409
1475
|
const newAst = { ...baseAst };
|
|
1410
1476
|
newAst.orderby = null;
|
|
1411
|
-
if (
|
|
1412
|
-
|
|
1413
|
-
|
|
1477
|
+
if (selectedPivot.rowFieldType === 'date') {
|
|
1478
|
+
selectedPivot['sort'] = true;
|
|
1479
|
+
selectedPivot['sortDirection'] = 'ASC';
|
|
1414
1480
|
}
|
|
1415
1481
|
setBaseAst(newAst); // trigger refetch
|
|
1416
1482
|
let dateBucket = undefined;
|
|
1417
1483
|
if (dateRange) {
|
|
1418
1484
|
dateBucket = (0, dates_1.getDateBucketFromRange)(dateRange);
|
|
1419
1485
|
}
|
|
1486
|
+
setPivot(selectedPivot);
|
|
1420
1487
|
if (!pivotTable) {
|
|
1421
|
-
|
|
1488
|
+
setTableLoading(true);
|
|
1489
|
+
pivotTable = await (0, PivotModal_1.generatePivotTable)(selectedPivot, rows, undefined, false, -1, undefined, dateBucket, tempReport, client, uniqueValues);
|
|
1422
1490
|
}
|
|
1491
|
+
// no other calls made
|
|
1423
1492
|
setPivotData(pivotTable || []);
|
|
1424
|
-
|
|
1425
|
-
const formattedRows = formatRows(pivotTable.rows, columns, true, pivot.aggregationType);
|
|
1493
|
+
const formattedRows = formatRows(pivotTable.rows, columns, true, selectedPivot.aggregationType);
|
|
1426
1494
|
setFormattedRows(formattedRows);
|
|
1427
1495
|
setErrorMessage('');
|
|
1428
|
-
|
|
1496
|
+
setTableLoading(false); // only set to false if this was the final call
|
|
1497
|
+
}, selectPivotOnEdit: true, showTrigger: !pivot, theme: theme, LabelComponent: LabelComponent, HeaderComponent: HeaderComponent, dateRange: undefined, pivotCountRequest: 4, query: activeQuery, initialUniqueValues: uniqueValues[currentTable], uniqueValuesIsLoading: uniqueValuesIsLoading, disabled: !baseAst || !dataDisplayed || tableLoading, pivotRecommendationsEnabled: pivotRecommendationsEnabledState, report: tempReport }), pivot && ((0, jsx_runtime_1.jsx)(PivotForm_1.default, { columns: columns, uniqueValues: uniqueValues[currentTable], uniqueValuesIsLoading: uniqueValuesIsLoading, setPivotRowField: (value) => {
|
|
1429
1498
|
setPivotRowField(value);
|
|
1430
1499
|
updatePivot(value, 'rowField');
|
|
1431
1500
|
}, setPivotColumnField: (value) => {
|
|
@@ -1442,7 +1511,7 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
1442
1511
|
setPivotData([]);
|
|
1443
1512
|
const formattedRows = formatRows(rows, columns, false);
|
|
1444
1513
|
setFormattedRows(formattedRows);
|
|
1445
|
-
}, pivotRowField: pivotRowField, pivotColumnField: pivotColumnField, pivotValueField: pivotValueField, pivotAggregation: pivotAggregation, SecondaryButtonComponent: SecondaryButtonComponent, SelectComponent: SelectComponent, PivotColumnContainer: PivotColumnContainer }))] }), (0, jsx_runtime_1.jsxs)("div", { style: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(SidebarHeadingComponent, { label: "Sort" }), pivot && pivot.sort && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
1514
|
+
}, isLoading: tableLoading, pivotRowField: pivotRowField, pivotColumnField: pivotColumnField, pivotValueField: pivotValueField, pivotAggregation: pivotAggregation, SecondaryButtonComponent: SecondaryButtonComponent, SelectComponent: SelectComponent, PivotColumnContainer: PivotColumnContainer }))] }), (0, jsx_runtime_1.jsxs)("div", { style: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(SidebarHeadingComponent, { label: "Sort" }), pivot && pivot.sort && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
1446
1515
|
display: 'flex',
|
|
1447
1516
|
flexDirection: 'column',
|
|
1448
1517
|
gap: 8,
|
|
@@ -1457,7 +1526,7 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
1457
1526
|
`.${pivot.rowField}`,
|
|
1458
1527
|
`.${pivot.valueField || 'count'}`,
|
|
1459
1528
|
]
|
|
1460
|
-
: selectedColumns, setIsPending:
|
|
1529
|
+
: selectedColumns, setIsPending: () => { }, setEditPopoverKey: () => { }, setActiveEditItem: setActiveEditItem, setActivePath: setActivePath, setOpenPopover: setOpenPopover, SortPopover: SortPopoverComponent, EditPopover: AddSortPopover_1.AddSortPopover, handleDelete: async () => {
|
|
1461
1530
|
if (pivot) {
|
|
1462
1531
|
const tempPivot = { ...pivot, sort: false };
|
|
1463
1532
|
let dateBucket = undefined;
|
|
@@ -1512,7 +1581,7 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
1512
1581
|
flexDirection: 'column',
|
|
1513
1582
|
gap: 8,
|
|
1514
1583
|
marginBottom: 12,
|
|
1515
|
-
}, children: baseAst.orderby.map((sortData, id) => ((0, jsx_runtime_1.jsx)(AddSortPopover_1.SortSentence, { sortData: sortData, columns: selectedColumns, setIsPending:
|
|
1584
|
+
}, children: baseAst.orderby.map((sortData, id) => ((0, jsx_runtime_1.jsx)(AddSortPopover_1.SortSentence, { sortData: sortData, columns: selectedColumns, setIsPending: () => { }, setEditPopoverKey: () => { }, setActiveEditItem: setActiveEditItem, setActivePath: setActivePath, setOpenPopover: setOpenPopover, SortPopover: SortPopoverComponent, EditPopover: AddSortPopover_1.AddSortPopover, handleDelete: () => {
|
|
1516
1585
|
if (pivot) {
|
|
1517
1586
|
setPivot({ ...pivot, sort: false });
|
|
1518
1587
|
return;
|
|
@@ -1535,7 +1604,6 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
1535
1604
|
});
|
|
1536
1605
|
return;
|
|
1537
1606
|
}
|
|
1538
|
-
setIsPending(false);
|
|
1539
1607
|
setActiveEditItem(null);
|
|
1540
1608
|
setOpenPopover(null);
|
|
1541
1609
|
if (column === '')
|
|
@@ -1566,7 +1634,6 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
1566
1634
|
...(openPopover === 'AddSortPopover' && { top: 12 }),
|
|
1567
1635
|
}, children: (0, jsx_runtime_1.jsx)(PopoverComponent, { isOpen: openPopover === 'AddSortPopover', setIsOpen: (isOpen) => {
|
|
1568
1636
|
if (!isOpen) {
|
|
1569
|
-
setIsPending(false);
|
|
1570
1637
|
setActiveEditItem(null);
|
|
1571
1638
|
setActivePath(null);
|
|
1572
1639
|
setOpenPopover(null);
|
|
@@ -1661,7 +1728,6 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
1661
1728
|
...(openPopover === 'AddLimitPopover' && { top: 12 }),
|
|
1662
1729
|
}, children: (0, jsx_runtime_1.jsx)(PopoverComponent, { isOpen: openPopover === 'AddLimitPopover', setIsOpen: (isOpen) => {
|
|
1663
1730
|
if (!isOpen) {
|
|
1664
|
-
setIsPending(false);
|
|
1665
1731
|
setActiveEditItem(null);
|
|
1666
1732
|
setActivePath(null);
|
|
1667
1733
|
setOpenPopover(null);
|
|
@@ -1695,9 +1761,10 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
1695
1761
|
? 'Ask a follow-up question...'
|
|
1696
1762
|
: 'Ask a question...' }), (0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: () => {
|
|
1697
1763
|
fetchAstFromPromptHelper();
|
|
1698
|
-
}, label: 'Ask AI' }), ((baseAst && dataDisplayed) || initialLoad) && !reportId && ((0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { label: 'New report', onClick: clearAllState }))] }) })), baseAst && ((0, jsx_runtime_1.jsx)(TableComponent, { isLoading:
|
|
1699
|
-
(
|
|
1700
|
-
|
|
1764
|
+
}, label: 'Ask AI' }), ((baseAst && dataDisplayed) || initialLoad) && !reportId && ((0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { label: 'New report', onClick: clearAllState }))] }) })), baseAst && ((0, jsx_runtime_1.jsx)(TableComponent, { isLoading: !isAddLoading &&
|
|
1765
|
+
(tableLoading ||
|
|
1766
|
+
(loading && errorMessage.length === 0) ||
|
|
1767
|
+
initialChartLoad), rows: formattedRows, rowCount: pivot ? undefined : numberOfRows, rowCountIsLoading: rowCountIsLoading, rowsPerPage: 20, columns: pivot
|
|
1701
1768
|
? pivotData?.columns || emptyPivotColumns()
|
|
1702
1769
|
: enforceOrderOnColumns(Object.keys(rows[0] ?? {})).map((c) => {
|
|
1703
1770
|
return {
|
|
@@ -1721,13 +1788,17 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
1721
1788
|
alignItems: 'center',
|
|
1722
1789
|
}, children: [(0, jsx_runtime_1.jsx)(ErrorMessageComponent, { errorMessage: errorMessage }), (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: () => {
|
|
1723
1790
|
fetchAstFromPromptHelper();
|
|
1724
|
-
}, label: 'Retry' })] })) : ((0, jsx_runtime_1.jsx)("div", { style: { width: '100%' } })), baseAst && dataDisplayed && !initialChartLoad && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [onDiscardChanges && ((0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: onDiscardChanges, label: "Discard changes" })), !hideCopySQL && ((0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { label: isCopying ? 'Copied' : 'Copy SQL', onClick: () => copySQLToClipboard() })), (0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: () => {
|
|
1791
|
+
}, label: 'Retry' })] })) : ((0, jsx_runtime_1.jsx)("div", { style: { width: '100%' } })), baseAst && dataDisplayed && !initialChartLoad && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [onDiscardChanges && ((0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: onDiscardChanges, label: "Discard changes" })), !hideCopySQL && ((0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { label: isCopying ? 'Copied' : 'Copy SQL', onClick: () => copySQLToClipboard() })), (0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: async () => {
|
|
1792
|
+
setIsAddLoading(true);
|
|
1793
|
+
await handleRunQuery(currentProcessing, true);
|
|
1794
|
+
setIsAddLoading(false);
|
|
1725
1795
|
onSaveChanges && onSaveChanges();
|
|
1726
1796
|
setIsChartBuilderOpen(true);
|
|
1727
|
-
}, disabled: !!errorMessage, label: reportId ? 'Save changes' : 'Add to dashboard' })] }))] })] }), (0, jsx_runtime_1.jsx)("style", { children: `body{margin:0;}` })] })), (!isChartBuilderHorizontalView || isChartBuilderOpen) && ((0, jsx_runtime_1.jsx)(ChartBuilder_1.ChartBuilderWithModal, { report: reportInfo
|
|
1797
|
+
}, disabled: !!errorMessage, label: reportId ? 'Save changes' : 'Add to dashboard', isLoading: isAddLoading })] }))] })] }), (0, jsx_runtime_1.jsx)("style", { children: `body{margin:0;}` })] })), (!isChartBuilderHorizontalView || isChartBuilderOpen) && ((0, jsx_runtime_1.jsx)(ChartBuilder_1.ChartBuilderWithModal, { report: reportInfo
|
|
1728
1798
|
? {
|
|
1729
1799
|
...reportInfo,
|
|
1730
1800
|
...tempReport,
|
|
1801
|
+
filtersApplied: dashboardFilters.filter((f) => f && destinationDashboard === f.dashboardName),
|
|
1731
1802
|
pivot: pivot,
|
|
1732
1803
|
yAxisFields: reportInfo.pivot && !pivot ? [] : reportInfo.yAxisFields,
|
|
1733
1804
|
columns: reportInfo.columns.filter((col) => {
|
|
@@ -1738,6 +1809,9 @@ SidebarComponent = ui_1.QuillSidebar, ContainerComponent = ui_1.CustomContainer,
|
|
|
1738
1809
|
queryString: activeQuery,
|
|
1739
1810
|
rows: rows,
|
|
1740
1811
|
}
|
|
1741
|
-
:
|
|
1812
|
+
: {
|
|
1813
|
+
...tempReport,
|
|
1814
|
+
filtersApplied: dashboardFilters.filter((f) => f && destinationDashboard === f.dashboardName),
|
|
1815
|
+
}, 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], initialUniqueValuesIsLoading: uniqueValuesIsLoading, pivotRecommendationsEnabled: pivotRecommendationsEnabledState, 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, onFilterPreviewChange: onFilterPreviewChange, isLoading: tableLoading || isAddLoading, isEditingMode: true }))] }));
|
|
1742
1816
|
}
|
|
1743
1817
|
exports.default = ReportBuilder;
|