Skip to content

Commit

Permalink
Merge pull request ManageIQ#11529 from tzumainn/cloud-volume-backup-c…
Browse files Browse the repository at this point in the history
…ontroller-and-views

add cloud volume backup controller and base views
  • Loading branch information
martinpovolny committed Oct 5, 2016
2 parents 612ad2c + c93c21a commit 93c8dc9
Show file tree
Hide file tree
Showing 19 changed files with 488 additions and 11 deletions.
80 changes: 80 additions & 0 deletions app/controllers/cloud_volume_backup_controller.rb
@@ -0,0 +1,80 @@
class CloudVolumeBackupController < ApplicationController
before_action :check_privileges
before_action :get_session_data
after_action :cleanup_action
after_action :set_session_data

def index
redirect_to :action => 'show_list'
end

# handle buttons pressed on the button bar
def button
@edit = session[:edit] # Restore @edit for adv search box
params[:page] = @current_page unless @current_page.nil? # Save current page for list refresh
return tag("CloudVolumeBackup") if params[:pressed] == 'cloud_volume_backup_tag'
if @refresh_div == "main_div" && @lastaction == "show_list"
replace_gtl_main_div
else
render_flash
end
end

def show
@display = params[:display] || "main" unless control_selected?
@showtype = @display
@lastaction = "show"

@backup = @record = identify_record(params[:id])
return if record_no_longer_exists?(@backup)

@gtl_url = "/show"
drop_breadcrumb(
{
:name => ui_lookup(:tables => 'cloud_volume_backup'),
:url => "/cloud_volume_backup/show_list?page=#{@current_page}&refresh=y"
},
true
)

case @display
when "download_pdf", "main", "summary_only"
get_tagdata(@backup)
drop_breadcrumb(
:name => _("%{name} (Summary)") % {:name => @backup.name},
:url => "/cloud_volume_backup/show/#{@backup.id}"
)
@showtype = "main"
set_summary_pdf_data if %w(download_pdf summary_only).include?(@display)
end

if params[:ppsetting] || params[:searchtag] || params[:entry] || params[:sort_choice]
replace_gtl_main_div
end
end

# Show the main Cloud Volume Backup list view
def show_list
process_show_list
end

private

def get_session_data
@title = ui_lookup(:table => 'cloud_volume_backup')
@layout = "cloud_volume_backup"
@lastaction = session[:cloud_volume_backup_lastaction]
@display = session[:cloud_volume_backup_display]
@filters = session[:cloud_volume_backup_filters]
@catinfo = session[:cloud_volume_backup_catinfo]
@showtype = session[:cloud_volume_backup_showtype]
end

def set_session_data
session[:cloud_volume_backup_lastaction] = @lastaction
session[:cloud_volume_backup_display] = @display unless @display.nil?
session[:cloud_volume_backup_filters] = @filters
session[:cloud_volume_backup_catinfo] = @catinfo
session[:cloud_volume_backup_showtype] = @showtype
end
end
9 changes: 9 additions & 0 deletions app/controllers/cloud_volume_controller.rb
Expand Up @@ -104,6 +104,15 @@ def show
)
@view, @pages = get_view(kls, :parent => @volume, :association => :cloud_volume_snapshots)
@showtype = @display
when "cloud_volume_backups"
title = ui_lookup(:tables => 'cloud_volume_backups')
kls = CloudVolumeBackup
drop_breadcrumb(
:name => _("%{name} (All %{children})") % {:name => @volume.name, :children => title},
:url => "/cloud_volume/show/#{@volume.id}?display=cloud_volume_backups"
)
@view, @pages = get_view(kls, :parent => @volume, :association => :cloud_volume_backups)
@showtype = @display
when "instances"
title = ui_lookup(:tables => "vm_cloud")
kls = ManageIQ::Providers::CloudManager::Vm
Expand Down
16 changes: 8 additions & 8 deletions app/helpers/application_helper.rb
Expand Up @@ -1011,7 +1011,7 @@ def primary_nav_class(nav_id)
test_layout = @layout
# FIXME: exception behavior to remove
test_layout = 'my_tasks' if %w(my_tasks my_ui_tasks all_tasks all_ui_tasks).include?(@layout)
test_layout = 'cloud_volume' if @layout == 'cloud_volume_snapshot'
test_layout = 'cloud_volume' if @layout == 'cloud_volume_snapshot' || @layout == 'cloud_volume_backup'
test_layout = 'cloud_object_store_container' if @layout == 'cloud_object_store_object'

