Skip to content

Commit

Permalink
Read-only pages for browsing firmware repository
Browse files Browse the repository at this point in the history
With this commit we add following pages to support
firmware repository browsing:

```
- firmware registry list
- firmware registry details
   + display firmware_binaries
- firmware binary details
   + display firmware constraints
- firmware contstraint details
   + display firmware binaries
```

Signed-off-by: Miha Pleško <[email protected]>
  • Loading branch information
miha-plesko committed May 23, 2019
1 parent eacc599 commit 6d6bacf
Show file tree
Hide file tree
Showing 22 changed files with 590 additions and 9 deletions.
51 changes: 51 additions & 0 deletions app/controllers/firmware_binary_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
class FirmwareBinaryController < ApplicationController
before_action :check_privileges
before_action :get_session_data

after_action :cleanup_action
after_action :set_session_data

include Mixins::GenericListMixin
include Mixins::GenericSessionMixin
include Mixins::GenericShowMixin
include Mixins::ListnavMixin
include Mixins::BreadcrumbsMixin

def self.display_methods
%w[firmware_constraints]
end

def self.model
FirmwareBinary
end

def display_firmware_constraints
nested_list(FirmwareConstraint, :breadcrumb_title => _('Firmware Constraints'))
end

private

def textual_group_list
[%i[properties relationships]]
end
helper_method :textual_group_list

def breadcrumbs_options
{
:breadcrumbs => [
{:title => _('Cloud')},
{:title => _('Infrastructure')},
{:title => _('Firmware Registries')},
{
:title => @record.firmware_registry.name,
:url => url_for(:controller => :firmware_registry, :id => @record.firmware_registry.id, :action => :show)
},
{
:title => _('Firmware Binaries'),
:url => url_for(:controller => :firmware_registry, :id => @record.firmware_registry.id, :action => :show,
:display => :firmware_binaries)
},
],
}
end
end
46 changes: 46 additions & 0 deletions app/controllers/firmware_constraint_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
class FirmwareConstraintController < ApplicationController
before_action :check_privileges
before_action :get_session_data

after_action :cleanup_action
after_action :set_session_data

include Mixins::GenericListMixin
include Mixins::GenericSessionMixin
include Mixins::GenericShowMixin
include Mixins::ListnavMixin
include Mixins::BreadcrumbsMixin

def self.display_methods
%w[firmware_binaries]
end

def self.model
FirmwareConstraint
end

def display_firmware_binaries
nested_list(FirmwareBinary, :breadcrumb_title => _('Firmware Binaries'))
end

private

def textual_group_list
[%i[properties relationships]]
end
helper_method :textual_group_list

def breadcrumbs_options
{
:breadcrumbs => [
{:title => _('Cloud')},
{:title => _('Infrastructure')},
{
:title => _('Firmware Registries'),
:url => url_for(:controller => :firmware_registry, :action => :show_list)
},
{:title => _('Firmware Constraints'), :url => controller_url},
],
}
end
end
48 changes: 48 additions & 0 deletions app/controllers/firmware_registry_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
class FirmwareRegistryController < ApplicationController
before_action :check_privileges
before_action :get_session_data

after_action :cleanup_action
after_action :set_session_data

include Mixins::GenericListMixin
include Mixins::GenericSessionMixin
include Mixins::GenericShowMixin
include Mixins::ListnavMixin
include Mixins::BreadcrumbsMixin

menu_section :firmware_registry

def self.display_methods
%w[firmware_binaries]
end

def self.model
FirmwareRegistry
end

def title
_('Firmware Registry')
end

def display_firmware_binaries
nested_list(FirmwareBinary, :breadcrumb_title => _('Firmware Binaries'))
end

private

def textual_group_list
[%i[properties relationships]]
end
helper_method :textual_group_list

def breadcrumbs_options
{
:breadcrumbs => [
{:title => _('Compute')},
{:title => _('Infrastructure')},
{:title => _('Firmware Registries'), :url => controller_url},
],
}
end
end
16 changes: 16 additions & 0 deletions app/helpers/application_helper/toolbar/firmware_registry_center.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class ApplicationHelper::Toolbar::FirmwareRegistryCenter < ApplicationHelper::Toolbar::Basic
button_group(
'firmware_registry_reload',
[
button(
:firmware_registry_reload,
'fa fa-refresh fa-lg',
N_('Refresh this page'),
N_('Refresh'),
:url_parms => "main_div",
:send_checked => true,
:klass => ApplicationHelper::Button::ButtonWithoutRbacCheck
)
]
)
end
3 changes: 3 additions & 0 deletions app/helpers/firmware_binary_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module FirmwareBinaryHelper
include_concern 'TextualSummary'
end
35 changes: 35 additions & 0 deletions app/helpers/firmware_binary_helper/textual_summary.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module FirmwareBinaryHelper::TextualSummary
include TextualMixins::TextualName
include TextualMixins::TextualDescription

