mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 09:51:09 +03:00
Fixed *flashy* working spinner behavior. Noticed it on Users page when adding a new user. Problem is with callback feature on working widget. If the callback is empty, then don't pass along undefined to fadein/fadeout. Applied delete spinner changes to Users, somehow it had been overlooked.
This commit is contained in:
parent
d6cbcde0b4
commit
aef534f080
@ -25,6 +25,15 @@ function UsersList ($scope, $rootScope, $location, $log, $routeParams, Rest, Ale
|
||||
var scope = view.inject(UserList, { mode: mode }); // Inject our view
|
||||
scope.selected = [];
|
||||
|
||||
if (scope.removePostRefresh) {
|
||||
scope.removePostRefresh();
|
||||
}
|
||||
scope.removePostRefresh = scope.$on('PostRefresh', function() {
|
||||
// Cleanup after a delete
|
||||
Wait('stop');
|
||||
$('#prompt-modal').off();
|
||||
});
|
||||
|
||||
$rootScope.flashMessage = null;
|
||||
SearchInit({ scope: scope, set: 'users', list: list, url: defaultUrl });
|
||||
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
||||
@ -49,18 +58,16 @@ function UsersList ($scope, $rootScope, $location, $log, $routeParams, Rest, Ale
|
||||
scope.deleteUser = function(id, name) {
|
||||
|
||||
var action = function() {
|
||||
Wait('start')
|
||||
$('#prompt-modal').on('hidden.bs.modal', function(){ Wait('start'); });
|
||||
$('#prompt-modal').modal('hide');
|
||||
var url = defaultUrl + id + '/';
|
||||
Rest.setUrl(url);
|
||||
Rest.destroy()
|
||||
.success( function(data, status, headers, config) {
|
||||
Wait('stop');
|
||||
$('#prompt-modal').modal('hide');
|
||||
scope.search(list.iterator);
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
Wait('stop');
|
||||
$('#prompt-modal').modal('hide');
|
||||
ProcessErrors(scope, data, status, null,
|
||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
||||
});
|
||||
@ -126,7 +133,6 @@ function UsersAdd ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
||||
// Save
|
||||
scope.formSave = function() {
|
||||
generator.clearApiErrors();
|
||||
Wait('start');
|
||||
if (scope.organization !== undefined && scope.organization !== null && scope.organization !== '') {
|
||||
Rest.setUrl(defaultUrl + scope.organization + '/users/');
|
||||
var data = {}
|
||||
@ -141,10 +147,9 @@ function UsersAdd ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
||||
|
||||
data.is_superuser = (data.is_superuser == null || data.is_superuser == undefined || data.is_superuser == '') ? false :
|
||||
data.is_superuser;
|
||||
|
||||
Wait('start');
|
||||
Rest.post(data)
|
||||
.success( function(data, status, headers, config) {
|
||||
Wait('stop');
|
||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
||||
if (base == 'users') {
|
||||
$rootScope.flashMessage = 'New user successfully created!';
|
||||
@ -265,7 +270,6 @@ function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
||||
// Save changes to the parent
|
||||
scope.formSave = function() {
|
||||
generator.clearApiErrors();
|
||||
Wait('start');
|
||||
$rootScope.flashMessage = null;
|
||||
Rest.setUrl(defaultUrl + id + '/');
|
||||
var data = {}
|
||||
@ -281,6 +285,7 @@ function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
||||
data.is_superuser = (data.is_superuser == null || data.is_superuser == undefined || data.is_superuser == '') ? false :
|
||||
data.is_superuser;
|
||||
|
||||
Wait('start');
|
||||
Rest.put(data)
|
||||
.success( function(data, status, headers, config) {
|
||||
Wait('stop');
|
||||
|
@ -356,7 +356,7 @@ angular.module('Utilities',['RestServices', 'Utilities'])
|
||||
}])
|
||||
|
||||
.factory('Wait', [ '$rootScope', function($rootScope) {
|
||||
return function(directive, callback) {
|
||||
return function(directive) {
|
||||
// Display a spinning icon in the center of the screen to freeze the
|
||||
// UI while waiting on async things to complete (i.e. API calls).
|
||||
// Wait('start' | 'stop');
|
||||
@ -375,11 +375,11 @@ angular.module('Utilities',['RestServices', 'Utilities'])
|
||||
$('.spinny').css({
|
||||
top: y,
|
||||
left: x
|
||||
}).fadeIn(400, callback);
|
||||
}).fadeIn(400);
|
||||
}
|
||||
else {
|
||||
else if (directive == 'stop' && $rootScope.waiting){
|
||||
$rootScope.waiting = false;
|
||||
$('.spinny, .overlay').fadeOut(500, callback);
|
||||
$('.spinny, .overlay').fadeOut(500);
|
||||
}
|
||||
}
|
||||
}])
|
||||
|
Loading…
Reference in New Issue
Block a user