Skip to content

Commit f6a266a

Browse files
author
Maren Süwer
committed
Widget AllMyIssues added and finished, started to implemented ProjectQuality
1 parent 95e4769 commit f6a266a

File tree

8 files changed

+262
-78
lines changed

8 files changed

+262
-78
lines changed

src/issues/edit.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<div class="form-group">
2+
<form role="form">
3+
<div class="form-group">
4+
<label for="sample">API-URL</label>
5+
<input type="text" class="form-control" id="sample" ng-model="config.apiUrl" placeholder="Sonar-URL">
6+
</div>
7+
</form>
8+
<form role="form">
9+
<div class="form-group">
10+
<label for="sample">Sorting</label>
11+
<select class="form-control" id="sample" ng-model="config.sorting" placeholder="Test">
12+
<option value="" disabled selected>Select your option</option>
13+
<option value="sortByEffort">Sorting by Effort</option>
14+
<option value="sortBySeverity">Sorting by Severity</option>
15+
</select>
16+
</div>
17+
</form>
18+
</div>

src/issues/issue.controller.js

Lines changed: 90 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,60 +3,100 @@
33
sonarADFWidget.
44
controller('sonarIssueCtrl', sonarIssueCtrl);
55

6-
function sonarIssueCtrl(data) {
6+
function sonarIssueCtrl(data, config) {
77
var vm = this;
88

9+
if (data.length != 0) {
910

10-
angular.forEach(data, function (issue) {
11-
issue.subProject = issue.subProject.slice(issue.component.search(":") + 1).replace(":", " ");
12-
issue.project = issue.project.slice(issue.component.search(":") + 1).replace(":", " "); //eig wird noch "parent" abgeschnitten, aber keine Ahnung warum!
13-
issue.component = issue.component.slice(issue.component.lastIndexOf(":") + 1);
14-
15-
issue.status = issue.status.toLowerCase();
16-
issue.severity = issue.severity.toLowerCase();
17-
issue.type = issue.type.toLowerCase().replace("_", " ");
18-
19-
for(var i=0; i<issue.tags.length; i++){
20-
if(i==0)
21-
issue.tag= issue.tags[i];
22-
else {
23-
issue.tag = issue.tag + ", ";
24-
issue.tag = issue.tag + issue.tags[i];
25-
}
11+
angular.forEach(data, function (issue) {
12+
13+
// Preparing displaying of issue components
14+
if (issue.subProject)
15+
issue.subProject = issue.subProject.slice(issue.component.search(":") + 1).replace(":", " ");
16+
if (issue.project)
17+
issue.project = issue.project.slice(issue.component.search(":") + 1).replace(":", " "); //eig wird noch "parent" abgeschnitten, aber keine Ahnung warum!
18+
if (issue.component)
19+
issue.component = issue.component.slice(issue.component.lastIndexOf(":") + 1);
20+
21+
if (issue.type)
22+
issue.type = issue.type.replace("_", " ");
23+
24+
for (var i = 0; i < issue.tags.length; i++) {
25+
if (i == 0)
26+
issue.tag = issue.tags[i];
27+
else
28+
issue.tag = issue.tag + ", " + issue.tags[i];
29+
}
30+
});
31+
32+
// sorting the elements by project, subProject and component
33+
// has the structure: projects [project, subProject, component, projectIssues[]]
34+
vm.projects = new Array();
35+
vm.projects[0] = new Object();
36+
37+
var counter = 0; //counting the projects
38+
var counter2 = 1; //counting the projectIssues per project
39+
for (var i = 0; i < data.length; i++) {
40+
41+
if (data[i].status !== "CLOSED") {
42+
43+
if (!vm.projects[counter].project) { //first initialisation of an object
44+
vm.projects[counter] = new Object();
45+
vm.projects[counter].project = data[i].project;
46+
vm.projects[counter].subProject = data[i].subProject;
47+
vm.projects[counter].component = data[i].component;
48+
vm.projects[counter].projectIssue = new Array();
49+
vm.projects[counter].projectIssue[0] = data[i];
50+
} else { //if there is already an object in vm.projects
51+
if (data[i].project === vm.projects[counter].project
52+
&& data[i].subProject === vm.projects[counter].subProject
53+
&& data[i].component === vm.projects[counter].component) {
54+
vm.projects[counter].projectIssue[counter2] = data[i];
55+
counter2 = counter2 + 1;
56+
} else {
57+
counter = counter + 1;
58+
counter2 = 1;
59+
vm.projects[counter] = new Object();
60+
vm.projects[counter].project = data[i].project;
61+
vm.projects[counter].subProject = data[i].subProject;
62+
vm.projects[counter].component = data[i].component;
63+
vm.projects[counter].projectIssue = new Array;
64+
vm.projects[counter].projectIssue[0] = data[i];
65+
}
66+
}
67+
}
2668
}
27-
});
28-
29-
// sorting the elements by project, subProject and component
30-
// has the structure: projects [project, subProject, component, projectIssues]
31-
vm.projects = new Array();
32-
vm.projects[0] = new Object();
33-
vm.projects[0].project = data[0].project;
34-
vm.projects[0].subProject = data[0].subProject;
35-
vm.projects[0].component = data[0].component;
36-
vm.projects[0].projectIssue = new Array();
37-
vm.projects[0].projectIssue[0] = data[0];
38-
39-
var counter = 0; //counting the projects
40-
var counter2 = 1; //counting the projectIssues per project
41-
for (var i = 1; i < data.length; i++) {
42-
if (data[i].project == vm.projects[counter].project
43-
&& data[i].subProject == vm.projects[counter].subProject
44-
&& data[i].component == vm.projects[counter].component) {
45-
vm.projects[counter].projectIssue[counter2] = data[i];
46-
counter2 = counter2 + 1;
47-
} else {
48-
counter = counter + 1;
49-
counter2 = 1;
50-
vm.projects[counter] = new Object();
51-
vm.projects[counter].project = data[i].project;
52-
vm.projects[counter].subProject = data[i].subProject;
53-
vm.projects[counter].component = data[i].component;
54-
vm.projects[counter].projectIssue = new Array;
55-
vm.projects[counter].projectIssue[0] = data[i];
69+
}
70+
71+
vm.sorting = function (issue) {
72+
if (config.sorting == "sortBySeverity")
73+
return vm.sortBySeverity(issue);
74+
else
75+
return vm.sortByEffort(issue);
76+
};
77+
78+
79+
vm.sortBySeverity = function (issue) {
80+
var severity = 0; //4=blocker, 3=critical, 2=major, 1=minor, 0=info
81+
for (var i = 0; i < issue.projectIssue.length; i++) {
82+
if (issue.projectIssue[i].severity === "BLOCKER")
83+
severity = 4;
84+
else if (issue.projectIssue[i].severity === "CRITICAL" && severity < 3)
85+
severity = 3;
86+
else if (issue.projectIssue[i].severity === "MAJOR" && severity < 2)
87+
severity = 2;
88+
else if (issue.projectIssue[i].severity === "MINOR" && severity < 1)
89+
severity = 1;
5690
}
91+
return -severity;
92+
};
5793

58-
}
59-
60-
61-
console.log(vm);
94+
vm.sortByEffort = function (issue) {
95+
var effort = 0;
96+
for (var i = 0; i < issue.projectIssue.length; i++) {
97+
if (issue.projectIssue[i].effort && effort < parseInt(issue.projectIssue[i].effort.slice(0, issue.projectIssue[i].effort.search("m"))))
98+
effort = parseInt(issue.projectIssue[i].effort.slice(0, issue.projectIssue[i].effort.search("m")));
99+
}
100+
return -effort;
101+
};
62102
}

src/issues/view.html

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
text-align: left;
44
color: black;
55
}
6+
.tagContent{
7+
color: grey;
8+
text-align: right;
9+
}
610
.linesOfCode {
711
background-color:#F0F0F0;
812
margin-bottom: 0.5%;
@@ -14,43 +18,43 @@
1418
margin-top: 1%;
1519
}
1620
</style>
17-
18-
<div>
19-
<div ng-if="!vm.projects" class="alert alert-info">
20-
You don't have any issues.
21-
</div>
22-
23-
<div ng-repeat="project in vm.projects">
21+
<div ng-if="!vm.projects" class="alert alert-info">
22+
You don't have any issues.
23+
</div>
24+
<div ng-if="vm.projects">
25+
26+
<div ng-repeat="project in vm.projects | orderBy: vm.sorting"> <!--(config.sorting?sortBySeverity:sortByEffort)-->
2427
<div class="heading">
25-
<span class="glyphicon glyphicon-folder-open"></span>
28+
<span ng-if="project.project" class="glyphicon glyphicon-folder-open"></span>
2629
{{project.project}}
27-
<span class="glyphicon glyphicon-folder-open"></span>
30+
<span ng-if="project.subProject" class="glyphicon glyphicon-folder-open"></span>
2831
{{project.subProject}}
29-
<span class="glyphicon glyphicon-file"></span>
32+
<span ng-if="project.component" class="glyphicon glyphicon-file"></span>
3033
{{project.component}}</br>
3134
</div>
3235
<div class="content col-md-20">
3336
<div class="col-md-20 linesOfCode" ng-repeat="issue in project.projectIssue track by $index">
3437

35-
<table width="1000">
38+
<table width="100%">
3639
<tr>
37-
<td width=80% colspan="4"><b>{{issue.message}}</b></td>
38-
<td ng-if="issue.line">L{{issue.line}}</td>
40+
<td width="80%" colspan="4"><b>{{issue.message}}</b></td>
41+
<td ng-if="issue.line">L{{issue.line}}</td>
3942
</tr>
43+
</table><table width="100%">
4044
<tr>
41-
<td>{{issue.type}}</td>
42-
<td>
43-
<span ng-if="issue.severity == 'major'" class="glyphicon glyphicon-chevron-up"></span>
44-
<span ng-if="issue.severity == 'minor'" class="glyphicon glyphicon-chevron-down"></span>
45-
<span ng-if="issue.severity == 'info'" class="glyphicon glyphicon-arrow-down"></span>
46-
<span ng-if="issue.severity == 'critical'" class="glyphicon glyphicon-arrow-up"></span>
47-
<span ng-if="issue.severity == 'blocker'" class="glyphicon glyphicon-exclamation-sign"></span>
48-
{{issue.severity}}
45+
<td width="15%">{{issue.type | lowercase}}</td>
46+
<td width="15%">
47+
<span ng-if="issue.severity == 'MAJOR'" class="glyphicon glyphicon-chevron-up"></span>
48+
<span ng-if="issue.severity == 'MINOR'" class="glyphicon glyphicon-chevron-down"></span>
49+
<span ng-if="issue.severity == 'INFO'" class="glyphicon glyphicon-arrow-down"></span>
50+
<span ng-if="issue.severity == 'CRITICAL'" class="glyphicon glyphicon-arrow-up"></span>
51+
<span ng-if="issue.severity == 'BLOCKER'" class="glyphicon glyphicon-exclamation-sign"></span>
52+
{{issue.severity | lowercase}}
4953
</td>
50-
<td>{{issue.status}}</td>
51-
<td ng-if="issue.effort" width="200"><span class="glyphicon glyphicon-time"></span> {{issue.effort}} effort</td>
52-
<td ng-if="!issue.effort" width="200"></td>
53-
<td><span ng-if="issue.tag" class="glyphicon glyphicon-tags"></span> {{issue.tag}}</td>
54+
<td width="15%">{{issue.status | lowercase}}</td>
55+
<td width="15%" ng-if="issue.effort"><span class="glyphicon glyphicon-time"></span> {{issue.effort}} effort</td>
56+
57+
<td class="tagContent"><span ng-if="issue.tag" class="glyphicon glyphicon-tags"></span> {{issue.tag}}</td>
5458
</tr>
5559
</table>
5660
</div>

src/projectquality/edit.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<style type="text/css"></style>
2+
<form role="form">
3+
<div class="form-group" ng-controller="editController as vm">
4+
<label for="sample">API-URL</label>
5+
<p>
6+
<input class="form-control" id="sample" ng-model="config.apiUrl" placeholder="Sonar-URL" type="text"
7+
ng-change="updateProjects()">
8+
</p>
9+
<label for="sample">Project</label>
10+
(*Required)
11+
<p>
12+
<input id="project" name="project" type="text" class="form-control" autocomplete="off"
13+
placeholder="Choose project" ng-model="config.project" required="true"
14+
uib-typeahead="project.name for project in vm.projects | limitTo:10 | filter:$viewValue"/>
15+
</p>
16+
</div>
17+
</form>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict';
2+
3+
sonarADFWidget.
4+
controller('qualityCtrl', qualityCtrl);
5+
6+
function qualityCtrl(data) {
7+
var vm = this;
8+
}

src/projectquality/view.html

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<style type="text/css">
2+
.content {
3+
text-align: right;
4+
color: white;
5+
}
6+
.coverage {
7+
background-color: #f0ad4e;
8+
border-radius: 8px;
9+
}
10+
.statusQualitygate {
11+
background-color: #337ab7;
12+
margin-bottom: 2%;
13+
border-radius: 8px;
14+
}
15+
.linesOfCodePencil {
16+
float: left;
17+
font-size: 3em;
18+
margin-top: 25px;
19+
}
20+
.coverageTask {
21+
float: left;
22+
font-size: 3em;
23+
margin-top: 25px;
24+
}
25+
</style>
26+
27+
<div>
28+
29+
<div class="col-md-6 statusQualitygate">Status Qualitygate</br></br></div>
30+
<div class="col-md-6 statusQualitygate">Code Coverage</div>
31+
<div class="col-md-6 statusQualitygate">Blocker Issues</div>
32+
33+
34+
<!--
35+
<div class="content col-md-12">
36+
<div class="col-md-12 statusQualitygate">
37+
<span class="glyphicon glyphicon-pencil linesOfCodePencil"></span>
38+
<h1>{{(vm.data.linesOfCode | number)||0}}</h1>
39+
<h4>Status Qualitygate</h4>
40+
</div>
41+
<div class="col-md-12 coverage">
42+
<span class="glyphicon glyphicon-tasks coverageTask"></span>
43+
<h1>{{(vm.data.coverage | number:2)||0}}%</h1>
44+
<h4>Code Coverage</h4>
45+
</div>
46+
47+
<div class="col-md-12 statusQualitygate">
48+
<span class="glyphicon glyphicon-tasks coverageTask"></span>
49+
<h1>{{(vm.data.coverage | number:2)||0}}%</h1>
50+
<h4>Blocker Issues</h4>
51+
</div>
52+
</div>-->
53+
</div>

src/service.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ function sonarApi($http, $q) {
2121
function createApiUrlMetrics(sonarUrl, projectname) {
2222
return sonarUrl + '/api/measures/component?componentKey=' + projectname + '&metricKeys=open_issues,ncloc,public_documented_api_density,duplicated_lines_density,sqale_index';
2323
}
24+
25+
function createApiUrlQuality(sonarUrl, projectname) {
26+
return sonarUrl + '/api/measures/component?componentKey=' + projectname + '&metricKeys=open_issues,ncloc,public_documented_api_density,duplicated_lines_density,sqale_index';
27+
}
2428

2529
function getProjectTime(projectBeginn, projectEnd) {
2630
var beginn = new Date(projectBeginn);
@@ -245,14 +249,29 @@ function sonarApi($http, $q) {
245249
return response.data.issues;
246250
});
247251
}
252+
253+
function getProjectquality(sonarUrl, project){
254+
var apiUrl = createApiUrlQuality(sonarUrl, project);
255+
256+
return $http({
257+
method: 'GET',
258+
url: apiUrl,
259+
headers: {
260+
'Accept': 'application/json'
261+
}
262+
}).then(function(response) {
263+
return response.data.issues;
264+
});
265+
}
248266

249267
return {
250268
getProjects: getProjects,
251269
getAllProjectsStatistics: getAllProjectsStatistics,
252270
getChartData: getChartData,
253271
getMetrics: getMetrics,
254272
getProjectTime: getProjectTime,
255-
getAllMyIssues: getAllMyIssues
273+
getAllMyIssues: getAllMyIssues,
274+
getProjectquality: getProjectquality
256275
};
257276

258277
}

0 commit comments

Comments
 (0)