def textual_group_properties
TextualGroup.new(
_("Properties"),
%i[name description version created updated]
)
end

def textual_group_relationships
TextualGroup.new(_("Relationships"), %i[firmware_registry firmware_constraints])
end

def textual_created
{:label => _("Created On"), :value => format_timezone(@record.created_at)}
end

def textual_updated
{:label => _("Updated On"), :value => format_timezone(@record.updated_at)}
end

def textual_version
@record.version
end

def textual_firmware_registry
textual_link(@record.firmware_registry)
end

def textual_firmware_constraints
textual_link(@record.firmware_constraints)
end
end
3 changes: 3 additions & 0 deletions app/helpers/firmware_constraint_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module FirmwareConstraintHelper
include_concern 'TextualSummary'
end
32 changes: 32 additions & 0 deletions app/helpers/firmware_constraint_helper/textual_summary.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module FirmwareConstraintHelper::TextualSummary
def textual_group_properties
TextualGroup.new(
_("Properties"),
%i[manufacturer model created updated]
)
end

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

def textual_created
{:label => _("Created On"), :value => format_timezone(@record.created_at)}
end

def textual_updated
{:label => _("Updated On"), :value => format_timezone(@record.updated_at)}
end

def textual_manufacturer
@record.manufacturer
end

def textual_model
@record.model
end

def textual_firmware_binaries
textual_link(@record.firmware_binaries)
end
end
3 changes: 3 additions & 0 deletions app/helpers/firmware_registry_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module FirmwareRegistryHelper
include_concern 'TextualSummary'
end
31 changes: 31 additions & 0 deletions app/helpers/firmware_registry_helper/textual_summary.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module FirmwareRegistryHelper::TextualSummary
include TextualMixins::TextualName

def textual_group_properties
TextualGroup.new(_("Properties"), %i[name last_refresh_on last_refresh_error created updated])
end

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

def textual_last_refresh_on
{:label => _("Last Refresh"), :value => format_timezone(@record.last_refresh_on)}
end

def textual_last_refresh_error
@record.last_refresh_error
end

def textual_created
{:label => _("Created On"), :value => format_timezone(@record.created_at)}
end

def textual_updated
{:label => _("Updated On"), :value => format_timezone(@record.updated_at)}
end

def textual_firmware_binaries
textual_link(@record.firmware_binaries)
end
end
19 changes: 10 additions & 9 deletions app/presenters/menu/default_menu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,16 @@ def infrastructure_menu_section
clusters_name = hybrid_name(EmsCluster, N_("Clusters"), N_("Deployment Roles"), N_("Clusters / Deployment Roles"))

Menu::Section.new(:inf, N_("Infrastructure"), 'fa fa-plus', [
Menu::Item.new('ems_infra', N_('Providers'), 'ems_infra', {:feature => 'ems_infra_show_list'}, '/ems_infra/show_list'),
Menu::Item.new('ems_cluster', clusters_name, 'ems_cluster', {:feature => 'ems_cluster_show_list'}, '/ems_cluster/show_list'),
Menu::Item.new('host', hosts_name, 'host', {:feature => 'host_show_list'}, '/host/show_list'),
Menu::Item.new('vm_infra', N_('Virtual Machines'), 'vm_infra_explorer', {:feature => 'vm_infra_explorer', :any => true}, '/vm_infra/explorer'),
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('infra_topology', N_('Topology'), 'infra_topology', {:feature => 'infra_topology', :any => true}, '/infra_topology/show')
Menu::Item.new('ems_infra', N_('Providers'), 'ems_infra', {:feature => 'ems_infra_show_list'}, '/ems_infra/show_list'),
Menu::Item.new('ems_cluster', clusters_name, 'ems_cluster', {:feature => 'ems_cluster_show_list'}, '/ems_cluster/show_list'),
Menu::Item.new('host', hosts_name, 'host', {:feature => 'host_show_list'}, '/host/show_list'),
Menu::Item.new('vm_infra', N_('Virtual Machines'), 'vm_infra_explorer', {:feature => 'vm_infra_explorer', :any => true}, '/vm_infra/explorer'),
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('firmware_registry', N_('Firmware Registry'), 'firmware_registry', {:feature => 'firmware_registry', :any => true}, '/firmware_registry/show_list'),
Menu::Item.new('switch', N_('Networking'), 'infra_networking', {:feature => 'infra_networking', :any => true}, '/infra_networking/explorer'),
Menu::Item.new('infra_topology', N_('Topology'), 'infra_topology', {:feature => 'infra_topology', :any => true}, '/infra_topology/show')
])
end

