]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2069 fix path to treemap widget + minor refactoring
authorSimon Brandhof <simon.brandhof@gmail.com>
Tue, 7 Feb 2012 16:04:02 +0000 (17:04 +0100)
committerSimon Brandhof <simon.brandhof@gmail.com>
Tue, 7 Feb 2012 16:24:46 +0000 (17:24 +0100)
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TreemapWidget.java
sonar-server/src/main/webapp/WEB-INF/app/controllers/treemap_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/models/sonar/treemap.rb

index 733e0a0778044c17e4404d0445829948268ab62d..b7b6640c3256702722628637171c194e914ac3cd 100644 (file)
@@ -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
index 9288782b57b6c35fe53d35e738c14f4e46f6245a..1d12417273716494798e86244cdacc673fed323e 100644 (file)
@@ -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
     })
index 6352a9a283b655e928d30508539fb0fe9a5b57fe..7571409b52be833eb29bb77a5abbd06f51d64a87 100644 (file)
@@ -148,7 +148,7 @@ class Sonar::HtmlOutput < Treemap::HtmlOutput
     return "" if node.bounds.nil?
 
     html = ''
-    html += "<div id=\"node-#{node.id}\" style=\""
+    html += "<div style=\""
     html += "overflow:hidden;position:absolute;"
     html += "left:#{node.bounds.x1}px; top:#{node.bounds.y1}px;"
     html += "width:#{node.bounds.width}px;height: #{node.bounds.height}px;"