Skip to content

Commit

Permalink
Merge pull request #3398 from skovic/network-device-ui-redesign
Browse files Browse the repository at this point in the history
Change the way that network device details are displayed
  • Loading branch information
Dan Clarizio committed Mar 2, 2018
2 parents 4e2c43b + f6043e3 commit 85ef2d8
Show file tree
Hide file tree
Showing 18 changed files with 271 additions and 37 deletions.
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def pp_choices
:emscluster => "grid",
:emscontainer => "grid",
:filesystem => "list",
:guestdevice => "list",
:flavor => "list",
:host => "grid",
:job => "list",
Expand Down
45 changes: 45 additions & 0 deletions app/controllers/guest_device_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
class GuestDeviceController < ApplicationController
include Mixins::GenericListMixin
include Mixins::GenericShowMixin
include Mixins::GenericSessionMixin
include Mixins::MoreShowActions

before_action :check_privileges
before_action :session_data
after_action :cleanup_action
after_action :set_session_data

def self.model
@model ||= "GuestDevice".safe_constantize
end

def title
_('Guest Devices')
end

def model
self.class.model
end

def self.table_name
@table_name ||= "guest_devices"
end

def session_data
@title = _("Guest Devices")
@layout = "guest_device"
@lastaction = session[:guest_device_lastaction]
end

def set_session_data
session[:layout] = @layout
session[:guest_device_lastaction] = @lastaction
end

def textual_group_list
[
%i(properties ports firmware),
]
end
helper_method(:textual_group_list)
end
10 changes: 9 additions & 1 deletion app/controllers/physical_server_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ class PhysicalServerController < ApplicationController
after_action :cleanup_action
after_action :set_session_data

def self.display_methods
%w(guest_devices)
end

def display_guest_devices
nested_list(GuestDevice, :named_scope => :with_ethernet_type)
end

def self.table_name
@table_name ||= "physical_servers"
end
Expand Down Expand Up @@ -36,7 +44,7 @@ def show_list

def textual_group_list
[
%i(properties networks relationships power_management assets firmware_details network_adapters smart_management),
%i(properties networks relationships power_management assets firmware_details smart_management),
]
end
helper_method(:textual_group_list)
Expand Down
3 changes: 3 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,7 @@ def pdf_page_size_style
floating_ip
generic_object
generic_object_definition
guest_device
host
host_aggregate
load_balancer
Expand Down Expand Up @@ -1441,6 +1442,7 @@ def render_listnav_filename
flavor
floating_ip
generic_object_definition
guest_device
host
load_balancer
middleware_deployment
Expand Down Expand Up @@ -1509,6 +1511,7 @@ def render_listnav_filename
flavor
floating_ip
generic_object_definition
guest_device
host
host_aggregate
load_balancer
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/application_helper/toolbar/guest_device_center.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class ApplicationHelper::Toolbar::GuestDeviceCenter < ApplicationHelper::Toolbar::Basic
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class ApplicationHelper::Toolbar::GuestDevicesCenter < ApplicationHelper::Toolbar::Basic
end
3 changes: 2 additions & 1 deletion app/helpers/application_helper/toolbar_chooser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def center_toolbar_filename_classic
load_balancers network_ports network_routers orchestration_stacks resource_pools
security_groups storages middleware_deployments
middleware_servers)
to_display_center = %w(stack_orchestration_template topology cloud_object_store_objects generic_objects physical_servers)
to_display_center = %w(stack_orchestration_template topology cloud_object_store_objects generic_objects physical_servers guest_devices)
performance_layouts = %w(vm host ems_container)
if @lastaction == 'show' && (@view || @display != 'main') && !@layout.starts_with?("miq_request")
if @display == "vms" || @display == "all_vms"
Expand Down Expand Up @@ -530,6 +530,7 @@ def center_toolbar_filename_classic
ems_object_storage
timeline
usage
guest_device
generic_object_definition).include?(@layout)
if ["show_list"].include?(@lastaction)
return "#{@layout.pluralize}_center_tb"
Expand Down
3 changes: 3 additions & 0 deletions app/helpers/guest_device_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module GuestDeviceHelper
include_concern 'TextualSummary'
end
54 changes: 54 additions & 0 deletions app/helpers/guest_device_helper/textual_summary.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
module GuestDeviceHelper::TextualSummary
def textual_group_properties
TextualGroup.new(
_("Properties"),
%i(device_name location manufacturer field_replaceable_unit)
)
end

