Sha256: 0abd36ed3fdeee53e3aa5a1f9ba997fb63777b8e701897dcc2bf93d57535b4b1

Contents?: true

Size: 1.48 KB

Versions: 3

Compression:

Stored size: 1.48 KB

Contents

module Logs
  
  # ---------------------------------------------------------------------------
  get "/logs/:page" do    
    page       = params[:page] ? params[:page].to_i : 1
    
    @logs        = Wackamole::Log.paginate( @filter.to_conds, page)   
    @search_path = "/logs/search"
    @filter_path = "/logs/filter"
    
    if request.xhr?
      erb :'logs/index.js', :layout => false
    else
      erb :'logs/index'
    end
  end
  
  # ---------------------------------------------------------------------------
  # Search logs - must specify a context ie ses: fred
  post "/logs/search" do
    begin
      @filter.search_terms = params[:search_filter][:search_terms]
      @logs = Wackamole::Log.paginate( @filter.to_conds )
    rescue => boom
      puts boom
      flash_it!( :error, boom )
      @logs = [].paginate
    end

    erb :"logs/filter.js", :layout => false
  end
  
  # ---------------------------------------------------------------------------
  # Fecth info about a particular log
  get "/logs/:id/show" do
    @log = Wackamole::Log.find_one( Mongo::ObjectID.from_string( params[:id] ) )
    erb :"logs/show", :layout => false 
  end
  
  # ---------------------------------------------------------------------------
  # Filter logs
  post "/logs/filter" do    
    @filter = Wackamole::SearchFilter.new
    @filter.from_options( params[:filter] )
    session[:filter] = @filter
    @logs = Wackamole::Log.paginate( @filter.to_conds )
    erb :"logs/filter.js", :layout => false
  end  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wackamole-0.0.3 lib/controllers/logs.rb
wackamole-0.0.2 lib/controllers/logs.rb
wackamole-0.0.1 lib/controllers/logs.rb