Skip to content

Commit

Permalink
feat: graph moveable, pk with emoji
Browse files Browse the repository at this point in the history
  • Loading branch information
alswl committed May 4, 2024
1 parent 3df86a8 commit 1cfe24f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ Ref: posts.user_id > users.id // many-to-one
vertexAddable: false,
vertexDeletable: false,
},
panning: true,
mousewheel: true,
});
graph.use(
new Snapline({
Expand Down
10 changes: 7 additions & 3 deletions src/parser/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ function parseFieldToPort(
schemaName: string,
tableName: string,
): any {
let label = field.name;
if (field.pk) {
label += ' 🔑';
}
return {
id: `${schemaName}-${tableName}-${field.name}`,
group: 'list',
attrs: {
portNameLabel: {
text: field.name,
text: label,
},
portTypeLabel: {
text: field.type.type_name || 'unknown',
Expand Down Expand Up @@ -68,7 +72,7 @@ function parseRef(ref: Ref): any {
attrs: {
label: {
text: source.relation,
stroke: '#aaa',
fontFamily: 'monospace',
},
},
position: 0.2,
Expand All @@ -77,7 +81,7 @@ function parseRef(ref: Ref): any {
attrs: {
label: {
text: target.relation,
stroke: '#aaa',
fontFamily: 'monospace',
},
},
position: 0.8,
Expand Down

0 comments on commit 1cfe24f

Please sign in to comment.