From ee43d9e69bcc6ecc7b0b75e43af4c9780b544b18 Mon Sep 17 00:00:00 2001 From: Milan Zazrivec Date: Tue, 4 Apr 2017 18:23:35 +0200 Subject: [PATCH] UI for Embedded Ansible Provider refresh https://bugzilla.redhat.com/show_bug.cgi?id=1436982 --- app/controllers/ansible_credential_controller.rb | 6 ++++++ app/controllers/ansible_repository_controller.rb | 6 ++++++ .../mixins/embedded_ansible_refresh_mixin.rb | 15 +++++++++++++++ .../toolbar/ansible_credentials_center.rb | 11 +++++++++++ .../toolbar/ansible_repositories_center.rb | 11 +++++++++++ config/routes.rb | 2 ++ 6 files changed, 51 insertions(+) create mode 100644 app/controllers/mixins/embedded_ansible_refresh_mixin.rb diff --git a/app/controllers/ansible_credential_controller.rb b/app/controllers/ansible_credential_controller.rb index deabf766ba3..074970e6cf7 100644 --- a/app/controllers/ansible_credential_controller.rb +++ b/app/controllers/ansible_credential_controller.rb @@ -8,6 +8,7 @@ class AnsibleCredentialController < ApplicationController include Mixins::GenericListMixin include Mixins::GenericSessionMixin include Mixins::GenericShowMixin + include Mixins::EmbeddedAnsibleRefreshMixin menu_section :ansible_credentials toolbar :ansible_credential @@ -50,6 +51,11 @@ def edit @id = auth.id end + def credential_refresh + # Targeted refresh for embedded ansible hasn't been implemented yet + embedded_ansible_refresh + end + private def textual_group_list diff --git a/app/controllers/ansible_repository_controller.rb b/app/controllers/ansible_repository_controller.rb index 246c0ff3fe3..74b1a23fd0b 100644 --- a/app/controllers/ansible_repository_controller.rb +++ b/app/controllers/ansible_repository_controller.rb @@ -8,6 +8,7 @@ class AnsibleRepositoryController < ApplicationController include Mixins::GenericListMixin include Mixins::GenericSessionMixin include Mixins::GenericShowMixin + include Mixins::EmbeddedAnsibleRefreshMixin menu_section :ansible_repositories toolbar :ansible_repository @@ -75,6 +76,11 @@ def display_playbooks nested_list("ansible_playbook", ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Playbook) end + def repository_refresh + # Targeted refresh for embedded ansible hasn't been implemented yet + embedded_ansible_refresh + end + private def textual_group_list diff --git a/app/controllers/mixins/embedded_ansible_refresh_mixin.rb b/app/controllers/mixins/embedded_ansible_refresh_mixin.rb new file mode 100644 index 00000000000..8e62daf5b07 --- /dev/null +++ b/app/controllers/mixins/embedded_ansible_refresh_mixin.rb @@ -0,0 +1,15 @@ +module Mixins + module EmbeddedAnsibleRefreshMixin + def embedded_ansible_refresh + begin + embedded_ansible = ManageIQ::Providers::EmbeddedAnsible::AutomationManager.first + ManageIQ::Providers::EmbeddedAnsible::AutomationManager.refresh_ems([embedded_ansible.id]) + add_flash(_("Embedded Ansible Provider refresh has been successfully initiated")) + rescue => ex + add_flash(_("An error occurred while initiating Embedded Ansible Provider refresh: %{error}") % {:error => ex}, :error) + end + session[:flash_msgs] = @flash_array + javascript_redirect :action => 'show_list' + end + end +end diff --git a/app/helpers/application_helper/toolbar/ansible_credentials_center.rb b/app/helpers/application_helper/toolbar/ansible_credentials_center.rb index 6a079f1c799..17d9f04c4f6 100644 --- a/app/helpers/application_helper/toolbar/ansible_credentials_center.rb +++ b/app/helpers/application_helper/toolbar/ansible_credentials_center.rb @@ -6,6 +6,17 @@ class ApplicationHelper::Toolbar::AnsibleCredentialsCenter < ApplicationHelper:: t = N_('Configuration'), t, :items => [ + button( + :embedded_automation_manager_credentials_refresh, + 'fa fa-refresh fa-lg', + N_('Refresh Embedded Ansible Provider'), + N_('Refresh Embedded Ansible Provider'), + :klass => ApplicationHelper::Button::EmbeddedAnsible, + :url => "credential_refresh", + :url_parms => "main_div", + :confirm => N_("Refresh relationships for all items from Embedded Ansible Provider?"), + :enabled => true), + separator, button( :embedded_automation_manager_credentials_add, 'pficon pficon-edit fa-lg', diff --git a/app/helpers/application_helper/toolbar/ansible_repositories_center.rb b/app/helpers/application_helper/toolbar/ansible_repositories_center.rb index 6c9724c0090..e1e5599a85e 100644 --- a/app/helpers/application_helper/toolbar/ansible_repositories_center.rb +++ b/app/helpers/application_helper/toolbar/ansible_repositories_center.rb @@ -6,6 +6,17 @@ class ApplicationHelper::Toolbar::AnsibleRepositoriesCenter < ApplicationHelper: t = N_('Configuration'), t, :items => [ + button( + :embedded_configuration_script_source_refresh, + 'fa fa-refresh fa-lg', + N_('Refresh Embedded Ansible Provider'), + N_('Refresh Embedded Ansible Provider'), + :klass => ApplicationHelper::Button::EmbeddedAnsible, + :url => "repository_refresh", + :url_parms => "main_div", + :confirm => N_("Refresh relationships for all items from Embedded Ansible Provider?"), + :enabled => true), + separator, button( :embedded_configuration_script_source_add, 'pficon pficon-edit fa-lg', diff --git a/config/routes.rb b/config/routes.rb index f09a43a4d1e..193cdbd7c5e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2025,6 +2025,7 @@ ), :post => %w( button + credential_refresh show_list ) }, @@ -2053,6 +2054,7 @@ button edit new + repository_refresh show_list ) },