@quillsql/react 2.14.14 → 2.14.16
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 +0 -12
- package/dist/cjs/ChartBuilder.d.ts +2 -3
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +23 -107
- package/dist/cjs/ChartEditor.d.ts.map +1 -1
- package/dist/cjs/ChartEditor.js +0 -2
- package/dist/cjs/Context.d.ts +2 -6
- package/dist/cjs/Context.d.ts.map +1 -1
- package/dist/cjs/Context.js +32 -159
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/Dashboard.js +16 -93
- package/dist/cjs/QuillProvider.d.ts +1 -38
- package/dist/cjs/QuillProvider.d.ts.map +1 -1
- package/dist/cjs/QuillProvider.js +2 -2
- package/dist/cjs/ReportBuilder.d.ts +1 -4
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +1270 -103
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +6 -50
- package/dist/cjs/Table.d.ts.map +1 -1
- package/dist/cjs/Table.js +0 -12
- package/dist/cjs/components/Chart/InternalChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/InternalChart.js +1 -24
- package/dist/cjs/components/Dashboard/DashboardTemplate.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DashboardTemplate.js +1 -2
- package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.js +2 -73
- package/dist/cjs/components/Dashboard/util.d.ts +1 -2
- package/dist/cjs/components/Dashboard/util.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/util.js +1 -12
- package/dist/cjs/components/QuillTable.d.ts +1 -2
- package/dist/cjs/components/QuillTable.d.ts.map +1 -1
- package/dist/cjs/components/QuillTable.js +2 -2
- package/dist/cjs/components/ReportBuilder/AddColumnModal.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddColumnModal.js +1 -7
- package/dist/cjs/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/ui.js +1 -3
- package/dist/cjs/components/UiComponents.d.ts +2 -5
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +5 -6
- package/dist/cjs/hooks/useAskQuill.d.ts.map +1 -1
- package/dist/cjs/hooks/useAskQuill.js +0 -38
- package/dist/cjs/hooks/useDashboard.d.ts.map +1 -1
- package/dist/cjs/hooks/useDashboard.js +4 -60
- package/dist/cjs/hooks/useExport.d.ts.map +1 -1
- package/dist/cjs/hooks/useExport.js +2 -5
- package/dist/cjs/hooks/useQuill.d.ts.map +1 -1
- package/dist/cjs/hooks/useQuill.js +1 -25
- package/dist/cjs/hooks/useVirtualTables.d.ts.map +1 -1
- package/dist/cjs/hooks/useVirtualTables.js +2 -27
- package/dist/cjs/index.d.ts +0 -11
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -17
- package/dist/cjs/internals/ReportBuilder/PivotForm.d.ts +1 -14
- package/dist/cjs/internals/ReportBuilder/PivotForm.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotForm.js +4 -87
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts +2 -18
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.js +141 -420
- package/dist/cjs/utils/astProcessing.d.ts +2 -4
- package/dist/cjs/utils/astProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/astProcessing.js +2 -25
- package/dist/cjs/utils/client.d.ts +1 -2
- package/dist/cjs/utils/client.d.ts.map +1 -1
- package/dist/cjs/utils/client.js +1 -12
- package/dist/cjs/utils/dashboard.d.ts +1 -3
- package/dist/cjs/utils/dashboard.d.ts.map +1 -1
- package/dist/cjs/utils/dashboard.js +3 -44
- package/dist/cjs/utils/filterProcessing.d.ts +1 -2
- package/dist/cjs/utils/filterProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/filterProcessing.js +1 -12
- package/dist/cjs/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/pivotConstructor.js +21 -15
- package/dist/cjs/utils/pivotProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/pivotProcessing.js +3 -1
- package/dist/cjs/utils/queryConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/queryConstructor.js +19 -11
- package/dist/cjs/utils/report.d.ts +5 -10
- package/dist/cjs/utils/report.d.ts.map +1 -1
- package/dist/cjs/utils/report.js +7 -51
- package/dist/cjs/utils/reportBuilder.d.ts.map +1 -1
- package/dist/cjs/utils/reportBuilder.js +2 -5
- package/dist/cjs/utils/schema.d.ts +2 -5
- package/dist/cjs/utils/schema.d.ts.map +1 -1
- package/dist/cjs/utils/schema.js +2 -14
- package/dist/cjs/utils/tableProcessing.d.ts +10 -17
- package/dist/cjs/utils/tableProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/tableProcessing.js +17 -99
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +1 -13
- package/dist/esm/ChartBuilder.d.ts +2 -3
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +25 -109
- package/dist/esm/ChartEditor.d.ts.map +1 -1
- package/dist/esm/ChartEditor.js +1 -3
- package/dist/esm/Context.d.ts +2 -6
- package/dist/esm/Context.d.ts.map +1 -1
- package/dist/esm/Context.js +31 -158
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/Dashboard.js +17 -94
- package/dist/esm/QuillProvider.d.ts +1 -38
- package/dist/esm/QuillProvider.d.ts.map +1 -1
- package/dist/esm/QuillProvider.js +2 -2
- package/dist/esm/ReportBuilder.d.ts +1 -4
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +1270 -106
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +7 -51
- package/dist/esm/Table.d.ts.map +1 -1
- package/dist/esm/Table.js +1 -13
- package/dist/esm/components/Chart/InternalChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/InternalChart.js +2 -25
- package/dist/esm/components/Dashboard/DashboardTemplate.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DashboardTemplate.js +2 -3
- package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.js +3 -74
- package/dist/esm/components/Dashboard/util.d.ts +1 -2
- package/dist/esm/components/Dashboard/util.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/util.js +1 -12
- package/dist/esm/components/QuillTable.d.ts +1 -2
- package/dist/esm/components/QuillTable.d.ts.map +1 -1
- package/dist/esm/components/QuillTable.js +2 -2
- package/dist/esm/components/ReportBuilder/AddColumnModal.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddColumnModal.js +1 -7
- package/dist/esm/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/ui.js +2 -4
- package/dist/esm/components/UiComponents.d.ts +2 -5
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +5 -6
- package/dist/esm/hooks/useAskQuill.d.ts.map +1 -1
- package/dist/esm/hooks/useAskQuill.js +1 -39
- package/dist/esm/hooks/useDashboard.d.ts.map +1 -1
- package/dist/esm/hooks/useDashboard.js +5 -61
- package/dist/esm/hooks/useExport.d.ts.map +1 -1
- package/dist/esm/hooks/useExport.js +3 -6
- package/dist/esm/hooks/useQuill.d.ts.map +1 -1
- package/dist/esm/hooks/useQuill.js +2 -26
- package/dist/esm/hooks/useVirtualTables.d.ts.map +1 -1
- package/dist/esm/hooks/useVirtualTables.js +3 -28
- package/dist/esm/index.d.ts +0 -11
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +0 -8
- package/dist/esm/internals/ReportBuilder/PivotForm.d.ts +1 -14
- package/dist/esm/internals/ReportBuilder/PivotForm.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotForm.js +5 -88
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts +2 -18
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.js +143 -422
- package/dist/esm/utils/astProcessing.d.ts +2 -4
- package/dist/esm/utils/astProcessing.d.ts.map +1 -1
- package/dist/esm/utils/astProcessing.js +2 -25
- package/dist/esm/utils/client.d.ts +1 -2
- package/dist/esm/utils/client.d.ts.map +1 -1
- package/dist/esm/utils/client.js +1 -12
- package/dist/esm/utils/dashboard.d.ts +1 -3
- package/dist/esm/utils/dashboard.d.ts.map +1 -1
- package/dist/esm/utils/dashboard.js +3 -44
- package/dist/esm/utils/filterProcessing.d.ts +1 -2
- package/dist/esm/utils/filterProcessing.d.ts.map +1 -1
- package/dist/esm/utils/filterProcessing.js +1 -12
- package/dist/esm/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/esm/utils/pivotConstructor.js +21 -15
- package/dist/esm/utils/pivotProcessing.d.ts.map +1 -1
- package/dist/esm/utils/pivotProcessing.js +3 -1
- package/dist/esm/utils/queryConstructor.d.ts.map +1 -1
- package/dist/esm/utils/queryConstructor.js +19 -11
- package/dist/esm/utils/report.d.ts +5 -10
- package/dist/esm/utils/report.d.ts.map +1 -1
- package/dist/esm/utils/report.js +7 -51
- package/dist/esm/utils/reportBuilder.d.ts.map +1 -1
- package/dist/esm/utils/reportBuilder.js +2 -5
- package/dist/esm/utils/schema.d.ts +2 -5
- package/dist/esm/utils/schema.d.ts.map +1 -1
- package/dist/esm/utils/schema.js +2 -14
- package/dist/esm/utils/tableProcessing.d.ts +10 -17
- package/dist/esm/utils/tableProcessing.d.ts.map +1 -1
- package/dist/esm/utils/tableProcessing.js +17 -99
- package/package.json +1 -1
- package/dist/cjs/components/ReportBuilder/ColumnComponent.d.ts +0 -48
- package/dist/cjs/components/ReportBuilder/ColumnComponent.d.ts.map +0 -1
- package/dist/cjs/components/ReportBuilder/ColumnComponent.js +0 -46
- package/dist/cjs/components/ReportBuilder/FilterComponent.d.ts +0 -65
- package/dist/cjs/components/ReportBuilder/FilterComponent.d.ts.map +0 -1
- package/dist/cjs/components/ReportBuilder/FilterComponent.js +0 -51
- package/dist/cjs/components/ReportBuilder/LimitComponent.d.ts +0 -42
- package/dist/cjs/components/ReportBuilder/LimitComponent.d.ts.map +0 -1
- package/dist/cjs/components/ReportBuilder/LimitComponent.js +0 -50
- package/dist/cjs/components/ReportBuilder/PivotComponent.d.ts +0 -66
- package/dist/cjs/components/ReportBuilder/PivotComponent.d.ts.map +0 -1
- package/dist/cjs/components/ReportBuilder/PivotComponent.js +0 -47
- package/dist/cjs/components/ReportBuilder/SaveReport.d.ts +0 -162
- package/dist/cjs/components/ReportBuilder/SaveReport.d.ts.map +0 -1
- package/dist/cjs/components/ReportBuilder/SaveReport.js +0 -31
- package/dist/cjs/components/ReportBuilder/SortComponent.d.ts +0 -42
- package/dist/cjs/components/ReportBuilder/SortComponent.d.ts.map +0 -1
- package/dist/cjs/components/ReportBuilder/SortComponent.js +0 -50
- package/dist/cjs/components/ReportBuilder/TableComponent.d.ts +0 -28
- package/dist/cjs/components/ReportBuilder/TableComponent.d.ts.map +0 -1
- package/dist/cjs/components/ReportBuilder/TableComponent.js +0 -24
- package/dist/cjs/hooks/useLongLoading.d.ts +0 -13
- package/dist/cjs/hooks/useLongLoading.d.ts.map +0 -1
- package/dist/cjs/hooks/useLongLoading.js +0 -67
- package/dist/cjs/hooks/useReportBuilder.d.ts +0 -178
- package/dist/cjs/hooks/useReportBuilder.d.ts.map +0 -1
- package/dist/cjs/hooks/useReportBuilder.js +0 -1476
- package/dist/esm/components/ReportBuilder/ColumnComponent.d.ts +0 -48
- package/dist/esm/components/ReportBuilder/ColumnComponent.d.ts.map +0 -1
- package/dist/esm/components/ReportBuilder/ColumnComponent.js +0 -39
- package/dist/esm/components/ReportBuilder/FilterComponent.d.ts +0 -65
- package/dist/esm/components/ReportBuilder/FilterComponent.d.ts.map +0 -1
- package/dist/esm/components/ReportBuilder/FilterComponent.js +0 -44
- package/dist/esm/components/ReportBuilder/LimitComponent.d.ts +0 -42
- package/dist/esm/components/ReportBuilder/LimitComponent.d.ts.map +0 -1
- package/dist/esm/components/ReportBuilder/LimitComponent.js +0 -46
- package/dist/esm/components/ReportBuilder/PivotComponent.d.ts +0 -66
- package/dist/esm/components/ReportBuilder/PivotComponent.d.ts.map +0 -1
- package/dist/esm/components/ReportBuilder/PivotComponent.js +0 -40
- package/dist/esm/components/ReportBuilder/SaveReport.d.ts +0 -162
- package/dist/esm/components/ReportBuilder/SaveReport.d.ts.map +0 -1
- package/dist/esm/components/ReportBuilder/SaveReport.js +0 -31
- package/dist/esm/components/ReportBuilder/SortComponent.d.ts +0 -42
- package/dist/esm/components/ReportBuilder/SortComponent.d.ts.map +0 -1
- package/dist/esm/components/ReportBuilder/SortComponent.js +0 -46
- package/dist/esm/components/ReportBuilder/TableComponent.d.ts +0 -28
- package/dist/esm/components/ReportBuilder/TableComponent.d.ts.map +0 -1
- package/dist/esm/components/ReportBuilder/TableComponent.js +0 -20
- package/dist/esm/hooks/useLongLoading.d.ts +0 -13
- package/dist/esm/hooks/useLongLoading.d.ts.map +0 -1
- package/dist/esm/hooks/useLongLoading.js +0 -64
- package/dist/esm/hooks/useReportBuilder.d.ts +0 -178
- package/dist/esm/hooks/useReportBuilder.d.ts.map +0 -1
- package/dist/esm/hooks/useReportBuilder.js +0 -1471
|
@@ -27,7 +27,7 @@ const pivotConstructor_1 = require("../../utils/pivotConstructor");
|
|
|
27
27
|
const dates_1 = require("../../utils/dates");
|
|
28
28
|
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
|
29
29
|
const columnProcessing_1 = require("../../utils/columnProcessing");
|
|
30
|
-
const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivotColumnField, pivotAggregations, setPivotAggregations,
|
|
30
|
+
const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivotColumnField, pivotAggregations, setPivotAggregations, popUpTitle, setPopUpTitle, selectedTable, SelectComponent, ButtonComponent, SecondaryButtonComponent, PopoverComponent, ErrorMessageComponent = UiComponents_1.QuillErrorMessageComponent, PivotRowContainer = UiComponents_1.QuillPivotRowContainer, PivotColumnContainer = UiComponents_1.QuillPivotColumnContainer, LoadingComponent = UiComponents_1.QuillLoadingComponent, CardComponent = QuillCard_1.QuillCard, HeaderComponent, SubheaderComponent = UiComponents_1.MemoizedSubHeader, DeleteButtonComponent = UiComponents_1.MemoizedDeleteButton, LabelComponent, TextComponent, selectedPivotIndex, setSelectedPivotIndex, removePivot, selectPivot, showUpdatePivot, setShowUpdatePivot, data, columns, theme, isOpen, setIsOpen, dateRange, createdPivots, setCreatedPivots, recommendedPivots, setRecommendedPivots, triggerButtonText = 'Pivot', showPivotEditButton = false, showEditOnPivotClick = true, showTrigger = true, pivotCountRequest = 6, query, initialUniqueValues, uniqueValuesIsLoading, initialSelectedPivotTable, disabled = false, pivotRecommendationsEnabled = true, report, dashboardName, dateFilter, }) => {
|
|
31
31
|
const { getToken, quillFetchWithToken } = (0, react_1.useContext)(Context_1.FetchContext);
|
|
32
32
|
const [isLoading, setIsLoading] = (0, react_1.useState)(false);
|
|
33
33
|
const [previewLoading, setPreviewLoading] = (0, react_1.useState)(false);
|
|
@@ -37,7 +37,6 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
37
37
|
const [client] = (0, react_1.useContext)(Context_1.ClientContext);
|
|
38
38
|
const [schemaData] = (0, react_1.useContext)(Context_1.SchemaDataContext);
|
|
39
39
|
const { tenants } = (0, react_1.useContext)(Context_1.TenantContext);
|
|
40
|
-
const { eventTracking } = (0, react_1.useContext)(Context_1.EventTrackingContext);
|
|
41
40
|
const rowFieldRef = (0, react_1.useRef)(null);
|
|
42
41
|
const colFieldRef = (0, react_1.useRef)(null);
|
|
43
42
|
const [pivotCardWidth, setPivotCardWidth] = (0, react_1.useState)(420);
|
|
@@ -52,15 +51,6 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
52
51
|
// const percentageAggButtonRef = useRef<HTMLDivElement>(null);
|
|
53
52
|
const [dateRanges, setDateRanges] = (0, react_1.useState)({});
|
|
54
53
|
const [pivotError, setPivotError] = (0, react_1.useState)('');
|
|
55
|
-
const [limitInput, setLimitInput] = (0, react_1.useState)(pivotLimit?.toString() ?? '100');
|
|
56
|
-
const [sortFieldInput, setSortFieldInput] = (0, react_1.useState)(pivotSort?.sortField ?? '');
|
|
57
|
-
const [sortDirectionInput, setSortDirectionInput] = (0, react_1.useState)(pivotSort?.sortDirection ?? 'ASC');
|
|
58
|
-
const [showLimitInput, setShowLimitInput] = (0, react_1.useState)(!!pivotLimit);
|
|
59
|
-
const [showSortInput, setShowSortInput] = (0, react_1.useState)(!!pivotSort);
|
|
60
|
-
const [availableHeight, setAvailableHeight] = (0, react_1.useState)(0);
|
|
61
|
-
const [pivotModalTopHeight, setPivotModalTopHeight] = (0, react_1.useState)(450);
|
|
62
|
-
const [popoverPosition, setPopoverPosition] = (0, react_1.useState)('bottom');
|
|
63
|
-
const popoverRef = (0, react_1.useRef)(null);
|
|
64
54
|
const getDistinctValues = async (fetchDistinct) => {
|
|
65
55
|
if (!client) {
|
|
66
56
|
return {
|
|
@@ -81,7 +71,7 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
81
71
|
}
|
|
82
72
|
let newUniqueValues = uniqueValues ?? null;
|
|
83
73
|
if (fetchDistinct || !uniqueValues) {
|
|
84
|
-
const { filteredColumns: smallStringColumns, exceededColumns } = await (0, tableProcessing_1.getCountsByColumns)(stringColumns, query || '', client, getToken, tenants, schemaData.customFields ?? {},
|
|
74
|
+
const { filteredColumns: smallStringColumns, exceededColumns } = await (0, tableProcessing_1.getCountsByColumns)(stringColumns, query || '', client, getToken, tenants, schemaData.customFields ?? {}, dashboardName);
|
|
85
75
|
newUniqueValues = await (0, tableProcessing_1.getUniqueValuesByQuery)({
|
|
86
76
|
columns: smallStringColumns,
|
|
87
77
|
query: query || '',
|
|
@@ -90,7 +80,6 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
90
80
|
tenants,
|
|
91
81
|
customFields: schemaData.customFields ?? {},
|
|
92
82
|
dashboardName,
|
|
93
|
-
eventTracking,
|
|
94
83
|
});
|
|
95
84
|
exceededColumns?.forEach((column) => {
|
|
96
85
|
if (newUniqueValues) {
|
|
@@ -122,7 +111,7 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
122
111
|
if (dateColumns.length === 0) {
|
|
123
112
|
return;
|
|
124
113
|
}
|
|
125
|
-
const dateRangeByColumn = await (0, tableProcessing_1.getQueryDateRangeByColumns)(dateColumns, query || '', client, getToken, tenants,
|
|
114
|
+
const dateRangeByColumn = await (0, tableProcessing_1.getQueryDateRangeByColumns)(dateColumns, query || '', client, getToken, tenants, schemaData.customFields ?? {}, dashboardName);
|
|
126
115
|
setDateRanges(dateRangeByColumn || {});
|
|
127
116
|
}
|
|
128
117
|
};
|
|
@@ -188,22 +177,10 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
188
177
|
page: { rowsPerPage: 6, rowsPerRequest: 6, page: 0 },
|
|
189
178
|
}, // limit preview
|
|
190
179
|
getToken,
|
|
191
|
-
eventTracking,
|
|
192
180
|
});
|
|
193
181
|
setSamplePivotTable({ pivot: pivot, rows, columns });
|
|
194
182
|
}
|
|
195
183
|
catch (e) {
|
|
196
|
-
eventTracking?.logError?.({
|
|
197
|
-
type: 'bug', // TODO: determine type
|
|
198
|
-
severity: 'high',
|
|
199
|
-
message: 'Error fetching pivot data',
|
|
200
|
-
errorMessage: e.message,
|
|
201
|
-
errorStack: e.stack,
|
|
202
|
-
errorData: {
|
|
203
|
-
caller: 'PivotModal',
|
|
204
|
-
function: 'fetchPivotData',
|
|
205
|
-
},
|
|
206
|
-
});
|
|
207
184
|
if (e instanceof Error) {
|
|
208
185
|
setPivotError(e.message);
|
|
209
186
|
return;
|
|
@@ -261,22 +238,10 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
261
238
|
page: { rowsPerPage: 6, rowsPerRequest: 6, page: 0 },
|
|
262
239
|
}, // limit preview
|
|
263
240
|
getToken,
|
|
264
|
-
eventTracking,
|
|
265
241
|
});
|
|
266
242
|
setSamplePivotTable({ pivot: pivot, rows, columns });
|
|
267
243
|
}
|
|
268
244
|
catch (e) {
|
|
269
|
-
eventTracking?.logError?.({
|
|
270
|
-
type: 'bug', // TODO: determine type
|
|
271
|
-
severity: 'high',
|
|
272
|
-
message: 'Error fetching pivot data',
|
|
273
|
-
errorMessage: e.message,
|
|
274
|
-
errorStack: e.stack,
|
|
275
|
-
errorData: {
|
|
276
|
-
caller: 'PivotModal',
|
|
277
|
-
function: 'fetchPivotData',
|
|
278
|
-
},
|
|
279
|
-
});
|
|
280
245
|
if (e instanceof Error) {
|
|
281
246
|
setPivotError(e.message);
|
|
282
247
|
return;
|
|
@@ -344,7 +309,6 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
344
309
|
page: { rowsPerPage: 6, rowsPerRequest: 6, page: 0 },
|
|
345
310
|
}, // limit preview
|
|
346
311
|
getToken,
|
|
347
|
-
eventTracking,
|
|
348
312
|
});
|
|
349
313
|
setSelectedPivotTable({
|
|
350
314
|
pivot: pivot,
|
|
@@ -353,17 +317,6 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
353
317
|
});
|
|
354
318
|
}
|
|
355
319
|
catch (e) {
|
|
356
|
-
eventTracking?.logError?.({
|
|
357
|
-
type: 'bug', // TODO: determine type
|
|
358
|
-
severity: 'high',
|
|
359
|
-
message: 'Error fetching pivot tables',
|
|
360
|
-
errorMessage: e.message,
|
|
361
|
-
errorStack: e.stack,
|
|
362
|
-
errorData: {
|
|
363
|
-
caller: 'PivotModal',
|
|
364
|
-
function: 'fetchPivotTables',
|
|
365
|
-
},
|
|
366
|
-
});
|
|
367
320
|
if (e instanceof Error) {
|
|
368
321
|
setPivotError(e.message);
|
|
369
322
|
return;
|
|
@@ -424,15 +377,8 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
424
377
|
if (pivotColumnField && !columnsToShow[pivotColumnField]) {
|
|
425
378
|
errors.push('Error in column field: undefined type');
|
|
426
379
|
}
|
|
427
|
-
if (showLimitInput && limitInput && !Number.isInteger(Number(limitInput))) {
|
|
428
|
-
errors.push('Limit must be an integer');
|
|
429
|
-
}
|
|
430
380
|
if (errors.length === 0 &&
|
|
431
381
|
pivotAggregations?.every((p) => p.aggregationType && (p.valueField || p.aggregationType === 'count'))) {
|
|
432
|
-
const sort = showSortInput && !!sortFieldInput && !!sortDirectionInput;
|
|
433
|
-
const sortField = sort ? sortFieldInput : undefined;
|
|
434
|
-
const sortDirection = sort ? sortDirectionInput : undefined;
|
|
435
|
-
const rowLimit = showLimitInput && limitInput ? Number(limitInput) : undefined;
|
|
436
382
|
const pivot = {
|
|
437
383
|
rowField: pivotRowField,
|
|
438
384
|
rowFieldType: columnTypes[pivotRowField ?? ''],
|
|
@@ -445,10 +391,6 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
445
391
|
valueField2Type: columnTypes[p.valueField2 ?? ''],
|
|
446
392
|
aggregationType: p.aggregationType,
|
|
447
393
|
})),
|
|
448
|
-
sort,
|
|
449
|
-
sortField,
|
|
450
|
-
sortDirection,
|
|
451
|
-
rowLimit,
|
|
452
394
|
// For backwards compatibility
|
|
453
395
|
valueField: pivotAggregations?.[0]?.valueField,
|
|
454
396
|
valueFieldType: columnTypes[pivotAggregations?.[0]?.valueField ?? ''],
|
|
@@ -469,16 +411,7 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
469
411
|
}
|
|
470
412
|
}
|
|
471
413
|
setErrors(errors);
|
|
472
|
-
}, [
|
|
473
|
-
pivotRowField,
|
|
474
|
-
pivotColumnField,
|
|
475
|
-
pivotAggregations,
|
|
476
|
-
sortFieldInput,
|
|
477
|
-
sortDirectionInput,
|
|
478
|
-
showSortInput,
|
|
479
|
-
showLimitInput,
|
|
480
|
-
limitInput,
|
|
481
|
-
]);
|
|
414
|
+
}, [pivotRowField, pivotColumnField, pivotAggregations]);
|
|
482
415
|
const onEditPivot = async (pivot, index, pivotType) => {
|
|
483
416
|
setIsLoading(false);
|
|
484
417
|
setErrors([]);
|
|
@@ -511,23 +444,11 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
511
444
|
page: { rowsPerPage: 6, rowsPerRequest: 6, page: 0 },
|
|
512
445
|
}, // limit preview
|
|
513
446
|
getToken,
|
|
514
|
-
eventTracking,
|
|
515
447
|
});
|
|
516
448
|
setSamplePivotTable({ pivot, rows, columns });
|
|
517
449
|
return;
|
|
518
450
|
}
|
|
519
451
|
catch (e) {
|
|
520
|
-
eventTracking?.logError?.({
|
|
521
|
-
type: 'bug', // TODO: determine type
|
|
522
|
-
severity: 'high',
|
|
523
|
-
message: 'Error fetching pivot data',
|
|
524
|
-
errorMessage: e.message,
|
|
525
|
-
errorStack: e.stack,
|
|
526
|
-
errorData: {
|
|
527
|
-
caller: 'PivotModal',
|
|
528
|
-
function: 'onEditPivot',
|
|
529
|
-
},
|
|
530
|
-
});
|
|
531
452
|
if (e instanceof Error) {
|
|
532
453
|
setPivotError(e.message);
|
|
533
454
|
setSamplePivotTable(null);
|
|
@@ -637,22 +558,10 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
637
558
|
page: { rowsPerPage: 6, rowsPerRequest: 6, page: 0 },
|
|
638
559
|
}, // limit preview
|
|
639
560
|
getToken,
|
|
640
|
-
eventTracking,
|
|
641
561
|
});
|
|
642
562
|
return { pivot: p, rows, columns };
|
|
643
563
|
}
|
|
644
564
|
catch (e) {
|
|
645
|
-
eventTracking?.logError?.({
|
|
646
|
-
type: 'bug', // TODO: determine type
|
|
647
|
-
severity: 'high',
|
|
648
|
-
message: 'Error fetching pivot data',
|
|
649
|
-
errorMessage: e.message,
|
|
650
|
-
errorStack: e.stack,
|
|
651
|
-
errorData: {
|
|
652
|
-
caller: 'PivotModal',
|
|
653
|
-
function: 'refreshPivots',
|
|
654
|
-
},
|
|
655
|
-
});
|
|
656
565
|
return undefined;
|
|
657
566
|
}
|
|
658
567
|
}));
|
|
@@ -676,17 +585,6 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
676
585
|
setSelectedPivotIndex(-1);
|
|
677
586
|
}
|
|
678
587
|
catch (e) {
|
|
679
|
-
eventTracking?.logError?.({
|
|
680
|
-
type: 'bug', // TODO: determine type
|
|
681
|
-
severity: 'high',
|
|
682
|
-
message: 'Error fetching pivot recommendations',
|
|
683
|
-
errorMessage: e.message,
|
|
684
|
-
errorStack: e.stack,
|
|
685
|
-
errorData: {
|
|
686
|
-
caller: 'PivotModal',
|
|
687
|
-
function: 'refreshPivots',
|
|
688
|
-
},
|
|
689
|
-
});
|
|
690
588
|
setPivotError('Failed to fetch pivot recommendations');
|
|
691
589
|
console.error('Failed parsing pivotai response', e);
|
|
692
590
|
}
|
|
@@ -799,22 +697,10 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
799
697
|
page: { rowsPerPage: 6, rowsPerRequest: 6, page: 0 },
|
|
800
698
|
}, // limit preview
|
|
801
699
|
getToken,
|
|
802
|
-
eventTracking,
|
|
803
700
|
});
|
|
804
701
|
setSamplePivotTable({ pivot, rows, columns });
|
|
805
702
|
}
|
|
806
703
|
catch (e) {
|
|
807
|
-
eventTracking?.logError?.({
|
|
808
|
-
type: 'bug', // TODO: determine type
|
|
809
|
-
severity: 'high',
|
|
810
|
-
message: 'Error fetching pivot data',
|
|
811
|
-
errorMessage: e.message,
|
|
812
|
-
errorStack: e.stack,
|
|
813
|
-
errorData: {
|
|
814
|
-
caller: 'PivotModal',
|
|
815
|
-
function: 'pivotFieldChange',
|
|
816
|
-
},
|
|
817
|
-
});
|
|
818
704
|
if (e instanceof Error) {
|
|
819
705
|
console.log('error', e);
|
|
820
706
|
setPivotError(e.message);
|
|
@@ -845,22 +731,10 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
845
731
|
page: { rowsPerPage: 6, rowsPerRequest: 6, page: 0 },
|
|
846
732
|
},
|
|
847
733
|
getToken,
|
|
848
|
-
eventTracking,
|
|
849
734
|
});
|
|
850
735
|
return { pivot: p, rows, columns };
|
|
851
736
|
}
|
|
852
737
|
catch (e) {
|
|
853
|
-
eventTracking?.logError?.({
|
|
854
|
-
type: 'bug', // TODO: determine type
|
|
855
|
-
severity: 'high',
|
|
856
|
-
message: 'Error fetching pivot data',
|
|
857
|
-
errorMessage: e.message,
|
|
858
|
-
errorStack: e.stack,
|
|
859
|
-
errorData: {
|
|
860
|
-
caller: 'PivotModal',
|
|
861
|
-
function: 'fetchPivotTables',
|
|
862
|
-
},
|
|
863
|
-
});
|
|
864
738
|
return undefined;
|
|
865
739
|
}
|
|
866
740
|
}));
|
|
@@ -868,58 +742,6 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
868
742
|
};
|
|
869
743
|
fetchPivotTables();
|
|
870
744
|
}, [createdPivots, dateRange]);
|
|
871
|
-
const handleResize = () => {
|
|
872
|
-
const parentRefElement = parentRef?.current;
|
|
873
|
-
const popoverRefElement = popoverRef?.current;
|
|
874
|
-
if (parentRefElement && popoverRefElement) {
|
|
875
|
-
const parentRect = parentRefElement.getBoundingClientRect();
|
|
876
|
-
const popoverRect = popoverRefElement.getBoundingClientRect();
|
|
877
|
-
const topOffset = popoverRect.top - parentRect.top;
|
|
878
|
-
const availableHeight = parentRect.height - topOffset;
|
|
879
|
-
setAvailableHeight(availableHeight);
|
|
880
|
-
calculatePopoverPosition();
|
|
881
|
-
}
|
|
882
|
-
};
|
|
883
|
-
const calculatePopoverPosition = () => {
|
|
884
|
-
if (!buttonRef.current)
|
|
885
|
-
return;
|
|
886
|
-
const buttonRect = buttonRef.current.getBoundingClientRect();
|
|
887
|
-
const parentRefElement = parentRef?.current;
|
|
888
|
-
if (!parentRefElement)
|
|
889
|
-
return;
|
|
890
|
-
const parentRect = parentRefElement.getBoundingClientRect();
|
|
891
|
-
// Calculate available space above and below
|
|
892
|
-
const spaceBelow = parentRect.bottom - buttonRect.bottom;
|
|
893
|
-
const spaceAbove = buttonRect.top - parentRect.top;
|
|
894
|
-
const desiredHeight = Math.max(450, spaceAbove - 20);
|
|
895
|
-
setPivotModalTopHeight(desiredHeight);
|
|
896
|
-
// If there's not enough space below but more space above, position above
|
|
897
|
-
if (spaceBelow < desiredHeight && spaceAbove > desiredHeight) {
|
|
898
|
-
setPopoverPosition('top');
|
|
899
|
-
}
|
|
900
|
-
else {
|
|
901
|
-
setPopoverPosition('bottom');
|
|
902
|
-
}
|
|
903
|
-
};
|
|
904
|
-
(0, react_1.useEffect)(() => {
|
|
905
|
-
handleResize();
|
|
906
|
-
window.addEventListener('resize', handleResize);
|
|
907
|
-
// Add scroll listener to the parent element if it exists
|
|
908
|
-
const parentElement = parentRef?.current;
|
|
909
|
-
if (parentElement) {
|
|
910
|
-
parentElement.addEventListener('scroll', handleResize);
|
|
911
|
-
}
|
|
912
|
-
return () => {
|
|
913
|
-
window.removeEventListener('resize', handleResize);
|
|
914
|
-
if (parentElement) {
|
|
915
|
-
parentElement.removeEventListener('scroll', handleResize);
|
|
916
|
-
}
|
|
917
|
-
};
|
|
918
|
-
}, [
|
|
919
|
-
parentRef?.current,
|
|
920
|
-
popoverRef?.current,
|
|
921
|
-
buttonRef?.current?.getBoundingClientRect().top,
|
|
922
|
-
]);
|
|
923
745
|
return ((0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flexDirection: 'column' }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
924
746
|
position: 'relative',
|
|
925
747
|
display: 'inline-block',
|
|
@@ -954,15 +776,9 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
954
776
|
}
|
|
955
777
|
setIsOpen(!isOpen);
|
|
956
778
|
setShowUpdatePivot(false);
|
|
957
|
-
}, label: triggerButtonText }) })), (0, jsx_runtime_1.jsx)("div", {
|
|
958
|
-
position: '
|
|
959
|
-
...(isOpen &&
|
|
960
|
-
showTrigger && {
|
|
961
|
-
top: popoverPosition === 'bottom' ? '100%' : 'auto',
|
|
962
|
-
bottom: popoverPosition === 'top' ? '100%' : 'auto',
|
|
963
|
-
marginBottom: popoverPosition === 'top' ? pivotModalTopHeight : 0,
|
|
964
|
-
marginTop: popoverPosition === 'bottom' ? 8 : 0,
|
|
965
|
-
}),
|
|
779
|
+
}, label: triggerButtonText }) })), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
780
|
+
position: 'relative',
|
|
781
|
+
...(isOpen && showTrigger && { top: 12 }),
|
|
966
782
|
}, children: (0, jsx_runtime_1.jsx)(PopoverComponent, { isOpen: isOpen, setIsOpen: (isOpen) => {
|
|
967
783
|
if (!isOpen) {
|
|
968
784
|
setShowUpdatePivot(false);
|
|
@@ -971,7 +787,7 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
971
787
|
setIsOpen(isOpen);
|
|
972
788
|
}, ignoredRefs: [buttonRef], popoverTitle: showUpdatePivot || !pivotRecommendationsEnabled
|
|
973
789
|
? popUpTitle
|
|
974
|
-
: 'Recommended pivots',
|
|
790
|
+
: 'Recommended pivots', popoverChildren: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
975
791
|
paddingTop: showUpdatePivot || !pivotRecommendationsEnabled ? 0 : 20,
|
|
976
792
|
position: 'relative',
|
|
977
793
|
}, children: showUpdatePivot || !pivotRecommendationsEnabled ? ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
@@ -979,223 +795,145 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
979
795
|
display: 'flex',
|
|
980
796
|
flexDirection: 'column',
|
|
981
797
|
gap: 20,
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
gap: 4,
|
|
1113
|
-
paddingBottom: 20,
|
|
1114
|
-
}, children: [(0, jsx_runtime_1.jsx)(HeaderComponent, { label: "Sort" }), !showSortInput ? ((0, jsx_runtime_1.jsx)("div", { style: { width: 200 }, children: (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: () => setShowSortInput(true), disabled: disabled, label: "Add Sort" }) })) : ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)(PivotRowContainer, { children: [(0, jsx_runtime_1.jsx)("div", { style: { width: 200 }, children: (0, jsx_runtime_1.jsx)(SubheaderComponent, { label: "Sort Field" }) }), (0, jsx_runtime_1.jsx)("div", { style: { width: 200 }, children: (0, jsx_runtime_1.jsx)(SubheaderComponent, { label: "Sort Direction" }) })] }), (0, jsx_runtime_1.jsxs)(PivotRowContainer, { children: [(0, jsx_runtime_1.jsx)(SelectComponent, { id: "pivot-sort-field", value: sortFieldInput, onChange: (e) => {
|
|
1115
|
-
setSortFieldInput(e.target.value);
|
|
1116
|
-
if (e.target.value &&
|
|
1117
|
-
sortDirectionInput) {
|
|
1118
|
-
setPivotSort({
|
|
1119
|
-
sortField: e.target.value,
|
|
1120
|
-
sortDirection: sortDirectionInput,
|
|
1121
|
-
});
|
|
1122
|
-
}
|
|
1123
|
-
}, options: (samplePivotTable?.columns ?? []).map((column) => ({
|
|
1124
|
-
label: (0, textProcessing_1.snakeAndCamelCaseToTitleCase)(column.field),
|
|
1125
|
-
value: column.field,
|
|
1126
|
-
})), width: 200 }), (0, jsx_runtime_1.jsx)(SelectComponent, { id: "pivot-sort-direction", value: sortDirectionInput, onChange: (e) => {
|
|
1127
|
-
setSortDirectionInput(e.target.value);
|
|
1128
|
-
if (sortFieldInput && e.target.value) {
|
|
1129
|
-
setPivotSort({
|
|
1130
|
-
sortField: sortFieldInput,
|
|
1131
|
-
sortDirection: e.target.value,
|
|
1132
|
-
});
|
|
1133
|
-
}
|
|
1134
|
-
}, options: [
|
|
1135
|
-
{ label: 'Ascending', value: 'ASC' },
|
|
1136
|
-
{ label: 'Descending', value: 'DESC' },
|
|
1137
|
-
], hideEmptyOption: true, width: 200 }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
1138
|
-
marginLeft: -16,
|
|
1139
|
-
marginRight: -16,
|
|
1140
|
-
}, children: (0, jsx_runtime_1.jsx)(DeleteButtonComponent, { onClick: () => {
|
|
1141
|
-
if (pivotSort !== undefined) {
|
|
1142
|
-
setPivotSort(undefined);
|
|
1143
|
-
}
|
|
1144
|
-
setShowSortInput(false);
|
|
1145
|
-
setSortFieldInput('');
|
|
1146
|
-
setSortDirectionInput('ASC');
|
|
1147
|
-
} }) })] })] }))] }) }), (0, jsx_runtime_1.jsx)(PivotColumnContainer, { children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
1148
|
-
display: 'flex',
|
|
1149
|
-
flexDirection: 'column',
|
|
1150
|
-
gap: 4,
|
|
1151
|
-
paddingBottom: 20,
|
|
1152
|
-
}, children: [(0, jsx_runtime_1.jsx)(HeaderComponent, { label: "Limit" }), !showLimitInput ? ((0, jsx_runtime_1.jsx)("div", { style: { width: 200 }, children: (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: () => setShowLimitInput(true), disabled: disabled, label: "Add Limit" }) })) : ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(PivotRowContainer, { children: (0, jsx_runtime_1.jsx)("div", { style: { width: 200 }, children: (0, jsx_runtime_1.jsx)(SubheaderComponent, { label: "Pivot row limit" }) }) }), (0, jsx_runtime_1.jsxs)(PivotRowContainer, { children: [(0, jsx_runtime_1.jsx)(TextInputComponent, { id: "pivot-limit", value: limitInput, width: 180, onChange: (e) => {
|
|
1153
|
-
setLimitInput(e.target.value);
|
|
1154
|
-
const limit = parseInt(e.target.value);
|
|
1155
|
-
if (limit) {
|
|
1156
|
-
setPivotLimit(limit);
|
|
1157
|
-
}
|
|
1158
|
-
else {
|
|
1159
|
-
setPivotLimit(undefined);
|
|
1160
|
-
}
|
|
1161
|
-
} }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
1162
|
-
marginLeft: -16,
|
|
1163
|
-
marginRight: -16,
|
|
1164
|
-
}, children: (0, jsx_runtime_1.jsx)(DeleteButtonComponent, { onClick: () => {
|
|
1165
|
-
if (pivotLimit !== undefined) {
|
|
1166
|
-
setPivotLimit(undefined);
|
|
1167
|
-
}
|
|
1168
|
-
setShowLimitInput(false);
|
|
1169
|
-
setLimitInput('100');
|
|
1170
|
-
} }) })] })] }))] }) }), errors.length > 0 && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
1171
|
-
display: 'flex',
|
|
1172
|
-
flexDirection: 'column',
|
|
1173
|
-
gap: 8,
|
|
1174
|
-
paddingTop: 8,
|
|
1175
|
-
width: pivotCardWidth,
|
|
1176
|
-
maxWidth: pivotCardWidth,
|
|
1177
|
-
paddingBottom: 20,
|
|
1178
|
-
}, children: errors.map((error, index) => ((0, jsx_runtime_1.jsx)(ErrorMessageComponent, { errorMessage: error }, `error_message_${index}`))) }))] }) }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
1179
|
-
position: 'sticky',
|
|
798
|
+
}, children: [previewLoading && (0, jsx_runtime_1.jsx)(LoadingComponent, {}), samplePivotTable && !previewLoading && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
799
|
+
width: pivotCardWidth,
|
|
800
|
+
minHeight: 160,
|
|
801
|
+
}, children: (0, jsx_runtime_1.jsx)(PivotList_1.PivotCard, { pivotTable: samplePivotTable, theme: theme, index: 0, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent: ButtonComponent, showEdit: false, clickable: false, minHeight: 180, LabelComponent: LabelComponent, TextComponent: TextComponent, HeaderComponent: HeaderComponent, CardComponent: CardComponent, onSelectPivot: () => { }, onClose: () => {
|
|
802
|
+
setPivotAggregations([
|
|
803
|
+
{
|
|
804
|
+
valueField: undefined,
|
|
805
|
+
valueField2: undefined,
|
|
806
|
+
aggregationType: undefined,
|
|
807
|
+
},
|
|
808
|
+
]);
|
|
809
|
+
setPivotRowField(undefined);
|
|
810
|
+
setPivotColumnField(undefined);
|
|
811
|
+
setSamplePivotTable(undefined);
|
|
812
|
+
} }) })), (0, jsx_runtime_1.jsxs)(PivotColumnContainer, { children: [(0, jsx_runtime_1.jsxs)("div", { style: {
|
|
813
|
+
display: 'flex',
|
|
814
|
+
flexDirection: 'column',
|
|
815
|
+
gap: 4,
|
|
816
|
+
}, children: [(0, jsx_runtime_1.jsx)(HeaderComponent, { label: "Groupings" }), (0, jsx_runtime_1.jsxs)(PivotRowContainer, { children: [(0, jsx_runtime_1.jsx)("div", { ref: rowFieldRef, children: (0, jsx_runtime_1.jsx)(SelectComponent, { id: "pivot-row-field", label: "Group rows by", value: pivotRowField, onChange: (e) => {
|
|
817
|
+
pivotFieldChange('rowField', e.target.value);
|
|
818
|
+
setPivotRowField(e.target.value === ''
|
|
819
|
+
? undefined
|
|
820
|
+
: e.target.value);
|
|
821
|
+
}, options: allowedRowFields
|
|
822
|
+
.filter((field) => field !== pivotColumnField)
|
|
823
|
+
.map((field) => {
|
|
824
|
+
return {
|
|
825
|
+
label: (0, textProcessing_1.snakeAndCamelCaseToTitleCase)(field),
|
|
826
|
+
value: field,
|
|
827
|
+
};
|
|
828
|
+
}), isLoading: uniqueValuesIsLoading, width: 200 }) }), (0, jsx_runtime_1.jsx)("div", { ref: colFieldRef, children: (0, jsx_runtime_1.jsx)(SelectComponent, { id: "pivot-column-field", label: "Group columns by", value: pivotColumnField, onChange: (e) => {
|
|
829
|
+
pivotFieldChange('columnField', e.target.value);
|
|
830
|
+
setPivotColumnField(e.target.value === ''
|
|
831
|
+
? undefined
|
|
832
|
+
: e.target.value);
|
|
833
|
+
}, options: allowedColumnFields
|
|
834
|
+
.filter((field) => field !== pivotRowField)
|
|
835
|
+
.map((field) => {
|
|
836
|
+
return {
|
|
837
|
+
label: (0, textProcessing_1.snakeAndCamelCaseToTitleCase)(field),
|
|
838
|
+
value: field,
|
|
839
|
+
};
|
|
840
|
+
}), isLoading: uniqueValuesIsLoading, width: 200, disabled: pivotRowField === undefined }) })] })] }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
841
|
+
display: 'flex',
|
|
842
|
+
flexDirection: 'column',
|
|
843
|
+
gap: 4,
|
|
844
|
+
}, children: [(0, jsx_runtime_1.jsx)(HeaderComponent, { label: "Aggregations" }), (0, jsx_runtime_1.jsxs)(PivotRowContainer, { children: [(0, jsx_runtime_1.jsx)("div", { style: { width: 200 }, children: (0, jsx_runtime_1.jsx)(SubheaderComponent, { label: "Aggregation Type" }) }), (0, jsx_runtime_1.jsx)("div", { style: { width: 200 }, children: (0, jsx_runtime_1.jsx)(SubheaderComponent, { label: "Value Field" }) })] }), pivotAggregations?.map((agg, index) => ((0, jsx_runtime_1.jsxs)(PivotRowContainer, { children: [(0, jsx_runtime_1.jsx)(SelectComponent, { id: "pivot-aggregation-type", value: agg.aggregationType, onChange: (e) => {
|
|
845
|
+
// if (
|
|
846
|
+
// e.target.value !== 'count' &&
|
|
847
|
+
// agg.valueField &&
|
|
848
|
+
// !numberFormatOptions.includes(
|
|
849
|
+
// columns.find(
|
|
850
|
+
// (col: Column) =>
|
|
851
|
+
// col.field === agg.valueField,
|
|
852
|
+
// )!.format,
|
|
853
|
+
// )
|
|
854
|
+
// ) {
|
|
855
|
+
// setPivotValueField(undefined);
|
|
856
|
+
// }
|
|
857
|
+
const newAgg = [
|
|
858
|
+
...pivotAggregations.slice(0, index),
|
|
859
|
+
{
|
|
860
|
+
...agg,
|
|
861
|
+
aggregationType: e.target.value === ''
|
|
862
|
+
? undefined
|
|
863
|
+
: e.target.value,
|
|
864
|
+
},
|
|
865
|
+
...pivotAggregations.slice(index + 1),
|
|
866
|
+
];
|
|
867
|
+
pivotFieldChange('aggregations', newAgg);
|
|
868
|
+
setPivotAggregations(newAgg);
|
|
869
|
+
}, options: [
|
|
870
|
+
...[
|
|
871
|
+
'sum',
|
|
872
|
+
'average',
|
|
873
|
+
'count',
|
|
874
|
+
'max',
|
|
875
|
+
'min',
|
|
876
|
+
'percentage',
|
|
877
|
+
].map((option) => {
|
|
878
|
+
return { label: option, value: option };
|
|
879
|
+
}),
|
|
880
|
+
], width: 200 }), (0, jsx_runtime_1.jsx)(SelectComponent, { id: "pivot-value-field", value: agg.valueField, onChange: (e) => {
|
|
881
|
+
const newAgg = [
|
|
882
|
+
...pivotAggregations.slice(0, index),
|
|
883
|
+
{
|
|
884
|
+
...agg,
|
|
885
|
+
valueField: e.target.value === ''
|
|
886
|
+
? undefined
|
|
887
|
+
: e.target.value,
|
|
888
|
+
},
|
|
889
|
+
...pivotAggregations.slice(index + 1),
|
|
890
|
+
];
|
|
891
|
+
pivotFieldChange('aggregations', newAgg);
|
|
892
|
+
setPivotAggregations(newAgg);
|
|
893
|
+
}, options: allowedValueFields.map((field) => {
|
|
894
|
+
return {
|
|
895
|
+
label: (0, textProcessing_1.snakeAndCamelCaseToTitleCase)(field),
|
|
896
|
+
value: field,
|
|
897
|
+
};
|
|
898
|
+
}), isLoading: uniqueValuesIsLoading, width: 200 }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
899
|
+
marginLeft: -16,
|
|
900
|
+
marginRight: -16,
|
|
901
|
+
visibility: index > 0 ? 'visible' : 'hidden',
|
|
902
|
+
}, children: (0, jsx_runtime_1.jsx)(DeleteButtonComponent, { onClick: () => {
|
|
903
|
+
setPivotAggregations([
|
|
904
|
+
...pivotAggregations.slice(0, index),
|
|
905
|
+
...pivotAggregations.slice(index + 1),
|
|
906
|
+
]);
|
|
907
|
+
} }) })] }, index)))] })] }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
908
|
+
display: 'flex',
|
|
909
|
+
flexDirection: 'row',
|
|
910
|
+
marginRight: 'auto',
|
|
911
|
+
}, children: (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { label: "Add Aggregation", onClick: () => {
|
|
912
|
+
setPivotAggregations([
|
|
913
|
+
...pivotAggregations,
|
|
914
|
+
{
|
|
915
|
+
aggregationType: undefined,
|
|
916
|
+
valueField: undefined,
|
|
917
|
+
valueField2: undefined,
|
|
918
|
+
},
|
|
919
|
+
]);
|
|
920
|
+
} }) }), errors.length > 0 && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
921
|
+
display: 'flex',
|
|
922
|
+
flexDirection: 'column',
|
|
923
|
+
gap: 8,
|
|
924
|
+
paddingTop: 8,
|
|
925
|
+
width: pivotCardWidth,
|
|
926
|
+
maxWidth: pivotCardWidth,
|
|
927
|
+
}, children: errors.map((error, index) => ((0, jsx_runtime_1.jsx)(ErrorMessageComponent, { errorMessage: error }, `error_message_${index}`))) })), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
1180
928
|
display: 'flex',
|
|
1181
929
|
flexDirection: 'row',
|
|
1182
|
-
justifyContent: 'flex-end',
|
|
1183
930
|
marginLeft: 'auto',
|
|
1184
931
|
gap: 8,
|
|
1185
|
-
bottom: 0,
|
|
1186
|
-
right: 0,
|
|
1187
|
-
backgroundColor: 'white',
|
|
1188
|
-
width: '100%',
|
|
1189
|
-
paddingRight: 20,
|
|
1190
932
|
}, children: [(0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: () => {
|
|
1191
933
|
setPivotError('');
|
|
1192
934
|
setIsOpen(false);
|
|
1193
935
|
setPopUpTitle('Add pivot');
|
|
1194
|
-
}, label: "Cancel" }), (0, jsx_runtime_1.jsx)(ButtonComponent, { id: "custom-button", onClick: onCommitPivot, label: 'Save', disabled: (
|
|
1195
|
-
(!sortFieldInput ||
|
|
1196
|
-
!(samplePivotTable?.columns ?? []).some((c) => c.field === sortFieldInput) ||
|
|
1197
|
-
!sortDirectionInput)) ||
|
|
1198
|
-
!(pivotAggregations?.length > 0) ||
|
|
936
|
+
}, label: "Cancel" }), (0, jsx_runtime_1.jsx)(ButtonComponent, { id: "custom-button", onClick: onCommitPivot, label: 'Save', disabled: !(pivotAggregations?.length > 0) ||
|
|
1199
937
|
pivotAggregations.some((agg) => !agg.aggregationType ||
|
|
1200
938
|
(!agg.valueField &&
|
|
1201
939
|
agg.aggregationType !== 'count')) })] })] })) : ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
@@ -1204,13 +942,8 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
1204
942
|
fontFamily: theme?.fontFamily,
|
|
1205
943
|
color: theme?.primaryTextColor,
|
|
1206
944
|
width: selectedPivotTable ? 500 : 600,
|
|
1207
|
-
|
|
1208
|
-
maxHeight: popoverPosition === 'bottom'
|
|
1209
|
-
? 600
|
|
1210
|
-
: pivotModalTopHeight - 100,
|
|
945
|
+
maxHeight: 600,
|
|
1211
946
|
overflowY: 'scroll',
|
|
1212
|
-
paddingRight: 20,
|
|
1213
|
-
paddingLeft: 20,
|
|
1214
947
|
}, children: selectedPivotIndex >= 0 ? ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("div", { onClick: () => {
|
|
1215
948
|
setPopUpTitle('Edit pivot');
|
|
1216
949
|
onEditPivot(createdPivots[0], 0);
|
|
@@ -1224,7 +957,6 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
1224
957
|
display: 'flex',
|
|
1225
958
|
flexDirection: 'row',
|
|
1226
959
|
gap: 8,
|
|
1227
|
-
paddingRight: 20,
|
|
1228
960
|
}, children: [(0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { label: "Regenerate", onClick: refreshPivots, icon: (0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", style: { width: 16, height: 16 }, children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", d: "M9 4.5a.75.75 0 0 1 .721.544l.813 2.846a3.75 3.75 0 0 0 2.576 2.576l2.846.813a.75.75 0 0 1 0 1.442l-2.846.813a3.75 3.75 0 0 0-2.576 2.576l-.813 2.846a.75.75 0 0 1-1.442 0l-.813-2.846a3.75 3.75 0 0 0-2.576-2.576l-2.846-.813a.75.75 0 0 1 0-1.442l2.846-.813A3.75 3.75 0 0 0 7.466 7.89l.813-2.846A.75.75 0 0 1 9 4.5ZM18 1.5a.75.75 0 0 1 .728.568l.258 1.036c.236.94.97 1.674 1.91 1.91l1.036.258a.75.75 0 0 1 0 1.456l-1.036.258c-.94.236-1.674.97-1.91 1.91l-.258 1.036a.75.75 0 0 1-1.456 0l-.258-1.036a2.625 2.625 0 0 0-1.91-1.91l-1.036-.258a.75.75 0 0 1 0-1.456l1.036-.258a2.625 2.625 0 0 0 1.91-1.91l.258-1.036A.75.75 0 0 1 18 1.5ZM16.5 15a.75.75 0 0 1 .712.513l.394 1.183c.15.447.5.799.948.948l1.183.395a.75.75 0 0 1 0 1.422l-1.183.395c-.447.15-.799.5-.948.948l-.395 1.183a.75.75 0 0 1-1.422 0l-.395-1.183a1.5 1.5 0 0 0-.948-.948l-1.183-.395a.75.75 0 0 1 0-1.422l1.183-.395c.447-.15.799-.5.948-.948l.395-1.183A.75.75 0 0 1 16.5 15Z", clipRule: "evenodd" }) }) }), (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { label: "Create pivot +", onClick: () => onEditPivot({ aggregations: [{}] }, null) })] }), isLoading || uniqueValuesIsLoading ? ((0, jsx_runtime_1.jsx)(LoadingComponent, {})) : pivotError ? ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
1229
961
|
width: '100%',
|
|
1230
962
|
height: '140px',
|
|
@@ -1518,7 +1250,7 @@ function isDateField(fieldType) {
|
|
|
1518
1250
|
// }
|
|
1519
1251
|
// return newData;
|
|
1520
1252
|
// };
|
|
1521
|
-
async function generatePivotTable({ pivot, dateBucket, dateFilter, report, client, getToken,
|
|
1253
|
+
async function generatePivotTable({ pivot, dateBucket, dateFilter, report, client, getToken, uniqueValues, dashboardName, tenants, additionalProcessing, caller, pivotQuery, }) {
|
|
1522
1254
|
try {
|
|
1523
1255
|
if (report && client) {
|
|
1524
1256
|
const pivotTable = await (0, pivotConstructor_1.generatePivotWithSQL)({
|
|
@@ -1541,17 +1273,6 @@ async function generatePivotTable({ pivot, dateBucket, dateFilter, report, clien
|
|
|
1541
1273
|
}
|
|
1542
1274
|
}
|
|
1543
1275
|
catch (e) {
|
|
1544
|
-
eventTracking?.logError?.({
|
|
1545
|
-
type: 'bug', // TODO: determine type
|
|
1546
|
-
severity: 'high',
|
|
1547
|
-
message: 'Error generating pivot table',
|
|
1548
|
-
errorMessage: e.message,
|
|
1549
|
-
errorStack: e.stack,
|
|
1550
|
-
errorData: {
|
|
1551
|
-
caller: 'PivotModal',
|
|
1552
|
-
function: 'generatePivotTable',
|
|
1553
|
-
},
|
|
1554
|
-
});
|
|
1555
1276
|
throw Error(`Failed to generate pivot table with SQL: ${e}`);
|
|
1556
1277
|
}
|
|
1557
1278
|
throw Error('Failed to generate pivot table: invalid report');
|