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
})
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;"