Skip to content

Commit

Permalink
Merge pull request #399 from asifdxtreme/master
Browse files Browse the repository at this point in the history
Fix topology bug for multiple versions
  • Loading branch information
asifdxtreme committed Jul 24, 2018
2 parents 89e1378 + 709e1f0 commit aca35ba
Showing 1 changed file with 67 additions and 65 deletions.
132 changes: 67 additions & 65 deletions frontend/app/scripts/modules/topology/controllers/topologyCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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();
Expand All @@ -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 ? "<br> Providers : " + providers : "";
consumers = consumers.length > 0 ? "<br> Consumers : " + consumers : "";
status = showStatus ? "<br> Status : up" : "";
version = "<br> Version : " + service.microService.version;
registerBy = "<br> 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);
}
});
Expand All @@ -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);
}

}
]);
}]);

0 comments on commit aca35ba

Please sign in to comment.