AC-1308 spinner lingers after 403 error

Happening on response to Delete prompt. Removed modal hide listener when starting spinner. Not sure why I thought that was needed. Instead, just close the dialog and start the spinner. If an error occurs, ProcessErrors always stops the spinner. Issue was caused by a race condition. ProcessErrors would sometimes fire tht stop before the event listener fired a start.
This commit is contained in:
Chris Houseknecht 2014-06-03 19:20:35 -04:00
parent ad5d0454c2
commit c517332191
8 changed files with 68 additions and 79 deletions

View File

@ -12,21 +12,21 @@
function AdminsList($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, AdminList, GenerateList, LoadBreadCrumbs,
Prompt, SearchInit, PaginateInit, ReturnToCaller, GetBasePath, SelectionInit) {
var list = AdminList,
defaultUrl = GetBasePath('organizations') + $routeParams.organization_id + '/users/',
generator = GenerateList,
mode = 'select',
url = GetBasePath('organizations') + $routeParams.organization_id + '/admins/';
generator.inject(AdminList, { mode: mode, scope: $scope });
SelectionInit({ scope: $scope, list: list, url: url, returnToCaller: 1 });
SearchInit({ scope: $scope, set: 'admins', list: list, url: defaultUrl });
PaginateInit({ scope: $scope, list: list, url: defaultUrl });
$scope.search(list.iterator);
LoadBreadCrumbs();

View File

@ -12,7 +12,7 @@
function CredentialsList($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, CredentialList,
GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller,
ClearScope, ProcessErrors, GetBasePath, SelectionInit, GetChoices, Wait, Stream) {
ClearScope();
Wait('start');
@ -40,8 +40,8 @@ function CredentialsList($scope, $rootScope, $location, $log, $routeParams, Rest
}
$scope.removePostRefresh = $scope.$on('PostRefresh', function () {
var i, j;
// Cleanup after a delete
// Cleanup after a delete
Wait('stop');
$('#prompt-modal').modal('hide');
@ -102,10 +102,8 @@ function CredentialsList($scope, $rootScope, $location, $log, $routeParams, Rest
$scope.deleteCredential = function (id, name) {
var action = function () {
$('#prompt-modal').on('hidden.bs.modal', function () {
Wait('start');
});
$('#prompt-modal').modal('hide');
Wait('start');
var url = defaultUrl + id + '/';
Rest.setUrl(url);
Rest.destroy()
@ -135,7 +133,7 @@ CredentialsList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routeP
function CredentialsAdd($scope, $rootScope, $compile, $location, $log, $routeParams, CredentialForm, GenerateForm, Rest, Alert,
ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, GenerateList, SearchInit, PaginateInit, LookUpInit, UserList, TeamList,
GetBasePath, GetChoices, Empty, KindChange, OwnerChange, FormSave) {
ClearScope();
// Inject dynamic view
@ -143,7 +141,7 @@ function CredentialsAdd($scope, $rootScope, $compile, $location, $log, $routePar
generator = GenerateForm,
defaultUrl = GetBasePath('credentials'),
url;
generator.inject(form, { mode: 'add', related: false, scope: $scope });
generator.reset();
LoadBreadCrumbs();
@ -269,7 +267,7 @@ CredentialsAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log
function CredentialsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, CredentialForm, GenerateForm, Rest, Alert,
ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, Prompt, GetBasePath, GetChoices,
KindChange, UserList, TeamList, LookUpInit, Empty, OwnerChange, FormSave, Stream, Wait) {
ClearScope();
var defaultUrl = GetBasePath('credentials'),
@ -278,7 +276,7 @@ function CredentialsEdit($scope, $rootScope, $compile, $location, $log, $routePa
base = $location.path().replace(/^\//, '').split('/')[0],
master = {},
id = $routeParams.credential_id;
generator.inject(form, { mode: 'edit', related: true, scope: $scope });
generator.reset();
$scope.id = id;
@ -344,9 +342,9 @@ function CredentialsEdit($scope, $rootScope, $compile, $location, $log, $routePa
Rest.setUrl(defaultUrl + ':id/');
Rest.get({ params: { id: id } })
.success(function (data) {
var i, fld;
LoadBreadCrumbs({
path: '/credentials/' + id,
title: data.name

View File

@ -316,9 +316,7 @@ function InventoriesList($scope, $rootScope, $location, $log, $routeParams, $com
var action = function () {
var url = defaultUrl + id + '/';
$('#prompt-modal').on('hidden.bs.modal', function () {
Wait('start');
});
Wait('start');
$('#prompt-modal').modal('hide');
Rest.setUrl(url);
Rest.destroy()

View File

@ -21,7 +21,7 @@ function JobTemplatesList($scope, $rootScope, $location, $log, $routeParams, Res
view = GenerateList,
base = $location.path().replace(/^\//, '').split('/')[0],
mode = (base === 'job_templates') ? 'edit' : 'select';
view.inject(list, { mode: mode, scope: $scope });
$rootScope.flashMessage = null;
@ -71,10 +71,8 @@ function JobTemplatesList($scope, $rootScope, $location, $log, $routeParams, Res
$scope.deleteJobTemplate = function (id, name) {
var action = function () {
$('#prompt-modal').on('hidden.bs.modal', function () {
Wait('start');
});
$('#prompt-modal').modal('hide');
Wait('start');
var url = defaultUrl + id + '/';
Rest.setUrl(url);
Rest.destroy()
@ -110,7 +108,7 @@ function JobTemplatesAdd($scope, $rootScope, $compile, $location, $log, $routePa
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, GetBasePath,
InventoryList, CredentialList, ProjectList, LookUpInit, md5Setup, ParseTypeChange, Wait, Empty, ToJSON,
CallbackHelpInit) {
ClearScope();
// Inject dynamic view
@ -121,11 +119,11 @@ function JobTemplatesAdd($scope, $rootScope, $compile, $location, $log, $routePa
CloudCredentialList = {},
selectPlaybook, checkSCMStatus,
callback;
CallbackHelpInit({ scope: $scope });
generator.inject(form, { mode: 'add', related: false, scope: $scope });
callback = function() {
// Make sure the form controller knows there was a change
$scope[form.name + '_form'].setDirty();
@ -343,7 +341,7 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP
CredentialList, ProjectList, LookUpInit, GetBasePath, md5Setup, ParseTypeChange, JobStatusToolTip, FormatDate,
Wait, Stream, Empty, Prompt, ParseVariableString, ToJSON, SchedulesControllerInit, JobsControllerInit, JobsListUpdate,
GetChoices, SchedulesListInit, SchedulesList, CallbackHelpInit) {
ClearScope();
var defaultUrl = GetBasePath('job_templates'),
@ -364,19 +362,19 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP
$scope.parseType = 'yaml';
$scope.showJobType = false;
// Our job type options
$scope.job_type_options = [
{ value: 'run', label: 'Run' },
{ value: 'check', label: 'Check' }
];
$scope.verbosity_options = [
{ value: 0, label: 'Default' },
{ value: 1, label: 'Verbose' },
{ value: 3, label: 'Debug' }
];
callback = function() {
// Make sure the form controller knows there was a change
$scope[form.name + '_form'].$setDirty();
@ -482,7 +480,7 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP
$scope.removeJobTemplateLoadFinished = $scope.$on('jobTemplateLoadFinished', function () {
loadingFinishedCount++;
if (loadingFinishedCount >= 2) {
// The initial template load finished. Now load related jobs, which
// The initial template load finished. Now load related jobs, which
// will turn off the 'working' spinner.
for (var set in relatedSets) {
$scope.search(relatedSets[set].iterator);
@ -601,7 +599,7 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP
master[fld] = $scope[fld];
}
if (fld === 'variables') {
// Parse extra_vars, converting to YAML.
// Parse extra_vars, converting to YAML.
$scope.variables = ParseVariableString(data.extra_vars);
master.variables = $scope.variables;
}
@ -617,15 +615,15 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP
$scope.ask_variables_on_launch = (data.ask_variables_on_launch) ? 'true' : 'false';
master.ask_variables_on_launch = $scope.ask_variables_on_launch;
relatedSets = form.relatedSets(data.related);
if (data.host_config_key) {
$scope.example_config_key = data.host_config_key;
}
$scope.example_template_id = id;
$scope.setCallbackHelp();
$scope.callback_url = $scope.callback_server_path + ((data.related.callback) ? data.related.callback :
GetBasePath('job_templates') + id + '/callback/');
master.callback_url = $scope.callback_url;
@ -661,7 +659,7 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP
form: form,
relatedSets: relatedSets
});
RelatedPaginateInit({
scope: $scope,
relatedSets: relatedSets
@ -694,7 +692,7 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP
variable: 'status_choices',
callback: 'choicesReady'
});
GetChoices({
scope: $scope,
url: GetBasePath('unified_jobs'),

View File

@ -12,7 +12,7 @@
function OrganizationsList($routeParams, $scope, $rootScope, $location, $log, Rest, Alert, LoadBreadCrumbs, Prompt,
GenerateList, OrganizationList, SearchInit, PaginateInit, ClearScope, ProcessErrors, GetBasePath, SelectionInit, Wait, Stream) {
ClearScope();
var list = OrganizationList,
@ -21,11 +21,11 @@ function OrganizationsList($routeParams, $scope, $rootScope, $location, $log, Re
mode = (paths[0] === 'organizations') ? 'edit' : 'select',
defaultUrl = GetBasePath('organizations'),
url;
generate.inject(OrganizationList, { mode: mode, scope: $scope });
$rootScope.flashMessage = null;
LoadBreadCrumbs();
if (mode === 'select') {
url = GetBasePath('projects') + $routeParams.project_id + '/organizations/';
SelectionInit({ scope: $scope, list: list, url: url, returnToCaller: 1 });
@ -69,10 +69,8 @@ function OrganizationsList($routeParams, $scope, $rootScope, $location, $log, Re
$scope.deleteOrganization = function (id, name) {
var action = function () {
$('#prompt-modal').on('hidden.bs.modal', function () {
Wait('start');
});
$('#prompt-modal').modal('hide');
Wait('start');
var url = defaultUrl + id + '/';
Rest.setUrl(url);
Rest.destroy()
@ -102,9 +100,9 @@ OrganizationsList.$inject = ['$routeParams', '$scope', '$rootScope', '$location'
function OrganizationsAdd($scope, $rootScope, $compile, $location, $log, $routeParams, OrganizationForm,
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope, GetBasePath,
ReturnToCaller, Wait) {
ClearScope();
// Inject dynamic view
var generator = GenerateForm,
form = OrganizationForm,
@ -152,7 +150,7 @@ OrganizationsAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$l
function OrganizationsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, OrganizationForm, GenerateForm, Rest,
Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, Prompt, ClearScope, GetBasePath, Wait, Stream) {
ClearScope();
// Inject dynamic view

View File

@ -7,20 +7,20 @@
* Controller functions for Permissions model.
*
*/
'use strict';
function PermissionsList($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, PermissionList,
GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors,
GetBasePath, CheckAccess, Wait) {
ClearScope();
var list = PermissionList,
base = $location.path().replace(/^\//, '').split('/')[0],
defaultUrl = GetBasePath(base),
generator = GenerateList;
generator.inject(list, { mode: 'edit', scope: $scope });
defaultUrl += ($routeParams.user_id !== undefined) ? $routeParams.user_id : $routeParams.team_id;
defaultUrl += '/permissions/';
@ -67,10 +67,8 @@ function PermissionsList($scope, $rootScope, $location, $log, $routeParams, Rest
$scope.deletePermission = function (id, name) {
var action = function () {
$('#prompt-modal').on('hidden.bs.modal', function () {
Wait('start');
});
$('#prompt-modal').modal('hide');
Wait('start');
var url = GetBasePath('base') + 'permissions/' + id + '/';
Rest.setUrl(url);
Rest.destroy()
@ -104,7 +102,7 @@ function PermissionsAdd($scope, $rootScope, $compile, $location, $log, $routePar
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope,
GetBasePath, ReturnToCaller, InventoryList, ProjectList, LookUpInit, CheckAccess,
Wait, PermissionCategoryChange) {
ClearScope();
// Inject dynamic view
@ -113,7 +111,7 @@ function PermissionsAdd($scope, $rootScope, $compile, $location, $log, $routePar
id = ($routeParams.user_id !== undefined) ? $routeParams.user_id : $routeParams.team_id,
base = $location.path().replace(/^\//, '').split('/')[0],
master = {};
generator.inject(form, { mode: 'add', related: false, scope: $scope });
CheckAccess({ scope: $scope });
generator.reset();
@ -198,7 +196,7 @@ PermissionsAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log
function PermissionsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, PermissionsForm,
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, Prompt, GetBasePath,
InventoryList, ProjectList, LookUpInit, CheckAccess, Wait, PermissionCategoryChange) {
ClearScope();
var generator = GenerateForm,
@ -207,11 +205,11 @@ function PermissionsEdit($scope, $rootScope, $compile, $location, $log, $routePa
id = $routeParams.permission_id,
defaultUrl = GetBasePath('base') + 'permissions/' + id + '/',
master = {};
generator.inject(form, { mode: 'edit', related: true, scope: $scope });
generator.reset();
CheckAccess({ scope: $scope });
$scope.selectCategory = function (resetIn) {

View File

@ -13,7 +13,7 @@
function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, ProjectList, GenerateList, LoadBreadCrumbs,
Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, SelectionInit, ProjectUpdate,
Refresh, Wait, Stream, GetChoices, Empty, Find, LogViewer, GetProjectIcon, GetProjectToolTip) {
ClearScope();
Wait('start');
@ -45,10 +45,10 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
}
$scope.removePostRefresh = $scope.$on('PostRefresh', function () {
Wait('stop');
if ($scope.projects) {
$scope.projects.forEach(function(project, i) {
$scope.projects[i].statusIcon = GetProjectIcon(project.status);
$scope.projects[i].statusTip = GetProjectToolTip(project.status);
@ -233,10 +233,8 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
$scope.deleteProject = function (id, name) {
var action = function () {
$('#prompt-modal').on('hiden.bs.modal', function () {
Wait('start');
});
$('#prompt-modal').modal('hide');
Wait('start');
var url = defaultUrl + id + '/';
Rest.setUrl(url);
Rest.destroy()
@ -376,7 +374,7 @@ ProjectsList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routePara
function ProjectsAdd($scope, $rootScope, $compile, $location, $log, $routeParams, ProjectsForm, GenerateForm, Rest, Alert, ProcessErrors,
LoadBreadCrumbs, ClearScope, GetBasePath, ReturnToCaller, GetProjectPath, LookUpInit, OrganizationList,
CredentialList, GetChoices, DebugForm, Wait) {
ClearScope();
// Inject dynamic view
@ -385,7 +383,7 @@ function ProjectsAdd($scope, $rootScope, $compile, $location, $log, $routeParams
base = $location.path().replace(/^\//, '').split('/')[0],
defaultUrl = GetBasePath('projects'),
master = {};
generator.inject(form, { mode: 'add', related: false, scope: $scope });
generator.reset();
LoadBreadCrumbs();
@ -518,7 +516,7 @@ function ProjectsEdit($scope, $rootScope, $compile, $location, $log, $routeParam
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, Prompt,
ClearScope, GetBasePath, ReturnToCaller, GetProjectPath, Authorization, CredentialList, LookUpInit, GetChoices,
Empty, DebugForm, Wait, Stream, SchedulesControllerInit, SchedulesListInit, SchedulesList) {
ClearScope('htmlTemplate');
// Inject dynamic view
@ -529,7 +527,7 @@ function ProjectsEdit($scope, $rootScope, $compile, $location, $log, $routeParam
master = {},
id = $routeParams.id,
relatedSets = {};
SchedulesList.well = false;
generator.inject(form, { mode: 'edit', related: true, scope: $scope });
generator.reset();
@ -622,7 +620,7 @@ function ProjectsEdit($scope, $rootScope, $compile, $location, $log, $routeParam
data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField];
}
}
relatedSets = form.relatedSets(data.related);
data.scm_type = (Empty(data.scm_type)) ? '' : data.scm_type;

View File

@ -23,7 +23,7 @@ function UsersList($scope, $rootScope, $location, $log, $routeParams, Rest, Aler
GetBasePath('teams') + $routeParams.team_id + '/users/';
generator.inject(UserList, { mode: mode, scope: $scope });
$scope.selected = [];
if (mode === 'select') {
@ -70,10 +70,11 @@ function UsersList($scope, $rootScope, $location, $log, $routeParams, Rest, Aler
$scope.deleteUser = function (id, name) {
var action = function () {
$('#prompt-modal').on('hidden.bs.modal', function () {
Wait('start');
});
//$('#prompt-modal').on('hidden.bs.modal', function () {
// Wait('start');
//});
$('#prompt-modal').modal('hide');
Wait('start');
var url = defaultUrl + id + '/';
Rest.setUrl(url);
Rest.destroy()
@ -102,17 +103,17 @@ UsersList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routeParams'
function UsersAdd($scope, $rootScope, $compile, $location, $log, $routeParams, UserForm, GenerateForm, Rest, Alert, ProcessErrors,
LoadBreadCrumbs, ReturnToCaller, ClearScope, GetBasePath, LookUpInit, OrganizationList, ResetForm, Wait) {
ClearScope();
// Inject dynamic view
var defaultUrl = GetBasePath('organizations'),
form = UserForm,
generator = GenerateForm;
generator.inject(form, { mode: 'add', related: false, scope: $scope });
ResetForm();
$scope.ldap_user = false;
$scope.not_ldap_user = !$scope.ldap_user;
$scope.ldap_dn = null;
@ -121,7 +122,7 @@ function UsersAdd($scope, $rootScope, $compile, $location, $log, $routeParams, U
LoadBreadCrumbs();
// Configure the lookup dialog. If we're adding a user through the Organizations tab,
// Configure the lookup dialog. If we're adding a user through the Organizations tab,
// default the Organization value.
LookUpInit({
scope: $scope,
@ -205,7 +206,7 @@ UsersAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$r
function UsersEdit($scope, $rootScope, $compile, $location, $log, $routeParams, UserForm, GenerateForm, Rest, Alert,
ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, GetBasePath,
Prompt, CheckAccess, ResetForm, Wait, Stream) {
ClearScope();
var defaultUrl = GetBasePath('users'),
@ -422,7 +423,7 @@ function UsersEdit($scope, $rootScope, $compile, $location, $log, $routeParams,
};
}); // $scope.$on
// Put form back to its original state
// Put form back to its original state
ResetForm();