Skip to content

Commit

Permalink
Merge pull request #1 from capitalone/master
Browse files Browse the repository at this point in the history
Get Latest changes
  • Loading branch information
Satheesh-Balachandran authored Mar 14, 2018
2 parents 05fec13 + af0858e commit d9db993
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 30 deletions.
49 changes: 19 additions & 30 deletions UI/src/components/widgets/repo/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,28 @@
var ctrl = this;
var widgetConfig = modalData.widgetConfig;

ctrl.repoOptions = [{
name: 'GitHub',
value: 'GitHub'
}, {
name: 'Subversion',
value: 'Subversion'
},{
name: 'Bitbucket',
value: 'Bitbucket'
}, {
name: 'Gitlab',
value: 'Gitlab'
}];

if (!widgetConfig.options.scm) {
ctrl.repoOption="";
}
else
{
var myindex;
// Request collectors
collectorData.collectorsByType('scm').then(processCollectorsResponse);

function processCollectorsResponse(data) {
ctrl.collectors = data;

for (var v = 0; v < ctrl.repoOptions.length; v++) {
if (ctrl.repoOptions[v].name === widgetConfig.options.scm.name) {
myindex = v;
ctrl.repoOptions =[];
_(data).forEach(function (collector) {
ctrl.repoOptions.push({name:collector.name,value:collector.name});
});
var collector = modalData.dashboard.application.components[0].collectorItems.SCM;
var scmType = collector!=null? collector[0].options.scm: null;
var myIndex;
if(scmType!=null){
for (var v = 0; v < ctrl.repoOptions.length; v++) {
if (ctrl.repoOptions[v].name.toUpperCase() === scmType.toUpperCase()) {
myIndex = v;
}
}
ctrl.repoOption=ctrl.repoOptions[myIndex];
}
ctrl.repoOption=ctrl.repoOptions[myindex];

}

ctrl.repoUrl = removeGit(widgetConfig.options.url);
Expand All @@ -54,12 +49,7 @@
// public methods
ctrl.submit = submitForm;

// Request collecters
collectorData.collectorsByType('scm').then(processCollectorsResponse);

function processCollectorsResponse(data) {
ctrl.collectors = data;
}

/*
* function submitForm(valid, url) { ctrl.submitted = true; if (valid &&
Expand Down Expand Up @@ -191,7 +181,6 @@
name : "repo",
options : {
id : widgetConfig.options.id,
scm : ctrl.repoOption,
url : removeGit(ctrl.repoUrl),
branch : ctrl.gitBranch,
userID : getNonNullString(ctrl.repouser),
Expand Down
5 changes: 5 additions & 0 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-ldap</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>


<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.capitalone.dashboard.service;

import com.capitalone.dashboard.model.Collector;
import com.capitalone.dashboard.model.CollectorItem;
import com.capitalone.dashboard.model.CollectorType;
import com.capitalone.dashboard.repository.CollectorRepository;
import com.capitalone.dashboard.util.GitHubParsedUrl;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Aspect
@Component
public class CollectorServiceAspect {

private static final Logger LOGGER = LoggerFactory.getLogger(CollectorServiceAspect.class);

private final CollectorRepository collectorRepository;

@Autowired
public CollectorServiceAspect(CollectorRepository collectorRepository) {
this.collectorRepository = collectorRepository;
}

private boolean isGit(Collector collector) {
String name = collector.getName().toUpperCase();
boolean isGit = true;
switch (name) {
case "GITHUB":
isGit = true;
break;
case "SUBVERSION":
isGit = false;
break;
default:
isGit = true;
break;
}
return isGit;
}

private void normalizeOptions(CollectorItem item, Map<String, Object> uniqueOptions) {
Collector collector = collectorRepository.findOne(item.getCollectorId());
if (collector.getCollectorType() == CollectorType.SCM && isGit(collector)) {
String repoUrl = (String)uniqueOptions.get("url");
GitHubParsedUrl gitHubParsed = new GitHubParsedUrl(repoUrl);
uniqueOptions.put("url", gitHubParsed.getUrl());
}
}

@Before("execution(* com.capitalone.dashboard.service.CollectorService.createCollectorItemSelectOptions (com.capitalone.dashboard.model.CollectorItem, java.util.Map<String, Object>, java.util.Map<String, Object>)) && args(item, allOptions, uniqueOptions)")
public void normalizeCreateItem(CollectorItem item, Map<String, Object> allOptions, Map<String, Object> uniqueOptions) {
LOGGER.debug("normalizeCreateItem " + item.getNiceName());
normalizeOptions(item, uniqueOptions);
}
}

0 comments on commit d9db993

Please # to comment.