@aloudata/ink-lineage 0.0.1-beta.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/package.json +27 -0
- package/src/assets/big/dataSourceTypeIcon.ts +65 -0
- package/src/assets/big/entityType.ts +1 -0
- package/src/assets/big/index.ts +5 -0
- package/src/assets/big/lineageIcon.ts +35 -0
- package/src/assets/big/tableTypeIcon.ts +17 -0
- package/src/assets/big/tipIcon.ts +1 -0
- package/src/assets/index.ts +14 -0
- package/src/components/Edges/DefaultEdge.ts +196 -0
- package/src/components/Edges/FoldEdge.ts +97 -0
- package/src/components/Edges/LineageEdge.ts +24 -0
- package/src/components/Edges/index.ts +3 -0
- package/src/components/Nodes/AssetNode.ts +438 -0
- package/src/components/Nodes/ColumnNode.ts +491 -0
- package/src/components/Nodes/CustomNode.ts +63 -0
- package/src/components/Nodes/DefaultNode.ts +74 -0
- package/src/components/Nodes/DowngradeNode.ts +115 -0
- package/src/components/Nodes/TableNode.ts +534 -0
- package/src/components/Nodes/index.ts +4 -0
- package/src/components/index.ts +2 -0
- package/src/constant/index.ts +1 -0
- package/src/constant/nodeStyle.ts +141 -0
- package/src/index.ts +6 -0
- package/src/manager/BaseManager.ts +20 -0
- package/src/manager/DataProcessor.ts +782 -0
- package/src/manager/ExpandManager.ts +93 -0
- package/src/manager/FoldLineageManager.ts +196 -0
- package/src/manager/GraphEventManager.ts +90 -0
- package/src/manager/LineageManager.ts +680 -0
- package/src/manager/RightKeyMenuManager.ts +114 -0
- package/src/manager/SearchNodeManager.ts +188 -0
- package/src/manager/ToolbarManager.ts +42 -0
- package/src/manager/index.ts +8 -0
- package/src/manager/nodeManager/AssetEventManager.ts +442 -0
- package/src/manager/nodeManager/BaseEventManager.ts +68 -0
- package/src/manager/nodeManager/ColumnEventManager.ts +467 -0
- package/src/manager/nodeManager/CustomEventManager.ts +11 -0
- package/src/manager/nodeManager/TableEventManager.ts +87 -0
- package/src/manager/nodeManager/index.ts +3 -0
- package/src/types/NodeConfig.ts +69 -0
- package/src/types/eventEnum.ts +58 -0
- package/src/types/index.ts +3 -0
- package/src/types/manager.ts +75 -0
- package/src/types/node.ts +246 -0
- package/src/utils/downgradeNode.ts +22 -0
- package/src/utils/foldNode.ts +345 -0
- package/src/utils/getIconByType.ts +104 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/node.ts +294 -0
- package/tsconfig.json +30 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { InkLineageManager } from './LineageManager';
|
|
2
|
+
import { BaseManager } from './BaseManager';
|
|
3
|
+
import { EDashType, IColResBase, TDataBase } from '../types';
|
|
4
|
+
import {
|
|
5
|
+
contextMenuDefaultData,
|
|
6
|
+
EOverviewType,
|
|
7
|
+
hotspotModalDefaultData,
|
|
8
|
+
hotspotTipDefaultData,
|
|
9
|
+
IContextMenuState,
|
|
10
|
+
IHotspotModalState,
|
|
11
|
+
IHotspotTipState,
|
|
12
|
+
IOverViewBase,
|
|
13
|
+
overviewDefaultData,
|
|
14
|
+
EEventEnum,
|
|
15
|
+
} from '../types';
|
|
16
|
+
|
|
17
|
+
export const getOverviewDefaultData = () => {
|
|
18
|
+
const search = window.location.hash.split('?')[1];
|
|
19
|
+
if (!search) return overviewDefaultData;
|
|
20
|
+
const arr = search.split('&');
|
|
21
|
+
const filterData: string[] = arr.filter((item) => item.includes('code'));
|
|
22
|
+
const [, codeValue] = filterData[0]?.split('=');
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
...overviewDefaultData,
|
|
26
|
+
type: codeValue === 'Custom' ? EOverviewType.CUSTOM : EOverviewType.TABLE,
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export class RightKeyMenuManager<
|
|
30
|
+
TTableData extends TDataBase<TColumnData>,
|
|
31
|
+
TColumnData extends IColResBase,
|
|
32
|
+
> extends BaseManager<TTableData, TColumnData> {
|
|
33
|
+
constructor(lineageManager: InkLineageManager<TTableData, TColumnData>) {
|
|
34
|
+
super(lineageManager);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// context menu
|
|
38
|
+
contextMenuState: IContextMenuState = contextMenuDefaultData;
|
|
39
|
+
|
|
40
|
+
overviewState: IOverViewBase = getOverviewDefaultData();
|
|
41
|
+
|
|
42
|
+
edgeDashVisible: EDashType = EDashType.DIRECT;
|
|
43
|
+
|
|
44
|
+
onlyShowRelated: boolean = false;
|
|
45
|
+
|
|
46
|
+
hotspotModalState: IHotspotModalState = hotspotModalDefaultData;
|
|
47
|
+
|
|
48
|
+
hotspotTipState: IHotspotTipState = hotspotTipDefaultData;
|
|
49
|
+
|
|
50
|
+
// 更新概览信息
|
|
51
|
+
setOverview(data: Partial<IOverViewBase>) {
|
|
52
|
+
this.overviewState = {
|
|
53
|
+
...this.overviewState,
|
|
54
|
+
...data,
|
|
55
|
+
};
|
|
56
|
+
this.lineageManager.emit(EEventEnum.OVERVIEW);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
showContextMenu(data: IContextMenuState) {
|
|
60
|
+
this.contextMenuState = data;
|
|
61
|
+
this.lineageManager.emit(EEventEnum.CONTEXT_MENU);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// hide context menu
|
|
65
|
+
hideContextMenu() {
|
|
66
|
+
this.contextMenuState.visible = false;
|
|
67
|
+
this.lineageManager.emit(EEventEnum.CONTEXT_MENU);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// update direct & indirect table visible
|
|
71
|
+
updateEdgeDashVisible(edgeDashVisible: EDashType) {
|
|
72
|
+
if (!this.graph) return;
|
|
73
|
+
|
|
74
|
+
this.edgeDashVisible = edgeDashVisible;
|
|
75
|
+
|
|
76
|
+
this.lineageManager.update();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// update related & unrelated table visible
|
|
80
|
+
updateRelatedTableVisible(
|
|
81
|
+
onlyShowRelated: boolean,
|
|
82
|
+
needUpdate: boolean = true,
|
|
83
|
+
) {
|
|
84
|
+
if (!this.graph) return;
|
|
85
|
+
|
|
86
|
+
this.onlyShowRelated = onlyShowRelated;
|
|
87
|
+
|
|
88
|
+
if (needUpdate) {
|
|
89
|
+
this.lineageManager.update();
|
|
90
|
+
} else {
|
|
91
|
+
this.lineageManager.refreshExtraStatus();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
this.lineageManager.emit(EEventEnum.CONTEXT_MENU);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
resetEdgeDashVisible() {
|
|
98
|
+
this.edgeDashVisible = EDashType.DIRECT;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
resetOnlyShowRelated() {
|
|
102
|
+
this.onlyShowRelated = false;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
updateHotspotModalState(data: IHotspotModalState) {
|
|
106
|
+
this.hotspotModalState = data;
|
|
107
|
+
this.lineageManager.emit(EEventEnum.HOTSPOT_MODAL_UPDATE);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
updateHotspotTipState(data: IHotspotTipState) {
|
|
111
|
+
this.hotspotTipState = data;
|
|
112
|
+
this.lineageManager.emit(EEventEnum.HOTSPOT_TIPS);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { InkLineageManager } from './LineageManager';
|
|
2
|
+
import {
|
|
3
|
+
EDataSourceType,
|
|
4
|
+
IColumnConfig,
|
|
5
|
+
INodeConfig,
|
|
6
|
+
IColResBase,
|
|
7
|
+
TDataBase,
|
|
8
|
+
} from '../types';
|
|
9
|
+
import { getNodeHeight } from '@aloudata/ink-graph-new';
|
|
10
|
+
import { BaseManager } from './BaseManager';
|
|
11
|
+
export class SearchNodeManager<
|
|
12
|
+
TTableData extends TDataBase<TColumnData>,
|
|
13
|
+
TColumnData extends IColResBase,
|
|
14
|
+
> extends BaseManager<TTableData, TColumnData> {
|
|
15
|
+
constructor(lineageManager: InkLineageManager<TTableData, TColumnData>) {
|
|
16
|
+
super(lineageManager);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
highlightCurrIndex: number = 0;
|
|
20
|
+
|
|
21
|
+
highlightNodesId: string[];
|
|
22
|
+
|
|
23
|
+
highlightNodeId: string;
|
|
24
|
+
|
|
25
|
+
searchNode(input: string) {
|
|
26
|
+
this.resetHighLightNodes();
|
|
27
|
+
|
|
28
|
+
const search = input.trim();
|
|
29
|
+
if (!search || search.length < 1) return;
|
|
30
|
+
|
|
31
|
+
const nodeRes = this.getLikeNodesIdBySearch(search);
|
|
32
|
+
|
|
33
|
+
// 绘制每个column的高亮框
|
|
34
|
+
if (nodeRes.size < 1) return;
|
|
35
|
+
return nodeRes;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 每次查询 重置参数
|
|
39
|
+
resetHighLightNodes() {
|
|
40
|
+
// reset highlight node
|
|
41
|
+
const target = this.lineageManager.getNodeConfigById(this.highlightNodeId);
|
|
42
|
+
|
|
43
|
+
if (target) {
|
|
44
|
+
// reset highlight
|
|
45
|
+
target.style.stroke = '#E8E8E8';
|
|
46
|
+
target.style.fill = '#FFF';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
this.highlightCurrIndex = 0;
|
|
50
|
+
this.highlightNodeId = '';
|
|
51
|
+
this.highlightNodesId = [];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
getLikeNodesIdBySearch(search: string) {
|
|
55
|
+
const res = new Map<
|
|
56
|
+
string,
|
|
57
|
+
{
|
|
58
|
+
id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
tableId?: string;
|
|
61
|
+
tableName?: string;
|
|
62
|
+
icon?: string;
|
|
63
|
+
type?: string;
|
|
64
|
+
tableType?: string;
|
|
65
|
+
dataSourceType?: EDataSourceType;
|
|
66
|
+
assetPath?: string;
|
|
67
|
+
description?: string;
|
|
68
|
+
}
|
|
69
|
+
>();
|
|
70
|
+
|
|
71
|
+
this.lineageManager.parsedData?.nodes?.forEach(
|
|
72
|
+
(n: INodeConfig<TTableData, TColumnData>) => {
|
|
73
|
+
if (n.visible) {
|
|
74
|
+
// node
|
|
75
|
+
if (n.data?.name?.toLowerCase().includes(search)) {
|
|
76
|
+
res.set(n.id, {
|
|
77
|
+
id: n.id,
|
|
78
|
+
type: (n as INodeConfig<TTableData, TColumnData>).data?.type,
|
|
79
|
+
name: n?.data?.name,
|
|
80
|
+
icon: n?.data?.icon,
|
|
81
|
+
dataSourceType: n?.data?.datasourceType,
|
|
82
|
+
description: n?.data?.description,
|
|
83
|
+
assetPath: n?.data?.assetPath,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// related columns
|
|
88
|
+
(n.relatedColumns as IColumnConfig<TColumnData>[])?.forEach(
|
|
89
|
+
(col: IColumnConfig<TColumnData>) => {
|
|
90
|
+
if (col.data?.name?.toLowerCase().includes(search)) {
|
|
91
|
+
const tableNode = this.lineageManager.getTableNodeConfigById(
|
|
92
|
+
col.tableId,
|
|
93
|
+
);
|
|
94
|
+
res.set(col.id, {
|
|
95
|
+
tableId: col.tableId,
|
|
96
|
+
tableName: col.tableName,
|
|
97
|
+
tableType: tableNode?.data.type,
|
|
98
|
+
dataSourceType: tableNode?.data?.datasourceType,
|
|
99
|
+
description: tableNode?.data?.description,
|
|
100
|
+
assetPath: tableNode?.data?.assetPath,
|
|
101
|
+
id: col.id,
|
|
102
|
+
type: 'Column',
|
|
103
|
+
name: col?.data?.name,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
// children columns
|
|
110
|
+
(n.children as IColumnConfig<TColumnData>[])?.forEach(
|
|
111
|
+
(col: IColumnConfig<TColumnData>) => {
|
|
112
|
+
if (
|
|
113
|
+
!res.get(col.id) &&
|
|
114
|
+
col?.data?.name?.toLowerCase().includes(search)
|
|
115
|
+
) {
|
|
116
|
+
const tableNode = this.lineageManager.getTableNodeConfigById(
|
|
117
|
+
col.tableId,
|
|
118
|
+
);
|
|
119
|
+
res.set(col.id, {
|
|
120
|
+
tableId: col.tableId,
|
|
121
|
+
tableName: col.tableName,
|
|
122
|
+
tableType: tableNode?.data.type,
|
|
123
|
+
dataSourceType: tableNode?.data?.datasourceType,
|
|
124
|
+
description: tableNode?.data?.description,
|
|
125
|
+
assetPath: tableNode?.data?.assetPath,
|
|
126
|
+
id: col.id,
|
|
127
|
+
type: 'Column',
|
|
128
|
+
name: col?.data?.name,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
return res;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
highLightById() {
|
|
141
|
+
// highlight current node
|
|
142
|
+
const currNodeId = this.highlightNodeId;
|
|
143
|
+
if (!currNodeId) return;
|
|
144
|
+
|
|
145
|
+
const currNodeConfig = this.lineageManager.getNodeConfigById(currNodeId);
|
|
146
|
+
if (!currNodeConfig) return;
|
|
147
|
+
|
|
148
|
+
const nodeId = currNodeConfig?.tableId
|
|
149
|
+
? currNodeConfig.tableId
|
|
150
|
+
: currNodeConfig.id;
|
|
151
|
+
|
|
152
|
+
this.graph.moveTargetToCenter(nodeId as string);
|
|
153
|
+
|
|
154
|
+
const tableId = currNodeConfig.tableId as string;
|
|
155
|
+
|
|
156
|
+
if (tableId) {
|
|
157
|
+
// 如果是列则说明不在当前页面
|
|
158
|
+
// 需要翻页
|
|
159
|
+
const tableNodeConfig =
|
|
160
|
+
this.lineageManager.getTableNodeConfigById(tableId);
|
|
161
|
+
|
|
162
|
+
if (!tableNodeConfig) return;
|
|
163
|
+
|
|
164
|
+
const { children, pagination } = tableNodeConfig;
|
|
165
|
+
|
|
166
|
+
// 根据currNodeId 在children中的位置,计算该字段处于第几个页,每页展示10个字段
|
|
167
|
+
const index = children.findIndex(
|
|
168
|
+
(col: IColumnConfig<TColumnData>) => col.id === currNodeId,
|
|
169
|
+
);
|
|
170
|
+
const page = Math.floor(index / 10) + 1;
|
|
171
|
+
|
|
172
|
+
tableNodeConfig.pagination = {
|
|
173
|
+
...pagination,
|
|
174
|
+
pageNum: page,
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
tableNodeConfig.isOpen = true; // 需要layout
|
|
178
|
+
tableNodeConfig.style.height = getNodeHeight(tableNodeConfig);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (currNodeConfig) {
|
|
182
|
+
currNodeConfig.style.stroke = '#FFC04D';
|
|
183
|
+
currNodeConfig.style.fill = '#FFD180';
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
this.lineageManager.update();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { IColumnConfig, IEdgeConfig, INodeConfig, TDataBase } from '../types';
|
|
2
|
+
import { BaseManager } from './BaseManager';
|
|
3
|
+
import { InkLineageManager } from './LineageManager';
|
|
4
|
+
import { EEventEnum } from '../types';
|
|
5
|
+
import { isAllDirectEdges } from '../utils';
|
|
6
|
+
import { IColResBase } from '../types';
|
|
7
|
+
|
|
8
|
+
export interface IToolbarState {
|
|
9
|
+
onlyRelatedVisible: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class ToolbarManager<
|
|
13
|
+
TTableData extends TDataBase<TColumnData>,
|
|
14
|
+
TColumnData extends IColResBase,
|
|
15
|
+
> extends BaseManager<TTableData, TColumnData> {
|
|
16
|
+
constructor(lineageManager: InkLineageManager<TTableData, TColumnData>) {
|
|
17
|
+
super(lineageManager);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
state: IToolbarState = {
|
|
21
|
+
onlyRelatedVisible: false,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
updateOnlyRelatedVisible(
|
|
25
|
+
nodeConfig:
|
|
26
|
+
| INodeConfig<TTableData, TColumnData>
|
|
27
|
+
| IColumnConfig<TColumnData>,
|
|
28
|
+
) {
|
|
29
|
+
const onlyRelatedVisible = isAllDirectEdges<TTableData, TColumnData>(
|
|
30
|
+
nodeConfig,
|
|
31
|
+
this.graph.nodesConfig as (
|
|
32
|
+
| INodeConfig<TTableData, TColumnData>
|
|
33
|
+
| IColumnConfig<TColumnData>
|
|
34
|
+
)[],
|
|
35
|
+
this.graph.edgesConfig as IEdgeConfig[],
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
this.state.onlyRelatedVisible = onlyRelatedVisible;
|
|
39
|
+
|
|
40
|
+
this.lineageManager.emit(EEventEnum.TOOLBAR);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './LineageManager';
|
|
2
|
+
export * from './ExpandManager';
|
|
3
|
+
export * from './FoldLineageManager';
|
|
4
|
+
export * from './RightKeyMenuManager';
|
|
5
|
+
export * from './SearchNodeManager';
|
|
6
|
+
export * from './DataProcessor';
|
|
7
|
+
export * from './ToolbarManager';
|
|
8
|
+
export * from './nodeManager';
|