Skip to content

Commit b3ac4be

Browse files
authored
Merge pull request #18 from angular-dashboard-framework/feature/SonarUpdate6.7LTS
Make widgets compatible to SonarQube 6.7 LTS
2 parents 099d57d + 0afde42 commit b3ac4be

File tree

14 files changed

+706
-357
lines changed

14 files changed

+706
-357
lines changed

dist/adf-widget-sonar.js

Lines changed: 339 additions & 176 deletions
Large diffs are not rendered by default.

dist/adf-widget-sonar.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/allProjects/stats.controller.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,13 @@ controller('sonarStatsCtrl', sonarStatsCtrl);
55

66
function sonarStatsCtrl(data){
77
var vm = this;
8-
vm.data = data;
8+
if (data){
9+
if (data.support){
10+
vm.support = data;
11+
}else{
12+
vm.data = data;
13+
}
14+
}
15+
16+
917
}

src/allProjects/view.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,19 @@
2828

2929
<div>
3030
<div class="sonar-content col-md-12">
31-
<div class="col-md-12 linesOfCode">
31+
32+
<div ng-if="vm.data.linesOfCode" class="col-md-12 linesOfCode">
3233
<span class="glyphicon glyphicon-pencil linesOfCodePencil"></span>
3334
<h1>{{(vm.data.linesOfCode | number)||0}}</h1>
3435
<h4>Lines of code</h4>
3536
</div>
36-
<div class="col-md-12 coverage">
37+
<div ng-if="vm.data.linesOfCode" class="col-md-12 coverage">
3738
<span class="glyphicon glyphicon-tasks coverageTask"></span>
3839
<h1>{{(vm.data.coverage | number:2)||0}}%</h1>
3940
<h4>Average test coverage</h4>
4041
</div>
4142
</div>
43+
<div class="alert alert-warning" ng-if="vm.support">
44+
{{vm.support.message}}
45+
</div>
4246
</div>

src/chart/lineChart.controller.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ sonarADFWidget.
66
function sonarLineChart(data, METRIC_NAMES) {
77
//initialize controller variable
88
var vm = this;
9-
if (data) {
10-
vm.chart = createChart();
9+
if (data != "Please Setup the Widget"){
10+
vm.chart = createChart();
1111
}
12-
1312
function createChart() {
1413
var options = {
1514
legend:{
@@ -32,7 +31,6 @@ function sonarLineChart(data, METRIC_NAMES) {
3231
}
3332

3433
chart.labels = data[0].dates;
35-
3634
return chart;
3735
}
3836
}

src/chart/view.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
<div class="alert alert-info" ng-if="!vm.chart">
22
Please configure the widget
33
</div>
4+
45
<div ng-if="vm.chart">
56
<canvas id="line" class="chart chart-line" chart-data="vm.chart.data" chart-labels="vm.chart.labels" chart-series="vm.chart.series"
67
chart-options="vm.chart.options">
78
</canvas>
8-
</div
9+
</div>
10+
11+

src/compare/compare.controller.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,24 @@
22

33
sonarADFWidget.controller('compare', compare);
44

5-
function compare(data,METRIC_NAMES) {
5+
function compare(data) {
66
var vm = this;
7-
8-
vm.METRIC_NAMES = METRIC_NAMES;
9-
vm.projectLeft = data.projectLeft;
10-
vm.projectRight = data.projectRight;
7+
if(data != "Please Setup the Widget"){
8+
vm.projectLeft = data.projectLeft.split(':')[1];
9+
vm.projectRight = data.projectRight.split(':')[1];
10+
var projectLeftMetrics = data.resp.projectLeft.data.component.measures;
11+
var projectRightMetrics = data.resp.projectRight.data.component.measures;
12+
var compareTable = [];
13+
angular.forEach(projectLeftMetrics, function (metricLeft) {
14+
angular.forEach(projectRightMetrics, function (metricRight) {
15+
if (metricRight.metric === metricLeft.metric) {
16+
compareTable.push({metricName: metricLeft.metric,
17+
projectValLeft: metricLeft.value, projectValRight: metricRight.value});
18+
}
19+
});
20+
});
21+
vm.compareTable = compareTable;
22+
}
1123

1224
}
1325

@@ -28,11 +40,11 @@ function editController($scope, $http, sonarApi, sonarEndpoint) {
2840
data.forEach(function(project) {
2941
var proj = {
3042
name: project.k
31-
}
43+
};
3244
vm.projects.push(proj);
3345
});
3446
});
35-
}
47+
};
3648
$scope.updateProjects();
3749

