+++ /dev/null
-#
-# 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.
-#
-class CloudController < ApplicationController
-
- SECTION=Navigation::SECTION_RESOURCE
- before_filter :init_resource_for_user_role
-
- def index
- @size_metric=Metric.by_key(params[:size]||'ncloc')
- @color_metric=Metric.by_key(params[:color]||'coverage')
-
- if @snapshot.measure(@color_metric).nil?
- @color_metric=Metric.by_key('violations_density')
- end
-
- snapshot_conditions='snapshots.islast=:islast AND snapshots.qualifier in (:qualifiers) AND snapshots.qualifier!=:test_qualifier AND
- (snapshots.id=:sid OR (snapshots.root_snapshot_id=:root_sid AND snapshots.path LIKE :path))'
- snapshot_values={
- :islast => true,
- :qualifiers => @snapshot.leaves_qualifiers,
- :test_qualifier => 'UTS',
- :sid => @snapshot.id,
- :root_sid => (@snapshot.root_snapshot_id || @snapshot.id),
- :path => "#{@snapshot.path}#{@snapshot.id}.%"
- }
-
- @snapshots=Snapshot.find(:all, :conditions => [snapshot_conditions, snapshot_values], :include => 'project', :order => 'projects.name')
-
- size_measures=ProjectMeasure.find(:all,
- :select => 'project_measures.id,project_measures.value,project_measures.metric_id,project_measures.snapshot_id,project_measures.rule_id,project_measures.text_value,project_measures.characteristic_id,project_measures.alert_status',
- :joins => :snapshot,
- :conditions => [snapshot_conditions + " AND project_measures.metric_id=#{@size_metric.id} AND project_measures.rule_id IS NULL AND project_measures.characteristic_id IS NULL AND project_measures.person_id IS NULL", snapshot_values],
- :order => 'project_measures.value')
-
- color_measures=ProjectMeasure.find(:all,
- :select => 'project_measures.id,project_measures.value,project_measures.metric_id,project_measures.snapshot_id,project_measures.rule_id,project_measures.text_value,project_measures.characteristic_id,project_measures.alert_status',
- :joins => :snapshot,
- :conditions => [snapshot_conditions + " AND project_measures.metric_id=#{@color_metric.id} AND project_measures.rule_id IS NULL AND project_measures.characteristic_id IS NULL AND project_measures.person_id IS NULL", snapshot_values],
- :order => 'project_measures.value')
-
- @size_measure_by_sid={}
- @color_measure_by_sid={}
- size_measures.each do |m|
- @size_measure_by_sid[m.snapshot_id]=m
- end
- color_measures.each do |m|
- @color_measure_by_sid[m.snapshot_id]=m
- end
- @min_size_value=(size_measures.empty? ? 0.0 : size_measures.first.value)
- @max_size_value=(size_measures.empty? ? 0.0 : size_measures.last.value)
- end
-
-end
+++ /dev/null
-#
-# 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.
-#
-module CloudHelper
- MIN_SIZE_PERCENT=60.0
- MAX_SIZE_PERCENT=240.0
-
- def font_size(value)
- divisor=@max_size_value - @min_size_value
- size=MIN_SIZE_PERCENT
- if divisor!=0.0
- multiplier=(MAX_SIZE_PERCENT - MIN_SIZE_PERCENT)/divisor
- size=MIN_SIZE_PERCENT + ((@max_size_value - (@max_size_value-(value - @min_size_value)))*multiplier)
- end
- size.to_i
- end
-end
"<a href='#' id='star-#{filter.name.parameterize}' class='measure-filter-star #{style}' filter-id='#{filter.id}' title='#{title}'></a>"
end
- CLOUD_MIN_SIZE_PERCENT=60.0
- CLOUD_MAX_SIZE_PERCENT=240.0
-
- def cloud_font_size(value, min_size_value, max_size_value)
- divisor=max_size_value - min_size_value
- size=CLOUD_MIN_SIZE_PERCENT
- if divisor!=0.0
- multiplier=(CLOUD_MAX_SIZE_PERCENT - CLOUD_MIN_SIZE_PERCENT)/divisor
- size=CLOUD_MIN_SIZE_PERCENT + ((max_size_value - (max_size_value-(value - min_size_value)))*multiplier)
- end
- size.to_i
- end
-
def period_labels
[Api::Utils.period_label(1), Api::Utils.period_label(2), Api::Utils.period_label(3)]
end
+++ /dev/null
-<style>
- #cloud a {
- text-decoration: none;
- }
-</style>
-<script type="text/javascript">
- // open view
- function ov(id) {
- window.location.href = '<%=ApplicationController.root_context-%>/cloud/index/' + id + '?size=<%= @size_metric.key -%>&color=<%= @color_metric.key -%>';
- return false;
- }
-
- // open file
- function of(id) {
- window.open('<%=ApplicationController.root_context-%>/resource/index/' + id + '?metric=<%= @color_metric.key -%>', 'resource', 'height=800,width=900,scrollbars=1,resizable=1');
- return false;
- }
-</script>
-
-<div>
- <form id="cloudform" action="<%= ApplicationController.root_context -%>/cloud/index/<%= @resource.id -%>" method="GET">
- <ul class="headerLine">
- <li>
- <span><%= message('color') -%>:</span>
- <select name="color" onchange="document.forms['cloudform'].submit()">
- <% if @snapshot.measure('coverage') %>
- <option value="coverage" <%= 'selected' if @color_metric.key=='coverage' -%>><%= message('metric.coverage.name') -%></option>
- <% end %>
- <option value="violations_density" <%= 'selected' if @color_metric.key=='violations_density' -%>><%= message('metric.violations_density.name') -%></option>
- </select>
- <script>
- $j(function() {
- $j('select[name=color]').select2({ width: '200px' });
- });
- </script>
- </li>
- <li class="sep"></li>
- <li>
- <input type="radio" name="size" value="ncloc" <%= 'checked' if @size_metric.key=='ncloc' -%> onclick="document.forms['cloudform'].submit()" id="radio-quick">
- <label for="radio-quick"><%= message('cloud.quick_wins') -%></label></option>
-
- <input type="radio" name="size" value="function_complexity" <%= 'checked' if @size_metric.key=='function_complexity' -%> onclick="document.forms['cloudform'].submit()" id="radio-top">
- <label for="radio-top"><%= message('cloud.top_risk') -%></label></input>
- </li>
- </ul>
- </form>
-</div>
-
-<div id="cloud">
- <%
- color_options={
- :check_alert_status => false,
- :min_color => Color::RGB.from_html("EE0000"), # red
- :mean_color => Color::RGB.from_html("4D05B1"), # purple
- :max_color => Color::RGB.from_html("2360BF") # blue
- }
- @snapshots.each do |s|
- size_measure=@size_measure_by_sid[s.id]
- if size_measure && size_measure.value
- color_measure=@color_measure_by_sid[s.id]
- if s.source_code?
- link="of(#{s.project_id})"
- else
- link="ov(#{s.project_id})"
- end
-
- title="#{s.resource.long_name} | #{@size_metric.short_name}: #{size_measure.formatted_value}"
- if color_measure && color_measure.value
- title += " | #{@color_metric.short_name}: #{color_measure.formatted_value}"
- end
- %>
- <a href="#" onclick="<%= link -%>" title="<%= title -%>"><span style="font-size: <%= font_size(size_measure.value) -%>%;color: <%= MeasureColor.color(color_measure, color_options).html -%>"><%= h s.resource.name %></span></a>
- <% end
- end %>
-</div>
<a href="<%= ApplicationController.root_context -%><%= page_url -%>"><%= h message(page.getId() + '.page', :default => page.getTitle()) -%></a>
</li>
<% end %>
- <li class="<%= 'active' if controller.controller_path=='cloud' -%>">
- <a href="<%= ApplicationController.root_context -%>/cloud/index/<%= @project.id -%>"><%= message('clouds.page') -%></a>
- </li>
<% if controller.java_facade.getResourceTypeBooleanProperty(@project.qualifier, 'comparable') %>
<li class="<%= 'active' if request.request_uri.include?('/comparison/index') -%>">
<a href="<%= ApplicationController.root_context -%>/comparison/index?resource=<%= @project.key -%>"><%= message('comparison.page') -%></a>
+++ /dev/null
-<div>
- <%
- color_options={
- :check_alert_status => false,
- :min_color => Color::RGB.from_html("EE0000"), # red
- :mean_color => Color::RGB.from_html("4D05B1"), # purple
- :max_color => Color::RGB.from_html("2360BF") # blue
- }
- size_measure_values = filter.rows.map do |row|
- size_measure = row.measure(filter.display.size_metric)
- size_measure.value if size_measure
- end.compact
-
- min_size_value=(size_measure_values.empty? ? 0.0 : size_measure_values.min)
- max_size_value=(size_measure_values.empty? ? 0.0 : size_measure_values.max)
-
- filter.rows.each do |row|
- size_measure=row.measure(filter.display.size_metric)
- if size_measure && size_measure.value
- color_measure=row.measure(filter.display.color_metric)
-
- title="#{row.snapshot.resource.long_name} | #{filter.display.size_metric.short_name}: #{size_measure.formatted_value}"
- if color_measure && color_measure.value
- title += " | #{filter.display.color_metric.short_name}: #{color_measure.formatted_value}"
- end
- %>
- <a href="<%= ApplicationController.root_context -%>/dashboard/index/<%= row.snapshot.resource_id -%>" title="<%= title -%>">
- <span style="font-size: <%= cloud_font_size(size_measure.value, min_size_value, max_size_value) -%>%;color: <%= MeasureColor.color(color_measure, color_options).html -%>"><%= h row.snapshot.resource.name %></span></a>
- <% end
- end %>
-</div>