mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 23:07:42 -02:30
fix to credentials ui based on api change
This commit is contained in:
@@ -178,7 +178,7 @@ export function CredentialsAdd($scope, $rootScope, $compile, $location, $log,
|
|||||||
if ($rootScope.current_user.is_superuser) {
|
if ($rootScope.current_user.is_superuser) {
|
||||||
$scope.canShareCredential = true;
|
$scope.canShareCredential = true;
|
||||||
} else {
|
} else {
|
||||||
Rest.setUrl(`/api/v1/users/${$rootScope.current_user.id}/admin_of_organizations`)
|
Rest.setUrl(`/api/v1/users/${$rootScope.current_user.id}/admin_of_organizations`);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success(function(data) {
|
.success(function(data) {
|
||||||
$scope.canShareCredential = (data.count) ? true : false;
|
$scope.canShareCredential = (data.count) ? true : false;
|
||||||
@@ -190,7 +190,7 @@ export function CredentialsAdd($scope, $rootScope, $compile, $location, $log,
|
|||||||
GetBasePath("organizations") :
|
GetBasePath("organizations") :
|
||||||
$rootScope.current_user.url + "admin_of_organizations?";
|
$rootScope.current_user.url + "admin_of_organizations?";
|
||||||
|
|
||||||
// TODO: create LookUpInit for organizations
|
// Create LookUpInit for organizations
|
||||||
LookUpInit({
|
LookUpInit({
|
||||||
scope: $scope,
|
scope: $scope,
|
||||||
url: orgUrl,
|
url: orgUrl,
|
||||||
@@ -201,26 +201,6 @@ export function CredentialsAdd($scope, $rootScope, $compile, $location, $log,
|
|||||||
autopopulateLookup: false
|
autopopulateLookup: false
|
||||||
});
|
});
|
||||||
|
|
||||||
// LookUpInit({
|
|
||||||
// scope: $scope,
|
|
||||||
// form: form,
|
|
||||||
// current_item: (!Empty($stateParams.user_id)) ? $stateParams.user_id : null,
|
|
||||||
// list: UserList,
|
|
||||||
// field: 'user',
|
|
||||||
// input_type: 'radio',
|
|
||||||
// autopopulateLookup: false
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// LookUpInit({
|
|
||||||
// scope: $scope,
|
|
||||||
// form: form,
|
|
||||||
// current_item: (!Empty($stateParams.team_id)) ? $stateParams.team_id : null,
|
|
||||||
// list: TeamList,
|
|
||||||
// field: 'team',
|
|
||||||
// input_type: 'radio',
|
|
||||||
// autopopulateLookup: false
|
|
||||||
// });
|
|
||||||
|
|
||||||
if (!Empty($stateParams.user_id)) {
|
if (!Empty($stateParams.user_id)) {
|
||||||
// Get the username based on incoming route
|
// Get the username based on incoming route
|
||||||
$scope.owner = 'user';
|
$scope.owner = 'user';
|
||||||
@@ -279,11 +259,6 @@ export function CredentialsAdd($scope, $rootScope, $compile, $location, $log,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle Owner change
|
|
||||||
$scope.shareableChange = function () {
|
|
||||||
console.log("TODO: implement shareable change");
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.formCancel = function () {
|
$scope.formCancel = function () {
|
||||||
$state.transitionTo('credentials');
|
$state.transitionTo('credentials');
|
||||||
};
|
};
|
||||||
@@ -342,7 +317,7 @@ CredentialsAdd.$inject = ['$scope', '$rootScope', '$compile', '$location',
|
|||||||
export function CredentialsEdit($scope, $rootScope, $compile, $location, $log,
|
export function CredentialsEdit($scope, $rootScope, $compile, $location, $log,
|
||||||
$stateParams, CredentialForm, GenerateForm, Rest, Alert, ProcessErrors,
|
$stateParams, CredentialForm, GenerateForm, Rest, Alert, ProcessErrors,
|
||||||
RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, Prompt,
|
RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, Prompt,
|
||||||
GetBasePath, GetChoices, KindChange, UserList, TeamList, LookUpInit, Empty,
|
GetBasePath, GetChoices, KindChange, OrganizationList, LookUpInit, Empty,
|
||||||
OwnerChange, FormSave, Wait, $state, CreateSelect2) {
|
OwnerChange, FormSave, Wait, $state, CreateSelect2) {
|
||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
@@ -358,6 +333,18 @@ export function CredentialsEdit($scope, $rootScope, $compile, $location, $log,
|
|||||||
generator.reset();
|
generator.reset();
|
||||||
$scope.id = id;
|
$scope.id = id;
|
||||||
|
|
||||||
|
$scope.canShareCredential = false;
|
||||||
|
|
||||||
|
if ($rootScope.current_user.is_superuser) {
|
||||||
|
$scope.canShareCredential = true;
|
||||||
|
} else {
|
||||||
|
Rest.setUrl(`/api/v1/users/${$rootScope.current_user.id}/admin_of_organizations`);
|
||||||
|
Rest.get()
|
||||||
|
.success(function(data) {
|
||||||
|
$scope.canShareCredential = (data.count) ? true : false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function setAskCheckboxes() {
|
function setAskCheckboxes() {
|
||||||
var fld, i;
|
var fld, i;
|
||||||
for (fld in form.fields) {
|
for (fld in form.fields) {
|
||||||
@@ -387,22 +374,20 @@ export function CredentialsEdit($scope, $rootScope, $compile, $location, $log,
|
|||||||
$scope.removeCredentialLoaded();
|
$scope.removeCredentialLoaded();
|
||||||
}
|
}
|
||||||
$scope.removeCredentialLoaded = $scope.$on('credentialLoaded', function () {
|
$scope.removeCredentialLoaded = $scope.$on('credentialLoaded', function () {
|
||||||
LookUpInit({
|
var orgUrl = ($rootScope.current_user.is_superuser) ?
|
||||||
scope: $scope,
|
GetBasePath("organizations") :
|
||||||
form: form,
|
$rootScope.current_user.url + "admin_of_organizations?";
|
||||||
current_item: (!Empty($scope.user_id)) ? $scope.user_id : null,
|
|
||||||
list: UserList,
|
|
||||||
field: 'user',
|
|
||||||
input_type: 'radio'
|
|
||||||
});
|
|
||||||
|
|
||||||
|
// create LookUpInit for organizations
|
||||||
LookUpInit({
|
LookUpInit({
|
||||||
scope: $scope,
|
scope: $scope,
|
||||||
|
url: orgUrl,
|
||||||
form: form,
|
form: form,
|
||||||
current_item: (!Empty($scope.team_id)) ? $scope.team_id : null,
|
current_item: $scope.organization,
|
||||||
list: TeamList,
|
list: OrganizationList,
|
||||||
|
field: 'organization',
|
||||||
input_type: 'radio',
|
input_type: 'radio',
|
||||||
field: 'team'
|
autopopulateLookup: false
|
||||||
});
|
});
|
||||||
|
|
||||||
setAskCheckboxes();
|
setAskCheckboxes();
|
||||||
@@ -658,6 +643,6 @@ CredentialsEdit.$inject = ['$scope', '$rootScope', '$compile', '$location',
|
|||||||
'$log', '$stateParams', 'CredentialForm', 'GenerateForm', 'Rest', 'Alert',
|
'$log', '$stateParams', 'CredentialForm', 'GenerateForm', 'Rest', 'Alert',
|
||||||
'ProcessErrors', 'RelatedSearchInit', 'RelatedPaginateInit',
|
'ProcessErrors', 'RelatedSearchInit', 'RelatedPaginateInit',
|
||||||
'ReturnToCaller', 'ClearScope', 'Prompt', 'GetBasePath', 'GetChoices',
|
'ReturnToCaller', 'ClearScope', 'Prompt', 'GetBasePath', 'GetChoices',
|
||||||
'KindChange', 'UserList', 'TeamList', 'LookUpInit', 'Empty', 'OwnerChange',
|
'KindChange', 'OrganizationList', 'LookUpInit', 'Empty', 'OwnerChange',
|
||||||
'FormSave', 'Wait', '$state', 'CreateSelect2'
|
'FormSave', 'Wait', '$state', 'CreateSelect2'
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user