Expand Down
5 changes: 5 additions & 0 deletions app/views/firmware_binary/show.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#main_div
- if %w(firmware_constraints).include?(@display)
= render :partial => "layouts/gtl", :locals => {:action_url => "show/#{@record.id}"}
- else
= render :partial => 'layouts/textual_groups_generic'
5 changes: 5 additions & 0 deletions app/views/firmware_constraint/show.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#main_div
- if %w(firmware_binaries).include?(@display)
= render :partial => "layouts/gtl", :locals => {:action_url => "show/#{@record.id}"}
- else
= render :partial => 'layouts/textual_groups_generic'
5 changes: 5 additions & 0 deletions app/views/firmware_registry/show.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#main_div
- if %w(firmware_binaries).include?(@display)
= render :partial => "layouts/gtl", :locals => {:action_url => "show/#{@record.id}"}
- else
= render :partial => 'layouts/textual_groups_generic'
2 changes: 2 additions & 0 deletions app/views/firmware_registry/show_list.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#main_div
= render :partial => 'layouts/gtl'
25 changes: 25 additions & 0 deletions app/views/layouts/listnav/_firmware_binary.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
- if @record.try(:name)
#accordion.panel-group
= miq_accordion_panel(truncate(@record.name, :length => truncate_length), true, "icon") do
= render :partial => 'shared/quadicon', :locals => {:record => @record}

= miq_accordion_panel(_("Properties"), false, "stack_prop") do
%ul.nav.nav-pills.nav-stacked
%li
= link_to_with_icon(_('Summary'), {:action => 'show', :id => @record, :display => 'main'},
:title => _("Show Summary"))

= miq_accordion_panel(_("Relationships"), false, "stack_rel") do
%ul.nav.nav-pills.nav-stacked
%li
= link_to(_('Firmware Registry'),
{:controller => "firmware_registry",
:action => 'show',
:id => @record.firmware_registry_id},
:title => _("Show Firmware Registry"))
%li
= li_link(:count => @record.firmware_constraints.size,
:text => _("Firmware Constraints"),
:display => 'firmware_constraints',
:record_id => @record.id,
:title => _("Show all Firmware Constraints"))
19 changes: 19 additions & 0 deletions app/views/layouts/listnav/_firmware_constraint.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
- if @record.try(:name)
#accordion.panel-group
= miq_accordion_panel(truncate(@record.name, :length => truncate_length), true, "icon") do
= render :partial => 'shared/quadicon', :locals => {:record => @record}

= miq_accordion_panel(_("Properties"), false, "stack_prop") do
%ul.nav.nav-pills.nav-stacked
%li
= link_to_with_icon(_('Summary'), {:action => 'show', :id => @record, :display => 'main'},
:title => _("Show Summary"))

= miq_accordion_panel(_("Relationships"), false, "stack_rel") do
%ul.nav.nav-pills.nav-stacked
%li
= li_link(:count => @record.firmware_binaries.size,
:text => _("Firmware Binaries"),
:display => 'firmware_binaries',
:record_id => @record.id,
:title => _("Show all Firmware Binaries"))
19 changes: 19 additions & 0 deletions app/views/layouts/listnav/_firmware_registry.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
- if @record.try(:name)
#accordion.panel-group
= miq_accordion_panel(truncate(@record.name, :length => truncate_length), true, "icon") do
= render :partial => 'shared/quadicon', :locals => {:record => @record}

= miq_accordion_panel(_("Properties"), false, "stack_prop") do
%ul.nav.nav-pills.nav-stacked
%li
= link_to_with_icon(_('Summary'), {:action => 'show', :id => @record, :display => 'main'},
:title => _("Show Summary"))

= miq_accordion_panel(_("Relationships"), false, "stack_rel") do
%ul.nav.nav-pills.nav-stacked
%li
= li_link(:count => @record.firmware_binaries.size,
:text => _("Firmware Binaries"),
:display => 'firmware_binaries',
:record_id => @record.id,
:title => _("Show all Firmware Binaries"))
Loading

0 comments on commit 6d6bacf

Please sign in to comment.