Sha256: bcf83a11a24064ec555cecbf4717e9ac65388d2290c4a695235aeffb7a1bfdb6

Contents?: true

Size: 1.86 KB

Versions: 1

Compression:

Stored size: 1.86 KB

Contents

require 'chronic'

module Mission
  # ---------------------------------------------------------------------------
  get '/mission' do
    clear_flash!
    
     # reset app info
    session[:app_info] = @app_info = nil
  
    # Support store like mongodb where not allowed to peruse connection
    # in which case just show the dashboard
    if Wackamole::Control.single_app?
      app_name, stage = Wackamole::Control.app_info
      redirect "/dashboard/#{app_name}/#{stage}"
      return
    end
    
    last_tick           = session[:last_tick]
    last_tick           ||= Chronic.parse( "#{@refresh_rate} seconds ago" )
    session[:last_tick] = Time.now
    
    @pulse = Wackamole::Mission.pulse( last_tick )
              
    erb :'mission/index'
  end
  
  # ---------------------------------------------------------------------------
  get '/mission/refresh' do
    last_tick           = session[:last_tick]
    last_tick           ||= Chronic.parse( "#{@refresh_rate} seconds ago" )
    session[:last_tick] = Time.now
      
    @pulse = Wackamole::Mission.pulse( last_tick )

    erb :'/mission/refresh_js', :layout => false
  end

  # ---------------------------------------------------------------------------
  get '/mission/logs/:app_name/:stage/:type' do
    Wackamole::Control.switch_mole_db!( params[:app_name].downcase, params[:stage] )
    
    # Set app info
    @app_info = Wackamole::Feature.get_app_info
    session[:app_info] = @app_info

    # Reset filter    
    filter = Wackamole::SearchFilter.new
    filter.mole_type( params[:type].to_i )
    session[:filter] = filter
    
    redirect '/logs/1'
  end

  # # ---------------------------------------------------------------------------
  # get '/mission/fixed/:app/:env/:type' do
  #   Wackamole::Mission.reset!( params[:app], params[:env], params[:type] )
  #   erb :'/mission/refresh_js', :layout => false
  # end  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wackamole-0.0.9 lib/controllers/mission.rb