From 48ca4ef72ffb7a1ed84350c4af810d9e25cc2596 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Hern=C3=A1ndez?= Date: Fri, 5 Jan 2018 14:43:05 -0600 Subject: [PATCH] Revert "Merge pull request #286 from Jiri-Kremser/server-group-power-ops-ui" This reverts commit e7a178a61cfb03ab13f93b3320196cf31cab2d27, reversing changes made to ce85750b53c1b133a348a4a14fbe297e1693a711. --- .../middleware_server_controller.js | 34 ++-------- .../middleware_server_controller.rb | 2 +- .../middleware_server_group_controller.rb | 31 +-------- .../mixins/middleware_operations_mixin.rb | 1 - .../toolbar/middleware_server_group_center.rb | 65 ------------------- .../_ops_params.html.haml | 2 +- app/views/middleware_server/show.html.haml | 2 +- .../middleware_server_group/show.html.haml | 1 - config/routes.rb | 1 - 9 files changed, 10 insertions(+), 129 deletions(-) rename app/views/{middleware_shared => middleware_server}/_ops_params.html.haml (97%) diff --git a/app/assets/javascripts/controllers/middleware_server/middleware_server_controller.js b/app/assets/javascripts/controllers/middleware_server/middleware_server_controller.js index fd8cd24da5a2..a720a1094a19 100644 --- a/app/assets/javascripts/controllers/middleware_server/middleware_server_controller.js +++ b/app/assets/javascripts/controllers/middleware_server/middleware_server_controller.js @@ -79,20 +79,10 @@ function MwServerController($scope, miqService, $timeout, $document) { } ManageIQ.angular.app.controller('mwServerOpsController', MwServerOpsController); -ManageIQ.angular.app.controller('mwServerGroupOpsController', MwServerGroupOpsController); MwServerOpsController.$inject = ['miqService', 'serverOpsService']; -function MwServerOpsController(miqService, serverOpsService) { - return MwServerOpsControllerFactory(miqService, serverOpsService); -} - -MwServerGroupOpsController.$inject = ['miqService', 'serverGroupOpsService']; -function MwServerGroupOpsController(miqService, serverGroupOpsService) { - return MwServerOpsControllerFactory(miqService, serverGroupOpsService); -} - -function MwServerOpsControllerFactory(miqService, serverOpsService) { +function MwServerOpsController( miqService, serverOpsService) { ManageIQ.angular.rxSubject.subscribe(function(event) { if (event.type === 'mwSeverOpsEvent') { @@ -112,22 +102,12 @@ function MwServerOpsControllerFactory(miqService, serverOpsService) { } ManageIQ.angular.app.service('serverOpsService', ServerOpsService); -ManageIQ.angular.app.service('serverGroupOpsService', ServerGroupOpsService); ServerOpsService.$inject = ['$http', '$q']; -function ServerOpsService($http, $q) { - return ServerOpsServiceFactory($http, $q, false); -} - -ServerGroupOpsService.$inject = ['$http', '$q']; -function ServerGroupOpsService($http, $q) { - return ServerOpsServiceFactory($http, $q, true); -} -function ServerOpsServiceFactory($http, $q, isGroup) { - var runOperation = function runOperation(id, operation, timeout) { - var errorMsg = isGroup ? _('Error running operation on this server.') - : _('Error running operation on this server group.'); +function ServerOpsService($http, $q) { + this.runOperation = function runOperation(id, operation, timeout) { + var errorMsg = _('Error running operation on this server.'); var deferred = $q.defer(); var payload = { 'id': id, @@ -135,8 +115,7 @@ function ServerOpsServiceFactory($http, $q, isGroup) { 'timeout': timeout, }; - var url = '/middleware_server' + (isGroup ? '_group' : '') + '/run_operation'; - $http.post(url, angular.toJson(payload)) + $http.post('/middleware_server/run_operation', angular.toJson(payload)) .then( function(response) { // success var data = response.data; @@ -157,7 +136,4 @@ function ServerOpsServiceFactory($http, $q, isGroup) { }); return deferred.promise; }; - return { - runOperation: runOperation, - }; } diff --git a/app/controllers/middleware_server_controller.rb b/app/controllers/middleware_server_controller.rb index 1b344e82b86a..2b6261a7763d 100644 --- a/app/controllers/middleware_server_controller.rb +++ b/app/controllers/middleware_server_controller.rb @@ -193,7 +193,7 @@ def run_operation operation_info = ALL_OPERATIONS.fetch(operation) run_server_param_operation(operation_info, selected_servers) else - msg = _("Unknown server operation: %{operation}") % {:operation => operation.to_s} + msg = _("Unknown server operation: ") + operation render :json => {:status => :error, :msg => msg} end end diff --git a/app/controllers/middleware_server_group_controller.rb b/app/controllers/middleware_server_group_controller.rb index 6508a2a6cf4f..5d014b93e384 100644 --- a/app/controllers/middleware_server_group_controller.rb +++ b/app/controllers/middleware_server_group_controller.rb @@ -17,37 +17,10 @@ def self.default_show_template "#{model.name.underscore}/show" end + private + def textual_group_list [%i(properties), %i(relationships smart_management)] end helper_method :textual_group_list - - def run_operation - selected_server_groups = identify_selected_entities - if selected_server_groups.nil? - render :json => {:status => :error, :msg => _('No Server Groups selected')} - return - end - operation = ('middleware_server_group_' + params['operation']).to_sym - if OPERATIONS.key?(operation) - do_run_operation(operation, selected_server_groups) - else - msg = _('Unknown server group operation: ') + operation.to_s - render :json => {:status => :error, :msg => msg} - end - end - - private - - def do_run_operation(operation, selected_server_groups) - operation_info = OPERATIONS.fetch(operation) - triggered = run_specific_operation(operation_info, selected_server_groups) - if triggered - initiated_msg = _('%{operation} initiated for given server group.') % {:operation => operation_info.fetch(:msg)} - render :json => {:status => :ok, :msg => initiated_msg} - else - fail_msg = _('%{operation} was not initiated for given group.') % {:operation => operation_info.fetch(:msg)} - render :json => {:status => :error, :msg => fail_msg} - end - end end diff --git a/app/controllers/mixins/middleware_operations_mixin.rb b/app/controllers/mixins/middleware_operations_mixin.rb index 0dc98e444f0b..dab94c045504 100644 --- a/app/controllers/mixins/middleware_operations_mixin.rb +++ b/app/controllers/mixins/middleware_operations_mixin.rb @@ -55,7 +55,6 @@ def run_specific_operation(operation_info, items, success_msg = "%{msg}", klass end operation_triggered = run_operation_batch(operation_info, items, klass) add_flash(_(success_msg) % {:msg => operation_info.fetch(:msg)}) if operation_triggered - operation_triggered end def run_operation_on_record(operation_info, item_record) diff --git a/app/helpers/application_helper/toolbar/middleware_server_group_center.rb b/app/helpers/application_helper/toolbar/middleware_server_group_center.rb index f39b97935bd2..c732122c24c6 100644 --- a/app/helpers/application_helper/toolbar/middleware_server_group_center.rb +++ b/app/helpers/application_helper/toolbar/middleware_server_group_center.rb @@ -16,69 +16,4 @@ class ApplicationHelper::Toolbar::MiddlewareServerGroupCenter < ApplicationHelpe ] ), ]) - button_group('middleware_server_operations', [ - select( - :middleware_server_power_choice, - 'fa fa-power-off fa-lg', - t = N_('Power'), - t, - :items => [ - button( - :middleware_server_group_restart, - nil, - N_('Restart Servers in this Server Group'), - N_('Restart Server Group'), - :image => 'restart', - :confirm => N_('Do you want to restart this server group?'), - ), - separator, - button( - :middleware_server_group_stop, - nil, - N_('Stop Servers in this Server Group'), - N_('Stop Server Group'), - :image => 'power_off', - :data => {'toggle' => 'modal', - 'target' => '#modal_param_div', - 'function' => 'sendDataWithRx', - 'function-data' => '{"type": "mwServerOps", "operation": "stop", "timeout": 10}'}, - ), - button( - :middleware_server_group_suspend, - nil, - N_('Suspend Server in this Server Group'), - N_('Suspend Server Group'), - :image => 'suspend', - :data => {'toggle' => 'modal', - 'target' => '#modal_param_div', - 'function' => 'sendDataWithRx', - 'function-data' => '{"type": "mwServerOps", "operation": "suspend", "timeout": 10}'}, - ), - button( - :middleware_server_group_resume, - nil, - N_('Resume Servers in this Server Group'), - N_('Resume Server Group'), - :image => 'resume', - :confirm => N_('Do you want to resume this server group?'), - ), - button( - :middleware_server_group_reload, - nil, - N_('Reload Servers in this Server Group'), - N_('Reload Server Group'), - :confirm => N_('Do you want to trigger a reload of this server group?'), - :image => 'guest_restart', - ), - button( - :middleware_server_group_start, - nil, - N_('Start Servers in this Server Group'), - N_('Start Server Group'), - :image => 'start', - :confirm => N_('Do you want to trigger a start of this server group?'), - ), - ] - ), - ]) end diff --git a/app/views/middleware_shared/_ops_params.html.haml b/app/views/middleware_server/_ops_params.html.haml similarity index 97% rename from app/views/middleware_shared/_ops_params.html.haml rename to app/views/middleware_server/_ops_params.html.haml index 75dac6870c06..77a49c799cb1 100644 --- a/app/views/middleware_shared/_ops_params.html.haml +++ b/app/views/middleware_server/_ops_params.html.haml @@ -1,7 +1,7 @@ - @angular_form = true %ng-form.form-horizontal#form_op_params{"name" => "opsParamForm", - "ng-controller" => opsController, + "ng-controller" => "mwServerOpsController", "novalidate" => "true"} .modal.fade#modal_param_div{"tabindex" => "-1", "role" => "dialog", diff --git a/app/views/middleware_server/show.html.haml b/app/views/middleware_server/show.html.haml index cbe0bf7d22a6..eced346942aa 100644 --- a/app/views/middleware_server/show.html.haml +++ b/app/views/middleware_server/show.html.haml @@ -10,7 +10,7 @@ %ng-form#mw_server_form{"name" => "mw_server_form", "ng-controller" => "mwServerController", "novalidate" => "true"} - = render :partial => 'middleware_shared/ops_params', :locals => {:opsController => 'mwServerOpsController'} + = render :partial => 'ops_params' :javascript miq_bootstrap('#mw_server_form'); diff --git a/app/views/middleware_server_group/show.html.haml b/app/views/middleware_server_group/show.html.haml index c0bc3e978a4f..9578a7d0669e 100644 --- a/app/views/middleware_server_group/show.html.haml +++ b/app/views/middleware_server_group/show.html.haml @@ -9,7 +9,6 @@ %ng-form#mw_server_form{"name" => "mw_server_form", "ng-controller" => "mwServerGroupController", "novalidate" => "true"} - = render :partial => 'middleware_shared/ops_params', :locals => {:opsController => 'mwServerGroupOpsController'} :javascript miq_bootstrap('#mw_server_form'); diff --git a/config/routes.rb b/config/routes.rb index e279d89a6aae..d6c0eeb63151 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1516,7 +1516,6 @@ form_field_changed listnav_search_selected quick_search - run_operation sections_field_changed show show_list