@gingkoo/pandora-metabase 1.0.0-alpha.17 → 1.0.0-alpha.18
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/es/index.js +25 -85
- package/lib/es/index.js.map +1 -1
- package/package.json +1 -1
package/lib/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @gingkoo/pandora-metabase v1.0.0-alpha.
|
|
2
|
+
* @gingkoo/pandora-metabase v1.0.0-alpha.18
|
|
3
3
|
*/
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import * as React from 'react';
|
|
@@ -1146,28 +1146,29 @@ const useStore = () => {
|
|
|
1146
1146
|
};
|
|
1147
1147
|
// 回显
|
|
1148
1148
|
// 设置column
|
|
1149
|
-
const setQuotes =
|
|
1150
|
-
let newMeta = cloneDeep(_meta);
|
|
1149
|
+
const setQuotes = newMeta => {
|
|
1151
1150
|
newMeta.table1 = {
|
|
1152
1151
|
...newMeta.table1,
|
|
1153
1152
|
fieldAlias: newMeta.table1.fieldAlias || newMeta.table1.column,
|
|
1154
|
-
fieldUuid: newMeta.table1.fieldUuid ||
|
|
1155
|
-
quotes: newMeta.table1.quotes || newMeta.table1.column
|
|
1153
|
+
fieldUuid: newMeta.table1.fieldUuid || uuidv4('field'),
|
|
1154
|
+
quotes: newMeta.table1.quotes || newMeta.table1.column,
|
|
1155
|
+
tableUuid: newMeta.table1.tableUuid || uuidv4('table')
|
|
1156
1156
|
};
|
|
1157
1157
|
newMeta.table2 = {
|
|
1158
1158
|
...newMeta.table2,
|
|
1159
1159
|
fieldAlias: newMeta.table2.fieldAlias || newMeta.table2.column,
|
|
1160
|
-
fieldUuid: newMeta.table2.fieldUuid ||
|
|
1161
|
-
quotes: newMeta.table2.quotes || newMeta.table2.column
|
|
1160
|
+
fieldUuid: newMeta.table2.fieldUuid || uuidv4('field'),
|
|
1161
|
+
quotes: newMeta.table2.quotes || newMeta.table2.column,
|
|
1162
|
+
tableUuid: newMeta.table2.tableUuid || uuidv4('table')
|
|
1162
1163
|
};
|
|
1163
1164
|
newMeta.expressions = newMeta.expressions?.map(v => {
|
|
1164
1165
|
return {
|
|
1165
1166
|
...v,
|
|
1166
1167
|
left_fieldAlias: v.fieldAlias || v.left_column,
|
|
1167
|
-
left_fieldUuid: v.fieldUuid ||
|
|
1168
|
+
left_fieldUuid: v.fieldUuid || uuidv4('field'),
|
|
1168
1169
|
left_quotes: v.left_quotes || v.left_column,
|
|
1169
1170
|
right_fieldAlias: v.right_fieldAlias || v.right_column,
|
|
1170
|
-
right_fieldUuid: v.right_fieldUuid ||
|
|
1171
|
+
right_fieldUuid: v.right_fieldUuid || uuidv4('field'),
|
|
1171
1172
|
right_quotes: v.right_quotes || v.right_column
|
|
1172
1173
|
};
|
|
1173
1174
|
});
|
|
@@ -1178,6 +1179,12 @@ const useStore = () => {
|
|
|
1178
1179
|
let _metaList = data?.map((item, groupIndex) => {
|
|
1179
1180
|
let newList = item.list?.map((v, i) => {
|
|
1180
1181
|
let newMeta = item.list;
|
|
1182
|
+
if (v.table) {
|
|
1183
|
+
v.table.tableUuid = v.table.tableUuid || uuidv4('table');
|
|
1184
|
+
}
|
|
1185
|
+
if (v.type === TypeEnum.joinData) {
|
|
1186
|
+
newMeta[i] = setQuotes(newMeta[i]);
|
|
1187
|
+
}
|
|
1181
1188
|
// 设置右侧column
|
|
1182
1189
|
if (v.table2?.datasourceId && v.columns.length < 1) {
|
|
1183
1190
|
fetchColumns(newMeta[i].table2, newMeta[i].table2.datasourceId, (columns = []) => {
|
|
@@ -1189,9 +1196,6 @@ const useStore = () => {
|
|
|
1189
1196
|
} else {
|
|
1190
1197
|
newMeta[i].columns = columns || [];
|
|
1191
1198
|
}
|
|
1192
|
-
if (v.type === TypeEnum.joinData) {
|
|
1193
|
-
newMeta[i] = setQuotes(newMeta[i]);
|
|
1194
|
-
}
|
|
1195
1199
|
setMeta(newMeta, groupIndex);
|
|
1196
1200
|
});
|
|
1197
1201
|
return {
|
|
@@ -1209,9 +1213,9 @@ const useStore = () => {
|
|
|
1209
1213
|
} else {
|
|
1210
1214
|
newMeta[i].columns = columns || [];
|
|
1211
1215
|
}
|
|
1212
|
-
if (v.type === TypeEnum.joinData) {
|
|
1213
|
-
|
|
1214
|
-
}
|
|
1216
|
+
// if (v.type === TypeEnum.joinData) {
|
|
1217
|
+
// newMeta[i] = setQuotes(newMeta[i]);
|
|
1218
|
+
// }
|
|
1215
1219
|
setMeta(newMeta, groupIndex);
|
|
1216
1220
|
});
|
|
1217
1221
|
return {
|
|
@@ -1410,46 +1414,10 @@ const useStore = () => {
|
|
|
1410
1414
|
const getDataset = datasourceId => {
|
|
1411
1415
|
return _cacheSource2TableMap[datasourceId] || [];
|
|
1412
1416
|
};
|
|
1413
|
-
const changeAlias = (groupIndex, alias) => {
|
|
1414
|
-
let newMetaList = metaList.slice();
|
|
1415
|
-
const _list = newMetaList[groupIndex].list;
|
|
1416
|
-
if (_list.length > 0) {
|
|
1417
|
-
_list.forEach(item => {
|
|
1418
|
-
if (item.type === TypeEnum.joinData && item.table2.alias === alias) {
|
|
1419
|
-
item.table2.alias = alias;
|
|
1420
|
-
} else if (item.type === TypeEnum.data && item.table.alias === alias) {
|
|
1421
|
-
item.table.alias = alias;
|
|
1422
|
-
} else if (item.type === TypeEnum.filter) {
|
|
1423
|
-
//过滤器
|
|
1424
|
-
item.filter.forEach(filterItem => {
|
|
1425
|
-
if (filterItem.alias === alias) {
|
|
1426
|
-
filterItem.alias = alias;
|
|
1427
|
-
}
|
|
1428
|
-
});
|
|
1429
|
-
} else if (item.type === TypeEnum.summarize) {
|
|
1430
|
-
// 汇总
|
|
1431
|
-
item.alias = alias;
|
|
1432
|
-
item.by.forEach(byItem => {
|
|
1433
|
-
if (byItem.alias === alias) {
|
|
1434
|
-
byItem.alias = alias;
|
|
1435
|
-
}
|
|
1436
|
-
});
|
|
1437
|
-
item.group.forEach(groupItem => {
|
|
1438
|
-
if (groupItem.alias === alias) {
|
|
1439
|
-
groupItem.alias = alias;
|
|
1440
|
-
groupItem.sql = alias;
|
|
1441
|
-
}
|
|
1442
|
-
});
|
|
1443
|
-
}
|
|
1444
|
-
});
|
|
1445
|
-
newMetaList[groupIndex].list = _list;
|
|
1446
|
-
_setMeta(newMetaList);
|
|
1447
|
-
}
|
|
1448
|
-
};
|
|
1449
1417
|
const reset = () => {
|
|
1450
1418
|
// setSourceList([]);
|
|
1451
1419
|
_setMeta(defaultMeta);
|
|
1452
|
-
setToolbar(defaultToolbar);
|
|
1420
|
+
// setToolbar(defaultToolbar);
|
|
1453
1421
|
set_cacheSource2TableMap({});
|
|
1454
1422
|
set_cacheColumnsMap({});
|
|
1455
1423
|
};
|
|
@@ -1503,7 +1471,6 @@ const useStore = () => {
|
|
|
1503
1471
|
_setShowSubquery,
|
|
1504
1472
|
constantList,
|
|
1505
1473
|
setConstantList,
|
|
1506
|
-
changeAlias,
|
|
1507
1474
|
popupContainer
|
|
1508
1475
|
};
|
|
1509
1476
|
};
|
|
@@ -5631,33 +5598,6 @@ const TableData = props => {
|
|
|
5631
5598
|
};
|
|
5632
5599
|
|
|
5633
5600
|
const PrevResult$1 = 'Previous results';
|
|
5634
|
-
function setQuotes(_meta) {
|
|
5635
|
-
let newMeta = cloneDeep(_meta);
|
|
5636
|
-
newMeta.table1 = {
|
|
5637
|
-
...newMeta.table1,
|
|
5638
|
-
fieldAlias: newMeta.table1.fieldAlias || newMeta.table1.column,
|
|
5639
|
-
fieldUuid: newMeta.table1.fieldUuid || newMeta.table1.column_id,
|
|
5640
|
-
quotes: newMeta.table1.quotes || newMeta.table1.column
|
|
5641
|
-
};
|
|
5642
|
-
newMeta.table2 = {
|
|
5643
|
-
...newMeta.table2,
|
|
5644
|
-
fieldAlias: newMeta.table2.fieldAlias || newMeta.table2.column,
|
|
5645
|
-
fieldUuid: newMeta.table2.fieldUuid || newMeta.table2.column_id,
|
|
5646
|
-
quotes: newMeta.table2.quotes || newMeta.table2.column
|
|
5647
|
-
};
|
|
5648
|
-
newMeta.expressions = newMeta.expressions?.map(v => {
|
|
5649
|
-
return {
|
|
5650
|
-
...v,
|
|
5651
|
-
left_fieldAlias: v.fieldAlias || v.left_column,
|
|
5652
|
-
left_fieldUuid: v.fieldUuid || v.left_column_id,
|
|
5653
|
-
left_quotes: v.left_quotes || v.left_column,
|
|
5654
|
-
right_fieldAlias: v.right_fieldAlias || v.right_column,
|
|
5655
|
-
right_fieldUuid: v.right_fieldUuid || v.right_column_id,
|
|
5656
|
-
right_quotes: v.right_quotes || v.right_column
|
|
5657
|
-
};
|
|
5658
|
-
});
|
|
5659
|
-
return newMeta;
|
|
5660
|
-
}
|
|
5661
5601
|
var FlagLocation;
|
|
5662
5602
|
(function (FlagLocation) {
|
|
5663
5603
|
FlagLocation["TABLE_1"] = "table1";
|
|
@@ -5682,11 +5622,11 @@ const JoinData = props => {
|
|
|
5682
5622
|
let table2Selected = Boolean(meta.table2.name);
|
|
5683
5623
|
let subQuerySelected = Boolean(meta.subquery?.[0]?.table?.name);
|
|
5684
5624
|
let columnsSelected = meta.table1.quotes && meta.table2.quotes;
|
|
5685
|
-
useEffect(() => {
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
|
|
5689
|
-
}, []);
|
|
5625
|
+
// useEffect(() => {
|
|
5626
|
+
// let newMetaList = store.metaList[groupIndex].list.slice();
|
|
5627
|
+
// newMetaList[index] = setQuotes(meta);
|
|
5628
|
+
// store.setMeta(newMetaList, groupIndex);
|
|
5629
|
+
// }, []);
|
|
5690
5630
|
function selectColumns(e) {
|
|
5691
5631
|
let columns = meta.columns;
|
|
5692
5632
|
!meta.readonly && store.setPopup({
|