Class: ForemanDatacenter::DevicesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ForemanDatacenter::DevicesController
- Includes:
- Foreman::Controller::AutoCompleteSearch
- Defined in:
- app/controllers/foreman_datacenter/devices_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #destroy_interfaces ⇒ Object
- #device_types ⇒ Object
- #edit ⇒ Object
- #for_rack ⇒ Object
- #index ⇒ Object
- #inventory ⇒ Object
- #new ⇒ Object
- #qr_code ⇒ Object
- #racks ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 46 def create @device = Device.new(device_params) if @device.save process_success object: @device else process_error object: @device end end |
#destroy ⇒ Object
64 65 66 67 68 69 70 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 64 def destroy if @device.destroy process_success object: @device else process_error object: @device end end |
#destroy_interfaces ⇒ Object
87 88 89 90 91 92 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 87 def destroy_interfaces @device.non_management_interfaces. where(id: params[:interfaces]). destroy_all redirect_to device_url(@device) end |
#device_types ⇒ Object
72 73 74 75 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 72 def device_types @manufacturer_id = params[:manufacturer_id] render partial: 'device_types' end |
#edit ⇒ Object
41 42 43 44 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 41 def edit @device = Device.find(params[:id]) populate_from_host end |
#for_rack ⇒ Object
82 83 84 85 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 82 def for_rack @rack = ForemanDatacenter::Rack.find(params[:rack_id]) render partial: 'for_rack' end |
#index ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 12 def index begin search = resource_base.search_for(params[:search], :order => params[:order]) rescue => e error e.to_s search = resource_base.search_for '' end @devices = search.includes(:device_role, :device_type, :site, :rack). paginate(:page => params[:page]) end |
#inventory ⇒ Object
33 34 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 33 def inventory end |
#new ⇒ Object
36 37 38 39 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 36 def new @device = Device.new populate_from_host end |
#qr_code ⇒ Object
94 95 96 97 98 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 94 def qr_code send_data(generate_qr_code(@device), filename: "#{@device.name_without_fqdn}.qr.pdf", type: 'application/pdf') end |
#racks ⇒ Object
77 78 79 80 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 77 def racks @site_id = params[:site_id] render partial: 'racks' end |
#show ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 23 def show @device = Device.includes( device_bays: [:installed_device], console_server_ports: [:console_port], power_outlets: [:power_port], console_ports: [:console_server_port], power_ports: [:power_outlet] ).find(params[:id]) end |
#update ⇒ Object
56 57 58 59 60 61 62 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 56 def update if @device.update(device_params) process_success object: @device else process_error object: @device end end |