From 709e1f059d202f2e6f5cd37c4893b52732fc8b56 Mon Sep 17 00:00:00 2001 From: asifdxtreme Date: Tue, 24 Jul 2018 13:10:24 +0530 Subject: [PATCH] Fix topology bug for multiple versions --- .../topology/controllers/topologyCtrl.js | 132 +++++++++--------- 1 file changed, 67 insertions(+), 65 deletions(-) diff --git a/frontend/app/scripts/modules/topology/controllers/topologyCtrl.js b/frontend/app/scripts/modules/topology/controllers/topologyCtrl.js index 314fae3ff..d7da99526 100644 --- a/frontend/app/scripts/modules/topology/controllers/topologyCtrl.js +++ b/frontend/app/scripts/modules/topology/controllers/topologyCtrl.js @@ -13,7 +13,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ 'use strict'; angular.module('serviceCenter.topology', []) .controller('topologyController', ['$scope', 'httpService', 'apiConstant', function($scope, httpService, apiConstant) { @@ -27,23 +27,23 @@ angular.module('serviceCenter.topology', []) var url = apiConstant.api.allServices.url; var method = apiConstant.api.allServices.method; - httpService.apiRequest(url, method).then(function(response){ + httpService.apiRequest(url, method).then(function(response) { $(".loader").hide(); - if(response && response.data && response.data.allServicesDetail && response.data.allServicesDetail.length > 0) { + if (response && response.data && response.data.allServicesDetail && response.data.allServicesDetail.length > 0) { $scope.allAppId.push("All"); $scope.appId = appId ? appId : "All"; $scope.allServicesDetail = response.data.allServicesDetail; - angular.forEach(response.data.allServicesDetail, function(service){ - if(!$scope.allAppId.includes(service.microService.appId) && service.microService.serviceName.toLowerCase() !== 'servicecenter') { + angular.forEach(response.data.allServicesDetail, function(service) { + if (!$scope.allAppId.includes(service.microService.appId) && service.microService.serviceName.toLowerCase() !== 'servicecenter') { $scope.allAppId.push(service.microService.appId); } }); - if($scope.appId === "All"){ + if ($scope.appId === "All") { $scope.microServices = []; $scope.prosAndCons = []; - angular.forEach($scope.allAppId, function(appId){ + angular.forEach($scope.allAppId, function(appId) { $scope.getDependencies(appId); }); createTopology(); @@ -58,55 +58,55 @@ angular.module('serviceCenter.topology', []) document.getElementById("topology").innerHTML = ""; } }, function(error) { - $(".loader").hide(); - $scope.allAppId = []; - document.getElementById("topology").innerHTML = ""; + $(".loader").hide(); + $scope.allAppId = []; + document.getElementById("topology").innerHTML = ""; }); } $scope.getServices(); $scope.getDependencies = function(appId) { - angular.forEach($scope.allServicesDetail, function(service){ - if(appId === service.microService.appId && service.microService.serviceName.toLowerCase() !== 'servicecenter'){ + angular.forEach($scope.allServicesDetail, function(service) { + if (appId === service.microService.appId && service.microService.serviceName.toLowerCase() !== 'servicecenter') { var objMic = {}; var providers = []; var consumers = []; var showStatus = false; var version, registerBy; - if(service.providers) { - angular.forEach(service.providers, function(provider){ + if (service.providers) { + angular.forEach(service.providers, function(provider) { var objPro = {}; - objPro.from = service.microService.serviceName + service.microService.appId; - objPro.to = provider.serviceName + service.microService.appId; + objPro.from = service.microService.serviceName + service.microService.appId + "#" + service.microService.version; + objPro.to = provider.serviceName + provider.appId + "#" + provider.version; $scope.prosAndCons.push(objPro); - providers.push(provider.serviceName); + providers.push(provider.serviceName + "#" + provider.version); }) } - if(service.consumers) { - angular.forEach(service.consumers, function(consumer){ - consumers.push(consumer.serviceName) + if (service.consumers) { + angular.forEach(service.consumers, function(consumer) { + consumers.push(consumer.serviceName + "#" + consumer.version) }) } - if(service.instances) { - angular.forEach(service.instances, function(instance){ - if(instance.status.toLowerCase() === 'up') { + if (service.instances) { + angular.forEach(service.instances, function(instance) { + if (instance.status.toLowerCase() === 'up') { showStatus = true; - } + } }) } - objMic.id = service.microService.serviceName + service.microService.appId; - objMic.label = service.microService.serviceName; + objMic.id = service.microService.serviceName + service.microService.appId + "#" + service.microService.version; + objMic.label = service.microService.serviceName + "#" + service.microService.version; providers = providers.length > 0 ? "
Providers : " + providers : ""; consumers = consumers.length > 0 ? "
Consumers : " + consumers : ""; status = showStatus ? "
Status : up" : ""; version = "
Version : " + service.microService.version; registerBy = "
Register By :" + service.microService.registerBy; - objMic.title = service.microService.serviceName + status + version + registerBy + providers + consumers; + objMic.title = service.microService.serviceName + status + version + registerBy + providers + consumers; $scope.microServices.push(objMic); } }); @@ -117,54 +117,56 @@ angular.module('serviceCenter.topology', []) var microServices = new vis.DataSet($scope.microServices); var prosAndCons = new vis.DataSet($scope.prosAndCons); var container = document.getElementById('topology'); - var data = { nodes: microServices, edges: prosAndCons }; var options = { - autoResize: false, - height: (screen.height - 300).toString(), - width: (screen.width - 325).toString(), - physics: { - enabled: true - }, - edges: { - arrows: { - to: {enabled: true, scaleFactor:1, type:'arrow'} - }, - arrowStrikethrough: false, - length: 170 - }, - nodes: { - shape: "circle", - color: { - border: "rgba(59,50,233,1)", - background: "rgb(255,255,255)", - highlight: { - border: "rgba(226,77,233,1)", - background: "rgba(130,38,255,1)" - }, - hover: { - border: "rgba(226,77,233,1)", - background: "rgba(130,38,255,1)" - } + autoResize: false, + height: (screen.height - 300).toString(), + width: (screen.width - 325).toString(), + physics: { + enabled: true + }, + edges: { + arrows: { + to: { + enabled: true, + scaleFactor: 1, + type: 'arrow' + } + }, + arrowStrikethrough: false, + length: 170 }, - font: { - size: 17 + nodes: { + shape: "circle", + color: { + border: "rgba(59,50,233,1)", + background: "rgb(255,255,255)", + highlight: { + border: "rgba(226,77,233,1)", + background: "rgba(130,38,255,1)" + }, + hover: { + border: "rgba(226,77,233,1)", + background: "rgba(130,38,255,1)" + } + }, + font: { + size: 17 + }, + shapeProperties: { + borderRadius: 5 + } }, - shapeProperties: { - borderRadius: 5 + interaction: { + navigationButtons: true, + hover: true } - }, - interaction: { - navigationButtons: true, - hover: true - } }; var topology = new vis.Network(container, data, options); } - } -]); \ No newline at end of file + }]); \ No newline at end of file