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_type_size ⇒ 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
51 52 53 54 55 56 57 58 59 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 51 def create @device = Device.new(device_params) if @device.save process_success object: @device else process_error object: @device end end |
#destroy ⇒ Object
69 70 71 72 73 74 75 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 69 def destroy if @device.destroy process_success success_redirect: "/datacenter/devices" else process_error object: @device end end |
#destroy_interfaces ⇒ Object
97 98 99 100 101 102 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 97 def destroy_interfaces @device.non_management_interfaces. where(id: params[:interfaces]). destroy_all redirect_to device_url(@device) end |
#device_type_size ⇒ Object
82 83 84 85 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 82 def device_type_size @device_type_id = params[:device_type_id] render partial: 'device_type_size' end |
#device_types ⇒ Object
77 78 79 80 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 77 def device_types @manufacturer_id = params[:manufacturer_id] render partial: 'device_types' end |
#edit ⇒ Object
46 47 48 49 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 46 def edit @device = Device.find(params[:id]) populate_from_host end |
#for_rack ⇒ Object
92 93 94 95 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 92 def for_rack @rack = ForemanDatacenter::Rack.find(params[:rack_id]) render partial: 'for_rack' end |
#index ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 14 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
38 39 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 38 def inventory end |
#new ⇒ Object
41 42 43 44 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 41 def new @device = Device.new populate_from_host end |
#qr_code ⇒ Object
104 105 106 107 108 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 104 def qr_code send_data(generate_qr_code(@device), filename: "#{@device.name_without_fqdn}.qr.pdf", type: 'application/pdf') end |
#racks ⇒ Object
87 88 89 90 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 87 def racks @site_id = params[:site_id] render partial: 'racks' end |
#show ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 25 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]) @current_user = User.current @commentable = @device @comment = Comment.new end |
#update ⇒ Object
61 62 63 64 65 66 67 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 61 def update if @device.update(device_params) process_success object: @device else process_error object: @device end end |