Skip to content

Commit ed8735b

Browse files
authored
Merge pull request #12 from msuewer/master
Widgets "Projectquality" & "My Issues"
2 parents 50fddb0 + b676fb1 commit ed8735b

File tree

9 files changed

+403
-4
lines changed

9 files changed

+403
-4
lines changed

src/compare/compare.controller.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ function editController($scope, $http, sonarApi, sonarEndpoint) {
3434
});
3535
}
3636
$scope.updateProjects();
37+
3738
}

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: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
'use strict';
2+
3+
sonarADFWidget.
4+
controller('sonarIssueCtrl', sonarIssueCtrl);
5+
6+
function sonarIssueCtrl(data, config) {
7+
var vm = this;
8+
9+
if (data.length != 0) {
10+
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+
}
68+
}
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;
90+
}
91+
return -severity;
92+
};
93+
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+
};
102+
}

src/issues/view.html

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<style type="text/css">
2+
.content{
3+
text-align: left;
4+
color: black;
5+
}
6+
.tagContent{
7+
color: grey;
8+
text-align: right;
9+
}
10+
.linesOfCode {
11+
background-color:#F0F0F0;
12+
margin-bottom: 0.5%;
13+
border-radius: 1px;
14+
}
15+
.heading {
16+
color: #1874CD;
17+
font-size: small;
18+
margin-top: 1%;
19+
}
20+
</style>
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)-->
27+
<div class="heading">
28+
<span ng-if="project.project" class="glyphicon glyphicon-folder-open"></span>
29+
{{project.project}}
30+
<span ng-if="project.subProject" class="glyphicon glyphicon-folder-open"></span>
31+
{{project.subProject}}
32+
<span ng-if="project.component" class="glyphicon glyphicon-file"></span>
33+
{{project.component}}</br>
34+
</div>
35+
<div class="content col-md-20">
36+
<div class="col-md-20 linesOfCode" ng-repeat="issue in project.projectIssue track by $index">
37+
38+
<table width="100%">
39+
<tr>
40+
<td width="80%" colspan="4"><b>{{issue.message}}</b></td>
41+
<td ng-if="issue.line">L{{issue.line}}</td>
42+
</tr>
43+
</table><table width="100%">
44+
<tr>
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}}
53+
</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>
58+
</tr>
59+
</table>
60+
</div>
61+
</div>
62+
</div>
63+
64+
</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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use strict';
2+
3+
sonarADFWidget.controller('qualityCtrl', qualityCtrl);
4+
5+
function qualityCtrl(data) {
6+
var vm = this;
7+
vm.name = data.name;
8+
9+
angular.forEach(data.msr, function (metric) {
10+
if (metric.key === "coverage") //going through all entries with if/elseif since there could miss some entries. So there is no special order
11+
vm.coverage = metric.frmt_val;
12+
else if (metric.key === "blocker_violations")
13+
vm.blocker = metric.frmt_val;
14+
else if (metric.key === "quality_gate_details") {
15+
vm.qualityGateStatus = metric.data.split('"')[3]; //structure of quality_gate_details: "level":"OK",...
16+
}
17+
});
18+
}

src/projectquality/view.html

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<style type="text/css">
2+
.content {
3+
text-align: right;
4+
color: black;
5+
}
6+
7+
.statusQualitygate {
8+
border-radius: 8px;
9+
margin-bottom: 2%;
10+
}
11+
12+
.codeCoverage {
13+
border-radius: 8px;
14+
background-color: #f0ad4e;
15+
margin-bottom: 2%;
16+
}
17+
18+
.blockerIssues {
19+
border-radius: 8px;
20+
background-color: #1B7DAA;
21+
}
22+
23+
.glyphiconStyle {
24+
float: left;
25+
font-size: 3em;
26+
margin-top: 25px;
27+
}
28+
29+
.error {
30+
background-color: #E43B53;
31+
}
32+
33+
.warning {
34+
background-color: #DD7800;
35+
}
36+
37+
.ok {
38+
background-color: #B5CA00;
39+
}
40+
41+
.unknown {
42+
background-color: #777777;
43+
}
44+
</style>
45+
46+
47+
<div class="alert alert-info" ng-if="!vm.name">
48+
Please configure the widget
49+
</div>
50+
51+
<div class="content col-md-12" ng-if="vm.name">
52+
53+
<div ng-switch on="vm.qualityGateStatus">
54+
<div ng-switch-when="OK">
55+
<div class="ok col-md-12 statusQualitygate">
56+
<span class="glyphicon glyphicon-ok glyphiconStyle"></span>
57+
<h1>Passed</h1>
58+
<h4>Quality Gate</h4>
59+
</div>
60+
</div>
61+
<div ng-switch-when="ERROR">
62+
<div class="error col-md-12 statusQualitygate">
63+
<span class="glyphicon glyphicon-remove glyphiconStyle"></span>
64+
<h1>Error</h1>
65+
<h4>Quality Gate</h4>
66+
</div>
67+
</div>
68+
<div ng-switch-when="WARNING">
69+
<div class="warning col-md-12 statusQualitygate">
70+
<span class="glyphicon glyphicon-info-sign glyphiconStyle"></span>
71+
<h1>Warning</h1>
72+
<h4>Quality Gate</h4>
73+
</div>
74+
</div>
75+
76+
<div ng-switch-default>
77+
<div class="unknown col-md-12 statusQualitygate">
78+
<span class="glyphicon glyphicon-question-sign glyphiconStyle"></span>
79+
<h1>unknown</h1>
80+
<h4>Quality Gate</h4>
81+
</div>
82+
</div>
83+
</div>
84+
85+
<div class="col-md-12 codeCoverage">
86+
<span class="glyphicon glyphicon-tasks glyphiconStyle"></span>
87+
<h1>{{vm.coverage||"unknown"}}</h1>
88+
<h4>Code Coverage</h4>
89+
</div>
90+
<div class="col-md-12 blockerIssues">
91+
<span class="glyphicon glyphicon-exclamation-sign glyphiconStyle"></span>
92+
<h1>{{vm.blocker||"unknown"}}</h1>
93+
<h4>Blocker Issues</h4>
94+
</div>
95+
96+
</div>
97+

0 commit comments

Comments
 (0)