From 72caee0b94b9c6955dd46925c2f5145d9924872b Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Tue, 7 Feb 2012 17:04:02 +0100 Subject: [PATCH] SONAR-2069 fix path to treemap widget + minor refactoring --- .../sonar/plugins/core/widgets/TreemapWidget.java | 2 +- .../WEB-INF/app/controllers/treemap_controller.rb | 12 +++++------- .../main/webapp/WEB-INF/app/models/sonar/treemap.rb | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TreemapWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TreemapWidget.java index 733e0a07780..b7b6640c325 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TreemapWidget.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TreemapWidget.java @@ -39,6 +39,6 @@ public class TreemapWidget extends AbstractRubyTemplate implements RubyRailsWidg @Override protected String getTemplatePath() { - return "/Users/sbrandhof/projects/github/sonar/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/treemap.html.erb"; + return "/org/sonar/plugins/core/widgets/treemap.html.erb"; } } \ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/treemap_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/treemap_controller.rb index 9288782b57b..1d124172737 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/treemap_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/treemap_controller.rb @@ -39,16 +39,14 @@ class TreemapController < ApplicationController color_metric=(params[:color_metric].present? ? Metric.by_key(params[:color_metric]) : nil) - resource = nil - if params[:resource] - resource = Project.by_key(params[:resource]) - bad_request('Unknown resource: ' + params[:resource]) unless resource - access_denied unless has_role?(:user, resource) - end + resource = Project.by_key(params[:resource]) + bad_request('Unknown resource: ' + params[:resource]) unless resource + bad_request('Data not available') unless resource.last_snapshot + access_denied unless has_role?(:user, resource) treemap = Sonar::Treemap.new(html_id, size_metric, width.to_i, height.to_i, { :color_metric => color_metric, - :root_snapshot => (resource ? resource.last_snapshot : nil), + :root_snapshot => resource.last_snapshot, :period_index => params[:period_index].to_i, :browsable => true }) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/treemap.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/treemap.rb index 6352a9a283b..7571409b52b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/treemap.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/sonar/treemap.rb @@ -148,7 +148,7 @@ class Sonar::HtmlOutput < Treemap::HtmlOutput return "" if node.bounds.nil? html = '' - html += "