Skip to content

Commit b676fb1

Browse files
author
Maren Süwer
committed
Gesamtuebersicht Projectquality Widget fertiggestellt
1 parent f6a266a commit b676fb1

File tree

6 files changed

+123
-68
lines changed

6 files changed

+123
-68
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/projectquality/edit.html

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<style type="text/css"></style>
22
<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>
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>
1717
</form>
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
'use strict';
22

3-
sonarADFWidget.
4-
controller('qualityCtrl', qualityCtrl);
3+
sonarADFWidget.controller('qualityCtrl', qualityCtrl);
54

65
function qualityCtrl(data) {
76
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+
});
818
}

src/projectquality/view.html

Lines changed: 89 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,97 @@
11
<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-
}
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+
}
2544
</style>
2645

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-
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">
3352

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>
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>
4083
</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>
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>
4589
</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>
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>
5194
</div>
52-
</div>-->
95+
5396
</div>
97+

src/service.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ function sonarApi($http, $q) {
1515
}
1616

1717
function createApiUrlAllMyIssues(sonarUrl) {
18-
return sonarUrl + '/api/issues/search?assignees=pczora';//___me__'; //--> nur zum Testen, eigentlich ist es __me__!
18+
return sonarUrl + '/api/issues/search?assignees=__me__';//--> nur zum Testen, eigentlich ist es __me__!
1919
}
2020

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
}
2424

2525
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';
26+
return sonarUrl + '/api/resources?resource=' + projectname + '&metrics=coverage,blocker_violations,quality_gate_details';
2727
}
2828

2929
function getProjectTime(projectBeginn, projectEnd) {
@@ -32,13 +32,13 @@ function sonarApi($http, $q) {
3232
var today = new Date();
3333

3434
var maxDays = workingDaysBetweenDates(beginn, end);
35-
var daysLeft = workingDaysBetweenDates(today, end)
35+
var daysLeft = workingDaysBetweenDates(today, end);
3636

3737
return {
3838
'maxDays': maxDays,
3939
'daysLeft': daysLeft
4040
};
41-
41+
4242
}
4343

4444
function workingDaysBetweenDates(startDate, endDate) {
@@ -260,7 +260,7 @@ function sonarApi($http, $q) {
260260
'Accept': 'application/json'
261261
}
262262
}).then(function(response) {
263-
return response.data.issues;
263+
return response.data[0];
264264
});
265265
}
266266

src/sonar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ var sonarADFWidget = angular.module('adf.widget.sonar', ['adf.provider', 'chart.
135135
}
136136
})
137137
.widget('sonar-projectquality', {
138-
title: 'Sonar: Projectquality of a project',
139-
description: 'Displays status of the qualitygate, code coverage and blocker issues',
138+
title: 'Sonar: Projectquality of a Project',
139+
description: 'Displays Status of the Quality Gate, Code Coverage and Blocker Issues',
140140
templateUrl: '{widgetsPath}/sonar/src/projectquality/view.html',
141141
resolve: {
142142
data: function(sonarApi, config, sonarEndpoint) {

0 commit comments

Comments
 (0)