forked from ManageIQ/manageiq
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ManageIQ#11529 from tzumainn/cloud-volume-backup-c…
…ontroller-and-views add cloud volume backup controller and base views
- Loading branch information
Showing
19 changed files
with
488 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
app/helpers/application_helper/toolbar/cloud_volume_backup_center.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
22 changes: 22 additions & 0 deletions
22
app/helpers/application_helper/toolbar/cloud_volume_backups_center.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module CloudVolumeBackupHelper | ||
include_concern 'TextualSummary' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
= render :partial => @showtype |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#main_div | ||
= render :partial => 'layouts/gtl' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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")}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.