aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2014-04-28 11:30:13 +0200
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2014-04-28 14:14:55 +0200
commite3a6ba3fd6a43896a718ead80a081540d0b24841 (patch)
treec3b47a725b2c0ade478ab800881d18bd0de8502a /plugins
parentadab7517ae4c4cfa293b5720b66fd7b5ec4e026b (diff)
downloadsonarqube-e3a6ba3fd6a43896a718ead80a081540d0b24841.tar.gz
sonarqube-e3a6ba3fd6a43896a718ead80a081540d0b24841.zip
SONAR-4927 Merge new QG widget with old one, update layout
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java1
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/AlertsWidget.java6
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/QualityGateWidget.java33
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/alerts.html.erb79
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/quality_gate.html.erb63
5 files changed, 73 insertions, 109 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
index 6268c9b7109..6a7499e2332 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
@@ -213,7 +213,6 @@ public final class CorePlugin extends SonarPlugin {
// widgets
AlertsWidget.class,
- QualityGateWidget.class,
CoverageWidget.class,
ItCoverageWidget.class,
DescriptionWidget.class,
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/AlertsWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/AlertsWidget.java
index 738d6153fb4..c794e898573 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/AlertsWidget.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/AlertsWidget.java
@@ -19,9 +19,11 @@
*/
package org.sonar.plugins.core.widgets;
-import org.sonar.api.web.WidgetLayout;
-import org.sonar.api.web.WidgetLayoutType;
+import org.sonar.api.web.*;
+@WidgetProperties({
+ @WidgetProperty(key = "show_ok", type = WidgetPropertyType.BOOLEAN, defaultValue = "false"),
+})
@WidgetLayout(WidgetLayoutType.NONE)
public class AlertsWidget extends CoreWidget {
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/QualityGateWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/QualityGateWidget.java
deleted file mode 100644
index dd7e1d0cf85..00000000000
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/QualityGateWidget.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.plugins.core.widgets;
-
-import org.sonar.api.web.*;
-
-@WidgetProperties({
- @WidgetProperty(key = "show_ok", type = WidgetPropertyType.BOOLEAN, defaultValue = "false"),
-})
-@WidgetLayout(WidgetLayoutType.NONE)
-public class QualityGateWidget extends CoreWidget {
-
- public QualityGateWidget() {
- super("quality_gate", "Quality Gate Details", "/org/sonar/plugins/core/widgets/quality_gate.html.erb");
- }
-}
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/alerts.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/alerts.html.erb
index 1f1f243340a..0b1c505466f 100644
--- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/alerts.html.erb
+++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/alerts.html.erb
@@ -1,14 +1,73 @@
+<% m=measure(Metric::QUALITY_GATE_DETAILS)
+ if m && !m.data.blank?
+ details = JSON.parse m.data
+ m.alert_status = details['level']
+ conditions = details['conditions']
+ alert_metric = metric(Metric::ALERT_STATUS)
+
+ warn_message = message('measure_filter.criteria.alert.warn')
+ error_message = message('measure_filter.criteria.alert.error')
+
+ css_class = "color_#{m.alert_status}"
+ if m.alert_status==Metric::TYPE_LEVEL_OK
+ label = "#{message('widget.alerts.no_alert')}."
+ elsif m.alert_status==Metric::TYPE_LEVEL_WARN
+ label = "#{message('widget.alerts.warnings')}"
+ else
+ label = "#{message('widget.alerts.errors')}"
+ end
+-%><div class="widget <%= css_class -%>" style="color: black !important" id="quality_gate_widget_<%= widget.id -%>">
+ <div><%= format_measure(measure(Metric::ALERT_STATUS)) -%> <%= label -%></div>
+ <% if conditions.any? {|condition| condition['level'] != 'OK'} || widget_properties['show_ok'] && !conditions.empty? -%>
+ <% details['conditions'].sort_by {|condition| [ -condition['level'].length, metric(condition['metric']).short_name] }.each do |condition|
+
+ level = condition['level']
+ condition_metric = metric(condition['metric'])
+ operator = message("quality_gates.operator.#{condition['op']}.short")
+ period = condition['period']
+ warning_value = condition['warning']
+ error_value = condition['error']
+ actual_value = condition['actual']
+
+ detail_measure = ProjectMeasure.new :metric => alert_metric, :alert_status => level
+
+ drilldown_url = period.blank? ? url_for_drilldown(condition_metric) : url_for_drilldown(condition_metric, :period => period)
+
+ actual_measure = ProjectMeasure.new :metric => condition_metric, :value => actual_value, :alert_status => level
+ warning_measure = ProjectMeasure.new :metric => condition_metric, :value => warning_value
+ error_measure = ProjectMeasure.new :metric => condition_metric, :value => error_value
+
+
+ unless level == 'OK' && !widget_properties['show_ok']
+ -%>
+ <div class="dashbox" style="margin: 10px">
+ <p class="title"><%= condition_metric.short_name -%></p>
+ <span class="big"><%= format_measure(actual_measure, :url => drilldown_url) -%></span>
+ <% if level == 'WARN' -%><%= operator -%> <%= format_measure(warning_measure) -%><% end -%>
+ <% if level == 'ERROR' -%><%= operator -%> <%= format_measure(error_measure) -%><% end -%>
+ <% if level == 'OK' -%>
+ <% unless warning_value.blank? -%><%= warn_message -%> <%= operator -%> <%= format_measure(warning_measure) -%> <%= '|' unless error_value.blank? -%><% end -%>
+ <% unless error_value.blank? -%><%= error_message -%> <%= operator -%> <%= format_measure(error_measure) -%><% end -%>
+ <% end -%>
+ <p><%= period_label(@snapshot, period) unless period.blank? -%></p>
+ </div>
+ <% end
+ end
+ end -%>
+</div>
+<% else -%>
<% m=measure(Metric::ALERT_STATUS)
if m && !m.alert_status.blank?
- css_class = "widget color_#{m.alert_status}"
- if m.alert_status==Metric::TYPE_LEVEL_OK
- label = "<b>#{message('widget.alerts.no_alert')}</b>."
- elsif m.alert_status==Metric::TYPE_LEVEL_WARN
- label = "<b>#{message('widget.alerts.warnings')}</b>#{h(m.alert_text)}."
- else
- label = "<b>#{message('widget.alerts.errors')}</b>#{h(m.alert_text)}."
- end
-%><div class="<%= css_class -%>" id="alerts_widget">
+ css_class = "widget color_#{m.alert_status}"
+ if m.alert_status==Metric::TYPE_LEVEL_OK
+ label = "<b>#{message('widget.alerts.no_alert')}</b>."
+ elsif m.alert_status==Metric::TYPE_LEVEL_WARN
+ label = "<b>#{message('widget.alerts.warnings')}</b>#{h(m.alert_text)}."
+ else
+ label = "<b>#{message('widget.alerts.errors')}</b>#{h(m.alert_text)}."
+ end
+-%><div class="<%= css_class -%>" id="alerts_widget">
<div><%= format_measure(m) -%> <%= label -%></div>
</div>
-<% end %>
+<% end
+end -%>
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/quality_gate.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/quality_gate.html.erb
deleted file mode 100644
index af8143e1a58..00000000000
--- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/quality_gate.html.erb
+++ /dev/null
@@ -1,63 +0,0 @@
-<% m=measure(Metric::QUALITY_GATE_DETAILS)
- if m && !m.measure_data.blank?
-
- details = JSON.parse m.measure_data.data
- m.alert_status = details['level']
-
- warn_message = message('measure_filter.criteria.alert.warn')
- error_message = message('measure_filter.criteria.alert.error')
-
- css_class = "color_#{m.alert_status}"
- if m.alert_status==Metric::TYPE_LEVEL_OK
- label = "<b>#{message('widget.alerts.no_alert')}.</b>"
- elsif m.alert_status==Metric::TYPE_LEVEL_WARN
- label = "<b>#{message('widget.alerts.warnings')}</b>"
- else
- label = "<b>#{message('widget.alerts.errors')}</b>"
- end
--%><div class="widget <%= css_class -%>" id="quality_gate_widget_<%= widget.id -%>">
- <div><%= format_measure(m) -%> <%= label -%></div>
- <table class="data" style="color: black; margin-top: 10px">
- <thead>
- <tr></tr>
- </thead>
- <tbody>
- <% details['conditions'].sort_by {|condition| [ -condition['level'].length, metric(condition['metric']).short_name] }.each do |condition|
-
- level = condition['level']
- condition_metric = metric(condition['metric'])
- operator = message("quality_gates.operator.#{condition['op']}.short")
- period = condition['period']
- warning_value = condition['warning']
- error_value = condition['error']
- actual_value = condition['actual']
-
- detail_measure = ProjectMeasure.new :metric => m.metric, :alert_status => level
-
- drilldown_url = period.blank? ? url_for_drilldown(condition_metric) : url_for_drilldown(condition_metric, :period => period)
-
- actual_measure = ProjectMeasure.new :metric => condition_metric, :value => actual_value
- warning_measure = ProjectMeasure.new :metric => condition_metric, :value => warning_value
- error_measure = ProjectMeasure.new :metric => condition_metric, :value => error_value
-
-
- unless level == 'OK' && !widget_properties['show_ok']
- -%>
- <tr>
- <td><%= format_measure(detail_measure) -%></td>
- <td><%= link_to "#{condition_metric.short_name} #{period_label(@snapshot, period) unless period.blank?}", drilldown_url, {:class => 'nolink'} -%></td>
- <td align="right"><%= link_to format_measure(actual_measure), drilldown_url, {:class => 'nolink'} -%></td>
- <td>
- <% if level == 'WARN' -%><%= operator -%> <%= format_measure(warning_measure) -%><% end -%>
- <% if level == 'ERROR' -%><%= operator -%> <%= format_measure(error_measure) -%><% end -%>
- <% if level == 'OK' -%>
- <% unless warning_value.blank? -%><%= warn_message -%> <%= operator -%> <%= format_measure(warning_measure) -%> <%= '|' unless error_value.blank? -%><% end %>
- <% unless error_value.blank? -%><%= error_message -%> <%= operator -%> <%= format_measure(error_measure) -%><% end %>
- <% end -%>
- </tr>
- <% end
- end -%>
- </tbody>
- </table>
-</div>
-<% end %>