Menu::Manager.item_in_section?(test_layout, nav_id) ? 'active' : nil
Expand Down Expand Up @@ -1112,7 +1112,7 @@ def pdf_page_size_style

GTL_VIEW_LAYOUTS = %w(action availability_zone host_aggregate auth_key_pair_cloud
cim_base_storage_extent ems_storage cloud_object_store_container
cloud_object_store_object cloud_tenant cloud_volume cloud_volume_snapshot
cloud_object_store_object cloud_tenant cloud_volume cloud_volume_backup cloud_volume_snapshot
configuration_job condition container_group container_route container_project
container_replicator container_image container_image_registry
container_topology container_dashboard middleware_topology persistent_volume container_build
Expand Down Expand Up @@ -1159,8 +1159,8 @@ def placeholder_if_present(password)
def render_listnav_filename
if @lastaction == "show_list" && !session[:menu_click] &&
%w(auth_key_pair_cloud availability_zone cloud_object_store_container cloud_object_store_object cloud_tenant
cloud_volume cloud_volume_snapshot container_node container_service ems_container container_group ems_cloud
ems_cluster container_route container_project container_replicator container_image container_image_registry
cloud_volume cloud_volume_backup cloud_volume_snapshot container_node container_service ems_container container_group
ems_cloud ems_cluster container_route container_project container_replicator container_image container_image_registry
container_build ems_infra flavor host miq_template offline orchestration_stack persistent_volume
ems_middleware middleware_server middleware_deployment middleware_datasource middleware_domain
middleware_server_group middleware_messaging ems_network security_group floating_ip cloud_subnet
Expand All @@ -1174,8 +1174,8 @@ def render_listnav_filename
elsif %w(offline retired templates vm vm_cloud vm_or_template).include?(@layout)
"vm"
elsif %w(action auth_key_pair_cloud availability_zone host_aggregate cim_base_storage_extent cloud_object_store_container
cloud_object_store_object cloud_tenant cloud_volume cloud_volume_snapshot condition container_group
container_route container_project container_replicator container_image container_image_registry
cloud_object_store_object cloud_tenant cloud_volume cloud_volume_backup cloud_volume_snapshot condition
container_group container_route container_project container_replicator container_image container_image_registry
container_build container_node container_service persistent_volume ems_cloud ems_container ems_cluster ems_infra
ems_middleware middleware_server middleware_deployment middleware_datasource middleware_domain
middleware_messaging middleware_server_group flavor
Expand All @@ -1190,8 +1190,8 @@ def render_listnav_filename

def show_adv_search?
show_search = %w(auth_key_pair_cloud availability_zone host_aggregate cim_base_storage_extent
cloud_object_store_container cloud_tenant cloud_volume cloud_volume_snapshot container_group
container_node container_service container_route container_project container_replicator
cloud_object_store_container cloud_tenant cloud_volume cloud_volume_backup cloud_volume_snapshot
container_group container_node container_service container_route container_project container_replicator
container_image container_image_registry persistent_volume container_build ems_middleware
middleware_server middleware_domain middleware_messaging middleware_deployment
middleware_datasource ems_cloud ems_cluster ems_container ems_infra flavor host miq_template
Expand Down
@@ -0,0 +1,17 @@
class ApplicationHelper::Toolbar::CloudVolumeBackupCenter < ApplicationHelper::Toolbar::Basic
button_group('cloud_volume_backup_policy', [
select(
:cloud_volume_backup_policy_choice,
'fa fa-shield fa-lg',
t = N_('Policy'),
t,
:items => [
button(
:cloud_volume_backup_tag,
'pficon pficon-edit fa-lg',
N_('Edit tags for this Cloud Volume Backup'),
N_('Edit Tags')),
]
),
])
end
@@ -0,0 +1,22 @@
class ApplicationHelper::Toolbar::CloudVolumeBackupsCenter < ApplicationHelper::Toolbar::Basic
button_group('cloud_volume_backup_policy', [
select(
:cloud_volume_backup_policy_choice,
'fa fa-shield fa-lg',
t = N_('Policy'),
t,
:enabled => false,
:onwhen => "1+",
:items => [
button(
:cloud_volume_backup_tag,
'pficon pficon-edit fa-lg',
N_('Edit tags for the selected items'),
N_('Edit Tags'),
:url_parms => "main_div",
:enabled => false,
:onwhen => "1+"),
]
),
])
end
4 changes: 2 additions & 2 deletions app/helpers/application_helper/toolbar_chooser.rb
Expand Up @@ -472,8 +472,8 @@ def center_toolbar_filename_classic
# show_list and show screens
unless @in_a_form
if %w(auth_key_pair_cloud availability_zone host_aggregate cloud_object_store_object cloud_object_store_container cloud_tenant
cloud_volume cloud_volume_snapshot configuration_job container_group container_node container_service ems_cloud ems_cluster
ems_container ems_middleware container_project container_route container_replicator container_image
cloud_volume cloud_volume_backup cloud_volume_snapshot configuration_job container_group container_node container_service
ems_cloud ems_cluster ems_container ems_middleware container_project container_route container_replicator container_image
ems_network security_group floating_ip cloud_subnet network_router network_topology network_port cloud_network load_balancer
container_image_registry ems_infra flavor host container_build infra_networking ems_storage
ontap_file_share ontap_logical_disk container_topology middleware_topology middleware_server
Expand Down
3 changes: 3 additions & 0 deletions app/helpers/cloud_volume_backup_helper.rb
@@ -0,0 +1,3 @@
module CloudVolumeBackupHelper
include_concern 'TextualSummary'
end
44 changes: 44 additions & 0 deletions app/helpers/cloud_volume_backup_helper/textual_summary.rb
@@ -0,0 +1,44 @@
module CloudVolumeBackupHelper::TextualSummary
include TextualMixins::TextualDescription
include TextualMixins::TextualGroupTags
include TextualMixins::TextualName

def textual_group_properties
%i(name status size)
end

def textual_group_relationships
%i(parent_ems_cloud ems_storage cloud_volume cloud_tenant)
end

def textual_status
{:label => _("Status"), :value => @record.status}
end

def textual_size
{:label => _("Size"), :value => number_to_human_size(@record.size, :precision => 2)}
end

def textual_cloud_volume
textual_link(@record.cloud_volume)
end

def textual_parent_ems_cloud
@record.ext_management_system.try(:parent_manager)
end

def textual_ems_storage
textual_link(@record.ext_management_system)
end

def textual_cloud_tenant
cloud_tenant = @record.try(:cloud_tenant)
label = ui_lookup(:table => "cloud_tenants")
h = {:label => label, :image => "cloud_tenant", :value => (cloud_tenant.try(:name) || _("None"))}
if cloud_tenant && role_allows?(:feature => "cloud_tenant_show")
h[:title] = _("Show this Backup's %{parent}") % {:parent => label}
h[:link] = url_for(:controller => 'cloud_tenant', :action => 'show', :id => cloud_tenant)
end
h
end
end
1 change: 1 addition & 0 deletions app/helpers/ui_constants.rb
Expand Up @@ -193,6 +193,7 @@ module UiConstants
:cloudobjectstoreobject => "list",
:cloudtenant => "list",
:cloudvolume => "list",
:cloudvolumebackup => "list",
:cloudvolumesnapshot => "list",
:drift => "expanded",
:drift_mode => "details",
Expand Down
2 changes: 1 addition & 1 deletion app/views/cloud_volume/show.html.haml
@@ -1,4 +1,4 @@
- if %w(cloud_volume_snapshots instances).include?(@display)
- if %w(cloud_volume_backups cloud_volume_snapshots instances).include?(@display)
= render :partial => "layouts/gtl", :locals => {:action_url => "show/#{@volume.id}"}
- else
- if @showtype == "item"
Expand Down
7 changes: 7 additions & 0 deletions app/views/cloud_volume_backup/_main.html.haml
@@ -0,0 +1,7 @@
= render :partial => "layouts/flash_msg"
.row
.col-md-12.col-lg-6
= render :partial => "shared/summary/textual", :locals => {:title => _("Properties"), :items => textual_group_properties}
= render :partial => "shared/summary/textual", :locals => {:title => _("Relationships"), :items => textual_group_relationships}
.col-md-12.col-lg-6
= render :partial => "shared/summary/textual_tags", :locals => {:title => _("Smart Management"), :items => textual_group_tags}
1 change: 1 addition & 0 deletions app/views/cloud_volume_backup/show.html.haml
@@ -0,0 +1 @@
= render :partial => @showtype
2 changes: 2 additions & 0 deletions app/views/cloud_volume_backup/show_list.html.haml
@@ -0,0 +1,2 @@
#main_div
= render :partial => 'layouts/gtl'
22 changes: 22 additions & 0 deletions app/views/layouts/listnav/_cloud_volume_backup.html.haml
@@ -0,0 +1,22 @@
- if @record.try(:name)
#accordion.panel-group
= miq_accordion_panel(truncate(@record.name, :length => truncate_length), true, "icon") do
= render_quadicon(@record, :mode => :icon, :size => 72, :typ => :listnav)

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

= miq_accordion_panel(_("Relationships"), false, "cloud_volume_rel") do
%ul.nav.nav-pills.nav-stacked
- if role_allows?(:feature => "ems_cloud_show") && @record.ext_management_system
%li
= link_to(_("%{model}: %{name}") % {:model => ui_lookup(:table => "ext_management_system"), :name => @record.ext_management_system.name},
ems_cloud_path(@record.ext_management_system.id),
:title => _("Show this Backup's parent %{parent}") % {:parent => ui_lookup(:table => "ems_cloud")})
- if role_allows?(:feature => "cloud_volume_show") && @record.cloud_volume
%li
= link_to(_("%{model}: %{name}") % {:model => ui_lookup(:table => "cloud_volume"), :name => @record.cloud_volume.name},
{:action => 'show', :id => @record.cloud_volume.id, :controller => 'cloud_volume'},
:title => _("Show this Backup's parent %{parent}") % {:parent => ui_lookup(:table => "cloud_volume")})
22 changes: 22 additions & 0 deletions config/routes.rb
Expand Up @@ -440,6 +440,28 @@
},

:cloud_volume_snapshot => {
:get => %w(
download_data
index
show
show_list
tagging_edit
tag_edit_form_field_changed
) + compare_get,
:post => %w(
button
dynamic_checkbox_refresh
form_field_changed
listnav_search_selected
quick_search
show
show_list
tagging_edit
tag_edit_form_field_changed
) + compare_post + adv_search_post + exp_post + save_post
},

:cloud_volume_backup => {
:get => %w(
download_data
edit
Expand Down
29 changes: 29 additions & 0 deletions db/fixtures/miq_product_features.yml
Expand Up @@ -754,6 +754,35 @@
:feature_type: control
:identifier: cloud_volume_snapshot_tag

# CloudVolumeBackup
- :name: Cloud Volume Backups
:description: Everything under Cloud Volume Backups
:feature_type: node
:identifier: cloud_volume_backup
:children:
- :name: View
:description: View Backups
:feature_type: view
:identifier: cloud_volume_backup_view
:children:
- :name: List
:description: Display Lists of Backups
:feature_type: view
:identifier: cloud_volume_backup_show_list
- :name: Show
:description: Display Individual Backups
:feature_type: view
:identifier: cloud_volume_backup_show
- :name: Operate
:description: Perform Operations on Backups
:feature_type: control
:identifier: cloud_volume_backup_control
:children:
- :name: Edit Tags
:description: Edit Tags of Backups
:feature_type: control
:identifier: cloud_volume_backup_tag

# Flavor
- :name: Flavors
:description: Everything under Flavors
Expand Down

0 comments on commit 93c8dc9

Please sign in to comment.