@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,115 @@
|
|
|
1
|
+
import { Graph, Image, Rect } from '@aloudata/ink-graph-new';
|
|
2
|
+
import {
|
|
3
|
+
DOWNGRADE_TABLE_HEADER_HEIGHT,
|
|
4
|
+
NODE_WIDTH,
|
|
5
|
+
SIDE_ICON_SIZE,
|
|
6
|
+
} from '../../constant';
|
|
7
|
+
import {
|
|
8
|
+
EEntityType,
|
|
9
|
+
EElementType,
|
|
10
|
+
IColResBase,
|
|
11
|
+
INodeConfig,
|
|
12
|
+
TDataBase,
|
|
13
|
+
AssetEventType,
|
|
14
|
+
} from '../../types';
|
|
15
|
+
import { getEventTypeByNodeType } from '../../utils';
|
|
16
|
+
import { getEventTypeByEntityType } from '../../utils/downgradeNode';
|
|
17
|
+
import { AssetNode } from './AssetNode';
|
|
18
|
+
|
|
19
|
+
export class DowngradeNode extends AssetNode {
|
|
20
|
+
declare config: INodeConfig<TDataBase<IColResBase>, IColResBase>;
|
|
21
|
+
|
|
22
|
+
constructor(
|
|
23
|
+
graph: Graph,
|
|
24
|
+
config: INodeConfig<TDataBase<IColResBase>, IColResBase>,
|
|
25
|
+
) {
|
|
26
|
+
super(graph, config);
|
|
27
|
+
this.elementType = EElementType.TABLE;
|
|
28
|
+
this.eventType = getEventTypeByNodeType(
|
|
29
|
+
EElementType.TABLE,
|
|
30
|
+
) as AssetEventType;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
render() {
|
|
34
|
+
const { isStartNode, visible } = this.config;
|
|
35
|
+
|
|
36
|
+
if (visible === false) return;
|
|
37
|
+
|
|
38
|
+
if (isStartNode) {
|
|
39
|
+
this.renderStartNodeTag();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
super.render(this.config, this.container);
|
|
43
|
+
|
|
44
|
+
this.renderBgHideRect();
|
|
45
|
+
|
|
46
|
+
this.renderIcon();
|
|
47
|
+
|
|
48
|
+
this.initEvents();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
renderBgHideRect() {
|
|
52
|
+
// 用于hover到sideIcon区域时也能显示sideIcon
|
|
53
|
+
const bgHideRect = new Rect({
|
|
54
|
+
name: 'column-bgRect-hide',
|
|
55
|
+
style: {
|
|
56
|
+
x: -20,
|
|
57
|
+
fill: '#0000',
|
|
58
|
+
stroke: '#0000',
|
|
59
|
+
width: NODE_WIDTH + 40,
|
|
60
|
+
height: DOWNGRADE_TABLE_HEADER_HEIGHT,
|
|
61
|
+
zIndex: 9,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
this.headerGroup.appendChild(bgHideRect);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
renderIcon() {
|
|
68
|
+
const { data } = this.config;
|
|
69
|
+
const eventType = getEventTypeByEntityType(data.type as EEntityType);
|
|
70
|
+
if (!eventType) return null;
|
|
71
|
+
|
|
72
|
+
this.leftIcon = new Image({
|
|
73
|
+
name: `sideIcon-img-left`,
|
|
74
|
+
style: {
|
|
75
|
+
x: -SIDE_ICON_SIZE - 4,
|
|
76
|
+
y: DOWNGRADE_TABLE_HEADER_HEIGHT / 2 - SIDE_ICON_SIZE / 2,
|
|
77
|
+
width: SIDE_ICON_SIZE,
|
|
78
|
+
height: SIDE_ICON_SIZE,
|
|
79
|
+
cursor: 'pointer',
|
|
80
|
+
zIndex: 99,
|
|
81
|
+
visibility: 'visible',
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
this.rightIcon = new Image({
|
|
86
|
+
name: `sideIcon-img-right`,
|
|
87
|
+
style: {
|
|
88
|
+
x: NODE_WIDTH + 6,
|
|
89
|
+
y: DOWNGRADE_TABLE_HEADER_HEIGHT / 2 - SIDE_ICON_SIZE / 2,
|
|
90
|
+
width: SIDE_ICON_SIZE,
|
|
91
|
+
height: SIDE_ICON_SIZE,
|
|
92
|
+
cursor: 'pointer',
|
|
93
|
+
zIndex: 99,
|
|
94
|
+
visibility: 'visible',
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
this.headerGroup.addEventListener('click', () => {
|
|
99
|
+
this.lineageManager.emit(this.eventType.HEADER_CLICK, this);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
this.leftIcon.addEventListener('click', () => {
|
|
103
|
+
this.leftIconClick();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
this.rightIcon.addEventListener('click', () => {
|
|
107
|
+
this.rightIconClick();
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
this.headerGroup.appendChild(this.leftIcon);
|
|
111
|
+
this.headerGroup.appendChild(this.rightIcon);
|
|
112
|
+
|
|
113
|
+
this.container.appendChild(this.headerGroup);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Group,
|
|
3
|
+
Rect,
|
|
4
|
+
Text,
|
|
5
|
+
Image,
|
|
6
|
+
Graph,
|
|
7
|
+
getTextDomWidth,
|
|
8
|
+
} from '@aloudata/ink-graph-new';
|
|
9
|
+
import {
|
|
10
|
+
PAGINATION_IMAGE_SIZE,
|
|
11
|
+
TABLE_CONTROL_BAR_HEIGHT,
|
|
12
|
+
TABLE_HEADER_HEIGHT,
|
|
13
|
+
TABLE_RECT_BORDER_RADIUS,
|
|
14
|
+
NODE_WIDTH,
|
|
15
|
+
TABLE_OPERATE_ICON_X,
|
|
16
|
+
COL_HEIGHT,
|
|
17
|
+
TABLE_HEADER_DESC_WRAP_WIDTH,
|
|
18
|
+
} from '../../constant';
|
|
19
|
+
import {
|
|
20
|
+
tableShowLess,
|
|
21
|
+
tablePaginationNextClick,
|
|
22
|
+
tablePaginationNextHover,
|
|
23
|
+
tablePaginationNext,
|
|
24
|
+
tablePaginationPrevClick,
|
|
25
|
+
tablePaginationPrevHover,
|
|
26
|
+
tablePaginationPrev,
|
|
27
|
+
tableShowMore,
|
|
28
|
+
} from '../../assets';
|
|
29
|
+
import { ColumnNode } from './ColumnNode';
|
|
30
|
+
import { AssetNode } from './AssetNode';
|
|
31
|
+
import {
|
|
32
|
+
AssetEventType,
|
|
33
|
+
EElementType,
|
|
34
|
+
ETableEvents,
|
|
35
|
+
IColResBase,
|
|
36
|
+
IColumnConfig,
|
|
37
|
+
INodeConfig,
|
|
38
|
+
TDataBase,
|
|
39
|
+
} from '../../types';
|
|
40
|
+
import {
|
|
41
|
+
getDataSourceTypeIcon,
|
|
42
|
+
getEntityTypeIcon,
|
|
43
|
+
getEventTypeByNodeType,
|
|
44
|
+
} from '../../utils';
|
|
45
|
+
|
|
46
|
+
export class TableNode extends AssetNode {
|
|
47
|
+
declare config: INodeConfig<TDataBase<IColResBase>, IColResBase>;
|
|
48
|
+
|
|
49
|
+
tableRelatedGroup: Rect;
|
|
50
|
+
|
|
51
|
+
tableContentGroup: Group;
|
|
52
|
+
|
|
53
|
+
colGroup: Rect;
|
|
54
|
+
|
|
55
|
+
paginationPrevImage: Image;
|
|
56
|
+
|
|
57
|
+
paginationNextImage: Image;
|
|
58
|
+
|
|
59
|
+
children: ColumnNode[] = [];
|
|
60
|
+
|
|
61
|
+
relatedColumns: ColumnNode[] = [];
|
|
62
|
+
|
|
63
|
+
constructor(
|
|
64
|
+
graph: Graph,
|
|
65
|
+
config: INodeConfig<TDataBase<IColResBase>, IColResBase>,
|
|
66
|
+
) {
|
|
67
|
+
super(graph, config);
|
|
68
|
+
this.elementType = EElementType.TABLE;
|
|
69
|
+
this.eventType = getEventTypeByNodeType(
|
|
70
|
+
EElementType.TABLE,
|
|
71
|
+
) as AssetEventType;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
render(config: INodeConfig<TDataBase<IColResBase>, IColResBase>) {
|
|
75
|
+
this.renderAssetNode();
|
|
76
|
+
|
|
77
|
+
const { isOpen } = config;
|
|
78
|
+
|
|
79
|
+
this.renderTableHeader();
|
|
80
|
+
|
|
81
|
+
// render table related content
|
|
82
|
+
this.renderRelatedContent();
|
|
83
|
+
|
|
84
|
+
// // render table control bar
|
|
85
|
+
this.renderControlBar();
|
|
86
|
+
|
|
87
|
+
// render table content
|
|
88
|
+
if (isOpen) {
|
|
89
|
+
this.renderColumns();
|
|
90
|
+
this.calculatePaginationData();
|
|
91
|
+
this.renderPagination();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// refresh table height
|
|
95
|
+
this.updateNodeHeight();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
renderTableHeader() {
|
|
99
|
+
const { data } = this.config;
|
|
100
|
+
const { assetPath, datasourceType, typeCode } = data;
|
|
101
|
+
const entityTypeIcon = new Image({
|
|
102
|
+
style: {
|
|
103
|
+
x: 12,
|
|
104
|
+
y: 14,
|
|
105
|
+
width: 20,
|
|
106
|
+
height: 20,
|
|
107
|
+
zIndex: 99,
|
|
108
|
+
img: getEntityTypeIcon(typeCode, data.type) as string,
|
|
109
|
+
cursor: 'pointer',
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const headerDesc = new Text({
|
|
114
|
+
style: {
|
|
115
|
+
x: 36,
|
|
116
|
+
y: 47,
|
|
117
|
+
lineHeight: 16,
|
|
118
|
+
textOverflow: 'ellipsis',
|
|
119
|
+
text:
|
|
120
|
+
this.config?.data.displayName || this.config?.data.description || '-',
|
|
121
|
+
fontSize: 12,
|
|
122
|
+
fontWeight: 400,
|
|
123
|
+
fontFamily: 'PingFang SC',
|
|
124
|
+
textBaseline: 'top',
|
|
125
|
+
wordWrap: true,
|
|
126
|
+
wordWrapWidth: TABLE_HEADER_DESC_WRAP_WIDTH,
|
|
127
|
+
maxLines: 1,
|
|
128
|
+
textAlign: 'start',
|
|
129
|
+
fill: '#111827',
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
const sourceTypeIcon = new Image({
|
|
133
|
+
style: {
|
|
134
|
+
x: 12,
|
|
135
|
+
y: 67,
|
|
136
|
+
width: 16,
|
|
137
|
+
height: 16,
|
|
138
|
+
zIndex: 99,
|
|
139
|
+
img: getDataSourceTypeIcon(datasourceType) as string,
|
|
140
|
+
cursor: 'pointer',
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
// 表才有
|
|
144
|
+
const headerAssetPath = new Text({
|
|
145
|
+
style: {
|
|
146
|
+
x: 36,
|
|
147
|
+
y: 70,
|
|
148
|
+
zIndex: 99,
|
|
149
|
+
lineHeight: 16,
|
|
150
|
+
textOverflow: 'ellipsis',
|
|
151
|
+
text: assetPath,
|
|
152
|
+
fontSize: 12,
|
|
153
|
+
fontWeight: 400,
|
|
154
|
+
fontFamily: 'PingFang SC',
|
|
155
|
+
textBaseline: 'top',
|
|
156
|
+
wordWrap: true,
|
|
157
|
+
wordWrapWidth: TABLE_HEADER_DESC_WRAP_WIDTH,
|
|
158
|
+
maxLines: 1,
|
|
159
|
+
textAlign: 'start',
|
|
160
|
+
fill: '#858585',
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
this.headerGroup.appendChild(entityTypeIcon);
|
|
164
|
+
this.headerGroup.appendChild(headerDesc);
|
|
165
|
+
this.headerGroup.appendChild(sourceTypeIcon);
|
|
166
|
+
this.headerGroup.appendChild(headerAssetPath);
|
|
167
|
+
this.container.appendChild(this.headerGroup);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
renderRelatedContent() {
|
|
171
|
+
const { relatedColumns, isActive, isRelated, style } = this.config;
|
|
172
|
+
|
|
173
|
+
const visibleColumns = relatedColumns.filter(
|
|
174
|
+
(col: IColumnConfig<IColResBase>) => col.visible,
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
// table related group
|
|
178
|
+
this.tableRelatedGroup = new Rect({
|
|
179
|
+
style: {
|
|
180
|
+
y: TABLE_HEADER_HEIGHT,
|
|
181
|
+
width: NODE_WIDTH,
|
|
182
|
+
height:
|
|
183
|
+
visibleColumns.length > 0
|
|
184
|
+
? visibleColumns.length * COL_HEIGHT + 16
|
|
185
|
+
: 0,
|
|
186
|
+
fill: '#F4F4F4',
|
|
187
|
+
zIndex: 2,
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
const tableRelatedColumnsGroup = new Group({
|
|
192
|
+
style: {
|
|
193
|
+
y: 8,
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
visibleColumns
|
|
198
|
+
.sort((i, j) => {
|
|
199
|
+
return i.data.position - j.data.position;
|
|
200
|
+
})
|
|
201
|
+
.forEach((colConfig: IColumnConfig<IColResBase>, i) => {
|
|
202
|
+
const col = new ColumnNode(this.graph, colConfig, this, i);
|
|
203
|
+
|
|
204
|
+
// add or replace column DOM
|
|
205
|
+
const colIndex = this.relatedColumns.findIndex((c) => c.id === col.id);
|
|
206
|
+
|
|
207
|
+
if (colIndex === -1) {
|
|
208
|
+
this.relatedColumns.push(col);
|
|
209
|
+
} else {
|
|
210
|
+
this.relatedColumns[colIndex] = col;
|
|
211
|
+
}
|
|
212
|
+
tableRelatedColumnsGroup.appendChild(col.container);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
this.tableRelatedGroup.appendChild(tableRelatedColumnsGroup);
|
|
216
|
+
this.container.appendChild(this.tableRelatedGroup);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
renderControlBar() {
|
|
220
|
+
const { lineageManager } = this;
|
|
221
|
+
const { data, isOpen, isActive, isRelated, style } = this.config;
|
|
222
|
+
const { columnCount = 0 } = data;
|
|
223
|
+
|
|
224
|
+
// column count
|
|
225
|
+
const columnCountStr = '' + columnCount;
|
|
226
|
+
const tableRelatedGroupHeight = this.tableRelatedGroup?.getBBox()?.height;
|
|
227
|
+
const relatedColsHeight = tableRelatedGroupHeight;
|
|
228
|
+
|
|
229
|
+
// table content group
|
|
230
|
+
const tableControlGroup = new Rect({
|
|
231
|
+
name: 'table-control-group',
|
|
232
|
+
style: {
|
|
233
|
+
x: 0,
|
|
234
|
+
y: TABLE_HEADER_HEIGHT + relatedColsHeight,
|
|
235
|
+
zIndex: 1,
|
|
236
|
+
width: NODE_WIDTH,
|
|
237
|
+
height: 32,
|
|
238
|
+
fill: '#F4F4F4',
|
|
239
|
+
radius: isOpen
|
|
240
|
+
? [0]
|
|
241
|
+
: [0, 0, TABLE_RECT_BORDER_RADIUS, TABLE_RECT_BORDER_RADIUS],
|
|
242
|
+
},
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
const columnCountText = new Text({
|
|
246
|
+
style: {
|
|
247
|
+
x: 12,
|
|
248
|
+
y: 22,
|
|
249
|
+
text: `全部 ${columnCountStr} 列`,
|
|
250
|
+
fill: '#575757',
|
|
251
|
+
fontSize: 12,
|
|
252
|
+
fontWeight: 400,
|
|
253
|
+
fontFamily: 'PingFang SC',
|
|
254
|
+
},
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
const columnToggleImage = new Image({
|
|
258
|
+
name: 'table-control-toggle-group',
|
|
259
|
+
style: {
|
|
260
|
+
x: TABLE_OPERATE_ICON_X,
|
|
261
|
+
y: 10,
|
|
262
|
+
width: 44,
|
|
263
|
+
height: 16,
|
|
264
|
+
img: isOpen ? tableShowLess : tableShowMore,
|
|
265
|
+
zIndex: 1,
|
|
266
|
+
cursor: 'pointer',
|
|
267
|
+
},
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
columnToggleImage.addEventListener('click', () => {
|
|
271
|
+
lineageManager.emit(ETableEvents.CONTROL_TOGGLE_GROUP, this);
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
tableControlGroup.appendChild(columnCountText);
|
|
275
|
+
tableControlGroup.appendChild(columnToggleImage);
|
|
276
|
+
this.container.appendChild(tableControlGroup);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
calculatePaginationData() {
|
|
280
|
+
const { data, pagination } = this.config;
|
|
281
|
+
const { columnCount = 0 } = data;
|
|
282
|
+
|
|
283
|
+
const totalPage = Math.ceil(columnCount / pagination.pageSize);
|
|
284
|
+
this.config.pagination = {
|
|
285
|
+
...pagination,
|
|
286
|
+
totalPage,
|
|
287
|
+
total: columnCount,
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
renderColumns() {
|
|
292
|
+
const { children, pagination, isActive, style, isRelated } = this.config;
|
|
293
|
+
// const { columnCount = 0 } = data;
|
|
294
|
+
|
|
295
|
+
const tableRelatedGroupHeight = this.tableRelatedGroup?.getBBox()?.height;
|
|
296
|
+
const relatedColsHeight = tableRelatedGroupHeight;
|
|
297
|
+
|
|
298
|
+
// table content group
|
|
299
|
+
this.tableContentGroup = new Group({
|
|
300
|
+
style: {
|
|
301
|
+
y: TABLE_HEADER_HEIGHT + relatedColsHeight + TABLE_CONTROL_BAR_HEIGHT,
|
|
302
|
+
zIndex: 3,
|
|
303
|
+
},
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
const sortVisibleColumns = children.sort((i, j) => {
|
|
307
|
+
return i.data.position - j.data.position;
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
const { pageNum, pageSize } = pagination;
|
|
311
|
+
const renderVisibleColumns = sortVisibleColumns.slice(
|
|
312
|
+
(pageNum - 1) * pageSize,
|
|
313
|
+
pageNum * pageSize,
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
// table columns group
|
|
317
|
+
this.colGroup = new Rect({
|
|
318
|
+
style: {
|
|
319
|
+
width: NODE_WIDTH,
|
|
320
|
+
height: renderVisibleColumns.length * COL_HEIGHT,
|
|
321
|
+
fill: '#F4F4F4',
|
|
322
|
+
zIndex: 2,
|
|
323
|
+
},
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
renderVisibleColumns.forEach((colConfig: IColumnConfig<IColResBase>, i) => {
|
|
327
|
+
const col = new ColumnNode(this.graph, colConfig, this, i);
|
|
328
|
+
|
|
329
|
+
// add or replace column DOM
|
|
330
|
+
const colIndex = this.children.findIndex((c) => c.id === col.id);
|
|
331
|
+
if (colIndex === -1) {
|
|
332
|
+
this.children.push(col);
|
|
333
|
+
} else {
|
|
334
|
+
this.children[colIndex] = col;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
this.colGroup.appendChild(col.container);
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
this.tableContentGroup.appendChild(this.colGroup);
|
|
341
|
+
this.container.appendChild(this.tableContentGroup);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
renderPagination() {
|
|
345
|
+
const { pagination } = this.config;
|
|
346
|
+
const { pageNum, totalPage } = pagination;
|
|
347
|
+
|
|
348
|
+
const colGroupHeight = this.colGroup.getBBox().height;
|
|
349
|
+
|
|
350
|
+
// pagination content group
|
|
351
|
+
const paginationGroup = new Group({
|
|
352
|
+
name: 'pagination-wrapper',
|
|
353
|
+
style: {
|
|
354
|
+
y: colGroupHeight,
|
|
355
|
+
zIndex: -1,
|
|
356
|
+
},
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
const paginationBgRect = new Rect({
|
|
360
|
+
name: 'pagination-bgRect',
|
|
361
|
+
style: {
|
|
362
|
+
fill: '#F4F4F4',
|
|
363
|
+
width: NODE_WIDTH,
|
|
364
|
+
radius: [0, 0, TABLE_RECT_BORDER_RADIUS, TABLE_RECT_BORDER_RADIUS],
|
|
365
|
+
height: 32,
|
|
366
|
+
},
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
const paginationTotalPage = new Text({
|
|
370
|
+
name: 'pagination-totalPage-text',
|
|
371
|
+
style: {
|
|
372
|
+
x: 12,
|
|
373
|
+
y: 20,
|
|
374
|
+
text: `共 ${totalPage} 页`,
|
|
375
|
+
fill: '#575757',
|
|
376
|
+
fontSize: 12,
|
|
377
|
+
fontWeight: 400,
|
|
378
|
+
fontFamily: 'PingFang SC',
|
|
379
|
+
zIndex: 2,
|
|
380
|
+
},
|
|
381
|
+
});
|
|
382
|
+
const textWidth = getTextDomWidth(pageNum + '', 12, 'Tahoma');
|
|
383
|
+
|
|
384
|
+
const middleX = 260 - textWidth;
|
|
385
|
+
const leftX = middleX - 23;
|
|
386
|
+
const rightX = middleX + textWidth + 7;
|
|
387
|
+
|
|
388
|
+
this.paginationPrevImage = new Image({
|
|
389
|
+
name: 'pagination-prev-image',
|
|
390
|
+
style: {
|
|
391
|
+
x: leftX,
|
|
392
|
+
y: 6,
|
|
393
|
+
width: PAGINATION_IMAGE_SIZE,
|
|
394
|
+
height: PAGINATION_IMAGE_SIZE,
|
|
395
|
+
img: tablePaginationPrev,
|
|
396
|
+
cursor: this.config.pagination.pageNum > 1 ? 'pointer' : 'not-allowed',
|
|
397
|
+
zIndex: 2,
|
|
398
|
+
opacity: this.config.pagination.pageNum > 1 ? 1 : 0.5,
|
|
399
|
+
},
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
this.paginationPrevImage.addEventListener('click', () => {
|
|
403
|
+
this.onPaginationPrev();
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
this.paginationPrevImage?.addEventListener('mousedown', () => {
|
|
407
|
+
if (this.config.pagination.pageNum > 1)
|
|
408
|
+
this.paginationPrevImage.setAttribute('img', tablePaginationPrevClick);
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
this.paginationPrevImage?.addEventListener('mouseup', () => {
|
|
412
|
+
if (this.config.pagination.pageNum > 1)
|
|
413
|
+
this.paginationPrevImage.setAttribute('img', tablePaginationPrev);
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
this.paginationPrevImage?.addEventListener('mouseenter', () => {
|
|
417
|
+
if (this.config.pagination.pageNum > 1)
|
|
418
|
+
this.paginationPrevImage.setAttribute('img', tablePaginationPrevHover);
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
this.paginationPrevImage?.addEventListener('mouseleave', () => {
|
|
422
|
+
if (this.config.pagination.pageNum > 1)
|
|
423
|
+
this.paginationPrevImage.setAttribute('img', tablePaginationPrev);
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
const paginationPageNum = new Text({
|
|
427
|
+
style: {
|
|
428
|
+
// x: 300 / 2 - textWidth / 2,
|
|
429
|
+
x: middleX,
|
|
430
|
+
y: 20,
|
|
431
|
+
text: pageNum,
|
|
432
|
+
fill: '#000',
|
|
433
|
+
fontSize: 12,
|
|
434
|
+
fontWeight: 400,
|
|
435
|
+
fontFamily: 'Tahoma',
|
|
436
|
+
cursor: 'pointer',
|
|
437
|
+
zIndex: 2,
|
|
438
|
+
},
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
this.paginationNextImage = new Image({
|
|
442
|
+
name: 'pagination-next-image',
|
|
443
|
+
style: {
|
|
444
|
+
x: rightX,
|
|
445
|
+
y: 6,
|
|
446
|
+
width: PAGINATION_IMAGE_SIZE,
|
|
447
|
+
height: PAGINATION_IMAGE_SIZE,
|
|
448
|
+
img: tablePaginationNext,
|
|
449
|
+
cursor:
|
|
450
|
+
this.config.pagination.pageNum < this.config.pagination.totalPage
|
|
451
|
+
? 'pointer'
|
|
452
|
+
: 'not-allowed',
|
|
453
|
+
zIndex: 2,
|
|
454
|
+
opacity:
|
|
455
|
+
this.config.pagination.pageNum < this.config.pagination.totalPage
|
|
456
|
+
? 1
|
|
457
|
+
: 0.5,
|
|
458
|
+
},
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
this.paginationNextImage.addEventListener('click', () => {
|
|
462
|
+
this.onPaginationNext();
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
this.paginationNextImage?.addEventListener('mousedown', () => {
|
|
466
|
+
if (this.config.pagination.pageNum < this.config.pagination.totalPage)
|
|
467
|
+
this.paginationNextImage.setAttribute('img', tablePaginationNextClick);
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
this.paginationNextImage?.addEventListener('mouseup', () => {
|
|
471
|
+
if (this.config.pagination.pageNum < this.config.pagination.totalPage)
|
|
472
|
+
this.paginationNextImage.setAttribute('img', tablePaginationNext);
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
this.paginationNextImage?.addEventListener('mouseenter', () => {
|
|
476
|
+
if (this.config.pagination.pageNum < this.config.pagination.totalPage)
|
|
477
|
+
this.paginationNextImage.setAttribute('img', tablePaginationNextHover);
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
this.paginationNextImage?.addEventListener('mouseleave', () => {
|
|
481
|
+
if (this.config.pagination.pageNum < this.config.pagination.totalPage)
|
|
482
|
+
this.paginationNextImage.setAttribute('img', tablePaginationNext);
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
paginationGroup.appendChild(paginationBgRect);
|
|
486
|
+
paginationGroup.appendChild(paginationTotalPage);
|
|
487
|
+
paginationGroup.appendChild(this.paginationPrevImage);
|
|
488
|
+
paginationGroup.appendChild(paginationPageNum);
|
|
489
|
+
paginationGroup.appendChild(this.paginationNextImage);
|
|
490
|
+
|
|
491
|
+
this.tableContentGroup.appendChild(paginationGroup);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
onPaginationPrev() {
|
|
495
|
+
const onlyShowRelated =
|
|
496
|
+
!!this.lineageManager?.rightKeyMenuManager?.onlyShowRelated;
|
|
497
|
+
|
|
498
|
+
if (!onlyShowRelated) {
|
|
499
|
+
this.lineageManager?.resetActiveNodes();
|
|
500
|
+
this.lineageManager?.resetRelatedNodes();
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
const { pagination } = this.config;
|
|
504
|
+
const { pageNum } = pagination;
|
|
505
|
+
if (pageNum === 1) return;
|
|
506
|
+
|
|
507
|
+
this.config.pagination = {
|
|
508
|
+
...pagination,
|
|
509
|
+
pageNum: pageNum - 1,
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
this.graph.update();
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
onPaginationNext() {
|
|
516
|
+
const onlyShowRelated =
|
|
517
|
+
!!this.lineageManager?.rightKeyMenuManager?.onlyShowRelated;
|
|
518
|
+
|
|
519
|
+
if (!onlyShowRelated) {
|
|
520
|
+
this.lineageManager?.resetActiveNodes();
|
|
521
|
+
this.lineageManager?.resetRelatedNodes();
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
const { pagination } = this.config;
|
|
525
|
+
const { pageNum, totalPage } = pagination;
|
|
526
|
+
if (pageNum === totalPage) return;
|
|
527
|
+
this.config.pagination = {
|
|
528
|
+
...pagination,
|
|
529
|
+
pageNum: pageNum + 1,
|
|
530
|
+
};
|
|
531
|
+
|
|
532
|
+
this.graph.update();
|
|
533
|
+
}
|
|
534
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './nodeStyle';
|