Class: MyNagios::ChecksController

Inherits:
ApplicationController show all
Defined in:
app/controllers/my_nagios/checks_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



12
13
14
15
# File 'app/controllers/my_nagios/checks_controller.rb', line 12

def create
  @check = Check.create(params_check)
  redirect_to root_path
end

#editObject



17
18
# File 'app/controllers/my_nagios/checks_controller.rb', line 17

def edit
end

#group_actionObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/my_nagios/checks_controller.rb', line 41

def group_action
  check_ids = params["group_action_check_ids"].split(',')
  redirect_to root_path and return if check_ids.blank?

  case params['check_group_action'].downcase
  when 'disable'
    Check.where(id: check_ids).update_all(enabled: false)
  when 'enable'
    Check.where(id: check_ids).update_all(enabled: true)
  when 'snooze for'
    Check.where(id: check_ids).update_all(snooze_for: (Time.now + params['snooze_time_select'].to_i.minutes))
  end

  redirect_to root_path
end

#newObject



8
9
10
# File 'app/controllers/my_nagios/checks_controller.rb', line 8

def new
  @check = Check.new
end

#run_nowObject



25
26
27
28
29
30
31
# File 'app/controllers/my_nagios/checks_controller.rb', line 25

def run_now
  @check.run!

  respond_to do |format|
    format.js { render layout: false }
  end
end

#toggleObject



33
34
35
36
37
38
39
# File 'app/controllers/my_nagios/checks_controller.rb', line 33

def toggle
  @check.toggle! :enabled

  respond_to do |format|
    format.js { render layout: false }
  end
end

#updateObject



20
21
22
23
# File 'app/controllers/my_nagios/checks_controller.rb', line 20

def update
  @check.update(params_check)
  redirect_to root_path
end