@datawheel/data-explorer 0.2.1 → 0.2.3
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 +119 -101
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useClipboard, useClickOutside, useFullscreen, useMediaQuery, useDebounc
|
|
|
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';
|
|
@@ -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.fullName] = 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.fullName] = payload;
|
|
1013
1013
|
},
|
|
1014
1014
|
/**
|
|
1015
1015
|
* Replaces a single FilterItem in the current QueryItem.
|
|
@@ -1032,7 +1032,7 @@ var queriesSlice = createSlice({
|
|
|
1032
1032
|
*/
|
|
1033
1033
|
updateMeasure(state, { payload }) {
|
|
1034
1034
|
const query = taintCurrentQuery(state);
|
|
1035
|
-
query.params.measures[payload.
|
|
1035
|
+
query.params.measures[payload.name] = payload;
|
|
1036
1036
|
},
|
|
1037
1037
|
/**
|
|
1038
1038
|
* Replaces the pagination settings in the current QueryItem.
|
|
@@ -1565,7 +1565,7 @@ function calcMaxMemberCount(query, params, dispatch) {
|
|
|
1565
1565
|
(level) => Level.isLevel(level) ? drills[level.uniqueName] || ds.fetchMembers(level).then(async (members) => {
|
|
1566
1566
|
const { dimension } = level;
|
|
1567
1567
|
const drilldown = Object.values(params.drilldowns).find(
|
|
1568
|
-
(d) => d.uniqueName === level.uniqueName
|
|
1568
|
+
(d) => d.uniqueName === buildDrilldown(level).uniqueName
|
|
1569
1569
|
);
|
|
1570
1570
|
if (drilldown) {
|
|
1571
1571
|
const ddd = {
|
|
@@ -1574,7 +1574,6 @@ function calcMaxMemberCount(query, params, dispatch) {
|
|
|
1574
1574
|
memberCount: members.length,
|
|
1575
1575
|
members
|
|
1576
1576
|
};
|
|
1577
|
-
dispatch(actions.updateDrilldown(ddd));
|
|
1578
1577
|
createCutHandler(params.cuts, ddd, dispatch);
|
|
1579
1578
|
}
|
|
1580
1579
|
return members.length;
|
|
@@ -1591,6 +1590,7 @@ function hydrateDrilldownProperties(cube, drilldownItem) {
|
|
|
1591
1590
|
if (level.matches(drilldownItem)) {
|
|
1592
1591
|
return buildDrilldown({
|
|
1593
1592
|
...drilldownItem,
|
|
1593
|
+
key: stringifyName(drilldownItem),
|
|
1594
1594
|
fullName: level.fullName,
|
|
1595
1595
|
uniqueName: level.uniqueName,
|
|
1596
1596
|
dimType: level.dimension.dimensionType,
|
|
@@ -1617,9 +1617,15 @@ function deriveDrilldowns(dimensions) {
|
|
|
1617
1617
|
}
|
|
1618
1618
|
for (const dim of dimensions) {
|
|
1619
1619
|
if (dim.type !== "time" && drilldowns.length < 4) {
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1620
|
+
if (dim.hierarchies.length === 1) {
|
|
1621
|
+
const { levels } = dim.hierarchies[0];
|
|
1622
|
+
const levelIndex = dim.type === "geo" ? levels.length - 1 : 0;
|
|
1623
|
+
drilldowns.push(levels[levelIndex]);
|
|
1624
|
+
} else {
|
|
1625
|
+
const { levels } = findDefaultHierarchy(dim);
|
|
1626
|
+
const levelIndex = dim.type === "geo" ? levels.length - 1 : 0;
|
|
1627
|
+
drilldowns.push(levels[levelIndex]);
|
|
1628
|
+
}
|
|
1623
1629
|
}
|
|
1624
1630
|
}
|
|
1625
1631
|
return drilldowns;
|
|
@@ -1749,7 +1755,7 @@ function willExecuteQuery({ limit, offset } = {}) {
|
|
|
1749
1755
|
const { data, headers, status } = aggregation;
|
|
1750
1756
|
!isPrefetch && dispatch(
|
|
1751
1757
|
queriesActions.updateResult({
|
|
1752
|
-
data,
|
|
1758
|
+
data: data == null ? void 0 : data.data,
|
|
1753
1759
|
types: (data == null ? void 0 : data.data.length) ? describeData(cube.toJSON(), params, data == null ? void 0 : data.data) : currentResult.types,
|
|
1754
1760
|
headers: { ...headers },
|
|
1755
1761
|
sourceCall: query.toSource(),
|
|
@@ -2707,33 +2713,8 @@ function AddColumnsDrawer() {
|
|
|
2707
2713
|
}
|
|
2708
2714
|
function DrillDownOptions() {
|
|
2709
2715
|
const locale = useSelector$1(selectLocale);
|
|
2710
|
-
const actions2 = useActions();
|
|
2711
2716
|
const selectedDimensions = useSelector$1(selectDrilldownItems);
|
|
2712
2717
|
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
2718
|
const activeItems = selectedDimensions.filter((i) => i.active);
|
|
2738
2719
|
const options = useMemo(
|
|
2739
2720
|
() => dimensions.map((dimension) => /* @__PURE__ */ React10__default.createElement(
|
|
@@ -2745,7 +2726,7 @@ function DrillDownOptions() {
|
|
|
2745
2726
|
activeItems
|
|
2746
2727
|
}
|
|
2747
2728
|
)),
|
|
2748
|
-
[dimensions, activeItems
|
|
2729
|
+
[dimensions, activeItems]
|
|
2749
2730
|
);
|
|
2750
2731
|
return options;
|
|
2751
2732
|
}
|
|
@@ -2805,6 +2786,7 @@ function LevelItem({ dimension, hierarchy, isSubMenu, level, locale, activeItems
|
|
|
2805
2786
|
const cutItems = useSelector$1(selectCutItems);
|
|
2806
2787
|
const dimensions = useSelector$1(selectOlapDimensionItems);
|
|
2807
2788
|
const drilldowns = useSelector$1(selectDrilldownMap);
|
|
2789
|
+
const ditems = useSelector$1(selectDrilldownItems);
|
|
2808
2790
|
const label = useMemo(() => {
|
|
2809
2791
|
const captions = [
|
|
2810
2792
|
getCaption(dimension, locale),
|
|
@@ -2845,15 +2827,21 @@ function LevelItem({ dimension, hierarchy, isSubMenu, level, locale, activeItems
|
|
|
2845
2827
|
});
|
|
2846
2828
|
return drilldown;
|
|
2847
2829
|
}
|
|
2848
|
-
const currentDrilldown = drilldowns[stringifyName(level)]
|
|
2830
|
+
const currentDrilldown = drilldowns[stringifyName(level)];
|
|
2831
|
+
useLayoutEffect(() => {
|
|
2832
|
+
if (!drilldowns[stringifyName(level)] && !ditems.find((d) => d.uniqueName === buildDrilldown(level).uniqueName)) {
|
|
2833
|
+
createDrilldown(level, cutItems);
|
|
2834
|
+
}
|
|
2835
|
+
}, [level, ditems]);
|
|
2849
2836
|
const cut = cutItems.find((cut2) => {
|
|
2850
|
-
return cut2.uniqueName === currentDrilldown.uniqueName;
|
|
2837
|
+
return cut2.uniqueName === (currentDrilldown == null ? void 0 : currentDrilldown.uniqueName);
|
|
2851
2838
|
});
|
|
2852
2839
|
const updatecutHandler = React10__default.useCallback((item, members) => {
|
|
2853
2840
|
actions2.updateCut({ ...item, members });
|
|
2854
2841
|
}, []);
|
|
2855
2842
|
const checked = activeItems.map(stringifyName).includes(stringifyName(level));
|
|
2856
|
-
|
|
2843
|
+
if (!currentDrilldown) return;
|
|
2844
|
+
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(
|
|
2857
2845
|
Checkbox,
|
|
2858
2846
|
{
|
|
2859
2847
|
onChange: () => {
|
|
@@ -3054,7 +3042,7 @@ function MeasuresOptions() {
|
|
|
3054
3042
|
}, [itemMap, measures, filtersMap, filtersItems]);
|
|
3055
3043
|
const activeItems = filteredItems.filter((f) => isActiveItem(f.measure));
|
|
3056
3044
|
const options = filteredItems.map(({ measure, filter }) => {
|
|
3057
|
-
return /* @__PURE__ */ React10__default.createElement(FilterItem4, { measure, filter, activeItems });
|
|
3045
|
+
return /* @__PURE__ */ React10__default.createElement(FilterItem4, { key: measure.key, measure, filter, activeItems });
|
|
3058
3046
|
});
|
|
3059
3047
|
return options;
|
|
3060
3048
|
}
|
|
@@ -3164,7 +3152,7 @@ function getFiltersConditions(fn, value) {
|
|
|
3164
3152
|
]);
|
|
3165
3153
|
return (_a = comparisonMap.get(fn)) == null ? void 0 : _a(value);
|
|
3166
3154
|
}
|
|
3167
|
-
function useTableData({
|
|
3155
|
+
function useTableData({ columns, filters, cuts, pagination }) {
|
|
3168
3156
|
const normalizedFilters = filters.map((filter) => ({
|
|
3169
3157
|
id: filter.measure,
|
|
3170
3158
|
value: getFilterValue(filter)
|
|
@@ -3176,20 +3164,18 @@ function useTableData({ offset, limit, columns, filters, cuts, pagination }) {
|
|
|
3176
3164
|
const actions2 = useActions();
|
|
3177
3165
|
const columnsStr = JSON.stringify(columns.sort());
|
|
3178
3166
|
const page = pagination.pageIndex;
|
|
3179
|
-
const
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
cutKey,
|
|
3183
|
-
page
|
|
3184
|
-
]);
|
|
3167
|
+
const enabled = Boolean(columns.length) || Boolean(filters.length) || Boolean(cuts.length);
|
|
3168
|
+
const initialKey = enabled ? [columnsStr, filterKey, cutKey, page] : "";
|
|
3169
|
+
const [filterKeydebouced, setDebouncedTerm] = useState(initialKey);
|
|
3185
3170
|
useEffect(() => {
|
|
3171
|
+
if (!enabled) return;
|
|
3186
3172
|
const handler = debounce(() => {
|
|
3187
3173
|
const term = [columnsStr, filterKey, cutKey, page];
|
|
3188
3174
|
setDebouncedTerm(term);
|
|
3189
3175
|
}, 700);
|
|
3190
3176
|
handler();
|
|
3191
3177
|
return () => handler.cancel();
|
|
3192
|
-
}, [columnsStr,
|
|
3178
|
+
}, [columnsStr, filterKey, cutKey, page, enabled]);
|
|
3193
3179
|
return useQuery({
|
|
3194
3180
|
queryKey: ["table", filterKeydebouced],
|
|
3195
3181
|
queryFn: () => {
|
|
@@ -3200,7 +3186,7 @@ function useTableData({ offset, limit, columns, filters, cuts, pagination }) {
|
|
|
3200
3186
|
});
|
|
3201
3187
|
},
|
|
3202
3188
|
staleTime: 3e5,
|
|
3203
|
-
enabled: !!filterKeydebouced
|
|
3189
|
+
enabled: enabled && !!filterKeydebouced
|
|
3204
3190
|
});
|
|
3205
3191
|
}
|
|
3206
3192
|
function usePrefetch({
|
|
@@ -3212,7 +3198,8 @@ function usePrefetch({
|
|
|
3212
3198
|
columns,
|
|
3213
3199
|
cuts,
|
|
3214
3200
|
filters,
|
|
3215
|
-
pagination
|
|
3201
|
+
pagination,
|
|
3202
|
+
isFetching
|
|
3216
3203
|
}) {
|
|
3217
3204
|
const queryClient2 = useQueryClient();
|
|
3218
3205
|
const actions2 = useActions();
|
|
@@ -3230,7 +3217,7 @@ function usePrefetch({
|
|
|
3230
3217
|
const columnsStr = JSON.stringify(columns.sort());
|
|
3231
3218
|
const key = [columnsStr, filterKey, cutKey, page];
|
|
3232
3219
|
React10__default.useEffect(() => {
|
|
3233
|
-
if (!isPlaceholderData && hasMore) {
|
|
3220
|
+
if (!isPlaceholderData && hasMore && !isFetching) {
|
|
3234
3221
|
queryClient2.prefetchQuery({
|
|
3235
3222
|
queryKey: ["table", key],
|
|
3236
3223
|
queryFn: () => {
|
|
@@ -3243,7 +3230,7 @@ function usePrefetch({
|
|
|
3243
3230
|
staleTime: 3e5
|
|
3244
3231
|
});
|
|
3245
3232
|
}
|
|
3246
|
-
}, [
|
|
3233
|
+
}, [limit, page, isPlaceholderData, key, queryClient2, hasMore, off, isFetching]);
|
|
3247
3234
|
}
|
|
3248
3235
|
function useTable({
|
|
3249
3236
|
cube,
|
|
@@ -3283,8 +3270,8 @@ function useTable({
|
|
|
3283
3270
|
actions2.updateFilter(filter);
|
|
3284
3271
|
return filter;
|
|
3285
3272
|
}
|
|
3286
|
-
|
|
3287
|
-
|
|
3273
|
+
useLayoutEffect(() => {
|
|
3274
|
+
filterMap(measuresOlap, (m) => {
|
|
3288
3275
|
const measure = measuresMap[m.name] || handlerCreateMeasure({ ...m, active: false });
|
|
3289
3276
|
const foundFilter = filtersMap[m.name] || filterItems.find((f) => f.measure === measure.name);
|
|
3290
3277
|
const filter = foundFilter || handlerCreateFilter({
|
|
@@ -3296,8 +3283,6 @@ function useTable({
|
|
|
3296
3283
|
});
|
|
3297
3284
|
}, [measuresMap, measuresOlap, filtersMap, filterItems]);
|
|
3298
3285
|
const { isLoading, isFetching, isError, data, isPlaceholderData } = useTableData({
|
|
3299
|
-
offset,
|
|
3300
|
-
limit,
|
|
3301
3286
|
columns: finalUniqueKeys,
|
|
3302
3287
|
filters: filterItems.filter(isActiveItem),
|
|
3303
3288
|
cuts: itemsCuts.filter(isActiveCut),
|
|
@@ -3316,14 +3301,15 @@ function useTable({
|
|
|
3316
3301
|
columns: finalUniqueKeys,
|
|
3317
3302
|
filters: filterItems.filter(isActiveItem),
|
|
3318
3303
|
cuts: itemsCuts.filter(isActiveCut),
|
|
3319
|
-
pagination
|
|
3304
|
+
pagination,
|
|
3305
|
+
isFetching: isFetching || isLoading
|
|
3320
3306
|
});
|
|
3321
3307
|
useEffect(() => {
|
|
3322
3308
|
actions2.updatePagination({
|
|
3323
3309
|
limit: pagination.pageSize,
|
|
3324
3310
|
offset: pagination.pageIndex * pagination.pageSize
|
|
3325
3311
|
});
|
|
3326
|
-
}, [pagination]);
|
|
3312
|
+
}, [pagination, actions2]);
|
|
3327
3313
|
const { translate: t } = useTranslation();
|
|
3328
3314
|
const { currentFormats, getAvailableKeys, getFormatter, getFormatterKey, setFormat } = useFormatter(
|
|
3329
3315
|
cube.measures
|
|
@@ -3332,7 +3318,7 @@ function useTable({
|
|
|
3332
3318
|
const indexColumn = {
|
|
3333
3319
|
id: "#",
|
|
3334
3320
|
Header: "#",
|
|
3335
|
-
Cell: ({ row }) => row.index + 1,
|
|
3321
|
+
Cell: ({ row }) => row.index + 1 + offset,
|
|
3336
3322
|
minWidth: 50,
|
|
3337
3323
|
maxWidth: 50,
|
|
3338
3324
|
width: 50,
|
|
@@ -3986,6 +3972,11 @@ var Graph = class {
|
|
|
3986
3972
|
});
|
|
3987
3973
|
return topic;
|
|
3988
3974
|
}
|
|
3975
|
+
getName(node, locale) {
|
|
3976
|
+
const item = this.items.find((item2) => item2.name === node);
|
|
3977
|
+
const name4 = getAnnotation(item, "table", locale);
|
|
3978
|
+
return name4;
|
|
3979
|
+
}
|
|
3989
3980
|
getSubtopic(startingNode, locale) {
|
|
3990
3981
|
let found = false;
|
|
3991
3982
|
let subtopic = null;
|
|
@@ -4015,15 +4006,16 @@ var Graph = class {
|
|
|
4015
4006
|
"name",
|
|
4016
4007
|
(item) => getAnnotation(item, "topic", locale) || "",
|
|
4017
4008
|
(item) => getAnnotation(item, "subtopic", locale) || "",
|
|
4018
|
-
(item) => getAnnotation(item, "table", locale) || ""
|
|
4009
|
+
(item) => getAnnotation(item, "table", locale) || "",
|
|
4010
|
+
(item) => item.name.replace(/_/g, " ")
|
|
4019
4011
|
]
|
|
4020
4012
|
});
|
|
4021
4013
|
for (const item of results) {
|
|
4022
4014
|
const topic = getAnnotation(item, "topic", locale);
|
|
4023
4015
|
const subtopic = getAnnotation(item, "subtopic", locale);
|
|
4024
|
-
|
|
4025
|
-
addItemToSubtopic(map, `${topic} - ${subtopic}`,
|
|
4026
|
-
matches.push(
|
|
4016
|
+
getAnnotation(item, "table", locale);
|
|
4017
|
+
addItemToSubtopic(map, `${topic} - ${subtopic}`, item.name);
|
|
4018
|
+
matches.push(item.name);
|
|
4027
4019
|
}
|
|
4028
4020
|
}
|
|
4029
4021
|
return { matches, map };
|
|
@@ -4164,6 +4156,7 @@ function LocaleSelector() {
|
|
|
4164
4156
|
if (currentCode !== l.value) {
|
|
4165
4157
|
resetGraph();
|
|
4166
4158
|
actions2.updateLocale(l.value);
|
|
4159
|
+
actions2.willRequestQuery();
|
|
4167
4160
|
}
|
|
4168
4161
|
};
|
|
4169
4162
|
if (localeOptions.length < 2) {
|
|
@@ -4389,12 +4382,7 @@ init_esm_shims();
|
|
|
4389
4382
|
init_esm_shims();
|
|
4390
4383
|
function useSelectCube(onSelectCube) {
|
|
4391
4384
|
const { updateMeasure, updateCut, updateDrilldown, willFetchMembers: willFetchMembers2 } = useActions();
|
|
4392
|
-
|
|
4393
|
-
const cutItem = buildCut({ ...level });
|
|
4394
|
-
cutItem.active = false;
|
|
4395
|
-
updateCut(cutItem);
|
|
4396
|
-
}, []);
|
|
4397
|
-
const addDrilldown = useCallback((level, dimensions) => {
|
|
4385
|
+
useCallback((level, dimensions) => {
|
|
4398
4386
|
const drilldownItem = buildDrilldown(level);
|
|
4399
4387
|
createCutHandler2(level);
|
|
4400
4388
|
updateDrilldown(drilldownItem);
|
|
@@ -4409,13 +4397,34 @@ function useSelectCube(onSelectCube) {
|
|
|
4409
4397
|
});
|
|
4410
4398
|
});
|
|
4411
4399
|
}, []);
|
|
4400
|
+
const createCutHandler2 = React10__default.useCallback((level) => {
|
|
4401
|
+
const cutItem = buildCut({ ...level });
|
|
4402
|
+
cutItem.active = false;
|
|
4403
|
+
updateCut(cutItem);
|
|
4404
|
+
}, []);
|
|
4405
|
+
function createDrilldown(level, dimensions) {
|
|
4406
|
+
const drilldown = buildDrilldown({ ...level, key: stringifyName(level), active: true });
|
|
4407
|
+
updateDrilldown(drilldown);
|
|
4408
|
+
createCutHandler2({ ...level, key: stringifyName(level) });
|
|
4409
|
+
willFetchMembers2({ ...level, level: level.name }).then((members) => {
|
|
4410
|
+
const dimension = dimensions.find((dim) => dim.name === level.dimension);
|
|
4411
|
+
if (!dimension) return;
|
|
4412
|
+
updateDrilldown({
|
|
4413
|
+
...drilldown,
|
|
4414
|
+
dimType: dimension.dimensionType,
|
|
4415
|
+
memberCount: members.length,
|
|
4416
|
+
members
|
|
4417
|
+
});
|
|
4418
|
+
});
|
|
4419
|
+
return drilldown;
|
|
4420
|
+
}
|
|
4412
4421
|
return (item, subtopic) => () => onSelectCube(item, subtopic).then(({ cube, measures, dimensions }) => {
|
|
4413
4422
|
const [measure] = Object.values(measures);
|
|
4414
4423
|
const drilldowns = deriveDrilldowns(dimensions);
|
|
4415
4424
|
if (measure && drilldowns.length > 0) {
|
|
4416
4425
|
updateMeasure({ ...measure, active: true });
|
|
4417
4426
|
for (const level of drilldowns) {
|
|
4418
|
-
|
|
4427
|
+
createDrilldown(level, dimensions);
|
|
4419
4428
|
}
|
|
4420
4429
|
}
|
|
4421
4430
|
});
|
|
@@ -4433,6 +4442,7 @@ function Results(props) {
|
|
|
4433
4442
|
const [topic, subtopic] = key.split(" - ");
|
|
4434
4443
|
const component = /* @__PURE__ */ React10__default.createElement("div", { key }, /* @__PURE__ */ React10__default.createElement(Divider, { my: "xs", label: key }), items.map((item) => {
|
|
4435
4444
|
const cube = getCube2(graph.items, item, subtopic, locale);
|
|
4445
|
+
const table = getAnnotation(cube, "table", locale);
|
|
4436
4446
|
return /* @__PURE__ */ React10__default.createElement(
|
|
4437
4447
|
Text,
|
|
4438
4448
|
{
|
|
@@ -4446,7 +4456,7 @@ function Results(props) {
|
|
|
4446
4456
|
setInput("");
|
|
4447
4457
|
}
|
|
4448
4458
|
},
|
|
4449
|
-
|
|
4459
|
+
table
|
|
4450
4460
|
);
|
|
4451
4461
|
}));
|
|
4452
4462
|
result.push(component);
|
|
@@ -4491,32 +4501,38 @@ function SelectCubeInternal(props) {
|
|
|
4491
4501
|
useTranslation();
|
|
4492
4502
|
const { code: locale } = useSelector$1(selectLocale);
|
|
4493
4503
|
const { updateMeasure, updateDrilldown, willFetchMembers: willFetchMembers2, updateCut } = useActions();
|
|
4504
|
+
const cutItems = useSelector$1(selectCutItems);
|
|
4494
4505
|
const cube = useSelector$1(selectCubeName);
|
|
4495
4506
|
const itemMap = useSelector$1(selectMeasureMap);
|
|
4496
4507
|
const dimensions = useSelector$1(selectOlapDimensionItems);
|
|
4508
|
+
const drilldowns = useSelector$1(selectDrilldownMap);
|
|
4509
|
+
const ditems = useSelector$1(selectDrilldownItems);
|
|
4497
4510
|
const createCutHandler2 = React10__default.useCallback((level) => {
|
|
4498
4511
|
const cutItem = buildCut({ ...level });
|
|
4499
4512
|
cutItem.active = false;
|
|
4500
4513
|
updateCut(cutItem);
|
|
4501
4514
|
}, []);
|
|
4502
|
-
|
|
4503
|
-
(level) => {
|
|
4504
|
-
const
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4515
|
+
function createDrilldown(level, cuts) {
|
|
4516
|
+
if (!drilldowns[stringifyName(level)] && !ditems.find((d) => d.uniqueName === buildDrilldown(level).uniqueName)) {
|
|
4517
|
+
const drilldown = buildDrilldown({ ...level, key: stringifyName(level), active: true });
|
|
4518
|
+
updateDrilldown(drilldown);
|
|
4519
|
+
const cut = cuts.find((cut2) => cut2.uniqueName === drilldown.uniqueName);
|
|
4520
|
+
if (!cut) {
|
|
4521
|
+
createCutHandler2({ ...level, key: stringifyName(level) });
|
|
4522
|
+
}
|
|
4523
|
+
willFetchMembers2({ ...level, level: level.name }).then((members) => {
|
|
4508
4524
|
const dimension = dimensions.find((dim) => dim.name === level.dimension);
|
|
4509
4525
|
if (!dimension) return;
|
|
4510
|
-
|
|
4511
|
-
...
|
|
4526
|
+
updateDrilldown({
|
|
4527
|
+
...drilldown,
|
|
4512
4528
|
dimType: dimension.dimensionType,
|
|
4513
4529
|
memberCount: members.length,
|
|
4514
4530
|
members
|
|
4515
4531
|
});
|
|
4516
4532
|
});
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4533
|
+
return drilldown;
|
|
4534
|
+
}
|
|
4535
|
+
}
|
|
4520
4536
|
useEffect(() => {
|
|
4521
4537
|
const params = new URLSearchParams(location.search);
|
|
4522
4538
|
const cubeParam = params.get("cube");
|
|
@@ -4525,11 +4541,11 @@ function SelectCubeInternal(props) {
|
|
|
4525
4541
|
const [dimension] = dimensions;
|
|
4526
4542
|
if (measure && dimension) {
|
|
4527
4543
|
updateMeasure({ ...measure, active: true });
|
|
4528
|
-
const
|
|
4529
|
-
if (measure &&
|
|
4544
|
+
const drilldowns2 = deriveDrilldowns(dimensions);
|
|
4545
|
+
if (measure && drilldowns2.length > 0) {
|
|
4530
4546
|
updateMeasure({ ...measure, active: true });
|
|
4531
|
-
for (const level of
|
|
4532
|
-
|
|
4547
|
+
for (const level of drilldowns2) {
|
|
4548
|
+
createDrilldown(level, cutItems);
|
|
4533
4549
|
}
|
|
4534
4550
|
}
|
|
4535
4551
|
}
|
|
@@ -4559,7 +4575,7 @@ function isSelected(selectedItem, currentItem) {
|
|
|
4559
4575
|
}
|
|
4560
4576
|
function getCube(items, table, subtopic, locale) {
|
|
4561
4577
|
const cube = items.find(
|
|
4562
|
-
(item) =>
|
|
4578
|
+
(item) => item.name === table && getAnnotation(item, "subtopic", locale) === subtopic
|
|
4563
4579
|
);
|
|
4564
4580
|
return cube;
|
|
4565
4581
|
}
|
|
@@ -4567,16 +4583,17 @@ function useBuildGraph(items, locale, graph, setGraph) {
|
|
|
4567
4583
|
useEffect(() => {
|
|
4568
4584
|
const graph2 = new graph_default();
|
|
4569
4585
|
items.map((item) => {
|
|
4586
|
+
const { name: name4 } = item;
|
|
4570
4587
|
const topic = getAnnotation(item, "topic", locale);
|
|
4571
4588
|
const subtopic = getAnnotation(item, "subtopic", locale);
|
|
4572
|
-
|
|
4589
|
+
getAnnotation(item, "table", locale);
|
|
4573
4590
|
const hide = getAnnotation(item, "hide_in_ui", locale);
|
|
4574
4591
|
if (!yn(hide)) {
|
|
4575
4592
|
graph2.addNode(topic);
|
|
4576
4593
|
graph2.addNode(subtopic);
|
|
4577
|
-
graph2.addNode(
|
|
4594
|
+
graph2.addNode(name4);
|
|
4578
4595
|
graph2.addEdge(topic, subtopic);
|
|
4579
|
-
graph2.addEdge(subtopic,
|
|
4596
|
+
graph2.addEdge(subtopic, name4);
|
|
4580
4597
|
}
|
|
4581
4598
|
return item;
|
|
4582
4599
|
});
|
|
@@ -4596,9 +4613,12 @@ function CubeTree({
|
|
|
4596
4613
|
const actions2 = useActions();
|
|
4597
4614
|
const onSelectCube = (table, subtopic) => {
|
|
4598
4615
|
const cube = items.find(
|
|
4599
|
-
(item) =>
|
|
4616
|
+
(item) => item.name === table && getAnnotation(item, "subtopic", locale) === subtopic
|
|
4600
4617
|
);
|
|
4601
4618
|
if (cube) {
|
|
4619
|
+
actions2.resetDrilldowns({});
|
|
4620
|
+
actions2.resetCuts({});
|
|
4621
|
+
actions2.resetMeasures({});
|
|
4602
4622
|
return actions2.willSetCube(cube.name);
|
|
4603
4623
|
}
|
|
4604
4624
|
};
|
|
@@ -4696,7 +4716,7 @@ function CubeButton({
|
|
|
4696
4716
|
}) {
|
|
4697
4717
|
const callback = useSelectCube(onSelectCube);
|
|
4698
4718
|
const { classes } = useStyles3();
|
|
4699
|
-
const table = item;
|
|
4719
|
+
const table = graph.getName(item, locale);
|
|
4700
4720
|
const subtopic = parent != null ? parent : "";
|
|
4701
4721
|
return /* @__PURE__ */ React10__default.createElement(
|
|
4702
4722
|
Text,
|
|
@@ -4707,14 +4727,14 @@ function CubeButton({
|
|
|
4707
4727
|
maw: "100%",
|
|
4708
4728
|
pr: "md",
|
|
4709
4729
|
component: "a",
|
|
4710
|
-
className: isSelected(selectedItem, getCube(graph.items,
|
|
4730
|
+
className: isSelected(selectedItem, getCube(graph.items, item, subtopic, locale)) ? `${classes.link} ${classes.linkActive}` : classes.link,
|
|
4711
4731
|
sx: (t) => ({
|
|
4712
|
-
background: isSelected(selectedItem, getCube(graph.items,
|
|
4732
|
+
background: isSelected(selectedItem, getCube(graph.items, item, subtopic, locale)) ? t.fn.primaryColor() : t.colorScheme === "dark" ? t.colors.dark[6] : t.colors.gray[3],
|
|
4713
4733
|
overflow: "hidden"
|
|
4714
4734
|
}),
|
|
4715
4735
|
onClick: callback(item, subtopic)
|
|
4716
4736
|
},
|
|
4717
|
-
|
|
4737
|
+
table
|
|
4718
4738
|
);
|
|
4719
4739
|
}
|
|
4720
4740
|
function SubtopicAccordion({
|
|
@@ -6607,11 +6627,9 @@ function createVizbuilderView(settings) {
|
|
|
6607
6627
|
return VizbuilderView;
|
|
6608
6628
|
function VizbuilderView(props) {
|
|
6609
6629
|
const { cube, panelKey, params, result } = props;
|
|
6630
|
+
console.log(result);
|
|
6610
6631
|
const { actions: actions2, formatters } = useSettings();
|
|
6611
|
-
const [panelName, currentChart] = useMemo(
|
|
6612
|
-
() => `${panelKey || ""}-`.split("-"),
|
|
6613
|
-
[panelKey]
|
|
6614
|
-
);
|
|
6632
|
+
const [panelName, currentChart] = useMemo(() => `${panelKey || ""}-`.split("-"), [panelKey]);
|
|
6615
6633
|
const resetCurrentPanel = useCallback(() => {
|
|
6616
6634
|
actions2.switchPanel(panelName);
|
|
6617
6635
|
}, [panelName]);
|
|
@@ -6620,7 +6638,7 @@ function createVizbuilderView(settings) {
|
|
|
6620
6638
|
[
|
|
6621
6639
|
{
|
|
6622
6640
|
cube,
|
|
6623
|
-
dataset: result.data,
|
|
6641
|
+
dataset: result.data.data,
|
|
6624
6642
|
params: {
|
|
6625
6643
|
locale: params.locale || defaultLocale,
|
|
6626
6644
|
booleans: params.booleans,
|
|
@@ -6653,7 +6671,7 @@ function createVizbuilderView(settings) {
|
|
|
6653
6671
|
],
|
|
6654
6672
|
chartGenOptions
|
|
6655
6673
|
),
|
|
6656
|
-
[cube, result.data, params]
|
|
6674
|
+
[cube, result.data.data, params]
|
|
6657
6675
|
);
|
|
6658
6676
|
const content = useMemo(() => {
|
|
6659
6677
|
const isSingleChart = charts.length === 1;
|