@gingkoo/pandora-metabase 1.0.0 → 1.0.1
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/README.md +2 -0
- package/lib/es/components/dialog/select-summarize/index.d.ts +2 -1
- package/lib/es/index.js +71 -50
- package/lib/es/index.js.map +1 -1
- package/lib/es/types.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,6 +62,8 @@ export interface MetaBaseProps {
|
|
|
62
62
|
subShowSubquery?: boolean; //子查询是否展示子查询
|
|
63
63
|
constantList?: OptionItem[]; //常量下拉框
|
|
64
64
|
notExistsToolbar?: ToolbarType[]; // notExists的功能菜单 默认取toolbar
|
|
65
|
+
ignoreGroupByType?: boolean; // 忽略groupBy类型
|
|
66
|
+
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
export interface OptionItem {
|
|
@@ -12,6 +12,7 @@ interface PropsType {
|
|
|
12
12
|
value: ValueType;
|
|
13
13
|
onChange: (reocrd: ValueType) => void;
|
|
14
14
|
didUpdate?: Function;
|
|
15
|
+
ignoreGroupByType?: boolean;
|
|
15
16
|
}
|
|
16
|
-
declare const SelectSummarize: ({ data, value, onChange, didUpdate }: PropsType) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
declare const SelectSummarize: ({ data, value, onChange, didUpdate, ignoreGroupByType }: PropsType) => import("react/jsx-runtime").JSX.Element;
|
|
17
18
|
export default SelectSummarize;
|
package/lib/es/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @gingkoo/pandora-metabase v1.0.
|
|
2
|
+
* @gingkoo/pandora-metabase v1.0.1
|
|
3
3
|
*/
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import React__default, { useContext, createContext, useState, useRef, useMemo, useEffect, forwardRef, useImperativeHandle } from 'react';
|
|
7
7
|
import cloneDeep from 'lodash/cloneDeep';
|
|
8
8
|
import cx from 'classnames';
|
|
9
|
-
import { Tooltip, Button, Modal, Input, DatePicker, Dropdown, InputNumber, Select,
|
|
9
|
+
import { Tooltip, Button, Modal, Input, DatePicker, Dropdown, InputNumber, Select, Toast, Modal2 } from '@gingkoo/pandora';
|
|
10
10
|
import Styled from 'styled-components';
|
|
11
11
|
import { ChevronODown, Repeat, Function, RelatedWork, FfPlus, FfLine } from '@gingkoo/pandora-icons';
|
|
12
12
|
import isEqual from 'lodash/isEqual';
|
|
@@ -1224,6 +1224,7 @@ const useStore = () => {
|
|
|
1224
1224
|
const [tableNameTpl, setTableNameTpl] = useState('${name}'); //显示字段
|
|
1225
1225
|
const [sourceList, setSourceList] = useState([]); //数据源列表
|
|
1226
1226
|
const [constantList, setConstantList] = useState([]); //常量列表
|
|
1227
|
+
const [ignoreGroupByType, setIgnoreGroupByType] = useState(false); // 忽略groupBy类型
|
|
1227
1228
|
const [_cacheSource2TableMap, set_cacheSource2TableMap] = useState({}); //数据源id 对应数据集列表
|
|
1228
1229
|
const [_cacheColumnsMap, set_cacheColumnsMap] = useState({}); //数据源id 对应数据集列表
|
|
1229
1230
|
const [metaList, _setMeta] = useState(defaultMeta); //数据源id 对应数据集列表
|
|
@@ -1653,7 +1654,9 @@ const useStore = () => {
|
|
|
1653
1654
|
_setShowSubquery,
|
|
1654
1655
|
constantList,
|
|
1655
1656
|
setConstantList,
|
|
1656
|
-
popupContainer
|
|
1657
|
+
popupContainer,
|
|
1658
|
+
ignoreGroupByType,
|
|
1659
|
+
setIgnoreGroupByType
|
|
1657
1660
|
};
|
|
1658
1661
|
};
|
|
1659
1662
|
|
|
@@ -1704,6 +1707,7 @@ register('en', {
|
|
|
1704
1707
|
'SqlQueryBuilder.visualize': 'visualize',
|
|
1705
1708
|
'SqlQueryBuilder.selectColumnAll': 'select all',
|
|
1706
1709
|
'SqlQueryBuilder.alias': 'alias',
|
|
1710
|
+
'SqlQueryBuilder.aliasCannotEmpty': 'Alias cannot be empty',
|
|
1707
1711
|
'customColumn.operator': 'operator',
|
|
1708
1712
|
'customColumn.field': 'field',
|
|
1709
1713
|
'customColumn.constant': 'constant',
|
|
@@ -1848,6 +1852,7 @@ register('zh', {
|
|
|
1848
1852
|
'SqlQueryBuilder.visualize': '可视化',
|
|
1849
1853
|
'SqlQueryBuilder.selectColumnAll': '全选',
|
|
1850
1854
|
'SqlQueryBuilder.alias': '别名',
|
|
1855
|
+
'SqlQueryBuilder.aliasCannotEmpty': '别名不能为空',
|
|
1851
1856
|
'customColumn.operator': '运算符',
|
|
1852
1857
|
'customColumn.field': '字段',
|
|
1853
1858
|
'customColumn.constant': '常量',
|
|
@@ -2167,13 +2172,13 @@ const LeftJoinIcon = ({
|
|
|
2167
2172
|
})
|
|
2168
2173
|
});
|
|
2169
2174
|
const InnerJoinIcon = ({
|
|
2170
|
-
width:
|
|
2171
|
-
height:
|
|
2175
|
+
width: _width0 = 32,
|
|
2176
|
+
height: _height0 = 32,
|
|
2172
2177
|
style
|
|
2173
2178
|
}) => jsx("svg", {
|
|
2174
2179
|
viewBox: '0 0 32 32',
|
|
2175
|
-
width:
|
|
2176
|
-
height:
|
|
2180
|
+
width: _width0,
|
|
2181
|
+
height: _height0,
|
|
2177
2182
|
fill: 'currentcolor',
|
|
2178
2183
|
role: 'img',
|
|
2179
2184
|
"aria-label": 'join_inner icon',
|
|
@@ -2183,13 +2188,13 @@ const InnerJoinIcon = ({
|
|
|
2183
2188
|
})
|
|
2184
2189
|
});
|
|
2185
2190
|
const UpArrowIcon = ({
|
|
2186
|
-
width:
|
|
2187
|
-
height:
|
|
2191
|
+
width: _width1 = 16,
|
|
2192
|
+
height: _height1 = 17
|
|
2188
2193
|
}) => jsx("svg", {
|
|
2189
2194
|
className: 'sort-arrow',
|
|
2190
2195
|
viewBox: '0 0 32 34',
|
|
2191
|
-
width:
|
|
2192
|
-
height:
|
|
2196
|
+
width: _width1,
|
|
2197
|
+
height: _height1,
|
|
2193
2198
|
fill: 'currentcolor',
|
|
2194
2199
|
role: 'img',
|
|
2195
2200
|
"aria-label": 'arrow_up icon',
|
|
@@ -2198,13 +2203,13 @@ const UpArrowIcon = ({
|
|
|
2198
2203
|
})
|
|
2199
2204
|
});
|
|
2200
2205
|
const DownArrowIcon = ({
|
|
2201
|
-
width:
|
|
2202
|
-
height:
|
|
2206
|
+
width: _width10 = 16,
|
|
2207
|
+
height: _height10 = 17
|
|
2203
2208
|
}) => jsx("svg", {
|
|
2204
2209
|
className: 'sort-arrow',
|
|
2205
2210
|
viewBox: '0 0 32 34',
|
|
2206
|
-
width:
|
|
2207
|
-
height:
|
|
2211
|
+
width: _width10,
|
|
2212
|
+
height: _height10,
|
|
2208
2213
|
fill: 'currentcolor',
|
|
2209
2214
|
role: 'img',
|
|
2210
2215
|
"aria-label": 'arrow_down icon',
|
|
@@ -2213,13 +2218,13 @@ const DownArrowIcon = ({
|
|
|
2213
2218
|
})
|
|
2214
2219
|
});
|
|
2215
2220
|
const CloseIcon = ({
|
|
2216
|
-
width:
|
|
2217
|
-
height:
|
|
2221
|
+
width: _width11 = 16,
|
|
2222
|
+
height: _height11 = 16
|
|
2218
2223
|
}) => jsx("svg", {
|
|
2219
2224
|
className: 'closeIcon',
|
|
2220
2225
|
viewBox: '0 0 32 32',
|
|
2221
|
-
width:
|
|
2222
|
-
height:
|
|
2226
|
+
width: _width11,
|
|
2227
|
+
height: _height11,
|
|
2223
2228
|
fill: 'currentcolor',
|
|
2224
2229
|
role: 'img',
|
|
2225
2230
|
"aria-label": 'close icon',
|
|
@@ -2228,12 +2233,12 @@ const CloseIcon = ({
|
|
|
2228
2233
|
})
|
|
2229
2234
|
});
|
|
2230
2235
|
const AddIcon = ({
|
|
2231
|
-
width:
|
|
2232
|
-
height:
|
|
2236
|
+
width: _width12 = 16,
|
|
2237
|
+
height: _height12 = 16
|
|
2233
2238
|
}) => jsx("svg", {
|
|
2234
2239
|
viewBox: '0 0 32 32',
|
|
2235
|
-
width:
|
|
2236
|
-
height:
|
|
2240
|
+
width: _width12,
|
|
2241
|
+
height: _height12,
|
|
2237
2242
|
fill: 'currentcolor',
|
|
2238
2243
|
role: 'img',
|
|
2239
2244
|
"aria-label": 'add icon',
|
|
@@ -2242,12 +2247,12 @@ const AddIcon = ({
|
|
|
2242
2247
|
})
|
|
2243
2248
|
});
|
|
2244
2249
|
const TableIcon = ({
|
|
2245
|
-
width:
|
|
2246
|
-
height:
|
|
2250
|
+
width: _width13 = 18,
|
|
2251
|
+
height: _height13 = 18
|
|
2247
2252
|
}) => jsx("svg", {
|
|
2248
2253
|
viewBox: '0 0 32 32',
|
|
2249
|
-
width:
|
|
2250
|
-
height:
|
|
2254
|
+
width: _width13,
|
|
2255
|
+
height: _height13,
|
|
2251
2256
|
fill: 'currentcolor',
|
|
2252
2257
|
role: 'img',
|
|
2253
2258
|
"aria-label": 'table2 icon',
|
|
@@ -2256,12 +2261,12 @@ const TableIcon = ({
|
|
|
2256
2261
|
})
|
|
2257
2262
|
});
|
|
2258
2263
|
const SearchIcon = ({
|
|
2259
|
-
width:
|
|
2260
|
-
height:
|
|
2264
|
+
width: _width14 = 16,
|
|
2265
|
+
height: _height14 = 16
|
|
2261
2266
|
}) => jsx("svg", {
|
|
2262
2267
|
viewBox: '0 0 32 32',
|
|
2263
|
-
width:
|
|
2264
|
-
height:
|
|
2268
|
+
width: _width14,
|
|
2269
|
+
height: _height14,
|
|
2265
2270
|
fill: 'currentcolor',
|
|
2266
2271
|
role: 'img',
|
|
2267
2272
|
"aria-label": 'search icon',
|
|
@@ -4549,7 +4554,7 @@ const SelectFilterColumn = ({
|
|
|
4549
4554
|
},
|
|
4550
4555
|
format: 'YYYY-MM-DD HH:mm',
|
|
4551
4556
|
className: 'w_300',
|
|
4552
|
-
value: moment(firstVal
|
|
4557
|
+
value: firstVal ? moment(firstVal) : '',
|
|
4553
4558
|
onChange: val => {
|
|
4554
4559
|
if (val) {
|
|
4555
4560
|
setVal([moment(val).format('YYYY-MM-DD HH:mm')]);
|
|
@@ -4950,7 +4955,8 @@ const SelectSummarize = ({
|
|
|
4950
4955
|
data,
|
|
4951
4956
|
value,
|
|
4952
4957
|
onChange,
|
|
4953
|
-
didUpdate
|
|
4958
|
+
didUpdate,
|
|
4959
|
+
ignoreGroupByType
|
|
4954
4960
|
}) => {
|
|
4955
4961
|
const [condition, setCondition] = useState(value.condition);
|
|
4956
4962
|
function goPrevPage() {
|
|
@@ -4966,7 +4972,7 @@ const SelectSummarize = ({
|
|
|
4966
4972
|
}
|
|
4967
4973
|
if (condition && !~Special.indexOf(condition)) {
|
|
4968
4974
|
let availableData = data.slice();
|
|
4969
|
-
if (condition !== '不重复值的总数') {
|
|
4975
|
+
if (condition !== '不重复值的总数' && !ignoreGroupByType) {
|
|
4970
4976
|
// 只能用数字类型做聚合
|
|
4971
4977
|
availableData = data.map(v => {
|
|
4972
4978
|
return {
|
|
@@ -5710,12 +5716,17 @@ const TableData = props => {
|
|
|
5710
5716
|
alias = val;
|
|
5711
5717
|
}
|
|
5712
5718
|
}),
|
|
5713
|
-
onOk: () => {
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
+
onOk: async () => {
|
|
5720
|
+
if (!alias) {
|
|
5721
|
+
Toast.warning(__('SqlQueryBuilder.aliasCannotEmpty'));
|
|
5722
|
+
return false;
|
|
5723
|
+
} else {
|
|
5724
|
+
let newMetaList = store.metaList[groupIndex].list.slice();
|
|
5725
|
+
// @ts-ignore
|
|
5726
|
+
newMetaList[0].table.alias = alias;
|
|
5727
|
+
newMetaList = changeTableAlias(newMetaList, newMetaList[0].table);
|
|
5728
|
+
store.setMeta(newMetaList, groupIndex);
|
|
5729
|
+
}
|
|
5719
5730
|
},
|
|
5720
5731
|
onCancel: () => {}
|
|
5721
5732
|
});
|
|
@@ -5751,7 +5762,7 @@ const TableData = props => {
|
|
|
5751
5762
|
newMetaList.subquery = newList;
|
|
5752
5763
|
newMetaList.table = {
|
|
5753
5764
|
...newList[0].table,
|
|
5754
|
-
alias: newMetaList.table.alias || '',
|
|
5765
|
+
alias: newMetaList.table.alias || newList[0].table.name + '_' + groupIndex + '_' + 0,
|
|
5755
5766
|
tableUuid: uuidv4('table')
|
|
5756
5767
|
};
|
|
5757
5768
|
const items = getSubColumns(newList);
|
|
@@ -6419,7 +6430,8 @@ const JoinData = props => {
|
|
|
6419
6430
|
}
|
|
6420
6431
|
newMeta[index].subquery = newList;
|
|
6421
6432
|
newMeta[index].table2 = {
|
|
6422
|
-
...newList[0].table
|
|
6433
|
+
...newList[0].table,
|
|
6434
|
+
alias: newMeta[index].table2.alias || newList[0].table.name + '_' + groupIndex + '_' + index
|
|
6423
6435
|
};
|
|
6424
6436
|
const items = getSubColumns(newList);
|
|
6425
6437
|
const newColumns = items.flatMap(item => item.columns);
|
|
@@ -6477,12 +6489,17 @@ const JoinData = props => {
|
|
|
6477
6489
|
alias = val;
|
|
6478
6490
|
}
|
|
6479
6491
|
}),
|
|
6480
|
-
onOk: () => {
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
6492
|
+
onOk: async () => {
|
|
6493
|
+
if (!alias) {
|
|
6494
|
+
Toast.warning(__('SqlQueryBuilder.aliasCannotEmpty'));
|
|
6495
|
+
return false;
|
|
6496
|
+
} else {
|
|
6497
|
+
let index = findIndex(store.metaList[groupIndex].list, meta);
|
|
6498
|
+
let newMeta = store.metaList[groupIndex].list.slice();
|
|
6499
|
+
newMeta[index].table2.alias = alias;
|
|
6500
|
+
newMeta = changeTableAlias(newMeta, newMeta[index].table2);
|
|
6501
|
+
store.setMeta(newMeta, groupIndex);
|
|
6502
|
+
}
|
|
6486
6503
|
},
|
|
6487
6504
|
onCancel: () => {}
|
|
6488
6505
|
});
|
|
@@ -8419,6 +8436,7 @@ const SelectIndex = props => {
|
|
|
8419
8436
|
content: jsx(SelectSummarize, {
|
|
8420
8437
|
data: data,
|
|
8421
8438
|
value: value,
|
|
8439
|
+
ignoreGroupByType: store.ignoreGroupByType,
|
|
8422
8440
|
onChange: data => {
|
|
8423
8441
|
//@ts-ignore
|
|
8424
8442
|
newMeta[index].group.splice(i, 1, data);
|
|
@@ -8472,6 +8490,7 @@ const SelectIndex = props => {
|
|
|
8472
8490
|
content: jsx(SelectSummarize, {
|
|
8473
8491
|
data: data,
|
|
8474
8492
|
value: value,
|
|
8493
|
+
ignoreGroupByType: store.ignoreGroupByType,
|
|
8475
8494
|
onChange: data => {
|
|
8476
8495
|
// @ts-ignore
|
|
8477
8496
|
newMeta[index].group.push(data);
|
|
@@ -9154,7 +9173,8 @@ const SqlVisionBuilder = /*#__PURE__*/React__default.forwardRef((props, ref) =>
|
|
|
9154
9173
|
showSubquery = true,
|
|
9155
9174
|
// 是否展示子查询
|
|
9156
9175
|
subShowSubquery = false,
|
|
9157
|
-
constantList
|
|
9176
|
+
constantList,
|
|
9177
|
+
ignoreGroupByType = false
|
|
9158
9178
|
} = props;
|
|
9159
9179
|
const store = useStore();
|
|
9160
9180
|
useEffect(() => {
|
|
@@ -9179,7 +9199,8 @@ const SqlVisionBuilder = /*#__PURE__*/React__default.forwardRef((props, ref) =>
|
|
|
9179
9199
|
store.setShowSubquery(showSubquery);
|
|
9180
9200
|
store._setShowSubquery(subShowSubquery);
|
|
9181
9201
|
store.setConstantList(constantList || []);
|
|
9182
|
-
|
|
9202
|
+
store.setIgnoreGroupByType(ignoreGroupByType);
|
|
9203
|
+
}, [showFields, fieldNameTpl, tableNameTpl, toolbar, showSubquery, subShowSubquery, constantList, ignoreGroupByType]);
|
|
9183
9204
|
React__default.useImperativeHandle(ref, () => ({
|
|
9184
9205
|
// setDatasource: (list) => {
|
|
9185
9206
|
// store.setSourceList(list);
|