OLD | NEW |
1 'use strict'; | 1 'use strict'; |
2 | 2 |
3 YUI.add('juju-topology-relation', function(Y) { | 3 YUI.add('juju-topology-relation', function(Y) { |
4 var views = Y.namespace('juju.views'), | 4 var views = Y.namespace('juju.views'), |
5 models = Y.namespace('juju.models'), | 5 models = Y.namespace('juju.models'), |
6 utils = Y.namespace('juju.views.utils'), | 6 utils = Y.namespace('juju.views.utils'), |
7 d3ns = Y.namespace('d3'), | 7 d3ns = Y.namespace('d3'), |
8 Templates = views.Templates; | 8 Templates = views.Templates; |
9 | 9 |
10 /** | 10 /** |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 render: function() { | 60 render: function() { |
61 RelationModule.superclass.render.apply(this, arguments); | 61 RelationModule.superclass.render.apply(this, arguments); |
62 return this; | 62 return this; |
63 }, | 63 }, |
64 | 64 |
65 update: function() { | 65 update: function() { |
66 RelationModule.superclass.update.apply(this, arguments); | 66 RelationModule.superclass.update.apply(this, arguments); |
67 | 67 |
68 var topo = this.get('component'); | 68 var topo = this.get('component'); |
69 var db = topo.get('db'); | 69 var db = topo.get('db'); |
| 70 var self = this; |
70 var relations = db.relations.toArray(); | 71 var relations = db.relations.toArray(); |
71 this.relPairs = this.processRelations(relations); | 72 this.relPairs = this.processRelations(relations); |
72 topo.relPairs = this.relPairs; | 73 topo.relPairs = this.relPairs; |
73 this.updateLinks(); | 74 this.updateLinks(); |
74 this.updateSubordinateRelationsCount(); | 75 this.updateSubordinateRelationsCount(); |
75 | 76 |
| 77 // Ensure that link endpoints are up-to-date. |
| 78 Y.each(topo.service_boxes, function(svc, key) { |
| 79 self.updateLinkEndpoints({ service: svc }); |
| 80 }); |
| 81 |
76 return this; | 82 return this; |
77 }, | 83 }, |
78 | 84 |
79 renderedHandler: function() { | 85 renderedHandler: function() { |
80 this.update(); | 86 this.update(); |
81 }, | 87 }, |
82 | 88 |
83 processRelation: function(r) { | 89 processRelation: function(r) { |
84 var self = this; | 90 var self = this; |
85 var topo = self.get('component'); | 91 var topo = self.get('component'); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 /** | 135 /** |
130 * Update relation line endpoints for a given service. | 136 * Update relation line endpoints for a given service. |
131 * | 137 * |
132 * @method updateLinkEndpoints | 138 * @method updateLinkEndpoints |
133 * @param {Object} service The service module that has been moved. | 139 * @param {Object} service The service module that has been moved. |
134 */ | 140 */ |
135 updateLinkEndpoints: function(evt) { | 141 updateLinkEndpoints: function(evt) { |
136 var self = this; | 142 var self = this; |
137 var service = evt.service; | 143 var service = evt.service; |
138 Y.each(Y.Array.filter(self.relPairs, function(relation) { | 144 Y.each(Y.Array.filter(self.relPairs, function(relation) { |
139 return relation.source() === service || | 145 return relation.source().id === service.id || |
140 relation.target() === service; | 146 relation.target().id === service.id; |
141 }), function(relation) { | 147 }), function(relation) { |
142 var rel_group = d3.select('#' + relation.id); | 148 var rel_group = d3.select('#' + relation.id); |
143 var connectors = relation.source() | 149 var connectors = relation.source() |
144 .getConnectorPair(relation.target()); | 150 .getConnectorPair(relation.target()); |
145 var s = connectors[0]; | 151 var s = connectors[0]; |
146 var t = connectors[1]; | 152 var t = connectors[1]; |
147 rel_group.select('line') | 153 rel_group.select('line') |
148 .attr('x1', s[0]) | 154 .attr('x1', s[0]) |
149 .attr('y1', s[1]) | 155 .attr('y1', s[1]) |
150 .attr('x2', t[0]) | 156 .attr('x2', t[0]) |
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 }, '0.1.0', { | 866 }, '0.1.0', { |
861 requires: [ | 867 requires: [ |
862 'd3', | 868 'd3', |
863 'd3-components', | 869 'd3-components', |
864 'node', | 870 'node', |
865 'event', | 871 'event', |
866 'juju-models', | 872 'juju-models', |
867 'juju-env' | 873 'juju-env' |
868 ] | 874 ] |
869 }); | 875 }); |
OLD | NEW |