mirror of
https://github.com/ansible/awx.git
synced 2026-03-10 05:59:28 -02:30
AC-234 create organizaions via Projects Tab
This commit is contained in:
@@ -10,9 +10,9 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function OrganizationsList ($scope, $rootScope, $location, $log, Rest, Alert, LoadBreadCrumbs, Prompt,
|
function OrganizationsList ($routeParams, $scope, $rootScope, $location, $log, Rest, Alert, LoadBreadCrumbs, Prompt,
|
||||||
GenerateList, OrganizationList, SearchInit, PaginateInit, ClearScope, ProcessErrors,
|
GenerateList, OrganizationList, SearchInit, PaginateInit, ClearScope, ProcessErrors,
|
||||||
GetBasePath)
|
GetBasePath, SelectionInit)
|
||||||
{
|
{
|
||||||
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.
|
||||||
@@ -28,6 +28,8 @@ function OrganizationsList ($scope, $rootScope, $location, $log, Rest, Alert, Lo
|
|||||||
|
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
|
|
||||||
|
SelectionInit({ scope: scope, list: list });
|
||||||
|
|
||||||
// Initialize search and paginate pieces and load data
|
// Initialize search and paginate pieces and load data
|
||||||
SearchInit({ scope: scope, set: list.name, list: list, url: defaultUrl });
|
SearchInit({ scope: scope, set: list.name, list: list, url: defaultUrl });
|
||||||
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
||||||
@@ -65,11 +67,65 @@ function OrganizationsList ($scope, $rootScope, $location, $log, Rest, Alert, Lo
|
|||||||
action: action
|
action: action
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
scope.finishSelection = function() {
|
||||||
|
var url;
|
||||||
|
url = GetBasePath('projects') + $routeParams.project_id + '/organizations/';
|
||||||
|
scope.queue = [];
|
||||||
|
scope.$on('callFinished', function() {
|
||||||
|
// We call the API for each selected row. We need to hang out until all the api
|
||||||
|
// calls are finished.
|
||||||
|
if (scope.queue.length == scope.selected.length) {
|
||||||
|
// All the api calls finished
|
||||||
|
scope.selected = [];
|
||||||
|
var errors = 0;
|
||||||
|
for (var i=0; i < scope.queue.length; i++) {
|
||||||
|
if (scope.queue[i].result == 'error') {
|
||||||
|
errors++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (errors > 0) {
|
||||||
|
Alert('Error', 'There was an error while adding one or more of the selected organizations.');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ReturnToCaller(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (scope.selected.length > 0 ) {
|
||||||
|
var org;
|
||||||
|
for (var i=0; i < scope.selected.length; i++) {
|
||||||
|
org = null;
|
||||||
|
for (var j=0; j < scope.organizations.length; j++) {
|
||||||
|
if (scope.organizations[j].id == scope.selected[i]) {
|
||||||
|
org = scope.organizations[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (org !== null) {
|
||||||
|
Rest.setUrl(url);
|
||||||
|
Rest.post(org)
|
||||||
|
.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 {
|
||||||
|
ReturnToCaller();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OrganizationsList.$inject=[ '$scope', '$rootScope', '$location', '$log', 'Rest', 'Alert', 'LoadBreadCrumbs', 'Prompt',
|
OrganizationsList.$inject=[ '$routeParams', '$scope', '$rootScope', '$location', '$log', 'Rest', 'Alert', 'LoadBreadCrumbs', 'Prompt',
|
||||||
'GenerateList', 'OrganizationList', 'SearchInit', 'PaginateInit', 'ClearScope', 'ProcessErrors',
|
'GenerateList', 'OrganizationList', 'SearchInit', 'PaginateInit', 'ClearScope', 'ProcessErrors',
|
||||||
'GetBasePath' ];
|
'GetBasePath', 'SelectionInit' ];
|
||||||
|
|
||||||
|
|
||||||
function OrganizationsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, OrganizationForm,
|
function OrganizationsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, OrganizationForm,
|
||||||
|
|||||||
Reference in New Issue
Block a user