Merge pull request #142 from warpc/127-build-lists-filter-refactor

[Done #127] Reduced the query string for monitoring page
This commit is contained in:
Vladimir Sharshov 2012-02-01 10:18:11 -08:00
commit 92a8e591de
4 changed files with 24 additions and 13 deletions

View File

@ -14,20 +14,29 @@ class BuildListsController < ApplicationController
load_and_authorize_resource :except => CALLBACK_ACTIONS.concat(NESTED_ACTIONS)
def index
filter_params = params[:filter] || {}
if @project
@action_url = project_build_lists_path(@project)
if request.post?
new_params = {:filter => {}}
params[:filter].each do |k,v|
new_params[:filter][k] = v unless v.empty?
end
redirect_to build_lists_path(new_params)
else
@action_url = build_lists_path
end
filter_params = params[:filter] || {}
if @project
@action_url = project_build_lists_path(@project)
else
@action_url = build_lists_path
end
@filter = BuildList::Filter.new(@project, filter_params)
@build_lists = @filter.find.accessible_by(current_ability).recent.paginate :page => params[:page]
@filter = BuildList::Filter.new(@project, filter_params)
@build_lists = @filter.find.accessible_by(current_ability).recent.paginate :page => params[:page]
@build_server_status = begin
BuildServer.get_status
rescue Exception # Timeout::Error
{}
@build_server_status = begin
BuildServer.get_status
rescue Exception # Timeout::Error
{}
end
end
end

View File

@ -68,7 +68,7 @@ class BuildList::Filter
def build_date_from_params(field_name, params)
if params["#{field_name}(1i)"].present? || params["#{field_name}(2i)"].present? || params["#{field_name}(3i)"].present?
Date.civil((params["#{field_name}(1i)"].presence || Date.today.year).to_i,
(params["#{field_name}(2i)"].presence || Date.today.mohth).to_i,
(params["#{field_name}(2i)"].presence || Date.today.month).to_i,
(params["#{field_name}(3i)"].presence || Date.today.day).to_i)
else
nil

View File

@ -1,6 +1,6 @@
%h2.title= t("layout.build_lists.filter_header")
= form_for :filter, :url => @action_url, :html => { :method => :get, :class => :form } do |f|
= form_for :filter, :url => @action_url, :html => { :method => :post, :class => :form } do |f|
.columns.wat-cf
.column.left
.group

View File

@ -42,6 +42,8 @@ Rosa::Application.routes.draw do
end
end
post 'build_lists' => 'build_lists#index', :as => 'build_lists'
resources :auto_build_lists, :only => [:index, :create, :destroy]
resources :personal_repositories, :only => [:show] do