diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2010-12-03 17:51:58 +0000 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2010-12-03 17:51:58 +0000 |
commit | 46124a16b74a5e20b25a87e804ecce9baf135f16 (patch) | |
tree | 6f827f7b45fec2b0af43f702285a0bf60d7ca0c3 /sonar-server | |
parent | e0c44a1486144da97f75279b0f30c7110de94e96 (diff) | |
download | sonarqube-46124a16b74a5e20b25a87e804ecce9baf135f16.tar.gz sonarqube-46124a16b74a5e20b25a87e804ecce9baf135f16.zip |
SONAR-249 add the select-box to display variation periods
Diffstat (limited to 'sonar-server')
3 files changed, 39 insertions, 24 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb index 6cd75f7d723..81eed039cd6 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb @@ -20,23 +20,6 @@ module DashboardHelper include WidgetPropertiesHelper - def active_widgets_ids_formatted(column) - active_widget_ids=[] - @dashboard.widgets.find(:all, :conditions => {:column_index => column}, :order => 'row_index ASC').each do |widget| - widget_view=nil - found_index=-1 - @widgets.each_with_index {|item, index| - if item.getId()==widget.widget_key - found_index=index - end - } - if found_index>-1 - active_widget_ids=active_widget_ids << (widget.widget_key+"_"+found_index.to_s()) - end - end - return "\'"+active_widget_ids.join("\',\'")+"\'" - end - def formatted_value(measure, default='') measure ? measure.formatted_value : default end @@ -45,4 +28,24 @@ module DashboardHelper @snapshot.measure(metric_key) end + def variation_select_option(snapshot, index) + return nil if snapshot.nil? || snapshot.project_snapshot.nil? + mode=snapshot.project_snapshot.send "var_mode_#{index}" + mode_param=snapshot.project_snapshot.send "var_label_#{index}" + + if mode + if mode=='days' + label = "Last %s days" % mode_param + elsif mode=='version' + label = "Version %s" % mode_param + end + if label + selected=(params[:var]==index.to_s ? 'selected' : '') + "<option value='#{index}' #{selected}>#{label}</option>" + end + else + nil + end + + end end
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb index 61beff4ccf2..94daa90e107 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/snapshot.rb @@ -81,12 +81,15 @@ class Snapshot < ActiveRecord::Base end def project_snapshot - if scope==Project::SCOPE_SET - self - elsif parent_snapshot_id - parent_snapshot.project - else - nil + @project_snapshot ||= + begin + if scope==Project::SCOPE_SET + self + elsif parent_snapshot_id + parent_snapshot.project_snapshot + else + nil + end end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb index 040d8ba867f..f9565ca5d0b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb @@ -21,7 +21,16 @@ profile_measure=@snapshot.measure(Metric::PROFILE) %> <%= link_to_favourite(@project) -%> <%= "#{version_event.fullname} - " if version_event %> <%= l @snapshot.created_at %> - <% if profile_measure %> - profile <%= link_to profile_measure.data, :controller => '/rules_configuration', :action => 'index', :id => profile_measure.value.to_i %><% end %> + <% if profile_measure %> - Profile <%= link_to profile_measure.data, :controller => '/rules_configuration', :action => 'index', :id => profile_measure.value.to_i %><% end %> + - Compare to + <form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:var => nil} -%>" style="display: inline"> + <select id="select-comparison" name="var" onchange="submit()"> + <option value=""></option> + <%= variation_select_option(@snapshot, 1) -%> + <%= variation_select_option(@snapshot, 2) -%> + <%= variation_select_option(@snapshot, 3) -%> + </select> + </form> </h4> </div> <% end %> |