From 54db7f018442c091ed8f7d74d8372fb59248658b Mon Sep 17 00:00:00 2001 From: monitobeko Date: Thu, 1 Sep 2016 18:02:57 +0300 Subject: [PATCH] Fixed Pipelines not being displayed correctly if there are no Permissions it's Pipeline Group #228 --- .../controllers/pipelines.controller.js | 56 +++++++++++++------ 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/Server/ui/src/app/pipelines/controllers/pipelines.controller.js b/Server/ui/src/app/pipelines/controllers/pipelines.controller.js index f692dc6e..1f504956 100644 --- a/Server/ui/src/app/pipelines/controllers/pipelines.controller.js +++ b/Server/ui/src/app/pipelines/controllers/pipelines.controller.js @@ -30,6 +30,7 @@ angular return viewModel.allPipelines }, function(newVal, oldVal) { vm.allPipelines = angular.copy(viewModel.allPipelines); + vm.allPipelineGroups = angular.copy(viewModel.allPipelineGroups); if(vm.allPipelineRuns.length > 0) { vm.allPipelineRuns.forEach(function (currentPipelineRun, index, array) { vm.allPipelines.forEach(function (currentPipeline, pipelineIndex, array) { @@ -43,21 +44,30 @@ angular vm.allPipelines.forEach(function (currentPipeline, pipelineIndex, pipelineArray) { currentPipeline.disabled = false; var isContained = false; + var groupNames = []; vm.allPipelineGroups.forEach(function (currentPipelineGroup, pipelineGroupIndex, pipelineGroupArray) { - if(currentPipeline.pipelineGroupId == currentPipelineGroup.id) { + if($.grep(currentPipelineGroup.pipelines, function(obj) { return obj.id == currentPipeline.id}).length > 0){ isContained = true; } + groupNames.push(currentPipelineGroup.name); }); if(!isContained && currentPipeline.pipelineGroupId != ''){ - var newGroup = {}; - newGroup.name = currentPipeline.groupName; - newGroup.id = currentPipeline.pipelineGroupId; - if(newGroup.pipelines == null){ - newGroup.pipelines = []; + var groupIndex = $.inArray(currentPipeline.groupName, groupNames); + debugger; + if(groupIndex > -1){ + vm.allPipelineGroups[groupIndex].pipelines.push(currentPipeline); + } else { + var newGroup = {}; + newGroup.name = currentPipeline.groupName; + newGroup.id = currentPipeline.pipelineGroupId; + vm.allPipelineGroups.push(newGroup); + if(newGroup.pipelines == null){ + newGroup.pipelines = []; + } + newGroup.pipelines.push(currentPipeline); + newGroup.permissionType = 'VIEWER'; } - newGroup.pipelines.push(currentPipeline); - newGroup.permissionType = 'VIEWER'; - vm.allPipelineGroups.push(newGroup); + } }); console.log(vm.allPipelines); @@ -103,21 +113,31 @@ angular vm.allPipelines.forEach(function (currentPipeline, pipelineIndex, pipelineArray) { currentPipeline.disabled = false; var isContained = false; + var groupNames = []; vm.allPipelineGroups.forEach(function (currentPipelineGroup, pipelineGroupIndex, pipelineGroupArray) { if(currentPipeline.pipelineGroupId == currentPipelineGroup.id) { - isContained = true; + if($.grep(currentPipelineGroup.pipelines, function(obj) { return obj.id == currentPipeline.id}).length > 0){ + isContained = true; + } } + groupNames.push(currentPipelineGroup.name); }); if(!isContained && currentPipeline.pipelineGroupId != ''){ - var newGroup = {}; - newGroup.name = currentPipeline.groupName; - newGroup.id = currentPipeline.pipelineGroupId; - if(newGroup.pipelines == null){ - newGroup.pipelines = []; + var groupIndex = $.inArray(currentPipeline.groupName, groupNames); + debugger; + if(groupIndex > -1){ + vm.allPipelineGroups[groupIndex].pipelines.push(currentPipeline); + } else { + var newGroup = {}; + newGroup.name = currentPipeline.groupName; + newGroup.id = currentPipeline.pipelineGroupId; + vm.allPipelineGroups.push(newGroup); + if(newGroup.pipelines == null){ + newGroup.pipelines = []; + } + newGroup.pipelines.push(currentPipeline); + newGroup.permissionType = 'VIEWER'; } - newGroup.pipelines.push(currentPipeline); - newGroup.permissionType = 'VIEWER'; - vm.allPipelineGroups.push(newGroup); } }); console.log(vm.allPipelineGroups);