()
| 84 | } |
| 85 | |
| 86 | function restart(){ |
| 87 | if(node){ |
| 88 | node.on('mousedown',null); |
| 89 | node.on('mouseup',null); |
| 90 | } |
| 91 | |
| 92 | link = svg.selectAll('.link').data(LINKS); |
| 93 | node = svg.selectAll('.service').data(NODES); |
| 94 | |
| 95 | link.enter().insert('line', '.service') |
| 96 | .attr('class', 'link'); |
| 97 | |
| 98 | link.exit().remove(); |
| 99 | |
| 100 | var nodeEnter = node.enter().append('g').call(force.drag); |
| 101 | |
| 102 | nodeEnter |
| 103 | .append('circle') |
| 104 | .attr('r',NODE_MIN_RADIUS); |
| 105 | |
| 106 | nodeEnter.insert('g') |
| 107 | .classed('docker-image',true) |
| 108 | .html((d) => { |
| 109 | console.log(d); |
| 110 | //var image = d.image_name.split(':')[0] || []; |
| 111 | var image = d.image.split(':')[0] || []; |
| 112 | if(image.indexOf('haproxy') > -1){ |
| 113 | return icons.haproxy; |
| 114 | } |
| 115 | else if(image.indexOf('results-demo') > -1){ |
| 116 | return icons.angular; |
| 117 | } |
| 118 | else if(image.indexOf('voting-demo') > -1){ |
| 119 | return icons.python; |
| 120 | } |
| 121 | |
| 122 | var [namespace,imageName] = image.split('/'); |
| 123 | |
| 124 | if(!imageName){ |
| 125 | imageName = namespace; |
| 126 | namespace = 'library'; |
| 127 | } |
| 128 | |
| 129 | if(namespace === 'tutum') return icons.tutum; |
| 130 | |
| 131 | return icons[imageName] || (namespace === 'tutum' ? icons.tutum : icons.docker); |
| 132 | }) |
| 133 | .select('svg') |
| 134 | .attr('width',30) |
| 135 | .attr('height',30) |
| 136 | |
| 137 | var nodeEnterText = nodeEnter.append('text'); |
| 138 | |
| 139 | nodeEnterText |
| 140 | .append('tspan') |
| 141 | .classed('name',true) |
| 142 | .attr('dy', '.35em') |
| 143 |
no test coverage detected