@quillsql/react 2.13.7 → 2.13.9
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 +5 -5
- package/dist/cjs/Chart.d.ts.map +1 -1
- package/dist/cjs/Chart.js +19 -8
- package/dist/cjs/ChartBuilder.d.ts +1 -1
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +58 -93
- package/dist/cjs/ChartEditor.js +1 -1
- package/dist/cjs/Context.d.ts +9 -8
- package/dist/cjs/Context.d.ts.map +1 -1
- package/dist/cjs/Context.js +119 -34
- package/dist/cjs/Dashboard.d.ts +20 -8
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/Dashboard.js +68 -58
- package/dist/cjs/DateRangePicker/QuillDateRangePicker.d.ts +2 -2
- package/dist/cjs/DateRangePicker/QuillDateRangePicker.d.ts.map +1 -1
- package/dist/cjs/DateRangePicker/QuillDateRangePicker.js +1 -2
- package/dist/cjs/DateRangePicker/dateRangePickerUtils.d.ts +20 -20
- package/dist/cjs/DateRangePicker/dateRangePickerUtils.d.ts.map +1 -1
- package/dist/cjs/DateRangePicker/dateRangePickerUtils.js +64 -52
- package/dist/cjs/ReportBuilder.d.ts +2 -1
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +339 -339
- package/dist/cjs/SQLEditor.d.ts +1 -1
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +30 -18
- package/dist/cjs/components/Banner/index.d.ts +0 -1
- package/dist/cjs/components/Banner/index.d.ts.map +1 -1
- package/dist/cjs/components/Banner/index.js +1 -1
- package/dist/cjs/components/Chart/BarChart.d.ts +0 -1
- package/dist/cjs/components/Chart/BarChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/BarChart.js +1 -1
- package/dist/cjs/components/Chart/BarList.js +1 -2
- package/dist/cjs/components/Chart/ChartError.js +2 -3
- package/dist/cjs/components/Chart/ChartSkeleton.js +1 -1
- package/dist/cjs/components/Chart/ChartTooltip.js +1 -1
- package/dist/cjs/components/Chart/ChartTooltipFrame.d.ts +0 -1
- package/dist/cjs/components/Chart/ChartTooltipFrame.d.ts.map +1 -1
- package/dist/cjs/components/Chart/ChartTooltipFrame.js +1 -1
- package/dist/cjs/components/Chart/ChartTooltipGroup.js +1 -1
- package/dist/cjs/components/Chart/ChartTooltipRow.js +1 -1
- package/dist/cjs/components/Chart/LineChart.d.ts +0 -1
- package/dist/cjs/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/LineChart.js +1 -1
- package/dist/cjs/components/Chart/PieChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/PieChart.js +18 -9
- package/dist/cjs/components/Dashboard/ChartComponent.d.ts +0 -1
- package/dist/cjs/components/Dashboard/ChartComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/ChartComponent.js +1 -1
- package/dist/cjs/components/Dashboard/DashboardFilter.d.ts +10 -2
- package/dist/cjs/components/Dashboard/DashboardFilter.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DashboardFilter.js +9 -23
- package/dist/cjs/components/Dashboard/DashboardSection.d.ts +0 -1
- package/dist/cjs/components/Dashboard/DashboardSection.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DashboardSection.js +1 -1
- package/dist/cjs/components/Dashboard/DashboardSectionContainer.d.ts +0 -1
- package/dist/cjs/components/Dashboard/DashboardSectionContainer.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DashboardSectionContainer.js +1 -1
- package/dist/cjs/components/Dashboard/DashboardTemplate.js +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.d.ts +9 -7
- package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.js +104 -61
- package/dist/cjs/components/Dashboard/MetricComponent.d.ts +0 -1
- package/dist/cjs/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/MetricComponent.js +3 -3
- package/dist/cjs/components/Dashboard/TableComponent.d.ts +0 -1
- package/dist/cjs/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/TableComponent.js +1 -1
- package/dist/cjs/components/Dashboard/TemplateChartComponent.d.ts +0 -1
- package/dist/cjs/components/Dashboard/TemplateChartComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/TemplateChartComponent.js +1 -1
- package/dist/cjs/components/Dashboard/TemplateMetricComponent.d.ts +0 -1
- package/dist/cjs/components/Dashboard/TemplateMetricComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/TemplateMetricComponent.js +1 -1
- package/dist/cjs/components/Dashboard/TemplateTableComponent.d.ts +0 -1
- package/dist/cjs/components/Dashboard/TemplateTableComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/TemplateTableComponent.js +1 -1
- package/dist/cjs/components/Dashboard/util.js +2 -3
- package/dist/cjs/components/QuillCard.js +1 -2
- package/dist/cjs/components/QuillMultiSelect.d.ts.map +1 -1
- package/dist/cjs/components/QuillMultiSelect.js +21 -20
- package/dist/cjs/components/QuillMultiSelectWithCombo.d.ts.map +1 -1
- package/dist/cjs/components/QuillMultiSelectWithCombo.js +172 -70
- package/dist/cjs/components/QuillSelect.d.ts.map +1 -1
- package/dist/cjs/components/QuillSelect.js +9 -8
- package/dist/cjs/components/QuillSelectWithCombo.d.ts.map +1 -1
- package/dist/cjs/components/QuillSelectWithCombo.js +26 -12
- package/dist/cjs/components/QuillTable.d.ts +5 -1
- package/dist/cjs/components/QuillTable.d.ts.map +1 -1
- package/dist/cjs/components/QuillTable.js +5 -3
- package/dist/cjs/components/ReportBuilder/AddColumnModal.js +1 -1
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.d.ts +2 -3
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts +5 -6
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/FilterModal.d.ts +3 -4
- package/dist/cjs/components/ReportBuilder/FilterModal.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/FilterModal.js +45 -39
- package/dist/cjs/components/ReportBuilder/FilterStack.js +1 -1
- package/dist/cjs/components/ReportBuilder/ast.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/ast.js +2 -2
- package/dist/cjs/components/ReportBuilder/convert.js +11 -12
- package/dist/cjs/components/ReportBuilder/postgres.js +4 -4
- package/dist/cjs/components/ReportBuilder/ui.d.ts +3 -3
- package/dist/cjs/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/util.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/util.js +21 -23
- package/dist/cjs/components/UiComponents.d.ts +14 -12
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +41 -17
- package/dist/cjs/components/selectUtils.js +3 -3
- package/dist/cjs/contexts/BaseColorContext.d.ts +0 -1
- package/dist/cjs/contexts/BaseColorContext.d.ts.map +1 -1
- package/dist/cjs/contexts/RootStylesContext.d.ts +0 -1
- package/dist/cjs/contexts/RootStylesContext.d.ts.map +1 -1
- package/dist/cjs/contexts/SelectedValueContext.d.ts +0 -1
- package/dist/cjs/contexts/SelectedValueContext.d.ts.map +1 -1
- package/dist/cjs/hooks/useAskQuill.d.ts +2 -2
- package/dist/cjs/hooks/useAskQuill.d.ts.map +1 -1
- package/dist/cjs/hooks/useAskQuill.js +11 -11
- package/dist/cjs/hooks/useAstToFilterTree.d.ts.map +1 -1
- package/dist/cjs/hooks/useDashboard.d.ts +8 -7
- package/dist/cjs/hooks/useDashboard.d.ts.map +1 -1
- package/dist/cjs/hooks/useDashboard.js +47 -31
- package/dist/cjs/hooks/useExport.d.ts +3 -4
- package/dist/cjs/hooks/useExport.d.ts.map +1 -1
- package/dist/cjs/hooks/useExport.js +6 -2
- package/dist/cjs/hooks/useInternalState.d.ts +1 -2
- package/dist/cjs/hooks/useInternalState.d.ts.map +1 -1
- package/dist/cjs/hooks/useOnClickOutside.d.ts +3 -1
- package/dist/cjs/hooks/useOnClickOutside.d.ts.map +1 -1
- package/dist/cjs/hooks/useQuill.d.ts +0 -14
- package/dist/cjs/hooks/useQuill.d.ts.map +1 -1
- package/dist/cjs/hooks/useQuill.js +17 -55
- package/dist/cjs/hooks/useSelectOnKeyDown.d.ts.map +1 -1
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +7 -2
- package/dist/cjs/internals/ReportBuilder/PivotForm.d.ts +4 -1
- package/dist/cjs/internals/ReportBuilder/PivotForm.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotForm.js +32 -7
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts +17 -13
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.js +368 -162
- package/dist/cjs/lib/utils.d.ts +0 -1
- package/dist/cjs/lib/utils.d.ts.map +1 -1
- package/dist/cjs/lib/utils.js +2 -2
- package/dist/cjs/models/Filter.d.ts +49 -30
- package/dist/cjs/models/Filter.d.ts.map +1 -1
- package/dist/cjs/models/Filter.js +125 -52
- package/dist/cjs/models/Pivot.d.ts +3 -1
- package/dist/cjs/models/Pivot.d.ts.map +1 -1
- package/dist/cjs/models/Report.d.ts +2 -2
- package/dist/cjs/models/Report.d.ts.map +1 -1
- package/dist/cjs/utils/astFilterProcessing.d.ts +4 -4
- package/dist/cjs/utils/astFilterProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/astFilterProcessing.js +3839 -3427
- package/dist/cjs/utils/astProcessing.d.ts +12 -3
- package/dist/cjs/utils/astProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/astProcessing.js +76 -11
- package/dist/cjs/utils/client.js +2 -2
- package/dist/cjs/utils/color.js +5 -6
- package/dist/cjs/utils/columnProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/columnProcessing.js +7 -7
- package/dist/cjs/utils/crypto.js +1 -2
- package/dist/cjs/utils/dashboard.d.ts.map +1 -1
- package/dist/cjs/utils/dashboard.js +34 -30
- package/dist/cjs/utils/dataFetcher.js +3 -4
- package/dist/cjs/utils/dataProcessing.js +2 -2
- package/dist/cjs/utils/dates.d.ts +4 -1
- package/dist/cjs/utils/dates.d.ts.map +1 -1
- package/dist/cjs/utils/dates.js +12 -10
- package/dist/cjs/utils/errorProcessing.js +1 -2
- package/dist/cjs/utils/filterProcessing.d.ts +3 -3
- package/dist/cjs/utils/filterProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/filterProcessing.js +30 -27
- package/dist/cjs/utils/getDomain.js +1 -1
- package/dist/cjs/utils/logging.js +1 -2
- package/dist/cjs/utils/merge.d.ts +1 -1
- package/dist/cjs/utils/merge.d.ts.map +1 -1
- package/dist/cjs/utils/merge.js +15 -11
- package/dist/cjs/utils/monacoConfig.js +3 -3
- package/dist/cjs/utils/paginationProcessing.js +3 -3
- package/dist/cjs/utils/pivotConstructor.d.ts +4 -4
- package/dist/cjs/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/pivotConstructor.js +104 -127
- package/dist/cjs/utils/pivotProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/pivotProcessing.js +14 -16
- package/dist/cjs/utils/queryConstructor.d.ts +2 -2
- package/dist/cjs/utils/queryConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/queryConstructor.js +344 -78
- package/dist/cjs/utils/report.d.ts.map +1 -1
- package/dist/cjs/utils/report.js +22 -12
- package/dist/cjs/utils/schema.d.ts.map +1 -1
- package/dist/cjs/utils/styles.js +1 -2
- package/dist/cjs/utils/tableProcessing.d.ts +12 -12
- package/dist/cjs/utils/tableProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/tableProcessing.js +69 -26
- package/dist/cjs/utils/textProcessing.js +5 -6
- package/dist/cjs/utils/validation.d.ts.map +1 -1
- package/dist/cjs/utils/validation.js +3 -1
- package/dist/cjs/utils/valueFormatter.d.ts +1 -0
- package/dist/cjs/utils/valueFormatter.d.ts.map +1 -1
- package/dist/cjs/utils/valueFormatter.js +2 -0
- package/dist/cjs/utils/width.d.ts.map +1 -1
- package/dist/esm/Chart.d.ts +5 -5
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +15 -4
- package/dist/esm/ChartBuilder.d.ts +1 -1
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +52 -87
- package/dist/esm/Context.d.ts +9 -8
- package/dist/esm/Context.d.ts.map +1 -1
- package/dist/esm/Context.js +119 -34
- package/dist/esm/Dashboard.d.ts +20 -8
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/Dashboard.js +68 -58
- package/dist/esm/DateRangePicker/QuillDateRangePicker.d.ts +2 -2
- package/dist/esm/DateRangePicker/QuillDateRangePicker.d.ts.map +1 -1
- package/dist/esm/DateRangePicker/dateRangePickerUtils.d.ts +20 -20
- package/dist/esm/DateRangePicker/dateRangePickerUtils.d.ts.map +1 -1
- package/dist/esm/DateRangePicker/dateRangePickerUtils.js +64 -52
- package/dist/esm/ReportBuilder.d.ts +2 -1
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +343 -343
- package/dist/esm/SQLEditor.d.ts +1 -1
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +29 -17
- package/dist/esm/components/Banner/index.d.ts +0 -1
- package/dist/esm/components/Banner/index.d.ts.map +1 -1
- package/dist/esm/components/Chart/BarChart.d.ts +0 -1
- package/dist/esm/components/Chart/BarChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/ChartTooltipFrame.d.ts +0 -1
- package/dist/esm/components/Chart/ChartTooltipFrame.d.ts.map +1 -1
- package/dist/esm/components/Chart/LineChart.d.ts +0 -1
- package/dist/esm/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/PieChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/PieChart.js +18 -9
- package/dist/esm/components/Dashboard/ChartComponent.d.ts +0 -1
- package/dist/esm/components/Dashboard/ChartComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DashboardFilter.d.ts +10 -2
- package/dist/esm/components/Dashboard/DashboardFilter.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DashboardFilter.js +8 -21
- package/dist/esm/components/Dashboard/DashboardSection.d.ts +0 -1
- package/dist/esm/components/Dashboard/DashboardSection.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DashboardSectionContainer.d.ts +0 -1
- package/dist/esm/components/Dashboard/DashboardSectionContainer.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.d.ts +9 -7
- package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.js +102 -62
- package/dist/esm/components/Dashboard/MetricComponent.d.ts +0 -1
- package/dist/esm/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/MetricComponent.js +2 -2
- package/dist/esm/components/Dashboard/TableComponent.d.ts +0 -1
- package/dist/esm/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/TemplateChartComponent.d.ts +0 -1
- package/dist/esm/components/Dashboard/TemplateChartComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/TemplateMetricComponent.d.ts +0 -1
- package/dist/esm/components/Dashboard/TemplateMetricComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/TemplateTableComponent.d.ts +0 -1
- package/dist/esm/components/Dashboard/TemplateTableComponent.d.ts.map +1 -1
- package/dist/esm/components/QuillMultiSelect.d.ts.map +1 -1
- package/dist/esm/components/QuillMultiSelect.js +19 -18
- package/dist/esm/components/QuillMultiSelectWithCombo.d.ts.map +1 -1
- package/dist/esm/components/QuillMultiSelectWithCombo.js +171 -69
- package/dist/esm/components/QuillSelect.d.ts.map +1 -1
- package/dist/esm/components/QuillSelect.js +8 -6
- package/dist/esm/components/QuillSelectWithCombo.d.ts.map +1 -1
- package/dist/esm/components/QuillSelectWithCombo.js +25 -10
- package/dist/esm/components/QuillTable.d.ts +5 -1
- package/dist/esm/components/QuillTable.d.ts.map +1 -1
- package/dist/esm/components/QuillTable.js +4 -2
- package/dist/esm/components/ReportBuilder/AddLimitPopover.d.ts +2 -3
- package/dist/esm/components/ReportBuilder/AddLimitPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts +5 -6
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/FilterModal.d.ts +3 -4
- package/dist/esm/components/ReportBuilder/FilterModal.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/FilterModal.js +46 -40
- package/dist/esm/components/ReportBuilder/ast.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/ui.d.ts +3 -3
- package/dist/esm/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/util.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/util.js +0 -2
- package/dist/esm/components/UiComponents.d.ts +14 -12
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +37 -14
- package/dist/esm/contexts/BaseColorContext.d.ts +0 -1
- package/dist/esm/contexts/BaseColorContext.d.ts.map +1 -1
- package/dist/esm/contexts/RootStylesContext.d.ts +0 -1
- package/dist/esm/contexts/RootStylesContext.d.ts.map +1 -1
- package/dist/esm/contexts/SelectedValueContext.d.ts +0 -1
- package/dist/esm/contexts/SelectedValueContext.d.ts.map +1 -1
- package/dist/esm/hooks/useAskQuill.d.ts +2 -2
- package/dist/esm/hooks/useAskQuill.d.ts.map +1 -1
- package/dist/esm/hooks/useAskQuill.js +12 -12
- package/dist/esm/hooks/useAstToFilterTree.d.ts.map +1 -1
- package/dist/esm/hooks/useDashboard.d.ts +8 -7
- package/dist/esm/hooks/useDashboard.d.ts.map +1 -1
- package/dist/esm/hooks/useDashboard.js +48 -32
- package/dist/esm/hooks/useExport.d.ts +3 -4
- package/dist/esm/hooks/useExport.d.ts.map +1 -1
- package/dist/esm/hooks/useExport.js +6 -2
- package/dist/esm/hooks/useInternalState.d.ts +1 -2
- package/dist/esm/hooks/useInternalState.d.ts.map +1 -1
- package/dist/esm/hooks/useOnClickOutside.d.ts +3 -1
- package/dist/esm/hooks/useOnClickOutside.d.ts.map +1 -1
- package/dist/esm/hooks/useQuill.d.ts +0 -14
- package/dist/esm/hooks/useQuill.d.ts.map +1 -1
- package/dist/esm/hooks/useQuill.js +16 -53
- package/dist/esm/hooks/useSelectOnKeyDown.d.ts.map +1 -1
- 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/PivotForm.d.ts +4 -1
- package/dist/esm/internals/ReportBuilder/PivotForm.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotForm.js +32 -7
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts +17 -13
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.js +364 -158
- package/dist/esm/lib/utils.d.ts +0 -1
- package/dist/esm/lib/utils.d.ts.map +1 -1
- package/dist/esm/models/Filter.d.ts +49 -30
- package/dist/esm/models/Filter.d.ts.map +1 -1
- package/dist/esm/models/Filter.js +123 -50
- package/dist/esm/models/Pivot.d.ts +3 -1
- package/dist/esm/models/Pivot.d.ts.map +1 -1
- package/dist/esm/models/Report.d.ts +2 -2
- package/dist/esm/models/Report.d.ts.map +1 -1
- package/dist/esm/utils/astFilterProcessing.d.ts +4 -4
- package/dist/esm/utils/astFilterProcessing.d.ts.map +1 -1
- package/dist/esm/utils/astFilterProcessing.js +3835 -3423
- package/dist/esm/utils/astProcessing.d.ts +12 -3
- package/dist/esm/utils/astProcessing.d.ts.map +1 -1
- package/dist/esm/utils/astProcessing.js +64 -0
- package/dist/esm/utils/columnProcessing.d.ts.map +1 -1
- package/dist/esm/utils/columnProcessing.js +1 -1
- package/dist/esm/utils/dashboard.d.ts.map +1 -1
- package/dist/esm/utils/dashboard.js +31 -26
- package/dist/esm/utils/dates.d.ts +4 -1
- package/dist/esm/utils/dates.d.ts.map +1 -1
- package/dist/esm/utils/dates.js +6 -3
- package/dist/esm/utils/filterProcessing.d.ts +3 -3
- package/dist/esm/utils/filterProcessing.d.ts.map +1 -1
- package/dist/esm/utils/filterProcessing.js +22 -19
- package/dist/esm/utils/merge.d.ts +1 -1
- package/dist/esm/utils/merge.d.ts.map +1 -1
- package/dist/esm/utils/merge.js +14 -9
- package/dist/esm/utils/pivotConstructor.d.ts +4 -4
- package/dist/esm/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/esm/utils/pivotConstructor.js +103 -125
- package/dist/esm/utils/pivotProcessing.d.ts.map +1 -1
- package/dist/esm/utils/pivotProcessing.js +9 -11
- package/dist/esm/utils/queryConstructor.d.ts +2 -2
- package/dist/esm/utils/queryConstructor.d.ts.map +1 -1
- package/dist/esm/utils/queryConstructor.js +338 -71
- package/dist/esm/utils/report.d.ts.map +1 -1
- package/dist/esm/utils/report.js +18 -8
- package/dist/esm/utils/schema.d.ts.map +1 -1
- package/dist/esm/utils/tableProcessing.d.ts +12 -12
- package/dist/esm/utils/tableProcessing.d.ts.map +1 -1
- package/dist/esm/utils/tableProcessing.js +69 -26
- package/dist/esm/utils/validation.d.ts.map +1 -1
- package/dist/esm/utils/validation.js +3 -1
- package/dist/esm/utils/valueFormatter.d.ts +1 -0
- package/dist/esm/utils/valueFormatter.d.ts.map +1 -1
- package/dist/esm/utils/valueFormatter.js +2 -1
- package/dist/esm/utils/width.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useContext, useEffect, useMemo, useRef, useState, } from 'react';
|
|
3
|
-
import { MemoizedButton, MemoizedDeleteButton, MemoizedHeader, MemoizedLabel, MemoizedSecondaryButton, MemoizedText, MemoizedPopover, QuillTabs, MemoizedModal, QuillChartBuilderInputRowContainer, QuillChartBuilderInputColumnContainer, MemoizedSubHeader, QuillErrorMessageComponent, QuillPivotRowContainer, QuillPivotColumnContainer, QuillColumnSearchEmptyState, QuillChartBuilderFormContainer, QuillLoadingComponent,
|
|
3
|
+
import { MemoizedButton, MemoizedDeleteButton, MemoizedHeader, MemoizedLabel, MemoizedSecondaryButton, MemoizedText, MemoizedPopover, QuillTabs, MemoizedModal, QuillChartBuilderInputRowContainer, QuillChartBuilderInputColumnContainer, MemoizedSubHeader, QuillErrorMessageComponent, QuillPivotRowContainer, QuillPivotColumnContainer, QuillColumnSearchEmptyState, QuillChartBuilderFormContainer, QuillLoadingComponent, QuillTableReportBuilderComponent, } 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';
|
|
@@ -21,11 +21,11 @@ import { updateFirstChildWidth } from './utils/width';
|
|
|
21
21
|
import { QuillSelectComponent } from './components/QuillSelect';
|
|
22
22
|
import { QuillCard } from './components/QuillCard';
|
|
23
23
|
import { DATE_FORMAT_TYPES, quillFormat } from './utils/valueFormatter';
|
|
24
|
-
import { pivotToSql } from './utils/pivotProcessing';
|
|
25
|
-
import { getUniqueValuesByColumns,
|
|
26
|
-
import { fetchAndProcessASTFromPrompt, fetchASTFromQuillReport, getAllPossibleColumns, } from './utils/astProcessing';
|
|
24
|
+
import { getPossiblePivotFieldOptions, isValidPivot, pivotToSql, } from './utils/pivotProcessing';
|
|
25
|
+
import { getUniqueValuesByColumns, getQueryDateRangeByColumns, fetchResultsByQuery, getUniqueStringValues, fetchTableByAST, } from './utils/tableProcessing';
|
|
26
|
+
import { createBasicSelectASTFromColumns, fetchAndProcessASTFromPrompt, fetchASTFromQuillReport, getAllPossibleColumns, } from './utils/astProcessing';
|
|
27
27
|
import PivotForm from './internals/ReportBuilder/PivotForm';
|
|
28
|
-
import { getDateBucketFromRange } from './utils/dates';
|
|
28
|
+
import { getDateBucketFromRange, getDateFormatFromBucket } from './utils/dates';
|
|
29
29
|
import FilterModal from './components/ReportBuilder/FilterModal';
|
|
30
30
|
import { astToFilterTree, filterToAst, filterTreeToAst, } from './utils/astFilterProcessing';
|
|
31
31
|
import useAstToFilterTree from './hooks/useAstToFilterTree';
|
|
@@ -67,7 +67,7 @@ import { QUILL_SERVER } from './utils/constants';
|
|
|
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, onDiscardChanges = undefined, onSaveChanges = undefined, onCloseChartBuilder = undefined, destinationDashboard = undefined, organizationName = '', ButtonComponent = MemoizedButton, SecondaryButtonComponent = MemoizedSecondaryButton, DeleteButtonComponent = MemoizedDeleteButton, ModalComponent = MemoizedModal, TextInputComponent = QuillTextInput, SelectComponent = QuillSelectComponent, MultiSelectComponent = QuillMultiSelectComponentWithCombo, TableComponent =
|
|
70
|
+
export default function ReportBuilder({ initialTableName = '', onSubmitEditReport = () => void null, onSubmitCreateReport = () => void null, onDiscardChanges = undefined, onSaveChanges = undefined, onCloseChartBuilder = undefined, destinationDashboard = undefined, organizationName = '', ButtonComponent = MemoizedButton, SecondaryButtonComponent = MemoizedSecondaryButton, DeleteButtonComponent = MemoizedDeleteButton, ModalComponent = MemoizedModal, TextInputComponent = QuillTextInput, SelectComponent = QuillSelectComponent, MultiSelectComponent = QuillMultiSelectComponentWithCombo, TableComponent = QuillTableReportBuilderComponent, 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);
|
|
@@ -95,10 +95,11 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
95
95
|
const [openPopover, setOpenPopover] = useState(null);
|
|
96
96
|
const [loading, setLoading] = useState(!!initialTableName);
|
|
97
97
|
const [isChartBuilderOpen, setIsChartBuilderOpen] = useState(false);
|
|
98
|
-
const [isAddLoading, setIsAddLoading] = useState(false);
|
|
99
98
|
const [isCopying, setIsCopying] = useState(false);
|
|
100
99
|
const [dataDisplayed, setDataDisplayed] = useState(false);
|
|
101
100
|
const [rows, setRows] = useState([]);
|
|
101
|
+
const [filteredRows, setFilteredRows] = useState([]);
|
|
102
|
+
const [chartBuilderInFilteredPreview, setChartBuilderInFilteredPreview] = useState(true);
|
|
102
103
|
const [formattedRows, setFormattedRows] = useState([]);
|
|
103
104
|
const [columns, setColumns] = useState([]);
|
|
104
105
|
const [tempReport, setTempReport] = useState(EMPTY_INTERNAL_REPORT);
|
|
@@ -111,8 +112,8 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
111
112
|
const [pivotPopUpTitle, setPivotPopUpTitle] = useState('Add pivot');
|
|
112
113
|
const [showPivotPopover, setShowPivotPopover] = useState(false);
|
|
113
114
|
const [isEditingPivot, setIsEditingPivot] = useState(false);
|
|
114
|
-
const [initialChartLoad, setInitialChartLoad] = useState(false);
|
|
115
115
|
const [askedAQuestion, setAskedAQuestion] = useState(false);
|
|
116
|
+
const [askAILoading, setAskAILoading] = useState(false);
|
|
116
117
|
const [selectedPivotIndex, setSelectedPivotIndex] = useState(-1);
|
|
117
118
|
const [initialLoad, setInitialLoad] = useState(!!initialTableName || !!reportId);
|
|
118
119
|
const [currentTable, setCurrentTable] = useState(initialTableName || '');
|
|
@@ -125,9 +126,14 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
125
126
|
const [pivotRowField, setPivotRowField] = useState(undefined);
|
|
126
127
|
const [pivotColumnField, setPivotColumnField] = useState(undefined);
|
|
127
128
|
const [pivotValueField, setPivotValueField] = useState(undefined);
|
|
129
|
+
const [pivotValueField2, setPivotValueField2] = useState(undefined);
|
|
128
130
|
const [pivotAggregation, setPivotAggregation] = useState(undefined);
|
|
131
|
+
const [pivotHint, setPivotHint] = useState('');
|
|
132
|
+
/* eslint-disable-next-line */
|
|
133
|
+
const [pivotError, setPivotError] = useState(undefined);
|
|
129
134
|
const [dateRanges, setDateRanges] = useState(null);
|
|
130
135
|
const [client] = useContext(ClientContext);
|
|
136
|
+
const [currentOrganizationId, setCurrentOrganizationId] = useState(client.organizationId);
|
|
131
137
|
const [fieldValuesMap, setFieldValuesMap] = useState({}); // Mapping of unique values per field, used in string filter 'in' and 'not in'
|
|
132
138
|
const [globalUniqueValues, setGlobalUniqueValues] = useState({});
|
|
133
139
|
const [globalUniqueValuesIsLoading, setGlobalUniqueValuesIsLoading] = useState(false);
|
|
@@ -139,6 +145,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
139
145
|
rowsPerPage: 20,
|
|
140
146
|
rowsPerRequest: 1000,
|
|
141
147
|
};
|
|
148
|
+
const [unresolvedReportMessage, setUnresolvedReportMessage] = useState('');
|
|
142
149
|
useEffect(() => {
|
|
143
150
|
if (!client) {
|
|
144
151
|
return;
|
|
@@ -212,6 +219,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
212
219
|
}
|
|
213
220
|
let distinctValuesForQuery = {};
|
|
214
221
|
setPivot(newPivot);
|
|
222
|
+
setPivotHint('');
|
|
215
223
|
if (newPivot.columnField) {
|
|
216
224
|
distinctValuesForQuery = await getUniqueValuesByColumns([
|
|
217
225
|
{
|
|
@@ -221,11 +229,25 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
221
229
|
},
|
|
222
230
|
], activeQuery, [], client, schemaData.customFields ?? []);
|
|
223
231
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
232
|
+
try {
|
|
233
|
+
const pivotedData = await generatePivotTable({
|
|
234
|
+
pivot: newPivot,
|
|
235
|
+
dateBucket,
|
|
236
|
+
report: tempReport,
|
|
237
|
+
client,
|
|
238
|
+
uniqueValues: distinctValuesForQuery,
|
|
239
|
+
});
|
|
240
|
+
setPivotData(pivotedData || []);
|
|
241
|
+
const formattedRows = formatRows(pivotedData.rows, columns, true, newPivot.aggregationType);
|
|
242
|
+
setFormattedRows(formattedRows);
|
|
243
|
+
}
|
|
244
|
+
catch (e) {
|
|
245
|
+
if (e instanceof Error)
|
|
246
|
+
setPivotError(e.message);
|
|
247
|
+
}
|
|
248
|
+
finally {
|
|
249
|
+
setTableLoading(false);
|
|
250
|
+
}
|
|
229
251
|
};
|
|
230
252
|
const enforceOrderOnColumns = (columnNames) => {
|
|
231
253
|
if (pivot) {
|
|
@@ -257,11 +279,13 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
257
279
|
setLoading(false);
|
|
258
280
|
setDataDisplayed(false);
|
|
259
281
|
setRows([]);
|
|
282
|
+
setFilteredRows([]);
|
|
260
283
|
setColumns([]);
|
|
261
284
|
setErrorMessage('');
|
|
262
285
|
setFormattedRows([]);
|
|
263
286
|
// setUniqueValues({});
|
|
264
287
|
setPivot(null);
|
|
288
|
+
setPivotHint('');
|
|
265
289
|
setPivotData(null);
|
|
266
290
|
setRecommendedPivots([]);
|
|
267
291
|
}, 0);
|
|
@@ -281,7 +305,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
281
305
|
uniqueValuesDependenciesRef.current = { client, columns, currentTable };
|
|
282
306
|
}
|
|
283
307
|
}, [client, columns, currentTable, memoizedFetchGlobalUniqueValues]);
|
|
284
|
-
const formatRows = (rows, columns, pivot, aggregationType) => {
|
|
308
|
+
const formatRows = (rows, columns, pivot, aggregationType, dateBucket) => {
|
|
285
309
|
const copiedRows = deepCopy(rows);
|
|
286
310
|
if (pivot) {
|
|
287
311
|
const formattedRows = copiedRows.map((row) => {
|
|
@@ -297,7 +321,9 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
297
321
|
}
|
|
298
322
|
else {
|
|
299
323
|
format = DATE_FORMAT_TYPES.includes(column.format)
|
|
300
|
-
?
|
|
324
|
+
? dateBucket
|
|
325
|
+
? getDateFormatFromBucket(dateBucket)
|
|
326
|
+
: 'MMM_yyyy'
|
|
301
327
|
: 'string';
|
|
302
328
|
}
|
|
303
329
|
const formattedValue = quillFormat({
|
|
@@ -369,6 +395,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
369
395
|
});
|
|
370
396
|
const data = await response.json();
|
|
371
397
|
setActiveQuery(data.query);
|
|
398
|
+
fetchFilteredRows(data.query);
|
|
372
399
|
if (fetchData) {
|
|
373
400
|
fetchReportFromASTHelper(ast, formData);
|
|
374
401
|
}
|
|
@@ -389,7 +416,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
389
416
|
const dateColumnNames = dateColumns.map((column) => {
|
|
390
417
|
return column.field;
|
|
391
418
|
});
|
|
392
|
-
const dateRanges = await
|
|
419
|
+
const dateRanges = await getQueryDateRangeByColumns(dateColumns, `Select ${dateColumnNames.join(', ')} from ${tableName}`, client, schemaData.customFields ?? []);
|
|
393
420
|
return dateRanges;
|
|
394
421
|
};
|
|
395
422
|
// It's just like getColumnsInPivot but we expand the columnField
|
|
@@ -497,10 +524,13 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
497
524
|
setActiveQuery(query);
|
|
498
525
|
}
|
|
499
526
|
catch (err) {
|
|
500
|
-
|
|
527
|
+
console.error(err);
|
|
528
|
+
setErrorMessage('Error when loading chart');
|
|
501
529
|
}
|
|
502
530
|
};
|
|
503
|
-
|
|
531
|
+
if (reportId) {
|
|
532
|
+
loadChart();
|
|
533
|
+
}
|
|
504
534
|
}, [dashboard[reportId || '']]);
|
|
505
535
|
useEffect(() => {
|
|
506
536
|
onSchemaChange();
|
|
@@ -732,7 +762,8 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
732
762
|
setPreviousPage(0);
|
|
733
763
|
};
|
|
734
764
|
const onFilterPreviewChange = (preview) => {
|
|
735
|
-
|
|
765
|
+
setChartBuilderInFilteredPreview(preview);
|
|
766
|
+
// handleRunQuery(currentProcessing, true, preview);
|
|
736
767
|
};
|
|
737
768
|
const fetchRowCount = async (processing, includeFilters) => {
|
|
738
769
|
if (!client || !activeQuery) {
|
|
@@ -744,6 +775,11 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
744
775
|
: undefined, false, true);
|
|
745
776
|
if (tableInfo.rowCount) {
|
|
746
777
|
setNumberOfRows(tableInfo.rowCount);
|
|
778
|
+
// @ts-ignore
|
|
779
|
+
setTempReport((tempReport) => ({
|
|
780
|
+
...tempReport,
|
|
781
|
+
rowCount: tableInfo.rowCount,
|
|
782
|
+
}));
|
|
747
783
|
}
|
|
748
784
|
setRowCountIsLoading(false);
|
|
749
785
|
};
|
|
@@ -752,33 +788,52 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
752
788
|
const tableData = await fetchTableByAST({ ...ast, where }, client, { page: REPORT_BUILDER_PAGINATION }, undefined, false, true);
|
|
753
789
|
if (tableData.rowCount) {
|
|
754
790
|
setNumberOfRows(tableData.rowCount);
|
|
791
|
+
// @ts-ignore
|
|
792
|
+
setTempReport((tempReport) => ({
|
|
793
|
+
...tempReport,
|
|
794
|
+
rowCount: tableData.rowCount,
|
|
795
|
+
}));
|
|
755
796
|
}
|
|
756
797
|
setRowCountIsLoading(false);
|
|
757
798
|
};
|
|
799
|
+
const fetchFilteredRows = async (query) => {
|
|
800
|
+
const filteredTableInfo = await fetchResultsByQuery(query, client, currentProcessing, schemaData.customFields, specificDashboardFilters, tempReport.dateField, true);
|
|
801
|
+
if (filteredTableInfo.error) {
|
|
802
|
+
throw new Error(filteredTableInfo.error);
|
|
803
|
+
}
|
|
804
|
+
setFilteredRows([...filteredRows, ...filteredTableInfo.rows]);
|
|
805
|
+
};
|
|
758
806
|
const handleRunQuery = async (processing, resetRows = false, includeFilters = false) => {
|
|
759
807
|
try {
|
|
760
808
|
setErrorMessage('');
|
|
761
809
|
setTableLoading(true);
|
|
762
|
-
const tableInfo = await fetchResultsByQuery(activeQuery, client, processing, schemaData.customFields,
|
|
810
|
+
const tableInfo = await fetchResultsByQuery(activeQuery, client, processing, schemaData.customFields, undefined, undefined, true);
|
|
811
|
+
const filteredTableInfo = await fetchResultsByQuery(activeQuery, client, processing, schemaData.customFields, specificDashboardFilters, tempReport.dateField, true);
|
|
763
812
|
if (tableInfo.error) {
|
|
764
813
|
throw new Error(tableInfo.error);
|
|
765
814
|
}
|
|
815
|
+
else if (filteredTableInfo.error) {
|
|
816
|
+
throw new Error(filteredTableInfo.error);
|
|
817
|
+
}
|
|
766
818
|
else if (tableInfo.rows.length === 0) {
|
|
767
819
|
throw new Error('No data found');
|
|
768
820
|
}
|
|
769
821
|
fetchRowCount(processing, includeFilters);
|
|
770
822
|
setCurrentProcessing(processing);
|
|
771
823
|
let tempRows = [...rows, ...tableInfo.rows];
|
|
824
|
+
let tempFilteredRows = [...filteredRows, ...filteredTableInfo.rows];
|
|
772
825
|
if (resetRows) {
|
|
773
826
|
tempRows = tableInfo.rows;
|
|
827
|
+
tempFilteredRows = filteredTableInfo.rows;
|
|
774
828
|
}
|
|
775
829
|
setRows(tempRows);
|
|
830
|
+
setFilteredRows(tempFilteredRows);
|
|
776
831
|
setFormattedRows(formatRowsFromReport({ rows: tempRows, columns: tableInfo.columns }));
|
|
777
|
-
setTempReport({
|
|
832
|
+
setTempReport((tempReport) => ({
|
|
778
833
|
...tempReport,
|
|
779
834
|
rows: tempRows,
|
|
780
835
|
rowCount: tableInfo.rowCount ?? tempReport.rowCount,
|
|
781
|
-
});
|
|
836
|
+
}));
|
|
782
837
|
setColumns(tableInfo.columns);
|
|
783
838
|
setTableLoading(false);
|
|
784
839
|
}
|
|
@@ -786,6 +841,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
786
841
|
setTableLoading(false);
|
|
787
842
|
setErrorMessage('Failed to run SQL query: ' + e.message);
|
|
788
843
|
setRows([]);
|
|
844
|
+
setFilteredRows([]);
|
|
789
845
|
setColumns([]);
|
|
790
846
|
return;
|
|
791
847
|
}
|
|
@@ -814,12 +870,13 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
814
870
|
as: null,
|
|
815
871
|
});
|
|
816
872
|
const updateUniqueValue = (uniqueStrings, table) => {
|
|
817
|
-
const uniqueStringsObj = {};
|
|
873
|
+
const uniqueStringsObj = uniqueValues ?? {};
|
|
818
874
|
uniqueStringsObj[table] = uniqueStrings ?? {};
|
|
819
875
|
setUniqueValues(uniqueStringsObj);
|
|
820
876
|
updateFieldValuesMap(uniqueStringsObj, table);
|
|
877
|
+
return uniqueStringsObj;
|
|
821
878
|
};
|
|
822
|
-
const fetchReportFromASTHelper = async (baseAst, newFormData, curPivot, curSchema, previousReport) => {
|
|
879
|
+
const fetchReportFromASTHelper = async (baseAst, newFormData, curPivot, curSchema, previousReport, keepPivotHint = false) => {
|
|
823
880
|
const curFormData = newFormData !== undefined ? newFormData : formData;
|
|
824
881
|
let reportBuilderInfo = undefined;
|
|
825
882
|
try {
|
|
@@ -843,6 +900,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
843
900
|
setErrorMessage('Failed to fetch');
|
|
844
901
|
return;
|
|
845
902
|
}
|
|
903
|
+
setTempReport(reportBuilderInfo.report);
|
|
846
904
|
fetchRowCountFromAST(baseAst, curFormData);
|
|
847
905
|
const reportTable = reportBuilderInfo.table;
|
|
848
906
|
const reportBuilderInfoColumns = reportBuilderInfo.columns.map((column) => {
|
|
@@ -850,39 +908,105 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
850
908
|
});
|
|
851
909
|
const prevFormData = formData;
|
|
852
910
|
const prevTable = currentTable;
|
|
911
|
+
const prevOrganization = currentOrganizationId;
|
|
853
912
|
setRows(reportBuilderInfo.rows);
|
|
854
|
-
|
|
855
|
-
|
|
913
|
+
setFilteredRows(reportBuilderInfo.rows);
|
|
914
|
+
if (!(client.databaseType.toLowerCase() === 'bigquery') ||
|
|
915
|
+
(reportBuilderInfo.rows && reportBuilderInfo.rows.length > 0)) {
|
|
916
|
+
setColumns(reportBuilderInfo.columns);
|
|
917
|
+
setSelectedColumns(reportBuilderInfoColumns);
|
|
918
|
+
}
|
|
919
|
+
setNumberOfRows(reportBuilderInfo.rowCount);
|
|
856
920
|
setPivot(reportBuilderInfo.pivot);
|
|
921
|
+
if (!keepPivotHint) {
|
|
922
|
+
setPivotHint('');
|
|
923
|
+
}
|
|
857
924
|
setPivotData(reportBuilderInfo.pivotData);
|
|
858
925
|
setDateRanges(reportBuilderInfo.dateRanges);
|
|
859
926
|
setFormattedRows(reportBuilderInfo.formattedRows);
|
|
860
|
-
setTempReport(reportBuilderInfo.report);
|
|
861
|
-
setSelectedColumns(reportBuilderInfoColumns);
|
|
862
|
-
setLoading(false);
|
|
863
927
|
setDataDisplayed(true);
|
|
864
928
|
setCurrentTable(reportBuilderInfo.table);
|
|
929
|
+
setCurrentOrganizationId(client.organizationId);
|
|
865
930
|
setFormData(curFormData);
|
|
866
931
|
if (reportBuilderInfo.pivot) {
|
|
867
932
|
setPivotRowField(reportBuilderInfo.pivot.rowField);
|
|
868
933
|
setPivotAggregation(reportBuilderInfo.pivot.aggregationType);
|
|
869
934
|
setPivotColumnField(reportBuilderInfo.pivot.columnField);
|
|
870
935
|
setPivotValueField(reportBuilderInfo.pivot.valueField);
|
|
936
|
+
setPivotValueField2(reportBuilderInfo.pivot.valueField2);
|
|
937
|
+
}
|
|
938
|
+
else {
|
|
939
|
+
setLoading(false);
|
|
871
940
|
}
|
|
872
941
|
setReportInfo(reportBuilderInfo.report);
|
|
873
942
|
// fetch unique values after everything else since it is the most expensive
|
|
874
943
|
if (prevTable !== reportBuilderInfo.table ||
|
|
875
|
-
!equal(prevFormData, curFormData)
|
|
944
|
+
!equal(prevFormData, curFormData) ||
|
|
945
|
+
prevOrganization !== client.organizationId) {
|
|
876
946
|
try {
|
|
877
947
|
setUniqueValuesIsLoading(true);
|
|
948
|
+
if (reportBuilderInfo.pivot) {
|
|
949
|
+
setUnresolvedReportMessage('Processing pivot selection options...');
|
|
950
|
+
}
|
|
878
951
|
const schema = curSchema ?? schemaData.schema;
|
|
879
952
|
const tableInfo = schema.find((tableInfo) => tableInfo.name === reportBuilderInfo?.table);
|
|
880
953
|
if (!reportBuilderInfo.table || !tableInfo) {
|
|
881
954
|
throw new Error('No table found;');
|
|
882
955
|
}
|
|
883
|
-
|
|
884
|
-
|
|
956
|
+
let query = reportBuilderInfo.query;
|
|
957
|
+
if (!query) {
|
|
958
|
+
const queryResult = await fetchSqlQuery({
|
|
959
|
+
...createBasicSelectASTFromColumns(tableInfo.columns, reportBuilderInfo.table),
|
|
960
|
+
where: curFormData,
|
|
961
|
+
}, curFormData, false);
|
|
962
|
+
if (queryResult.error) {
|
|
963
|
+
console.error(queryResult.error);
|
|
964
|
+
}
|
|
965
|
+
else {
|
|
966
|
+
query = queryResult.query;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
const uniqueStrings = await getUniqueStringValues(tableInfo.columns, reportBuilderInfo.table, client, schemaData.customFields, undefined, true, query);
|
|
970
|
+
const newUnique = updateUniqueValue(uniqueStrings, reportBuilderInfo.table);
|
|
971
|
+
let pivotChanged = false;
|
|
972
|
+
let newPivot;
|
|
973
|
+
if (reportBuilderInfo.pivot &&
|
|
974
|
+
!isValidPivotForReport(reportBuilderInfo.pivot, newUnique)) {
|
|
975
|
+
// try flipping row and column field
|
|
976
|
+
newPivot = {
|
|
977
|
+
...reportBuilderInfo.pivot,
|
|
978
|
+
rowField: reportBuilderInfo.pivot.columnField,
|
|
979
|
+
columnField: reportBuilderInfo.pivot.rowField,
|
|
980
|
+
};
|
|
981
|
+
if (isValidPivotForReport(newPivot, newUnique)) {
|
|
982
|
+
setPivot(newPivot);
|
|
983
|
+
pivotChanged = true;
|
|
984
|
+
setPivotHint('Flipped pivot row and column fields to maintain validity');
|
|
985
|
+
}
|
|
986
|
+
else if (isValidPivotForReport({ ...reportBuilderInfo.pivot, columnField: undefined }, newUnique)) {
|
|
987
|
+
// try removing column field
|
|
988
|
+
newPivot = {
|
|
989
|
+
...reportBuilderInfo.pivot,
|
|
990
|
+
columnField: undefined,
|
|
991
|
+
};
|
|
992
|
+
setPivot(newPivot);
|
|
993
|
+
pivotChanged = true;
|
|
994
|
+
setPivotHint('Removed column field to maintain validity');
|
|
995
|
+
}
|
|
996
|
+
else {
|
|
997
|
+
setUnresolvedReportMessage('Not a valid pivot');
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
else {
|
|
1001
|
+
setUnresolvedReportMessage('');
|
|
1002
|
+
}
|
|
885
1003
|
setUniqueValuesIsLoading(false);
|
|
1004
|
+
if (pivotChanged) {
|
|
1005
|
+
fetchReportFromASTHelper(baseAst, curFormData, newPivot, curSchema, previousReport, true);
|
|
1006
|
+
}
|
|
1007
|
+
else {
|
|
1008
|
+
setLoading(false);
|
|
1009
|
+
}
|
|
886
1010
|
}
|
|
887
1011
|
catch (err) {
|
|
888
1012
|
if (err instanceof Error) {
|
|
@@ -905,6 +1029,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
905
1029
|
}
|
|
906
1030
|
try {
|
|
907
1031
|
setLoading(true);
|
|
1032
|
+
setAskAILoading(true);
|
|
908
1033
|
astInfo = await fetchAndProcessASTFromPrompt(prompt, schemaData.schema, client, pivot, activeQuery);
|
|
909
1034
|
if (astInfo.error) {
|
|
910
1035
|
throw new Error(astInfo.error);
|
|
@@ -913,10 +1038,16 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
913
1038
|
catch (err) {
|
|
914
1039
|
if (err instanceof Error) {
|
|
915
1040
|
setErrorMessage(err.message);
|
|
916
|
-
setLoading(false);
|
|
917
1041
|
}
|
|
1042
|
+
setLoading(false);
|
|
1043
|
+
setAskAILoading(false);
|
|
918
1044
|
return;
|
|
919
1045
|
}
|
|
1046
|
+
// check if pivot works with ReportBuilder constraints
|
|
1047
|
+
if (astInfo.pivot && !isValidPivotForReport(astInfo.pivot)) {
|
|
1048
|
+
astInfo.pivot = null;
|
|
1049
|
+
astInfo.ast.groupby = null;
|
|
1050
|
+
}
|
|
920
1051
|
// parse the whereAst first
|
|
921
1052
|
const filterTree = astToFilterTree(astInfo.whereAST, client.databaseType?.toLowerCase());
|
|
922
1053
|
const cleanAst = filterTree
|
|
@@ -926,8 +1057,34 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
926
1057
|
astInfo.ast.where = cleanAst;
|
|
927
1058
|
setBaseAst(astInfo.ast);
|
|
928
1059
|
fetchSqlQuery(astInfo.ast, cleanAst, false);
|
|
1060
|
+
setAskAILoading(false);
|
|
929
1061
|
await fetchReportFromASTHelper(astInfo.ast, cleanAst, astInfo.pivot);
|
|
930
1062
|
};
|
|
1063
|
+
const isValidPivotForReport = (pivot, uniqueValuesForPivot) => {
|
|
1064
|
+
if (!isValidPivot) {
|
|
1065
|
+
return false;
|
|
1066
|
+
}
|
|
1067
|
+
const uniqueValuesToCheck = uniqueValuesForPivot ?? uniqueValues;
|
|
1068
|
+
// check that pivot rows and columns
|
|
1069
|
+
const possibleOptions = getPossiblePivotFieldOptions(columns, uniqueValuesToCheck[currentTable] ?? {});
|
|
1070
|
+
if (pivot.rowField &&
|
|
1071
|
+
pivot.columnField &&
|
|
1072
|
+
pivot.rowField === pivot.columnField) {
|
|
1073
|
+
return false;
|
|
1074
|
+
}
|
|
1075
|
+
if (pivot.rowField && !possibleOptions.rowFields.includes(pivot.rowField)) {
|
|
1076
|
+
return false;
|
|
1077
|
+
}
|
|
1078
|
+
if (pivot.columnField &&
|
|
1079
|
+
!possibleOptions.columnFields.includes(pivot.columnField)) {
|
|
1080
|
+
return false;
|
|
1081
|
+
}
|
|
1082
|
+
if (pivot.valueField &&
|
|
1083
|
+
!possibleOptions.valueFields.includes(pivot.valueField)) {
|
|
1084
|
+
return false;
|
|
1085
|
+
}
|
|
1086
|
+
return true;
|
|
1087
|
+
};
|
|
931
1088
|
const handleDeleteColumn = (name) => {
|
|
932
1089
|
if (!baseAst || !baseAst.columns.length || selectedColumns.length === 1) {
|
|
933
1090
|
clearAllState();
|
|
@@ -960,7 +1117,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
960
1117
|
};
|
|
961
1118
|
return (_jsx("div", { style: { ...style }, ref: setNodeRef, children: _jsx(DraggableColumnComponent, { label: snakeAndCamelCaseToTitleCase(label), onDelete: onDelete, DragHandle: (props) => (_jsx("div", { style: {
|
|
962
1119
|
cursor: 'grab',
|
|
963
|
-
}, ...attributes, ...listeners, children: _jsx(props.dragIcon, {}) })), deleteDisabled: loading }) }));
|
|
1120
|
+
}, ...attributes, ...listeners, children: _jsx(props.dragIcon, {}) })), deleteDisabled: loading || tableLoading }) }));
|
|
964
1121
|
};
|
|
965
1122
|
function DraggableColumns() {
|
|
966
1123
|
const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, {
|
|
@@ -1037,240 +1194,6 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1037
1194
|
gap: 8,
|
|
1038
1195
|
}, children: [columnNamesInAst.map((name) => (_jsx(DraggableItem, { id: name, label: name, onDelete: () => !loading && handleDeleteColumn(name) }, name))), columnNamesInAst?.length > 0 && _jsx("div", { style: { height: 6 } })] }) }) }));
|
|
1039
1196
|
}
|
|
1040
|
-
// TODO: Refactor this part
|
|
1041
|
-
if (loading || initialChartLoad) {
|
|
1042
|
-
return (_jsxs("div", { style: {
|
|
1043
|
-
display: 'flex',
|
|
1044
|
-
flexDirection: 'row',
|
|
1045
|
-
height: '100%',
|
|
1046
|
-
...containerStyle,
|
|
1047
|
-
}, className: className, ref: parentRef, children: [_jsxs(SidebarComponent, { children: [_jsxs("div", { style: { width: '100%' }, children: [_jsx(SidebarHeadingComponent, { label: "Columns" }), _jsx(DraggableColumns, {}), _jsx(SecondaryButtonComponent, { onClick: () => {
|
|
1048
|
-
if (!openPopover) {
|
|
1049
|
-
setOpenPopover('AddColumnModal');
|
|
1050
|
-
}
|
|
1051
|
-
}, label: 'Select columns', disabled: true }), _jsx(ModalComponent, { isOpen: openPopover === 'AddColumnModal', setIsOpen: (isOpen) => {
|
|
1052
|
-
if (!isOpen) {
|
|
1053
|
-
// delay onClose callback so onClick no-ops
|
|
1054
|
-
setTimeout(() => {
|
|
1055
|
-
setActiveEditItem(null);
|
|
1056
|
-
setActivePath(null);
|
|
1057
|
-
setOpenPopover(null);
|
|
1058
|
-
}, 100);
|
|
1059
|
-
}
|
|
1060
|
-
}, title: "Select columns", children: _jsx(AddColumnModal, { onSave: () => {
|
|
1061
|
-
setActiveEditItem(null);
|
|
1062
|
-
setActivePath(null);
|
|
1063
|
-
setOpenPopover(null);
|
|
1064
|
-
}, orderedColumnNames: orderedColumnNames, setOrderedColumnNames: setOrderedColumnNames, selectedColumns: selectedColumns, setSelectedColumns: setSelectedColumns, isSelectedAllColumns: isSelectedAllColumns, clearAllState: clearAllState, nameToColumn: nameToColumn, baseAst: baseAst, setBaseAst: (ast) => {
|
|
1065
|
-
setBaseAst(ast);
|
|
1066
|
-
fetchSqlQuery(ast);
|
|
1067
|
-
}, 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: {
|
|
1068
|
-
display: 'flex',
|
|
1069
|
-
flexDirection: 'column',
|
|
1070
|
-
gap: 8,
|
|
1071
|
-
marginBottom: 12,
|
|
1072
|
-
}, children: _jsx(FilterStack, { client: client, filterStack: filterStack, filterTree: filterTree, defaultAST: defaultAST, baseAst: baseAst, setBaseAst: setBaseAst, setFormData: setFormData, fetchSqlQuery: fetchSqlQuery, schemaData: schemaData, defaultColumn: defaultColumn, defaultTable: defaultTable, currentTable: currentTable, initialTableName: initialTableName, globalUniqueValues: globalUniqueValues, globalUniqueValuesIsLoading: globalUniqueValuesIsLoading, columns: columns, removingFilter: removingFilter, setRemovingFilter: setRemovingFilter, TabsComponent: TabsComponent, FilterPopoverComponent: FilterPopoverComponent, FilterModal: FilterModal, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, MultiSelectComponent: MultiSelectComponent, actionsEnabled: false }) })), _jsxs("div", { style: {
|
|
1073
|
-
display: 'flex',
|
|
1074
|
-
flexDirection: 'column',
|
|
1075
|
-
alignItems: 'flex-start',
|
|
1076
|
-
}, children: [_jsx(SecondaryButtonComponent, { onClick: () => {
|
|
1077
|
-
if (!selectedColumns ||
|
|
1078
|
-
selectedColumns.length === 0 ||
|
|
1079
|
-
loading) {
|
|
1080
|
-
return;
|
|
1081
|
-
}
|
|
1082
|
-
if (!openPopover) {
|
|
1083
|
-
const value = orderedColumnNames[0];
|
|
1084
|
-
const column = value.split('.')[1];
|
|
1085
|
-
const columnType = getColumnTypeByName(column);
|
|
1086
|
-
if (isNumericColumnType(columnType)) {
|
|
1087
|
-
const newSubtree = deepCopy(defaultNumericComparison);
|
|
1088
|
-
newSubtree.left.column = column;
|
|
1089
|
-
setActiveEditItem(newSubtree);
|
|
1090
|
-
}
|
|
1091
|
-
else {
|
|
1092
|
-
const newSubtree = deepCopy(defaultEntry);
|
|
1093
|
-
newSubtree.left.args.value[0].column = column;
|
|
1094
|
-
setActiveEditItem(newSubtree);
|
|
1095
|
-
}
|
|
1096
|
-
setOpenPopover('AddFilterPopover');
|
|
1097
|
-
setActivePath('');
|
|
1098
|
-
}
|
|
1099
|
-
}, label: 'Add filter', disabled: true }), _jsx("div", { style: {
|
|
1100
|
-
position: 'relative',
|
|
1101
|
-
...(openPopover === 'AddFilterPopover' && { top: 12 }),
|
|
1102
|
-
}, children: _jsx(PopoverComponent, { isOpen: openPopover === 'AddFilterPopover', setIsOpen: (isOpen) => {
|
|
1103
|
-
if (!isOpen) {
|
|
1104
|
-
setActivePath(null);
|
|
1105
|
-
setOpenPopover(null);
|
|
1106
|
-
setTimeout(() => {
|
|
1107
|
-
clearCheckboxes();
|
|
1108
|
-
setActiveEditItem(null);
|
|
1109
|
-
}, 300);
|
|
1110
|
-
}
|
|
1111
|
-
}, popoverTitle: 'Add filter', popoverChildren: _jsx(FilterModal, { schema: schemaData.schema.find((s) => s.name === currentTable ||
|
|
1112
|
-
s.displayName === currentTable) ?? schemaData.schema[0], fieldValuesMap: uniqueValues[getTableNames(baseAst).length === 1
|
|
1113
|
-
? getTableNames(baseAst)[0]
|
|
1114
|
-
: initialTableName], fieldValuesMapIsLoading: uniqueValuesIsLoading, onSubmitFilter: (filter) => {
|
|
1115
|
-
setOpenPopover(null);
|
|
1116
|
-
const item = filterToAst(filter, client.databaseType.toLowerCase());
|
|
1117
|
-
handleInsertion(item, 'AND', false);
|
|
1118
|
-
}, onDeleteFilter: () => { }, ButtonComponent: ButtonComponent, SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, SecondaryButtonComponent: SecondaryButtonComponent, MultiSelectComponent: MultiSelectComponent }) }) })] })] }), _jsxs("div", { style: { width: '100%' }, children: [_jsx(SidebarHeadingComponent, { label: "Pivot" }), _jsx(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: () => {
|
|
1119
|
-
setPivot(null);
|
|
1120
|
-
setPivotData(null);
|
|
1121
|
-
const formattedRows = formatRows(rows, columns, false);
|
|
1122
|
-
setFormattedRows(formattedRows);
|
|
1123
|
-
},
|
|
1124
|
-
// TODOs
|
|
1125
|
-
selectPivot: () => {
|
|
1126
|
-
return;
|
|
1127
|
-
}, 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 && (_jsx(PivotForm, { columns: columns, uniqueValues: uniqueValues[currentTable], uniqueValuesIsLoading: uniqueValuesIsLoading, setPivotRowField: (value) => {
|
|
1128
|
-
setPivotRowField(value);
|
|
1129
|
-
}, setPivotColumnField: setPivotColumnField, setPivotValueField: setPivotValueField, setPivotAggregation: setPivotAggregation, pivotRowField: pivotRowField, pivotColumnField: pivotColumnField, pivotValueField: pivotValueField, pivotAggregation: pivotAggregation, onDelete: () => {
|
|
1130
|
-
setPivot(null);
|
|
1131
|
-
setPivotData([]);
|
|
1132
|
-
const formattedRows = formatRows(rows, columns, false);
|
|
1133
|
-
setFormattedRows(formattedRows);
|
|
1134
|
-
}, isLoading: tableLoading, SecondaryButtonComponent: SecondaryButtonComponent, SelectComponent: SelectComponent, PivotColumnContainer: PivotColumnContainer }))] }), _jsxs("div", { style: { width: '100%' }, children: [_jsx(SidebarHeadingComponent, { label: "Sort" }), pivot && pivot.sort && (_jsx("div", { style: {
|
|
1135
|
-
display: 'flex',
|
|
1136
|
-
flexDirection: 'column',
|
|
1137
|
-
gap: 8,
|
|
1138
|
-
marginBottom: 12,
|
|
1139
|
-
}, children: _jsx(SortSentence, { sortData: {
|
|
1140
|
-
type: pivot.sortDirection,
|
|
1141
|
-
expr: { type: 'column_ref', column: pivot.sortField },
|
|
1142
|
-
}, columns: selectedColumns, setIsPending: () => { }, setEditPopoverKey: () => { }, setActiveEditItem: setActiveEditItem, setActivePath: setActivePath, setOpenPopover: setOpenPopover, SortPopover: SortPopoverComponent, EditPopover: AddSortPopover, handleDelete: () => {
|
|
1143
|
-
setPivot({ ...pivot, sort: false });
|
|
1144
|
-
setBaseAst(deepCopy(baseAst));
|
|
1145
|
-
if (!pivot) {
|
|
1146
|
-
fetchSqlQuery(baseAst);
|
|
1147
|
-
}
|
|
1148
|
-
}, onSave: (column, direction) => {
|
|
1149
|
-
const sortFieldType = column === (pivot.valueField || 'count')
|
|
1150
|
-
? 'number'
|
|
1151
|
-
: pivot.rowFieldType;
|
|
1152
|
-
setPivot({
|
|
1153
|
-
...pivot,
|
|
1154
|
-
sort: true,
|
|
1155
|
-
sortDirection: direction,
|
|
1156
|
-
sortField: column,
|
|
1157
|
-
sortFieldType: sortFieldType,
|
|
1158
|
-
});
|
|
1159
|
-
setOpenPopover(null);
|
|
1160
|
-
setBaseAst(deepCopy(baseAst));
|
|
1161
|
-
if (!pivot) {
|
|
1162
|
-
fetchSqlQuery(baseAst);
|
|
1163
|
-
}
|
|
1164
|
-
}, Select: SelectComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent }, `sort-sentence-pivot`) })), baseAst && baseAst.orderby && (_jsx("div", { style: {
|
|
1165
|
-
display: 'flex',
|
|
1166
|
-
flexDirection: 'column',
|
|
1167
|
-
gap: 8,
|
|
1168
|
-
marginBottom: 12,
|
|
1169
|
-
}, children: baseAst.orderby.map((sortData, id) => (_jsx(SortSentence, { sortData: sortData, columns: selectedColumns, onSave: (column, direction) => {
|
|
1170
|
-
setActiveEditItem(null);
|
|
1171
|
-
setOpenPopover(null);
|
|
1172
|
-
if (column === '')
|
|
1173
|
-
return;
|
|
1174
|
-
const newAst = { ...baseAst };
|
|
1175
|
-
newAst.orderby[id] = {
|
|
1176
|
-
expr: {
|
|
1177
|
-
type: 'column_ref',
|
|
1178
|
-
table: null,
|
|
1179
|
-
column: column,
|
|
1180
|
-
},
|
|
1181
|
-
type: direction,
|
|
1182
|
-
};
|
|
1183
|
-
// look through the columns
|
|
1184
|
-
setActivePath(null);
|
|
1185
|
-
setOpenPopover(null);
|
|
1186
|
-
setBaseAst(deepCopy(newAst));
|
|
1187
|
-
if (!pivot) {
|
|
1188
|
-
fetchSqlQuery(newAst);
|
|
1189
|
-
}
|
|
1190
|
-
}, setIsPending: () => { }, setEditPopoverKey: () => { }, setActiveEditItem: setActiveEditItem, setActivePath: setActivePath, setOpenPopover: setOpenPopover, SortPopover: SortPopoverComponent, EditPopover: AddSortPopover, handleDelete: () => {
|
|
1191
|
-
const newAst = { ...baseAst };
|
|
1192
|
-
newAst.orderby.splice(id, 1);
|
|
1193
|
-
setBaseAst(deepCopy(newAst));
|
|
1194
|
-
if (!pivot) {
|
|
1195
|
-
fetchSqlQuery(newAst);
|
|
1196
|
-
}
|
|
1197
|
-
}, Select: SelectComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent, disabled: true }, `sort-sentence-${id}`))) })), _jsx(SecondaryButtonComponent, { onClick: () => {
|
|
1198
|
-
if (!selectedColumns ||
|
|
1199
|
-
selectedColumns.length === 0 ||
|
|
1200
|
-
loading) {
|
|
1201
|
-
return;
|
|
1202
|
-
}
|
|
1203
|
-
if (!openPopover) {
|
|
1204
|
-
setOpenPopover('AddSortPopover');
|
|
1205
|
-
}
|
|
1206
|
-
}, label: "Add sort", disabled: true }), _jsx(PopoverComponent, { isOpen: openPopover === 'AddSortPopover', setIsOpen: (isOpen) => {
|
|
1207
|
-
if (!isOpen) {
|
|
1208
|
-
setActiveEditItem(null);
|
|
1209
|
-
setActivePath(null);
|
|
1210
|
-
setOpenPopover(null);
|
|
1211
|
-
}
|
|
1212
|
-
}, popoverTitle: "Sort by", popoverChildren: _jsx(AddSortPopover, { columns: selectedColumns, Select: SelectComponent, Button: ButtonComponent, onSave: () => { } }) })] }), _jsxs("div", { style: { width: '100%' }, children: [_jsx(SidebarHeadingComponent, { label: "Limit" }), baseAst && baseAst.limit && baseAst.limit.value?.length > 0 ? (_jsx("div", { style: {
|
|
1213
|
-
display: 'flex',
|
|
1214
|
-
flexDirection: 'column',
|
|
1215
|
-
gap: 8,
|
|
1216
|
-
marginBottom: 12,
|
|
1217
|
-
}, children: _jsx(LimitSentence, { limit: baseAst.limit, setOpenPopover: setOpenPopover, LimitPopover: LimitPopoverComponent, EditPopover: AddLimitPopover, handleDelete: () => {
|
|
1218
|
-
const newAst = { ...baseAst };
|
|
1219
|
-
newAst.limit = null;
|
|
1220
|
-
setBaseAst(deepCopy(newAst));
|
|
1221
|
-
fetchSqlQuery(newAst);
|
|
1222
|
-
}, onSave: (limit) => {
|
|
1223
|
-
const newAst = { ...baseAst };
|
|
1224
|
-
newAst.limit = {
|
|
1225
|
-
seperator: '',
|
|
1226
|
-
value: [
|
|
1227
|
-
{
|
|
1228
|
-
type: 'number',
|
|
1229
|
-
value: limit,
|
|
1230
|
-
},
|
|
1231
|
-
],
|
|
1232
|
-
};
|
|
1233
|
-
setOpenPopover(null);
|
|
1234
|
-
setBaseAst(deepCopy(newAst));
|
|
1235
|
-
fetchSqlQuery(newAst);
|
|
1236
|
-
}, TextInput: TextInputComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent, disabled: true }) })) : (_jsxs(_Fragment, { children: [_jsx(SecondaryButtonComponent, { onClick: () => {
|
|
1237
|
-
if (!selectedColumns ||
|
|
1238
|
-
selectedColumns.length === 0 ||
|
|
1239
|
-
loading) {
|
|
1240
|
-
return;
|
|
1241
|
-
}
|
|
1242
|
-
if (!openPopover) {
|
|
1243
|
-
setOpenPopover('AddLimitPopover');
|
|
1244
|
-
}
|
|
1245
|
-
}, label: 'Add limit', disabled: true }), _jsx(PopoverComponent, { isOpen: openPopover === 'AddLimitPopover', setIsOpen: (isOpen) => {
|
|
1246
|
-
if (!isOpen) {
|
|
1247
|
-
setActiveEditItem(null);
|
|
1248
|
-
setActivePath(null);
|
|
1249
|
-
setOpenPopover(null);
|
|
1250
|
-
}
|
|
1251
|
-
}, popoverTitle: "Add limit", popoverChildren: _jsx(AddLimitPopover, { TextInputComponent: TextInputComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent, onSave: () => { } }) })] }))] })] }), _jsxs(ContainerComponent, { children: [isAIEnabled && (_jsx("form", { ref: askAILoadingContainerRef, onSubmit: (event) => {
|
|
1252
|
-
event.preventDefault();
|
|
1253
|
-
}, style: {
|
|
1254
|
-
display: 'flex',
|
|
1255
|
-
flexDirection: 'row',
|
|
1256
|
-
gap: 12,
|
|
1257
|
-
visibility: askAIInputWidth === -1 && askAILoadingContainerWidth === -1
|
|
1258
|
-
? 'hidden'
|
|
1259
|
-
: 'visible',
|
|
1260
|
-
}, children: _jsxs(_Fragment, { children: [_jsx(TextInputComponent, { id: "ask_ai_loading_bar", placeholder: askedAQuestion
|
|
1261
|
-
? 'Ask a follow-up question...'
|
|
1262
|
-
: 'Ask a question...', width: askAIInputWidth !== -1
|
|
1263
|
-
? askAIInputWidth
|
|
1264
|
-
: askAILoadingContainerWidth, value: aiPrompt, onChange: () => { } }), _jsx(ButtonComponent, { onClick: () => { }, label: "Ask AI" }), ((baseAst && dataDisplayed) ||
|
|
1265
|
-
initialLoad ||
|
|
1266
|
-
initialChartLoad) &&
|
|
1267
|
-
!reportId && (_jsx(SecondaryButtonComponent, { onClick: () => { }, label: "New report" }))] }) })), _jsxs(_Fragment, { children: [_jsx(TableComponent, { isLoading: true, rows: [], columns: [] }), baseAst && dataDisplayed && !initialChartLoad && (_jsxs("div", { style: {
|
|
1268
|
-
display: 'flex',
|
|
1269
|
-
flexDirection: 'row',
|
|
1270
|
-
gap: '12px',
|
|
1271
|
-
marginTop: 'auto',
|
|
1272
|
-
}, 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;}` })] }));
|
|
1273
|
-
}
|
|
1274
1197
|
return (_jsxs("div", { style: { backgroundColor: theme?.backgroundColor, ...containerStyle }, className: className, children: [(!isChartBuilderHorizontalView ||
|
|
1275
1198
|
(isChartBuilderHorizontalView && !isChartBuilderOpen)) && (_jsxs("div", { ref: parentRef, style: {
|
|
1276
1199
|
display: 'flex',
|
|
@@ -1286,7 +1209,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1286
1209
|
if (!openPopover) {
|
|
1287
1210
|
setOpenPopover('AddColumnModal');
|
|
1288
1211
|
}
|
|
1289
|
-
}, label: "Select columns" }), _jsx(ModalComponent, { isOpen: openPopover === 'AddColumnModal', setIsOpen: (isOpen) => {
|
|
1212
|
+
}, label: "Select columns", disabled: tableLoading || loading }), _jsx(ModalComponent, { isOpen: openPopover === 'AddColumnModal', setIsOpen: (isOpen) => {
|
|
1290
1213
|
if (!isOpen) {
|
|
1291
1214
|
// delay onClose callback so onClick no-ops
|
|
1292
1215
|
setTimeout(() => {
|
|
@@ -1300,18 +1223,32 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1300
1223
|
setActivePath(null);
|
|
1301
1224
|
setOpenPopover(null);
|
|
1302
1225
|
}, orderedColumnNames: orderedColumnNames, setOrderedColumnNames: setOrderedColumnNames, selectedColumns: selectedColumns, setSelectedColumns: setSelectedColumns, isSelectedAllColumns: isSelectedAllColumns, clearAllState: clearAllState, nameToColumn: nameToColumn, baseAst: baseAst, setBaseAst: (ast) => {
|
|
1303
|
-
|
|
1304
|
-
|
|
1226
|
+
if (baseAst &&
|
|
1227
|
+
ast?.from?.[0]?.table !== baseAst?.from?.[0]?.table) {
|
|
1228
|
+
// table changed, past presets no longer valid
|
|
1229
|
+
setFormData(null);
|
|
1230
|
+
setRecommendedPivots([]);
|
|
1231
|
+
setCreatedPivots([]);
|
|
1232
|
+
ast.where = null;
|
|
1233
|
+
ast.orderby = null;
|
|
1234
|
+
ast.limit = null;
|
|
1235
|
+
setBaseAst(ast);
|
|
1236
|
+
fetchSqlQuery(ast, null);
|
|
1237
|
+
}
|
|
1238
|
+
else {
|
|
1239
|
+
setBaseAst(ast);
|
|
1240
|
+
fetchSqlQuery(ast);
|
|
1241
|
+
}
|
|
1305
1242
|
}, 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: {
|
|
1306
1243
|
display: 'flex',
|
|
1307
1244
|
flexDirection: 'column',
|
|
1308
1245
|
gap: 8,
|
|
1309
1246
|
marginBottom: 12,
|
|
1310
|
-
}, children: _jsx(FilterStack, { client: client, filterStack: filterStack, filterTree: filterTree, defaultAST: defaultAST, baseAst: baseAst, setBaseAst: setBaseAst, setFormData: setFormData, fetchSqlQuery: fetchSqlQuery, schemaData: schemaData, defaultColumn: defaultColumn, defaultTable: defaultTable, currentTable: currentTable, initialTableName: initialTableName, globalUniqueValues: globalUniqueValues, globalUniqueValuesIsLoading: globalUniqueValuesIsLoading, columns: columns, removingFilter: removingFilter, setRemovingFilter: setRemovingFilter, TabsComponent: TabsComponent, FilterPopoverComponent: FilterPopoverComponent, FilterModal: FilterModal, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, MultiSelectComponent: MultiSelectComponent, actionsEnabled:
|
|
1247
|
+
}, children: _jsx(FilterStack, { client: client, filterStack: filterStack, filterTree: filterTree, defaultAST: defaultAST, baseAst: baseAst, setBaseAst: setBaseAst, setFormData: setFormData, fetchSqlQuery: fetchSqlQuery, schemaData: schemaData, defaultColumn: defaultColumn, defaultTable: defaultTable, currentTable: currentTable, initialTableName: initialTableName, globalUniqueValues: globalUniqueValues, globalUniqueValuesIsLoading: globalUniqueValuesIsLoading, columns: columns, removingFilter: removingFilter, setRemovingFilter: setRemovingFilter, TabsComponent: TabsComponent, FilterPopoverComponent: FilterPopoverComponent, FilterModal: FilterModal, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, MultiSelectComponent: MultiSelectComponent, actionsEnabled: !tableLoading && !loading }) })), _jsxs("div", { style: {
|
|
1311
1248
|
display: 'flex',
|
|
1312
1249
|
flexDirection: 'column',
|
|
1313
1250
|
alignItems: 'flex-start',
|
|
1314
|
-
}, children: [_jsx(SecondaryButtonComponent, { disabled: !baseAst || !dataDisplayed, onClick: () => {
|
|
1251
|
+
}, children: [_jsx(SecondaryButtonComponent, { disabled: !baseAst || !dataDisplayed || loading || tableLoading, onClick: () => {
|
|
1315
1252
|
if (!selectedColumns ||
|
|
1316
1253
|
selectedColumns.length === 0 ||
|
|
1317
1254
|
loading) {
|
|
@@ -1352,8 +1289,9 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1352
1289
|
setOpenPopover(null);
|
|
1353
1290
|
const item = filterToAst(filter, client.databaseType.toLowerCase());
|
|
1354
1291
|
handleInsertion(item, 'AND', false);
|
|
1355
|
-
}, onDeleteFilter: () => { }, ButtonComponent: ButtonComponent, SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, MultiSelectComponent: MultiSelectComponent }) }) })] })] }), _jsxs("div", { style: { width: '100%' }, children: [_jsx(SidebarHeadingComponent, { label: "Pivot" }), _jsx(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: () => {
|
|
1292
|
+
}, onDeleteFilter: () => { }, ButtonComponent: ButtonComponent, SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, MultiSelectComponent: MultiSelectComponent }) }) })] })] }), _jsxs("div", { style: { width: '100%' }, children: [_jsx(SidebarHeadingComponent, { label: "Pivot" }), _jsx(PivotModal, { pivotRowField: pivotRowField, setPivotRowField: setPivotRowField, pivotColumnField: pivotColumnField, setPivotColumnField: setPivotColumnField, pivotValueField: pivotValueField, pivotValueField2: pivotValueField2, setPivotValueField: setPivotValueField, setPivotValueField2: setPivotValueField2, 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: () => {
|
|
1356
1293
|
setPivot(null);
|
|
1294
|
+
setPivotHint('');
|
|
1357
1295
|
setPivotData(null);
|
|
1358
1296
|
const formattedRows = formatRows(rows, columns, false);
|
|
1359
1297
|
setFormattedRows(formattedRows);
|
|
@@ -1372,17 +1310,32 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1372
1310
|
dateBucket = getDateBucketFromRange(dateRange);
|
|
1373
1311
|
}
|
|
1374
1312
|
setPivot(selectedPivot);
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1313
|
+
setPivotHint('');
|
|
1314
|
+
try {
|
|
1315
|
+
if (!pivotTable) {
|
|
1316
|
+
setTableLoading(true);
|
|
1317
|
+
pivotTable = await generatePivotTable({
|
|
1318
|
+
pivot: selectedPivot,
|
|
1319
|
+
dateBucket,
|
|
1320
|
+
report: tempReport,
|
|
1321
|
+
client,
|
|
1322
|
+
uniqueValues,
|
|
1323
|
+
});
|
|
1324
|
+
}
|
|
1325
|
+
setPivotData(pivotTable || []);
|
|
1326
|
+
const formattedRows = formatRows(pivotTable.rows, columns, true, selectedPivot.aggregationType, dateBucket);
|
|
1327
|
+
setFormattedRows(formattedRows);
|
|
1328
|
+
setErrorMessage('');
|
|
1329
|
+
setPivotError(undefined);
|
|
1378
1330
|
}
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1331
|
+
catch (e) {
|
|
1332
|
+
if (e instanceof Error)
|
|
1333
|
+
setPivotError(e.message);
|
|
1334
|
+
}
|
|
1335
|
+
finally {
|
|
1336
|
+
setTableLoading(false);
|
|
1337
|
+
}
|
|
1338
|
+
}, 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 || loading, pivotRecommendationsEnabled: pivotRecommendationsEnabledState, report: tempReport }), pivot && (_jsx(PivotForm, { columns: columns, uniqueValues: uniqueValues[currentTable], uniqueValuesIsLoading: uniqueValuesIsLoading, setPivotRowField: (value) => {
|
|
1386
1339
|
setPivotRowField(value);
|
|
1387
1340
|
updatePivot(value, 'rowField');
|
|
1388
1341
|
}, setPivotColumnField: (value) => {
|
|
@@ -1391,15 +1344,19 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1391
1344
|
}, setPivotValueField: (value) => {
|
|
1392
1345
|
setPivotValueField(value);
|
|
1393
1346
|
updatePivot(value, 'valueField');
|
|
1347
|
+
}, setPivotValueField2: (value) => {
|
|
1348
|
+
setPivotValueField2(value);
|
|
1349
|
+
updatePivot(value, 'valueField2');
|
|
1394
1350
|
}, setPivotAggregation: (value) => {
|
|
1395
1351
|
setPivotAggregation(value);
|
|
1396
1352
|
updatePivot(value, 'aggregationType');
|
|
1397
1353
|
}, onDelete: () => {
|
|
1398
1354
|
setPivot(null);
|
|
1355
|
+
setPivotHint('');
|
|
1399
1356
|
setPivotData([]);
|
|
1400
1357
|
const formattedRows = formatRows(rows, columns, false);
|
|
1401
1358
|
setFormattedRows(formattedRows);
|
|
1402
|
-
}, isLoading: tableLoading, pivotRowField: pivotRowField, pivotColumnField: pivotColumnField, pivotValueField: pivotValueField, pivotAggregation: pivotAggregation, SecondaryButtonComponent: SecondaryButtonComponent, SelectComponent: SelectComponent, PivotColumnContainer: PivotColumnContainer }))] }), _jsxs("div", { style: { width: '100%' }, children: [_jsx(SidebarHeadingComponent, { label: "Sort" }), pivot && pivot.sort && (_jsx("div", { style: {
|
|
1359
|
+
}, isLoading: tableLoading || loading, pivotRowField: pivotRowField, pivotColumnField: pivotColumnField, pivotValueField: pivotValueField, pivotValueField2: pivotValueField2, pivotAggregation: pivotAggregation, SecondaryButtonComponent: SecondaryButtonComponent, SelectComponent: SelectComponent, PivotColumnContainer: PivotColumnContainer, pivotHint: pivotHint }))] }), _jsxs("div", { style: { width: '100%' }, children: [_jsx(SidebarHeadingComponent, { label: "Sort" }), pivot && pivot.sort && (_jsx("div", { style: {
|
|
1403
1360
|
display: 'flex',
|
|
1404
1361
|
flexDirection: 'column',
|
|
1405
1362
|
gap: 8,
|
|
@@ -1415,56 +1372,87 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1415
1372
|
`.${pivot.valueField || 'count'}`,
|
|
1416
1373
|
]
|
|
1417
1374
|
: selectedColumns, setIsPending: () => { }, setEditPopoverKey: () => { }, setActiveEditItem: setActiveEditItem, setActivePath: setActivePath, setOpenPopover: setOpenPopover, SortPopover: SortPopoverComponent, EditPopover: AddSortPopover, handleDelete: async () => {
|
|
1418
|
-
if (pivot) {
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1375
|
+
if (!pivot) {
|
|
1376
|
+
setBaseAst(deepCopy(baseAst));
|
|
1377
|
+
fetchSqlQuery(deepCopy(baseAst));
|
|
1378
|
+
return;
|
|
1379
|
+
}
|
|
1380
|
+
const tempPivot = { ...pivot, sort: false };
|
|
1381
|
+
let dateBucket = undefined;
|
|
1382
|
+
const tempDateRange = dateRanges &&
|
|
1383
|
+
pivot.rowField &&
|
|
1384
|
+
dateRanges[pivot.rowField];
|
|
1385
|
+
if (tempDateRange) {
|
|
1386
|
+
dateBucket = getDateBucketFromRange(tempDateRange.dateRange);
|
|
1387
|
+
}
|
|
1388
|
+
setPivot(tempPivot);
|
|
1389
|
+
setPivotHint('');
|
|
1390
|
+
try {
|
|
1391
|
+
const pivotedData = await generatePivotTable({
|
|
1392
|
+
pivot: tempPivot,
|
|
1393
|
+
rowLimit: -1,
|
|
1394
|
+
dateBucket,
|
|
1395
|
+
report: tempReport,
|
|
1396
|
+
client,
|
|
1397
|
+
uniqueValues: uniqueValues[currentTable],
|
|
1398
|
+
});
|
|
1429
1399
|
setPivotData(pivotedData || []);
|
|
1430
|
-
const formattedRows = formatRows(pivotedData.rows, columns, true, pivot.aggregationType);
|
|
1400
|
+
const formattedRows = formatRows(pivotedData.rows, columns, true, pivot.aggregationType, dateBucket);
|
|
1431
1401
|
setFormattedRows(formattedRows);
|
|
1432
1402
|
setErrorMessage('');
|
|
1433
|
-
return;
|
|
1434
1403
|
}
|
|
1435
|
-
|
|
1436
|
-
|
|
1404
|
+
catch (e) {
|
|
1405
|
+
if (e instanceof Error)
|
|
1406
|
+
setPivotError(e.message);
|
|
1407
|
+
}
|
|
1408
|
+
finally {
|
|
1409
|
+
setTableLoading(false);
|
|
1410
|
+
}
|
|
1437
1411
|
}, onSave: async (column, direction) => {
|
|
1438
|
-
if (pivot) {
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1412
|
+
if (!pivot) {
|
|
1413
|
+
setOpenPopover(null);
|
|
1414
|
+
setBaseAst(deepCopy(baseAst));
|
|
1415
|
+
fetchSqlQuery(deepCopy(baseAst));
|
|
1416
|
+
return;
|
|
1417
|
+
}
|
|
1418
|
+
const sortFieldType = column === (pivot.valueField || 'count')
|
|
1419
|
+
? 'number'
|
|
1420
|
+
: pivot.rowFieldType;
|
|
1421
|
+
const tempPivot = {
|
|
1422
|
+
...pivot,
|
|
1423
|
+
sort: true,
|
|
1424
|
+
sortDirection: direction,
|
|
1425
|
+
sortField: column,
|
|
1426
|
+
sortFieldType: sortFieldType,
|
|
1427
|
+
};
|
|
1428
|
+
setPivot(tempPivot);
|
|
1429
|
+
setPivotHint('');
|
|
1430
|
+
let dateBucket = undefined;
|
|
1431
|
+
const tempDateRange = dateRanges &&
|
|
1432
|
+
pivot.rowField &&
|
|
1433
|
+
dateRanges[pivot.rowField];
|
|
1434
|
+
if (tempDateRange) {
|
|
1435
|
+
dateBucket = getDateBucketFromRange(tempDateRange.dateRange);
|
|
1436
|
+
}
|
|
1437
|
+
try {
|
|
1438
|
+
const pivotedData = await generatePivotTable({
|
|
1439
|
+
pivot: tempPivot,
|
|
1440
|
+
rowLimit: -1,
|
|
1441
|
+
dateBucket,
|
|
1442
|
+
report: tempReport,
|
|
1443
|
+
client,
|
|
1444
|
+
uniqueValues: uniqueValues[currentTable],
|
|
1445
|
+
});
|
|
1458
1446
|
setPivotData(pivotedData || []);
|
|
1459
|
-
const formattedRows = formatRows(pivotedData.rows, columns, true, pivot.aggregationType);
|
|
1447
|
+
const formattedRows = formatRows(pivotedData.rows, columns, true, pivot.aggregationType, dateBucket);
|
|
1460
1448
|
setFormattedRows(formattedRows);
|
|
1461
1449
|
setErrorMessage('');
|
|
1462
|
-
return;
|
|
1463
1450
|
}
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1451
|
+
catch (e) {
|
|
1452
|
+
if (e instanceof Error)
|
|
1453
|
+
setPivotError(e.message);
|
|
1454
|
+
}
|
|
1455
|
+
}, Select: SelectComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent, disabled: tableLoading || loading }, `sort-sentence-pivot`) })), baseAst && baseAst.orderby && (_jsx("div", { style: {
|
|
1468
1456
|
display: 'flex',
|
|
1469
1457
|
flexDirection: 'column',
|
|
1470
1458
|
gap: 8,
|
|
@@ -1472,6 +1460,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1472
1460
|
}, children: baseAst.orderby.map((sortData, id) => (_jsx(SortSentence, { sortData: sortData, columns: selectedColumns, setIsPending: () => { }, setEditPopoverKey: () => { }, setActiveEditItem: setActiveEditItem, setActivePath: setActivePath, setOpenPopover: setOpenPopover, SortPopover: SortPopoverComponent, EditPopover: AddSortPopover, handleDelete: () => {
|
|
1473
1461
|
if (pivot) {
|
|
1474
1462
|
setPivot({ ...pivot, sort: false });
|
|
1463
|
+
setPivotHint('');
|
|
1475
1464
|
return;
|
|
1476
1465
|
}
|
|
1477
1466
|
const newAst = { ...baseAst };
|
|
@@ -1490,6 +1479,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1490
1479
|
sortField: column,
|
|
1491
1480
|
sortFieldType: sortFieldType,
|
|
1492
1481
|
});
|
|
1482
|
+
setPivotHint('');
|
|
1493
1483
|
return;
|
|
1494
1484
|
}
|
|
1495
1485
|
setActiveEditItem(null);
|
|
@@ -1510,7 +1500,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1510
1500
|
setOpenPopover(null);
|
|
1511
1501
|
setBaseAst(deepCopy(newAst));
|
|
1512
1502
|
fetchSqlQuery(deepCopy(newAst));
|
|
1513
|
-
}, Select: SelectComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent }, `sort-sentence-${id}`))) })), _jsx(SecondaryButtonComponent, { disabled: !baseAst || !dataDisplayed, onClick: () => {
|
|
1503
|
+
}, Select: SelectComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent, disabled: tableLoading || loading }, `sort-sentence-${id}`))) })), _jsx(SecondaryButtonComponent, { disabled: !baseAst || !dataDisplayed || loading || tableLoading, onClick: () => {
|
|
1514
1504
|
if (!selectedColumns || selectedColumns.length === 0) {
|
|
1515
1505
|
return;
|
|
1516
1506
|
}
|
|
@@ -1548,6 +1538,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1548
1538
|
sortFieldType: sortFieldType,
|
|
1549
1539
|
};
|
|
1550
1540
|
setPivot(tempPivot);
|
|
1541
|
+
setPivotHint('');
|
|
1551
1542
|
let dateBucket = undefined;
|
|
1552
1543
|
const tempDateRange = dateRanges &&
|
|
1553
1544
|
pivot.rowField &&
|
|
@@ -1555,11 +1546,23 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1555
1546
|
if (tempDateRange) {
|
|
1556
1547
|
dateBucket = getDateBucketFromRange(tempDateRange.dateRange);
|
|
1557
1548
|
}
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1549
|
+
try {
|
|
1550
|
+
const pivotedData = await generatePivotTable({
|
|
1551
|
+
pivot: tempPivot,
|
|
1552
|
+
dateBucket,
|
|
1553
|
+
report: tempReport,
|
|
1554
|
+
client,
|
|
1555
|
+
uniqueValues: uniqueValues[currentTable],
|
|
1556
|
+
});
|
|
1557
|
+
setErrorMessage('');
|
|
1558
|
+
setPivotData(pivotedData || []);
|
|
1559
|
+
const formattedRows = formatRows(pivotedData.rows, columns, true, pivot.aggregationType, dateBucket);
|
|
1560
|
+
setFormattedRows(formattedRows);
|
|
1561
|
+
}
|
|
1562
|
+
catch (e) {
|
|
1563
|
+
if (e instanceof Error)
|
|
1564
|
+
setPivotError(e.message);
|
|
1565
|
+
}
|
|
1563
1566
|
setActivePath(null);
|
|
1564
1567
|
setOpenPopover(null);
|
|
1565
1568
|
setBaseAst(deepCopy(baseAst));
|
|
@@ -1601,7 +1604,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1601
1604
|
setOpenPopover(null);
|
|
1602
1605
|
setBaseAst(deepCopy(newAst));
|
|
1603
1606
|
fetchSqlQuery(deepCopy(newAst));
|
|
1604
|
-
}, TextInput: TextInputComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent }) })) : (_jsxs(_Fragment, { children: [_jsx(SecondaryButtonComponent, { disabled: !baseAst || !dataDisplayed, onClick: () => {
|
|
1607
|
+
}, TextInput: TextInputComponent, Button: ButtonComponent, SecondaryButton: SecondaryButtonComponent, disabled: tableLoading || loading }) })) : (_jsxs(_Fragment, { children: [_jsx(SecondaryButtonComponent, { disabled: !baseAst || !dataDisplayed || loading || tableLoading, onClick: () => {
|
|
1605
1608
|
if (!selectedColumns || selectedColumns.length === 0) {
|
|
1606
1609
|
return;
|
|
1607
1610
|
}
|
|
@@ -1649,10 +1652,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1649
1652
|
? 'Ask a follow-up question...'
|
|
1650
1653
|
: 'Ask a question...' }), _jsx(ButtonComponent, { onClick: () => {
|
|
1651
1654
|
fetchAstFromPromptHelper();
|
|
1652
|
-
}, label: 'Ask AI' }), ((baseAst && dataDisplayed) || initialLoad) && !reportId && (_jsx(SecondaryButtonComponent, { label: 'New report', onClick: clearAllState }))] }) })), baseAst && (_jsx(TableComponent, { isLoading:
|
|
1653
|
-
(tableLoading ||
|
|
1654
|
-
(loading && errorMessage.length === 0) ||
|
|
1655
|
-
initialChartLoad), rows: formattedRows, rowCount: pivot ? undefined : numberOfRows, rowCountIsLoading: rowCountIsLoading, rowsPerPage: 20, columns: pivot
|
|
1655
|
+
}, isLoading: askAILoading && !baseAst, label: 'Ask AI' }), ((baseAst && dataDisplayed) || initialLoad) && !reportId && (_jsx(SecondaryButtonComponent, { label: 'New report', onClick: clearAllState }))] }) })), baseAst && (_jsx(TableComponent, { isLoading: tableLoading || (loading && errorMessage.length === 0), rows: formattedRows, rowCount: pivot ? undefined : numberOfRows, rowCountIsLoading: rowCountIsLoading, rowsPerPage: 20, columns: pivot
|
|
1656
1656
|
? pivotData?.columns || emptyPivotColumns()
|
|
1657
1657
|
: enforceOrderOnColumns(Object.keys(rows[0] ?? {})).map((c) => {
|
|
1658
1658
|
return {
|
|
@@ -1676,13 +1676,13 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1676
1676
|
alignItems: 'center',
|
|
1677
1677
|
}, children: [_jsx(ErrorMessageComponent, { errorMessage: errorMessage }), _jsx(SecondaryButtonComponent, { onClick: () => {
|
|
1678
1678
|
fetchAstFromPromptHelper();
|
|
1679
|
-
}, label: 'Retry' })] })) : (_jsx("div", { style: { width: '100%' } })), baseAst && dataDisplayed &&
|
|
1680
|
-
setIsAddLoading(true);
|
|
1681
|
-
await handleRunQuery(currentProcessing, true);
|
|
1682
|
-
setIsAddLoading(false);
|
|
1679
|
+
}, label: 'Retry' })] })) : (_jsx("div", { style: { width: '100%' } })), baseAst && dataDisplayed && (_jsxs(_Fragment, { children: [onDiscardChanges && (_jsx(SecondaryButtonComponent, { onClick: onDiscardChanges, label: "Discard changes" })), !hideCopySQL && (_jsx(SecondaryButtonComponent, { label: isCopying ? 'Copied' : 'Copy SQL', onClick: () => copySQLToClipboard() })), _jsx(ButtonComponent, { onClick: async () => {
|
|
1683
1680
|
onSaveChanges && onSaveChanges();
|
|
1684
1681
|
setIsChartBuilderOpen(true);
|
|
1685
|
-
}, disabled: !!errorMessage
|
|
1682
|
+
}, disabled: !!errorMessage ||
|
|
1683
|
+
tableLoading ||
|
|
1684
|
+
loading ||
|
|
1685
|
+
unresolvedReportMessage, label: reportId ? 'Save changes' : 'Add to dashboard', tooltipText: unresolvedReportMessage })] }))] })] }), _jsx("style", { children: `body{margin:0;}` })] })), (!isChartBuilderHorizontalView || isChartBuilderOpen) && (_jsx(ChartBuilderWithModal, { report: reportInfo
|
|
1686
1686
|
? {
|
|
1687
1687
|
...reportInfo,
|
|
1688
1688
|
...tempReport,
|
|
@@ -1700,5 +1700,5 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1700
1700
|
: {
|
|
1701
1701
|
...tempReport,
|
|
1702
1702
|
filtersApplied: specificDashboardFilters,
|
|
1703
|
-
}, 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
|
|
1703
|
+
}, rows: chartBuilderInFilteredPreview ? filteredRows : 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, isEditingMode: true }))] }));
|
|
1704
1704
|
}
|