aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/sonar-web/src/main/hbs/source-viewer/measures/_source-viewer-measures-all.hbs40
-rw-r--r--server/sonar-web/src/main/hbs/source-viewer/measures/_source-viewer-measures-test-cases.hbs10
-rw-r--r--server/sonar-web/src/main/hbs/source-viewer/source-viewer-measures.hbs12
-rw-r--r--server/sonar-web/src/main/js/common/handlebars-extensions.js20
-rw-r--r--server/sonar-web/src/main/js/source-viewer/measures-overlay.js51
-rw-r--r--server/sonar-web/src/main/less/components/source.less4
6 files changed, 110 insertions, 27 deletions
diff --git a/server/sonar-web/src/main/hbs/source-viewer/measures/_source-viewer-measures-all.hbs b/server/sonar-web/src/main/hbs/source-viewer/measures/_source-viewer-measures-all.hbs
new file mode 100644
index 00000000000..e38b18ac92d
--- /dev/null
+++ b/server/sonar-web/src/main/hbs/source-viewer/measures/_source-viewer-measures-all.hbs
@@ -0,0 +1,40 @@
+<div class="source-viewer-measures-section source-viewer-measures-section-big">
+ {{#eachEven measuresToDisplay}}
+ <div class="source-viewer-measures-card">
+ <div class="measures">
+ <div class="measures-list">
+ <div class="measure measure-one-line measure-big">
+ <span class="measure-name">{{name}}</span>
+ </div>
+ {{#each metrics}}
+ <div class="measure measure-one-line" data-metric="{{key}}">
+ <span class="measure-name">{{name}}</span>
+ <span class="measure-value">&nbsp;{{value}}</span>
+ </div>
+ {{/each}}
+ </div>
+ </div>
+ </div>
+ {{/eachEven}}
+</div>
+
+<div class="source-viewer-measures-section source-viewer-measures-section-big">
+ {{#eachOdd measuresToDisplay}}
+ <div class="source-viewer-measures-card">
+ <div class="measures">
+ <div class="measures-list">
+ <div class="measure measure-one-line measure-big">
+ <span class="measure-name">{{name}}</span>
+ </div>
+ {{#each metrics}}
+ <div class="measure measure-one-line" data-metric="{{key}}">
+ <span class="measure-name">{{name}}</span>
+ <span class="measure-value">&nbsp;{{value}}</span>
+ </div>
+ {{/each}}
+ </div>
+ </div>
+ </div>
+ {{/eachOdd}}
+</div>
+
diff --git a/server/sonar-web/src/main/hbs/source-viewer/measures/_source-viewer-measures-test-cases.hbs b/server/sonar-web/src/main/hbs/source-viewer/measures/_source-viewer-measures-test-cases.hbs
index 50b6eecf3af..cda0b9112d0 100644
--- a/server/sonar-web/src/main/hbs/source-viewer/measures/_source-viewer-measures-test-cases.hbs
+++ b/server/sonar-web/src/main/hbs/source-viewer/measures/_source-viewer-measures-test-cases.hbs
@@ -43,9 +43,9 @@
</div>
</div>
-<div class="source-viewer-measures-section source-viewer-measures-section-big">
- <div class="source-viewer-measures-card source-viewer-measures-card-overflow">
- {{#if selectedTest}}
+{{#if selectedTest}}
+ <div class="source-viewer-measures-section source-viewer-measures-section-full">
+ <div class="source-viewer-measures-card source-viewer-measures-card-overflow">
{{#notEq selectedTest.status 'ERROR'}}
{{#notEq selectedTest.status 'FAILURE'}}
<div class="bubble-popup-title">{{t 'component_viewer.transition.covers'}}</div>
@@ -67,6 +67,6 @@
{{/if}}
<pre>{{selectedTest.stackTrace}}</pre>
{{/notEq}}
- {{/if}}
+ </div>
</div>
-</div>
+{{/if}}
diff --git a/server/sonar-web/src/main/hbs/source-viewer/source-viewer-measures.hbs b/server/sonar-web/src/main/hbs/source-viewer/source-viewer-measures.hbs
index 2f079986815..f119164a5a2 100644
--- a/server/sonar-web/src/main/hbs/source-viewer/source-viewer-measures.hbs
+++ b/server/sonar-web/src/main/hbs/source-viewer/source-viewer-measures.hbs
@@ -21,18 +21,14 @@
<div class="source-viewer-measures-section">
{{> '_source-viewer-measures-tests'}}
</div>
- <div class="source-viewer-measures-section">
- {{> '_source-viewer-measures-issues'}}
- </div>
+ {{> '_source-viewer-measures-test-cases'}}
{{/unless}}
</div>
-{{#if isUnitTest}}
- <div class="source-viewer-measures">
- {{> '_source-viewer-measures-test-cases'}}
- </div>
-{{/if}}
+<div class="source-viewer-measures">
+ {{> '_source-viewer-measures-all'}}
+</div>
<div class="modal-foot">
<a class="overlay-popup-close" title="{{t 'close'}}">{{t 'close'}}</a>
diff --git a/server/sonar-web/src/main/js/common/handlebars-extensions.js b/server/sonar-web/src/main/js/common/handlebars-extensions.js
index 2d0bd715144..f5e8e3cfe0b 100644
--- a/server/sonar-web/src/main/js/common/handlebars-extensions.js
+++ b/server/sonar-web/src/main/js/common/handlebars-extensions.js
@@ -132,6 +132,26 @@ define(['handlebars'], function (Handlebars) {
return ret;
});
+ Handlebars.registerHelper('eachEven', function (context, options) {
+ var ret = '';
+ context.forEach(function (d, i) {
+ if (i % 2 === 0) {
+ ret += options.fn(d);
+ }
+ });
+ return ret;
+ });
+
+ Handlebars.registerHelper('eachOdd', function (context, options) {
+ var ret = '';
+ context.forEach(function (d, i) {
+ if (i % 2 === 1) {
+ ret += options.fn(d);
+ }
+ });
+ return ret;
+ });
+
Handlebars.registerHelper('eq', function(v1, v2, options) {
// use `==` instead of `===` to ignore types
return v1 == v2 ? options.fn(this) : options.inverse(this);
diff --git a/server/sonar-web/src/main/js/source-viewer/measures-overlay.js b/server/sonar-web/src/main/js/source-viewer/measures-overlay.js
index 588a962cb72..f104ef39220 100644
--- a/server/sonar-web/src/main/js/source-viewer/measures-overlay.js
+++ b/server/sonar-web/src/main/js/source-viewer/measures-overlay.js
@@ -99,24 +99,34 @@ define([
});
},
+ getMetrics: function () {
+ var metrics = '',
+ url = baseUrl + '/api/metrics';
+ $.ajax({
+ url: url,
+ async: false
+ }).done(function (data) {
+ metrics = _.filter(data, function (metric) {
+ return !metric.hidden && metric.val_type !== 'DATA';
+ });
+ });
+ return metrics;
+ },
+
requestMeasures: function () {
var that = this,
url = baseUrl + '/api/resources',
+ metrics = this.getMetrics(),
options = {
resource: this.model.key(),
- metrics: [].concat(
- SOURCE_METRIC_LIST,
- COVERAGE_METRIC_LIST,
- ISSUES_METRIC_LIST,
- DUPLICATIONS_METRIC_LIST,
- TESTS_METRIC_LIST
- ).join()
- //metrics: 'true'
+ metrics: _.pluck(metrics, 'key').join()
};
return $.get(url, options).done(function (data) {
var measuresList = data[0].msr || [],
measures = that.model.get('measures') || {};
measuresList.forEach(function (m) {
+ var metric = _.findWhere(metrics, {key: m.key});
+ metric.value = m.frmt_val || m.data;
measures[m.key] = m.frmt_val || m.data;
measures[m.key + '_raw'] = m.val;
});
@@ -132,7 +142,20 @@ define([
if (measures.it_conditions_to_cover && measures.it_uncovered_conditions) {
measures.it_covered_conditions = measures.it_conditions_to_cover - measures.it_uncovered_conditions;
}
- that.model.set({ measures: measures });
+ metrics = _.filter(metrics, function (metric) {
+ return metric.value != null;
+ });
+ metrics = _.map(_.pairs(_.groupBy(metrics, 'domain')), function (domain) {
+ return {
+ name: domain[0],
+ metrics: domain[1]
+ };
+ });
+ console.log(metrics);
+ that.model.set({
+ measures: measures,
+ measuresToDisplay: metrics
+ });
});
},
@@ -147,7 +170,7 @@ define([
};
return $.get(url, options).done(function (data) {
var issuesFacets = {};
- data.facets.forEach(function(facet) {
+ data.facets.forEach(function (facet) {
issuesFacets[facet.property] = facet.values;
});
var severityOrder = ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO'],
@@ -172,9 +195,9 @@ define([
requestTests: function () {
var that = this,
url = baseUrl + '/api/tests/show',
- options = { key: this.model.key() };
+ options = {key: this.model.key()};
return $.get(url, options).done(function (data) {
- that.model.set({ tests: data.tests });
+ that.model.set({tests: data.tests});
that.sortTests('name');
that.testSorting = 'name';
});
@@ -183,7 +206,7 @@ define([
sortTests: function (condition) {
var tests = this.model.get('tests');
if (_.isArray(tests)) {
- this.model.set({ tests: _.sortBy(tests, condition) });
+ this.model.set({tests: _.sortBy(tests, condition)});
}
},
@@ -215,7 +238,7 @@ define([
};
return $.get(url, options).done(function (data) {
that.coveredFiles = data.files;
- that.selectedTest = _.findWhere(that.model.get('tests'), { name: name });
+ that.selectedTest = _.findWhere(that.model.get('tests'), {name: name});
that.render();
});
},
diff --git a/server/sonar-web/src/main/less/components/source.less b/server/sonar-web/src/main/less/components/source.less
index b715d1b8530..0468b6f0377 100644
--- a/server/sonar-web/src/main/less/components/source.less
+++ b/server/sonar-web/src/main/less/components/source.less
@@ -335,6 +335,10 @@
width: 100%;
}
+.source-viewer-measures-section + .source-viewer-measures-section-full {
+ margin-top: 20px;
+}
+
.source-viewer-measures-card {
margin: 20px 10px;
padding: 10px;