Skip to content

Commit fe77112

Browse files
committed
add text to landscape nodes
1 parent 041febc commit fe77112

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

ui-modules/blueprint-composer/app/components/util/d3-blueprint-abstract.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,11 @@ export function D3BlueprintAbstract(container) {
473473
.duration(config.global.transitionDuration)
474474
.attr('opacity', (d)=>(d.data.hasIcon() ? 1 : 0))
475475
.attr('xlink:href', (d)=>(d.data.icon));
476+
nodeData.filter(isChildNode).select('.node-entity text')
477+
.text(trimChildNodeText)
478+
.transition()
479+
.duration(config.global.transitionDuration)
480+
.text(trimChildNodeText);
476481

477482
// Draw child nodes
478483
appendElements(entity.filter(isChildNode).selectAll('circle').data([2, 1, 0]).enter(), config.child);
@@ -848,8 +853,18 @@ export function D3BlueprintAbstract(container) {
848853
return 'New application';
849854
} else {
850855
let name = d.data.metadata.get('name');
851-
return name.length > config.root.maxNameLength ? name.substring(0, config.root.maxNameLength) + '...' : name
856+
return name.length > config.root.maxNameLength ? name.substring(0, config.root.maxNameLength-2) + '...' : name
857+
}
858+
}
859+
860+
let trimChildNodeText = bp.trimChildNodeText = (d) => {
861+
var name;
862+
if (!d.data.metadata.has('name') || d.data.metadata.get('name').length === 0) {
863+
name = d.data.metadata.get('type');
864+
} else {
865+
name = d.data.metadata.get('name');
852866
}
867+
return name.length > config.child.maxNameLength ? name.substring(0, config.child.maxNameLength-2) + '...' : name
853868
}
854869

855870
let isRootNode = bp.isRootNode = (d) => d.depth === 0;

ui-modules/blueprint-composer/app/components/util/d3-blueprint-landscape-view.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function D3BlueprintLandscapeView(container) {
2727
function updateLayout(blueprint, relationships, d3data) {
2828
// TODO new layout will be needed to give fill width
2929
let tree = d3.tree()
30-
.nodeSize([bp.config.child.width * 3, bp.config.child.height * 3])
30+
.nodeSize([bp.config.child.width * 2, bp.config.child.height * 3])
3131
.separation((right, left)=> {
3232
let maxColumnsBeforeExpand = 2;
3333
let adjuncts = bp.getImportantAdjuncts(left).length;
@@ -99,9 +99,10 @@ export function D3BlueprintLandscapeView(container) {
9999

100100
child: {
101101
radius: childRadius,
102-
width: 200,
102+
width: 250,
103103
height: 100,
104104
imgSize: 96,
105+
maxNameLength: 15,
105106

106107
shape: tagWithAttrs('rect', {
107108
x: (d) => -width(d)/2,
@@ -112,11 +113,18 @@ export function D3BlueprintLandscapeView(container) {
112113
ry: 15,
113114
class: (d)=>(`node-cluster node-cluster-${d}`)
114115
}),
116+
title: tagWithAttrs('text', {
117+
class: 'node-name',
118+
width: (d) => width(d) - bp.config.child.imgSize - 16,
119+
height,
120+
x: 40,
121+
y: 0,
122+
}),
115123
icon: tagWithAttrs('image', {
116124
class: 'node-icon',
117125
width: getPropertyFn('imgSize'),
118126
height: getPropertyFn('imgSize'),
119-
x: (d) => -width(d)/2 + 10,
127+
x: (d) => -width(d)/2 + 4,
120128
y: (d) => -getPropertyFn('imgSize')(d)/2,
121129
opacity: 0
122130
}),
@@ -136,14 +144,14 @@ export function D3BlueprintLandscapeView(container) {
136144

137145
dropzonePrev: {
138146
shape: tagWithAttrs('circle', {
139-
cx: -3*childRadius,
147+
cx: -4*childRadius,
140148
r: 3/5 * childRadius,
141149
class: 'dropzone dropzone-prev'
142150
}),
143151
},
144152
dropzoneNext: {
145153
shape: tagWithAttrs('circle', {
146-
cx: 3*childRadius,
154+
cx: 4*childRadius,
147155
r: 3/5 * childRadius,
148156
class: 'dropzone dropzone-next'
149157
}),

0 commit comments

Comments
 (0)