Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for displaying storage device details #3830

Merged
merged 2 commits into from May 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions app/controllers/physical_server_controller.rb
Expand Up @@ -10,11 +10,15 @@ class PhysicalServerController < ApplicationController
after_action :set_session_data

def self.display_methods
%w(guest_devices)
%w(network_devices storage_devices)
end

def display_guest_devices
nested_list(GuestDevice, :named_scope => :with_ethernet_type)
def display_network_devices
nested_list(GuestDevice, :named_scope => :with_ethernet_type, :breadcrumb_title => _("Network Devices"))
end

def display_storage_devices
nested_list(GuestDevice, :named_scope => :with_storage_type, :breadcrumb_title => _("Storage Devices"))
end

def self.table_name
Expand Down
13 changes: 11 additions & 2 deletions app/helpers/physical_server_helper/textual_summary.rb
Expand Up @@ -2,7 +2,7 @@ module PhysicalServerHelper::TextualSummary
def textual_group_properties
TextualGroup.new(
_("Properties"),
%i(name model product_name manufacturer machine_type serial_number ems_ref capacity memory cores network_devices health_state loc_led_state)
%i(name model product_name manufacturer machine_type serial_number ems_ref capacity memory cores network_devices storage_devices health_state loc_led_state)
)
end

Expand Down Expand Up @@ -166,7 +166,16 @@ def textual_network_devices
hardware_nics_count = @record.hardware.nics.count
device = {:label => _("Network Devices"), :value => hardware_nics_count, :icon => "ff ff-network-card"}
if hardware_nics_count.positive?
device[:link] = "/physical_server/show/#{@record.id}?display=guest_devices"
device[:link] = "/physical_server/show/#{@record.id}?display=network_devices"
end
device
end

def textual_storage_devices
storage_devices_count = @record.hardware.storage_adapters.count
device = {:label => _("Storage Devices"), :value => storage_devices_count, :icon => "ff ff-network-card"}
if storage_devices_count.positive?
device[:link] = "/physical_server/show/#{@record.id}?display=storage_devices"
end
device
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/physical_server/show.html.haml
@@ -1,5 +1,5 @@
#main_div
- if %w(guest_devices physical_servers).include?(@display)
- if %w(network_devices physical_servers storage_devices).include?(@display)
= render :partial => "layouts/gtl", :locals => {:action_url => "show/#{@record.id}"}
- else
- case @showtype
Expand Down
13 changes: 11 additions & 2 deletions spec/controllers/physical_server_controller_spec.rb
Expand Up @@ -62,9 +62,18 @@
end
end

context "display=guest_devices" do
context "display=network_devices" do
it do
post :show, :params => {:id => @physical_server.id, :display => "guest_devices"}
post :show, :params => {:id => @physical_server.id, :display => "network_devices"}
expect(response.status).to eq 200
is_expected.to render_template(:partial => "layouts/_gtl")
expect(controller.send(:flash_errors?)).to be_falsey
end
end

context "display=storage_devices" do
it do
post :show, :params => {:id => @physical_server.id, :display => "storage_devices"}
expect(response.status).to eq 200
is_expected.to render_template(:partial => "layouts/_gtl")
expect(controller.send(:flash_errors?)).to be_falsey
Expand Down