Class: Admin::RunnersController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/admin/runners_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject


32
33
34
35
36
# File 'app/controllers/admin/runners_controller.rb', line 32

def destroy
  @runner.destroy

  redirect_to admin_runners_path
end

#indexObject


4
5
6
7
8
9
# File 'app/controllers/admin/runners_controller.rb', line 4

def index
  @runners = Ci::Runner.order('id DESC')
  @runners = @runners.search(params[:search]) if params[:search].present?
  @runners = @runners.page(params[:page]).per(30)
  @active_runners_cnt = Ci::Runner.online.count
end

#pauseObject


46
47
48
49
50
51
52
# File 'app/controllers/admin/runners_controller.rb', line 46

def pause
  if @runner.update_attributes(active: false)
    redirect_to admin_runners_path, notice: 'Runner was successfully updated.'
  else
    redirect_to admin_runners_path, alert: 'Runner was not updated.'
  end
end

#resumeObject


38
39
40
41
42
43
44
# File 'app/controllers/admin/runners_controller.rb', line 38

def resume
  if @runner.update_attributes(active: true)
    redirect_to admin_runners_path, notice: 'Runner was successfully updated.'
  else
    redirect_to admin_runners_path, alert: 'Runner was not updated.'
  end
end

#showObject


11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/admin/runners_controller.rb', line 11

def show
  @builds = @runner.builds.order('id DESC').first(30)
  @projects =
    if params[:search].present?
      ::Project.search(params[:search])
    else
      Project.all
    end
  @projects = @projects.where.not(id: @runner.projects.select(:id)) if @runner.projects.any?
  @projects = @projects.page(params[:page]).per(30)
end

#updateObject


23
24
25
26
27
28
29
30
# File 'app/controllers/admin/runners_controller.rb', line 23

def update
  @runner.update_attributes(runner_params)

  respond_to do |format|
    format.js
    format.html { redirect_to admin_runner_path(@runner) }
  end
end