mirror of
https://github.com/ansible/awx.git
synced 2026-03-23 03:45:01 -02:30
Permissions CRUD now functional within Users tab.
This commit is contained in:
@@ -46,6 +46,7 @@ angular.module('ansible', [
|
|||||||
'ProjectsListDefinition',
|
'ProjectsListDefinition',
|
||||||
'ProjectFormDefinition',
|
'ProjectFormDefinition',
|
||||||
'PermissionFormDefinition',
|
'PermissionFormDefinition',
|
||||||
|
'PermissionListDefinition',
|
||||||
'JobsListDefinition',
|
'JobsListDefinition',
|
||||||
'JobFormDefinition',
|
'JobFormDefinition',
|
||||||
'JobEventsListDefinition',
|
'JobEventsListDefinition',
|
||||||
@@ -178,6 +179,12 @@ angular.module('ansible', [
|
|||||||
when('/users/:user_id/permissions/add', { templateUrl: urlPrefix + 'partials/users.html',
|
when('/users/:user_id/permissions/add', { templateUrl: urlPrefix + 'partials/users.html',
|
||||||
controller: PermissionsAdd }).
|
controller: PermissionsAdd }).
|
||||||
|
|
||||||
|
when('/users/:user_id/permissions', { templateUrl: urlPrefix + 'partials/users.html',
|
||||||
|
controller: PermissionsList }).
|
||||||
|
|
||||||
|
when('/users/:user_id/permissions/:permission_id', { templateUrl: urlPrefix + 'partials/users.html',
|
||||||
|
controller: PermissionsEdit }).
|
||||||
|
|
||||||
when('/users/:user_id/credentials/add', { templateUrl: urlPrefix + 'partials/teams.html',
|
when('/users/:user_id/credentials/add', { templateUrl: urlPrefix + 'partials/teams.html',
|
||||||
controller: CredentialsAdd }).
|
controller: CredentialsAdd }).
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ function CredentialsList ($scope, $rootScope, $location, $log, $routeParams, Res
|
|||||||
var view = GenerateList;
|
var view = GenerateList;
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
var base = $location.path().replace(/^\//,'').split('/')[0];
|
||||||
var mode = (base == 'credentials') ? 'edit' : 'select'; // if base path 'credentials', we're here to add/edit
|
var mode = (base == 'credentials') ? 'edit' : 'select'; // if base path 'credentials', we're here to add/edit
|
||||||
var scope = view.inject(CredentialList, { mode: mode }); // Inject our view
|
var scope = view.inject(list, { mode: mode }); // Inject our view
|
||||||
scope.selected = [];
|
scope.selected = [];
|
||||||
|
|
||||||
if (scope.PostRefreshRemove) {
|
if (scope.PostRefreshRemove) {
|
||||||
|
|||||||
@@ -1,3 +1,64 @@
|
|||||||
|
|
||||||
|
function PermissionsList ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, PermissionList,
|
||||||
|
GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller,
|
||||||
|
ClearScope, ProcessErrors, GetBasePath)
|
||||||
|
{
|
||||||
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
|
//scope.
|
||||||
|
var list = PermissionList;
|
||||||
|
var base = $location.path().replace(/^\//,'').split('/')[0];
|
||||||
|
var defaultUrl = GetBasePath(base);
|
||||||
|
defaultUrl += ($routeParams['user_id'] !== undefined) ? $routeParams['user_id'] : $routeParams['team_id'];
|
||||||
|
defaultUrl += '/permissions/';
|
||||||
|
|
||||||
|
var view = GenerateList;
|
||||||
|
var scope = view.inject(list, { mode: 'edit' }); // Inject our view
|
||||||
|
scope.selected = [];
|
||||||
|
|
||||||
|
SearchInit({ scope: scope, set: 'permissions', list: list, url: defaultUrl });
|
||||||
|
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
||||||
|
scope.search(list.iterator);
|
||||||
|
|
||||||
|
LoadBreadCrumbs();
|
||||||
|
|
||||||
|
scope.addPermission = function() {
|
||||||
|
$location.path($location.path() + '/add');
|
||||||
|
}
|
||||||
|
|
||||||
|
scope.editPermission = function(id) {
|
||||||
|
$location.path($location.path() + '/' + id);
|
||||||
|
}
|
||||||
|
|
||||||
|
scope.deletePermission = function(id, name) {
|
||||||
|
|
||||||
|
var action = function() {
|
||||||
|
var url = GetBasePath('base') + 'permissions/' + id + '/';
|
||||||
|
Rest.setUrl(url);
|
||||||
|
Rest.destroy()
|
||||||
|
.success( function(data, status, headers, config) {
|
||||||
|
$('#prompt-modal').modal('hide');
|
||||||
|
scope.search(list.iterator);
|
||||||
|
})
|
||||||
|
.error( function(data, status, headers, config) {
|
||||||
|
$('#prompt-modal').modal('hide');
|
||||||
|
ProcessErrors(scope, data, status, null,
|
||||||
|
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Prompt({ hdr: 'Delete',
|
||||||
|
body: 'Are you sure you want to delete ' + name + '?',
|
||||||
|
action: action
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PermissionsList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'PermissionList',
|
||||||
|
'GenerateList', 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller',
|
||||||
|
'ClearScope', 'ProcessErrors', 'GetBasePath'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
function PermissionsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, PermissionsForm,
|
function PermissionsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, PermissionsForm,
|
||||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope,
|
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope,
|
||||||
GetBasePath, ReturnToCaller, InventoryList, ProjectList, LookUpInit)
|
GetBasePath, ReturnToCaller, InventoryList, ProjectList, LookUpInit)
|
||||||
@@ -8,7 +69,7 @@ function PermissionsAdd ($scope, $rootScope, $compile, $location, $log, $routePa
|
|||||||
// Inject dynamic view
|
// Inject dynamic view
|
||||||
var form = PermissionsForm;
|
var form = PermissionsForm;
|
||||||
var generator = GenerateForm;
|
var generator = GenerateForm;
|
||||||
var id = $routeParams.user_id;
|
var id = ($routeParams.user_id !== undefined) ? $routeParams.user_id : $routeParams.team_id;
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
var base = $location.path().replace(/^\//,'').split('/')[0];
|
||||||
var defaultUrl = GetBasePath(base) + id + '/permissions';
|
var defaultUrl = GetBasePath(base) + id + '/permissions';
|
||||||
var scope = generator.inject(form, {mode: 'add', related: false});
|
var scope = generator.inject(form, {mode: 'add', related: false});
|
||||||
@@ -17,8 +78,8 @@ function PermissionsAdd ($scope, $rootScope, $compile, $location, $log, $routePa
|
|||||||
generator.reset();
|
generator.reset();
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
|
|
||||||
scope.category = 'i';
|
scope.category = 'Inventory';
|
||||||
master.category = 'i';
|
master.category = 'Inventory';
|
||||||
|
|
||||||
LookUpInit({
|
LookUpInit({
|
||||||
scope: scope,
|
scope: scope,
|
||||||
@@ -49,7 +110,7 @@ function PermissionsAdd ($scope, $rootScope, $compile, $location, $log, $routePa
|
|||||||
ReturnToCaller(1);
|
ReturnToCaller(1);
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error( function(data, status, headers, config) {
|
||||||
ProcessErrors(scope, data, status, ProjectsForm,
|
ProcessErrors(scope, data, status, PermissionsForm,
|
||||||
{ hdr: 'Error!', msg: 'Failed to create new permission. Post returned status: ' + status });
|
{ hdr: 'Error!', msg: 'Failed to create new permission. Post returned status: ' + status });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -64,9 +125,110 @@ function PermissionsAdd ($scope, $rootScope, $compile, $location, $log, $routePa
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectsAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'PermissionForm',
|
PermissionsAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'PermissionsForm',
|
||||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath',
|
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath',
|
||||||
'ReturnToCaller', 'InventoryList', 'ProjectList', 'LookUpInit'
|
'ReturnToCaller', 'InventoryList', 'ProjectList', 'LookUpInit'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
function PermissionsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams, PermissionsForm,
|
||||||
|
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller,
|
||||||
|
ClearScope, Prompt, GetBasePath, InventoryList, ProjectList, LookUpInit)
|
||||||
|
{
|
||||||
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
|
//scope.
|
||||||
|
|
||||||
|
var generator = GenerateForm;
|
||||||
|
var form = PermissionsForm;
|
||||||
|
var scope = generator.inject(form, {mode: 'edit', related: true});
|
||||||
|
var base_id = ($routeParams.user_id !== undefined) ? $routeParams.user_id : $routeParams.team_id;
|
||||||
|
var base = $location.path().replace(/^\//,'').split('/')[0];
|
||||||
|
var id = $routeParams.permission_id;
|
||||||
|
var defaultUrl = GetBasePath('base') + 'permissions/' + id + '/';
|
||||||
|
generator.reset();
|
||||||
|
|
||||||
|
var master = {};
|
||||||
|
var relatedSets = {};
|
||||||
|
|
||||||
|
|
||||||
|
// Retrieve detail record and prepopulate the form
|
||||||
|
Rest.setUrl(defaultUrl);
|
||||||
|
Rest.get()
|
||||||
|
.success( function(data, status, headers, config) {
|
||||||
|
|
||||||
|
LoadBreadCrumbs({ path: '/users/' + base_id + '/permissions/' + id, title: data.name });
|
||||||
|
|
||||||
|
for (var fld in form.fields) {
|
||||||
|
if (data[fld]) {
|
||||||
|
if (form.fields[fld].sourceModel) {
|
||||||
|
var sourceModel = form.fields[fld].sourceModel;
|
||||||
|
var sourceField = form.fields[fld].sourceField;
|
||||||
|
scope[sourceModel + '_' + sourceField] = data.summary_fields[sourceModel][sourceField];
|
||||||
|
master[sourceModel + '_' + sourceField] = data.summary_fields[sourceModel][sourceField];
|
||||||
|
}
|
||||||
|
scope[fld] = data[fld];
|
||||||
|
master[fld] = scope[fld];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
scope.category = 'Deploy';
|
||||||
|
if (data['permission_type'] != 'run' && data['permission_type'] != 'check' ) {
|
||||||
|
scope.category = 'Inventory';
|
||||||
|
}
|
||||||
|
master['category'] = scope.category;
|
||||||
|
|
||||||
|
LookUpInit({
|
||||||
|
scope: scope,
|
||||||
|
form: form,
|
||||||
|
current_item: data.inventory,
|
||||||
|
list: InventoryList,
|
||||||
|
field: 'inventory'
|
||||||
|
});
|
||||||
|
|
||||||
|
LookUpInit({
|
||||||
|
scope: scope,
|
||||||
|
form: form,
|
||||||
|
current_item: data.project,
|
||||||
|
list: ProjectList,
|
||||||
|
field: 'project'
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.error( function(data, status, headers, config) {
|
||||||
|
ProcessErrors(scope, data, status, form,
|
||||||
|
{ hdr: 'Error!', msg: 'Failed to retrieve Permission: ' + id + '. GET status: ' + status });
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Save changes to the parent
|
||||||
|
scope.formSave = function() {
|
||||||
|
var data = {}
|
||||||
|
for (var fld in form.fields) {
|
||||||
|
data[fld] = scope[fld];
|
||||||
|
}
|
||||||
|
Rest.setUrl(defaultUrl);
|
||||||
|
Rest.put(data)
|
||||||
|
.success( function(data, status, headers, config) {
|
||||||
|
ReturnToCaller(1);
|
||||||
|
})
|
||||||
|
.error( function(data, status, headers, config) {
|
||||||
|
ProcessErrors(scope, data, status, form,
|
||||||
|
{ hdr: 'Error!', msg: 'Failed to update Permission: ' + $routeParams.id + '. PUT status: ' + status });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Cancel
|
||||||
|
scope.formReset = function() {
|
||||||
|
generator.reset();
|
||||||
|
for (var fld in master) {
|
||||||
|
scope[fld] = master[fld];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
PermissionsEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'PermissionsForm',
|
||||||
|
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller',
|
||||||
|
'ClearScope', 'Prompt', 'GetBasePath', 'InventoryList', 'ProjectList', 'LookUpInit'
|
||||||
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ UsersAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$
|
|||||||
|
|
||||||
function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams, UserForm,
|
function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams, UserForm,
|
||||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit,
|
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit,
|
||||||
RelatedPaginateInit, ReturnToCaller, ClearScope, GetBasePath)
|
RelatedPaginateInit, ReturnToCaller, ClearScope, GetBasePath, Prompt)
|
||||||
{
|
{
|
||||||
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.
|
||||||
@@ -330,7 +330,12 @@ function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
// Related set: Edit button
|
// Related set: Edit button
|
||||||
scope.edit = function(set, id, name) {
|
scope.edit = function(set, id, name) {
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
$location.path('/' + set + '/' + id);
|
if (set == 'permissions') {
|
||||||
|
$location.path('/users/' + $routeParams.user_id + '/permissions/' + id);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$location.path('/' + set + '/' + id);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Related set: Delete button
|
// Related set: Delete button
|
||||||
@@ -338,22 +343,39 @@ function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
|
|
||||||
var action = function() {
|
var action = function() {
|
||||||
var url = defaultUrl + $routeParams.user_id + '/' + set + '/';
|
var url;
|
||||||
Rest.setUrl(url);
|
if (set == 'permissions') {
|
||||||
Rest.post({ id: itm_id, disassociate: 1 })
|
url = GetBasePath('base') + 'permissions/' + itm_id + '/';
|
||||||
.success( function(data, status, headers, config) {
|
Rest.setUrl(url);
|
||||||
$('#prompt-modal').modal('hide');
|
Rest.destroy()
|
||||||
scope.search(form.related[set].iterator);
|
.success( function(data, status, headers, config) {
|
||||||
})
|
$('#prompt-modal').modal('hide');
|
||||||
.error( function(data, status, headers, config) {
|
scope.search(form.related[set].iterator);
|
||||||
$('#prompt-modal').modal('hide');
|
})
|
||||||
ProcessErrors(scope, data, status, null,
|
.error( function(data, status, headers, config) {
|
||||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. POST returned status: ' + status });
|
$('#prompt-modal').modal('hide');
|
||||||
});
|
ProcessErrors(scope, data, status, null,
|
||||||
};
|
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
url = defaultUrl + $routeParams.user_id + '/' + set + '/';
|
||||||
|
Rest.setUrl(url);
|
||||||
|
Rest.post({ id: itm_id, disassociate: 1 })
|
||||||
|
.success( function(data, status, headers, config) {
|
||||||
|
$('#prompt-modal').modal('hide');
|
||||||
|
scope.search(form.related[set].iterator);
|
||||||
|
})
|
||||||
|
.error( function(data, status, headers, config) {
|
||||||
|
$('#prompt-modal').modal('hide');
|
||||||
|
ProcessErrors(scope, data, status, null,
|
||||||
|
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. POST returned status: ' + status });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Prompt({ hdr: 'Delete',
|
Prompt({ hdr: 'Delete',
|
||||||
body: 'Are you sure you want to remove ' + name + ' from ' + scope.name + ' ' + title + '?',
|
body: 'Are you sure you want to remove ' + name + ' from ' + scope.username + ' ' + title + '?',
|
||||||
action: action
|
action: action
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -362,5 +384,5 @@ function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
|
|
||||||
UsersEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'UserForm',
|
UsersEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'UserForm',
|
||||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit',
|
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit',
|
||||||
'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope', 'GetBasePath'];
|
'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope', 'GetBasePath', 'Prompt'];
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ angular.module('PermissionFormDefinition', [])
|
|||||||
category: {
|
category: {
|
||||||
label: 'Permission Type',
|
label: 'Permission Type',
|
||||||
type: 'radio',
|
type: 'radio',
|
||||||
options: [{ label: 'Inventory', value: 'i' }, { label: 'Deployment', value: 'd'}],
|
options: [{ label: 'Inventory', value: 'Inventory' }, { label: 'Deployment', value: 'Deploy'}],
|
||||||
ngChange: 'selectCategory()'
|
ngChange: 'selectCategory()'
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
@@ -49,8 +49,10 @@ angular.module('PermissionFormDefinition', [])
|
|||||||
type: 'lookup',
|
type: 'lookup',
|
||||||
sourceModel: 'project',
|
sourceModel: 'project',
|
||||||
sourceField: 'name',
|
sourceField: 'name',
|
||||||
ngShow: "category == 'd'",
|
ngShow: "category == 'Deploy'",
|
||||||
ngClick: 'lookUpProject()',
|
ngClick: 'lookUpProject()',
|
||||||
|
addRequired: false,
|
||||||
|
editRequired: false
|
||||||
},
|
},
|
||||||
inventory: {
|
inventory: {
|
||||||
label: 'Inventory',
|
label: 'Inventory',
|
||||||
@@ -58,26 +60,30 @@ angular.module('PermissionFormDefinition', [])
|
|||||||
sourceModel: 'inventory',
|
sourceModel: 'inventory',
|
||||||
sourceField: 'name',
|
sourceField: 'name',
|
||||||
ngClick: 'lookUpInventory()',
|
ngClick: 'lookUpInventory()',
|
||||||
|
addRequired: false,
|
||||||
|
editRequired: false
|
||||||
},
|
},
|
||||||
inventory_permission_type: {
|
permission_type: {
|
||||||
label: 'Permission',
|
label: 'Permission',
|
||||||
type: 'radio',
|
type: 'radio',
|
||||||
ngShow: "category == 'i'",
|
|
||||||
options: [
|
options: [
|
||||||
{label: 'Admin', value: 'PERM_INVENTORY_ADMIN'},
|
{label: 'Admin', value: 'admin', ngShow: "category == 'Inventory'" },
|
||||||
{label: 'Read', value: 'PERM_INVENTORY_READ'},
|
{label: 'Read', value: 'read', ngShow: "category == 'Inventory'" },
|
||||||
{label: 'Write', value: 'PERM_INVENTORY_WRITE'}
|
{label: 'Write', value: 'write', ngShow: "category == 'Inventory'" },
|
||||||
|
{label: 'Run', value: 'run', ngShow: "category == 'Deploy'" },
|
||||||
|
{label: 'Check', value: 'check', ngShow: "category == 'Deploy'" }
|
||||||
]
|
]
|
||||||
},
|
}
|
||||||
|
/* ,
|
||||||
deployment_permission_type: {
|
deployment_permission_type: {
|
||||||
label: 'Permission',
|
label: 'Permission',
|
||||||
type: 'radio',
|
type: 'radio',
|
||||||
ngShow: "category == 'd'",
|
ngShow: "category == 'Deploy'",
|
||||||
options: [
|
options: [
|
||||||
{label: 'Deploy', value: 'PERM_INVENTORY_DEPLOY'},
|
{label: 'Deploy', value: 'PERM_INVENTORY_DEPLOY'},
|
||||||
{label: 'Check', value: 'PERM_INVENTORY_CHECK'}
|
{label: 'Check', value: 'PERM_INVENTORY_CHECK'}
|
||||||
]
|
]
|
||||||
}
|
}*/
|
||||||
},
|
},
|
||||||
|
|
||||||
buttons: { //for now always generates <button> tags
|
buttons: { //for now always generates <button> tags
|
||||||
|
|||||||
@@ -156,13 +156,20 @@ angular.module('UserFormDefinition', [])
|
|||||||
fields: {
|
fields: {
|
||||||
name: {
|
name: {
|
||||||
key: true,
|
key: true,
|
||||||
label: 'Name'
|
label: 'Name',
|
||||||
|
ngClick: "edit('permissions', \{\{ permission.id \}\}, '\{\{ permission.name \}\}')"
|
||||||
},
|
},
|
||||||
project: {
|
project: {
|
||||||
label: 'Project'
|
label: 'Project',
|
||||||
|
sourceModel: 'project',
|
||||||
|
sourceField: 'name',
|
||||||
|
ngBind: 'permission.summary_fields.project.name',
|
||||||
},
|
},
|
||||||
inventory: {
|
inventory: {
|
||||||
label: 'Inventory'
|
label: 'Inventory',
|
||||||
|
sourceModel: 'inventory',
|
||||||
|
sourceField: 'name',
|
||||||
|
ngBind: 'permission.summary_fields.inventory.name',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
72
awx/ui/static/js/lists/Permissions.js
Normal file
72
awx/ui/static/js/lists/Permissions.js
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
/*********************************************
|
||||||
|
* Copyright (c) 2013 AnsibleWorks, Inc.
|
||||||
|
*
|
||||||
|
* Permissions.js
|
||||||
|
* List view object for Permissions data model.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
angular.module('PermissionListDefinition', [])
|
||||||
|
.value(
|
||||||
|
'PermissionList', {
|
||||||
|
|
||||||
|
name: 'permissions',
|
||||||
|
iterator: 'permission',
|
||||||
|
selectTitle: 'Add Permission',
|
||||||
|
selectInstructions: 'Click on a row to select it, and click Finished when done. Use the green <i class=\"icon-plus\"></i> button to create a new row.',
|
||||||
|
editTitle: 'Permissions',
|
||||||
|
index: true,
|
||||||
|
well: true,
|
||||||
|
|
||||||
|
fields: {
|
||||||
|
name: {
|
||||||
|
key: true,
|
||||||
|
label: 'Name',
|
||||||
|
ngClick: 'editPermission(\{\{ permission.id \}\})'
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
label: 'Description'
|
||||||
|
},
|
||||||
|
project: {
|
||||||
|
label: 'Project',
|
||||||
|
sourceModel: 'project',
|
||||||
|
sourceField: 'name',
|
||||||
|
ngBind: 'permission.summary_fields.project.name'
|
||||||
|
},
|
||||||
|
inventory: {
|
||||||
|
label: 'Inventory',
|
||||||
|
sourceModel: 'inventory',
|
||||||
|
sourceField: 'name',
|
||||||
|
ngBind: 'permission.summary_fields.inventory.name'
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
actions: {
|
||||||
|
add: {
|
||||||
|
icon: 'icon-plus',
|
||||||
|
label: 'Add',
|
||||||
|
mode: 'all', // One of: edit, select, all
|
||||||
|
ngClick: 'createPermission()',
|
||||||
|
"class": 'btn-success btn-small',
|
||||||
|
awToolTip: 'Add a new permission'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
fieldActions: {
|
||||||
|
edit: {
|
||||||
|
label: 'Edit',
|
||||||
|
ngClick: "editPermission(\{\{ permission.id \}\})",
|
||||||
|
icon: 'icon-edit',
|
||||||
|
"class": 'btn-small btn-success',
|
||||||
|
awToolTip: 'View/Edit permission'
|
||||||
|
},
|
||||||
|
|
||||||
|
"delete": {
|
||||||
|
label: 'Delete',
|
||||||
|
ngClick: "deletePermission(\{\{ permission.id \}\},'\{\{ permission.name \}\}')",
|
||||||
|
icon: 'icon-remove',
|
||||||
|
"class": 'btn-small btn-danger',
|
||||||
|
awToolTip: 'Delete permission'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -82,7 +82,10 @@ angular.module('FormGenerator', ['GeneratorHelpers'])
|
|||||||
for (var fld in this.form.fields) {
|
for (var fld in this.form.fields) {
|
||||||
this.scope[fld] = '';
|
this.scope[fld] = '';
|
||||||
this.scope[fld + '_api_error'] = '';
|
this.scope[fld + '_api_error'] = '';
|
||||||
this.scope[this.form.fields[fld].sourceModel + '_' + this.form.fields[fld].sourceField] = '';
|
if (this.form.fields[fld].sourceModel) {
|
||||||
|
this.scope[this.form.fields[fld].sourceModel + '_' + this.form.fields[fld].sourceField] = '';
|
||||||
|
this.scope[this.form.fields[fld].sourceModel + '_' + this.form.fields[fld].sourceField + '_api_error'] = '';
|
||||||
|
}
|
||||||
if ( this.form.fields[fld].type == 'lookup' &&
|
if ( this.form.fields[fld].type == 'lookup' &&
|
||||||
this.scope[this.form.name + '_form'][this.form.fields[fld].sourceModel + '_' + this.form.fields[fld].sourceField] ) {
|
this.scope[this.form.name + '_form'][this.form.fields[fld].sourceModel + '_' + this.form.fields[fld].sourceField] ) {
|
||||||
this.scope[this.form.name + '_form'][this.form.fields[fld].sourceModel + '_' + this.form.fields[fld].sourceField].$setPristine();
|
this.scope[this.form.name + '_form'][this.form.fields[fld].sourceModel + '_' + this.form.fields[fld].sourceField].$setPristine();
|
||||||
@@ -384,17 +387,19 @@ angular.module('FormGenerator', ['GeneratorHelpers'])
|
|||||||
html += field.label + '</label>' + "\n";
|
html += field.label + '</label>' + "\n";
|
||||||
html += "<div class=\"controls\">\n";
|
html += "<div class=\"controls\">\n";
|
||||||
for (var i=0; i < field.options.length; i++) {
|
for (var i=0; i < field.options.length; i++) {
|
||||||
html += "<label class=\"radio inline\">";
|
html += "<label class=\"radio inline\" ";
|
||||||
|
html += (field.options[i].ngShow) ? this.attr(field.options[i],'ngShow') : "";
|
||||||
|
html += ">";
|
||||||
html += "<input type=\"radio\" ";
|
html += "<input type=\"radio\" ";
|
||||||
html += "name=\"" + fld + "\" ";
|
html += "name=\"" + fld + "\" ";
|
||||||
|
html += "value=\"" + field.options[i].value + "\" ";
|
||||||
html += "ng-model=\"" + fld + "\" ";
|
html += "ng-model=\"" + fld + "\" ";
|
||||||
html += (field.ngChange) ? this.attr(field,'ngChange') : "";
|
html += (field.ngChange) ? this.attr(field,'ngChange') : "";
|
||||||
html += "value=\"" + field.options[i].value + "\" ";
|
|
||||||
html += (field.readonly) ? "readonly " : "";
|
html += (field.readonly) ? "readonly " : "";
|
||||||
html += " /> " + field.options[i].label + "\n";
|
html += " /> " + field.options[i].label + "\n";
|
||||||
html += "</label>\n";
|
html += "</label>\n";
|
||||||
}
|
}
|
||||||
html += "<span class=\"error api-error\" ng-bind=\"" + fld + "_api_error\"></span>\n";
|
html += "<p><span class=\"error api-error\" ng-bind=\"" + fld + "_api_error\"></span></p>\n";
|
||||||
html += "</div>\n";
|
html += "</div>\n";
|
||||||
html += "</div>\n";
|
html += "</div>\n";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,13 @@ angular.module('Utilities',[])
|
|||||||
fieldErrors = true;
|
fieldErrors = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (form.fields[field].sourceModel) {
|
||||||
|
if (data[field]) {
|
||||||
|
scope[form.fields[field].sourceModel + '_' + form.fields[field].sourceField + '_api_error'] =
|
||||||
|
data[field][0];
|
||||||
|
fieldErrors = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
if (data[field]) {
|
if (data[field]) {
|
||||||
scope[field + '_api_error'] = data[field][0];
|
scope[field + '_api_error'] = data[field][0];
|
||||||
|
|||||||
@@ -63,6 +63,7 @@
|
|||||||
<script src="{{ STATIC_URL }}js/lists/Jobs.js"></script>
|
<script src="{{ STATIC_URL }}js/lists/Jobs.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/lists/JobEvents.js"></script>
|
<script src="{{ STATIC_URL }}js/lists/JobEvents.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/lists/JobHosts.js"></script>
|
<script src="{{ STATIC_URL }}js/lists/JobHosts.js"></script>
|
||||||
|
<script src="{{ STATIC_URL }}js/lists/Permissions.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/helpers/refresh-related.js"></script>
|
<script src="{{ STATIC_URL }}js/helpers/refresh-related.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/helpers/related-paginate.js"></script>
|
<script src="{{ STATIC_URL }}js/helpers/related-paginate.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/helpers/related-search.js"></script>
|
<script src="{{ STATIC_URL }}js/helpers/related-search.js"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user