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

[WIP] De explorization of infra networking pages #8579

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/controllers/application_controller/tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def tagging_edit_tags_cancel
add_flash(_("Tag Edit was cancelled by the user"))
session[:tag_items] = nil # reset tag_items in session
@edit = nil # clean out the saved info
if tagging_explorer_controller?
if tagging_explorer_controller? && @lastaction != 'show_list'
@sb[:action] = nil
replace_right_cell
else
Expand All @@ -109,7 +109,7 @@ def tagging_edit_tags_save
tagging_save_tags

@edit = nil # clean out the saved info
if tagging_explorer_controller?
if tagging_explorer_controller? && @lastaction != 'show_list'
@sb[:action] = nil
replace_right_cell
else
Expand Down
89 changes: 74 additions & 15 deletions app/controllers/infra_networking_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ class InfraNetworkingController < ApplicationController
after_action :set_session_data

include Mixins::GenericSessionMixin
include Mixins::ExplorerPresenterMixin
# include Mixins::ExplorerPresenterMixin
include Mixins::FindRecord
include Mixins::CustomButtonDialogFormMixin
include Mixins::BreadcrumbsMixin

INFRA_X_BUTTON_ALLOWED_ACTIONS = {
"infra_networking_tag" => :infra_networking_tag
}.freeze

def self.model
Switch
end
Expand All @@ -20,16 +24,25 @@ def self.table_name
end

def show_list
flash_to_session
redirect_to(:action => 'explorer')
@lastaction = "showlist"
@center_toolbar = 'infra_networkings'
process_show_list(:dbname => :switch, :gtl_dbname => :switch, :named_scope => :shareable)
end

alias_method :index, :show_list
# alias_method :index, :show_list

def tagging_explorer_controller?
@explorer
end

def show_searchbar?
@record.nil?
end

def display_back_button?
false
end

def tree_select
@lastaction = "explorer"
@sb[:action] = nil
Expand Down Expand Up @@ -75,6 +88,15 @@ def load_or_clear_adv_search
end
end

def show
assert_privileges("infra_networking_view")
@center_toolbar = 'infra_networking'
@lastaction = "show"
@display = 'main'
@showtype = 'main'
@switch = @record = identify_record(params[:id], Switch)
end

def x_show
assert_privileges("infra_networking_view")
@switch = @record = identify_record(params[:id], Switch)
Expand All @@ -100,15 +122,24 @@ def show_record(_id = nil)
@center_toolbar = 'infra_networking'
end

def explorer
@explorer = true
@lastaction = "explorer"
# def explorer
# @explorer = true
# @lastaction = "explorer"

build_accordions_and_trees
@in_a_form = false
# build_accordions_and_trees
# @in_a_form = false

render :layout => "application"
end
# render :layout => "application"
# end

# def index
# @lastaction = "index"

# build_accordions_and_trees
# @in_a_form = false

# render :layout => "application"
# end

def tagging
assert_privileges("infra_networking_tag")
Expand All @@ -119,6 +150,8 @@ def tagging
def button
if params[:pressed] == "custom_button"
custom_buttons
else
tag(self.class.model)
end
end

Expand All @@ -142,6 +175,28 @@ def download_summary_pdf
super
end

def hosts
db = params[:db] || controller_name
db = 'switch' if db == 'infra_networking'
# binding.pry
return unless init_show_variables(db)

@lastaction = "hosts"
id = params[:show] || params[:x_show]
if id.present?
# binding.pry
@item = @record.hosts.find(id)
item_breadcrumbs(_("Hosts"), 'hosts')
@view = get_db_view(Host)
show_item
else
# binding.pry
drop_breadcrumb(:name => _("%{name} (Hosts)") % {:name => @record.name},
:url => "/#{controller_name}/hosts/#{@record.id}")
show_details(Host, :association => "hosts")
end
end

private

def textual_group_list
Expand Down Expand Up @@ -299,6 +354,11 @@ def replace_right_cell(options = {})
return
end

