mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 13:39:27 -02:30
Fixed issue with selected users based on user.id rathr than set index. Fixed dataLoad callback not being destroyed after controller routine exits.
This commit is contained in:
@@ -63,17 +63,25 @@ function AdminsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (scope.selected.length > 0 ) {
|
if (scope.selected.length > 0 ) {
|
||||||
|
var user;
|
||||||
for (var i=0; i < scope.selected.length; i++) {
|
for (var i=0; i < scope.selected.length; i++) {
|
||||||
//var admin = scope.admins[scope.selected[i]].username;
|
user = null;
|
||||||
Rest.post(scope.admins[scope.selected[i]])
|
for (var j=0; j < scope.admins.length; j++) {
|
||||||
.success( function(data, status, headers, config) {
|
if (scope.admins[j].id == scope.selected[i]) {
|
||||||
scope.queue.push({ result: 'success', data: data, status: status });
|
user = scope.admins[j];
|
||||||
scope.$emit('callFinished');
|
}
|
||||||
})
|
}
|
||||||
.error( function(data, status, headers, config) {
|
if (user !== null) {
|
||||||
scope.queue.push({ result: 'error', data: data, status: status, headers: headers });
|
Rest.post(user)
|
||||||
scope.$emit('callFinished');
|
.success( function(data, status, headers, config) {
|
||||||
});
|
scope.queue.push({ result: 'success', data: data, status: status });
|
||||||
|
scope.$emit('callFinished');
|
||||||
|
})
|
||||||
|
.error( function(data, status, headers, config) {
|
||||||
|
scope.queue.push({ result: 'error', data: data, status: status, headers: headers });
|
||||||
|
scope.$emit('callFinished');
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function GroupsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
function GroupsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
||||||
Alert, GroupList, GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit,
|
Alert, GroupList, GenerateList, LoadBreadCrumbs, Prompt, SearchInit,
|
||||||
ReturnToCaller, ClearScope)
|
PaginateInit, ReturnToCaller, ClearScope, ProcessErrors)
|
||||||
{
|
{
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
//scope.
|
//scope.
|
||||||
@@ -149,8 +149,7 @@ function GroupsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams
|
|||||||
LookUpInventoryInit({ scope: scope });
|
LookUpInventoryInit({ scope: scope });
|
||||||
|
|
||||||
// After the Organization is loaded, retrieve each related set
|
// After the Organization is loaded, retrieve each related set
|
||||||
scope.$on('dataLoaded', function() {
|
scope.$on('groupLoaded', function() {
|
||||||
|
|
||||||
Rest.setUrl(scope['inventory_url']);
|
Rest.setUrl(scope['inventory_url']);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success( function(data, status, headers, config) {
|
||||||
@@ -161,11 +160,9 @@ function GroupsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams
|
|||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null,
|
||||||
{ hdr: 'Error!', msg: 'Failed to retrieve: ' + scope.orgnization_url + '. GET status: ' + status });
|
{ hdr: 'Error!', msg: 'Failed to retrieve: ' + scope.orgnization_url + '. GET status: ' + status });
|
||||||
});
|
});
|
||||||
|
|
||||||
for (var set in relatedSets) {
|
for (var set in relatedSets) {
|
||||||
scope.search(relatedSets[set].iterator);
|
scope.search(relatedSets[set].iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Retrieve detail record and prepopulate the form
|
// Retrieve detail record and prepopulate the form
|
||||||
@@ -189,7 +186,7 @@ function GroupsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams
|
|||||||
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
|
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
|
||||||
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
|
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
|
||||||
scope['inventory_url'] = data.related.inventory;
|
scope['inventory_url'] = data.related.inventory;
|
||||||
scope.$emit('dataLoaded');
|
scope.$emit('groupLoaded');
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error( function(data, status, headers, config) {
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, form,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
function HostsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
function HostsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
||||||
Alert, HostList, GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit,
|
Alert, HostList, GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit,
|
||||||
ReturnToCaller, ClearScope)
|
ReturnToCaller, ClearScope, ProcessErrors)
|
||||||
{
|
{
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
//scope.
|
//scope.
|
||||||
@@ -65,7 +65,7 @@ function HostsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
}
|
}
|
||||||
|
|
||||||
HostsList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'HostList', 'GenerateList',
|
HostsList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'HostList', 'GenerateList',
|
||||||
'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope' ];
|
'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors' ];
|
||||||
|
|
||||||
|
|
||||||
function HostsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, HostForm,
|
function HostsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, HostForm,
|
||||||
@@ -150,8 +150,7 @@ function HostsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
LookUpInventoryInit({ scope: scope });
|
LookUpInventoryInit({ scope: scope });
|
||||||
|
|
||||||
// After form data loads, load related sets and lookups
|
// After form data loads, load related sets and lookups
|
||||||
scope.$on('dataLoaded', function() {
|
scope.$on('hostLoaded', function() {
|
||||||
|
|
||||||
Rest.setUrl(scope['inventory_url']);
|
Rest.setUrl(scope['inventory_url']);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success( function(data, status, headers, config) {
|
||||||
@@ -162,11 +161,9 @@ function HostsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null,
|
||||||
{ hdr: 'Error!', msg: 'Failed to retrieve: ' + scope.inventory_url + '. GET status: ' + status });
|
{ hdr: 'Error!', msg: 'Failed to retrieve: ' + scope.inventory_url + '. GET status: ' + status });
|
||||||
});
|
});
|
||||||
|
|
||||||
for (var set in relatedSets) {
|
for (var set in relatedSets) {
|
||||||
scope.search(relatedSets[set].iterator);
|
scope.search(relatedSets[set].iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Retrieve detail record and prepopulate the form
|
// Retrieve detail record and prepopulate the form
|
||||||
@@ -190,7 +187,7 @@ function HostsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
|
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
|
||||||
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
|
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
|
||||||
scope['inventory_url'] = data.related.inventory;
|
scope['inventory_url'] = data.related.inventory;
|
||||||
scope.$emit('dataLoaded');
|
scope.$emit('hostLoaded');
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error( function(data, status, headers, config) {
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, form,
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ function InventoriesAdd ($scope, $rootScope, $compile, $location, $log, $routePa
|
|||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error( function(data, status, headers, config) {
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, form,
|
||||||
{ hdr: 'Error!', msg: 'Failed to add new user. Post returned status: ' + status });
|
{ hdr: 'Error!', msg: 'Failed to add new inventory. Post returned status: ' + status });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -203,8 +203,7 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
LookUpOrganizationInit({ scope: scope });
|
LookUpOrganizationInit({ scope: scope });
|
||||||
|
|
||||||
// After inventory is loaded, retrieve each related set and any lookups
|
// After inventory is loaded, retrieve each related set and any lookups
|
||||||
scope.$on('dataLoaded', function() {
|
scope.$on('inventoryLoaded', function() {
|
||||||
|
|
||||||
Rest.setUrl(scope['organization_url']);
|
Rest.setUrl(scope['organization_url']);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success( function(data, status, headers, config) {
|
||||||
@@ -215,11 +214,10 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null,
|
||||||
{ hdr: 'Error!', msg: 'Failed to retrieve: ' + scope.orgnization_url + '. GET status: ' + status });
|
{ hdr: 'Error!', msg: 'Failed to retrieve: ' + scope.orgnization_url + '. GET status: ' + status });
|
||||||
});
|
});
|
||||||
|
|
||||||
for (var set in relatedSets) {
|
for (var set in relatedSets) {
|
||||||
|
console.log('inventory edit set: ' + set);
|
||||||
scope.search(relatedSets[set].iterator);
|
scope.search(relatedSets[set].iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Retrieve detail record and prepopulate the form
|
// Retrieve detail record and prepopulate the form
|
||||||
@@ -243,7 +241,7 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
|
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
|
||||||
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
|
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
|
||||||
scope['organization_url'] = data.related.organization;
|
scope['organization_url'] = data.related.organization;
|
||||||
scope.$emit('dataLoaded');
|
scope.$emit('inventoryLoaded');
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error( function(data, status, headers, config) {
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, form,
|
||||||
@@ -264,7 +262,7 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error( function(data, status, headers, config) {
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, form,
|
||||||
{ hdr: 'Error!', msg: 'Failed to update users: ' + $routeParams.id + '. PUT status: ' + status });
|
{ hdr: 'Error!', msg: 'Failed to update inventory: ' + $routeParams.id + '. PUT status: ' + status });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function OrganizationsList ($scope, $rootScope, $location, $log, Rest, Alert, LoadBreadCrumbs, Prompt, GetAPIDefaults,
|
function OrganizationsList ($scope, $rootScope, $location, $log, Rest, Alert, LoadBreadCrumbs, Prompt, GetAPIDefaults,
|
||||||
GenerateList, OrganizationList, SearchInit, PaginateInit, ClearScope)
|
GenerateList, OrganizationList, SearchInit, PaginateInit, ClearScope, ProcessErrors)
|
||||||
{
|
{
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
//scope.
|
//scope.
|
||||||
@@ -67,7 +67,7 @@ function OrganizationsList ($scope, $rootScope, $location, $log, Rest, Alert, Lo
|
|||||||
}
|
}
|
||||||
|
|
||||||
OrganizationsList.$inject=[ '$scope', '$rootScope', '$location', '$log', 'Rest', 'Alert', 'LoadBreadCrumbs', 'Prompt', 'GetAPIDefaults',
|
OrganizationsList.$inject=[ '$scope', '$rootScope', '$location', '$log', 'Rest', 'Alert', 'LoadBreadCrumbs', 'Prompt', 'GetAPIDefaults',
|
||||||
'GenerateList', 'OrganizationList', 'SearchInit', 'PaginateInit', 'ClearScope' ];
|
'GenerateList', 'OrganizationList', 'SearchInit', 'PaginateInit', 'ClearScope', 'ProcessErrors'];
|
||||||
|
|
||||||
|
|
||||||
function OrganizationsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, OrganizationForm,
|
function OrganizationsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, OrganizationForm,
|
||||||
@@ -129,7 +129,7 @@ function OrganizationsEdit ($scope, $rootScope, $compile, $location, $log, $rout
|
|||||||
var relatedSets = {};
|
var relatedSets = {};
|
||||||
|
|
||||||
// After the Organization is loaded, retrieve each related set
|
// After the Organization is loaded, retrieve each related set
|
||||||
scope.$on('dataLoaded', function() {
|
scope.$on('organizationLoaded', function() {
|
||||||
for (var set in relatedSets) {
|
for (var set in relatedSets) {
|
||||||
scope.search(relatedSets[set].iterator);
|
scope.search(relatedSets[set].iterator);
|
||||||
}
|
}
|
||||||
@@ -155,7 +155,7 @@ function OrganizationsEdit ($scope, $rootScope, $compile, $location, $log, $rout
|
|||||||
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
|
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
|
||||||
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
|
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
|
||||||
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
|
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
|
||||||
scope.$emit('dataLoaded');
|
scope.$emit('organizationLoaded');
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error( function(data, status, headers, config) {
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, form,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
function UsersList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
function UsersList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
||||||
Alert, UserList, GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit,
|
Alert, UserList, GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit,
|
||||||
ReturnToCaller, ClearScope)
|
ReturnToCaller, ClearScope, ProcessErrors)
|
||||||
{
|
{
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
//scope.
|
//scope.
|
||||||
@@ -98,17 +98,25 @@ function UsersList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (scope.selected.length > 0 ) {
|
if (scope.selected.length > 0 ) {
|
||||||
|
var user;
|
||||||
for (var i=0; i < scope.selected.length; i++) {
|
for (var i=0; i < scope.selected.length; i++) {
|
||||||
var user = scope.users[scope.selected[i]].username;
|
user = null;
|
||||||
Rest.post(scope.users[scope.selected[i]])
|
for (var j=0; j < scope.users.length; j++) {
|
||||||
.success( function(data, status, headers, config) {
|
if (scope.users[j].id == scope.selected[i]) {
|
||||||
scope.queue.push({ result: 'success', data: data, status: status });
|
user = scope.users[j];
|
||||||
scope.$emit('callFinished');
|
}
|
||||||
})
|
}
|
||||||
.error( function(data, status, headers, config) {
|
if (user !== null) {
|
||||||
scope.queue.push({ result: 'error', data: data, status: status, headers: headers });
|
Rest.post(user)
|
||||||
scope.$emit('callFinished');
|
.success( function(data, status, headers, config) {
|
||||||
});
|
scope.queue.push({ result: 'success', data: data, status: status });
|
||||||
|
scope.$emit('callFinished');
|
||||||
|
})
|
||||||
|
.error( function(data, status, headers, config) {
|
||||||
|
scope.queue.push({ result: 'error', data: data, status: status, headers: headers });
|
||||||
|
scope.$emit('callFinished');
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -127,7 +135,7 @@ function UsersList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
}
|
}
|
||||||
|
|
||||||
UsersList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'UserList', 'GenerateList',
|
UsersList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'UserList', 'GenerateList',
|
||||||
'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope' ];
|
'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors' ];
|
||||||
|
|
||||||
|
|
||||||
function UsersAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, UserForm,
|
function UsersAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, UserForm,
|
||||||
@@ -197,7 +205,7 @@ function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
var relatedSets = {};
|
var relatedSets = {};
|
||||||
|
|
||||||
// After the Organization is loaded, retrieve each related set
|
// After the Organization is loaded, retrieve each related set
|
||||||
scope.$on('dataLoaded', function() {
|
scope.$on('userLoaded', function() {
|
||||||
for (var set in relatedSets) {
|
for (var set in relatedSets) {
|
||||||
scope.search(relatedSets[set].iterator);
|
scope.search(relatedSets[set].iterator);
|
||||||
}
|
}
|
||||||
@@ -228,7 +236,7 @@ function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
|
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
|
||||||
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
|
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
|
||||||
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
|
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
|
||||||
scope.$emit('dataLoaded');
|
scope.$emit('userLoaded');
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error( function(data, status, headers, config) {
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, form,
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ angular.module('OrganizationFormDefinition', [])
|
|||||||
class: 'btn-danger'
|
class: 'btn-danger'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ angular.module('ListGenerator', ['GeneratorHelpers'])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (options.mode == 'select') {
|
if (options.mode == 'select') {
|
||||||
html += " <button class=\"btn btn-success\" ng-click=\"finishSelection()\"><i class=\"icon-ok\"></i> Finished</button>\n";
|
html += " <button class=\"btn btn-mini btn-success\" ng-click=\"finishSelection()\"><i class=\"icon-ok\"></i> Finished</button>\n";
|
||||||
}
|
}
|
||||||
html += "</div>\n";
|
html += "</div>\n";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user