3850
}

src/compare/view.html

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
<div class="alert alert-info" ng-if="!vm.projectLeft">
1+
<div class="alert alert-info" ng-if="!vm.compareTable">
22
Please configure the widget
33
</div>
4-
<div ng-if="vm.projectLeft" class="col-md-12 centerText">
4+
<div ng-if="vm.compareTable" class="col-md-12 centerText">
5+
56

67
<table class="table">
78
<tr>
89
<th>Metric</th>
9-
<th>{{vm.projectLeft.data.component.name}}</th>
10-
<th>{{vm.projectRight.data.component.name}}</th>
10+
<th>{{vm.projectLeft}}</th>
11+
<th>{{vm.projectRight}}</th>
1112
</tr>
12-
<tr ng-repeat="metric in vm.projectLeft.data.component.measures">
13-
<td>{{vm.METRIC_NAMES[metric.metric]}}</td>
14-
<td>{{vm.projectLeft.data.component.measures[$index].value}}</td>
15-
<td>{{vm.projectRight.data.component.measures[$index].value}}</td>
13+
<tr ng-repeat="entry in vm.compareTable">
14+
<td>{{entry.metricName}}</td>
15+
<td>{{entry.projectValLeft}}</td>
16+
<td>{{entry.projectValRight}}</td>
1617
</tr>
1718
</table>
1819

src/projectquality/quality.controller.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,24 @@ sonarADFWidget.controller('qualityCtrl', qualityCtrl);
44

55
function qualityCtrl(data) {
66
var vm = this;
7-
vm.name = data.name;
7+
if(data!="Please Setup the Widget") {
88

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",...
9+
vm.project = data.project.split(':')[1];
10+
vm.url = data.url;
11+
12+
angular.forEach(data.quality_index, function (metric) {
13+
if (metric.metric === "coverage") //going through all entries with if/elseif since there could miss some entries. So there is no special order
14+
vm.coverage = metric.value;
15+
else if (metric.metric === "blocker_violations")
16+
vm.blocker = metric.value;
17+
else if (metric.metric === "alert_status") {
18+
vm.qualityGateStatus = metric.value;
19+
} else if (metric.metric === "sqale_index") {
20+
vm.technicalDept = metric.value;
21+
} else if (metric.metric === "vulnerabilities") {
22+
vm.vulnerabilities = metric.value;
1623
}
17-
});
24+
});
25+
}
26+
1827
}

src/projectquality/view.html

Lines changed: 50 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
11
<style type="text/css">
22

