Skip to content

Commit

Permalink
Merge pull request #2234 from Ladas/displaying_amazon_network_routers
Browse files Browse the repository at this point in the history
  • Loading branch information
martinpovolny authored and simaishi committed Jan 31, 2018
1 parent 6be04b4 commit 01db70a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class ApplicationHelper::Toolbar::NetworkRouterCenter < ApplicationHelper::Toolb
t,
:url_parms => 'main_div',
:send_checked => true,
:klass => ApplicationHelper::Button::GenericFeatureButtonWithDisable,
:options => {:feature => :update}
),
button(
:network_router_add_interface,
Expand Down Expand Up @@ -44,6 +46,8 @@ class ApplicationHelper::Toolbar::NetworkRouterCenter < ApplicationHelper::Toolb
:url_parms => 'main_div',
:send_checked => true,
:confirm => N_('Warning: This Router and ALL of its components will be removed!'),
:klass => ApplicationHelper::Button::GenericFeatureButtonWithDisable,
:options => {:feature => :delete}
)
]
)
Expand Down
39 changes: 0 additions & 39 deletions app/helpers/application_helper/toolbar/network_routers_center.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,6 @@ class ApplicationHelper::Toolbar::NetworkRoutersCenter < ApplicationHelper::Tool
t,
:klass => ApplicationHelper::Button::NetworkRouterNew
),
separator,
button(
:network_router_edit,
'pficon pficon-edit fa-lg',
t = N_('Edit selected Router'),
t,
:url_parms => 'main_div',
:send_checked => true,
:enabled => false,
:onwhen => '1'
),
button(
:network_router_add_interface,
'pficon pficon-edit fa-lg',
t = N_('Add Interface to selected Router'),
t,
:url_parms => "main_div",
:send_checked => true,
:enabled => false,
:onwhen => "1"),
button(
:network_router_remove_interface,
'pficon pficon-edit fa-lg',
t = N_('Remove Interface from selected Router'),
t,
:url_parms => "main_div",
:send_checked => true,
:enabled => false,
:onwhen => "1"),
button(
:network_router_delete,
'pficon pficon-delete fa-lg',
t = N_('Delete selected Routers'),
t,
:url_parms => 'main_div',
:send_checked => true,
:confirm => N_('Warning: The selected Routers and ALL of their components will be removed!'),
:enabled => false,
:onwhen => '1+'),
]
)
]
Expand Down
35 changes: 34 additions & 1 deletion app/helpers/network_router_helper/textual_summary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module NetworkRouterHelper::TextualSummary
#

def textual_group_properties
TextualGroup.new(_("Properties"), %i(name type status))
TextualGroup.new(_("Properties"), %i(name type status main_route_table route_propagation routes))
end

def textual_group_relationships
Expand All @@ -24,10 +24,43 @@ def textual_type
{:label => _('Type'), :value => ui_lookup(:model => @record.type)}
end

def textual_main_route_table
return nil if @record.main_route_table.nil?

if @record.main_route_table
message = _("(Subnets not explicitely assigned to a route table are assigned to this main route table, for this VPC)")
end

{:label => _('Main Route Table'), :value => "#{@record.main_route_table} #{message}"}
end

def textual_route_propagation
return nil if @record.propagating_vgws.nil?

{:label => _('Route Propagation'), :value => @record.propagating_vgws.to_s }
end

def textual_status
@record.status
end

def textual_routes
# TODO: Should be TextualTable if possible
# AWS compatible fields, add another format for another provider or comply with AWS format
labels = {
"destination_cidr_block" => _("Destination CIDR"),
"gateway_id" => _("Gateway ID"),
"state" => _("State")
}

return nil unless @record.routes.kind_of?(Array)
return @record.routes.to_s if !@record.routes.first || !@record.routes.first.kind_of?(Hash) || !labels.keys.all? { |x| @record.routes.first.key?(x) }

@record.routes.each_with_object([]) do |route, obj|
obj << labels.keys.map { |key| "#{labels[key]}: #{route[key]}" }.join(", ")
end.join(" | ")
end

def textual_parent_ems_cloud
textual_link(@record.ext_management_system.try(:parent_manager), :label => _('Cloud Provider'))
end
Expand Down

0 comments on commit 01db70a

Please sign in to comment.