Skip to content

Commit aca35ba

Browse files
authored
Merge pull request #399 from asifdxtreme/master
Fix topology bug for multiple versions
2 parents 89e1378 + 709e1f0 commit aca35ba

File tree

1 file changed

+67
-65
lines changed

1 file changed

+67
-65
lines changed

frontend/app/scripts/modules/topology/controllers/topologyCtrl.js

Lines changed: 67 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
16-
*/
16+
*/
1717
'use strict';
1818
angular.module('serviceCenter.topology', [])
1919
.controller('topologyController', ['$scope', 'httpService', 'apiConstant', function($scope, httpService, apiConstant) {
@@ -27,23 +27,23 @@ angular.module('serviceCenter.topology', [])
2727

2828
var url = apiConstant.api.allServices.url;
2929
var method = apiConstant.api.allServices.method;
30-
httpService.apiRequest(url, method).then(function(response){
30+
httpService.apiRequest(url, method).then(function(response) {
3131
$(".loader").hide();
32-
if(response && response.data && response.data.allServicesDetail && response.data.allServicesDetail.length > 0) {
32+
if (response && response.data && response.data.allServicesDetail && response.data.allServicesDetail.length > 0) {
3333
$scope.allAppId.push("All");
3434
$scope.appId = appId ? appId : "All";
3535
$scope.allServicesDetail = response.data.allServicesDetail;
3636

37-
angular.forEach(response.data.allServicesDetail, function(service){
38-
if(!$scope.allAppId.includes(service.microService.appId) && service.microService.serviceName.toLowerCase() !== 'servicecenter') {
37+
angular.forEach(response.data.allServicesDetail, function(service) {
38+
if (!$scope.allAppId.includes(service.microService.appId) && service.microService.serviceName.toLowerCase() !== 'servicecenter') {
3939
$scope.allAppId.push(service.microService.appId);
4040
}
4141
});
4242

43-
if($scope.appId === "All"){
43+
if ($scope.appId === "All") {
4444
$scope.microServices = [];
4545
$scope.prosAndCons = [];
46-
angular.forEach($scope.allAppId, function(appId){
46+
angular.forEach($scope.allAppId, function(appId) {
4747
$scope.getDependencies(appId);
4848
});
4949
createTopology();
@@ -58,55 +58,55 @@ angular.module('serviceCenter.topology', [])
5858
document.getElementById("topology").innerHTML = "";
5959
}
6060
}, function(error) {
61-
$(".loader").hide();
62-
$scope.allAppId = [];
63-
document.getElementById("topology").innerHTML = "";
61+
$(".loader").hide();
62+
$scope.allAppId = [];
63+
document.getElementById("topology").innerHTML = "";
6464
});
6565
}
6666
$scope.getServices();
6767

6868
$scope.getDependencies = function(appId) {
69-
angular.forEach($scope.allServicesDetail, function(service){
70-
if(appId === service.microService.appId && service.microService.serviceName.toLowerCase() !== 'servicecenter'){
69+
angular.forEach($scope.allServicesDetail, function(service) {
70+
if (appId === service.microService.appId && service.microService.serviceName.toLowerCase() !== 'servicecenter') {
7171
var objMic = {};
7272
var providers = [];
7373
var consumers = [];
7474
var showStatus = false;
7575
var version, registerBy;
7676

77-
if(service.providers) {
78-
angular.forEach(service.providers, function(provider){
77+
if (service.providers) {
78+
angular.forEach(service.providers, function(provider) {
7979
var objPro = {};
80-
objPro.from = service.microService.serviceName + service.microService.appId;
81-
objPro.to = provider.serviceName + service.microService.appId;
80+
objPro.from = service.microService.serviceName + service.microService.appId + "#" + service.microService.version;
81+
objPro.to = provider.serviceName + provider.appId + "#" + provider.version;
8282
$scope.prosAndCons.push(objPro);
83-
providers.push(provider.serviceName);
83+
providers.push(provider.serviceName + "#" + provider.version);
8484
})
8585
}
8686

87-
if(service.consumers) {
88-
angular.forEach(service.consumers, function(consumer){
89-
consumers.push(consumer.serviceName)
87+
if (service.consumers) {
88+
angular.forEach(service.consumers, function(consumer) {
89+
consumers.push(consumer.serviceName + "#" + consumer.version)
9090
})
9191
}
9292

93-
if(service.instances) {
94-
angular.forEach(service.instances, function(instance){
95-
if(instance.status.toLowerCase() === 'up') {
93+
if (service.instances) {
94+
angular.forEach(service.instances, function(instance) {
95+
if (instance.status.toLowerCase() === 'up') {
9696
showStatus = true;
97-
}
97+
}
9898
})
9999
}
100100

101-
objMic.id = service.microService.serviceName + service.microService.appId;
102-
objMic.label = service.microService.serviceName;
101+
objMic.id = service.microService.serviceName + service.microService.appId + "#" + service.microService.version;
102+
objMic.label = service.microService.serviceName + "#" + service.microService.version;
103103

104104
providers = providers.length > 0 ? "<br> Providers : " + providers : "";
105105
consumers = consumers.length > 0 ? "<br> Consumers : " + consumers : "";
106106
status = showStatus ? "<br> Status : up" : "";
107107
version = "<br> Version : " + service.microService.version;
108108
registerBy = "<br> Register By :" + service.microService.registerBy;
109-
objMic.title = service.microService.serviceName + status + version + registerBy + providers + consumers;
109+
objMic.title = service.microService.serviceName + status + version + registerBy + providers + consumers;
110110
$scope.microServices.push(objMic);
111111
}
112112
});
@@ -117,54 +117,56 @@ angular.module('serviceCenter.topology', [])
117117
var microServices = new vis.DataSet($scope.microServices);
118118
var prosAndCons = new vis.DataSet($scope.prosAndCons);
119119
var container = document.getElementById('topology');
120-
121120
var data = {
122121
nodes: microServices,
123122
edges: prosAndCons
124123
};
125124

126125
var options = {
127-
autoResize: false,
128-
height: (screen.height - 300).toString(),
129-
width: (screen.width - 325).toString(),
130-
physics: {
131-
enabled: true
132-
},
133-
edges: {
134-
arrows: {
135-
to: {enabled: true, scaleFactor:1, type:'arrow'}
136-
},
137-
arrowStrikethrough: false,
138-
length: 170
139-
},
140-
nodes: {
141-
shape: "circle",
142-
color: {
143-
border: "rgba(59,50,233,1)",
144-
background: "rgb(255,255,255)",
145-
highlight: {
146-
border: "rgba(226,77,233,1)",
147-
background: "rgba(130,38,255,1)"
148-
},
149-
hover: {
150-
border: "rgba(226,77,233,1)",
151-
background: "rgba(130,38,255,1)"
152-
}
126+
autoResize: false,
127+
height: (screen.height - 300).toString(),
128+
width: (screen.width - 325).toString(),
129+
physics: {
130+
enabled: true
131+
},
132+
edges: {
133+
arrows: {
134+
to: {
135+
enabled: true,
136+
scaleFactor: 1,
137+
type: 'arrow'
138+
}
139+
},
140+
arrowStrikethrough: false,
141+
length: 170
153142
},
154-
font: {
155-
size: 17
143+
nodes: {
144+
shape: "circle",
145+
color: {
146+
border: "rgba(59,50,233,1)",
147+
background: "rgb(255,255,255)",
148+
highlight: {
149+
border: "rgba(226,77,233,1)",
150+
background: "rgba(130,38,255,1)"
151+
},
152+
hover: {
153+
border: "rgba(226,77,233,1)",
154+
background: "rgba(130,38,255,1)"
155+
}
156+
},
157+
font: {
158+
size: 17
159+
},
160+
shapeProperties: {
161+
borderRadius: 5
162+
}
156163
},
157-
shapeProperties: {
158-
borderRadius: 5
164+
interaction: {
165+
navigationButtons: true,
166+
hover: true
159167
}
160-
},
161-
interaction: {
162-
navigationButtons: true,
163-
hover: true
164-
}
165168
};
166169
var topology = new vis.Network(container, data, options);
167170
}
168171

169-
}
170-
]);
172+
}]);

0 commit comments

Comments
 (0)