From c9f44bd6372ddeb78075ffc60f4f49e5f4c14943 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Sun, 25 Nov 2012 23:13:15 +0100 Subject: [PATCH] Width of treemap is not required anymore --- .../WEB-INF/app/controllers/components_controller.rb | 2 +- .../WEB-INF/app/controllers/treemap_controller.rb | 6 +----- .../main/webapp/WEB-INF/app/models/sonar/treemap.rb | 11 +++++------ .../WEB-INF/app/views/components/index.html.erb | 2 +- .../WEB-INF/app/views/treemap/_treemap.html.erb | 2 +- .../app/views/treemap/_treemap_container.html.erb | 3 --- .../src/main/webapp/javascripts/application.js | 4 ++-- 7 files changed, 11 insertions(+), 19 deletions(-) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/components_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/components_controller.rb index 9e8e23cc0f8..8c412ab8db4 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/components_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/components_controller.rb @@ -44,7 +44,7 @@ class ComponentsController < ApplicationController measures = component_measures(@snapshots, metrics) @measures_by_snapshot = measures_by_snapshot(@snapshots, measures) if @components_configuration.treemap_enabled? && @snapshots.size>1 - @treemap = Sonar::Treemap.new(1, default_treemap_size_metric, TREEMAP_SIZE, TREEMAP_SIZE, { + @treemap = Sonar::Treemap.new(1, default_treemap_size_metric, TREEMAP_SIZE, { :color_metric => default_treemap_color_metric, :root_snapshot => @snapshot }) 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 fe34259e080..ea63d438747 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 @@ -26,10 +26,6 @@ class TreemapController < ApplicationController html_id = params[:id] bad_request('Missing required property: id') if html_id.blank? - width = params[:width] - bad_request('Missing required property: width') if width.blank? - bad_request('Bad width') if width.to_i<=0 - height = params[:height] bad_request('Missing required property: height') if height.blank? bad_request('Bad height') if height.to_i<=0 @@ -57,7 +53,7 @@ class TreemapController < ApplicationController bad_request('Missing parameter: resource or filter') end - treemap = Sonar::Treemap.new(html_id, size_metric, width.to_i, height.to_i, { + treemap = Sonar::Treemap.new(html_id, size_metric, height.to_i, { :color_metric => color_metric, :root_snapshot => (resource ? resource.last_snapshot : nil), :measures_by_snapshot => (filter_context ? filter_context.measures_by_snapshot : nil), 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 ceea573b8d8..63ae871374b 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 @@ -20,14 +20,13 @@ class Sonar::Treemap include ActionView::Helpers::UrlHelper - attr_accessor :size_metric, :color_metric, :width, :height, :root_snapshot, :period_index, + attr_accessor :size_metric, :color_metric, :height, :root_snapshot, :period_index, :id, :components_size, :measures - def initialize(id, size_metric, width, height, options={}) + def initialize(id, size_metric, height, options={}) @components_size = 0 @id = id @size_metric = size_metric - @width = width @height = height @color_metric = options[:color_metric] @@ -55,7 +54,7 @@ class Sonar::Treemap build_tree(root) output = Sonar::HtmlOutput.new do |o| - o.width = @width + o.width = 100 o.height = @height o.full_html = false o.details_at_depth = 1 @@ -148,8 +147,8 @@ class Sonar::HtmlOutput < Treemap::HtmlOutput html = '' html += "
" html += "
<% if @treemap %>   - + diff --git a/sonar-server/src/main/webapp/javascripts/application.js b/sonar-server/src/main/webapp/javascripts/application.js index 579609ebdcd..eb635f67831 100644 --- a/sonar-server/src/main/webapp/javascripts/application.js +++ b/sonar-server/src/main/webapp/javascripts/application.js @@ -195,7 +195,7 @@ Treemap.prototype.currentContext = function () { return null; }; Treemap.prototype.width = function () { - return $('tm-' + this.id).getWidth() - 10; + return $('tm-' + this.id).getWidth(); }; Treemap.prototype.load = function () { var context = this.currentContext(); @@ -215,7 +215,7 @@ Treemap.prototype.load = function () { } new Ajax.Request( - baseUrl + '/treemap/index?id=' + this.id + '&width=' + width + '&height=' + height + '&size_metric=' + this.sizeMetric + '&color_metric=' + this.colorMetric + '&' + context.type + '=' + context.id, + baseUrl + '/treemap/index?id=' + this.id + '&height=' + height + '&size_metric=' + this.sizeMetric + '&color_metric=' + this.colorMetric + '&' + context.type + '=' + context.id, { asynchronous:true, evalScripts:true -- 2.39.5