Sha256: fcb62f465d3e98b5092d4bb3c9059901a6d49df917d67ce8e96264d5a529f63d

Contents?: true

Size: 1019 Bytes

Versions: 3

Compression:

Stored size: 1019 Bytes

Contents

module Afterparty
  class DashboardController < ApplicationController
    before_filter :authenticate
    layout false
    before_filter :find_job, only: [:run, :destroy, :run_again]

    def index
      @queues = Afterparty.queues
      if params[:completed]
        @jobs = AfterpartyJob.completed.limit(20)
      else
        @jobs = queue.jobs
      end
    end

    def run
      queue.run @job
      flash[:notice] = "You successfully completed job ##{@job.id}."
      redirect_to afterparty_engine.dashboard_path(completed: true)
    end

    def destroy
      @job.destroy
      flash[:notice] = "You have successfully destroyed job ##{@job.id}."
      redirect_to afterparty_engine.dashboard_path
    end

    private

    def queue
      Rails.configuration.queue
    end

    def find_job
      @job = AfterpartyJob.find(params[:id])
    end

    def authenticate
      authenticate_or_request_with_http_basic do |username, password|
        queue.authenticate(username, password)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
afterparty-0.2.0 app/controllers/afterparty/dashboard_controller.rb
afterparty-0.1.1 app/controllers/afterparty/dashboard_controller.rb
afterparty-0.1.0 app/controllers/afterparty/dashboard_controller.rb