diff options
Diffstat (limited to 'sonar-server/src/main/webapp')
14 files changed, 241 insertions, 15 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/cloud_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/cloud_controller.rb new file mode 100644 index 00000000000..006184a5a26 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/cloud_controller.rb @@ -0,0 +1,72 @@ +# +# Sonar, open source software quality management tool. +# Copyright (C) 2008-2011 SonarSource +# mailto:contact AT sonarsource DOT com +# +# Sonar 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. +# +# Sonar 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 Sonar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 +# +class CloudController < ApplicationController + + SECTION=Navigation::SECTION_RESOURCE + + def index + resource_key = params[:id] + @project = resource_key ? Project.by_key(resource_key) : nil + if @project.nil? + return render :text => "Resource [#{project_key}] not found", :status => 404 + end + return access_denied unless has_role?(:user, @project) + @snapshot=@project.last_snapshot + + @size_metric=Metric.by_key(params[:size]||'ncloc') + @color_metric=Metric.by_key(params[:color]||'coverage') + + snapshot_conditions='snapshots.islast=:islast AND snapshots.scope=:scope 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, + :scope => 'FIL', + :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.rule_priority,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}", 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.rule_priority,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}", 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 diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb index 3d9cbeaf1ac..7cab30c34d5 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb @@ -225,7 +225,7 @@ class ProfilesController < ApplicationController end @changes = ActiveRuleChange.find(:all, :conditions => ['profile_id=? and ?<profile_version and profile_version<=?', @profile.id, @since_version, @to_version], :order => 'id desc') - @select_versions = versions.map {|u| ["version " + u.profile_version.to_s + " (" + u.change_date.strftime("%Y/%m/%d %H:%M:%S") + ")", u.profile_version]} | [["no version", 0]]; + @select_versions = versions.map {|u| [ (u.profile_version == last_version ? "last " : "" ) + "version " + u.profile_version.to_s + " (" + l(u.change_date) + ")", u.profile_version]} | [["no version", 0]]; end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/cloud_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/cloud_helper.rb new file mode 100644 index 00000000000..8d21be8cbbd --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/cloud_helper.rb @@ -0,0 +1,33 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2008-2011 SonarSource +# mailto:contact AT sonarsource DOT com +# +# Sonar 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. +# +# Sonar 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 Sonar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 +# +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 diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/active_rule_change.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/active_rule_change.rb index b58f811538e..218183b7839 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/active_rule_change.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/active_rule_change.rb @@ -24,8 +24,8 @@ class ActiveRuleChange < ActiveRecord::Base def action_text case enabled - when true then "enabled" - when false then "disabled" + when true then "on" + when false then "off" when nil then "modified" end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/measure_color.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/measure_color.rb index 390dc6bb581..745fb54a45b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/measure_color.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/measure_color.rb @@ -44,7 +44,7 @@ class MeasureColor percent = value_to_percent(value, min_value, max_value) end else - if !measure.alert_status.blank? && (options[:check_alert_status]||true) + if (options[:check_alert_status]||true) && !measure.alert_status.blank? case(measure.alert_status) when Metric::TYPE_LEVEL_OK : percent=100.0 when Metric::TYPE_LEVEL_ERROR : percent=0.0 @@ -61,12 +61,15 @@ class MeasureColor end end + max_color=options[:max_color]||MAX_COLOR + min_color=options[:min_color]||MIN_COLOR + mean_color=options[:mean_color]||MEAN_COLOR if percent<0.0 NONE_COLOR elsif (percent > 50.0) - MAX_COLOR.mix_with(MEAN_COLOR, (percent - 50.0) * 2.0) + max_color.mix_with(mean_color, (percent - 50.0) * 2.0) else - MIN_COLOR.mix_with(MEAN_COLOR, (50.0 - percent) * 2.0) + min_color.mix_with(mean_color, (50.0 - percent) * 2.0) end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb index e44ce280a55..638270e1476 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb @@ -261,7 +261,7 @@ class Review < ActiveRecord::Base xml.comments do review_comments.each do |comment| xml.comment do - xml.id(comment.id) + xml.id(comment.id.to_i) xml.author(comment.user.login) xml.updatedAt(Api::Utils.format_datetime(comment.updated_at)) if convert_markdown @@ -296,7 +296,7 @@ class Review < ActiveRecord::Base comments = [] review_comments.each do |comment| comments << { - 'id' => comment.id, + 'id' => comment.id.to_i, 'author' => comment.user.login, 'updatedAt' => Api::Utils.format_datetime(comment.updated_at), 'text' => convert_markdown ? comment.html_text : comment.plain_text diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/cloud/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/cloud/index.html.erb new file mode 100644 index 00000000000..2201de2c81b --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/cloud/index.html.erb @@ -0,0 +1,63 @@ +<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> + +<form id="cloudform" action="<%= ApplicationController.root_context -%>/cloud/index/<%= @project.id -%>" method="GET"> + <ul class="headerLine"> + <li class="first"> + <span class="note">Color:</span> + <select name="color" onchange="document.forms['cloudform'].submit()"> + <option value="coverage" <%= 'selected' if @color_metric.key=='coverage' -%>>Coverage</option> + <option value="violations_density" <%= 'selected' if @color_metric.key=='violations_density' -%>>Rules compliance</option> + </select> + </li> + <li> + <input type="radio" name="size" value="ncloc" <%= 'checked' if @size_metric.key=='ncloc' -%> onchange="document.forms['cloudform'].submit()"> + Quick wins</option> + + <input type="radio" name="size" value="function_complexity" <%= 'checked' if @size_metric.key=='function_complexity' -%> onchange="document.forms['cloudform'].submit()"> + Top risk</input> + </li> + </ul> +</form> + +<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.resource.copy_resource_id + link="ov(#{s.resource.copy_resource_id})" + else + link="of(#{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 -%>"><%= s.resource.name %></span></a> + <% end + end %> +</div>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb index e6ab11b5d22..7de0d6da97e 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb @@ -41,6 +41,7 @@ <li class="<%= 'selected' if request.request_uri.include?('/components/index') -%>"><a href="<%= ApplicationController.root_context -%>/components/index/<%= @project.id -%>">Components</a></li> <li class="<%= 'selected' if request.request_uri.include?('/drilldown/violations') -%>"><a href="<%= ApplicationController.root_context -%>/drilldown/violations/<%= @project.id -%>">Violations drilldown</a></li> <li class="<%= 'selected' if controller.controller_path=='timemachine' -%>"><a href="<%= ApplicationController.root_context -%>/timemachine/index/<%= @project.id -%>">Time machine</a></li> + <li class="<%= 'selected' if request.request_uri.include?('/cloud/index') -%>"><a href="<%= ApplicationController.root_context -%>/cloud/index/<%= @project.id -%>">Clouds</a></li> <% controller.java_facade.getPages(Navigation::SECTION_RESOURCE, @project.scope, @project.qualifier, @project.language).each do |page| %> <li class="<%= 'selected' if request.request_uri.include?("page=#{page.getId()}") -%>"><a href="<%= ApplicationController.root_context -%>/plugins/resource/<%= @project.id-%>?page=<%= page.getId() -%>"><%= page.getTitle() %></a></li> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/changelog.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/changelog.html.erb index d1cfc1635c4..049de5a9a8d 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/changelog.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/changelog.html.erb @@ -8,9 +8,9 @@ <% form_tag({:action => 'changelog'}, {:method => 'post'}) do %> <%= hidden_field_tag "id", @profile.id %> - Cahngelog between + Changelog from <%= select_tag "since", options_for_select(@select_versions, @since_version) %> - and + to <%= select_tag "to", options_for_select(@select_versions, @to_version) %> <%= submit_tag "Load", :id => 'submit'%> <% end %> @@ -31,10 +31,10 @@ %> <tr class="<%= cycle('even', 'odd') -%>"> <td valign="top"><%= change.profile_version - 1 %> -> <%= change.profile_version %></td> - <td valign="top"><%=change.change_date.strftime("%Y-%m-%d %H:%M:%S")%></td> - <td valign="top"><%=change.user_name%></td> - <td valign="top"><%=change.action_text%></td> - <td valign="top"><%=change.rule.name%></td> + <td valign="top"><%= l(change.change_date) -%></td> + <td valign="top"><%= change.user_name %></td> + <td valign="top"><%= change.action_text %></td> + <td valign="top"><%= change.rule.name %></td> <td valign="top"> <% if change.old_severity if change.new_severity %> diff --git a/sonar-server/src/main/webapp/WEB-INF/config/locales/de.yml b/sonar-server/src/main/webapp/WEB-INF/config/locales/de.yml new file mode 100644 index 00000000000..472666079e6 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/config/locales/de.yml @@ -0,0 +1,10 @@ +# Override default date formats + +de: + date: + formats: + default: "%d. %b %Y" + + time: + formats: + default: "%d. %b %Y %H:%M"
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/config/locales/en.yml b/sonar-server/src/main/webapp/WEB-INF/config/locales/en-AU.yml index f164a55f98e..9b4fd514388 100644 --- a/sonar-server/src/main/webapp/WEB-INF/config/locales/en.yml +++ b/sonar-server/src/main/webapp/WEB-INF/config/locales/en-AU.yml @@ -1,6 +1,6 @@ # Override default locale -en: +"en-AU": date: formats: default: "%d %b %Y" diff --git a/sonar-server/src/main/webapp/WEB-INF/config/locales/en-GB.yml b/sonar-server/src/main/webapp/WEB-INF/config/locales/en-GB.yml new file mode 100644 index 00000000000..0ef3ab82836 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/config/locales/en-GB.yml @@ -0,0 +1,13 @@ +# Override default locale + +"en-GB": + date: + formats: + default: "%d %b %Y" + + time: + formats: + default: "%d %b %Y %H:%M" + am: "am" + pm: "pm" + diff --git a/sonar-server/src/main/webapp/WEB-INF/config/locales/en-US.yml b/sonar-server/src/main/webapp/WEB-INF/config/locales/en-US.yml new file mode 100644 index 00000000000..154c872dc28 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/config/locales/en-US.yml @@ -0,0 +1,13 @@ +# Override default locale + +"en-US": + date: + formats: + default: "%d %b %Y" + + time: + formats: + default: "%d %b %Y %H:%M" + am: "am" + pm: "pm" + diff --git a/sonar-server/src/main/webapp/stylesheets/style.css b/sonar-server/src/main/webapp/stylesheets/style.css index f0246a34b58..f43efd4d03f 100644 --- a/sonar-server/src/main/webapp/stylesheets/style.css +++ b/sonar-server/src/main/webapp/stylesheets/style.css @@ -1178,6 +1178,24 @@ table.header1 td { text-align: left; vertical-align: top; } +.headerLine { + background-color: #ECECEC; + color: #444; + border: 1px solid #DDD; + margin: 0 0 10px 0; + line-height: 30px; + height: 30px; + width: 100%; +} +ul.headerLine li { + float: left; + display: block; + padding: 0 10px 0; + background: url("../images/sep12.png") no-repeat scroll 0 50% transparent; +} +ul.headerLine li.first { + background: none; +} select.withIcons option { background-repeat: no-repeat; background-position: 2px 0; |