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
|
var scope = view.inject(UserList, { mode: mode }); // Inject our view
|
||||||
scope.selected = [];
|
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;
|
$rootScope.flashMessage = null;
|
||||||
SearchInit({ scope: scope, set: 'users', list: list, url: defaultUrl });
|
SearchInit({ scope: scope, set: 'users', list: list, url: defaultUrl });
|
||||||
PaginateInit({ scope: scope, 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) {
|
scope.deleteUser = function(id, name) {
|
||||||
|
|
||||||
var action = function() {
|
var action = function() {
|
||||||
Wait('start')
|
$('#prompt-modal').on('hidden.bs.modal', function(){ Wait('start'); });
|
||||||
|
$('#prompt-modal').modal('hide');
|
||||||
var url = defaultUrl + id + '/';
|
var url = defaultUrl + id + '/';
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.destroy()
|
Rest.destroy()
|
||||||
.success( function(data, status, headers, config) {
|
.success( function(data, status, headers, config) {
|
||||||
Wait('stop');
|
|
||||||
$('#prompt-modal').modal('hide');
|
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error( function(data, status, headers, config) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
$('#prompt-modal').modal('hide');
|
|
||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null,
|
||||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
||||||
});
|
});
|
||||||
@ -126,7 +133,6 @@ function UsersAdd ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
// Save
|
// Save
|
||||||
scope.formSave = function() {
|
scope.formSave = function() {
|
||||||
generator.clearApiErrors();
|
generator.clearApiErrors();
|
||||||
Wait('start');
|
|
||||||
if (scope.organization !== undefined && scope.organization !== null && scope.organization !== '') {
|
if (scope.organization !== undefined && scope.organization !== null && scope.organization !== '') {
|
||||||
Rest.setUrl(defaultUrl + scope.organization + '/users/');
|
Rest.setUrl(defaultUrl + scope.organization + '/users/');
|
||||||
var data = {}
|
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 = (data.is_superuser == null || data.is_superuser == undefined || data.is_superuser == '') ? false :
|
||||||
data.is_superuser;
|
data.is_superuser;
|
||||||
|
Wait('start');
|
||||||
Rest.post(data)
|
Rest.post(data)
|
||||||
.success( function(data, status, headers, config) {
|
.success( function(data, status, headers, config) {
|
||||||
Wait('stop');
|
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
var base = $location.path().replace(/^\//,'').split('/')[0];
|
||||||
if (base == 'users') {
|
if (base == 'users') {
|
||||||
$rootScope.flashMessage = 'New user successfully created!';
|
$rootScope.flashMessage = 'New user successfully created!';
|
||||||
@ -265,7 +270,6 @@ function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
// Save changes to the parent
|
// Save changes to the parent
|
||||||
scope.formSave = function() {
|
scope.formSave = function() {
|
||||||
generator.clearApiErrors();
|
generator.clearApiErrors();
|
||||||
Wait('start');
|
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
Rest.setUrl(defaultUrl + id + '/');
|
Rest.setUrl(defaultUrl + id + '/');
|
||||||
var data = {}
|
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 = (data.is_superuser == null || data.is_superuser == undefined || data.is_superuser == '') ? false :
|
||||||
data.is_superuser;
|
data.is_superuser;
|
||||||
|
|
||||||
|
Wait('start');
|
||||||
Rest.put(data)
|
Rest.put(data)
|
||||||
.success( function(data, status, headers, config) {
|
.success( function(data, status, headers, config) {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
|
@ -356,7 +356,7 @@ angular.module('Utilities',['RestServices', 'Utilities'])
|
|||||||
}])
|
}])
|
||||||
|
|
||||||
.factory('Wait', [ '$rootScope', function($rootScope) {
|
.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
|
// 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).
|
// UI while waiting on async things to complete (i.e. API calls).
|
||||||
// Wait('start' | 'stop');
|
// Wait('start' | 'stop');
|
||||||
@ -375,11 +375,11 @@ angular.module('Utilities',['RestServices', 'Utilities'])
|
|||||||
$('.spinny').css({
|
$('.spinny').css({
|
||||||
top: y,
|
top: y,
|
||||||
left: x
|
left: x
|
||||||
}).fadeIn(400, callback);
|
}).fadeIn(400);
|
||||||
}
|
}
|
||||||
else {
|
else if (directive == 'stop' && $rootScope.waiting){
|
||||||
$rootScope.waiting = false;
|
$rootScope.waiting = false;
|
||||||
$('.spinny, .overlay').fadeOut(500, callback);
|
$('.spinny, .overlay').fadeOut(500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}])
|
}])
|
||||||
|
Loading…
Reference in New Issue
Block a user