3-
div.sonar-content, div.sonar-content h1, div.sonar-content h4 {
3+
div.sonar-content, div.sonar-content h1, div.sonar-content h5 a{
44
text-align: right;
55
color: white;
66
}
77

8-
.statusQualitygate {
9-
border-radius: 8px;
10-
margin-bottom: 2%;
8+
h4#headline{
9+
color: white;
10+
border: 2px solid white;
11+
padding: 8px;
12+
text-align: center;
1113
}
1214

13-
.codeCoverage {
14-
border-radius: 8px;
15-
background-color: #fcc700;
15+
16+
div.sonar-content .statusQualitygate,div.sonar-content > .codeCoverage,
17+
div.sonar-content > .blockerIssues,div.sonar-content >.technicalDept,div.sonar-content >.vulnerabilities {
18+
border: 2px solid white;
1619
margin-bottom: 2%;
1720
}
1821

19-
.blockerIssues {
20-
border-radius: 8px;
22+
div.sonar-content >.codeCoverage,div.sonar-content >.technicalDept,div.sonar-content >.blockerIssues,
23+
div.sonar-content >.vulnerabilities, div.sonar-content>h4{
2124
background-color: #1B7DAA;
2225
}
2326

27+
2428
.glyphiconStyle {
2529
float: left;
26-
font-size: 3em;
30+
font-size: 2.5em;
2731
margin-top: 25px;
2832
}
2933

@@ -45,54 +49,64 @@
4549
</style>
4650

4751

48-
<div class="alert alert-info" ng-if="!vm.name">
52+
<div class="alert alert-info" ng-if="!vm.project">
4953
Please configure the widget
5054
</div>
5155

52-
<div class="sonar-content col-md-12" ng-if="vm.name">
53-
56+
<div class="sonar-content col-md-12" ng-if="vm.project">
57+
<h4 id="headline">{{vm.project}}</h4>
5458
<div ng-switch on="vm.qualityGateStatus">
5559
<div ng-switch-when="OK">
56-
<div class="ok col-md-12 statusQualitygate">
57-
<span class="glyphicon glyphicon-ok glyphiconStyle"></span>
58-
<h1>Passed</h1>
59-
<h4>Quality Gate</h4>
60+
<div class="ok col-md-6 statusQualitygate">
61+
<span class="glyphicon glyphicon-ok-sign glyphiconStyle"></span>
62+
<h1>OK</h1>
63+
<h5><a href="{{vm.url}}/quality_gates">Quality Gate</a></h5>
6064
</div>
6165
</div>
6266
<div ng-switch-when="ERROR">
63-
<div class="error col-md-12 statusQualitygate">
64-
<span class="glyphicon glyphicon-remove glyphiconStyle"></span>
65-
<h1>Failed</h1>
66-
<h4>Quality Gate</h4>
67+
<div class="error col-md-6 statusQualitygate">
68+
<h2>Failed</h2>
69+
<h5><a href="{{vm.url}}/quality_gates">Quality Gate</a></h5>
6770
</div>
6871
</div>
6972
<div ng-switch-when="WARNING">
70-
<div class="warning col-md-12 statusQualitygate">
71-
<span class="glyphicon glyphicon-info-sign glyphiconStyle"></span>
72-
<h1>Warning</h1>
73-
<h4>Quality Gate</h4>
73+
<div class="warning col-md-6 statusQualitygate">
74+
<h2>Warning</h2>
75+
<h5><a href="{{vm.url}}/quality_gates">Quality Gate</a></h5>
7476
</div>
7577
</div>
7678

7779
<div ng-switch-default>
78-
<div class="unknown col-md-12 statusQualitygate">
79-
<span class="glyphicon glyphicon-question-sign glyphiconStyle"></span>
80-
<h1>unknown</h1>
81-
<h4>Quality Gate</h4>
80+
<div class="unknown col-md-6 statusQualitygate">
81+
<h2>unknown</h2>
82+
<h5><a href="{{vm.url}}/quality_gates">Quality Gate</a></h5>
8283
</div>
8384
</div>
8485
</div>
8586

86-
<div class="col-md-12 codeCoverage">
87+
88+
<div class="col-md-6 vulnerabilities">
89+
<span class="glyphicon glyphicon glyphicon-lock glyphiconStyle"></span>
90+
<h1>{{vm.vulnerabilities}}</h1>
91+
<h5>Vulnerabilities</a></h5>
92+
</div>
93+
94+
95+
<div class="col-md-6 codeCoverage">
8796
<span class="glyphicon glyphicon-tasks glyphiconStyle"></span>
88-
<h1>{{vm.coverage||"unknown"}}</h1>
89-
<h4>Code Coverage</h4>
97+
<h1>{{vm.coverage||"/"}}</h1>
98+
<h5>Code Coverage</a></h5>
9099
</div>
91-
<div class="col-md-12 blockerIssues">
100+
<div class="col-md-6 blockerIssues">
92101
<span class="glyphicon glyphicon-exclamation-sign glyphiconStyle"></span>
93-
<h1>{{vm.blocker||"unknown"}}</h1>
94-
<h4>Blocker Issues</h4>
102+
<h1>{{vm.blocker||"/"}}</h1>
103+
<h5>Blocker Issues</a></h5>
95104
</div>
96-
105+
<div class="col-md-12 technicalDept">
106+
<span class="glyphicon glyphicon-time glyphiconStyle"></span>
107+
<h1>{{vm.technicalDept+" days" ||"/"}}</h1>
108+
<h5>Technical Dept</a></h5>
109+
</div>
110+
<a href="https://docs.sonarqube.org/latest/user-guide/metric-definitions/" class="pull-right">about metrics</a>
97111
</div>
98112

0 commit comments

Comments
 (0)