@gingkoo/pandora-metabase 1.0.61 → 1.0.63
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/cjs/components/dialog/formula-list/index.js +159 -79
- package/lib/cjs/components/dialog/select-column-multiple/index.js +3 -3
- package/lib/cjs/components/dialog/select-join-column/index.js +3 -3
- package/lib/cjs/components/dialog/select-join-column-multiple/index.js +2 -2
- package/lib/cjs/components/dialog/select-permission-table/index.d.ts +2 -1
- package/lib/cjs/components/dialog/select-permission-table/index.js +4 -3
- package/lib/cjs/components/dialog/select-table/index.d.ts +3 -1
- package/lib/cjs/components/dialog/select-table/index.js +104 -9
- package/lib/cjs/components/metabase/index.js +8 -4
- package/lib/cjs/components/metabase/index.less +0 -1
- package/lib/cjs/components/modules/join-data.js +4 -1
- package/lib/cjs/components/modules/permission-table.js +1 -0
- package/lib/cjs/components/modules/table-data.js +2 -0
- package/lib/cjs/components/popup.d.ts +40 -102
- package/lib/cjs/components/popup.js +219 -190
- package/lib/cjs/hooks/use-state.js +103 -42
- package/lib/cjs/index.js +5 -2
- package/lib/cjs/types.d.ts +1 -0
- package/lib/cjs/utils/helper.d.ts +1 -1
- package/lib/cjs/utils/helper.js +2 -2
- package/lib/es/components/dialog/formula-list/index.js +159 -79
- package/lib/es/components/dialog/select-column-multiple/index.js +3 -3
- package/lib/es/components/dialog/select-join-column/index.js +3 -3
- package/lib/es/components/dialog/select-join-column-multiple/index.js +2 -2
- package/lib/es/components/dialog/select-permission-table/index.d.ts +2 -1
- package/lib/es/components/dialog/select-permission-table/index.js +4 -3
- package/lib/es/components/dialog/select-table/index.d.ts +3 -1
- package/lib/es/components/dialog/select-table/index.js +104 -9
- package/lib/es/components/metabase/index.js +8 -4
- package/lib/es/components/metabase/index.less +0 -1
- package/lib/es/components/modules/join-data.js +4 -1
- package/lib/es/components/modules/permission-table.js +1 -0
- package/lib/es/components/modules/table-data.js +2 -0
- package/lib/es/components/popup.d.ts +40 -102
- package/lib/es/components/popup.js +220 -191
- package/lib/es/hooks/use-state.js +104 -43
- package/lib/es/index.js +5 -2
- package/lib/es/types.d.ts +1 -0
- package/lib/es/utils/helper.d.ts +1 -1
- package/lib/es/utils/helper.js +2 -2
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
4
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
5
5
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
6
|
var _excluded = ["alias", "datasourceName", "datasourceId", "column"];
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
|
-
import { useState, useRef, useMemo } from 'react';
|
|
8
|
+
import { useEffect, useState, useRef, useMemo } from 'react';
|
|
9
9
|
import { uuidv4 } from '../utils/helper';
|
|
10
10
|
import { TypeEnum, JoinEnum, UnionEnum } from '../store/enum';
|
|
11
11
|
import { splitByUnion } from '../utils';
|
|
@@ -140,6 +140,14 @@ var useStore = function useStore() {
|
|
|
140
140
|
_useState44 = _slicedToArray(_useState43, 2),
|
|
141
141
|
isSelectFields = _useState44[0],
|
|
142
142
|
setIsSelectFields = _useState44[1]; // 是否默认勾选字段
|
|
143
|
+
var _useState45 = useState(false),
|
|
144
|
+
_useState46 = _slicedToArray(_useState45, 2),
|
|
145
|
+
tableFlat = _useState46[0],
|
|
146
|
+
setTableFlat = _useState46[1]; // 是否平铺数据表
|
|
147
|
+
var _useState47 = useState([]),
|
|
148
|
+
_useState48 = _slicedToArray(_useState47, 2),
|
|
149
|
+
sourceTable = _useState48[0],
|
|
150
|
+
setSourceTable = _useState48[1];
|
|
143
151
|
// 外层ref
|
|
144
152
|
var popupContainer = useRef();
|
|
145
153
|
// const [fetchDatasetFn, setFetchDatasetFn] = useState<(id: string) => Promise<any>>(
|
|
@@ -185,6 +193,55 @@ var useStore = function useStore() {
|
|
|
185
193
|
};
|
|
186
194
|
});
|
|
187
195
|
}, [metaList]);
|
|
196
|
+
useEffect(function () {
|
|
197
|
+
if (tableFlat) {
|
|
198
|
+
getSourceTable(sourceList);
|
|
199
|
+
}
|
|
200
|
+
}, [sourceList, isExit, tableFlat]);
|
|
201
|
+
// 获取所有数据表
|
|
202
|
+
var getSourceTable = /*#__PURE__*/function () {
|
|
203
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(source) {
|
|
204
|
+
var results;
|
|
205
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
206
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
207
|
+
case 0:
|
|
208
|
+
_context2.next = 1;
|
|
209
|
+
return Promise.all(source.map(/*#__PURE__*/function () {
|
|
210
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(v) {
|
|
211
|
+
var tables;
|
|
212
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
213
|
+
while (1) switch (_context.prev = _context.next) {
|
|
214
|
+
case 0:
|
|
215
|
+
_context.next = 1;
|
|
216
|
+
return fetchDataset(v.datasourceId);
|
|
217
|
+
case 1:
|
|
218
|
+
tables = _context.sent;
|
|
219
|
+
return _context.abrupt("return", _objectSpread(_objectSpread({}, v), {}, {
|
|
220
|
+
children: tables
|
|
221
|
+
}));
|
|
222
|
+
case 2:
|
|
223
|
+
case "end":
|
|
224
|
+
return _context.stop();
|
|
225
|
+
}
|
|
226
|
+
}, _callee);
|
|
227
|
+
}));
|
|
228
|
+
return function (_x2) {
|
|
229
|
+
return _ref2.apply(this, arguments);
|
|
230
|
+
};
|
|
231
|
+
}()));
|
|
232
|
+
case 1:
|
|
233
|
+
results = _context2.sent;
|
|
234
|
+
setSourceTable(results || []);
|
|
235
|
+
case 2:
|
|
236
|
+
case "end":
|
|
237
|
+
return _context2.stop();
|
|
238
|
+
}
|
|
239
|
+
}, _callee2);
|
|
240
|
+
}));
|
|
241
|
+
return function getSourceTable(_x) {
|
|
242
|
+
return _ref.apply(this, arguments);
|
|
243
|
+
};
|
|
244
|
+
}();
|
|
188
245
|
// const showMainColumn = useMemo(() => {
|
|
189
246
|
// let summarizeList = metaList.filter((v) => v.type === TypeEnum.summarize);
|
|
190
247
|
// if (
|
|
@@ -201,41 +258,41 @@ var useStore = function useStore() {
|
|
|
201
258
|
return !!~toolbar.indexOf(name);
|
|
202
259
|
};
|
|
203
260
|
var fetchDataset = /*#__PURE__*/function () {
|
|
204
|
-
var
|
|
261
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(datasourceId) {
|
|
205
262
|
var tables, _tables;
|
|
206
|
-
return _regeneratorRuntime.wrap(function (
|
|
207
|
-
while (1) switch (
|
|
263
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
264
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
208
265
|
case 0:
|
|
209
266
|
tables = getDataset(datasourceId);
|
|
210
267
|
if (!tables.length) {
|
|
211
|
-
|
|
268
|
+
_context3.next = 1;
|
|
212
269
|
break;
|
|
213
270
|
}
|
|
214
|
-
return
|
|
271
|
+
return _context3.abrupt("return", tables);
|
|
215
272
|
case 1:
|
|
216
|
-
|
|
273
|
+
_context3.next = 2;
|
|
217
274
|
return fetchDatasetFn.current(datasourceId, {
|
|
218
275
|
isExit: isExit
|
|
219
276
|
});
|
|
220
277
|
case 2:
|
|
221
|
-
_tables =
|
|
278
|
+
_tables = _context3.sent;
|
|
222
279
|
setDataset(datasourceId, _tables);
|
|
223
|
-
return
|
|
280
|
+
return _context3.abrupt("return", _tables);
|
|
224
281
|
case 3:
|
|
225
282
|
case "end":
|
|
226
|
-
return
|
|
283
|
+
return _context3.stop();
|
|
227
284
|
}
|
|
228
|
-
},
|
|
285
|
+
}, _callee3);
|
|
229
286
|
}));
|
|
230
|
-
return function fetchDataset(
|
|
231
|
-
return
|
|
287
|
+
return function fetchDataset(_x3) {
|
|
288
|
+
return _ref3.apply(this, arguments);
|
|
232
289
|
};
|
|
233
290
|
}();
|
|
234
291
|
// 根据数据源id查询集合列表
|
|
235
292
|
// fetchDataset():
|
|
236
293
|
// 查询表字段
|
|
237
294
|
var fetchColumns = /*#__PURE__*/function () {
|
|
238
|
-
var
|
|
295
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(table, datasourceId) {
|
|
239
296
|
var _columns2;
|
|
240
297
|
var oldColumns,
|
|
241
298
|
callback,
|
|
@@ -251,13 +308,13 @@ var useStore = function useStore() {
|
|
|
251
308
|
tableName,
|
|
252
309
|
columns,
|
|
253
310
|
_columns,
|
|
254
|
-
|
|
255
|
-
return _regeneratorRuntime.wrap(function (
|
|
256
|
-
while (1) switch (
|
|
311
|
+
_args4 = arguments;
|
|
312
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
313
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
257
314
|
case 0:
|
|
258
|
-
oldColumns =
|
|
259
|
-
callback =
|
|
260
|
-
isSelect =
|
|
315
|
+
oldColumns = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : [];
|
|
316
|
+
callback = _args4.length > 3 ? _args4[3] : undefined;
|
|
317
|
+
isSelect = _args4.length > 4 && _args4[4] !== undefined ? _args4[4] : isSelectFields;
|
|
261
318
|
// 获取之前选中的数据
|
|
262
319
|
oldObj = {};
|
|
263
320
|
selectId = oldColumns.filter(function (v) {
|
|
@@ -272,15 +329,15 @@ var useStore = function useStore() {
|
|
|
272
329
|
tableName = table.name;
|
|
273
330
|
columns = getColumns(tableName);
|
|
274
331
|
if (columns.length) {
|
|
275
|
-
|
|
332
|
+
_context4.next = 2;
|
|
276
333
|
break;
|
|
277
334
|
}
|
|
278
|
-
|
|
335
|
+
_context4.next = 1;
|
|
279
336
|
return fetchColumnsFn.current(extra, datasourceId, {
|
|
280
337
|
isExit: isExit
|
|
281
338
|
});
|
|
282
339
|
case 1:
|
|
283
|
-
columns =
|
|
340
|
+
columns = _context4.sent;
|
|
284
341
|
setColumns(tableName, columns);
|
|
285
342
|
case 2:
|
|
286
343
|
_columns = (_columns2 = columns) === null || _columns2 === void 0 ? void 0 : _columns2.map(function (v) {
|
|
@@ -295,26 +352,26 @@ var useStore = function useStore() {
|
|
|
295
352
|
typeof callback === 'function' && callback(_columns);
|
|
296
353
|
case 3:
|
|
297
354
|
case "end":
|
|
298
|
-
return
|
|
355
|
+
return _context4.stop();
|
|
299
356
|
}
|
|
300
|
-
},
|
|
357
|
+
}, _callee4);
|
|
301
358
|
}));
|
|
302
|
-
return function fetchColumns(
|
|
303
|
-
return
|
|
359
|
+
return function fetchColumns(_x4, _x5) {
|
|
360
|
+
return _ref4.apply(this, arguments);
|
|
304
361
|
};
|
|
305
362
|
}();
|
|
306
363
|
var setMeta = /*#__PURE__*/function () {
|
|
307
|
-
var
|
|
364
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(curData, groupInd) {
|
|
308
365
|
var changeObj,
|
|
309
366
|
_metaList,
|
|
310
367
|
newMeta,
|
|
311
368
|
isChange,
|
|
312
|
-
|
|
313
|
-
return _regeneratorRuntime.wrap(function (
|
|
314
|
-
while (1) switch (
|
|
369
|
+
_args5 = arguments;
|
|
370
|
+
return _regeneratorRuntime.wrap(function (_context5) {
|
|
371
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
315
372
|
case 0:
|
|
316
|
-
changeObj =
|
|
317
|
-
_metaList =
|
|
373
|
+
changeObj = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : {};
|
|
374
|
+
_metaList = _args5.length > 3 && _args5[3] !== undefined ? _args5[3] : metaList;
|
|
318
375
|
newMeta = cloneDeep(_metaList);
|
|
319
376
|
if (newMeta[groupInd]) {
|
|
320
377
|
newMeta[groupInd].list = curData;
|
|
@@ -322,29 +379,29 @@ var useStore = function useStore() {
|
|
|
322
379
|
}
|
|
323
380
|
// 过滤掉初始化
|
|
324
381
|
if (!(changeObj === 'init')) {
|
|
325
|
-
|
|
382
|
+
_context5.next = 1;
|
|
326
383
|
break;
|
|
327
384
|
}
|
|
328
|
-
return
|
|
385
|
+
return _context5.abrupt("return");
|
|
329
386
|
case 1:
|
|
330
|
-
|
|
387
|
+
_context5.next = 2;
|
|
331
388
|
return fetchChangeFn.current(splitByUnion(_metaList), changeObj, {
|
|
332
389
|
isExit: isExit
|
|
333
390
|
});
|
|
334
391
|
case 2:
|
|
335
|
-
isChange =
|
|
392
|
+
isChange = _context5.sent;
|
|
336
393
|
// 是否还原
|
|
337
394
|
if (isChange === false) {
|
|
338
395
|
_setMeta(_metaList);
|
|
339
396
|
}
|
|
340
397
|
case 3:
|
|
341
398
|
case "end":
|
|
342
|
-
return
|
|
399
|
+
return _context5.stop();
|
|
343
400
|
}
|
|
344
|
-
},
|
|
401
|
+
}, _callee5);
|
|
345
402
|
}));
|
|
346
|
-
return function setMeta(
|
|
347
|
-
return
|
|
403
|
+
return function setMeta(_x6, _x7) {
|
|
404
|
+
return _ref5.apply(this, arguments);
|
|
348
405
|
};
|
|
349
406
|
}();
|
|
350
407
|
// 回显
|
|
@@ -670,7 +727,11 @@ var useStore = function useStore() {
|
|
|
670
727
|
fieldEnableAlias: fieldEnableAlias,
|
|
671
728
|
setFieldEnableAlias: setFieldEnableAlias,
|
|
672
729
|
isSelectFields: isSelectFields,
|
|
673
|
-
setIsSelectFields: setIsSelectFields
|
|
730
|
+
setIsSelectFields: setIsSelectFields,
|
|
731
|
+
tableFlat: tableFlat,
|
|
732
|
+
setTableFlat: setTableFlat,
|
|
733
|
+
getSourceTable: getSourceTable,
|
|
734
|
+
sourceTable: sourceTable
|
|
674
735
|
};
|
|
675
736
|
};
|
|
676
737
|
export default useStore;
|
package/lib/es/index.js
CHANGED
|
@@ -53,7 +53,9 @@ var SqlVisionBuilder = React.forwardRef(function (props, ref) {
|
|
|
53
53
|
_props$fieldEnableAli = props.fieldEnableAlias,
|
|
54
54
|
fieldEnableAlias = _props$fieldEnableAli === void 0 ? true : _props$fieldEnableAli,
|
|
55
55
|
_props$isSelectFields = props.isSelectFields,
|
|
56
|
-
isSelectFields = _props$isSelectFields === void 0 ? true : _props$isSelectFields
|
|
56
|
+
isSelectFields = _props$isSelectFields === void 0 ? true : _props$isSelectFields,
|
|
57
|
+
_props$tableFlat = props.tableFlat,
|
|
58
|
+
tableFlat = _props$tableFlat === void 0 ? false : _props$tableFlat;
|
|
57
59
|
var store = useData();
|
|
58
60
|
useEffect(function () {
|
|
59
61
|
getTables && store.setFetchDatasetFn(getTables);
|
|
@@ -85,7 +87,8 @@ var SqlVisionBuilder = React.forwardRef(function (props, ref) {
|
|
|
85
87
|
store.setTableEnableAlias(tableEnableAlias);
|
|
86
88
|
store.setFieldEnableAlias(fieldEnableAlias);
|
|
87
89
|
store.setIsSelectFields(isSelectFields);
|
|
88
|
-
|
|
90
|
+
store.setTableFlat(tableFlat);
|
|
91
|
+
}, [showFields, fieldNameTpl, tableNameTpl, toolbar, showSubquery, subShowSubquery, constantList, formulaTemplates, ignoreGroupByType, filterCustomType, isExit, tableEnableAlias, fieldEnableAlias, isSelectFields, tableFlat]);
|
|
89
92
|
React.useImperativeHandle(ref, function () {
|
|
90
93
|
return {
|
|
91
94
|
// setDatasource: (list) => {
|
package/lib/es/types.d.ts
CHANGED
package/lib/es/utils/helper.d.ts
CHANGED
|
@@ -17,4 +17,4 @@ export declare const replaceTpl: (inputString: string, values: {
|
|
|
17
17
|
}) => string;
|
|
18
18
|
export declare const uuidv4: (prefix?: string) => string;
|
|
19
19
|
export declare const getAlias: (name: string | undefined, list: MetaListType[], columns?: any[]) => string;
|
|
20
|
-
export declare const mergeNameAlias: (name: string, alias: string) => string;
|
|
20
|
+
export declare const mergeNameAlias: (name: string, alias: string, isEnable: boolean) => string;
|
package/lib/es/utils/helper.js
CHANGED
|
@@ -182,6 +182,6 @@ export var getAlias = function getAlias() {
|
|
|
182
182
|
var nextIndex = Math.max.apply(Math, _toConsumableArray(uniqueIndexes)) + 1;
|
|
183
183
|
return "".concat(name, "_").concat(nextIndex);
|
|
184
184
|
};
|
|
185
|
-
export var mergeNameAlias = function mergeNameAlias(name, alias) {
|
|
186
|
-
return name + (alias ? "\uFF08".concat(alias, "\uFF09") : '');
|
|
185
|
+
export var mergeNameAlias = function mergeNameAlias(name, alias, isEnable) {
|
|
186
|
+
return name + (alias && isEnable ? "\uFF08".concat(alias, "\uFF09") : '');
|
|
187
187
|
};
|