|
| 1 | +class ResourcePoolCloudController < ApplicationController |
| 2 | + before_action :check_privileges |
| 3 | + before_action :get_session_data |
| 4 | + after_action :cleanup_action |
| 5 | + after_action :set_session_data |
| 6 | + |
| 7 | + include Mixins::GenericButtonMixin |
| 8 | + include Mixins::GenericListMixin |
| 9 | + include Mixins::GenericSessionMixin |
| 10 | + include Mixins::GenericShowMixin |
| 11 | + include Mixins::BreadcrumbsMixin |
| 12 | + |
| 13 | + def self.display_methods |
| 14 | + %w[vms all_vms resource_pools] |
| 15 | + end |
| 16 | + |
| 17 | + # handle buttons pressed on the button bar |
| 18 | + def button |
| 19 | + @edit = session[:edit] # Restore @edit for adv search box |
| 20 | + params[:display] = @display if %w[all_vms vms resource_pools].include?(@display) # Were we displaying sub-items |
| 21 | + |
| 22 | + @refresh_div = 'main_div' unless @display # Default div for button.rjs to refresh |
| 23 | + case params[:pressed] |
| 24 | + when 'resource_pool_cloud_delete' |
| 25 | + deletecloudresourcepools |
| 26 | + if @refresh_div == 'main_div' && @lastaction == 'show_list' |
| 27 | + replace_gtl_main_div |
| 28 | + else |
| 29 | + render_flash unless performed? |
| 30 | + end |
| 31 | + when 'resource_pool_cloud_protect' |
| 32 | + assign_policies(ResourcePool) |
| 33 | + when 'resource_pool_cloud_tag' |
| 34 | + tag(self.class.model) |
| 35 | + else |
| 36 | + super |
| 37 | + end |
| 38 | + end |
| 39 | + |
| 40 | + def self.model |
| 41 | + ManageIQ::Providers::CloudManager::ResourcePool |
| 42 | + end |
| 43 | + |
| 44 | + def download_data |
| 45 | + assert_privileges('resource_pool_cloud_view') |
| 46 | + super |
| 47 | + end |
| 48 | + |
| 49 | + def download_summary_pdf |
| 50 | + assert_privileges('resource_pool_cloud_view') |
| 51 | + super |
| 52 | + end |
| 53 | + |
| 54 | + def breadcrumb_name(_model) |
| 55 | + _("Cloud Resource Pools") |
| 56 | + end |
| 57 | + |
| 58 | + def self.table_name |
| 59 | + @table_name ||= "resource_pool" |
| 60 | + end |
| 61 | + |
| 62 | + def index |
| 63 | + redirect_to(:action => 'show_list') |
| 64 | + end |
| 65 | + |
| 66 | + def show_list |
| 67 | + assert_privileges('resource_pool_cloud_show_list') |
| 68 | + @center_toolbar = "resource_pool_clouds" |
| 69 | + super |
| 70 | + end |
| 71 | + |
| 72 | + def show |
| 73 | + assert_privileges('resource_pool_cloud_show') |
| 74 | + @center_toolbar = "resource_pool_cloud" |
| 75 | + super |
| 76 | + end |
| 77 | + |
| 78 | + private |
| 79 | + |
| 80 | + def record_class |
| 81 | + %w[all_vms vms].include?(params[:display]) ? VmOrTemplate : ResourcePool |
| 82 | + end |
| 83 | + |
| 84 | + def textual_group_list |
| 85 | + [%i[properties relationships], %i[configuration smart_management]] |
| 86 | + end |
| 87 | + |
| 88 | + helper_method :textual_group_list |
| 89 | + |
| 90 | + def breadcrumbs_options |
| 91 | + { |
| 92 | + :breadcrumbs => [ |
| 93 | + {:title => _("Compute")}, |
| 94 | + {:title => _("Clouds")}, |
| 95 | + {:title => _("Resource Pools"), :url => controller_url}, |
| 96 | + ], |
| 97 | + } |
| 98 | + end |
| 99 | + |
| 100 | + menu_section :resource_pool_cloud |
| 101 | + feature_for_actions "#{controller_name}_show_list", *ADV_SEARCH_ACTIONS |
| 102 | +end |
0 commit comments