diff options
author | David Gageot <david@gageot.net> | 2012-05-10 15:17:13 +0200 |
---|---|---|
committer | David Gageot <david@gageot.net> | 2012-05-10 15:17:13 +0200 |
commit | 7dbc751f1e65bf1e318655fe5ce79527851bb7a7 (patch) | |
tree | d905de679d69b0387f98140bf478afba5d5bb492 | |
parent | 8fbb1e5a79c549755ed11f385d5535b7a96d1eb3 (diff) | |
download | sonarqube-7dbc751f1e65bf1e318655fe5ce79527851bb7a7.tar.gz sonarqube-7dbc751f1e65bf1e318655fe5ce79527851bb7a7.zip |
SONAR-3465 My filters configuration
10 files changed, 463 insertions, 767 deletions
diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties index 97cba6c2cd5..de40f14bc95 100644 --- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -357,6 +357,7 @@ session.flash_notice.logged_out=You have been logged out. # #------------------------------------------------------------------------------ +filters.new=New filter filters.size=Size filters.color=Color filters.add_filter=Add filter @@ -380,8 +381,6 @@ filters.treemap_not_supported_for_period_selection=Treemap does not support yet filters.my_filters=My filters filters.no_filters=No filters filters.do_you_want_to_stop_following=Do you want to stop following this filter ? -filters.shared_filters=Shared filters -filters.shared_filters_description=These filters are shared by administrators and can be followed without copying them. filters.criteria=Criteria filters.display_form.title=Display filters.display_form.as=Display as diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/admin_filters_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/admin_filters_controller.rb deleted file mode 100644 index 621a4b9e29f..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/admin_filters_controller.rb +++ /dev/null @@ -1,100 +0,0 @@ -# -# Sonar, entreprise quality control tool. -# Copyright (C) 2008-2012 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 AdminFiltersController < ApplicationController - include FiltersHelper - - SECTION=Navigation::SECTION_CONFIGURATION - - verify :method => :post, :only => [:up, :down, :remove, :add], :redirect_to => {:action => :index} - before_filter :admin_required - before_filter :load_active_filters - - def index - @shared_filters=::Filter.find(:all, :conditions => {:shared => true}).sort{|a,b| a.name.downcase<=>b.name.downcase} - ids=@actives.map{|af| af.filter_id} - @shared_filters.reject!{|f| ids.include?(f.id) } - end - - def up - active_index=-1 - active=nil - @actives.each_index do |index| - if @actives[index].id==params[:id].to_i - active_index=index - active=@actives[index] - end - end - if active && active_index>0 - @actives[active_index]=@actives[active_index-1] - @actives[active_index-1]=active - - @actives.each_index do |index| - @actives[index].order_index=index+1 - @actives[index].save - end - end - redirect_to :action => 'index' - end - - def down - filter_index=-1 - filter=nil - @actives.each_index do |index| - if @actives[index].id==params[:id].to_i - filter_index=index - filter=@actives[index] - end - end - if filter && filter_index<@actives.size-1 - @actives[filter_index]=@actives[filter_index+1] - @actives[filter_index+1]=filter - - @actives.each_index do |index| - @actives[index].order_index=index+1 - @actives[index].save - end - end - redirect_to :action => 'index' - end - - def add - filter=::Filter.find(:first, :conditions => ['shared=? and id=?', true, params[:id].to_i]) - if filter - ActiveFilter.create(:filter => filter, :user => nil, :order_index => @actives.size+1) - flash[:notice]='Default filter added.' - end - redirect_to :action => 'index' - end - - def remove - active=@actives.to_a.find{|af| af.id==params[:id].to_i} - if active - active.destroy - flash[:notice]='Filter removed from default filters.' - end - redirect_to :action => 'index' - end - - private - - def load_active_filters - @actives=ActiveFilter.default_active_filters - end -end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/filters_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/filters_controller.rb index d712c13a75a..2b9649f1ad8 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/filters_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/filters_controller.rb @@ -22,269 +22,183 @@ class FiltersController < ApplicationController helper MetricsHelper helper FiltersHelper + #SECTION=Navigation::SECTION_CONFIGURATION SECTION=Navigation::SECTION_HOME verify :method => :post, :only => [:create, :delete, :up, :down, :activate, :deactivate, :up_column, :down_column, :add_column, :delete_column, :set_sorted_column, :set_view, :set_columns, :set_page_size], :redirect_to => {:action => :index} - before_filter :load_active_filters, :except => ['admin_console', 'treemap', 'set_view', 'set_columns'] before_filter :login_required, :except => ['index', 'treemap'] - before_filter :admin_required, :only => ['admin_console'] def index + load_active_filters() load_active_filter() end def manage - @shared_filters=::Filter.find(:all, :conditions => ['shared=? and (user_id<>? or user_id is null)', true, current_user.id]) - ids=@actives.map { |af| af.filter_id } - @shared_filters.reject! { |f| ids.include?(f.id) } + @filters = ::Filter.find(:all, :conditions => ['user_id=? or user_id is null', current_user.id]) end def new - @filter=::Filter.new() - @filter.criteria<<Criterion.new_for_qualifiers(['TRK']) + @filter=::Filter.new() + @filter.criteria<<Criterion.new_for_qualifiers(['TRK']) end def create - activate_default_filters_if_needed() - - @filter=::Filter.new() - load_filter_from_params(@filter, params) - - @filter.columns.build(:family => 'name', :order_index => 1, :sort_direction => 'ASC') - @filter.columns.build(:family => 'metric', :kee => 'ncloc', :order_index => 2, :variation => @filter.period?) - @filter.columns.build(:family => 'metric', :kee => 'violations_density', :order_index => 3, :variation => @filter.period?) - @filter.columns.build(:family => 'date', :order_index => 4) - - column_index=0 - @filter.measure_criteria.each do |criterion| - unless @filter.column(criterion.family, criterion.kee) - @filter.columns.build(:family => criterion.family, :kee => criterion.kee, :order_index => 3+column_index, :sort_direction => (column_index==0 ? 'ASC' : nil)) - column_index+=1 - end - end - - if @filter.valid? - @filter.save - - # activate it by default - current_user.active_filters.create(:filter => @filter, :user_id => current_user.id, :order_index => (current_user.active_filters.size + 1)) - flash[:notice]='Filter saved' - - if params[:preview]=='true' - redirect_to :action => 'edit', :id => @filter.id - else - redirect_to :action => 'index', :id => @filter.id - end - else - render :action => 'new' - end + activate_default_filters_if_needed() + + @filter=::Filter.new() + load_filter_from_params(@filter, params) + + @filter.columns.build(:family => 'name', :order_index => 1, :sort_direction => 'ASC') + @filter.columns.build(:family => 'metric', :kee => 'ncloc', :order_index => 2, :variation => @filter.period?) + @filter.columns.build(:family => 'metric', :kee => 'violations_density', :order_index => 3, :variation => @filter.period?) + @filter.columns.build(:family => 'date', :order_index => 4) + + column_index=0 + @filter.measure_criteria.each do |criterion| + unless @filter.column(criterion.family, criterion.kee) + @filter.columns.build(:family => criterion.family, :kee => criterion.kee, :order_index => 3+column_index, :sort_direction => (column_index==0 ? 'ASC' : nil)) + column_index+=1 + end + end + + if @filter.valid? + @filter.save + + # activate it by default + current_user.active_filters.create(:filter => @filter, :user_id => current_user.id, :order_index => (current_user.active_filters.size + 1)) + flash[:notice]='Filter saved' + + if params[:preview]=='true' + redirect_to :action => 'edit', :id => @filter.id + else + redirect_to :action => 'manage', :id => @filter.id + end + else + render :action => 'new' + end end def edit - @filter=::Filter.find(params[:id]) - access_denied unless @filter.authorized_to_edit?(self) + @filter=::Filter.find(params[:id]) + access_denied unless @filter.authorized_to_edit?(self) - @filter_context=Filters.execute(@filter, self, params) - render :action => 'new' + @filter_context=Filters.execute(@filter, self, params) + render :action => 'new' end def update - @filter=::Filter.find(params[:id]) - access_denied unless @filter.authorized_to_edit?(self) - - load_filter_from_params(@filter, params) - - if @filter.save - flash[:notice]='Filter updated' - if params[:preview]=='true' - redirect_to :action => 'edit', :id => @filter.id - else - redirect_to :action => 'index', :id => @filter.id - end - else - render :action => 'new', :id => @filter.id - end + @filter=::Filter.find(params[:id]) + access_denied unless @filter.authorized_to_edit?(self) + + load_filter_from_params(@filter, params) + + if @filter.save + flash[:notice]='Filter updated' + if params[:preview]=='true' + redirect_to :action => 'edit', :id => @filter.id + else + redirect_to :action => 'manage', :id => @filter.id + end + else + render :action => 'new', :id => @filter.id + end end def delete - filter=::Filter.find(:first, :conditions => {:id => params[:id].to_i, :user_id => current_user.id}) - if filter - filter.destroy - flash[:notice]='Filter deleted' - end - redirect_to :action => 'manage' + filter=::Filter.find(:first, :conditions => {:id => params[:id].to_i, :user_id => current_user.id}) + if filter + filter.destroy + flash[:notice]='Filter deleted' + end + redirect_to :action => 'manage' end - def activate - activate_default_filters_if_needed() - filter=::Filter.find(params[:id]) - if filter && filter.shared - existing=current_user.active_filters.to_a.find { |a| a.filter_id==filter.id } - if existing.nil? - current_user.active_filters.create(:filter => filter, :user => current_user, :order_index => current_user.active_filters.size+1) - end - end - redirect_to :action => 'manage' - end - - def deactivate - activate_default_filters_if_needed() - active_filter=current_user.active_filters.to_a.find { |a| a.filter_id==params[:id].to_i } - if active_filter - if active_filter.owner? - active_filter.filter.destroy - flash[:notice]='Filter deleted.' - else - active_filter.destroy - flash[:notice]='Filter unfollowed.' - end - end - redirect_to :action => 'manage' - end - - - #--------------------------------------------------------------------- - # - # TABS - # - #--------------------------------------------------------------------- - - def up - activate_default_filters_if_needed() - - actives=current_user.active_filters - active_index=-1 - active=nil - actives.each_index do |index| - if actives[index].id==params[:id].to_i - active_index=index - active=actives[index] - end - end - - if active && active_index>0 - actives[active_index]=actives[active_index-1] - actives[active_index-1]=active - - actives.each_index do |index| - actives[index].order_index=index+1 - actives[index].save - end - end - redirect_to :action => 'manage' - end - - def down - activate_default_filters_if_needed() - actives=current_user.active_filters - filter_index=-1 - filter=nil - actives.each_index do |index| - if actives[index].id==params[:id].to_i - filter_index=index - filter=actives[index] - end - end - - if filter && filter_index<actives.size-1 - actives[filter_index]=actives[filter_index+1] - actives[filter_index+1]=filter - - actives.each_index do |index| - actives[index].order_index=index+1 - actives[index].save - end - end - redirect_to :action => 'manage' - end - - #--------------------------------------------------------------------- # # COLUMNS # #--------------------------------------------------------------------- def delete_column - column=FilterColumn.find(params[:id]) - filter=column.filter - - access_denied unless filter.authorized_to_edit?(self) - - if column.deletable? - column.destroy - redirect_to :action => 'edit', :id => filter.id - else - flash[:error]='Unknown column' - redirect_to :action => 'manage' - end + column=FilterColumn.find(params[:id]) + filter=column.filter + + access_denied unless filter.authorized_to_edit?(self) + + if column.deletable? + column.destroy + redirect_to :action => 'edit', :id => filter.id + else + flash[:error]='Unknown column' + redirect_to :action => 'manage' + end end def add_column - filter=::Filter.find(params[:id]) - access_denied unless filter.authorized_to_edit?(self) - filter.clean_columns_order() # clean the columns which are badly ordered (see SONAR-1902) - - fields=params[:column].split(',') - family=fields[0] - if family=='metric' - filter.columns.create(:family => fields[0], :kee => Metric.by_id(fields[1]).name, :order_index => filter.columns.size + 1, :variation => params[:column_type]=='variation') - elsif family.present? - filter.columns.create(:family => family, :order_index => filter.columns.size + 1) - end - redirect_to :action => 'edit', :id => filter.id + filter=::Filter.find(params[:id]) + access_denied unless filter.authorized_to_edit?(self) + filter.clean_columns_order() # clean the columns which are badly ordered (see SONAR-1902) + + fields=params[:column].split(',') + family=fields[0] + if family=='metric' + filter.columns.create(:family => fields[0], :kee => Metric.by_id(fields[1]).name, :order_index => filter.columns.size + 1, :variation => params[:column_type]=='variation') + elsif family.present? + filter.columns.create(:family => family, :order_index => filter.columns.size + 1) + end + redirect_to :action => 'edit', :id => filter.id end def left_column - column=FilterColumn.find(params[:id]) - filter=column.filter - - access_denied unless filter.authorized_to_edit?(self) - - filter.clean_columns_order() # clean the columns which are badly ordered (see SONAR-1902) - target_column=filter.column_by_id(params[:id].to_i) - if target_column.order_index>1 - target_column.order_index-=1 - target_column.save - old_left_col=filter.columns[target_column.order_index-1] - old_left_col.order_index+=1 - old_left_col.save - end - redirect_to :action => 'edit', :id => filter.id + column=FilterColumn.find(params[:id]) + filter=column.filter + + access_denied unless filter.authorized_to_edit?(self) + + filter.clean_columns_order() # clean the columns which are badly ordered (see SONAR-1902) + target_column=filter.column_by_id(params[:id].to_i) + if target_column.order_index>1 + target_column.order_index-=1 + target_column.save + old_left_col=filter.columns[target_column.order_index-1] + old_left_col.order_index+=1 + old_left_col.save + end + redirect_to :action => 'edit', :id => filter.id end def right_column - column=FilterColumn.find(params[:id]) - filter=column.filter - - access_denied unless filter.authorized_to_edit?(self) - - filter.clean_columns_order() # clean the columns which are badly ordered (see SONAR-1902) - target_column=filter.column_by_id(params[:id].to_i) - if target_column.order_index>=1 && target_column.order_index<filter.columns.size - target_column.order_index+=1 - target_column.save - old_right_col=filter.columns[target_column.order_index-1] - old_right_col.order_index-=1 - old_right_col.save - end - redirect_to :action => 'edit', :id => filter.id + column=FilterColumn.find(params[:id]) + filter=column.filter + + access_denied unless filter.authorized_to_edit?(self) + + filter.clean_columns_order() # clean the columns which are badly ordered (see SONAR-1902) + target_column=filter.column_by_id(params[:id].to_i) + if target_column.order_index>=1 && target_column.order_index<filter.columns.size + target_column.order_index+=1 + target_column.save + old_right_col=filter.columns[target_column.order_index-1] + old_right_col.order_index-=1 + old_right_col.save + end + redirect_to :action => 'edit', :id => filter.id end def set_sorted_column - column=FilterColumn.find(params[:id]) - filter=column.filter - - access_denied unless filter.authorized_to_edit?(self) - - filter.columns.each do |col| - if col==column - col.sort_direction=params[:sort] - else - col.sort_direction=nil - end - col.save! - end - redirect_to :action => 'edit', :id => filter.id + column=FilterColumn.find(params[:id]) + filter=column.filter + + access_denied unless filter.authorized_to_edit?(self) + + filter.columns.each do |col| + if col==column + col.sort_direction=params[:sort] + else + col.sort_direction=nil + end + col.save! + end + redirect_to :action => 'edit', :id => filter.id end @@ -294,36 +208,36 @@ class FiltersController < ApplicationController # #--------------------------------------------------------------------- def set_view - filter=::Filter.find(params[:id]) - access_denied unless filter.authorized_to_edit?(self) + filter=::Filter.find(params[:id]) + access_denied unless filter.authorized_to_edit?(self) - filter.default_view=params[:view] - filter.save - redirect_to :action => :edit, :id => filter.id + filter.default_view=params[:view] + filter.save + redirect_to :action => :edit, :id => filter.id end def set_columns - filter=::Filter.find(params[:id]) - access_denied unless filter.authorized_to_edit?(self) - - filter.columns.clear - params[:columns].each do |colstring| - column=::FilterColumn.create_from_string(colstring) - filter.columns<<column if column - end - filter.save - redirect_to :action => :edit, :id => filter.id + filter=::Filter.find(params[:id]) + access_denied unless filter.authorized_to_edit?(self) + + filter.columns.clear + params[:columns].each do |colstring| + column=::FilterColumn.create_from_string(colstring) + filter.columns<<column if column + end + filter.save + redirect_to :action => :edit, :id => filter.id end def set_page_size - filter=::Filter.find(params[:id]) - access_denied unless filter.authorized_to_edit?(self) - - size=[::Filter::MAX_PAGE_SIZE, params[:size].to_i].min - size=[::Filter::MIN_PAGE_SIZE, size].max - filter.page_size=size - filter.save - redirect_to :action => :edit, :id => filter.id + filter=::Filter.find(params[:id]) + access_denied unless filter.authorized_to_edit?(self) + + size=[::Filter::MAX_PAGE_SIZE, params[:size].to_i].min + size=[::Filter::MIN_PAGE_SIZE, size].max + filter.page_size=size + filter.save + redirect_to :action => :edit, :id => filter.id end #--------------------------------------------------------------------- @@ -332,26 +246,26 @@ class FiltersController < ApplicationController # #--------------------------------------------------------------------- def search_path - if params[:search].present? - if params[:search].size<3 - flash[:warning]='Please type at least 3 characters' - redirect_to :action => :search_path - - else - @snapshots=Snapshot.find(:all, :include => [:project, {:root_snapshot => :project}, {:parent_snapshot => :project}], - :conditions => ['snapshots.status=? AND snapshots.islast=? AND snapshots.scope=? AND projects.scope=? AND UPPER(projects.long_name) LIKE ?', 'P', true, 'PRJ', 'PRJ', "%#{params[:search].upcase}%"], - :order => 'projects.long_name') - @snapshots=select_authorized(:user, @snapshots) - @snapshots.sort! do |s1, s2| - if s1.qualifier==s2.qualifier - s1.project.long_name<=>s2.project.long_name - else - Resourceable::QUALIFIERS.index(s1.qualifier)<=>Resourceable::QUALIFIERS.index(s2.qualifier) - end - end - end - end - params[:layout]='false' + if params[:search].present? + if params[:search].size<3 + flash[:warning]='Please type at least 3 characters' + redirect_to :action => :search_path + + else + @snapshots=Snapshot.find(:all, :include => [:project, {:root_snapshot => :project}, {:parent_snapshot => :project}], + :conditions => ['snapshots.status=? AND snapshots.islast=? AND snapshots.scope=? AND projects.scope=? AND UPPER(projects.long_name) LIKE ?', 'P', true, 'PRJ', 'PRJ', "%#{params[:search].upcase}%"], + :order => 'projects.long_name') + @snapshots=select_authorized(:user, @snapshots) + @snapshots.sort! do |s1, s2| + if s1.qualifier==s2.qualifier + s1.project.long_name<=>s2.project.long_name + else + Resourceable::QUALIFIERS.index(s1.qualifier)<=>Resourceable::QUALIFIERS.index(s2.qualifier) + end + end + end + end + params[:layout]='false' end @@ -361,30 +275,30 @@ class FiltersController < ApplicationController # #--------------------------------------------------------------------- def treemap - @filter=::Filter.find(params[:id]) - access_denied unless @filter.authorized_to_execute?(self) + @filter=::Filter.find(params[:id]) + access_denied unless @filter.authorized_to_execute?(self) - @size_metric=Metric.by_key(params[:size_metric]) - @color_metric=Metric.by_key(params[:color_metric]) + @size_metric=Metric.by_key(params[:size_metric]) + @color_metric=Metric.by_key(params[:color_metric]) - params[:metric_ids]=[@size_metric, @color_metric] + params[:metric_ids]=[@size_metric, @color_metric] - @filter.sorted_column=FilterColumn.new('family' => 'metric', :kee => @size_metric.key, :sort_direction => (@size_metric.direction>=0 ? 'ASC' : 'DESC')) + @filter.sorted_column=FilterColumn.new('family' => 'metric', :kee => @size_metric.key, :sort_direction => (@size_metric.direction>=0 ? 'ASC' : 'DESC')) - @filter_context=Filters.execute(@filter, self, params) + @filter_context=Filters.execute(@filter, self, params) - @width=(params[:width]||'800').to_i - @height=(params[:height]||'500').to_i + @width=(params[:width]||'800').to_i + @height=(params[:height]||'500').to_i - @treemap = Sonar::Treemap.new(@filter.id, @size_metric, @width, @height, { - :color_metric => @color_metric, - :period_index => @filter_context.period_index, - :measures_by_snapshot => @filter_context.measures_by_snapshot - }) + @treemap = Sonar::Treemap.new(@filter.id, @size_metric, @width, @height, { + :color_metric => @color_metric, + :period_index => @filter_context.period_index, + :measures_by_snapshot => @filter_context.measures_by_snapshot + }) - #@treemap=Sonar::Treemap.new(@filter_context.measures_by_snapshot, @width, @height, @size_metric, @color_metric, treemap_options) - render :action => "treemap", :layout => false + #@treemap=Sonar::Treemap.new(@filter_context.measures_by_snapshot, @width, @height, @size_metric, @color_metric, treemap_options) + render :action => "treemap", :layout => false end @@ -398,74 +312,74 @@ class FiltersController < ApplicationController private def load_filter_from_params(filter, params) - filter.name=params[:name] - filter.shared=(params[:shared].present? && is_admin?) - filter.favourites=params[:favourites].present? - filter.resource_id=(params[:path_id].present? ? Project.by_key(params[:path_id]).id : nil) - filter.user_id=current_user.id - filter.period_index=params[:period_index].to_i - filter.criteria=[] - filter.criteria<<Criterion.new_for_qualifiers(params['qualifiers']) - filter.criteria<<Criterion.new(:family => 'date', :operator => params['date_operator'], :value => params['date_value']) if params['date_operator'].present? - filter.criteria<<Criterion.new(:family => 'key', :operator => '=', :text_value => params['key_regexp']) if params['key_regexp'].present? - filter.criteria<<Criterion.new(:family => 'name', :operator => '=', :text_value => params['name_regexp']) if params['name_regexp'].present? - filter.criteria<<Criterion.new(:family => 'language', :operator => '=', :text_value => params['languages'].join(',')) if params['languages'] - - if params[:criteria]['0']['metric_id'].present? - filter.criteria<<Criterion.new_for_metric(params[:criteria]['0']) - end - if params[:criteria]['1']['metric_id'].present? - filter.criteria<<Criterion.new_for_metric(params[:criteria]['1']) - end - if params[:criteria]['2']['metric_id'].present? - filter.criteria<<Criterion.new_for_metric(params[:criteria]['2']) - end - end - - def load_active_filters - @actives=nil - if logged_in? - @actives=current_user.active_filters - @actives=::ActiveFilter.default_active_filters if (@actives.nil? || @actives.empty?) - else - @actives=::ActiveFilter.for_anonymous - end + filter.name=params[:name] + filter.shared=(params[:shared].present? && is_admin?) + filter.favourites=params[:favourites].present? + filter.resource_id=(params[:path_id].present? ? Project.by_key(params[:path_id]).id : nil) + filter.user_id=current_user.id + filter.period_index=params[:period_index].to_i + filter.criteria=[] + filter.criteria<<Criterion.new_for_qualifiers(params['qualifiers']) + filter.criteria<<Criterion.new(:family => 'date', :operator => params['date_operator'], :value => params['date_value']) if params['date_operator'].present? + filter.criteria<<Criterion.new(:family => 'key', :operator => '=', :text_value => params['key_regexp']) if params['key_regexp'].present? + filter.criteria<<Criterion.new(:family => 'name', :operator => '=', :text_value => params['name_regexp']) if params['name_regexp'].present? + filter.criteria<<Criterion.new(:family => 'language', :operator => '=', :text_value => params['languages'].join(',')) if params['languages'] + + if params[:criteria]['0']['metric_id'].present? + filter.criteria<<Criterion.new_for_metric(params[:criteria]['0']) + end + if params[:criteria]['1']['metric_id'].present? + filter.criteria<<Criterion.new_for_metric(params[:criteria]['1']) + end + if params[:criteria]['2']['metric_id'].present? + filter.criteria<<Criterion.new_for_metric(params[:criteria]['2']) + end end def activate_default_filters_if_needed - if current_user.active_filters.empty? - ActiveFilter.default_active_filters.each do |default_active| - current_user.active_filters.create(:filter => default_active.filter, :user => current_user, :order_index => default_active.order_index) - end - @actives=current_user.active_filters - end + if current_user.active_filters.empty? + ActiveFilter.default_active_filters.each do |default_active| + current_user.active_filters.create(:filter => default_active.filter, :user => current_user, :order_index => default_active.order_index) + end + @actives=current_user.active_filters + end end def load_masterproject() - @masterproject=Snapshot.find(:first, :include => 'project', :conditions => ['projects.kee=? and islast=?', 'MASTER_PROJECT', true]) - @masterproject=nil if @masterproject && !(has_role?(:user, @masterproject)) + @masterproject=Snapshot.find(:first, :include => 'project', :conditions => ['projects.kee=? and islast=?', 'MASTER_PROJECT', true]) + @masterproject=nil if @masterproject && !(has_role?(:user, @masterproject)) + end + + def load_active_filters + @actives=nil + if logged_in? + @actives=current_user.active_filters + @actives=::ActiveFilter.default_active_filters if (@actives.nil? || @actives.empty?) + else + @actives=::ActiveFilter.for_anonymous + end end def load_active_filter() - @active=nil - if params[:name] - @active=@actives.to_a.find { |a| a.name==params[:name] } - elsif params[:id] - @active=@actives.to_a.find { |a| a.filter.id==params[:id].to_i } - end - - if @active.nil? && !@actives.empty? - @active=@actives.first - end - - @filter=nil - @period_index=params[:period].to_i - if @active - @filter=@active.filter - unless @filter.ajax_loading? - @filter_context=Filters.execute(@filter, self, params) - load_masterproject() if @filter.projects_homepage? - end - end + @active=nil + if params[:name] + @active=@actives.to_a.find { |a| a.name==params[:name] } + elsif params[:id] + @active=@actives.to_a.find { |a| a.filter.id==params[:id].to_i } + end + + if @active.nil? && !@actives.empty? + @active=@actives.first + end + + @filter=nil + @period_index=params[:period].to_i + if @active + @filter=@active.filter + unless @filter.ajax_loading? + @filter_context=Filters.execute(@filter, self, params) + load_masterproject() if @filter.projects_homepage? + end + end end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/admin_filters/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/admin_filters/index.html.erb deleted file mode 100644 index 06254b1f73a..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/admin_filters/index.html.erb +++ /dev/null @@ -1,72 +0,0 @@ -<div class="admin_page"> - <h1><%= message('filters.default') -%></h1> - <p><%= message('filters.default.description') -%></p> - - <table class="data" id="admin_console"> - <thead> - <tr> - <th class="name"><%= message('name') -%></th> - <th><%= message('author') -%></th> - <th><%= message('order') -%></th> - <th class="right"><%= message('operations') -%></th> - </tr> - </thead> - <tbody> - <% if @actives.empty? %> - <tr class="even"> - <td colspan="4">No results.</td> - </tr> - <% else %> - <% @actives.each_with_index do |active, index| %> - <tr id="active-<%= u active.name -%>" class="<%= cycle('even', 'odd', :name => 'actives') -%>"> - <td><%= active.name %></td> - <td> - <%= h(active.author_name) %> - </td> - <td> - <% if index>0 %> - <%= link_to image_tag('blue-up.png'), {:action => :up, :id => active.id}, :method => :post, :id => "up-#{u active.name}" %> - <% else %> - <%= image_tag('transparent_16.gif') %> - <% end %> - <% if index<@actives.size-1 %> - <%= link_to image_tag('blue-down.png'), {:action => :down, :id => active.id}, :method => :post, :id => "down-#{u active.name}" %> - <% end %> - </td> - <td class="thin nowrap right"> - <%= link_to 'Remove', {:action => 'remove', :id => active.id}, {:confirm => 'Are you sure to remove it from default filters ?', :method => :post, :id => "remove-#{u active.name}", :class => 'link-action'} %> - </td> - </tr> - <% end %> - <% end %> - </tbody> - </table> - - <h1><%= message('filters.shared') -%></h1> - <p><%= message('filters.shared.description') -%></p> - - <table class="data" id="shared"> - <thead> - <tr> - <th><%= message('name') -%></th> - <th><%= message('author') -%></th> - <th class="right"><%= message('operations') -%></th> - </tr> - </thead> - <tbody> - <% if @shared_filters.nil? || @shared_filters.empty? %> - <tr class="even"> - <td colspan="3">No results.</td> - </tr> - <% else %> - <% @shared_filters.each do |filter| %> - <tr class="<%= cycle('even', 'odd') -%>"> - <td><%= h(filter.name) -%></td> - <td><%= h(filter.user.name) if filter.user -%></td> - <td class="thin nowrap right"><%= link_to 'Add to defaults', {:action => 'add', :id => filter.id}, {:method => :post, :id => "add-#{u filter.name}", :class => 'link-action'} %></td> - </tr> - <% end %> - <% end %> - </tbody> - </table> -</div> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_menu.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_menu.erb new file mode 100644 index 00000000000..63d0f4adccc --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_menu.erb @@ -0,0 +1,15 @@ +<% if logged_in? %> + <div id="page-operations"> + <ul class="operations"> + <li> + <a href="<%= url_for :action => 'new' -%>"><%= message('filters.add_filter') -%></a> + </li> + <% if @filter && @filter.id && @filter.authorized_to_edit?(self) %> + <li> + <a href="<%= url_for :action => 'edit', :id => @filter.id -%>"><%= message('filters.edit_filter') -%></a> + </li> + <% end %> + <li class="last"><%= link_to message('filters.manage_filters'), {:action => 'manage'} -%></li> + </ul> + </div> +<% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_tabs.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_tabs.html.erb deleted file mode 100644 index 09fd2a9013d..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_tabs.html.erb +++ /dev/null @@ -1,21 +0,0 @@ -<% if logged_in? %> -<div id="page-operations"> - <ul class="operations"> - <li><a href="<%= url_for :action => 'new' -%>" ><%= message('filters.add_filter') -%></a></li> - <% if @filter && @filter.id && @filter.authorized_to_edit?(self) %> - <li><a href="<%= url_for :action => 'edit', :id => @filter.id -%>"><%= message('filters.edit_filter') -%></a></li> - <% end %> - <li class="last"><%= link_to message('filters.manage_filters'), {:action => 'manage'} -%></li> - </ul> -</div> -<% end %> - -<% if selected_tab && @actives && !@actives.empty? %> -<ul class="tabs" id="filter-tabs"> -<% @actives.each do |active| %> - <li> - <a href="<%= url_for :action => 'index', :id => active.filter.id -%>" class="<%= 'selected' if selected_tab==active.filter.id -%>"><%= active.name -%></a> - </li> -<% end %> -</ul> -<% end %>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/index.html.erb index 4790275a8c5..137ece702db 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/index.html.erb @@ -1,4 +1 @@ -<%= render :partial => 'filters/tabs', :locals => {:selected_tab=> (@active && @active.filter ? @active.filter.id : nil) } %> -<div class="tabs-panel"> - <%= render :partial => "filters/#{@filter.default_view}", :locals => {:edit_mode => false} if @filter %> -</div> +<%= render :partial => "#{@filter.default_view}", :locals => {:edit_mode => false} if @filter %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/manage.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/manage.html.erb index 8d7486cb191..9e191947586 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/manage.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/manage.html.erb @@ -1,80 +1,39 @@ -<%= render :partial => 'filters/tabs', :locals => {:selected_tab => nil} %> +<%= render :partial => 'menu' %> -<h1><%= message('filters.my_filters') -%></h1> -<br/> -<table class="data" id="actives"> - <thead> - <tr> - <th><%= message('name') -%></th> - <th><%= message('author') -%></th> - <th><%= message('shared') -%></th> - <th><%= message('order') -%></th> - <th><%= message('operations') -%></th> - </tr> - </thead> - <tbody> - <% if @actives.nil? || @actives.empty? %> - <tr class="even"><td colspan="5"><%= message('filters.no_filters') -%></td></tr> +<div class="admin_page"> + <h1><%= message('filters.my_filters') -%></h1> - <% - else - @actives.each_with_index do |active,index| %> - <tr id="active-<%= u active.name -%>" class="<%= cycle('even','odd', :name => 'actives') -%>"> - <td><%= active.name %></td> - <td> - <%= h(active.author_name) %> - </td> - <td> - <%= boolean_icon(active.filter.shared, {:display_false => false}) -%> - </td> - <td> - <% if index>0 %> - <%= link_to image_tag('blue-up.png'), {:action => :up, :id => active.id}, :method => :post, :id => "up-#{u active.name}" %> - <% else %> - <%= image_tag('transparent_16.gif') %> - <% end %> - <% if index<@actives.size-1 %> - <%= link_to image_tag('blue-down.png'), {:action => :down, :id => active.id}, :method => :post, :id => "down-#{u active.name}" %> - <% end %> - </td> - <td> - <% if active.filter.authorized_to_edit?(self) %> - <%= link_to message('edit'), {:action => 'edit', :id => active.filter_id}, :id => "edit-#{u active.name}" %> | - <%= link_to message('delete'), {:action => 'deactivate', :id => active.filter_id}, :method => :post, :confirm => message('filters.do_you_want_to_delete'), :id => "delete-#{u active.name}" %> - <% else %> - <%= link_to message('unfollow'), {:action => 'deactivate', :id => active.filter_id}, :method => :post, :confirm => message('filters.do_you_want_to_stop_following'), :id => "unfollow-#{u active.name}" %> - <% end %> - </td> - </tr> - <% end - end - %> - </tbody> -</table> - -<br/><br/><br/> -<h1><%= message('filters.shared_filters') -%></h1> -<p><%= message('filters.shared_filters_description') -%></p> -<br/> -<table class="data" id="shared"> - <thead> + <table class="data" id="actives"> + <thead> <tr> <th><%= message('name') -%></th> - <th><%= message('author') -%></th> - <th><%= message('operations') -%></th> + <th><%= message('shared') -%></th> + <th class="right"><%= message('operations') -%></th> </tr> - </thead> - <tbody> - <% if @shared_filters.nil? || @shared_filters.empty? %> - <tr class="even"><td colspan="3"><%= message('no_results') -%>.</td></tr> - <% else %> - <% @shared_filters.each do |filter| %> - <tr class="<%= cycle('even', 'odd') -%>"> - <td><%= h(filter.name) -%></td> - <td><%= h(filter.user.name) if filter.user -%></td> - <td><%= link_to 'Follow', {:action => 'activate', :id => filter.id}, :method => :post, :id => "add-#{u filter.name}" %></td> + </thead> + <tbody> + <% if @filters.empty? %> + <tr class="even"> + <td colspan="3"><%= message('filters.no_filters') -%></td> </tr> + <% else %> + <% @filters.each do |filter| %> + <tr id="active-<%= u filter.name -%>" class="<%= cycle('even', 'odd', :name => 'actives') -%>"> + <td> + <%= filter.name -%> + </td> + <td> + <%= boolean_icon(filter.shared, {:display_false => false}) -%> + </td> + <td class="thin nowrap right"> + <% if filter.authorized_to_edit?(self) %> + <%= link_to message('edit'), {:action => :edit, :id => filter.id}, :id => "edit-#{u filter.name}", :class => 'link-action' %> | + <%= link_to message('delete'), {:action => :delete, :id => filter.id}, :method => :post, :confirm => message('filters.do_you_want_to_delete'), :id => "delete-#{u filter.name}", :class => 'link-action' %> + <% end %> + </td> + </tr> + <% end %> <% end %> - <% end %> - </tbody> -</table>
\ No newline at end of file + </tbody> + </table> +</div> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/new.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/new.html.erb index a8ec9cb8a0c..208c3b92317 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/new.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/new.html.erb @@ -1,206 +1,211 @@ -<%= render :partial => 'filters/tabs', :locals => {:selected_tab=> (@filter.id ? @filter.id : 'new')} %> -<style> -table#columns td { - text-align: left; - padding: 0 5px; - font-weight: normal; -} -</style> -<script> - function searchPopup(elt, text) { - newwindow=window.open(elt.href,'search','height=500,width=700,scrollbars=1,resizable=1'); - if (window.focus) { - newwindow.focus(); - } - return false; - } -</script> -<div class="tabs-panel"> +<%= render :partial => 'menu' %> + +<h1><%= message('filters.new') -%></h1> + <div class="admin"> <form id="filter_form" name="filter_form" action="<%= url_for :action => (@filter.id ? 'update' : 'create'), :id => @filter.id -%>" method="post"> - <input type="hidden" name="preview" value="" /> + <input type="hidden" name="preview" value=""/> <%= error_messages_for 'filter', :header_message => nil, :class => 'formError', :message => nil %> <table class="form"> <tbody> <tr> <td class="keyCell"><%= message('name') -%>:</td> <td> - <input type="text" name="name" id="name" value="<%= @filter.name -%>" class="spaced"></input> + <input type="text" name="name" id="name" value="<%= @filter.name -%>" class="spaced"/> <% if is_admin? %> - <span class="spacer"></span> - <label for="shared"><%= message('shared') -%>:</label> - <input type="checkbox" name="shared" id="shared" <%= 'checked' if @filter.shared -%>></input> + <span class="spacer"></span> + <label for="shared"><%= message('shared') -%>:</label> + <input type="checkbox" name="shared" id="shared" <%= 'checked' if @filter.shared -%> /> <% end %> </td> </tr> </tbody> <tbody id="simple-form"> - <tr> - <td class="keyCell"><%= message('path') -%>:</td> - <td> - <b><span id="path_name"><%= @filter.resource ? @filter.resource.path_name : params[:path_name] -%></span></b> - <input type="hidden" name="path_id" id="path_id" value="<%= @filter.resource ? @filter.resource.id : params[:path_id] -%>"></input> - <a onclick="searchPopup(this);return false;" href="<%= url_for :action => :search_path, :search => (@filter.resource ? @filter.resource.name : nil) -%>"><%= message('search_verb') -%></a> - <a href="#" onClick="$('path_name').innerText='';$('path_name').innerHTML='';Form.Element.clear('path_id');return false;"><%= message('reset_verb') -%></a> - </td> - </tr> - <tr> - <td class="keyCell"><%= message('filters.search_for') -%>:</td> - <td> - <% qualifiers=(@filter.criterion('qualifier') ? @filter.criterion('qualifier').text_values : []) %> + <tr> + <td class="keyCell"><%= message('path') -%>:</td> + <td> + <b><span id="path_name"><%= @filter.resource ? @filter.resource.path_name : params[:path_name] -%></span></b> + <input type="hidden" name="path_id" id="path_id" value="<%= @filter.resource ? @filter.resource.id : params[:path_id] -%>"/> + <a onclick="searchPopup(this);return false;" href="<%= url_for :action => :search_path, :search => (@filter.resource ? @filter.resource.name : nil) -%>"><%= message('search_verb') -%></a> + <a href="#" onClick="$('path_name').innerText='';$('path_name').innerHTML='';Form.Element.clear('path_id');return false;"><%= message('reset_verb') -%></a> + </td> + </tr> + <tr> + <td class="keyCell"><%= message('filters.search_for') -%>:</td> + <td> + <% qualifiers=(@filter.criterion('qualifier') ? @filter.criterion('qualifier').text_values : []) %> - <input type="checkbox" name="qualifiers[]" value="TRK" <%= 'checked' if qualifiers.include?('TRK') -%> id="q-TRK"></input> <label for="q-TRK"><%= message('qualifiers.TRK') -%></label> - <span class="spacer"> </span> + <input type="checkbox" name="qualifiers[]" value="TRK" <%= 'checked' if qualifiers.include?('TRK') -%> id="q-TRK"/> + <label for="q-TRK"><%= message('qualifiers.TRK') -%></label> + <span class="spacer"> </span> - <input type="checkbox" name="qualifiers[]" value="BRC" <%= 'checked' if qualifiers.include?('BRC') -%> id="q-BRC"></input> <label for="q-BRC"><%= message('qualifiers.BRC') -%></label> - <span class="spacer"> </span> + <input type="checkbox" name="qualifiers[]" value="BRC" <%= 'checked' if qualifiers.include?('BRC') -%> id="q-BRC"/> + <label for="q-BRC"><%= message('qualifiers.BRC') -%></label> + <span class="spacer"> </span> - <input type="checkbox" name="qualifiers[]" value="DIR,PAC" <%= 'checked' if qualifiers.include?('DIR') -%> id="q-DIR"></input> <label for="q-DIR"><%= message('qualifiers.DIR') -%>/<%= message('qualifiers.PAC') -%></label> - <span class="spacer"> </span> + <input type="checkbox" name="qualifiers[]" value="DIR,PAC" <%= 'checked' if qualifiers.include?('DIR') -%> id="q-DIR"/> + <label for="q-DIR"><%= message('qualifiers.DIR') -%>/<%= message('qualifiers.PAC') -%></label> + <span class="spacer"> </span> - <input type="checkbox" name="qualifiers[]" value="FIL,CLA" <%= 'checked' if qualifiers.include?('FIL') -%> id="q-FIL"></input> <label for="q-FIL"><%= message('qualifiers.FIL') -%></label> - <span class="spacer"> </span> + <input type="checkbox" name="qualifiers[]" value="FIL,CLA" <%= 'checked' if qualifiers.include?('FIL') -%> id="q-FIL"/> + <label for="q-FIL"><%= message('qualifiers.FIL') -%></label> + <span class="spacer"> </span> - <input type="checkbox" name="qualifiers[]" value="UTS" <%= 'checked' if qualifiers.include?('UTS') -%> id="q-UTS"></input> <label for="q-UTS"><%= message('qualifiers.UTS') -%></label> - <span class="spacer"> </span> + <input type="checkbox" name="qualifiers[]" value="UTS" <%= 'checked' if qualifiers.include?('UTS') -%> id="q-UTS"/> + <label for="q-UTS"><%= message('qualifiers.UTS') -%></label> + <span class="spacer"> </span> - <% for desc in controller.java_facade.getResourceTypesForFilter() - qualifier = desc.getQualifier() %> - <input type="checkbox" name="qualifiers[]" value="<%= qualifier -%>" <%= 'checked' if qualifiers.include?(qualifier) -%> id="q-<%= qualifier -%>"></input> - <label for="q-<%= qualifier -%>"><%= message("qualifiers.#{qualifier}") -%></label> - <span class="spacer"> </span> - <% end %> - </td> - </tr> - <tr> - <td class="keyCell"><%= message('filters.criteria') -%>:</td> - <td> - <%= render :partial => 'filters/criterion', :locals => {:id => '0', :criterion => (@filter.measure_criteria.size>0 ? @filter.measure_criteria[0] : nil)} %> - </td> - </tr> - <tr> - <td class="keyCell"><%= message('and').downcase -%>: </td> - <td> - <%= render :partial => 'filters/criterion', :locals => {:id => '1', :criterion => (@filter.measure_criteria.size>1 ? @filter.measure_criteria[1] : nil) } %> - </td> - </tr> - <tr> - <td class="keyCell"><%= message('and').downcase -%>: </td> - <td> - <%= render :partial => 'filters/criterion', :locals => {:id => '2', :criterion => (@filter.measure_criteria.size>2 ? @filter.measure_criteria[2] : nil) } %> - </td> - </tr> - <% unless @filter.advanced_search? %> + <% for desc in controller.java_facade.getResourceTypesForFilter() + qualifier = desc.getQualifier() %> + <input type="checkbox" name="qualifiers[]" value="<%= qualifier -%>" <%= 'checked' if qualifiers.include?(qualifier) -%> id="q-<%= qualifier -%>"/> + <label for="q-<%= qualifier -%>"><%= message("qualifiers.#{qualifier}") -%></label> + <span class="spacer"> </span> + <% end %> + </td> + </tr> + <tr> + <td class="keyCell"><%= message('filters.criteria') -%>:</td> + <td> + <%= render :partial => 'filters/criterion', :locals => {:id => '0', :criterion => (@filter.measure_criteria.size>0 ? @filter.measure_criteria[0] : nil)} %> + </td> + </tr> + <tr> + <td class="keyCell"><%= message('and').downcase -%>:</td> + <td> + <%= render :partial => 'filters/criterion', :locals => {:id => '1', :criterion => (@filter.measure_criteria.size>1 ? @filter.measure_criteria[1] : nil)} %> + </td> + </tr> + <tr> + <td class="keyCell"><%= message('and').downcase -%>:</td> + <td> + <%= render :partial => 'filters/criterion', :locals => {:id => '2', :criterion => (@filter.measure_criteria.size>2 ? @filter.measure_criteria[2] : nil)} %> + </td> + </tr> + <% unless @filter.advanced_search? %> <tr id="advanced-search-link"> - <td colspan="2"><a href="#" onClick="$('advanced-search').show();$('advanced-search-link').hide();return false;"><%= message('filters.advanced_search') -%></a></td> + <td colspan="2"> + <a href="#" onClick="$('advanced-search').show();$('advanced-search-link').hide();return false;"><%= message('filters.advanced_search') -%></a> + </td> </tr> - <% end %> + <% end %> </tbody> <tbody id="advanced-search" style="<%= 'display: none' unless @filter.advanced_search? -%>"> - <tr> - <td class="keyCell"><%= message('filters.default_period') -%>:</td> - <td> - <select id="period_index" name="period_index"> - <option value=""><%= message('none') -%></option> - <% period_names.each_with_index do |name, index| %> - <option value="<%= index+1 -%>" <%= 'selected' if @filter.period_index==index+1 -%>><%= name -%></value> - <% end %> - </select> - </td> - </tr> - <tr> - <td class="keyCell"><%= message('language') -%>:</td> - <td> - <% languages=(@filter.criterion('language') ? @filter.criterion('language').text_values : []) %> - <% controller.java_facade.getLanguages().each do |language| %> - <input type="checkbox" name="languages[]" value="<%= language.getKey() -%>" <%= 'checked' if languages.include?(language.getKey()) -%> id="lang-<%= language.getKey() -%>"> </input> <label for="lang-<%= language.getKey() -%>"><%= language.getName() -%></label> + <tr> + <td class="keyCell"><%= message('filters.default_period') -%>:</td> + <td> + <select id="period_index" name="period_index"> + <option value=""><%= message('none') -%></option> + <% period_names.each_with_index do |name, index| %> + <option value="<%= index+1 -%>" <%= 'selected' if @filter.period_index==index+1 -%>><%= name -%></option> <% end %> - <span class="comments"><%= message('filters.when_no_language_no_filter_apply') -%></span> - </td> - </tr> - <tr> - <td class="keyCell"><%= image_tag 'star.png' %> <label for="favourites"><%= message('filters.favourite_only') -%>:</label></td> - <td> - <input type="checkbox" name="favourites" id="favourites" <%= 'checked' if @filter.favourites -%>></input> - </td> - </tr> - <tr> - <td class="keyCell"><label for="key_regexp"><%= message('filters.resource_key_like') -%>:</label></td> - <td> - <% key_regexp_criterion=@filter.criterion('key') %> - <input type="text" name="key_regexp" id="key_regexp" value="<%= key_regexp_criterion.text_value if key_regexp_criterion -%>"></input> - <span class="comments"><%= message('filters.use_star_to_match') -%></span> - </td> - </tr> - <tr> - <td class="keyCell"><label for="name_regexp"><%= message('filters.resource_name_like') -%>:</label></td> - <td> - <% name_regexp_criterion=@filter.criterion('name') %> - <input type="text" name="name_regexp" id="name_regexp" value="<%= name_regexp_criterion.text_value if name_regexp_criterion -%>"></input> - <span class="comments"><%= message('filters.use_star_to_match') -%></span> - </td> - </tr> - <tr> - <td class="keyCell"><label for="date"><%= message('filters.build_date') -%>:</label></td> - <td> - <% date_criterion = @filter.criterion('date') %> - <select id="date_operator" name="date_operator"> - <option value=""></option> - <option value="<" <%= 'selected' if (date_criterion && date_criterion.operator=='<') -%>><%= message('filters.prior_to_last') -%></value> - <option value=">=" <%= 'selected' if (date_criterion && date_criterion.operator=='>=') -%>><%= message('filters.during_last') -%></value> - </select> - <input type="text" name="date_value" id="date_value" size="3" value="<%= date_criterion.value.to_i if date_criterion -%>"></input> <%= message('days').downcase -%> - </td> - </tr> + </select> + </td> + </tr> + <tr> + <td class="keyCell"><%= message('language') -%>:</td> + <td> + <% languages=(@filter.criterion('language') ? @filter.criterion('language').text_values : []) %> + <% controller.java_facade.getLanguages().each do |language| %> + <input type="checkbox" name="languages[]" value="<%= language.getKey() -%>" <%= 'checked' if languages.include?(language.getKey()) -%> id="lang-<%= language.getKey() -%>"> </input> + <label for="lang-<%= language.getKey() -%>"><%= language.getName() -%></label> + <% end %> + <span class="comments"><%= message('filters.when_no_language_no_filter_apply') -%></span> + </td> + </tr> + <tr> + <td class="keyCell"><%= image_tag 'star.png' %> + <label for="favourites"><%= message('filters.favourite_only') -%>:</label></td> + <td> + <input type="checkbox" name="favourites" id="favourites" <%= 'checked' if @filter.favourites -%> /> + </td> + </tr> + <tr> + <td class="keyCell"><label for="key_regexp"><%= message('filters.resource_key_like') -%>:</label></td> + <td> + <% key_regexp_criterion=@filter.criterion('key') %> + <input type="text" name="key_regexp" id="key_regexp" value="<%= key_regexp_criterion.text_value if key_regexp_criterion -%>"/> + <span class="comments"><%= message('filters.use_star_to_match') -%></span> + </td> + </tr> + <tr> + <td class="keyCell"><label for="name_regexp"><%= message('filters.resource_name_like') -%>:</label></td> + <td> + <% name_regexp_criterion=@filter.criterion('name') %> + <input type="text" name="name_regexp" id="name_regexp" value="<%= name_regexp_criterion.text_value if name_regexp_criterion -%>"/> + <span class="comments"><%= message('filters.use_star_to_match') -%></span> + </td> + </tr> + <tr> + <td class="keyCell"><label for="date"><%= message('filters.build_date') -%>:</label></td> + <td> + <% date_criterion = @filter.criterion('date') %> + <select id="date_operator" name="date_operator"> + <option value=""></option> + <option value="<" <%= 'selected' if (date_criterion && date_criterion.operator=='<') -%>><%= message('filters.prior_to_last') -%></option> + <option value=">=" <%= 'selected' if (date_criterion && date_criterion.operator=='>=') -%>><%= message('filters.during_last') -%></option> + </select> + <input type="text" name="date_value" id="date_value" size="3" value="<%= date_criterion.value.to_i if date_criterion -%>"/> <%= message('days').downcase -%> + </td> + </tr> </tbody> <tbody> - <tr> - <td colspan="2"> - <input type="submit" value="<%= message('save_and_preview') -%>" onclick="filter_form.preview.value='true';return true;"/> - <span class="spacer"> </span> - <input type="submit" value="<%= message('save_and_close') -%>" /> + <tr> + <td colspan="2"> + <input type="submit" value="<%= message('save_and_preview') -%>" onclick="filter_form.preview.value='true';return true;"/> + <span class="spacer"> </span> + <input type="submit" value="<%= message('save_and_close') -%>"/> + <span class="spacer"> </span> + <% if @filter.id + confirmation_message = message('filters.do_you_want_to_delete') + %> + <input name="delete" class="red-button" value="<%= message('delete') -%>" type="button" + onclick="if (confirm('<%= confirmation_message -%>')) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = '<%= url_for :action => 'delete', :id => @filter.id %>';f.submit(); };return false;"> <span class="spacer"> </span> - <% if @filter.id - confirmation_message = message('filters.do_you_want_to_delete') - %> - <input name="delete" class="red-button" value="<%= message('delete') -%>" type="button" - onclick="if (confirm('<%= confirmation_message -%>')) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = '<%= url_for :action => 'delete', :id => @filter.id %>';f.submit(); };return false;"> - <span class="spacer"> </span> - <a href="<%= url_for :action => 'index', :name => @filter.name -%>"><%= message('cancel') -%></a> - <% else %> - <a href="<%= url_for :action => 'index' -%>"><%= message('cancel') -%></a> - <% end %> - </td> - </tr> - </tbody> - </table> -</form> + <a href="<%= url_for :action => :manage, :name => @filter.name -%>"><%= message('cancel') -%></a> + <% else %> + <a href="<%= url_for :action => :manage -%>"><%= message('cancel') -%></a> + <% end %> + </td> + </tr> + </tbody> + </table> + </form> </div> -<script> -$('name').focus(); -</script> <br/> <% if @filter_context %> <h1><%= message('filters.display_form.title') -%></h1> + <div class="admin"> <table class="form" id="view-form"> <tr> <td class="keyCell"><%= message('filters.display_form.as') -%>:</td> <td> <form action="<%= url_for :action => :set_view, :id => @filter.id -%>" method="POST"> - <input type="radio" name="view" value="list" <%= 'checked' if @filter.default_view==::Filter::VIEW_LIST -%> id="view-list" onClick="$('view-loading').show();submit();"></input> <label for="view-list"><%= message('filters.display_form.table') -%></label> + <input type="radio" name="view" value="list" <%= 'checked' if @filter.default_view==::Filter::VIEW_LIST -%> id="view-list" onClick="$('view-loading').show();submit();"/> + <label for="view-list"><%= message('filters.display_form.table') -%></label> <span class="spacer"> </span> - <input type="radio" name="view" value="treemap" <%= 'checked' if @filter.default_view==::Filter::VIEW_TREEMAP -%> id="view-treemap" onClick="$('view-loading').show();submit();"></input> <label for="view-treemap"><%= message('filters.display_form.treemap') -%></label> + <input type="radio" name="view" value="treemap" <%= 'checked' if @filter.default_view==::Filter::VIEW_TREEMAP -%> id="view-treemap" onClick="$('view-loading').show();submit();"/> + <label for="view-treemap"><%= message('filters.display_form.treemap') -%></label> <span class="spacer"> </span> - <%= image_tag 'loading.gif', :id => 'view-loading', :style=>'display: none' %> + <%= image_tag 'loading.gif', :id => 'view-loading', :style => 'display: none' %> </form> </td> </tr> - <%= render :partial => "filters/customize_#{@filter.default_view}" %> + <%= render :partial => "customize_#{@filter.default_view}" %> </table> </div> <br/> - <%= render :partial => "filters/#{@filter.default_view}", :locals => {:edit_mode => true} %> + <%= render :partial => "#{@filter.default_view}", :locals => {:edit_mode => true} %> <% end %> -</div>
\ No newline at end of file + +<script> + function searchPopup(elt, text) { + newwindow = window.open(elt.href, 'search', 'height=500,width=700,scrollbars=1,resizable=1'); + if (window.focus) { + newwindow.focus(); + } + return false; + } + $('name').focus(); +</script> 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 bd130391597..8a4a2cb790a 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 @@ -126,7 +126,7 @@ <li class="<%= 'selected' if controller.controller_path=='manual_rules' -%>"> <a href="<%= ApplicationController.root_context -%>/manual_rules/index"><%= message('manual_rules.page') -%></a></li> <li class="<%= 'selected' if controller.controller_path=='admin_filters' -%>"> - <a href="<%= ApplicationController.root_context -%>/admin_filters/index"><%= message('default_filters.page') -%></a></li> + <a href="<%= ApplicationController.root_context -%>/filters/manage"><%= message('default_filters.page') -%></a></li> <li class="<%= 'selected' if controller.controller_path=='admin_dashboards' -%>"> <a href="<%= ApplicationController.root_context -%>/admin_dashboards/index"><%= message('default_dashboards.page') -%></a></li> <% controller.java_facade.getPages(Navigation::SECTION_CONFIGURATION, nil, nil, nil, nil).each do |page| |