@finos/legend-application-repl 0.0.31 → 0.0.33
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/lib/components/LegendREPLFrameworkProvider.js +1 -1
- package/lib/components/LegendREPLFrameworkProvider.js.map +1 -1
- package/lib/components/REPLStoreProvider.d.ts +1 -1
- package/lib/components/REPLStoreProvider.d.ts.map +1 -1
- package/lib/components/REPLStoreProvider.js +1 -1
- package/lib/components/REPLStoreProvider.js.map +1 -1
- package/lib/components/{dataCube/grid/menu/DataCubeGridSortsMenu.d.ts → REPLWindow.d.ts} +18 -4
- package/lib/components/REPLWindow.d.ts.map +1 -0
- package/lib/components/REPLWindow.js +117 -0
- package/lib/components/REPLWindow.js.map +1 -0
- package/lib/components/dataCube/DataCube.js +4 -4
- package/lib/components/dataCube/DataCube.js.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditor.d.ts.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditor.js +14 -93
- package/lib/components/dataCube/editor/DataCubeEditor.js.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorCodePanel.d.ts.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorCodePanel.js +3 -2
- package/lib/components/dataCube/editor/DataCubeEditorCodePanel.js.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorColumnPropertiesPanel.d.ts.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorColumnPropertiesPanel.js +161 -87
- package/lib/components/dataCube/editor/DataCubeEditorColumnPropertiesPanel.js.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorColumnsPanel.d.ts.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorColumnsPanel.js +10 -3
- package/lib/components/dataCube/editor/DataCubeEditorColumnsPanel.js.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorColumnsSelector.d.ts +3 -2
- package/lib/components/dataCube/editor/DataCubeEditorColumnsSelector.d.ts.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorColumnsSelector.js +23 -38
- package/lib/components/dataCube/editor/DataCubeEditorColumnsSelector.js.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorDeveloperPanel.d.ts.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorDeveloperPanel.js +3 -2
- package/lib/components/dataCube/editor/DataCubeEditorDeveloperPanel.js.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorExtendedColumnsPanel.d.ts.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorExtendedColumnsPanel.js +3 -2
- package/lib/components/dataCube/editor/DataCubeEditorExtendedColumnsPanel.js.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorFilterPanel.d.ts.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorFilterPanel.js +3 -2
- package/lib/components/dataCube/editor/DataCubeEditorFilterPanel.js.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorGeneralPropertiesPanel.d.ts.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorGeneralPropertiesPanel.js +96 -55
- package/lib/components/dataCube/editor/DataCubeEditorGeneralPropertiesPanel.js.map +1 -1
- package/lib/components/dataCube/editor/{DataCubeEditorVPivotsPanel.d.ts → DataCubeEditorHorizontalPivotsPanel.d.ts} +2 -2
- package/lib/components/dataCube/editor/DataCubeEditorHorizontalPivotsPanel.d.ts.map +1 -0
- package/lib/components/dataCube/editor/{DataCubeEditorHPivotsPanel.js → DataCubeEditorHorizontalPivotsPanel.js} +5 -4
- package/lib/components/dataCube/editor/DataCubeEditorHorizontalPivotsPanel.js.map +1 -0
- package/lib/components/dataCube/editor/DataCubeEditorShared.d.ts +1 -0
- package/lib/components/dataCube/editor/DataCubeEditorShared.d.ts.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorShared.js +44 -27
- package/lib/components/dataCube/editor/DataCubeEditorShared.js.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorSortsPanel.d.ts.map +1 -1
- package/lib/components/dataCube/editor/DataCubeEditorSortsPanel.js +7 -7
- package/lib/components/dataCube/editor/DataCubeEditorSortsPanel.js.map +1 -1
- package/lib/components/dataCube/editor/{DataCubeEditorHPivotsPanel.d.ts → DataCubeEditorVerticalPivotsPanel.d.ts} +2 -2
- package/lib/components/dataCube/editor/DataCubeEditorVerticalPivotsPanel.d.ts.map +1 -0
- package/lib/components/dataCube/editor/{DataCubeEditorVPivotsPanel.js → DataCubeEditorVerticalPivotsPanel.js} +5 -6
- package/lib/components/dataCube/editor/DataCubeEditorVerticalPivotsPanel.js.map +1 -0
- package/lib/components/dataCube/grid/DataCubeGrid.d.ts +3 -0
- package/lib/components/dataCube/grid/DataCubeGrid.d.ts.map +1 -1
- package/lib/components/dataCube/grid/DataCubeGrid.js +205 -75
- package/lib/components/dataCube/grid/DataCubeGrid.js.map +1 -1
- package/lib/components/dataCube/grid/DataCubeGridShared.d.ts +1 -1
- package/lib/components/dataCube/grid/DataCubeGridShared.d.ts.map +1 -1
- package/lib/components/dataCube/grid/DataCubeGridShared.js +1 -1
- package/lib/components/dataCube/grid/DataCubeGridShared.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/package.json +19 -15
- package/lib/stores/{dataCube/REPLStore.d.ts → REPLStore.d.ts} +5 -3
- package/lib/stores/REPLStore.d.ts.map +1 -0
- package/lib/stores/{dataCube/REPLStore.js → REPLStore.js} +5 -2
- package/lib/stores/REPLStore.js.map +1 -0
- package/lib/stores/dataCube/{core/DataCubeEngine.d.ts → DataCubeInfrastructure.d.ts} +20 -4
- package/lib/stores/dataCube/DataCubeInfrastructure.d.ts.map +1 -0
- package/lib/stores/dataCube/{core/DataCubeEngine.js → DataCubeInfrastructure.js} +31 -3
- package/lib/stores/dataCube/DataCubeInfrastructure.js.map +1 -0
- package/lib/stores/dataCube/DataCubeState.d.ts +4 -4
- package/lib/stores/dataCube/DataCubeState.d.ts.map +1 -1
- package/lib/stores/dataCube/DataCubeState.js +9 -10
- package/lib/stores/dataCube/DataCubeState.js.map +1 -1
- package/lib/stores/dataCube/core/DataCubeConfiguration.d.ts +44 -38
- package/lib/stores/dataCube/core/DataCubeConfiguration.d.ts.map +1 -1
- package/lib/stores/dataCube/core/DataCubeConfiguration.js +88 -78
- package/lib/stores/dataCube/core/DataCubeConfiguration.js.map +1 -1
- package/lib/stores/dataCube/core/DataCubeConfigurationBuilder.d.ts.map +1 -1
- package/lib/stores/dataCube/core/DataCubeConfigurationBuilder.js +2 -1
- package/lib/stores/dataCube/core/DataCubeConfigurationBuilder.js.map +1 -1
- package/lib/stores/dataCube/core/DataCubeCoreState.d.ts +1 -1
- package/lib/stores/dataCube/core/DataCubeCoreState.d.ts.map +1 -1
- package/lib/stores/dataCube/core/DataCubeCoreState.js +1 -1
- package/lib/stores/dataCube/core/DataCubeCoreState.js.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQueryBuilder.d.ts.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQueryBuilder.js +21 -21
- package/lib/stores/dataCube/core/DataCubeQueryBuilder.js.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQueryEngine.d.ts +68 -29
- package/lib/stores/dataCube/core/DataCubeQueryEngine.d.ts.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQueryEngine.js +93 -50
- package/lib/stores/dataCube/core/DataCubeQueryEngine.js.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQuerySnapshot.d.ts +5 -40
- package/lib/stores/dataCube/core/DataCubeQuerySnapshot.d.ts.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQuerySnapshot.js +9 -54
- package/lib/stores/dataCube/core/DataCubeQuerySnapshot.js.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotBuilder.d.ts.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotBuilder.js +18 -12
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotBuilder.js.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotSubscriber.d.ts +1 -3
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotSubscriber.d.ts.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotSubscriber.js +2 -3
- package/lib/stores/dataCube/core/DataCubeQuerySnapshotSubscriber.js.map +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorColumnPropertiesPanelState.d.ts +7 -1
- package/lib/stores/dataCube/editor/DataCubeEditorColumnPropertiesPanelState.d.ts.map +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorColumnPropertiesPanelState.js +29 -5
- package/lib/stores/dataCube/editor/DataCubeEditorColumnPropertiesPanelState.js.map +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorColumnsPanelState.d.ts +45 -0
- package/lib/stores/dataCube/editor/DataCubeEditorColumnsPanelState.d.ts.map +1 -0
- package/lib/stores/dataCube/editor/DataCubeEditorColumnsPanelState.js +102 -0
- package/lib/stores/dataCube/editor/DataCubeEditorColumnsPanelState.js.map +1 -0
- package/lib/stores/dataCube/editor/DataCubeEditorColumnsSelectorState.d.ts +26 -9
- package/lib/stores/dataCube/editor/DataCubeEditorColumnsSelectorState.d.ts.map +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorColumnsSelectorState.js +50 -20
- package/lib/stores/dataCube/editor/DataCubeEditorColumnsSelectorState.js.map +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorGeneralPropertiesPanelState.d.ts +2 -1
- package/lib/stores/dataCube/editor/DataCubeEditorGeneralPropertiesPanelState.d.ts.map +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorGeneralPropertiesPanelState.js +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorGeneralPropertiesPanelState.js.map +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorPanelState.d.ts +2 -1
- package/lib/stores/dataCube/editor/DataCubeEditorPanelState.d.ts.map +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorSortsPanelState.d.ts +12 -13
- package/lib/stores/dataCube/editor/DataCubeEditorSortsPanelState.d.ts.map +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorSortsPanelState.js +23 -70
- package/lib/stores/dataCube/editor/DataCubeEditorSortsPanelState.js.map +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorState.d.ts +18 -13
- package/lib/stores/dataCube/editor/DataCubeEditorState.d.ts.map +1 -1
- package/lib/stores/dataCube/editor/DataCubeEditorState.js +44 -25
- package/lib/stores/dataCube/editor/DataCubeEditorState.js.map +1 -1
- package/lib/stores/dataCube/editor/{DataCubeEditorHPivotPanelState.d.ts → DataCubeEditorVerticalPivotsPanelState.d.ts} +11 -4
- package/lib/stores/dataCube/editor/DataCubeEditorVerticalPivotsPanelState.d.ts.map +1 -0
- package/lib/stores/dataCube/editor/DataCubeEditorVerticalPivotsPanelState.js +62 -0
- package/lib/stores/dataCube/editor/DataCubeEditorVerticalPivotsPanelState.js.map +1 -0
- package/lib/stores/dataCube/editor/DataCubeMutableConfiguration.d.ts +48 -41
- package/lib/stores/dataCube/editor/DataCubeMutableConfiguration.d.ts.map +1 -1
- package/lib/stores/dataCube/editor/DataCubeMutableConfiguration.js +217 -134
- package/lib/stores/dataCube/editor/DataCubeMutableConfiguration.js.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridClientEngine.d.ts +40 -0
- package/lib/stores/dataCube/grid/DataCubeGridClientEngine.d.ts.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridClientEngine.js +43 -1
- package/lib/stores/dataCube/grid/DataCubeGridClientEngine.js.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridClientExportEngine.d.ts +31 -0
- package/lib/stores/dataCube/grid/DataCubeGridClientExportEngine.d.ts.map +1 -0
- package/lib/stores/dataCube/grid/DataCubeGridClientExportEngine.js +147 -0
- package/lib/stores/dataCube/grid/DataCubeGridClientExportEngine.js.map +1 -0
- package/lib/stores/dataCube/grid/{DataCubeGridQuerySnapshotAnalyzer.d.ts → DataCubeGridConfigurationBuilder.d.ts} +5 -2
- package/lib/stores/dataCube/grid/DataCubeGridConfigurationBuilder.d.ts.map +1 -0
- package/lib/stores/dataCube/grid/DataCubeGridConfigurationBuilder.js +478 -0
- package/lib/stores/dataCube/grid/DataCubeGridConfigurationBuilder.js.map +1 -0
- package/lib/stores/dataCube/grid/DataCubeGridControllerState.d.ts +62 -0
- package/lib/stores/dataCube/grid/DataCubeGridControllerState.d.ts.map +1 -0
- package/lib/stores/dataCube/grid/DataCubeGridControllerState.js +174 -0
- package/lib/stores/dataCube/grid/DataCubeGridControllerState.js.map +1 -0
- package/lib/{components/dataCube/grid/menu/DataCubeGridMenu.d.ts → stores/dataCube/grid/DataCubeGridMenuBuilder.d.ts} +3 -7
- package/lib/stores/dataCube/grid/DataCubeGridMenuBuilder.d.ts.map +1 -0
- package/lib/stores/dataCube/grid/DataCubeGridMenuBuilder.js +462 -0
- package/lib/stores/dataCube/grid/DataCubeGridMenuBuilder.js.map +1 -0
- package/lib/stores/dataCube/grid/DataCubeGridQueryBuilder.d.ts.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridQueryBuilder.js +3 -3
- package/lib/stores/dataCube/grid/DataCubeGridQueryBuilder.js.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.d.ts.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.js +9 -8
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.js.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridState.d.ts +20 -2
- package/lib/stores/dataCube/grid/DataCubeGridState.d.ts.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridState.js +58 -22
- package/lib/stores/dataCube/grid/DataCubeGridState.js.map +1 -1
- package/package.json +25 -21
- package/src/components/LegendREPLFrameworkProvider.tsx +1 -1
- package/src/components/REPLStoreProvider.tsx +1 -1
- package/src/components/REPLWindow.tsx +179 -0
- package/src/components/dataCube/DataCube.tsx +4 -4
- package/src/components/dataCube/editor/DataCubeEditor.tsx +81 -192
- package/src/components/dataCube/editor/DataCubeEditorCodePanel.tsx +3 -1
- package/src/components/dataCube/editor/DataCubeEditorColumnPropertiesPanel.tsx +482 -283
- package/src/components/dataCube/editor/DataCubeEditorColumnsPanel.tsx +42 -8
- package/src/components/dataCube/editor/DataCubeEditorColumnsSelector.tsx +38 -80
- package/src/components/dataCube/editor/DataCubeEditorDeveloperPanel.tsx +3 -1
- package/src/components/dataCube/editor/DataCubeEditorExtendedColumnsPanel.tsx +3 -1
- package/src/components/dataCube/editor/DataCubeEditorFilterPanel.tsx +3 -1
- package/src/components/dataCube/editor/DataCubeEditorGeneralPropertiesPanel.tsx +238 -175
- package/src/components/dataCube/editor/{DataCubeEditorHPivotsPanel.tsx → DataCubeEditorHorizontalPivotsPanel.tsx} +4 -2
- package/src/components/dataCube/editor/DataCubeEditorShared.tsx +69 -33
- package/src/components/dataCube/editor/DataCubeEditorSortsPanel.tsx +8 -10
- package/src/components/dataCube/editor/{DataCubeEditorVPivotsPanel.tsx → DataCubeEditorVerticalPivotsPanel.tsx} +6 -6
- package/src/components/dataCube/grid/DataCubeGrid.tsx +337 -149
- package/src/components/dataCube/grid/DataCubeGridShared.tsx +5 -1
- package/src/stores/{dataCube/REPLStore.ts → REPLStore.ts} +6 -3
- package/src/stores/dataCube/{core/DataCubeEngine.ts → DataCubeInfrastructure.ts} +40 -3
- package/src/stores/dataCube/DataCubeState.ts +16 -14
- package/src/stores/dataCube/core/DataCubeConfiguration.ts +112 -86
- package/src/stores/dataCube/core/DataCubeConfigurationBuilder.ts +5 -1
- package/src/stores/dataCube/core/DataCubeCoreState.ts +4 -1
- package/src/stores/dataCube/core/DataCubeQueryBuilder.ts +27 -27
- package/src/stores/dataCube/core/DataCubeQueryEngine.ts +95 -49
- package/src/stores/dataCube/core/DataCubeQuerySnapshot.ts +19 -58
- package/src/stores/dataCube/core/DataCubeQuerySnapshotBuilder.ts +18 -14
- package/src/stores/dataCube/core/DataCubeQuerySnapshotSubscriber.ts +6 -5
- package/src/stores/dataCube/editor/DataCubeEditorColumnPropertiesPanelState.ts +51 -5
- package/src/stores/dataCube/editor/DataCubeEditorColumnsPanelState.ts +162 -0
- package/src/stores/dataCube/editor/DataCubeEditorColumnsSelectorState.ts +98 -23
- package/src/stores/dataCube/editor/DataCubeEditorGeneralPropertiesPanelState.ts +5 -1
- package/src/stores/dataCube/editor/DataCubeEditorPanelState.ts +5 -1
- package/src/stores/dataCube/editor/DataCubeEditorSortsPanelState.ts +48 -117
- package/src/stores/dataCube/editor/DataCubeEditorState.ts +54 -27
- package/src/stores/dataCube/editor/DataCubeEditorVerticalPivotsPanelState.ts +105 -0
- package/src/stores/dataCube/editor/DataCubeMutableConfiguration.ts +263 -146
- package/src/stores/dataCube/grid/DataCubeGridClientEngine.ts +64 -1
- package/src/stores/dataCube/grid/DataCubeGridClientExportEngine.ts +170 -0
- package/src/stores/dataCube/grid/DataCubeGridConfigurationBuilder.tsx +668 -0
- package/src/stores/dataCube/grid/DataCubeGridControllerState.ts +254 -0
- package/src/stores/dataCube/grid/DataCubeGridMenuBuilder.tsx +535 -0
- package/src/stores/dataCube/grid/DataCubeGridQueryBuilder.ts +3 -5
- package/src/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.ts +12 -10
- package/src/stores/dataCube/grid/DataCubeGridState.ts +81 -21
- package/tsconfig.json +11 -8
- package/lib/components/dataCube/editor/DataCubeEditorHPivotsPanel.d.ts.map +0 -1
- package/lib/components/dataCube/editor/DataCubeEditorHPivotsPanel.js.map +0 -1
- package/lib/components/dataCube/editor/DataCubeEditorVPivotsPanel.d.ts.map +0 -1
- package/lib/components/dataCube/editor/DataCubeEditorVPivotsPanel.js.map +0 -1
- package/lib/components/dataCube/grid/menu/DataCubeGridMenu.d.ts.map +0 -1
- package/lib/components/dataCube/grid/menu/DataCubeGridMenu.js +0 -382
- package/lib/components/dataCube/grid/menu/DataCubeGridMenu.js.map +0 -1
- package/lib/components/dataCube/grid/menu/DataCubeGridSortsMenu.d.ts.map +0 -1
- package/lib/components/dataCube/grid/menu/DataCubeGridSortsMenu.js +0 -83
- package/lib/components/dataCube/grid/menu/DataCubeGridSortsMenu.js.map +0 -1
- package/lib/stores/dataCube/REPLStore.d.ts.map +0 -1
- package/lib/stores/dataCube/REPLStore.js.map +0 -1
- package/lib/stores/dataCube/core/DataCubeEngine.d.ts.map +0 -1
- package/lib/stores/dataCube/core/DataCubeEngine.js.map +0 -1
- package/lib/stores/dataCube/editor/DataCubeEditorHPivotPanelState.d.ts.map +0 -1
- package/lib/stores/dataCube/editor/DataCubeEditorHPivotPanelState.js +0 -30
- package/lib/stores/dataCube/editor/DataCubeEditorHPivotPanelState.js.map +0 -1
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.d.ts.map +0 -1
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.js +0 -160
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.js.map +0 -1
- package/src/components/dataCube/grid/menu/DataCubeGridMenu.tsx +0 -394
- package/src/components/dataCube/grid/menu/DataCubeGridSortsMenu.tsx +0 -120
- package/src/stores/dataCube/editor/DataCubeEditorHPivotPanelState.ts +0 -43
- package/src/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.tsx +0 -192
|
@@ -0,0 +1,668 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/***************************************************************************************
|
|
18
|
+
* [GRID]
|
|
19
|
+
*
|
|
20
|
+
* These are utilities used to build the configuration for the grid client,
|
|
21
|
+
* AG Grid, from the query snapshot.
|
|
22
|
+
***************************************************************************************/
|
|
23
|
+
|
|
24
|
+
import {
|
|
25
|
+
_findCol,
|
|
26
|
+
type DataCubeQuerySnapshot,
|
|
27
|
+
type DataCubeQuerySnapshotColumn,
|
|
28
|
+
} from '../core/DataCubeQuerySnapshot.js';
|
|
29
|
+
import type {
|
|
30
|
+
ColDef,
|
|
31
|
+
ColGroupDef,
|
|
32
|
+
GridOptions,
|
|
33
|
+
ICellRendererParams,
|
|
34
|
+
} from '@ag-grid-community/core';
|
|
35
|
+
import {
|
|
36
|
+
INTERNAL__GRID_CLIENT_TREE_COLUMN_ID,
|
|
37
|
+
GridClientAggregateOperation,
|
|
38
|
+
GridClientSortDirection,
|
|
39
|
+
INTERNAL__GRID_CLIENT_COLUMN_MIN_WIDTH,
|
|
40
|
+
INTERNAL__GRID_CLIENT_UTILITY_CSS_CLASS_NAME,
|
|
41
|
+
generateFontFamilyUtilityClassName,
|
|
42
|
+
generateFontSizeUtilityClassName,
|
|
43
|
+
generateFontUnderlineUtilityClassName,
|
|
44
|
+
generateTextAlignUtilityClassName,
|
|
45
|
+
generateTextColorUtilityClassName,
|
|
46
|
+
generateBackgroundColorUtilityClassName,
|
|
47
|
+
generateFontCaseUtilityClassName,
|
|
48
|
+
GridClientPinnedAlignement,
|
|
49
|
+
INTERNAL__GRID_CLIENT_ROW_HEIGHT,
|
|
50
|
+
INTERNAL__GRID_CLIENT_AUTO_RESIZE_PADDING,
|
|
51
|
+
INTERNAL__GRID_CLIENT_HEADER_HEIGHT,
|
|
52
|
+
INTERNAL__GRID_CLIENT_TOOLTIP_SHOW_DELAY,
|
|
53
|
+
INTERNAL__GRID_CLIENT_SIDE_BAR_WIDTH,
|
|
54
|
+
INTERNAL__GRID_CLIENT_ROW_GROUPING_COUNT_AGG_COLUMN_ID,
|
|
55
|
+
} from './DataCubeGridClientEngine.js';
|
|
56
|
+
import { PRIMITIVE_TYPE } from '@finos/legend-graph';
|
|
57
|
+
import {
|
|
58
|
+
getQueryParameters,
|
|
59
|
+
getQueryParameterValue,
|
|
60
|
+
IllegalStateError,
|
|
61
|
+
isNonNullable,
|
|
62
|
+
isNumber,
|
|
63
|
+
isValidUrl,
|
|
64
|
+
} from '@finos/legend-shared';
|
|
65
|
+
import type {
|
|
66
|
+
DataCubeColumnConfiguration,
|
|
67
|
+
DataCubeConfiguration,
|
|
68
|
+
} from '../core/DataCubeConfiguration.js';
|
|
69
|
+
import {
|
|
70
|
+
DataCubeAggregateFunction,
|
|
71
|
+
DataCubeColumnDataType,
|
|
72
|
+
DataCubeColumnPinPlacement,
|
|
73
|
+
DataCubeNumberScale,
|
|
74
|
+
DEFAULT_ROW_BUFFER,
|
|
75
|
+
DEFAULT_URL_LABEL_QUERY_PARAM,
|
|
76
|
+
getDataType,
|
|
77
|
+
DataCubeQuerySortOperation,
|
|
78
|
+
DataCubeColumnKind,
|
|
79
|
+
} from '../core/DataCubeQueryEngine.js';
|
|
80
|
+
import type { CustomLoadingCellRendererProps } from '@ag-grid-community/react';
|
|
81
|
+
import { DataCubeIcon } from '@finos/legend-art';
|
|
82
|
+
import type { DataCubeState } from '../DataCubeState.js';
|
|
83
|
+
|
|
84
|
+
// --------------------------------- UTILITIES ---------------------------------
|
|
85
|
+
|
|
86
|
+
// See https://www.ag-grid.com/javascript-data-grid/cell-data-types/
|
|
87
|
+
function _cellDataType(column: DataCubeQuerySnapshotColumn) {
|
|
88
|
+
switch (column.type) {
|
|
89
|
+
case PRIMITIVE_TYPE.NUMBER:
|
|
90
|
+
case PRIMITIVE_TYPE.DECIMAL:
|
|
91
|
+
case PRIMITIVE_TYPE.INTEGER:
|
|
92
|
+
case PRIMITIVE_TYPE.FLOAT:
|
|
93
|
+
return 'number';
|
|
94
|
+
case PRIMITIVE_TYPE.DATE:
|
|
95
|
+
case PRIMITIVE_TYPE.DATETIME:
|
|
96
|
+
case PRIMITIVE_TYPE.STRICTDATE:
|
|
97
|
+
return 'dateString';
|
|
98
|
+
case PRIMITIVE_TYPE.STRING:
|
|
99
|
+
default:
|
|
100
|
+
return 'text';
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function _allowedAggFuncs(column: DataCubeQuerySnapshotColumn) {
|
|
105
|
+
switch (column.type) {
|
|
106
|
+
case PRIMITIVE_TYPE.STRING:
|
|
107
|
+
case PRIMITIVE_TYPE.DATE:
|
|
108
|
+
case PRIMITIVE_TYPE.DATETIME:
|
|
109
|
+
case PRIMITIVE_TYPE.STRICTDATE:
|
|
110
|
+
return [];
|
|
111
|
+
case PRIMITIVE_TYPE.NUMBER:
|
|
112
|
+
case PRIMITIVE_TYPE.DECIMAL:
|
|
113
|
+
case PRIMITIVE_TYPE.INTEGER:
|
|
114
|
+
case PRIMITIVE_TYPE.FLOAT:
|
|
115
|
+
return [
|
|
116
|
+
GridClientAggregateOperation.AVERAGE,
|
|
117
|
+
GridClientAggregateOperation.COUNT,
|
|
118
|
+
GridClientAggregateOperation.SUM,
|
|
119
|
+
GridClientAggregateOperation.MAX,
|
|
120
|
+
GridClientAggregateOperation.MIN,
|
|
121
|
+
];
|
|
122
|
+
default:
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function _aggFunc(
|
|
128
|
+
func: DataCubeAggregateFunction,
|
|
129
|
+
): GridClientAggregateOperation {
|
|
130
|
+
switch (func) {
|
|
131
|
+
case DataCubeAggregateFunction.AVERAGE:
|
|
132
|
+
return GridClientAggregateOperation.AVERAGE;
|
|
133
|
+
case DataCubeAggregateFunction.COUNT:
|
|
134
|
+
return GridClientAggregateOperation.COUNT;
|
|
135
|
+
case DataCubeAggregateFunction.MAX:
|
|
136
|
+
return GridClientAggregateOperation.MAX;
|
|
137
|
+
case DataCubeAggregateFunction.MIN:
|
|
138
|
+
return GridClientAggregateOperation.MIN;
|
|
139
|
+
case DataCubeAggregateFunction.SUM:
|
|
140
|
+
return GridClientAggregateOperation.SUM;
|
|
141
|
+
default:
|
|
142
|
+
throw new IllegalStateError(`Unsupported aggregate function '${func}'`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function scaleNumber(
|
|
147
|
+
value: number,
|
|
148
|
+
type: DataCubeNumberScale | undefined,
|
|
149
|
+
): { value: number; unit: string | undefined } {
|
|
150
|
+
switch (type) {
|
|
151
|
+
case DataCubeNumberScale.PERCENT:
|
|
152
|
+
return { value: value * 1e2, unit: '%' };
|
|
153
|
+
case DataCubeNumberScale.BASIS_POINT:
|
|
154
|
+
return { value: value * 1e4, unit: 'bp' };
|
|
155
|
+
case DataCubeNumberScale.THOUSANDS:
|
|
156
|
+
return { value: value / 1e3, unit: 'k' };
|
|
157
|
+
case DataCubeNumberScale.MILLIONS:
|
|
158
|
+
return { value: value / 1e6, unit: 'm' };
|
|
159
|
+
case DataCubeNumberScale.BILLIONS:
|
|
160
|
+
return { value: value / 1e9, unit: 'b' };
|
|
161
|
+
case DataCubeNumberScale.TRILLIONS:
|
|
162
|
+
return { value: value / 1e12, unit: 't' };
|
|
163
|
+
case DataCubeNumberScale.AUTO:
|
|
164
|
+
return scaleNumber(
|
|
165
|
+
value,
|
|
166
|
+
value >= 1e12
|
|
167
|
+
? DataCubeNumberScale.TRILLIONS
|
|
168
|
+
: value >= 1e9
|
|
169
|
+
? DataCubeNumberScale.BILLIONS
|
|
170
|
+
: value >= 1e6
|
|
171
|
+
? DataCubeNumberScale.MILLIONS
|
|
172
|
+
: value >= 1e3
|
|
173
|
+
? DataCubeNumberScale.THOUSANDS
|
|
174
|
+
: undefined,
|
|
175
|
+
);
|
|
176
|
+
default:
|
|
177
|
+
return { value, unit: undefined };
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function DataCubeGridLoadingCellRenderer(
|
|
182
|
+
props: CustomLoadingCellRendererProps,
|
|
183
|
+
) {
|
|
184
|
+
if (props.node.failedLoad) {
|
|
185
|
+
return <span className="inline-flex items-center">#ERR</span>;
|
|
186
|
+
}
|
|
187
|
+
return (
|
|
188
|
+
<span className="inline-flex items-center">
|
|
189
|
+
<DataCubeIcon.Loader className="mr-1 animate-spin stroke-2" />
|
|
190
|
+
Loading
|
|
191
|
+
</span>
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// --------------------------------- BUILDING BLOCKS ---------------------------------
|
|
196
|
+
|
|
197
|
+
type ColumnData = {
|
|
198
|
+
snapshot: DataCubeQuerySnapshot;
|
|
199
|
+
column: DataCubeColumnConfiguration;
|
|
200
|
+
configuration: DataCubeConfiguration;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
function getCellRenderer(columnData: ColumnData) {
|
|
204
|
+
const { column } = columnData;
|
|
205
|
+
const dataType = getDataType(column.type);
|
|
206
|
+
if (dataType === DataCubeColumnDataType.TEXT && column.displayAsLink) {
|
|
207
|
+
return function LinkRenderer(params: ICellRendererParams) {
|
|
208
|
+
const isUrl = isValidUrl(params.value);
|
|
209
|
+
if (!isUrl) {
|
|
210
|
+
return params.value;
|
|
211
|
+
}
|
|
212
|
+
const url = params.value as string;
|
|
213
|
+
const label = getQueryParameterValue(
|
|
214
|
+
column.linkLabelParameter ?? DEFAULT_URL_LABEL_QUERY_PARAM,
|
|
215
|
+
getQueryParameters(url, true),
|
|
216
|
+
);
|
|
217
|
+
return (
|
|
218
|
+
<a
|
|
219
|
+
href={url}
|
|
220
|
+
target="_blank"
|
|
221
|
+
rel="noreferrer"
|
|
222
|
+
className="text-blue-600 underline"
|
|
223
|
+
>
|
|
224
|
+
{label ?? url}
|
|
225
|
+
</a>
|
|
226
|
+
);
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function _displaySpec(columnData: ColumnData) {
|
|
233
|
+
const { column, configuration } = columnData;
|
|
234
|
+
const dataType = getDataType(column.type);
|
|
235
|
+
const fontFamily = column.fontFamily ?? configuration.fontFamily;
|
|
236
|
+
const fontSize = column.fontSize ?? configuration.fontSize;
|
|
237
|
+
const fontBold = column.fontBold ?? configuration.fontBold;
|
|
238
|
+
const fontItalic = column.fontItalic ?? configuration.fontItalic;
|
|
239
|
+
const fontStrikethrough =
|
|
240
|
+
column.fontStrikethrough ?? configuration.fontStrikethrough;
|
|
241
|
+
const fontUnderline = column.fontUnderline ?? configuration.fontUnderline;
|
|
242
|
+
const fontCase = column.fontCase ?? configuration.fontCase;
|
|
243
|
+
const textAlign = column.textAlign ?? configuration.textAlign;
|
|
244
|
+
const normalForegroundColor =
|
|
245
|
+
column.normalForegroundColor ?? configuration.normalForegroundColor;
|
|
246
|
+
const normalBackgroundColor =
|
|
247
|
+
column.normalBackgroundColor ?? configuration.normalBackgroundColor;
|
|
248
|
+
const negativeForegroundColor =
|
|
249
|
+
column.negativeForegroundColor ?? configuration.negativeForegroundColor;
|
|
250
|
+
const negativeBackgroundColor =
|
|
251
|
+
column.negativeBackgroundColor ?? configuration.negativeBackgroundColor;
|
|
252
|
+
const zeroForegroundColor =
|
|
253
|
+
column.zeroForegroundColor ?? configuration.zeroForegroundColor;
|
|
254
|
+
const zeroBackgroundColor =
|
|
255
|
+
column.zeroBackgroundColor ?? configuration.zeroBackgroundColor;
|
|
256
|
+
const errorForegroundColor =
|
|
257
|
+
column.errorForegroundColor ?? configuration.errorForegroundColor;
|
|
258
|
+
const errorBackgroundColor =
|
|
259
|
+
column.errorBackgroundColor ?? configuration.errorBackgroundColor;
|
|
260
|
+
const cellRenderer = getCellRenderer(columnData);
|
|
261
|
+
return {
|
|
262
|
+
// setting the cell data type might helps guide the grid to render the cell properly
|
|
263
|
+
// and optimize the grid performance slightly by avoiding unnecessary type inference
|
|
264
|
+
cellDataType: _cellDataType(column),
|
|
265
|
+
hide: column.hideFromView,
|
|
266
|
+
valueFormatter:
|
|
267
|
+
dataType === DataCubeColumnDataType.NUMBER
|
|
268
|
+
? (params) => {
|
|
269
|
+
const value = params.value as number | null | undefined;
|
|
270
|
+
if (value === null || value === undefined) {
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
const showNegativeNumberInParens =
|
|
274
|
+
column.negativeNumberInParens && value < 0;
|
|
275
|
+
// 1. apply the number scale
|
|
276
|
+
const scaledNumber = scaleNumber(value, column.numberScale);
|
|
277
|
+
// 2. apply the number formatter
|
|
278
|
+
const formattedValue = (
|
|
279
|
+
showNegativeNumberInParens
|
|
280
|
+
? Math.abs(scaledNumber.value)
|
|
281
|
+
: scaledNumber.value
|
|
282
|
+
).toLocaleString(undefined, {
|
|
283
|
+
useGrouping: column.displayCommas,
|
|
284
|
+
...(column.decimals !== undefined
|
|
285
|
+
? {
|
|
286
|
+
minimumFractionDigits: column.decimals,
|
|
287
|
+
maximumFractionDigits: column.decimals,
|
|
288
|
+
}
|
|
289
|
+
: {}),
|
|
290
|
+
});
|
|
291
|
+
// 3. add the parentheses (and then the unit)
|
|
292
|
+
return (
|
|
293
|
+
(showNegativeNumberInParens
|
|
294
|
+
? `(${formattedValue})`
|
|
295
|
+
: formattedValue) +
|
|
296
|
+
(scaledNumber.unit ? ` ${scaledNumber.unit}` : '')
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
: (params) => params.value,
|
|
300
|
+
loadingCellRenderer: DataCubeGridLoadingCellRenderer,
|
|
301
|
+
cellClassRules: {
|
|
302
|
+
[generateFontFamilyUtilityClassName(fontFamily)]: () => true,
|
|
303
|
+
[generateFontSizeUtilityClassName(fontSize)]: () => true,
|
|
304
|
+
[INTERNAL__GRID_CLIENT_UTILITY_CSS_CLASS_NAME.FONT_BOLD]: () => fontBold,
|
|
305
|
+
[INTERNAL__GRID_CLIENT_UTILITY_CSS_CLASS_NAME.FONT_ITALIC]: () =>
|
|
306
|
+
fontItalic,
|
|
307
|
+
[INTERNAL__GRID_CLIENT_UTILITY_CSS_CLASS_NAME.FONT_STRIKETHROUGH]: () =>
|
|
308
|
+
fontStrikethrough,
|
|
309
|
+
[generateFontUnderlineUtilityClassName(fontUnderline)]: () =>
|
|
310
|
+
Boolean(fontUnderline),
|
|
311
|
+
[generateFontCaseUtilityClassName(fontCase)]: (params) =>
|
|
312
|
+
dataType === DataCubeColumnDataType.TEXT && Boolean(fontCase),
|
|
313
|
+
[generateTextAlignUtilityClassName(textAlign)]: () => true,
|
|
314
|
+
[generateTextColorUtilityClassName(normalForegroundColor, 'normal')]:
|
|
315
|
+
() => true,
|
|
316
|
+
[generateBackgroundColorUtilityClassName(
|
|
317
|
+
normalBackgroundColor,
|
|
318
|
+
'normal',
|
|
319
|
+
)]: () => true,
|
|
320
|
+
[generateTextColorUtilityClassName(zeroForegroundColor, 'zero')]: (
|
|
321
|
+
params,
|
|
322
|
+
) =>
|
|
323
|
+
dataType === DataCubeColumnDataType.NUMBER &&
|
|
324
|
+
isNumber(params.value) &&
|
|
325
|
+
params.value === 0,
|
|
326
|
+
[generateBackgroundColorUtilityClassName(zeroBackgroundColor, 'zero')]: (
|
|
327
|
+
params,
|
|
328
|
+
) =>
|
|
329
|
+
dataType === DataCubeColumnDataType.NUMBER &&
|
|
330
|
+
isNumber(params.value) &&
|
|
331
|
+
params.value === 0,
|
|
332
|
+
[generateTextColorUtilityClassName(negativeForegroundColor, 'negative')]:
|
|
333
|
+
(params) =>
|
|
334
|
+
dataType === DataCubeColumnDataType.NUMBER &&
|
|
335
|
+
isNumber(params.value) &&
|
|
336
|
+
params.value < 0,
|
|
337
|
+
[generateBackgroundColorUtilityClassName(
|
|
338
|
+
negativeBackgroundColor,
|
|
339
|
+
'negative',
|
|
340
|
+
)]: (params) =>
|
|
341
|
+
dataType === DataCubeColumnDataType.NUMBER &&
|
|
342
|
+
isNumber(params.value) &&
|
|
343
|
+
params.value < 0,
|
|
344
|
+
[generateTextColorUtilityClassName(errorForegroundColor, 'error')]: (
|
|
345
|
+
params,
|
|
346
|
+
) => params.node.failedLoad,
|
|
347
|
+
[generateBackgroundColorUtilityClassName(errorBackgroundColor, 'error')]:
|
|
348
|
+
(params) => params.node.failedLoad,
|
|
349
|
+
[INTERNAL__GRID_CLIENT_UTILITY_CSS_CLASS_NAME.BLUR]: () => column.blur,
|
|
350
|
+
},
|
|
351
|
+
cellRenderer: cellRenderer,
|
|
352
|
+
pinned:
|
|
353
|
+
column.pinned !== undefined
|
|
354
|
+
? column.pinned === DataCubeColumnPinPlacement.RIGHT
|
|
355
|
+
? GridClientPinnedAlignement.RIGHT
|
|
356
|
+
: GridClientPinnedAlignement.LEFT
|
|
357
|
+
: null,
|
|
358
|
+
tooltipValueGetter: (params) =>
|
|
359
|
+
isNonNullable(params.value)
|
|
360
|
+
? `Value = ${params.value === '' ? "''" : params.value === true ? 'TRUE' : params.value === false ? 'FALSE' : params.value}`
|
|
361
|
+
: `Missing Value`,
|
|
362
|
+
} as ColDef;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function _sizeSpec(columnData: ColumnData) {
|
|
366
|
+
const { column } = columnData;
|
|
367
|
+
return {
|
|
368
|
+
// NOTE: there is a problem with ag-grid when scrolling horizontally, the header row
|
|
369
|
+
// lags behind the data, it seems to be caused by synchronizing scroll not working properly
|
|
370
|
+
// There is currently, no way around this
|
|
371
|
+
// See https://github.com/ag-grid/ag-grid/issues/5233
|
|
372
|
+
// See https://github.com/ag-grid/ag-grid/issues/7620
|
|
373
|
+
// See https://github.com/ag-grid/ag-grid/issues/6292
|
|
374
|
+
// See https://issues.chromium.org/issues/40890343#comment11
|
|
375
|
+
//
|
|
376
|
+
// TODO: if we support column resize to fit content, should we disable this behavior?
|
|
377
|
+
resizable: column.fixedWidth === undefined,
|
|
378
|
+
// suppressAutoSize: columnConfiguration.fixedWidth !== undefined,
|
|
379
|
+
width: column.fixedWidth,
|
|
380
|
+
minWidth: Math.max(
|
|
381
|
+
column.minWidth ?? INTERNAL__GRID_CLIENT_COLUMN_MIN_WIDTH,
|
|
382
|
+
INTERNAL__GRID_CLIENT_COLUMN_MIN_WIDTH,
|
|
383
|
+
),
|
|
384
|
+
maxWidth: column.maxWidth,
|
|
385
|
+
} as ColDef;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function _sortSpec(columnData: ColumnData) {
|
|
389
|
+
const { snapshot, column } = columnData;
|
|
390
|
+
const sortColumns = snapshot.data.sortColumns;
|
|
391
|
+
const sortCol = _findCol(sortColumns, column.name);
|
|
392
|
+
return {
|
|
393
|
+
sortable: true, // if this is pivot column, no sorting is allowed
|
|
394
|
+
sort: sortCol
|
|
395
|
+
? sortCol.operation === DataCubeQuerySortOperation.ASCENDING
|
|
396
|
+
? GridClientSortDirection.ASCENDING
|
|
397
|
+
: GridClientSortDirection.DESCENDING
|
|
398
|
+
: null,
|
|
399
|
+
sortIndex: sortCol ? sortColumns.indexOf(sortCol) : null,
|
|
400
|
+
} as ColDef;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function _rowGroupSpec(columnData: ColumnData) {
|
|
404
|
+
const { snapshot, column } = columnData;
|
|
405
|
+
const data = snapshot.data;
|
|
406
|
+
const columns = snapshot.stageCols('aggregation');
|
|
407
|
+
const rowGroupColumn = _findCol(columns, column.name);
|
|
408
|
+
const groupByCol = _findCol(data.groupBy?.columns, column.name);
|
|
409
|
+
const aggCol = _findCol(data.groupBy?.aggColumns, column.name);
|
|
410
|
+
return {
|
|
411
|
+
enableRowGroup: column.kind === DataCubeColumnKind.DIMENSION,
|
|
412
|
+
enableValue: column.kind === DataCubeColumnKind.MEASURE,
|
|
413
|
+
rowGroup: Boolean(groupByCol),
|
|
414
|
+
// TODO: @akphi - add this from configuration object
|
|
415
|
+
aggFunc: aggCol
|
|
416
|
+
? _aggFunc(aggCol.function)
|
|
417
|
+
: rowGroupColumn
|
|
418
|
+
? (
|
|
419
|
+
[
|
|
420
|
+
PRIMITIVE_TYPE.NUMBER,
|
|
421
|
+
PRIMITIVE_TYPE.DECIMAL,
|
|
422
|
+
PRIMITIVE_TYPE.FLOAT,
|
|
423
|
+
PRIMITIVE_TYPE.INTEGER,
|
|
424
|
+
] as string[]
|
|
425
|
+
).includes(rowGroupColumn.type)
|
|
426
|
+
? GridClientAggregateOperation.SUM
|
|
427
|
+
: null
|
|
428
|
+
: null,
|
|
429
|
+
// TODO: @akphi - add this from configuration object
|
|
430
|
+
allowedAggFuncs: rowGroupColumn ? _allowedAggFuncs(rowGroupColumn) : [],
|
|
431
|
+
} satisfies ColDef;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// --------------------------------- MAIN ---------------------------------
|
|
435
|
+
|
|
436
|
+
export function generateBaseGridOptions(dataCube: DataCubeState): GridOptions {
|
|
437
|
+
const grid = dataCube.grid;
|
|
438
|
+
|
|
439
|
+
return {
|
|
440
|
+
// -------------------------------------- README --------------------------------------
|
|
441
|
+
// NOTE: we observe performance degradataion when configuring the grid via React component
|
|
442
|
+
// props when the options is non-static, i.e. changed when the query configuration changes.
|
|
443
|
+
// As such, we must ONLY ADD STATIC CONFIGURATION HERE, and dynamic configuration should be
|
|
444
|
+
// programatically updated when the query is modified.
|
|
445
|
+
//
|
|
446
|
+
//
|
|
447
|
+
// -------------------------------------- ROW GROUPING --------------------------------------
|
|
448
|
+
rowGroupPanelShow: 'always',
|
|
449
|
+
groupDisplayType: 'custom', // keeps the column set stable even when row grouping is used
|
|
450
|
+
suppressRowGroupHidesColumns: true, // keeps the column set stable even when row grouping is used
|
|
451
|
+
suppressAggFuncInHeader: true, // keeps the columns stable when aggregation is used
|
|
452
|
+
getChildCount: (data) =>
|
|
453
|
+
data[INTERNAL__GRID_CLIENT_ROW_GROUPING_COUNT_AGG_COLUMN_ID],
|
|
454
|
+
// -------------------------------------- PIVOT --------------------------------------
|
|
455
|
+
// pivotPanelShow: "always"
|
|
456
|
+
// pivotMode:true, // TODO: need to make sure we don't hide away any columns when this is enabled
|
|
457
|
+
// -------------------------------------- SORT --------------------------------------
|
|
458
|
+
// Force multi-sorting since this is what the query supports anyway
|
|
459
|
+
alwaysMultiSort: true,
|
|
460
|
+
// -------------------------------------- DISPLAY --------------------------------------
|
|
461
|
+
rowHeight: INTERNAL__GRID_CLIENT_ROW_HEIGHT,
|
|
462
|
+
headerHeight: INTERNAL__GRID_CLIENT_HEADER_HEIGHT,
|
|
463
|
+
suppressBrowserResizeObserver: true,
|
|
464
|
+
noRowsOverlayComponent: () => (
|
|
465
|
+
<div className="flex items-center border-[1.5px] border-neutral-300 p-2 font-medium text-neutral-400">
|
|
466
|
+
<div>
|
|
467
|
+
<DataCubeIcon.WarningCircle className="mr-1 stroke-2 text-lg" />
|
|
468
|
+
</div>
|
|
469
|
+
0 rows
|
|
470
|
+
</div>
|
|
471
|
+
),
|
|
472
|
+
loadingOverlayComponent: () => (
|
|
473
|
+
<div className="flex items-center border-[1.5px] border-neutral-300 p-2 font-medium text-neutral-400">
|
|
474
|
+
<div>
|
|
475
|
+
<DataCubeIcon.Loader className="mr-1 animate-spin stroke-2 text-lg" />
|
|
476
|
+
</div>
|
|
477
|
+
Loading...
|
|
478
|
+
</div>
|
|
479
|
+
),
|
|
480
|
+
// Show cursor position when scrolling
|
|
481
|
+
onBodyScroll: (event) => {
|
|
482
|
+
const rowCount = event.api.getDisplayedRowCount();
|
|
483
|
+
const range = event.api.getVerticalPixelRange();
|
|
484
|
+
const start = Math.max(
|
|
485
|
+
1,
|
|
486
|
+
Math.ceil(range.top / INTERNAL__GRID_CLIENT_ROW_HEIGHT) + 1,
|
|
487
|
+
);
|
|
488
|
+
const end = Math.min(
|
|
489
|
+
rowCount,
|
|
490
|
+
Math.floor(range.bottom / INTERNAL__GRID_CLIENT_ROW_HEIGHT),
|
|
491
|
+
);
|
|
492
|
+
grid.setScrollHintText(`${start}-${end}/${rowCount}`);
|
|
493
|
+
event.api.hidePopupMenu(); // hide context-menu while scrolling
|
|
494
|
+
},
|
|
495
|
+
onBodyScrollEnd: () => grid.setScrollHintText(undefined),
|
|
496
|
+
// -------------------------------------- CONTEXT MENU --------------------------------------
|
|
497
|
+
preventDefaultOnContextMenu: true, // prevent showing the browser's context menu
|
|
498
|
+
columnMenu: 'new', // ensure context menu works on header
|
|
499
|
+
// NOTE: dynamically generate the content of the context menu to make sure the items are not stale
|
|
500
|
+
getContextMenuItems: (params) =>
|
|
501
|
+
grid.controller.menuBuilder?.(params) ?? [],
|
|
502
|
+
getMainMenuItems: (params) => grid.controller.menuBuilder?.(params) ?? [],
|
|
503
|
+
// -------------------------------------- COLUMN SIZING --------------------------------------
|
|
504
|
+
autoSizePadding: INTERNAL__GRID_CLIENT_AUTO_RESIZE_PADDING,
|
|
505
|
+
autoSizeStrategy: {
|
|
506
|
+
// resize to fit content initially
|
|
507
|
+
type: 'fitCellContents',
|
|
508
|
+
},
|
|
509
|
+
// -------------------------------------- TOOLTIP --------------------------------------
|
|
510
|
+
tooltipShowDelay: INTERNAL__GRID_CLIENT_TOOLTIP_SHOW_DELAY,
|
|
511
|
+
tooltipInteraction: true,
|
|
512
|
+
// -------------------------------------- COLUMN MOVING --------------------------------------
|
|
513
|
+
// suppressDragLeaveHidesColumns: true,
|
|
514
|
+
// -------------------------------------- SERVER SIDE ROW MODEL --------------------------------------
|
|
515
|
+
suppressScrollOnNewData: true,
|
|
516
|
+
suppressServerSideFullWidthLoadingRow: true, // make sure each column has its own loading indicator instead of the whole row
|
|
517
|
+
// -------------------------------------- SELECTION --------------------------------------
|
|
518
|
+
enableRangeSelection: true,
|
|
519
|
+
// -------------------------------------- SIDEBAR --------------------------------------
|
|
520
|
+
sideBar: {
|
|
521
|
+
toolPanels: [
|
|
522
|
+
{
|
|
523
|
+
id: 'columns',
|
|
524
|
+
labelDefault: 'Columns',
|
|
525
|
+
labelKey: 'columns',
|
|
526
|
+
iconKey: 'columns',
|
|
527
|
+
toolPanel: 'agColumnsToolPanel',
|
|
528
|
+
minWidth: INTERNAL__GRID_CLIENT_SIDE_BAR_WIDTH,
|
|
529
|
+
width: INTERNAL__GRID_CLIENT_SIDE_BAR_WIDTH,
|
|
530
|
+
toolPanelParams: {
|
|
531
|
+
suppressValues: true,
|
|
532
|
+
// TODO: enable when we support pivot
|
|
533
|
+
suppressPivotMode: true,
|
|
534
|
+
suppressPivots: true,
|
|
535
|
+
},
|
|
536
|
+
},
|
|
537
|
+
],
|
|
538
|
+
position: 'right',
|
|
539
|
+
},
|
|
540
|
+
// allowDragFromColumnsToolPanel: true,
|
|
541
|
+
// -------------------------------------- PERFORMANCE --------------------------------------
|
|
542
|
+
animateRows: false, // improve performance
|
|
543
|
+
suppressColumnMoveAnimation: true, // improve performance
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
export function generateGridOptionsFromSnapshot(
|
|
548
|
+
snapshot: DataCubeQuerySnapshot,
|
|
549
|
+
configuration: DataCubeConfiguration,
|
|
550
|
+
dataCube: DataCubeState,
|
|
551
|
+
): GridOptions {
|
|
552
|
+
const gridOptions = {
|
|
553
|
+
/**
|
|
554
|
+
* NOTE: there is a strange issue where if we put dynamic configuration directly
|
|
555
|
+
* such as rowClassRules which depends on some changing state (e.g. alternateRows)
|
|
556
|
+
* as the grid component's props, the grid performance will be heavily compromised
|
|
557
|
+
* while if we programatically set it like this, it does not seem so taxing to the
|
|
558
|
+
* performance; perhaps something to do with React component rendering on props change
|
|
559
|
+
* so in general for grid options which are not static, we must configure them here
|
|
560
|
+
*/
|
|
561
|
+
rowClassRules: configuration.alternateRows
|
|
562
|
+
? {
|
|
563
|
+
[INTERNAL__GRID_CLIENT_UTILITY_CSS_CLASS_NAME.HIGHLIGHT_ROW]: (
|
|
564
|
+
params,
|
|
565
|
+
) =>
|
|
566
|
+
params.rowIndex % (configuration.alternateRowsCount * 2) >=
|
|
567
|
+
configuration.alternateRowsCount,
|
|
568
|
+
}
|
|
569
|
+
: null,
|
|
570
|
+
rowBuffer: DEFAULT_ROW_BUFFER,
|
|
571
|
+
|
|
572
|
+
// -------------------------------------- EVENT HANDLERS --------------------------------------
|
|
573
|
+
|
|
574
|
+
onColumnPinned: (event) => {
|
|
575
|
+
if (event.column) {
|
|
576
|
+
const column = event.column;
|
|
577
|
+
const pinned = column.getPinned();
|
|
578
|
+
dataCube.grid.controller.pinColumn(
|
|
579
|
+
column.getColId(),
|
|
580
|
+
pinned === null
|
|
581
|
+
? undefined
|
|
582
|
+
: pinned === GridClientPinnedAlignement.LEFT
|
|
583
|
+
? DataCubeColumnPinPlacement.LEFT
|
|
584
|
+
: DataCubeColumnPinPlacement.RIGHT,
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
},
|
|
588
|
+
|
|
589
|
+
onColumnMoved: (event) => {
|
|
590
|
+
// make sure the move event is finished before syncing the changes
|
|
591
|
+
if (event.column && event.finished) {
|
|
592
|
+
dataCube.grid.controller.rearrangeColumns(
|
|
593
|
+
(event.api.getColumnDefs() ?? [])
|
|
594
|
+
.filter((col): col is ColDef => !('children' in col))
|
|
595
|
+
.map((col) => col.colId ?? ''),
|
|
596
|
+
);
|
|
597
|
+
}
|
|
598
|
+
},
|
|
599
|
+
|
|
600
|
+
onColumnVisible: (event) => {
|
|
601
|
+
if (event.column) {
|
|
602
|
+
const column = event.column;
|
|
603
|
+
const isVisible = column.isVisible();
|
|
604
|
+
dataCube.grid.controller.showColumn(column.getColId(), isVisible);
|
|
605
|
+
}
|
|
606
|
+
},
|
|
607
|
+
|
|
608
|
+
// -------------------------------------- COLUMNS --------------------------------------
|
|
609
|
+
|
|
610
|
+
columnDefs: [
|
|
611
|
+
{
|
|
612
|
+
headerName: '',
|
|
613
|
+
colId: INTERNAL__GRID_CLIENT_TREE_COLUMN_ID,
|
|
614
|
+
cellRenderer: 'agGroupCellRenderer',
|
|
615
|
+
// cellRendererParams: {
|
|
616
|
+
// innerRenderer: (params: ICellRendererParams) => (
|
|
617
|
+
// <>
|
|
618
|
+
// <span>{params.value}</span>
|
|
619
|
+
// {Boolean(
|
|
620
|
+
// params.data[
|
|
621
|
+
// INTERNAL__GRID_CLIENT_ROW_GROUPING_COUNT_AGG_COLUMN_ID
|
|
622
|
+
// ],
|
|
623
|
+
// ) && (
|
|
624
|
+
// <span>{`(${params.data[INTERNAL__GRID_CLIENT_ROW_GROUPING_COUNT_AGG_COLUMN_ID]})`}</span>
|
|
625
|
+
// )}
|
|
626
|
+
// </>
|
|
627
|
+
// ),
|
|
628
|
+
// suppressCount: true,
|
|
629
|
+
// } satisfies IGroupCellRendererParams,
|
|
630
|
+
showRowGroup: true,
|
|
631
|
+
hide: !snapshot.data.groupBy,
|
|
632
|
+
lockPinned: true,
|
|
633
|
+
lockPosition: true,
|
|
634
|
+
pinned: GridClientPinnedAlignement.LEFT,
|
|
635
|
+
cellStyle: {
|
|
636
|
+
flex: 1,
|
|
637
|
+
justifyContent: 'space-between',
|
|
638
|
+
display: 'flex',
|
|
639
|
+
},
|
|
640
|
+
// TODO: display: coloring, text, etc.
|
|
641
|
+
// TODO: pinning (should we pin this left by default?)
|
|
642
|
+
// TODO: tooltip
|
|
643
|
+
loadingCellRenderer: DataCubeGridLoadingCellRenderer,
|
|
644
|
+
sortable: false, // TODO: @akphi - we can support this in the configuration
|
|
645
|
+
} satisfies ColDef,
|
|
646
|
+
// TODO: handle pivot and column grouping
|
|
647
|
+
...configuration.columns.map((column) => {
|
|
648
|
+
const columnData = {
|
|
649
|
+
snapshot,
|
|
650
|
+
column,
|
|
651
|
+
configuration,
|
|
652
|
+
};
|
|
653
|
+
return {
|
|
654
|
+
headerName: column.name,
|
|
655
|
+
field: column.name,
|
|
656
|
+
menuTabs: [],
|
|
657
|
+
|
|
658
|
+
..._displaySpec(columnData),
|
|
659
|
+
..._sizeSpec(columnData),
|
|
660
|
+
..._sortSpec(columnData),
|
|
661
|
+
..._rowGroupSpec(columnData),
|
|
662
|
+
} satisfies ColDef | ColGroupDef;
|
|
663
|
+
}),
|
|
664
|
+
],
|
|
665
|
+
} as GridOptions;
|
|
666
|
+
|
|
667
|
+
return gridOptions;
|
|
668
|
+
}
|