diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-03-30 18:01:05 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-03-30 18:09:06 +0200 |
commit | de3909d2ba28c865268e3ed1b287c09bf82b98de (patch) | |
tree | 6fb6cc7cc472664a383d90af7491134b49b3afd7 /server/sonar-web/src | |
parent | 4366491d73efe1e5bd400c460c5918dbd11a0bb3 (diff) | |
download | sonarqube-de3909d2ba28c865268e3ed1b287c09bf82b98de.tar.gz sonarqube-de3909d2ba28c865268e3ed1b287c09bf82b98de.zip |
SONAR-6331 do not fail if any piece of information is missing
(cherry picked from commit 80e13ed)
Diffstat (limited to 'server/sonar-web/src')
4 files changed, 88 insertions, 52 deletions
diff --git a/server/sonar-web/src/main/hbs/overview/overview-issues.hbs b/server/sonar-web/src/main/hbs/overview/overview-issues.hbs index 2aa91ce663c..5a7ba8090c3 100644 --- a/server/sonar-web/src/main/hbs/overview/overview-issues.hbs +++ b/server/sonar-web/src/main/hbs/overview/overview-issues.hbs @@ -11,30 +11,34 @@ </div> </td> <td class="width-15"> - <a href="{{urlForIssuesOverview componentKey period1Date}}" - class="overview-measure {{#gt issues1 0}}text-danger{{else}}text-success{{/gt}}"> - {{formatMeasureVariation issues1 'INT'}} - </a> - <span class="note">new</span> - <p class="note">{{period1Name}}</p> + {{#notNull issues1}} + <a href="{{urlForIssuesOverview componentKey period1Date}}" + class="overview-measure {{#gt issues1 0}}text-danger{{else}}text-success{{/gt}}"> + {{formatMeasureVariation issues1 'INT'}} + </a> + <span class="note">new</span> + <p class="note">{{period1Name}}</p> + {{/notNull}} </td> <td class="width-15"> - <div style="display: inline-block; vertical-align: middle;"> + {{#notNull issues2}} <a href="{{urlForIssuesOverview componentKey period2Date}}" class="overview-measure {{#gt issues2 0}}text-danger{{else}}text-success{{/gt}}"> {{formatMeasureVariation issues2 'INT'}} </a> <span class="note">new</span> <p class="note">{{period2Name}}</p> - </div> + {{/notNull}} </td> <td class="width-15"> - <a href="{{urlForIssuesOverview componentKey period3Date}}" - class="overview-measure {{#gt issues3 0}}text-danger{{else}}text-success{{/gt}}"> - {{formatMeasureVariation issues3 'INT'}} - </a> - <span class="note">new</span> - <p class="note">{{period3Name}}</p> + {{#notNull issues3}} + <a href="{{urlForIssuesOverview componentKey period3Date}}" + class="overview-measure {{#gt issues3 0}}text-danger{{else}}text-success{{/gt}}"> + {{formatMeasureVariation issues3 'INT'}} + </a> + <span class="note">new</span> + <p class="note">{{period3Name}}</p> + {{/notNull}} </td> </tr> </table> diff --git a/server/sonar-web/src/main/js/overview/layout.js b/server/sonar-web/src/main/js/overview/layout.js index adca32d5261..5e83b9334fd 100644 --- a/server/sonar-web/src/main/js/overview/layout.js +++ b/server/sonar-web/src/main/js/overview/layout.js @@ -34,13 +34,15 @@ define([ }, modelEvents: { - 'change:gateConditions': 'toggleGate' + 'change': 'toggleRegions' }, - toggleGate: function () { + toggleRegions: function () { var conditions = this.model.get('gateConditions'), - hasGate = _.isArray(conditions) && conditions.length > 0; + hasGate = _.isArray(conditions) && conditions.length > 0, + hasCoverage = !!this.model.get('coverage'); this.$(this.gateRegion.el).toggle(hasGate); + this.$(this.coverageRegion.el).toggle(hasCoverage); } }); diff --git a/server/sonar-web/src/main/js/overview/models/state.js b/server/sonar-web/src/main/js/overview/models/state.js index 6bb3eb340be..10d51657a77 100644 --- a/server/sonar-web/src/main/js/overview/models/state.js +++ b/server/sonar-web/src/main/js/overview/models/state.js @@ -60,6 +60,9 @@ define(function () { metrics: 'quality_gate_details' }; return $.get(url, options).done(function (r) { + if (!r || !r[0] || !r[0].msr || !r[0].msr[0] || !r[0].msr[0].data) { + return; + } var gateData = JSON.parse(r[0].msr[0].data), gateConditions = gateData.conditions, urlMetrics = baseUrl + '/api/metrics'; @@ -106,21 +109,21 @@ define(function () { functionComplexityMeasure = _.findWhere(msr, { key: 'function_complexity' }), fileComplexityMeasure = _.findWhere(msr, { key: 'file_complexity' }); that.set({ - ncloc: nclocMeasure.val, - ncloc1: nclocMeasure.var1, - ncloc2: nclocMeasure.var2, - ncloc3: nclocMeasure.var3, + ncloc: nclocMeasure && nclocMeasure.val, + ncloc1: nclocMeasure && nclocMeasure.var1, + ncloc2: nclocMeasure && nclocMeasure.var2, + ncloc3: nclocMeasure && nclocMeasure.var3, nclocLang: nclocLang, - functionComplexity: functionComplexityMeasure.val, - functionComplexity1: functionComplexityMeasure.var1, - functionComplexity2: functionComplexityMeasure.var2, - functionComplexity3: functionComplexityMeasure.var3, + functionComplexity: functionComplexityMeasure && functionComplexityMeasure.val, + functionComplexity1: functionComplexityMeasure && functionComplexityMeasure.var1, + functionComplexity2: functionComplexityMeasure && functionComplexityMeasure.var2, + functionComplexity3: functionComplexityMeasure && functionComplexityMeasure.var3, - fileComplexity: fileComplexityMeasure.val, - fileComplexity1: fileComplexityMeasure.var1, - fileComplexity2: fileComplexityMeasure.var2, - fileComplexity3: fileComplexityMeasure.var3 + fileComplexity: fileComplexityMeasure && fileComplexityMeasure.val, + fileComplexity1: fileComplexityMeasure && fileComplexityMeasure.var1, + fileComplexity2: fileComplexityMeasure && fileComplexityMeasure.var2, + fileComplexity3: fileComplexityMeasure && fileComplexityMeasure.var3 }); }); }, @@ -177,6 +180,9 @@ define(function () { }, fetchIssues1: function () { + if (!this.get('period1Date')) { + return; + } var that = this, url = baseUrl + '/api/issues/search', options = { @@ -201,6 +207,9 @@ define(function () { }, fetchIssues2: function () { + if (!this.get('period2Date')) { + return; + } var that = this, url = baseUrl + '/api/issues/search', options = { @@ -225,6 +234,9 @@ define(function () { }, fetchIssues3: function () { + if (!this.get('period3Date')) { + return; + } var that = this, url = baseUrl + '/api/issues/search', options = { @@ -275,10 +287,10 @@ define(function () { var msr = r[0].msr, debtMeasure = _.findWhere(msr, { key: 'sqale_index' }); that.set({ - debt: debtMeasure.val, - debt1: debtMeasure.var1, - debt2: debtMeasure.var2, - debt3: debtMeasure.var3 + debt: debtMeasure && debtMeasure.val, + debt1: debtMeasure && debtMeasure.var1, + debt2: debtMeasure && debtMeasure.var2, + debt3: debtMeasure && debtMeasure.var3 }); }); }, @@ -311,13 +323,13 @@ define(function () { coverageMeasure = _.findWhere(msr, { key: 'overall_coverage' }), newCoverageMeasure = _.findWhere(msr, { key: 'new_overall_coverage' }); that.set({ - coverage: coverageMeasure.val, - coverage1: coverageMeasure.var1, - coverage2: coverageMeasure.var2, - coverage3: coverageMeasure.var3, - newCoverage1: newCoverageMeasure.var1, - newCoverage2: newCoverageMeasure.var2, - newCoverage3: newCoverageMeasure.var3 + coverage: coverageMeasure && coverageMeasure.val, + coverage1: coverageMeasure && coverageMeasure.var1, + coverage2: coverageMeasure && coverageMeasure.var2, + coverage3: coverageMeasure && coverageMeasure.var3, + newCoverage1: newCoverageMeasure && newCoverageMeasure.var1, + newCoverage2: newCoverageMeasure && newCoverageMeasure.var2, + newCoverage3: newCoverageMeasure && newCoverageMeasure.var3 }); }); }, @@ -349,10 +361,10 @@ define(function () { var msr = r[0].msr, duplicationsMeasure = _.findWhere(msr, { key: 'duplicated_lines_density' }); that.set({ - duplications: duplicationsMeasure.val, - duplications1: duplicationsMeasure.var1, - duplications2: duplicationsMeasure.var2, - duplications3: duplicationsMeasure.var3 + duplications: duplicationsMeasure && duplicationsMeasure.val, + duplications1: duplicationsMeasure && duplicationsMeasure.var1, + duplications2: duplicationsMeasure && duplicationsMeasure.var2, + duplications3: duplicationsMeasure && duplicationsMeasure.var3 }); }); }, diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/overview/index.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/overview/index.html.erb index 87de54463aa..4627c31d911 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/overview/index.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/overview/index.html.erb @@ -1,16 +1,34 @@ <div class="overview"></div> +<% + period1Name = short_period_label(@snapshot, 1) + period2Name = short_period_label(@snapshot, 2) + period3Name = short_period_label(@snapshot, 3) + + period1Date = @snapshot.period_datetime(1) + period2Date = @snapshot.period_datetime(2) + period3Date = @snapshot.period_datetime(3) +%> + <script> window.overviewConf = { - componentKey: '<%= @resource.key -%>', - componentUuid: '<%= @resource.uuid -%>', + <% if period1Date %> + period1Name: '<%= period1Name -%>', + period1Date: '<%= period1Date.strftime('%FT%T%z') -%>', + <% end %> - period1Name: '<%= short_period_label(@snapshot, 1) -%>', - period1Date: '<%= @snapshot.period_datetime(1).strftime('%FT%T%z') -%>', - period2Name: '<%= short_period_label(@snapshot, 2) -%>', - period2Date: '<%= @snapshot.period_datetime(2).strftime('%FT%T%z') -%>', - period3Name: '<%= short_period_label(@snapshot, 3) -%>', - period3Date: '<%= @snapshot.period_datetime(3).strftime('%FT%T%z') -%>' + <% if period2Date %> + period2Name: '<%= period2Name -%>', + period2Date: '<%= period2Date.strftime('%FT%T%z') -%>', + <% end %> + + <% if period3Date %> + period3Name: '<%= period3Name -%>', + period3Date: '<%= period3Date.strftime('%FT%T%z') -%>', + <% end %> + + componentKey: '<%= @resource.key -%>', + componentUuid: '<%= @resource.uuid -%>' }; require(['overview/app']); </script> |