Skip to content

Commit

Permalink
Revert "Merge pull request ManageIQ#286 from Jiri-Kremser/server-grou…
Browse files Browse the repository at this point in the history
…p-power-ops-ui"

This reverts commit e7a178a, reversing
changes made to ce85750.
  • Loading branch information
israel-hdez committed Jan 15, 2018
1 parent e85f16a commit 48ca4ef
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -112,31 +102,20 @@ 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,
'operation': operation,
'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;
Expand All @@ -157,7 +136,4 @@ function ServerOpsServiceFactory($http, $q, isGroup) {
});
return deferred.promise;
};
return {
runOperation: runOperation,
};
}
2 changes: 1 addition & 1 deletion app/controllers/middleware_server_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 2 additions & 29 deletions app/controllers/middleware_server_group_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion app/controllers/mixins/middleware_operations_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion app/views/middleware_server/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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');
1 change: 0 additions & 1 deletion app/views/middleware_server_group/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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');
1 change: 0 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1516,7 +1516,6 @@
form_field_changed
listnav_search_selected
quick_search
run_operation
sections_field_changed
show
show_list
Expand Down

0 comments on commit 48ca4ef

Please sign in to comment.