if params[:action] == 'button' && params[:pressed] == 'infra_networking_tag'
tagging
return
end

if action_type == "dialog_form_button_pressed"
presenter = set_custom_button_dialog_presenter(options)
render :json => presenter.for_render
Expand Down Expand Up @@ -440,10 +500,9 @@ def show_details(db, options = {})
:conditions => conditions,
:clickable => clickable,
:dbname => "#{@db}item") # Get the records into a view & paginator

if @explorer # In explorer?
@refresh_partial = @showtype.to_s
replace_right_cell
# binding.pry
if association == 'hosts' # In explorer?
render "hosts"
elsif request.xml_http_request?
render :update do |page|
page << javascript_prologue
Expand Down
4 changes: 4 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ def view_to_url(view, parent = nil)
association = view_to_association(view, parent)
if association.nil?
controller, action = db_to_controller(view.db)
if controller == "switch" && action == "show"
return url_for_only_path(:action => action)
end
if controller == "ems_cloud" && action == "show"
return ems_clouds_path
end
Expand Down Expand Up @@ -1110,6 +1113,7 @@ def pdf_page_size_style
security_group
services
storage
switch
templates].freeze

def render_download_view_tb?
Expand Down
7 changes: 6 additions & 1 deletion app/helpers/infra_networking_helper/textual_summary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def textual_group_properties
end

def textual_group_relationships
TextualGroup.new(_("Relationships"), %i[hosts custom_button_events])
TextualGroup.new(_("Relationships"), %i[hosts custom_button_events lans])
end

def textual_group_smart_management
Expand All @@ -28,6 +28,11 @@ def textual_hosts
h
end

def textual_lans
portgroups = @record.lans.map(&:name)
{:label => _("Portgroup"), :icon => "pficon pficon-network", :value => portgroups.join(', ')}
end

def textual_custom_button_events
return nil unless User.current_user.super_admin_user? || User.current_user.admin?

Expand Down
2 changes: 1 addition & 1 deletion app/presenters/menu/default_menu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def infrastructure_menu_section
Menu::Item.new('resource_pool', N_('Resource Pools'), 'resource_pool', {:feature => 'resource_pool_show_list'}, '/resource_pool/show_list'),
Menu::Item.new('storage', N_('Datastores'), 'storage', {:feature => 'storage_show_list'}, '/storage/explorer'),
Menu::Item.new('pxe', N_('PXE'), 'pxe', {:feature => 'pxe', :any => true}, '/pxe/explorer'),
Menu::Item.new('switch', N_('Networking'), 'infra_networking', {:feature => 'infra_networking', :any => true}, '/infra_networking/explorer'),
Menu::Item.new('switch', N_('Networking'), 'infra_networking', {:feature => 'infra_networking', :any => true}, '/infra_networking/show_list'),
])
end

Expand Down
10 changes: 10 additions & 0 deletions app/views/infra_networking/hosts.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- content_for :search do
= render(:partial => "layouts/x_adv_searchbox")
= render(:partial => 'layouts/quick_search')

-# Showing a list of hosts
#main_div
= render(:partial => 'layouts/gtl')
-# Show Search box
:javascript
#{javascript_show_if_exists("adv_searchbox_div")}
2 changes: 2 additions & 0 deletions app/views/infra_networking/show.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#main_div
= render :partial => "layouts/textual_groups_generic"
10 changes: 10 additions & 0 deletions app/views/infra_networking/show_list.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- content_for :search do
= render(:partial => "layouts/x_adv_searchbox")
= render(:partial => 'layouts/quick_search')

-# Showing a list of switches
#main_div
= render(:partial => 'layouts/gtl')
-# Show Search box
:javascript
#{javascript_show_if_exists("adv_searchbox_div")}
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1779,6 +1779,7 @@
tagging
tagging_edit
x_show
show
),
:post => %w(
button
Expand Down