@quillsql/react 2.13.26 → 2.13.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Chart.d.ts.map +1 -1
- package/dist/cjs/Chart.js +2 -2
- package/dist/cjs/ChartBuilder.d.ts +20 -2
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +130 -36
- package/dist/cjs/ChartEditor.d.ts +5 -3
- package/dist/cjs/ChartEditor.d.ts.map +1 -1
- package/dist/cjs/ChartEditor.js +4 -5
- package/dist/cjs/Context.d.ts +15 -4
- package/dist/cjs/Context.d.ts.map +1 -1
- package/dist/cjs/Context.js +37 -60
- package/dist/cjs/Dashboard.d.ts +4 -0
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/Dashboard.js +78 -23
- package/dist/cjs/QuillProvider.d.ts +12 -9
- package/dist/cjs/QuillProvider.d.ts.map +1 -1
- package/dist/cjs/QuillProvider.js +2 -2
- package/dist/cjs/ReportBuilder.d.ts +9 -1
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +198 -80
- package/dist/cjs/SQLEditor.d.ts +5 -1
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +81 -18
- package/dist/cjs/Table.d.ts.map +1 -1
- package/dist/cjs/Table.js +5 -4
- package/dist/cjs/components/Chart/InternalChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/InternalChart.js +106 -27
- package/dist/cjs/components/Chart/PieChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/PieChart.js +10 -7
- package/dist/cjs/components/Dashboard/DashboardFilter.d.ts +3 -2
- package/dist/cjs/components/Dashboard/DashboardFilter.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DashboardFilter.js +65 -65
- package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.js +81 -34
- package/dist/cjs/components/Dashboard/MetricComponent.js +3 -3
- package/dist/cjs/components/Dashboard/util.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/util.js +6 -2
- package/dist/cjs/components/QuillMultiSelectWithCombo.d.ts +1 -1
- package/dist/cjs/components/QuillMultiSelectWithCombo.d.ts.map +1 -1
- package/dist/cjs/components/QuillMultiSelectWithCombo.js +17 -18
- package/dist/cjs/components/QuillTable.d.ts.map +1 -1
- package/dist/cjs/components/QuillTable.js +9 -1
- package/dist/cjs/components/ReportBuilder/FilterModal.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/FilterModal.js +25 -3
- package/dist/cjs/components/ReportBuilder/FilterStack.d.ts +2 -1
- package/dist/cjs/components/ReportBuilder/FilterStack.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/FilterStack.js +2 -2
- package/dist/cjs/components/ReportBuilder/convert.d.ts +1 -0
- package/dist/cjs/components/ReportBuilder/convert.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/convert.js +54 -4
- package/dist/cjs/components/ReportBuilder/ui.d.ts +2 -1
- package/dist/cjs/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/ui.js +3 -2
- package/dist/cjs/components/UiComponents.d.ts +1 -0
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/hooks/useAskQuill.d.ts +1 -1
- package/dist/cjs/hooks/useAskQuill.d.ts.map +1 -1
- package/dist/cjs/hooks/useAskQuill.js +6 -5
- package/dist/cjs/hooks/useAstToFilterTree.d.ts +2 -1
- package/dist/cjs/hooks/useAstToFilterTree.d.ts.map +1 -1
- package/dist/cjs/hooks/useAstToFilterTree.js +3 -3
- package/dist/cjs/hooks/useDashboard.d.ts +5 -2
- package/dist/cjs/hooks/useDashboard.d.ts.map +1 -1
- package/dist/cjs/hooks/useDashboard.js +21 -7
- package/dist/cjs/hooks/useExport.d.ts.map +1 -1
- package/dist/cjs/hooks/useExport.js +6 -4
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts +8 -2
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.js +59 -30
- package/dist/cjs/models/Client.d.ts +22 -3
- package/dist/cjs/models/Client.d.ts.map +1 -1
- package/dist/cjs/models/Dashboard.d.ts +1 -0
- package/dist/cjs/models/Dashboard.d.ts.map +1 -1
- package/dist/cjs/models/Report.d.ts +4 -0
- package/dist/cjs/models/Report.d.ts.map +1 -1
- package/dist/cjs/utils/astFilterProcessing.d.ts +3 -2
- package/dist/cjs/utils/astFilterProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/astFilterProcessing.js +3323 -977
- package/dist/cjs/utils/astProcessing.d.ts +1 -1
- package/dist/cjs/utils/astProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/astProcessing.js +3 -2
- package/dist/cjs/utils/client.d.ts +4 -2
- package/dist/cjs/utils/client.d.ts.map +1 -1
- package/dist/cjs/utils/client.js +47 -1
- package/dist/cjs/utils/columnProcessing.d.ts +3 -0
- package/dist/cjs/utils/columnProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/columnProcessing.js +34 -1
- package/dist/cjs/utils/dashboard.d.ts +4 -3
- package/dist/cjs/utils/dashboard.d.ts.map +1 -1
- package/dist/cjs/utils/dashboard.js +10 -91
- package/dist/cjs/utils/dataFetcher.d.ts +3 -1
- package/dist/cjs/utils/dataFetcher.d.ts.map +1 -1
- package/dist/cjs/utils/dataFetcher.js +66 -30
- package/dist/cjs/utils/filterProcessing.d.ts +1 -1
- package/dist/cjs/utils/filterProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/filterProcessing.js +2 -0
- package/dist/cjs/utils/pivotConstructor.d.ts +4 -1
- package/dist/cjs/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/pivotConstructor.js +7 -7
- package/dist/cjs/utils/pivotProcessing.d.ts +4 -1
- package/dist/cjs/utils/pivotProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/pivotProcessing.js +27 -20
- package/dist/cjs/utils/queryConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/queryConstructor.js +101 -85
- package/dist/cjs/utils/report.d.ts +17 -5
- package/dist/cjs/utils/report.d.ts.map +1 -1
- package/dist/cjs/utils/report.js +23 -23
- package/dist/cjs/utils/schema.d.ts.map +1 -1
- package/dist/cjs/utils/schema.js +21 -21
- package/dist/cjs/utils/tableProcessing.d.ts +37 -10
- package/dist/cjs/utils/tableProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/tableProcessing.js +45 -38
- package/dist/cjs/utils/tenants.d.ts +11 -0
- package/dist/cjs/utils/tenants.d.ts.map +1 -0
- package/dist/cjs/utils/tenants.js +13 -0
- package/dist/cjs/utils/textProcessing.d.ts +1 -0
- package/dist/cjs/utils/textProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/textProcessing.js +49 -0
- package/dist/cjs/utils/validation.js +1 -1
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +2 -2
- package/dist/esm/ChartBuilder.d.ts +20 -2
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +131 -40
- package/dist/esm/ChartEditor.d.ts +5 -3
- package/dist/esm/ChartEditor.d.ts.map +1 -1
- package/dist/esm/ChartEditor.js +5 -6
- package/dist/esm/Context.d.ts +15 -4
- package/dist/esm/Context.d.ts.map +1 -1
- package/dist/esm/Context.js +36 -59
- package/dist/esm/Dashboard.d.ts +4 -0
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/Dashboard.js +79 -24
- package/dist/esm/QuillProvider.d.ts +12 -9
- package/dist/esm/QuillProvider.d.ts.map +1 -1
- package/dist/esm/QuillProvider.js +2 -2
- package/dist/esm/ReportBuilder.d.ts +9 -1
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +200 -84
- package/dist/esm/SQLEditor.d.ts +5 -1
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +80 -17
- package/dist/esm/Table.d.ts.map +1 -1
- package/dist/esm/Table.js +6 -5
- package/dist/esm/components/Chart/InternalChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/InternalChart.js +107 -28
- package/dist/esm/components/Chart/PieChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/PieChart.js +10 -7
- package/dist/esm/components/Dashboard/DashboardFilter.d.ts +3 -2
- package/dist/esm/components/Dashboard/DashboardFilter.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DashboardFilter.js +65 -65
- package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.js +82 -35
- package/dist/esm/components/Dashboard/MetricComponent.js +3 -3
- package/dist/esm/components/Dashboard/util.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/util.js +6 -2
- package/dist/esm/components/QuillMultiSelectWithCombo.d.ts +1 -1
- package/dist/esm/components/QuillMultiSelectWithCombo.d.ts.map +1 -1
- package/dist/esm/components/QuillMultiSelectWithCombo.js +17 -18
- package/dist/esm/components/QuillTable.d.ts.map +1 -1
- package/dist/esm/components/QuillTable.js +9 -1
- package/dist/esm/components/ReportBuilder/FilterModal.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/FilterModal.js +26 -4
- package/dist/esm/components/ReportBuilder/FilterStack.d.ts +2 -1
- package/dist/esm/components/ReportBuilder/FilterStack.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/FilterStack.js +2 -2
- package/dist/esm/components/ReportBuilder/convert.d.ts +1 -0
- package/dist/esm/components/ReportBuilder/convert.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/convert.js +54 -5
- package/dist/esm/components/ReportBuilder/ui.d.ts +2 -1
- package/dist/esm/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/ui.js +4 -3
- package/dist/esm/components/UiComponents.d.ts +1 -0
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/hooks/useAskQuill.d.ts +1 -1
- package/dist/esm/hooks/useAskQuill.d.ts.map +1 -1
- package/dist/esm/hooks/useAskQuill.js +7 -6
- package/dist/esm/hooks/useAstToFilterTree.d.ts +2 -1
- package/dist/esm/hooks/useAstToFilterTree.d.ts.map +1 -1
- package/dist/esm/hooks/useAstToFilterTree.js +3 -3
- package/dist/esm/hooks/useDashboard.d.ts +5 -2
- package/dist/esm/hooks/useDashboard.d.ts.map +1 -1
- package/dist/esm/hooks/useDashboard.js +21 -7
- package/dist/esm/hooks/useExport.d.ts.map +1 -1
- package/dist/esm/hooks/useExport.js +7 -5
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts +8 -2
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.js +59 -30
- package/dist/esm/models/Client.d.ts +22 -3
- package/dist/esm/models/Client.d.ts.map +1 -1
- package/dist/esm/models/Dashboard.d.ts +1 -0
- package/dist/esm/models/Dashboard.d.ts.map +1 -1
- package/dist/esm/models/Report.d.ts +4 -0
- package/dist/esm/models/Report.d.ts.map +1 -1
- package/dist/esm/utils/astFilterProcessing.d.ts +3 -2
- package/dist/esm/utils/astFilterProcessing.d.ts.map +1 -1
- package/dist/esm/utils/astFilterProcessing.js +3323 -977
- package/dist/esm/utils/astProcessing.d.ts +1 -1
- package/dist/esm/utils/astProcessing.d.ts.map +1 -1
- package/dist/esm/utils/astProcessing.js +4 -3
- package/dist/esm/utils/client.d.ts +4 -2
- package/dist/esm/utils/client.d.ts.map +1 -1
- package/dist/esm/utils/client.js +47 -1
- package/dist/esm/utils/columnProcessing.d.ts +3 -0
- package/dist/esm/utils/columnProcessing.d.ts.map +1 -1
- package/dist/esm/utils/columnProcessing.js +31 -1
- package/dist/esm/utils/dashboard.d.ts +4 -3
- package/dist/esm/utils/dashboard.d.ts.map +1 -1
- package/dist/esm/utils/dashboard.js +10 -90
- package/dist/esm/utils/dataFetcher.d.ts +3 -1
- package/dist/esm/utils/dataFetcher.d.ts.map +1 -1
- package/dist/esm/utils/dataFetcher.js +65 -29
- package/dist/esm/utils/filterProcessing.d.ts +1 -1
- package/dist/esm/utils/filterProcessing.d.ts.map +1 -1
- package/dist/esm/utils/filterProcessing.js +2 -0
- package/dist/esm/utils/pivotConstructor.d.ts +4 -1
- package/dist/esm/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/esm/utils/pivotConstructor.js +8 -8
- package/dist/esm/utils/pivotProcessing.d.ts +4 -1
- package/dist/esm/utils/pivotProcessing.d.ts.map +1 -1
- package/dist/esm/utils/pivotProcessing.js +27 -20
- package/dist/esm/utils/queryConstructor.d.ts.map +1 -1
- package/dist/esm/utils/queryConstructor.js +101 -85
- package/dist/esm/utils/report.d.ts +17 -5
- package/dist/esm/utils/report.d.ts.map +1 -1
- package/dist/esm/utils/report.js +20 -23
- package/dist/esm/utils/schema.d.ts.map +1 -1
- package/dist/esm/utils/schema.js +21 -21
- package/dist/esm/utils/tableProcessing.d.ts +37 -10
- package/dist/esm/utils/tableProcessing.d.ts.map +1 -1
- package/dist/esm/utils/tableProcessing.js +46 -39
- package/dist/esm/utils/tenants.d.ts +11 -0
- package/dist/esm/utils/tenants.d.ts.map +1 -0
- package/dist/esm/utils/tenants.js +9 -0
- package/dist/esm/utils/textProcessing.d.ts +1 -0
- package/dist/esm/utils/textProcessing.d.ts.map +1 -1
- package/dist/esm/utils/textProcessing.js +48 -0
- package/dist/esm/utils/validation.js +1 -1
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import { MemoizedButton, MemoizedDeleteButton, MemoizedHeader, MemoizedLabel, Me
|
|
|
4
4
|
import { DndContext, closestCenter, KeyboardSensor, PointerSensor, useSensor, useSensors, } from '@dnd-kit/core';
|
|
5
5
|
import { arrayMove, SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy, useSortable, } from '@dnd-kit/sortable';
|
|
6
6
|
import { CSS as DND_CSS } from '@dnd-kit/utilities';
|
|
7
|
-
import { ClientContext, DashboardContext, DashboardFiltersContext, SchemaDataContext, ThemeContext, } from './Context';
|
|
7
|
+
import { ClientContext, DashboardContext, DashboardFiltersContext, SchemaDataContext, TenantContext, ThemeContext, } from './Context';
|
|
8
8
|
import { getTableNames, isNumericColumnType, } from './components/ReportBuilder/ast';
|
|
9
9
|
import { ChartBuilderWithModal } from './ChartBuilder';
|
|
10
10
|
import { QuillTextInput } from './components/UiComponents';
|
|
@@ -31,9 +31,7 @@ import { astToFilterTree, filterTreeToAst, getFieldFromExpression, } from './uti
|
|
|
31
31
|
import useAstToFilterTree from './hooks/useAstToFilterTree';
|
|
32
32
|
import { filterStackToFilterTree, uniqueValuesToStringMap, } from './utils/filterProcessing';
|
|
33
33
|
import { QuillMultiSelectComponentWithCombo } from './components/QuillMultiSelectWithCombo';
|
|
34
|
-
import { DEFAULT_PAGINATION, shouldFetchMore,
|
|
35
|
-
// shouldSortInMemory,
|
|
36
|
-
} from './utils/paginationProcessing';
|
|
34
|
+
import { DEFAULT_PAGINATION, shouldFetchMore, shouldSortInMemory, } from './utils/paginationProcessing';
|
|
37
35
|
import { EMPTY_INTERNAL_REPORT, fetchReportBuilderDataFromAST, formatRowsFromReport, } from './utils/report';
|
|
38
36
|
import { TEMP_REPORT_ID, } from './models/Report';
|
|
39
37
|
import equal from 'fast-deep-equal';
|
|
@@ -70,12 +68,13 @@ import { QUILL_SERVER } from './utils/constants';
|
|
|
70
68
|
* ### Report Builder API
|
|
71
69
|
* @see https://docs.quillsql.com/components/report-builder
|
|
72
70
|
*/
|
|
73
|
-
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
|
+
export default function ReportBuilder({ initialTableName = '', onSubmitEditReport = () => void null, onSubmitCreateReport = () => void null, onDiscardChanges = undefined, onSaveChanges = undefined, onCloseChartBuilder = undefined, destinationDashboard = undefined, chartBuilderTitle = undefined, organizationName = '', ButtonComponent = MemoizedButton, SecondaryButtonComponent = MemoizedSecondaryButton, DeleteButtonComponent = MemoizedDeleteButton, ModalComponent = MemoizedModal, TextInputComponent = QuillTextInput, SelectComponent = QuillSelectComponent, MultiSelectComponent = QuillMultiSelectComponentWithCombo, TableComponent = QuillTableReportBuilderComponent, PopoverComponent = MemoizedPopover, TabsComponent = QuillTabs,
|
|
74
72
|
// CheckboxComponent = MemoizedCheckbox,
|
|
75
|
-
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, containerStyle, className, pivotRecommendationsEnabled = true, reportId, hideCopySQL = true, isChartBuilderHorizontalView = true, onClickChartElement, }) {
|
|
73
|
+
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, containerStyle, className, pivotRecommendationsEnabled = true, reportId, hideCopySQL = true, isChartBuilderHorizontalView = true, onClickChartElement, flagsList, }) {
|
|
76
74
|
const [dashboard, dashboardDispatch] = useContext(DashboardContext);
|
|
77
75
|
const [schemaData] = useContext(SchemaDataContext);
|
|
78
76
|
const { dashboardFilters } = useContext(DashboardFiltersContext);
|
|
77
|
+
const { tenants } = useContext(TenantContext);
|
|
79
78
|
const specificDashboardFilters = useMemo(() => {
|
|
80
79
|
if (!reportId)
|
|
81
80
|
return [];
|
|
@@ -84,6 +83,63 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
84
83
|
return [];
|
|
85
84
|
return Object.values(dashboardFilters[dashboardName] ?? {}).map((f) => f.filter);
|
|
86
85
|
}, [dashboardFilters, reportId, dashboard]);
|
|
86
|
+
const [client] = useContext(ClientContext);
|
|
87
|
+
// const { dashboardConfig } = useContext(DashboardConfigContext);
|
|
88
|
+
// const flagsToAdd: { [tenantField: string]: string[] } = useMemo(() => {
|
|
89
|
+
// if (client && asSingleDatabaseTenant(client))
|
|
90
|
+
// return { 'QUILL_SINGLE_TENANT': flags ?? {} } as { [tenantField: string]: string[] };
|
|
91
|
+
// const tenantKeys =
|
|
92
|
+
// dashboardConfig[
|
|
93
|
+
// dashboard[reportId ?? '']?.dashboardName ?? destinationDashboard ?? ''
|
|
94
|
+
// ]?.config.tenantKeys ?? [];
|
|
95
|
+
// if (!tenantKeys.length) return {};
|
|
96
|
+
// if (
|
|
97
|
+
// tenants &&
|
|
98
|
+
// (typeof tenants[0] === 'string' || typeof tenants[0] === 'number')
|
|
99
|
+
// ) {
|
|
100
|
+
// const dashboardOwner = tenantKeys[0]!;
|
|
101
|
+
// const tenantIds = (client?.allTenantTypes as QuillTenant[])?.find(
|
|
102
|
+
// (tt) => dashboardOwner === tt.tenantField,
|
|
103
|
+
// )?.tenantIds;
|
|
104
|
+
// return {
|
|
105
|
+
// [dashboardOwner]:
|
|
106
|
+
// tenantIds
|
|
107
|
+
// ?.filter(
|
|
108
|
+
// (tt) =>
|
|
109
|
+
// (tenants as (string | number)[]).includes(tt.id) && tt.flag,
|
|
110
|
+
// )
|
|
111
|
+
// ?.map((tt) => tt.flag!) ?? [],
|
|
112
|
+
// };
|
|
113
|
+
// }
|
|
114
|
+
// const tenantKeysSet = new Set(tenantKeys);
|
|
115
|
+
// return (
|
|
116
|
+
// (
|
|
117
|
+
// tenants as
|
|
118
|
+
// | { tenantField: string; tenantIds: (string | number)[] }[]
|
|
119
|
+
// | undefined
|
|
120
|
+
// )
|
|
121
|
+
// ?.filter((t) => tenantKeysSet.has(t.tenantField))
|
|
122
|
+
// .reduce(
|
|
123
|
+
// (acc, t) => {
|
|
124
|
+
// const tenantIds = new Set(t.tenantIds);
|
|
125
|
+
// acc[t.tenantField] =
|
|
126
|
+
// (client?.allTenantTypes as QuillTenant[])
|
|
127
|
+
// ?.find((tt) => t.tenantField === tt.tenantField)
|
|
128
|
+
// ?.tenantIds?.filter((tt) => tenantIds.has(tt.id) && tt.flag)
|
|
129
|
+
// ?.map((tt) => tt.flag!) ?? [];
|
|
130
|
+
// return acc;
|
|
131
|
+
// },
|
|
132
|
+
// {} as { [tenantField: string]: string[] },
|
|
133
|
+
// ) ?? {}
|
|
134
|
+
// );
|
|
135
|
+
// }, [
|
|
136
|
+
// tenants,
|
|
137
|
+
// flags,
|
|
138
|
+
// dashboardConfig,
|
|
139
|
+
// destinationDashboard,
|
|
140
|
+
// dashboard[reportId ?? '']?.dashboardName,
|
|
141
|
+
// client?.allTenantTypes,
|
|
142
|
+
// ]);
|
|
87
143
|
const [reportInfo, setReportInfo] = useState(null);
|
|
88
144
|
const [aiPrompt, setAiPrompt] = useState('');
|
|
89
145
|
const [errorMessage, setErrorMessage] = useState('');
|
|
@@ -132,12 +188,10 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
132
188
|
/* eslint-disable-next-line */
|
|
133
189
|
const [pivotError, setPivotError] = useState(undefined);
|
|
134
190
|
const [dateRanges, setDateRanges] = useState(null);
|
|
135
|
-
const [client] = useContext(ClientContext);
|
|
136
|
-
const [currentOrganizationId, setCurrentOrganizationId] = useState(client.organizationId);
|
|
137
191
|
const [fieldValuesMap, setFieldValuesMap] = useState({}); // Mapping of unique values per field, used in string filter 'in' and 'not in'
|
|
138
192
|
const [globalUniqueValues, setGlobalUniqueValues] = useState({});
|
|
139
193
|
const [globalUniqueValuesIsLoading, setGlobalUniqueValuesIsLoading] = useState(false);
|
|
140
|
-
const { filterTree, filterStack } = useAstToFilterTree(formData, client); // Stores the state of filters
|
|
194
|
+
const { filterTree, filterStack } = useAstToFilterTree(formData, client, columns); // Stores the state of filters
|
|
141
195
|
const [removingFilter, setRemovingFilter] = useState(false);
|
|
142
196
|
const [pivotRecommendationsEnabledState, setPivotRecommendationsEnabledState,] = useState(pivotRecommendationsEnabled);
|
|
143
197
|
const REPORT_BUILDER_PAGINATION = {
|
|
@@ -146,6 +200,15 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
146
200
|
rowsPerRequest: 1000,
|
|
147
201
|
};
|
|
148
202
|
const [unresolvedReportMessage, setUnresolvedReportMessage] = useState('');
|
|
203
|
+
const dashboardName = useMemo(() => {
|
|
204
|
+
if (destinationDashboard) {
|
|
205
|
+
return destinationDashboard;
|
|
206
|
+
}
|
|
207
|
+
if (!reportId) {
|
|
208
|
+
return undefined;
|
|
209
|
+
}
|
|
210
|
+
return dashboard[reportId]?.dashboardName;
|
|
211
|
+
}, [reportId, dashboard, destinationDashboard]);
|
|
149
212
|
const [filtersEnabled, setFiltersEnabled] = useState(!!reportId);
|
|
150
213
|
useEffect(() => {
|
|
151
214
|
if (!client) {
|
|
@@ -193,9 +256,9 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
193
256
|
window.removeEventListener('resize', handleResize);
|
|
194
257
|
};
|
|
195
258
|
}, []);
|
|
196
|
-
const updatePivot = async (changeField, fieldKey) => {
|
|
259
|
+
const updatePivot = async (changeField, fieldKey, prevValue) => {
|
|
197
260
|
const newPivot = deepCopy(pivot);
|
|
198
|
-
|
|
261
|
+
setPivotError(undefined);
|
|
199
262
|
// @ts-ignore
|
|
200
263
|
newPivot[fieldKey] = changeField;
|
|
201
264
|
if (fieldKey === 'rowField') {
|
|
@@ -213,12 +276,20 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
213
276
|
newPivot.sort = undefined;
|
|
214
277
|
}
|
|
215
278
|
}
|
|
279
|
+
const { valid, reason } = isValidPivot(newPivot);
|
|
280
|
+
if (!valid) {
|
|
281
|
+
setPivotError(reason);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
setTableLoading(true);
|
|
216
285
|
let dateBucket = undefined;
|
|
217
286
|
const tempDateRange = dateRanges && dateRanges[newPivot.rowField || ''];
|
|
218
287
|
if (tempDateRange) {
|
|
219
288
|
dateBucket = getDateBucketFromRange(tempDateRange.dateRange);
|
|
220
289
|
}
|
|
221
290
|
let distinctValuesForQuery = {};
|
|
291
|
+
const prevPivot = pivot;
|
|
292
|
+
const prevPivotData = pivotData;
|
|
222
293
|
setPivot(newPivot);
|
|
223
294
|
setPivotHint('');
|
|
224
295
|
if (newPivot.columnField) {
|
|
@@ -228,7 +299,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
228
299
|
label: newPivot.columnField,
|
|
229
300
|
format: 'string',
|
|
230
301
|
},
|
|
231
|
-
], activeQuery, [], client, schemaData.customFields ?? []);
|
|
302
|
+
], activeQuery, [], client, tenants, schemaData.customFields ?? [], undefined, dashboardName);
|
|
232
303
|
}
|
|
233
304
|
try {
|
|
234
305
|
const pivotedData = await generatePivotTable({
|
|
@@ -237,12 +308,33 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
237
308
|
report: tempReport,
|
|
238
309
|
client,
|
|
239
310
|
uniqueValues: distinctValuesForQuery,
|
|
311
|
+
dashboardName,
|
|
312
|
+
tenants,
|
|
240
313
|
});
|
|
241
314
|
setPivotData(pivotedData || []);
|
|
242
315
|
const formattedRows = formatRows(pivotedData.rows, columns, true, newPivot.aggregationType);
|
|
243
316
|
setFormattedRows(formattedRows);
|
|
244
317
|
}
|
|
245
318
|
catch (e) {
|
|
319
|
+
switch (fieldKey) {
|
|
320
|
+
case 'rowField':
|
|
321
|
+
setPivotRowField(prevValue);
|
|
322
|
+
break;
|
|
323
|
+
case 'columnField':
|
|
324
|
+
setPivotColumnField(prevValue);
|
|
325
|
+
break;
|
|
326
|
+
case 'valueField':
|
|
327
|
+
setPivotValueField(prevValue);
|
|
328
|
+
break;
|
|
329
|
+
case 'valueField2':
|
|
330
|
+
setPivotValueField2(prevValue);
|
|
331
|
+
break;
|
|
332
|
+
case 'aggregationType':
|
|
333
|
+
setPivotAggregation(prevValue);
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
setPivot(prevPivot);
|
|
337
|
+
setPivotData(prevPivotData);
|
|
246
338
|
if (e instanceof Error)
|
|
247
339
|
setPivotError(e.message);
|
|
248
340
|
}
|
|
@@ -280,9 +372,12 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
280
372
|
setDataDisplayed(false);
|
|
281
373
|
setRows([]);
|
|
282
374
|
setColumns([]);
|
|
375
|
+
setSelectedOrderedColumns([]);
|
|
283
376
|
setErrorMessage('');
|
|
377
|
+
setPivotError(undefined);
|
|
284
378
|
setFormattedRows([]);
|
|
285
|
-
|
|
379
|
+
setCurrentTable('');
|
|
380
|
+
setUniqueValues({});
|
|
286
381
|
setPivot(null);
|
|
287
382
|
setPivotHint('');
|
|
288
383
|
setPivotData(null);
|
|
@@ -291,7 +386,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
291
386
|
};
|
|
292
387
|
const fetchGlobalUniqueValues = async (columns, currentTable, client) => {
|
|
293
388
|
setGlobalUniqueValuesIsLoading(true);
|
|
294
|
-
const global = await getUniqueStringValues(columns, currentTable, client, schemaData.customFields, undefined, true);
|
|
389
|
+
const global = await getUniqueStringValues(columns, currentTable, client, tenants, schemaData.customFields, undefined, true, undefined, dashboardName);
|
|
295
390
|
setGlobalUniqueValues(uniqueValuesToStringMap(global));
|
|
296
391
|
setGlobalUniqueValuesIsLoading(false);
|
|
297
392
|
};
|
|
@@ -414,7 +509,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
414
509
|
const dateColumnNames = dateColumns.map((column) => {
|
|
415
510
|
return column.field;
|
|
416
511
|
});
|
|
417
|
-
const dateRanges = await getQueryDateRangeByColumns(dateColumns, `Select ${dateColumnNames.join(', ')} from ${tableName}`, client, schemaData.customFields ?? []);
|
|
512
|
+
const dateRanges = await getQueryDateRangeByColumns(dateColumns, `Select ${dateColumnNames.join(', ')} from ${tableName}`, client, tenants, schemaData.customFields ?? [], dashboardName);
|
|
418
513
|
return dateRanges;
|
|
419
514
|
};
|
|
420
515
|
// It's just like getColumnsInPivot but we expand the columnField
|
|
@@ -444,7 +539,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
444
539
|
const tableInfo = tables.find((tableInfo) => tableInfo.name === initialTableName);
|
|
445
540
|
if (tableInfo) {
|
|
446
541
|
setUniqueValuesIsLoading(true);
|
|
447
|
-
const newUniqueValues = await getUniqueStringValues(tableInfo.columns, initialTableName, client, schemaData.customFields, uniqueValues, true);
|
|
542
|
+
const newUniqueValues = await getUniqueStringValues(tableInfo.columns, initialTableName, client, tenants, schemaData.customFields, uniqueValues, true, undefined, dashboardName);
|
|
448
543
|
if (hashCode(uniqueValues) !== hashCode(newUniqueValues)) {
|
|
449
544
|
setUniqueValues(newUniqueValues);
|
|
450
545
|
updateFieldValuesMap(newUniqueValues, initialTableName);
|
|
@@ -607,16 +702,6 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
607
702
|
const [numberOfRows, setNumberOfRows] = useState(0);
|
|
608
703
|
const [rowCountIsLoading, setRowCountIsLoading] = useState(false);
|
|
609
704
|
const [tableLoading, setTableLoading] = useState(false);
|
|
610
|
-
// const initialData = useMemo(() => ({
|
|
611
|
-
// rows,
|
|
612
|
-
// columns,
|
|
613
|
-
// itemQuery: tempReport.itemQuery ?? [],
|
|
614
|
-
// rowCount: numberOfRows ?? 0,
|
|
615
|
-
// dashboardName: destinationDashboard ?? reportInfo?.dashboardName,
|
|
616
|
-
// query: activeQuery,
|
|
617
|
-
// pivot: pivot,
|
|
618
|
-
// pivotData: pivotData,
|
|
619
|
-
// }), [rows, columns, tempReport, activeQuery, pivot, pivotData, numberOfRows, destinationDashboard, reportInfo]);
|
|
620
705
|
const onPageChange = (page, initiator = 'ReportBuilder') => {
|
|
621
706
|
const pagination = initiator === 'ReportBuilder'
|
|
622
707
|
? REPORT_BUILDER_PAGINATION
|
|
@@ -632,36 +717,30 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
632
717
|
setPreviousPage(page);
|
|
633
718
|
}
|
|
634
719
|
};
|
|
635
|
-
const onSortChange = (sort
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
};
|
|
651
|
-
}
|
|
652
|
-
else {
|
|
653
|
-
newAst.orderby.push({
|
|
654
|
-
expr: { type: 'column_ref', column: sort.field },
|
|
655
|
-
type: sort.direction.toUpperCase(),
|
|
656
|
-
});
|
|
657
|
-
}
|
|
658
|
-
setBaseAst(deepCopy(newAst));
|
|
659
|
-
fetchReportFromASTHelper(newAst, newAst.where);
|
|
720
|
+
const onSortChange = (sort) => {
|
|
721
|
+
if (shouldSortInMemory(REPORT_BUILDER_PAGINATION, numberOfRows) ||
|
|
722
|
+
(pivot && pivot.rowField !== sort.field)) {
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
const newAst = { ...baseAst };
|
|
726
|
+
if (!newAst.orderby) {
|
|
727
|
+
newAst.orderby = [];
|
|
728
|
+
}
|
|
729
|
+
const existingSortIndex = newAst.orderby.findIndex((item) => getFieldFromExpression(item.expr) === sort.field);
|
|
730
|
+
if (existingSortIndex !== -1) {
|
|
731
|
+
newAst.orderby[existingSortIndex] = {
|
|
732
|
+
expr: { type: 'column_ref', column: sort.field },
|
|
733
|
+
type: sort.direction.toUpperCase(),
|
|
734
|
+
};
|
|
660
735
|
}
|
|
661
736
|
else {
|
|
662
|
-
|
|
737
|
+
newAst.orderby.push({
|
|
738
|
+
expr: { type: 'column_ref', column: sort.field },
|
|
739
|
+
type: sort.direction.toUpperCase(),
|
|
740
|
+
});
|
|
663
741
|
}
|
|
664
|
-
|
|
742
|
+
setBaseAst(deepCopy(newAst));
|
|
743
|
+
fetchReportFromASTHelper(newAst, newAst.where);
|
|
665
744
|
setPreviousPage(0);
|
|
666
745
|
};
|
|
667
746
|
const fetchRowCount = async (processing, includeFilters) => {
|
|
@@ -669,9 +748,9 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
669
748
|
return;
|
|
670
749
|
}
|
|
671
750
|
setRowCountIsLoading(true);
|
|
672
|
-
const tableInfo = await fetchResultsByQuery(activeQuery, client, processing, schemaData.customFields, includeFilters ? specificDashboardFilters : undefined, includeFilters
|
|
751
|
+
const tableInfo = await fetchResultsByQuery(activeQuery, client, tenants, processing, schemaData.customFields, includeFilters ? specificDashboardFilters : undefined, includeFilters
|
|
673
752
|
? (tempReport.dateField ?? reportInfo?.dateField)
|
|
674
|
-
: undefined, false, true);
|
|
753
|
+
: undefined, false, true, undefined, dashboardName);
|
|
675
754
|
if (tableInfo.rowCount) {
|
|
676
755
|
setNumberOfRows(tableInfo.rowCount);
|
|
677
756
|
// @ts-ignore
|
|
@@ -684,7 +763,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
684
763
|
};
|
|
685
764
|
const fetchRowCountFromAST = async (ast, where) => {
|
|
686
765
|
setRowCountIsLoading(true);
|
|
687
|
-
const tableData = await fetchTableByAST({ ...ast, where }, client, { page: REPORT_BUILDER_PAGINATION }, undefined, false, true);
|
|
766
|
+
const tableData = await fetchTableByAST({ ...ast, where }, client, tenants, { page: REPORT_BUILDER_PAGINATION }, undefined, false, true, dashboardName);
|
|
688
767
|
if (tableData.rowCount) {
|
|
689
768
|
setNumberOfRows(tableData.rowCount);
|
|
690
769
|
// @ts-ignore
|
|
@@ -699,7 +778,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
699
778
|
try {
|
|
700
779
|
setErrorMessage('');
|
|
701
780
|
setTableLoading(true);
|
|
702
|
-
const tableInfo = await fetchResultsByQuery(activeQuery, client, processing, schemaData.customFields, undefined, undefined, true);
|
|
781
|
+
const tableInfo = await fetchResultsByQuery(activeQuery, client, tenants, processing, schemaData.customFields, undefined, undefined, true, undefined, undefined, dashboardName);
|
|
703
782
|
if (tableInfo.error) {
|
|
704
783
|
throw new Error(tableInfo.error);
|
|
705
784
|
}
|
|
@@ -707,7 +786,6 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
707
786
|
throw new Error('No data found');
|
|
708
787
|
}
|
|
709
788
|
fetchRowCount(processing, includeFilters);
|
|
710
|
-
setCurrentProcessing(processing);
|
|
711
789
|
let tempRows = [...rows, ...tableInfo.rows];
|
|
712
790
|
if (resetRows) {
|
|
713
791
|
tempRows = tableInfo.rows;
|
|
@@ -766,7 +844,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
766
844
|
let reportBuilderInfo = undefined;
|
|
767
845
|
try {
|
|
768
846
|
setLoading(true);
|
|
769
|
-
reportBuilderInfo = await fetchReportBuilderDataFromAST(baseAst, curFormData, curSchema ?? schemaData.schema, client, curPivot ?? pivot, formData, currentTable, { uniqueStrings: uniqueValues, dateRanges: dateRanges ?? {} }, previousReport ?? reportInfo ?? undefined, schemaData.customFields, true, true, { page: REPORT_BUILDER_PAGINATION });
|
|
847
|
+
reportBuilderInfo = await fetchReportBuilderDataFromAST(baseAst, curFormData, curSchema ?? schemaData.schema, client, tenants, curPivot ?? pivot, formData, currentTable, { uniqueStrings: uniqueValues, dateRanges: dateRanges ?? {} }, previousReport ?? reportInfo ?? undefined, schemaData.customFields, true, true, { page: REPORT_BUILDER_PAGINATION }, dashboardName);
|
|
770
848
|
if (reportBuilderInfo.error) {
|
|
771
849
|
throw new Error(reportBuilderInfo.error);
|
|
772
850
|
}
|
|
@@ -782,6 +860,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
782
860
|
return { error: true, message: 'Failed to fetch', rows: [] };
|
|
783
861
|
}
|
|
784
862
|
if (!reportBuilderInfo) {
|
|
863
|
+
setLoading(false);
|
|
785
864
|
setErrorMessage('Failed to fetch');
|
|
786
865
|
return;
|
|
787
866
|
}
|
|
@@ -793,7 +872,6 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
793
872
|
});
|
|
794
873
|
const prevFormData = formData;
|
|
795
874
|
const prevTable = currentTable;
|
|
796
|
-
const prevOrganization = currentOrganizationId;
|
|
797
875
|
setRows(reportBuilderInfo.rows);
|
|
798
876
|
setPreviousPage(0);
|
|
799
877
|
if (!(client.databaseType.toLowerCase() === 'bigquery') ||
|
|
@@ -801,6 +879,9 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
801
879
|
setColumns(reportBuilderInfo.columns);
|
|
802
880
|
setSelectedColumns(reportBuilderInfoColumns);
|
|
803
881
|
}
|
|
882
|
+
if (prevTable !== reportBuilderInfo.table) {
|
|
883
|
+
setSelectedOrderedColumns([]); // reset selected ordered columns
|
|
884
|
+
}
|
|
804
885
|
setNumberOfRows(reportBuilderInfo.rowCount);
|
|
805
886
|
setPivot(reportBuilderInfo.pivot);
|
|
806
887
|
if (!keepPivotHint) {
|
|
@@ -811,7 +892,6 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
811
892
|
setFormattedRows(reportBuilderInfo.formattedRows);
|
|
812
893
|
setDataDisplayed(true);
|
|
813
894
|
setCurrentTable(reportBuilderInfo.table);
|
|
814
|
-
setCurrentOrganizationId(client.organizationId);
|
|
815
895
|
setFormData(curFormData);
|
|
816
896
|
if (reportBuilderInfo.pivot) {
|
|
817
897
|
setPivotRowField(reportBuilderInfo.pivot.rowField);
|
|
@@ -847,8 +927,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
847
927
|
}
|
|
848
928
|
// fetch unique values after everything else since it is the most expensive
|
|
849
929
|
if (prevTable !== reportBuilderInfo.table ||
|
|
850
|
-
!equal(prevFormData, curFormData)
|
|
851
|
-
prevOrganization !== client.organizationId) {
|
|
930
|
+
!equal(prevFormData, curFormData)) {
|
|
852
931
|
try {
|
|
853
932
|
setUniqueValuesIsLoading(true);
|
|
854
933
|
if (reportBuilderInfo.pivot) {
|
|
@@ -857,7 +936,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
857
936
|
if (!tableInfo) {
|
|
858
937
|
throw new Error('Table info not found');
|
|
859
938
|
}
|
|
860
|
-
const uniqueStrings = await getUniqueStringValues(tableInfo.columns, reportBuilderInfo.table, client, schemaData.customFields, undefined, true, query);
|
|
939
|
+
const uniqueStrings = await getUniqueStringValues(tableInfo.columns, reportBuilderInfo.table, client, tenants, schemaData.customFields, undefined, true, query, dashboardName);
|
|
861
940
|
const newUnique = updateUniqueValue(uniqueStrings, reportBuilderInfo.table);
|
|
862
941
|
let pivotChanged = false;
|
|
863
942
|
let newPivot;
|
|
@@ -911,7 +990,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
911
990
|
setLoading(true);
|
|
912
991
|
setAskAILoading(true);
|
|
913
992
|
setErrorMessage('');
|
|
914
|
-
astInfo = await fetchAndProcessASTFromPrompt(prompt, schemaData.schema, client, pivot, activeQuery, currentTable);
|
|
993
|
+
astInfo = await fetchAndProcessASTFromPrompt(prompt, schemaData.schema, client, pivot, activeQuery, currentTable, dashboardName);
|
|
915
994
|
if (astInfo.error) {
|
|
916
995
|
throw new Error(astInfo.error);
|
|
917
996
|
}
|
|
@@ -931,8 +1010,13 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
931
1010
|
astInfo.pivot = null;
|
|
932
1011
|
astInfo.ast.groupby = null;
|
|
933
1012
|
}
|
|
1013
|
+
const _tables = getTableNames(astInfo.ast);
|
|
1014
|
+
const _table = _tables[0] ? _tables[0] : '';
|
|
1015
|
+
const _columns = schemaData.schema.find((table) => {
|
|
1016
|
+
return table.name === _table;
|
|
1017
|
+
})?.columns;
|
|
934
1018
|
// parse the whereAst first
|
|
935
|
-
const filterTree = astToFilterTree(astInfo.whereAST, client.databaseType?.toLowerCase());
|
|
1019
|
+
const filterTree = astToFilterTree(astInfo.whereAST, client.databaseType?.toLowerCase(), _columns);
|
|
936
1020
|
const cleanAst = filterTree
|
|
937
1021
|
? filterTreeToAst(filterTree, client.databaseType?.toLowerCase())
|
|
938
1022
|
: null;
|
|
@@ -974,7 +1058,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
974
1058
|
return { pivot: null, hint: '' };
|
|
975
1059
|
};
|
|
976
1060
|
const isValidPivotForReport = (pivot, uniqueValuesForPivot, reportTable, reportColumns) => {
|
|
977
|
-
if (!isValidPivot(pivot)) {
|
|
1061
|
+
if (!isValidPivot(pivot).valid) {
|
|
978
1062
|
return false;
|
|
979
1063
|
}
|
|
980
1064
|
const uniqueValuesToCheck = uniqueValuesForPivot ?? uniqueValues;
|
|
@@ -1157,7 +1241,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1157
1241
|
flexDirection: 'column',
|
|
1158
1242
|
gap: 8,
|
|
1159
1243
|
marginBottom: 12,
|
|
1160
|
-
}, 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: {
|
|
1244
|
+
}, 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, dashboardName: dashboardName }) })), _jsxs("div", { style: {
|
|
1161
1245
|
display: 'flex',
|
|
1162
1246
|
flexDirection: 'column',
|
|
1163
1247
|
alignItems: 'flex-start',
|
|
@@ -1230,6 +1314,8 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1230
1314
|
report: tempReport,
|
|
1231
1315
|
client,
|
|
1232
1316
|
uniqueValues,
|
|
1317
|
+
dashboardName,
|
|
1318
|
+
tenants,
|
|
1233
1319
|
});
|
|
1234
1320
|
}
|
|
1235
1321
|
setPivotData(pivotTable || []);
|
|
@@ -1245,23 +1331,29 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1245
1331
|
finally {
|
|
1246
1332
|
setTableLoading(false);
|
|
1247
1333
|
}
|
|
1248
|
-
}, 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) => {
|
|
1334
|
+
}, 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, dashboardName: dashboardName }), pivot && (_jsx(PivotForm, { columns: columns, uniqueValues: uniqueValues[currentTable], uniqueValuesIsLoading: uniqueValuesIsLoading, setPivotRowField: (value) => {
|
|
1335
|
+
const prev = pivotRowField;
|
|
1249
1336
|
setPivotRowField(value);
|
|
1250
|
-
updatePivot(value, 'rowField');
|
|
1337
|
+
updatePivot(value, 'rowField', prev);
|
|
1251
1338
|
}, setPivotColumnField: (value) => {
|
|
1339
|
+
const prev = pivotColumnField;
|
|
1252
1340
|
setPivotColumnField(value);
|
|
1253
|
-
updatePivot(value, 'columnField');
|
|
1341
|
+
updatePivot(value, 'columnField', prev);
|
|
1254
1342
|
}, setPivotValueField: (value) => {
|
|
1343
|
+
const prev = pivotValueField;
|
|
1255
1344
|
setPivotValueField(value);
|
|
1256
|
-
updatePivot(value, 'valueField');
|
|
1345
|
+
updatePivot(value, 'valueField', prev);
|
|
1257
1346
|
}, setPivotValueField2: (value) => {
|
|
1347
|
+
const prev = pivotValueField2;
|
|
1258
1348
|
setPivotValueField2(value);
|
|
1259
|
-
updatePivot(value, 'valueField2');
|
|
1349
|
+
updatePivot(value, 'valueField2', prev);
|
|
1260
1350
|
}, setPivotAggregation: (value) => {
|
|
1351
|
+
const prev = pivotAggregation;
|
|
1261
1352
|
setPivotAggregation(value);
|
|
1262
|
-
updatePivot(value, 'aggregationType');
|
|
1353
|
+
updatePivot(value, 'aggregationType', prev);
|
|
1263
1354
|
}, onDelete: () => {
|
|
1264
1355
|
setPivot(null);
|
|
1356
|
+
setPivotError(undefined);
|
|
1265
1357
|
setPivotHint('');
|
|
1266
1358
|
setPivotData([]);
|
|
1267
1359
|
const formattedRows = formatRows(rows, columns, false);
|
|
@@ -1305,6 +1397,8 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1305
1397
|
report: tempReport,
|
|
1306
1398
|
client,
|
|
1307
1399
|
uniqueValues: uniqueValues[currentTable],
|
|
1400
|
+
dashboardName,
|
|
1401
|
+
tenants,
|
|
1308
1402
|
});
|
|
1309
1403
|
setPivotData(pivotedData || []);
|
|
1310
1404
|
const formattedRows = formatRows(pivotedData.rows, columns, true, pivot.aggregationType, dateBucket);
|
|
@@ -1352,6 +1446,8 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1352
1446
|
report: tempReport,
|
|
1353
1447
|
client,
|
|
1354
1448
|
uniqueValues: uniqueValues[currentTable],
|
|
1449
|
+
dashboardName,
|
|
1450
|
+
tenants,
|
|
1355
1451
|
});
|
|
1356
1452
|
setPivotData(pivotedData || []);
|
|
1357
1453
|
const formattedRows = formatRows(pivotedData.rows, columns, true, pivot.aggregationType, dateBucket);
|
|
@@ -1464,6 +1560,8 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1464
1560
|
report: tempReport,
|
|
1465
1561
|
client,
|
|
1466
1562
|
uniqueValues: uniqueValues[currentTable],
|
|
1563
|
+
dashboardName,
|
|
1564
|
+
tenants,
|
|
1467
1565
|
});
|
|
1468
1566
|
setErrorMessage('');
|
|
1469
1567
|
setPivotData(pivotedData || []);
|
|
@@ -1577,7 +1675,7 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1577
1675
|
field: c,
|
|
1578
1676
|
};
|
|
1579
1677
|
}), onPageChange: onPageChange, onSortChange: (sort) => {
|
|
1580
|
-
onSortChange(sort
|
|
1678
|
+
onSortChange(sort);
|
|
1581
1679
|
}, containerStyle: {
|
|
1582
1680
|
maxHeight: Math.max(window.innerHeight - 290, 75 + Math.min(Math.max(10, rows.length), 20) * 37),
|
|
1583
1681
|
} })), _jsxs("div", { style: {
|
|
@@ -1586,14 +1684,15 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1586
1684
|
gap: '12px',
|
|
1587
1685
|
width: '100%',
|
|
1588
1686
|
marginTop: 'auto',
|
|
1589
|
-
|
|
1687
|
+
alignItems: 'center',
|
|
1688
|
+
}, children: [errorMessage || pivotError ? (_jsxs("div", { style: {
|
|
1590
1689
|
display: 'flex',
|
|
1591
1690
|
flexDirection: 'row',
|
|
1592
1691
|
overflow: 'hidden',
|
|
1593
1692
|
width: '100%',
|
|
1594
1693
|
gap: 12,
|
|
1595
1694
|
alignItems: 'center',
|
|
1596
|
-
}, children: [_jsx(ErrorMessageComponent, { errorMessage: errorMessage }), _jsx(SecondaryButtonComponent, { onClick: () => {
|
|
1695
|
+
}, children: [_jsx(ErrorMessageComponent, { errorMessage: errorMessage || pivotError || '' }), _jsx(SecondaryButtonComponent, { onClick: () => {
|
|
1597
1696
|
fetchAstFromPromptHelper();
|
|
1598
1697
|
}, label: 'Retry' }), _jsx(SecondaryButtonComponent, { onClick: clearAllState, label: 'Reset' })] })) : (_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 () => {
|
|
1599
1698
|
onSaveChanges && onSaveChanges();
|
|
@@ -1611,27 +1710,44 @@ SidebarComponent = QuillSidebar, ContainerComponent = CustomContainer, SelectCol
|
|
|
1611
1710
|
yAxisFields: reportInfo?.pivot && !pivot
|
|
1612
1711
|
? []
|
|
1613
1712
|
: reportInfo?.yAxisFields,
|
|
1614
|
-
columns:
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1713
|
+
columns: selectedOrderedColumns.length > 0
|
|
1714
|
+
? selectedOrderedColumns
|
|
1715
|
+
.map((columnName) => {
|
|
1716
|
+
return columns.find((col) => col.field === columnName);
|
|
1717
|
+
})
|
|
1718
|
+
.filter((col) => col !== undefined)
|
|
1719
|
+
.map((c) => reportInfo?.columns.find((col) => col.field === c.field))
|
|
1720
|
+
.filter((col) => col !== undefined)
|
|
1721
|
+
: reportInfo?.columns.filter((col) => {
|
|
1722
|
+
return columns.find((c) => {
|
|
1723
|
+
return col.field === c.field;
|
|
1724
|
+
});
|
|
1725
|
+
}),
|
|
1619
1726
|
queryString: activeQuery,
|
|
1620
1727
|
rows: rows,
|
|
1621
1728
|
pivotRows: pivotData?.rows,
|
|
1622
1729
|
pivotColumns: pivotData?.columns,
|
|
1730
|
+
flags: reportInfo?.flags ??
|
|
1731
|
+
tempReport?.flags
|
|
1732
|
+
// flagsToAdd,
|
|
1623
1733
|
}
|
|
1624
1734
|
: {
|
|
1625
1735
|
...tempReport,
|
|
1626
1736
|
id: TEMP_REPORT_ID,
|
|
1737
|
+
flags: tempReport?.flags,
|
|
1627
1738
|
}),
|
|
1628
1739
|
},
|
|
1629
1740
|
});
|
|
1630
1741
|
setIsChartBuilderOpen(true);
|
|
1631
1742
|
}, disabled: !!errorMessage ||
|
|
1743
|
+
!!pivotError ||
|
|
1632
1744
|
tableLoading ||
|
|
1633
1745
|
loading ||
|
|
1634
|
-
unresolvedReportMessage, label: reportId ? 'Save changes' : 'Add to dashboard', tooltipText: unresolvedReportMessage })] }))] })] }), _jsx("style", { children: `body{margin:0;}` })] })), (!isChartBuilderHorizontalView || isChartBuilderOpen) && (_jsx(ChartBuilderWithModal, { reportId: reportId, isAdmin: isAdminEnabled, title:
|
|
1746
|
+
unresolvedReportMessage, label: reportId ? 'Save changes' : 'Add to dashboard', tooltipText: unresolvedReportMessage })] }))] })] }), _jsx("style", { children: `body{margin:0;}` })] })), (!isChartBuilderHorizontalView || isChartBuilderOpen) && (_jsx(ChartBuilderWithModal, { reportId: reportId, isAdmin: isAdminEnabled, title: chartBuilderTitle
|
|
1747
|
+
? chartBuilderTitle
|
|
1748
|
+
: reportId
|
|
1749
|
+
? 'Save changes'
|
|
1750
|
+
: 'Add to dashboard', isHorizontalView: true, isOpen: isChartBuilderOpen, setIsOpen: setIsChartBuilderOpen, onAddToDashboardComplete: reportId ? onSubmitEditReport : onSubmitCreateReport, organizationName: organizationName, 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, filtersEnabled: filtersEnabled, onFiltersEnabledChanged: (enabled) => {
|
|
1635
1751
|
setFiltersEnabled(enabled);
|
|
1636
|
-
}, isEditingMode: true }))] }));
|
|
1752
|
+
}, isEditingMode: true, flagsList: flagsList }))] }));
|
|
1637
1753
|
}
|
package/dist/esm/SQLEditor.d.ts
CHANGED
|
@@ -249,6 +249,10 @@ export interface SQLEditorProps {
|
|
|
249
249
|
* Styles the top-level container of the SQLEditor.
|
|
250
250
|
*/
|
|
251
251
|
containerStyle?: React.CSSProperties;
|
|
252
|
+
/**
|
|
253
|
+
* A list of flags that can be applied to the resulting report (for single tenant per database setups)
|
|
254
|
+
*/
|
|
255
|
+
flagsList?: string[];
|
|
252
256
|
}
|
|
253
257
|
/**
|
|
254
258
|
* ### Quill SQLEditor
|
|
@@ -275,7 +279,7 @@ export interface SQLEditorProps {
|
|
|
275
279
|
* ### SQLEditor API
|
|
276
280
|
* @see https://docs.quillsql.com/components/sql-editor
|
|
277
281
|
*/
|
|
278
|
-
export default function SQLEditor({ ButtonComponent, SecondaryButtonComponent, DeleteButtonComponent, TextInputComponent, SelectComponent, TableComponent, isNewQueryEnabled, LoadingComponent, ModalComponent, PopoverComponent, CardComponent, LabelComponent, HeaderComponent, SubHeaderComponent, TextComponent, ErrorMessageComponent, ChartBuilderInputRowContainer, ChartBuilderInputColumnContainer, PivotRowContainer, PivotColumnContainer, ChartBuilderFormContainer, defaultQuery, destinationDashboard, onChangeQuery, onChangeData, onChangeColumns, onChangeFields, onDiscardChanges, onSaveChanges, onCloseChartBuilder, isChartBuilderEnabled, isAdminEnabled, chartBuilderTitle, runQueryOnMount, onAddToDashboardComplete, addToDashboardButtonLabel, report, organizationName, isChartBuilderHorizontalView, containerStyle, className, onClickChartElement, }: SQLEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
282
|
+
export default function SQLEditor({ ButtonComponent, SecondaryButtonComponent, DeleteButtonComponent, TextInputComponent, SelectComponent, TableComponent, isNewQueryEnabled, LoadingComponent, ModalComponent, PopoverComponent, CardComponent, LabelComponent, HeaderComponent, SubHeaderComponent, TextComponent, ErrorMessageComponent, ChartBuilderInputRowContainer, ChartBuilderInputColumnContainer, PivotRowContainer, PivotColumnContainer, ChartBuilderFormContainer, defaultQuery, destinationDashboard, onChangeQuery, onChangeData, onChangeColumns, onChangeFields, onDiscardChanges, onSaveChanges, onCloseChartBuilder, isChartBuilderEnabled, isAdminEnabled, chartBuilderTitle, runQueryOnMount, onAddToDashboardComplete, addToDashboardButtonLabel, report, organizationName, isChartBuilderHorizontalView, containerStyle, className, onClickChartElement, flagsList, }: SQLEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
279
283
|
export declare const SchemaListComponent: ({ schema, theme, loading, LoadingComponent, width, onClick, style, }: {
|
|
280
284
|
schema: any;
|
|
281
285
|
theme: any;
|