def textual_group_ports
ports = {:labels => [_("Name"), _("MAC Address")]}
ports[:values] = @record.child_devices.collect do |port|
[
port.name,
port.address
]
end

TextualMultilabel.new(
_("Ports"),
ports
)
end

def textual_group_firmware
firmware = {:labels => [_("Name"), _("Version")]}
firmware[:values] = @record.firmwares.collect do |fw|
[
fw.name,
fw.version
]
end

TextualMultilabel.new(
_("Firmware"),
firmware
)
end

def textual_device_name
{:label => _("Name"), :value => @record.device_name}
end

def textual_manufacturer
{:label => _("Manufacturer"), :value => @record.manufacturer}
end

def textual_location
{:label => _("Location"), :value => @record.location}
end

def textual_field_replaceable_unit
{:label => _("FRU"), :value => @record.field_replaceable_unit}
end
end
44 changes: 10 additions & 34 deletions app/helpers/physical_server_helper/textual_summary.rb
Original file line number Diff line number Diff line change
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 health_state loc_led_state)
%i(name model product_name manufacturer machine_type serial_number ems_ref capacity memory cores network_devices health_state loc_led_state)
)
end

Expand Down Expand Up @@ -42,14 +42,6 @@ def textual_group_firmware_details
)
end

def textual_group_network_adapters
TextualCustom.new(
_("Network Devices"),
"textual_network_adapter_table",
%i(network_adapter)
)
end

def textual_group_smart_management
TextualTags.new(_("Smart Management"), %i(tags))
end
Expand Down Expand Up @@ -163,6 +155,15 @@ def textual_health_state
{:label => _("Health State"), :value => @record.health_state}
end

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"
end
device
end

def textual_fw_details
fw_details = []
@record.hardware.firmwares.each do |fw|
Expand All @@ -171,29 +172,4 @@ def textual_fw_details

{:value => fw_details}
end

def textual_network_adapter
network_adapters = []

@record.hardware.nics.each do |nic|
port_names = []
mac_addresses = []

child_devices = nic.child_devices.sort_by(&:device_name)

child_devices.each do |child_device|
port_names.push(child_device.device_name)
mac_addresses.push(child_device.address)
end

network_adapters.push(:location => nic.location,
:adapter_name => nic.device_name,
:manufacturer => nic.manufacturer,
:fru => nic.field_replaceable_unit,
:port_names => port_names,
:mac_addresses => mac_addresses)
end

{:value => network_adapters}
end
end
7 changes: 7 additions & 0 deletions app/views/guest_device/show.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#main_div
- if %w(guest_devices).include?(@display)
= render :partial => "layouts/gtl", :locals => {:action_url => "show/#{@record.id}"}
- else
- case @showtype
- when "main"
= render :partial => 'layouts/textual_groups_generic'
2 changes: 2 additions & 0 deletions app/views/guest_device/show_list.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#main_div
= render :partial => 'layouts/gtl'
Empty file.
2 changes: 1 addition & 1 deletion app/views/physical_server/show.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#main_div
- if %w(physical_servers).include?(@display)
- if %w(guest_devices physical_servers).include?(@display)
= render :partial => "layouts/gtl", :locals => {:action_url => "show/#{@record.id}"}
- else
- case @showtype
Expand Down
16 changes: 16 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,22 @@
save_post
},

:guest_device => {
:get => %w(
show_list
show
quick_search
) + compare_get,

:post => %w(
button
show_list
) +
adv_search_post +
exp_post +
save_post
},

:ems_physical_infra_dashboard => {
:get => %w(
show
Expand Down
56 changes: 56 additions & 0 deletions product/views/GuestDevice.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#Report title
title: Guest Devices

#Menu name
name: Guest Device


db: GuestDevice


# Columns to fetch from main table
cols:
- device_name
- location
- manufacturer
- field_replaceable_unit


include:


include_for_find:
:ext_management_system: {}


col_order:
- device_name
- location
- manufacturer
- field_replaceable_unit

col_formats:

headers:
- Device Name
- Location
- Manufacturer
- Field Replaceable Unit


conditions:


order: Ascending


sortby:
- device_name

group: n


graph:


dims:

0 comments on commit 85ef2d8

Please sign in to comment.