@datawheel/data-explorer 0.2.2 → 0.2.4
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/main.js +151 -136
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { keyframes, createStyles, Select, rem, Flex, Title, Text, Group, Button, Box, Anchor, Input, Stack, SimpleGrid, ScrollArea, Table, MultiSelect, Center, Alert, Loader, Modal, NumberInput, Menu, ActionIcon, useMantineTheme, MantineProvider, Paper, useComponentDefaultProps, Switch, ThemeIcon, Tooltip, Tabs, CloseButton, Drawer, Checkbox, UnstyledButton, TextInput, Accordion, Popover, Divider } from '@mantine/core';
|
|
1
|
+
import { keyframes, createStyles, Select, rem, Flex, Title, Text, Group, Button, Box, Anchor, Input, Stack, SimpleGrid, ScrollArea, LoadingOverlay, Table, MultiSelect, Center, Alert, Loader, Modal, NumberInput, Menu, ActionIcon, useMantineTheme, MantineProvider, Paper, useComponentDefaultProps, Switch, ThemeIcon, Tooltip, Tabs, CloseButton, Drawer, Checkbox, UnstyledButton, TextInput, Accordion, Popover, Divider } from '@mantine/core';
|
|
2
2
|
import { useClipboard, useClickOutside, useFullscreen, useMediaQuery, useDebouncedValue, useDisclosure } from '@mantine/hooks';
|
|
3
3
|
import { Prism } from '@mantine/prism';
|
|
4
4
|
import { IconWorld, IconExternalLink, IconClipboard, IconAlertCircle, IconAlertTriangle, IconSettings, IconMathGreater, IconMathLower, IconArrowsLeftRight, IconCopy, IconDownload, IconDotsVertical, IconArrowsMinimize, IconArrowsMaximize, IconInfoCircleFilled, IconTrash, IconSearch, IconPhotoDown, IconVectorTriangle, IconStack3, IconFilterOff, IconFilter, IconArrowsSort, IconSortDescendingNumbers, IconSortDescendingLetters, IconSortAscendingNumbers, IconSortAscendingLetters, IconLanguage } from '@tabler/icons-react';
|
|
5
5
|
import * as React10 from 'react';
|
|
6
|
-
import React10__default, { createContext, forwardRef, useMemo, useCallback, useContext, useState, useEffect, useRef, Suspense } from 'react';
|
|
6
|
+
import React10__default, { createContext, forwardRef, useMemo, useCallback, useContext, useState, useEffect, useRef, Suspense, useLayoutEffect } from 'react';
|
|
7
7
|
import { translationFactory } from '@datawheel/use-translation';
|
|
8
8
|
import { translationDict, generateCharts, createChartConfig } from '@datawheel/vizbuilder';
|
|
9
9
|
import { createSlice, createSelector, combineReducers, bindActionCreators, configureStore } from '@reduxjs/toolkit';
|
|
@@ -913,8 +913,8 @@ var queriesSlice = createSlice({
|
|
|
913
913
|
delete query.params.drilldowns[action.payload];
|
|
914
914
|
},
|
|
915
915
|
/**
|
|
916
|
-
|
|
917
|
-
|
|
916
|
+
* Remove a single DrilldownItem from the current QueryItem.
|
|
917
|
+
*/
|
|
918
918
|
removeMeasure(state, action) {
|
|
919
919
|
const query = taintCurrentQuery(state);
|
|
920
920
|
delete query.params.measures[action.payload];
|
|
@@ -1002,14 +1002,14 @@ var queriesSlice = createSlice({
|
|
|
1002
1002
|
*/
|
|
1003
1003
|
updateCut(state, { payload }) {
|
|
1004
1004
|
const query = taintCurrentQuery(state);
|
|
1005
|
-
query.params.cuts[payload.
|
|
1005
|
+
query.params.cuts[payload.key] = payload;
|
|
1006
1006
|
},
|
|
1007
1007
|
/**
|
|
1008
1008
|
* Replaces a single DrilldownItem in the current QueryItem.
|
|
1009
1009
|
*/
|
|
1010
1010
|
updateDrilldown(state, { payload }) {
|
|
1011
1011
|
const query = taintCurrentQuery(state);
|
|
1012
|
-
query.params.drilldowns[payload.
|
|
1012
|
+
query.params.drilldowns[payload.key] = payload;
|
|
1013
1013
|
},
|
|
1014
1014
|
/**
|
|
1015
1015
|
* Replaces a single FilterItem in the current QueryItem.
|
|
@@ -1083,10 +1083,7 @@ var selectCurrentQueryParams = createSelector(
|
|
|
1083
1083
|
selectCurrentQueryItem,
|
|
1084
1084
|
(query) => query.params
|
|
1085
1085
|
);
|
|
1086
|
-
var selectCubeName = createSelector(
|
|
1087
|
-
selectCurrentQueryParams,
|
|
1088
|
-
(params) => params.cube
|
|
1089
|
-
);
|
|
1086
|
+
var selectCubeName = createSelector(selectCurrentQueryParams, (params) => params.cube);
|
|
1090
1087
|
var selectLocale = createSelector(
|
|
1091
1088
|
[selectCurrentQueryParams, selectServerState],
|
|
1092
1089
|
(params, server) => {
|
|
@@ -1098,10 +1095,7 @@ var selectLocale = createSelector(
|
|
|
1098
1095
|
};
|
|
1099
1096
|
}
|
|
1100
1097
|
);
|
|
1101
|
-
var selectCutMap = createSelector(
|
|
1102
|
-
selectCurrentQueryParams,
|
|
1103
|
-
(params) => params.cuts
|
|
1104
|
-
);
|
|
1098
|
+
var selectCutMap = createSelector(selectCurrentQueryParams, (params) => params.cuts);
|
|
1105
1099
|
createSelector(selectCutMap, getKeys);
|
|
1106
1100
|
var selectCutItems = createSelector(selectCutMap, getValues);
|
|
1107
1101
|
var selectDrilldownMap = createSelector(
|
|
@@ -1110,34 +1104,25 @@ var selectDrilldownMap = createSelector(
|
|
|
1110
1104
|
);
|
|
1111
1105
|
createSelector(selectDrilldownMap, getKeys);
|
|
1112
1106
|
var selectDrilldownItems = createSelector(selectDrilldownMap, getValues);
|
|
1113
|
-
var selectFilterMap = createSelector(
|
|
1114
|
-
selectCurrentQueryParams,
|
|
1115
|
-
(params) => params.filters
|
|
1116
|
-
);
|
|
1107
|
+
var selectFilterMap = createSelector(selectCurrentQueryParams, (params) => params.filters);
|
|
1117
1108
|
createSelector(selectFilterMap, getKeys);
|
|
1118
1109
|
var selectFilterItems = createSelector(selectFilterMap, getValues);
|
|
1119
|
-
var selectMeasureMap = createSelector(
|
|
1120
|
-
selectCurrentQueryParams,
|
|
1121
|
-
(params) => params.measures
|
|
1122
|
-
);
|
|
1110
|
+
var selectMeasureMap = createSelector(selectCurrentQueryParams, (params) => params.measures);
|
|
1123
1111
|
createSelector(selectMeasureMap, getKeys);
|
|
1124
1112
|
var selectMeasureItems = createSelector(selectMeasureMap, getValues);
|
|
1125
|
-
createSelector(
|
|
1126
|
-
selectCurrentQueryParams,
|
|
1127
|
-
(params) => params.booleans
|
|
1128
|
-
);
|
|
1113
|
+
createSelector(selectCurrentQueryParams, (params) => params.booleans);
|
|
1129
1114
|
var selectIsPreviewMode = createSelector(
|
|
1130
1115
|
selectCurrentQueryParams,
|
|
1131
1116
|
(params) => params.isPreview
|
|
1132
1117
|
);
|
|
1133
|
-
var selectPaginationParams = createSelector(
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
);
|
|
1137
|
-
createSelector(
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
);
|
|
1118
|
+
var selectPaginationParams = createSelector(selectCurrentQueryParams, (params) => ({
|
|
1119
|
+
limit: params.pagiLimit || 0,
|
|
1120
|
+
offset: params.pagiOffset || 0
|
|
1121
|
+
}));
|
|
1122
|
+
createSelector(selectCurrentQueryParams, (params) => ({
|
|
1123
|
+
sortKey: params.sortKey || "",
|
|
1124
|
+
sortDir: params.sortDir
|
|
1125
|
+
}));
|
|
1141
1126
|
createSelector(
|
|
1142
1127
|
selectCurrentQueryParams,
|
|
1143
1128
|
(params) => isValidQueryVerbose(params)
|
|
@@ -1565,7 +1550,7 @@ function calcMaxMemberCount(query, params, dispatch) {
|
|
|
1565
1550
|
(level) => Level.isLevel(level) ? drills[level.uniqueName] || ds.fetchMembers(level).then(async (members) => {
|
|
1566
1551
|
const { dimension } = level;
|
|
1567
1552
|
const drilldown = Object.values(params.drilldowns).find(
|
|
1568
|
-
(d) => d.uniqueName === level.uniqueName
|
|
1553
|
+
(d) => d.uniqueName === buildDrilldown(level).uniqueName
|
|
1569
1554
|
);
|
|
1570
1555
|
if (drilldown) {
|
|
1571
1556
|
const ddd = {
|
|
@@ -1574,7 +1559,7 @@ function calcMaxMemberCount(query, params, dispatch) {
|
|
|
1574
1559
|
memberCount: members.length,
|
|
1575
1560
|
members
|
|
1576
1561
|
};
|
|
1577
|
-
dispatch(actions.updateDrilldown(ddd));
|
|
1562
|
+
dispatch(actions.updateDrilldown(buildDrilldown({ ...ddd, key: stringifyName(ddd) })));
|
|
1578
1563
|
createCutHandler(params.cuts, ddd, dispatch);
|
|
1579
1564
|
}
|
|
1580
1565
|
return members.length;
|
|
@@ -1591,6 +1576,7 @@ function hydrateDrilldownProperties(cube, drilldownItem) {
|
|
|
1591
1576
|
if (level.matches(drilldownItem)) {
|
|
1592
1577
|
return buildDrilldown({
|
|
1593
1578
|
...drilldownItem,
|
|
1579
|
+
// key: stringifyName(drilldownItem),
|
|
1594
1580
|
fullName: level.fullName,
|
|
1595
1581
|
uniqueName: level.uniqueName,
|
|
1596
1582
|
dimType: level.dimension.dimensionType,
|
|
@@ -1617,9 +1603,15 @@ function deriveDrilldowns(dimensions) {
|
|
|
1617
1603
|
}
|
|
1618
1604
|
for (const dim of dimensions) {
|
|
1619
1605
|
if (dim.type !== "time" && drilldowns.length < 4) {
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1606
|
+
if (dim.hierarchies.length === 1) {
|
|
1607
|
+
const { levels } = dim.hierarchies[0];
|
|
1608
|
+
const levelIndex = dim.type === "geo" ? levels.length - 1 : 0;
|
|
1609
|
+
drilldowns.push(levels[levelIndex]);
|
|
1610
|
+
} else {
|
|
1611
|
+
const { levels } = findDefaultHierarchy(dim);
|
|
1612
|
+
const levelIndex = dim.type === "geo" ? levels.length - 1 : 0;
|
|
1613
|
+
drilldowns.push(levels[levelIndex]);
|
|
1614
|
+
}
|
|
1623
1615
|
}
|
|
1624
1616
|
}
|
|
1625
1617
|
return drilldowns;
|
|
@@ -1749,7 +1741,7 @@ function willExecuteQuery({ limit, offset } = {}) {
|
|
|
1749
1741
|
const { data, headers, status } = aggregation;
|
|
1750
1742
|
!isPrefetch && dispatch(
|
|
1751
1743
|
queriesActions.updateResult({
|
|
1752
|
-
data,
|
|
1744
|
+
data: data == null ? void 0 : data.data,
|
|
1753
1745
|
types: (data == null ? void 0 : data.data.length) ? describeData(cube.toJSON(), params, data == null ? void 0 : data.data) : currentResult.types,
|
|
1754
1746
|
headers: { ...headers },
|
|
1755
1747
|
sourceCall: query.toSource(),
|
|
@@ -2707,33 +2699,8 @@ function AddColumnsDrawer() {
|
|
|
2707
2699
|
}
|
|
2708
2700
|
function DrillDownOptions() {
|
|
2709
2701
|
const locale = useSelector$1(selectLocale);
|
|
2710
|
-
const actions2 = useActions();
|
|
2711
2702
|
const selectedDimensions = useSelector$1(selectDrilldownItems);
|
|
2712
2703
|
const dimensions = useSelector$1(selectOlapDimensionItems) || [];
|
|
2713
|
-
const createCutHandler2 = React10__default.useCallback((level) => {
|
|
2714
|
-
const cutItem = buildCut({ ...level, key: level.fullName, members: [] });
|
|
2715
|
-
cutItem.active = false;
|
|
2716
|
-
actions2.updateCut(cutItem);
|
|
2717
|
-
}, []);
|
|
2718
|
-
useCallback(
|
|
2719
|
-
(level) => {
|
|
2720
|
-
var _a;
|
|
2721
|
-
const drilldownItem = (_a = selectedDimensions.find((item) => item.uniqueName === level.uniqueName)) != null ? _a : buildDrilldown({ ...level });
|
|
2722
|
-
createCutHandler2(level);
|
|
2723
|
-
actions2.updateDrilldown(drilldownItem);
|
|
2724
|
-
actions2.willFetchMembers({ ...level, level: level.name }).then((members) => {
|
|
2725
|
-
const dimension = dimensions.find((dim) => dim.name === level.dimension);
|
|
2726
|
-
if (!dimension) return;
|
|
2727
|
-
actions2.updateDrilldown({
|
|
2728
|
-
...drilldownItem,
|
|
2729
|
-
dimType: dimension.dimensionType,
|
|
2730
|
-
memberCount: members.length,
|
|
2731
|
-
members
|
|
2732
|
-
});
|
|
2733
|
-
});
|
|
2734
|
-
},
|
|
2735
|
-
[dimensions]
|
|
2736
|
-
);
|
|
2737
2704
|
const activeItems = selectedDimensions.filter((i) => i.active);
|
|
2738
2705
|
const options = useMemo(
|
|
2739
2706
|
() => dimensions.map((dimension) => /* @__PURE__ */ React10__default.createElement(
|
|
@@ -2745,7 +2712,7 @@ function DrillDownOptions() {
|
|
|
2745
2712
|
activeItems
|
|
2746
2713
|
}
|
|
2747
2714
|
)),
|
|
2748
|
-
[dimensions, activeItems
|
|
2715
|
+
[dimensions, activeItems]
|
|
2749
2716
|
);
|
|
2750
2717
|
return options;
|
|
2751
2718
|
}
|
|
@@ -2803,12 +2770,9 @@ function LevelItem({ dimension, hierarchy, isSubMenu, level, locale, activeItems
|
|
|
2803
2770
|
const { translate: t } = useTranslation();
|
|
2804
2771
|
const actions2 = useActions();
|
|
2805
2772
|
const cutItems = useSelector$1(selectCutItems);
|
|
2806
|
-
useSelector$1(selectOlapDimensionItems);
|
|
2773
|
+
const dimensions = useSelector$1(selectOlapDimensionItems);
|
|
2807
2774
|
const drilldowns = useSelector$1(selectDrilldownMap);
|
|
2808
|
-
const
|
|
2809
|
-
const [currentDrilldown, setCurrentDrilldown] = useState(
|
|
2810
|
-
drilldowns[stringifyNameInternal(level)] || drilldowns[stringifyName(level)]
|
|
2811
|
-
);
|
|
2775
|
+
const ditems = useSelector$1(selectDrilldownItems);
|
|
2812
2776
|
const label = useMemo(() => {
|
|
2813
2777
|
const captions = [
|
|
2814
2778
|
getCaption(dimension, locale),
|
|
@@ -2825,20 +2789,36 @@ function LevelItem({ dimension, hierarchy, isSubMenu, level, locale, activeItems
|
|
|
2825
2789
|
level: captions[2]
|
|
2826
2790
|
});
|
|
2827
2791
|
}, [locale, dimension, hierarchy, level, isSubMenu]);
|
|
2828
|
-
React10__default.useCallback((level2) => {
|
|
2792
|
+
const createCutHandler2 = React10__default.useCallback((level2) => {
|
|
2829
2793
|
const cutItem = buildCut({ ...level2, members: [], key: level2.fullName });
|
|
2830
2794
|
cutItem.active = false;
|
|
2831
2795
|
actions2.updateCut(cutItem);
|
|
2832
2796
|
}, []);
|
|
2833
2797
|
function createDrilldown(level2, cuts) {
|
|
2834
2798
|
const drilldown = buildDrilldown({ ...level2, key: stringifyName(level2), active: false });
|
|
2799
|
+
actions2.updateDrilldown(drilldown);
|
|
2800
|
+
const cut2 = cuts.find((cut3) => cut3.uniqueName === drilldown.uniqueName);
|
|
2801
|
+
if (!cut2) {
|
|
2802
|
+
createCutHandler2({ ...level2, key: stringifyName(level2) });
|
|
2803
|
+
}
|
|
2804
|
+
actions2.willFetchMembers({ ...level2, level: level2.name }).then((members) => {
|
|
2805
|
+
const dimension2 = dimensions.find((dim) => dim.name === level2.dimension);
|
|
2806
|
+
if (!dimension2) return;
|
|
2807
|
+
actions2.updateDrilldown({
|
|
2808
|
+
...drilldown,
|
|
2809
|
+
dimType: dimension2.dimensionType,
|
|
2810
|
+
memberCount: members.length,
|
|
2811
|
+
members
|
|
2812
|
+
});
|
|
2813
|
+
});
|
|
2835
2814
|
return drilldown;
|
|
2836
2815
|
}
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2816
|
+
const currentDrilldown = drilldowns[stringifyName(level)];
|
|
2817
|
+
useLayoutEffect(() => {
|
|
2818
|
+
if (!drilldowns[stringifyName(level)] && !ditems.find((d) => d.uniqueName === buildDrilldown(level).uniqueName)) {
|
|
2819
|
+
createDrilldown(level, cutItems);
|
|
2840
2820
|
}
|
|
2841
|
-
}, []);
|
|
2821
|
+
}, [level, ditems]);
|
|
2842
2822
|
const cut = cutItems.find((cut2) => {
|
|
2843
2823
|
return cut2.uniqueName === (currentDrilldown == null ? void 0 : currentDrilldown.uniqueName);
|
|
2844
2824
|
});
|
|
@@ -2847,7 +2827,7 @@ function LevelItem({ dimension, hierarchy, isSubMenu, level, locale, activeItems
|
|
|
2847
2827
|
}, []);
|
|
2848
2828
|
const checked = activeItems.map(stringifyName).includes(stringifyName(level));
|
|
2849
2829
|
if (!currentDrilldown) return;
|
|
2850
|
-
return /* @__PURE__ */ React10__default.createElement(React10__default.Fragment, null, /* @__PURE__ */ React10__default.createElement(Group, { mt: "sm", position: "apart", key: level.uri, noWrap: true }, /* @__PURE__ */ React10__default.createElement(
|
|
2830
|
+
return currentDrilldown && /* @__PURE__ */ React10__default.createElement(React10__default.Fragment, null, /* @__PURE__ */ React10__default.createElement(Group, { mt: "sm", position: "apart", key: level.uri, noWrap: true }, /* @__PURE__ */ React10__default.createElement(
|
|
2851
2831
|
Checkbox,
|
|
2852
2832
|
{
|
|
2853
2833
|
onChange: () => {
|
|
@@ -2855,7 +2835,6 @@ function LevelItem({ dimension, hierarchy, isSubMenu, level, locale, activeItems
|
|
|
2855
2835
|
const active = checked ? false : cut.members.length ? true : false;
|
|
2856
2836
|
actions2.updateCut({ ...cut, active });
|
|
2857
2837
|
}
|
|
2858
|
-
console.log({ currentDrilldown });
|
|
2859
2838
|
actions2.updateDrilldown({ ...currentDrilldown, active: !currentDrilldown.active });
|
|
2860
2839
|
},
|
|
2861
2840
|
checked,
|
|
@@ -3049,7 +3028,7 @@ function MeasuresOptions() {
|
|
|
3049
3028
|
}, [itemMap, measures, filtersMap, filtersItems]);
|
|
3050
3029
|
const activeItems = filteredItems.filter((f) => isActiveItem(f.measure));
|
|
3051
3030
|
const options = filteredItems.map(({ measure, filter }) => {
|
|
3052
|
-
return /* @__PURE__ */ React10__default.createElement(FilterItem4, { measure, filter, activeItems });
|
|
3031
|
+
return /* @__PURE__ */ React10__default.createElement(FilterItem4, { key: measure.key, measure, filter, activeItems });
|
|
3053
3032
|
});
|
|
3054
3033
|
return options;
|
|
3055
3034
|
}
|
|
@@ -3159,7 +3138,7 @@ function getFiltersConditions(fn, value) {
|
|
|
3159
3138
|
]);
|
|
3160
3139
|
return (_a = comparisonMap.get(fn)) == null ? void 0 : _a(value);
|
|
3161
3140
|
}
|
|
3162
|
-
function useTableData({
|
|
3141
|
+
function useTableData({ columns, filters, cuts, pagination }) {
|
|
3163
3142
|
const normalizedFilters = filters.map((filter) => ({
|
|
3164
3143
|
id: filter.measure,
|
|
3165
3144
|
value: getFilterValue(filter)
|
|
@@ -3179,7 +3158,7 @@ function useTableData({ offset, limit, columns, filters, cuts, pagination }) {
|
|
|
3179
3158
|
const handler = debounce(() => {
|
|
3180
3159
|
const term = [columnsStr, filterKey, cutKey, page];
|
|
3181
3160
|
setDebouncedTerm(term);
|
|
3182
|
-
},
|
|
3161
|
+
}, 800);
|
|
3183
3162
|
handler();
|
|
3184
3163
|
return () => handler.cancel();
|
|
3185
3164
|
}, [columnsStr, filterKey, cutKey, page, enabled]);
|
|
@@ -3205,7 +3184,8 @@ function usePrefetch({
|
|
|
3205
3184
|
columns,
|
|
3206
3185
|
cuts,
|
|
3207
3186
|
filters,
|
|
3208
|
-
pagination
|
|
3187
|
+
pagination,
|
|
3188
|
+
isFetching
|
|
3209
3189
|
}) {
|
|
3210
3190
|
const queryClient2 = useQueryClient();
|
|
3211
3191
|
const actions2 = useActions();
|
|
@@ -3223,7 +3203,7 @@ function usePrefetch({
|
|
|
3223
3203
|
const columnsStr = JSON.stringify(columns.sort());
|
|
3224
3204
|
const key = [columnsStr, filterKey, cutKey, page];
|
|
3225
3205
|
React10__default.useEffect(() => {
|
|
3226
|
-
if (!isPlaceholderData && hasMore) {
|
|
3206
|
+
if (!isPlaceholderData && hasMore && !isFetching) {
|
|
3227
3207
|
queryClient2.prefetchQuery({
|
|
3228
3208
|
queryKey: ["table", key],
|
|
3229
3209
|
queryFn: () => {
|
|
@@ -3236,7 +3216,7 @@ function usePrefetch({
|
|
|
3236
3216
|
staleTime: 3e5
|
|
3237
3217
|
});
|
|
3238
3218
|
}
|
|
3239
|
-
}, [
|
|
3219
|
+
}, [limit, page, isPlaceholderData, key, queryClient2, hasMore, off, isFetching]);
|
|
3240
3220
|
}
|
|
3241
3221
|
function useTable({
|
|
3242
3222
|
cube,
|
|
@@ -3276,8 +3256,8 @@ function useTable({
|
|
|
3276
3256
|
actions2.updateFilter(filter);
|
|
3277
3257
|
return filter;
|
|
3278
3258
|
}
|
|
3279
|
-
|
|
3280
|
-
|
|
3259
|
+
useLayoutEffect(() => {
|
|
3260
|
+
filterMap(measuresOlap, (m) => {
|
|
3281
3261
|
const measure = measuresMap[m.name] || handlerCreateMeasure({ ...m, active: false });
|
|
3282
3262
|
const foundFilter = filtersMap[m.name] || filterItems.find((f) => f.measure === measure.name);
|
|
3283
3263
|
const filter = foundFilter || handlerCreateFilter({
|
|
@@ -3289,10 +3269,10 @@ function useTable({
|
|
|
3289
3269
|
});
|
|
3290
3270
|
}, [measuresMap, measuresOlap, filtersMap, filterItems]);
|
|
3291
3271
|
const { isLoading, isFetching, isError, data, isPlaceholderData } = useTableData({
|
|
3292
|
-
offset,
|
|
3293
|
-
limit,
|
|
3294
3272
|
columns: finalUniqueKeys,
|
|
3295
|
-
filters: filterItems.filter(
|
|
3273
|
+
filters: filterItems.filter(
|
|
3274
|
+
(f) => isActiveItem(f) && isActiveItem(measures.find((m) => m.name === f.measure) || { active: false })
|
|
3275
|
+
),
|
|
3296
3276
|
cuts: itemsCuts.filter(isActiveCut),
|
|
3297
3277
|
pagination
|
|
3298
3278
|
});
|
|
@@ -3309,14 +3289,15 @@ function useTable({
|
|
|
3309
3289
|
columns: finalUniqueKeys,
|
|
3310
3290
|
filters: filterItems.filter(isActiveItem),
|
|
3311
3291
|
cuts: itemsCuts.filter(isActiveCut),
|
|
3312
|
-
pagination
|
|
3292
|
+
pagination,
|
|
3293
|
+
isFetching: isFetching || isLoading
|
|
3313
3294
|
});
|
|
3314
3295
|
useEffect(() => {
|
|
3315
3296
|
actions2.updatePagination({
|
|
3316
3297
|
limit: pagination.pageSize,
|
|
3317
3298
|
offset: pagination.pageIndex * pagination.pageSize
|
|
3318
3299
|
});
|
|
3319
|
-
}, [pagination]);
|
|
3300
|
+
}, [pagination, actions2]);
|
|
3320
3301
|
const { translate: t } = useTranslation();
|
|
3321
3302
|
const { currentFormats, getAvailableKeys, getFormatter, getFormatterKey, setFormat } = useFormatter(
|
|
3322
3303
|
cube.measures
|
|
@@ -3325,7 +3306,7 @@ function useTable({
|
|
|
3325
3306
|
const indexColumn = {
|
|
3326
3307
|
id: "#",
|
|
3327
3308
|
Header: "#",
|
|
3328
|
-
Cell: ({ row }) => row.index + 1,
|
|
3309
|
+
Cell: ({ row }) => row.index + 1 + offset,
|
|
3329
3310
|
minWidth: 50,
|
|
3330
3311
|
maxWidth: 50,
|
|
3331
3312
|
width: 50,
|
|
@@ -3502,9 +3483,9 @@ function useTable({
|
|
|
3502
3483
|
...constTableProps,
|
|
3503
3484
|
...mantineTableProps
|
|
3504
3485
|
});
|
|
3505
|
-
return { table, isError, isLoading, data: tableData };
|
|
3486
|
+
return { table, isError, isLoading, data: tableData, columns };
|
|
3506
3487
|
}
|
|
3507
|
-
function TableView({ table, result, isError, isLoading, data }) {
|
|
3488
|
+
function TableView({ table, result, isError, isLoading = false, data, columns }) {
|
|
3508
3489
|
const isData = Boolean(table.getRowModel().rows.length);
|
|
3509
3490
|
return /* @__PURE__ */ React10__default.createElement(Box, { sx: { height: "100%" } }, /* @__PURE__ */ React10__default.createElement(Flex, { direction: "column", justify: "space-between", sx: { height: "100%", flex: "1 1 auto" } }, /* @__PURE__ */ React10__default.createElement(MRT_ProgressBar, { isTopToolbar: false, table }), /* @__PURE__ */ React10__default.createElement(
|
|
3510
3491
|
ScrollArea,
|
|
@@ -3516,6 +3497,7 @@ function TableView({ table, result, isError, isLoading, data }) {
|
|
|
3516
3497
|
overflow: "scroll"
|
|
3517
3498
|
}
|
|
3518
3499
|
},
|
|
3500
|
+
/* @__PURE__ */ React10__default.createElement(LoadingOverlay, { visible: columns.length === 0 && isLoading }),
|
|
3519
3501
|
/* @__PURE__ */ React10__default.createElement(
|
|
3520
3502
|
Table,
|
|
3521
3503
|
{
|
|
@@ -3878,7 +3860,7 @@ function SuccessResult(props) {
|
|
|
3878
3860
|
const { previewLimit, actions: actions2 } = useSettings();
|
|
3879
3861
|
const queryItem = useSelector$1(selectCurrentQueryItem);
|
|
3880
3862
|
const isPreviewMode = useSelector$1(selectIsPreviewMode);
|
|
3881
|
-
const { table, isError, isLoading, data } = useTable({ cube, result });
|
|
3863
|
+
const { table, isError, isLoading, data, columns } = useTable({ cube, result });
|
|
3882
3864
|
const fullscreen = useFullscreen();
|
|
3883
3865
|
const [CurrentComponent, panelKey, panelMeta] = useMemo(() => {
|
|
3884
3866
|
const currentPanel = queryItem.panel || `${panels[0].key}-`;
|
|
@@ -3911,7 +3893,8 @@ function SuccessResult(props) {
|
|
|
3911
3893
|
table,
|
|
3912
3894
|
isError,
|
|
3913
3895
|
isLoading,
|
|
3914
|
-
data
|
|
3896
|
+
data,
|
|
3897
|
+
columns
|
|
3915
3898
|
}
|
|
3916
3899
|
)))))));
|
|
3917
3900
|
}
|
|
@@ -3979,6 +3962,11 @@ var Graph = class {
|
|
|
3979
3962
|
});
|
|
3980
3963
|
return topic;
|
|
3981
3964
|
}
|
|
3965
|
+
getName(node, locale) {
|
|
3966
|
+
const item = this.items.find((item2) => item2.name === node);
|
|
3967
|
+
const name4 = getAnnotation(item, "table", locale);
|
|
3968
|
+
return name4;
|
|
3969
|
+
}
|
|
3982
3970
|
getSubtopic(startingNode, locale) {
|
|
3983
3971
|
let found = false;
|
|
3984
3972
|
let subtopic = null;
|
|
@@ -4008,15 +3996,16 @@ var Graph = class {
|
|
|
4008
3996
|
"name",
|
|
4009
3997
|
(item) => getAnnotation(item, "topic", locale) || "",
|
|
4010
3998
|
(item) => getAnnotation(item, "subtopic", locale) || "",
|
|
4011
|
-
(item) => getAnnotation(item, "table", locale) || ""
|
|
3999
|
+
(item) => getAnnotation(item, "table", locale) || "",
|
|
4000
|
+
(item) => item.name.replace(/_/g, " ")
|
|
4012
4001
|
]
|
|
4013
4002
|
});
|
|
4014
4003
|
for (const item of results) {
|
|
4015
4004
|
const topic = getAnnotation(item, "topic", locale);
|
|
4016
4005
|
const subtopic = getAnnotation(item, "subtopic", locale);
|
|
4017
|
-
|
|
4018
|
-
addItemToSubtopic(map, `${topic} - ${subtopic}`,
|
|
4019
|
-
matches.push(
|
|
4006
|
+
getAnnotation(item, "table", locale);
|
|
4007
|
+
addItemToSubtopic(map, `${topic} - ${subtopic}`, item.name);
|
|
4008
|
+
matches.push(item.name);
|
|
4020
4009
|
}
|
|
4021
4010
|
}
|
|
4022
4011
|
return { matches, map };
|
|
@@ -4187,7 +4176,7 @@ function LocaleSelector() {
|
|
|
4187
4176
|
var [useSideBar, Provider] = createContext2("SideBar");
|
|
4188
4177
|
function SideBarProvider(props) {
|
|
4189
4178
|
const [input, setInput] = useState("");
|
|
4190
|
-
const [expanded, setExpanded] = useState(
|
|
4179
|
+
const [expanded, setExpanded] = useState(true);
|
|
4191
4180
|
const [results, setResults] = useState([]);
|
|
4192
4181
|
const [map, setMap] = useState();
|
|
4193
4182
|
const [graph, setGraph] = useState(new graph_default());
|
|
@@ -4383,12 +4372,7 @@ init_esm_shims();
|
|
|
4383
4372
|
init_esm_shims();
|
|
4384
4373
|
function useSelectCube(onSelectCube) {
|
|
4385
4374
|
const { updateMeasure, updateCut, updateDrilldown, willFetchMembers: willFetchMembers2 } = useActions();
|
|
4386
|
-
|
|
4387
|
-
const cutItem = buildCut({ ...level });
|
|
4388
|
-
cutItem.active = false;
|
|
4389
|
-
updateCut(cutItem);
|
|
4390
|
-
}, []);
|
|
4391
|
-
const addDrilldown = useCallback((level, dimensions) => {
|
|
4375
|
+
useCallback((level, dimensions) => {
|
|
4392
4376
|
const drilldownItem = buildDrilldown(level);
|
|
4393
4377
|
createCutHandler2(level);
|
|
4394
4378
|
updateDrilldown(drilldownItem);
|
|
@@ -4403,13 +4387,34 @@ function useSelectCube(onSelectCube) {
|
|
|
4403
4387
|
});
|
|
4404
4388
|
});
|
|
4405
4389
|
}, []);
|
|
4390
|
+
const createCutHandler2 = React10__default.useCallback((level) => {
|
|
4391
|
+
const cutItem = buildCut({ ...level });
|
|
4392
|
+
cutItem.active = false;
|
|
4393
|
+
updateCut(cutItem);
|
|
4394
|
+
}, []);
|
|
4395
|
+
function createDrilldown(level, dimensions) {
|
|
4396
|
+
const drilldown = buildDrilldown({ ...level, key: stringifyName(level), active: true });
|
|
4397
|
+
updateDrilldown(drilldown);
|
|
4398
|
+
createCutHandler2({ ...level, key: stringifyName(level) });
|
|
4399
|
+
willFetchMembers2({ ...level, level: level.name }).then((members) => {
|
|
4400
|
+
const dimension = dimensions.find((dim) => dim.name === level.dimension);
|
|
4401
|
+
if (!dimension) return;
|
|
4402
|
+
updateDrilldown({
|
|
4403
|
+
...drilldown,
|
|
4404
|
+
dimType: dimension.dimensionType,
|
|
4405
|
+
memberCount: members.length,
|
|
4406
|
+
members
|
|
4407
|
+
});
|
|
4408
|
+
});
|
|
4409
|
+
return drilldown;
|
|
4410
|
+
}
|
|
4406
4411
|
return (item, subtopic) => () => onSelectCube(item, subtopic).then(({ cube, measures, dimensions }) => {
|
|
4407
4412
|
const [measure] = Object.values(measures);
|
|
4408
4413
|
const drilldowns = deriveDrilldowns(dimensions);
|
|
4409
4414
|
if (measure && drilldowns.length > 0) {
|
|
4410
4415
|
updateMeasure({ ...measure, active: true });
|
|
4411
4416
|
for (const level of drilldowns) {
|
|
4412
|
-
|
|
4417
|
+
createDrilldown(level, dimensions);
|
|
4413
4418
|
}
|
|
4414
4419
|
}
|
|
4415
4420
|
});
|
|
@@ -4427,6 +4432,7 @@ function Results(props) {
|
|
|
4427
4432
|
const [topic, subtopic] = key.split(" - ");
|
|
4428
4433
|
const component = /* @__PURE__ */ React10__default.createElement("div", { key }, /* @__PURE__ */ React10__default.createElement(Divider, { my: "xs", label: key }), items.map((item) => {
|
|
4429
4434
|
const cube = getCube2(graph.items, item, subtopic, locale);
|
|
4435
|
+
const table = getAnnotation(cube, "table", locale);
|
|
4430
4436
|
return /* @__PURE__ */ React10__default.createElement(
|
|
4431
4437
|
Text,
|
|
4432
4438
|
{
|
|
@@ -4440,7 +4446,7 @@ function Results(props) {
|
|
|
4440
4446
|
setInput("");
|
|
4441
4447
|
}
|
|
4442
4448
|
},
|
|
4443
|
-
|
|
4449
|
+
table
|
|
4444
4450
|
);
|
|
4445
4451
|
}));
|
|
4446
4452
|
result.push(component);
|
|
@@ -4485,32 +4491,38 @@ function SelectCubeInternal(props) {
|
|
|
4485
4491
|
useTranslation();
|
|
4486
4492
|
const { code: locale } = useSelector$1(selectLocale);
|
|
4487
4493
|
const { updateMeasure, updateDrilldown, willFetchMembers: willFetchMembers2, updateCut } = useActions();
|
|
4494
|
+
const cutItems = useSelector$1(selectCutItems);
|
|
4488
4495
|
const cube = useSelector$1(selectCubeName);
|
|
4489
4496
|
const itemMap = useSelector$1(selectMeasureMap);
|
|
4490
4497
|
const dimensions = useSelector$1(selectOlapDimensionItems);
|
|
4498
|
+
const drilldowns = useSelector$1(selectDrilldownMap);
|
|
4499
|
+
const ditems = useSelector$1(selectDrilldownItems);
|
|
4491
4500
|
const createCutHandler2 = React10__default.useCallback((level) => {
|
|
4492
4501
|
const cutItem = buildCut({ ...level });
|
|
4493
4502
|
cutItem.active = false;
|
|
4494
4503
|
updateCut(cutItem);
|
|
4495
4504
|
}, []);
|
|
4496
|
-
|
|
4497
|
-
(level) => {
|
|
4498
|
-
const
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4505
|
+
function createDrilldown(level, cuts) {
|
|
4506
|
+
if (!drilldowns[stringifyName(level)] && !ditems.find((d) => d.uniqueName === buildDrilldown(level).uniqueName)) {
|
|
4507
|
+
const drilldown = buildDrilldown({ ...level, key: stringifyName(level), active: true });
|
|
4508
|
+
updateDrilldown(drilldown);
|
|
4509
|
+
const cut = cuts.find((cut2) => cut2.uniqueName === drilldown.uniqueName);
|
|
4510
|
+
if (!cut) {
|
|
4511
|
+
createCutHandler2({ ...level, key: stringifyName(level) });
|
|
4512
|
+
}
|
|
4513
|
+
willFetchMembers2({ ...level, level: level.name }).then((members) => {
|
|
4502
4514
|
const dimension = dimensions.find((dim) => dim.name === level.dimension);
|
|
4503
4515
|
if (!dimension) return;
|
|
4504
|
-
|
|
4505
|
-
...
|
|
4516
|
+
updateDrilldown({
|
|
4517
|
+
...drilldown,
|
|
4506
4518
|
dimType: dimension.dimensionType,
|
|
4507
4519
|
memberCount: members.length,
|
|
4508
4520
|
members
|
|
4509
4521
|
});
|
|
4510
4522
|
});
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4523
|
+
return drilldown;
|
|
4524
|
+
}
|
|
4525
|
+
}
|
|
4514
4526
|
useEffect(() => {
|
|
4515
4527
|
const params = new URLSearchParams(location.search);
|
|
4516
4528
|
const cubeParam = params.get("cube");
|
|
@@ -4519,11 +4531,11 @@ function SelectCubeInternal(props) {
|
|
|
4519
4531
|
const [dimension] = dimensions;
|
|
4520
4532
|
if (measure && dimension) {
|
|
4521
4533
|
updateMeasure({ ...measure, active: true });
|
|
4522
|
-
const
|
|
4523
|
-
if (measure &&
|
|
4534
|
+
const drilldowns2 = deriveDrilldowns(dimensions);
|
|
4535
|
+
if (measure && drilldowns2.length > 0) {
|
|
4524
4536
|
updateMeasure({ ...measure, active: true });
|
|
4525
|
-
for (const level of
|
|
4526
|
-
|
|
4537
|
+
for (const level of drilldowns2) {
|
|
4538
|
+
createDrilldown(level, cutItems);
|
|
4527
4539
|
}
|
|
4528
4540
|
}
|
|
4529
4541
|
}
|
|
@@ -4553,7 +4565,7 @@ function isSelected(selectedItem, currentItem) {
|
|
|
4553
4565
|
}
|
|
4554
4566
|
function getCube(items, table, subtopic, locale) {
|
|
4555
4567
|
const cube = items.find(
|
|
4556
|
-
(item) =>
|
|
4568
|
+
(item) => item.name === table && getAnnotation(item, "subtopic", locale) === subtopic
|
|
4557
4569
|
);
|
|
4558
4570
|
return cube;
|
|
4559
4571
|
}
|
|
@@ -4561,16 +4573,17 @@ function useBuildGraph(items, locale, graph, setGraph) {
|
|
|
4561
4573
|
useEffect(() => {
|
|
4562
4574
|
const graph2 = new graph_default();
|
|
4563
4575
|
items.map((item) => {
|
|
4576
|
+
const { name: name4 } = item;
|
|
4564
4577
|
const topic = getAnnotation(item, "topic", locale);
|
|
4565
4578
|
const subtopic = getAnnotation(item, "subtopic", locale);
|
|
4566
|
-
|
|
4579
|
+
getAnnotation(item, "table", locale);
|
|
4567
4580
|
const hide = getAnnotation(item, "hide_in_ui", locale);
|
|
4568
4581
|
if (!yn(hide)) {
|
|
4569
4582
|
graph2.addNode(topic);
|
|
4570
4583
|
graph2.addNode(subtopic);
|
|
4571
|
-
graph2.addNode(
|
|
4584
|
+
graph2.addNode(name4);
|
|
4572
4585
|
graph2.addEdge(topic, subtopic);
|
|
4573
|
-
graph2.addEdge(subtopic,
|
|
4586
|
+
graph2.addEdge(subtopic, name4);
|
|
4574
4587
|
}
|
|
4575
4588
|
return item;
|
|
4576
4589
|
});
|
|
@@ -4590,9 +4603,12 @@ function CubeTree({
|
|
|
4590
4603
|
const actions2 = useActions();
|
|
4591
4604
|
const onSelectCube = (table, subtopic) => {
|
|
4592
4605
|
const cube = items.find(
|
|
4593
|
-
(item) =>
|
|
4606
|
+
(item) => item.name === table && getAnnotation(item, "subtopic", locale) === subtopic
|
|
4594
4607
|
);
|
|
4595
4608
|
if (cube) {
|
|
4609
|
+
actions2.resetDrilldowns({});
|
|
4610
|
+
actions2.resetCuts({});
|
|
4611
|
+
actions2.resetMeasures({});
|
|
4596
4612
|
return actions2.willSetCube(cube.name);
|
|
4597
4613
|
}
|
|
4598
4614
|
};
|
|
@@ -4690,7 +4706,7 @@ function CubeButton({
|
|
|
4690
4706
|
}) {
|
|
4691
4707
|
const callback = useSelectCube(onSelectCube);
|
|
4692
4708
|
const { classes } = useStyles3();
|
|
4693
|
-
const table = item;
|
|
4709
|
+
const table = graph.getName(item, locale);
|
|
4694
4710
|
const subtopic = parent != null ? parent : "";
|
|
4695
4711
|
return /* @__PURE__ */ React10__default.createElement(
|
|
4696
4712
|
Text,
|
|
@@ -4701,14 +4717,14 @@ function CubeButton({
|
|
|
4701
4717
|
maw: "100%",
|
|
4702
4718
|
pr: "md",
|
|
4703
4719
|
component: "a",
|
|
4704
|
-
className: isSelected(selectedItem, getCube(graph.items,
|
|
4720
|
+
className: isSelected(selectedItem, getCube(graph.items, item, subtopic, locale)) ? `${classes.link} ${classes.linkActive}` : classes.link,
|
|
4705
4721
|
sx: (t) => ({
|
|
4706
|
-
background: isSelected(selectedItem, getCube(graph.items,
|
|
4722
|
+
background: isSelected(selectedItem, getCube(graph.items, item, subtopic, locale)) ? t.fn.primaryColor() : t.colorScheme === "dark" ? t.colors.dark[6] : t.colors.gray[3],
|
|
4707
4723
|
overflow: "hidden"
|
|
4708
4724
|
}),
|
|
4709
4725
|
onClick: callback(item, subtopic)
|
|
4710
4726
|
},
|
|
4711
|
-
|
|
4727
|
+
table
|
|
4712
4728
|
);
|
|
4713
4729
|
}
|
|
4714
4730
|
function SubtopicAccordion({
|
|
@@ -6601,7 +6617,6 @@ function createVizbuilderView(settings) {
|
|
|
6601
6617
|
return VizbuilderView;
|
|
6602
6618
|
function VizbuilderView(props) {
|
|
6603
6619
|
const { cube, panelKey, params, result } = props;
|
|
6604
|
-
console.log(result);
|
|
6605
6620
|
const { actions: actions2, formatters } = useSettings();
|
|
6606
6621
|
const [panelName, currentChart] = useMemo(() => `${panelKey || ""}-`.split("-"), [panelKey]);
|
|
6607
6622
|
const resetCurrentPanel = useCallback(() => {
|
|
@@ -6612,7 +6627,7 @@ function createVizbuilderView(settings) {
|
|
|
6612
6627
|
[
|
|
6613
6628
|
{
|
|
6614
6629
|
cube,
|
|
6615
|
-
dataset: result.data
|
|
6630
|
+
dataset: result.data,
|
|
6616
6631
|
params: {
|
|
6617
6632
|
locale: params.locale || defaultLocale,
|
|
6618
6633
|
booleans: params.booleans,
|
|
@@ -6645,7 +6660,7 @@ function createVizbuilderView(settings) {
|
|
|
6645
6660
|
],
|
|
6646
6661
|
chartGenOptions
|
|
6647
6662
|
),
|
|
6648
|
-
[cube, result.data
|
|
6663
|
+
[cube, result.data, params]
|
|
6649
6664
|
);
|
|
6650
6665
|
const content = useMemo(() => {
|
|
6651
6666
|
const isSingleChart = charts.length === 1;
|