Class: LookupKeysController

Inherits:
ApplicationController show all
Includes:
Foreman::Controller::AutoCompleteSearch
Defined in:
app/controllers/lookup_keys_controller.rb

Instance Method Summary collapse

Methods included from Foreman::Controller::AutoCompleteSearch

#auto_complete_search, #invalid_search_query

Methods inherited from ApplicationController

#api_request?, #welcome

Methods included from Foreman::ThreadSession::Cleaner

#clear_thread, included

Instance Method Details

#destroyObject


45
46
47
48
49
50
51
# File 'app/controllers/lookup_keys_controller.rb', line 45

def destroy
  if @lookup_key.destroy
    process_success
  else
    process_error
  end
end

#editObject


34
35
# File 'app/controllers/lookup_keys_controller.rb', line 34

def edit
end

#indexObject


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/lookup_keys_controller.rb', line 6

def index
  begin
    values = LookupKey.search_for(params[:search], :order => params[:order])
  rescue => e
    error e.to_s
    values = LookupKey.search_for ""
  end

  respond_to do |format|
    format.html do
      @lookup_keys = values.paginate(:page => params[:page], :include => [:puppetclass])
    end
    format.json { render :json => values}
  end
end

#showObject


22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/lookup_keys_controller.rb', line 22

def show
  if (name = params[:host_id]).blank? or (host = Host.find_by_name(name)).blank?
    value = @lookup_key
  else
    value = { :value => Classification::GlobalParam.new(:host=>host).enc[@lookup_key.key] }
  end

  respond_to do |format|
    format.json { render :json => value }
  end
end

#updateObject


37
38
39
40
41
42
43
# File 'app/controllers/lookup_keys_controller.rb', line 37

def update
  if @lookup_key.update_attributes(params[:lookup_key])
    process_success
  else
    process_error
  end
end