@gingkoo/pandora-metabase 1.0.0-alpha.30 → 1.0.0-alpha.31
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 +43 -22
- package/lib/es/index.js.map +1 -1
- package/lib/es/types.d.ts +1 -0
- package/lib/es/utils.d.ts +22 -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.0-alpha.
|
|
2
|
+
* @gingkoo/pandora-metabase v1.0.0-alpha.31
|
|
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': '常量',
|
|
@@ -4570,7 +4575,7 @@ const SelectFilterColumn = ({
|
|
|
4570
4575
|
},
|
|
4571
4576
|
format: 'YYYY-MM-DD HH:mm',
|
|
4572
4577
|
className: 'w_300',
|
|
4573
|
-
value: moment(firstVal
|
|
4578
|
+
value: firstVal ? moment(firstVal) : '',
|
|
4574
4579
|
onChange: val => {
|
|
4575
4580
|
if (val) {
|
|
4576
4581
|
setVal([moment(val).format('YYYY-MM-DD HH:mm')]);
|
|
@@ -4971,7 +4976,8 @@ const SelectSummarize = ({
|
|
|
4971
4976
|
data,
|
|
4972
4977
|
value,
|
|
4973
4978
|
onChange,
|
|
4974
|
-
didUpdate
|
|
4979
|
+
didUpdate,
|
|
4980
|
+
ignoreGroupByType
|
|
4975
4981
|
}) => {
|
|
4976
4982
|
const [condition, setCondition] = useState(value.condition);
|
|
4977
4983
|
function goPrevPage() {
|
|
@@ -4987,7 +4993,7 @@ const SelectSummarize = ({
|
|
|
4987
4993
|
}
|
|
4988
4994
|
if (condition && !~Special.indexOf(condition)) {
|
|
4989
4995
|
let availableData = data.slice();
|
|
4990
|
-
if (condition !== '不重复值的总数') {
|
|
4996
|
+
if (condition !== '不重复值的总数' && !ignoreGroupByType) {
|
|
4991
4997
|
// 只能用数字类型做聚合
|
|
4992
4998
|
availableData = data.map(v => {
|
|
4993
4999
|
return {
|
|
@@ -5731,12 +5737,17 @@ const TableData = props => {
|
|
|
5731
5737
|
alias = val;
|
|
5732
5738
|
}
|
|
5733
5739
|
}),
|
|
5734
|
-
onOk: () => {
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
+
onOk: async () => {
|
|
5741
|
+
if (!alias) {
|
|
5742
|
+
Toast.warning(__('SqlQueryBuilder.aliasCannotEmpty'));
|
|
5743
|
+
return false;
|
|
5744
|
+
} else {
|
|
5745
|
+
let newMetaList = store.metaList[groupIndex].list.slice();
|
|
5746
|
+
// @ts-ignore
|
|
5747
|
+
newMetaList[0].table.alias = alias;
|
|
5748
|
+
newMetaList = changeTableAlias(newMetaList, newMetaList[0].table);
|
|
5749
|
+
store.setMeta(newMetaList, groupIndex);
|
|
5750
|
+
}
|
|
5740
5751
|
},
|
|
5741
5752
|
onCancel: () => {}
|
|
5742
5753
|
});
|
|
@@ -5774,7 +5785,7 @@ const TableData = props => {
|
|
|
5774
5785
|
newMetaList.subquery = newList;
|
|
5775
5786
|
newMetaList.table = {
|
|
5776
5787
|
...newList[0].table,
|
|
5777
|
-
alias: newMetaList.table.alias || '',
|
|
5788
|
+
alias: newMetaList.table.alias || newList[0].table.name + '_' + groupIndex + '_' + 0,
|
|
5778
5789
|
tableUuid: uuidv4('table')
|
|
5779
5790
|
};
|
|
5780
5791
|
const items = getSubColumns(newList);
|
|
@@ -6444,7 +6455,8 @@ const JoinData = props => {
|
|
|
6444
6455
|
}
|
|
6445
6456
|
newMeta[index].subquery = newList;
|
|
6446
6457
|
newMeta[index].table2 = {
|
|
6447
|
-
...newList[0].table
|
|
6458
|
+
...newList[0].table,
|
|
6459
|
+
alias: newMeta[index].table2.alias || newList[0].table.name + '_' + groupIndex + '_' + index
|
|
6448
6460
|
};
|
|
6449
6461
|
const items = getSubColumns(newList);
|
|
6450
6462
|
const newColumns = items.flatMap(item => item.columns);
|
|
@@ -6502,12 +6514,17 @@ const JoinData = props => {
|
|
|
6502
6514
|
alias = val;
|
|
6503
6515
|
}
|
|
6504
6516
|
}),
|
|
6505
|
-
onOk: () => {
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6517
|
+
onOk: async () => {
|
|
6518
|
+
if (!alias) {
|
|
6519
|
+
Toast.warning(__('SqlQueryBuilder.aliasCannotEmpty'));
|
|
6520
|
+
return false;
|
|
6521
|
+
} else {
|
|
6522
|
+
let index = findIndex(store.metaList[groupIndex].list, meta);
|
|
6523
|
+
let newMeta = store.metaList[groupIndex].list.slice();
|
|
6524
|
+
newMeta[index].table2.alias = alias;
|
|
6525
|
+
newMeta = changeTableAlias(newMeta, newMeta[index].table2);
|
|
6526
|
+
store.setMeta(newMeta, groupIndex);
|
|
6527
|
+
}
|
|
6511
6528
|
},
|
|
6512
6529
|
onCancel: () => {}
|
|
6513
6530
|
});
|
|
@@ -8448,6 +8465,7 @@ const SelectIndex = props => {
|
|
|
8448
8465
|
content: jsx(SelectSummarize, {
|
|
8449
8466
|
data: data,
|
|
8450
8467
|
value: value,
|
|
8468
|
+
ignoreGroupByType: store.ignoreGroupByType,
|
|
8451
8469
|
onChange: data => {
|
|
8452
8470
|
//@ts-ignore
|
|
8453
8471
|
newMeta[index].group.splice(i, 1, data);
|
|
@@ -8501,6 +8519,7 @@ const SelectIndex = props => {
|
|
|
8501
8519
|
content: jsx(SelectSummarize, {
|
|
8502
8520
|
data: data,
|
|
8503
8521
|
value: value,
|
|
8522
|
+
ignoreGroupByType: store.ignoreGroupByType,
|
|
8504
8523
|
onChange: data => {
|
|
8505
8524
|
// @ts-ignore
|
|
8506
8525
|
newMeta[index].group.push(data);
|
|
@@ -9186,7 +9205,8 @@ const SqlVisionBuilder = /*#__PURE__*/React__default.forwardRef((props, ref) =>
|
|
|
9186
9205
|
showSubquery = true,
|
|
9187
9206
|
// 是否展示子查询
|
|
9188
9207
|
subShowSubquery = false,
|
|
9189
|
-
constantList
|
|
9208
|
+
constantList,
|
|
9209
|
+
ignoreGroupByType = false
|
|
9190
9210
|
} = props;
|
|
9191
9211
|
const store = useStore();
|
|
9192
9212
|
useEffect(() => {
|
|
@@ -9211,7 +9231,8 @@ const SqlVisionBuilder = /*#__PURE__*/React__default.forwardRef((props, ref) =>
|
|
|
9211
9231
|
store.setShowSubquery(showSubquery);
|
|
9212
9232
|
store._setShowSubquery(subShowSubquery);
|
|
9213
9233
|
store.setConstantList(constantList || []);
|
|
9214
|
-
|
|
9234
|
+
store.setIgnoreGroupByType(ignoreGroupByType);
|
|
9235
|
+
}, [showFields, fieldNameTpl, tableNameTpl, toolbar, showSubquery, subShowSubquery, constantList, ignoreGroupByType]);
|
|
9215
9236
|
React__default.useImperativeHandle(ref, () => ({
|
|
9216
9237
|
// setDatasource: (list) => {
|
|
9217
9238
|
// store.setSourceList(list);
|