mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 09:51:09 +03:00
Reimplemented permissions as a module and pull of permissions label text from the api
This commit is contained in:
parent
ddfeaf597d
commit
e1138dc261
@ -30,6 +30,7 @@ import {JobsListController} from './controllers/Jobs';
|
|||||||
import {PortalController} from './controllers/Portal';
|
import {PortalController} from './controllers/Portal';
|
||||||
import systemTracking from './system-tracking/main';
|
import systemTracking from './system-tracking/main';
|
||||||
import inventoryScripts from './inventory-scripts/main';
|
import inventoryScripts from './inventory-scripts/main';
|
||||||
|
import permissions from './permissions/main';
|
||||||
import managementJobs from './management-jobs/main';
|
import managementJobs from './management-jobs/main';
|
||||||
import routeExtensions from './shared/route-extensions/main';
|
import routeExtensions from './shared/route-extensions/main';
|
||||||
import breadcrumbs from './shared/breadcrumbs/main';
|
import breadcrumbs from './shared/breadcrumbs/main';
|
||||||
@ -55,7 +56,6 @@ import {AdhocCtrl} from './controllers/Adhoc';
|
|||||||
import {AdminsList} from './controllers/Admins';
|
import {AdminsList} from './controllers/Admins';
|
||||||
import {UsersList, UsersAdd, UsersEdit} from './controllers/Users';
|
import {UsersList, UsersAdd, UsersEdit} from './controllers/Users';
|
||||||
import {TeamsList, TeamsAdd, TeamsEdit} from './controllers/Teams';
|
import {TeamsList, TeamsAdd, TeamsEdit} from './controllers/Teams';
|
||||||
import {PermissionsAdd, PermissionsList, PermissionsEdit} from './controllers/Permissions';
|
|
||||||
import './shared/RestServices';
|
import './shared/RestServices';
|
||||||
import './shared/api-loader';
|
import './shared/api-loader';
|
||||||
import './shared/form-generator';
|
import './shared/form-generator';
|
||||||
@ -86,6 +86,7 @@ var tower = angular.module('Tower', [
|
|||||||
breadcrumbs.name,
|
breadcrumbs.name,
|
||||||
systemTracking.name,
|
systemTracking.name,
|
||||||
inventoryScripts.name,
|
inventoryScripts.name,
|
||||||
|
permissions.name,
|
||||||
managementJobs.name,
|
managementJobs.name,
|
||||||
setupMenu.name,
|
setupMenu.name,
|
||||||
mainMenu.name,
|
mainMenu.name,
|
||||||
@ -140,9 +141,6 @@ var tower = angular.module('Tower', [
|
|||||||
'ProjectFormDefinition',
|
'ProjectFormDefinition',
|
||||||
'ProjectStatusDefinition',
|
'ProjectStatusDefinition',
|
||||||
'ProjectsHelper',
|
'ProjectsHelper',
|
||||||
'PermissionFormDefinition',
|
|
||||||
'PermissionListDefinition',
|
|
||||||
'PermissionsHelper',
|
|
||||||
'CompletedJobsDefinition',
|
'CompletedJobsDefinition',
|
||||||
'AllJobsDefinition',
|
'AllJobsDefinition',
|
||||||
'JobFormDefinition',
|
'JobFormDefinition',
|
||||||
@ -591,39 +589,6 @@ var tower = angular.module('Tower', [
|
|||||||
}
|
}
|
||||||
}).
|
}).
|
||||||
|
|
||||||
when('/teams/:team_id/permissions/add', {
|
|
||||||
name: 'teamPermissionAdd',
|
|
||||||
templateUrl: urlPrefix + 'partials/teams.html',
|
|
||||||
controller: PermissionsAdd,
|
|
||||||
resolve: {
|
|
||||||
features: ['FeaturesService', function(FeaturesService) {
|
|
||||||
return FeaturesService.get();
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}).
|
|
||||||
|
|
||||||
when('/teams/:team_id/permissions', {
|
|
||||||
name: 'teamPermissions',
|
|
||||||
templateUrl: urlPrefix + 'partials/teams.html',
|
|
||||||
controller: PermissionsList,
|
|
||||||
resolve: {
|
|
||||||
features: ['FeaturesService', function(FeaturesService) {
|
|
||||||
return FeaturesService.get();
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}).
|
|
||||||
|
|
||||||
when('/teams/:team_id/permissions/:permission_id', {
|
|
||||||
name: 'teamPermissionEdit',
|
|
||||||
templateUrl: urlPrefix + 'partials/teams.html',
|
|
||||||
controller: PermissionsEdit,
|
|
||||||
resolve: {
|
|
||||||
features: ['FeaturesService', function(FeaturesService) {
|
|
||||||
return FeaturesService.get();
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}).
|
|
||||||
|
|
||||||
when('/teams/:team_id/users', {
|
when('/teams/:team_id/users', {
|
||||||
name: 'teamUsers',
|
name: 'teamUsers',
|
||||||
templateUrl: urlPrefix + 'partials/teams.html',
|
templateUrl: urlPrefix + 'partials/teams.html',
|
||||||
@ -789,39 +754,6 @@ var tower = angular.module('Tower', [
|
|||||||
}
|
}
|
||||||
}).
|
}).
|
||||||
|
|
||||||
when('/users/:user_id/permissions/add', {
|
|
||||||
name: 'userPermissionAdd',
|
|
||||||
templateUrl: urlPrefix + 'partials/users.html',
|
|
||||||
controller: PermissionsAdd,
|
|
||||||
resolve: {
|
|
||||||
features: ['FeaturesService', function(FeaturesService) {
|
|
||||||
return FeaturesService.get();
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}).
|
|
||||||
|
|
||||||
when('/users/:user_id/permissions', {
|
|
||||||
name: 'userPermissions',
|
|
||||||
templateUrl: urlPrefix + 'partials/users.html',
|
|
||||||
controller: PermissionsList,
|
|
||||||
resolve: {
|
|
||||||
features: ['FeaturesService', function(FeaturesService) {
|
|
||||||
return FeaturesService.get();
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}).
|
|
||||||
|
|
||||||
when('/users/:user_id/permissions/:permission_id', {
|
|
||||||
name: 'userPermissionEdit',
|
|
||||||
templateUrl: urlPrefix + 'partials/users.html',
|
|
||||||
controller: PermissionsEdit,
|
|
||||||
resolve: {
|
|
||||||
features: ['FeaturesService', function(FeaturesService) {
|
|
||||||
return FeaturesService.get();
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}).
|
|
||||||
|
|
||||||
when('/users/:user_id/credentials/add', {
|
when('/users/:user_id/credentials/add', {
|
||||||
name: 'userCredentialAdd',
|
name: 'userCredentialAdd',
|
||||||
templateUrl: urlPrefix + 'partials/teams.html',
|
templateUrl: urlPrefix + 'partials/teams.html',
|
||||||
|
@ -1,409 +0,0 @@
|
|||||||
/*************************************************
|
|
||||||
* Copyright (c) 2015 Ansible, Inc.
|
|
||||||
*
|
|
||||||
* All Rights Reserved
|
|
||||||
*************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ngdoc function
|
|
||||||
* @name controllers.function:Permissions
|
|
||||||
* @description This controller's for permissions
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
export 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, breadCrumbs: true });
|
|
||||||
defaultUrl += ($routeParams.user_id !== undefined) ? $routeParams.user_id : $routeParams.team_id;
|
|
||||||
defaultUrl += '/permissions/';
|
|
||||||
|
|
||||||
$scope.selected = [];
|
|
||||||
|
|
||||||
CheckAccess({
|
|
||||||
scope: $scope
|
|
||||||
});
|
|
||||||
|
|
||||||
if ($scope.removePostRefresh) {
|
|
||||||
$scope.removePostRefresh();
|
|
||||||
}
|
|
||||||
$scope.removePostRefresh = $scope.$on('PostRefresh', function () {
|
|
||||||
// Cleanup after a delete
|
|
||||||
Wait('stop');
|
|
||||||
$('#prompt-modal').modal('hide');
|
|
||||||
});
|
|
||||||
|
|
||||||
SearchInit({
|
|
||||||
scope: $scope,
|
|
||||||
set: 'permissions',
|
|
||||||
list: list,
|
|
||||||
url: defaultUrl
|
|
||||||
});
|
|
||||||
PaginateInit({
|
|
||||||
scope: $scope,
|
|
||||||
list: list,
|
|
||||||
url: defaultUrl
|
|
||||||
});
|
|
||||||
$scope.search(list.iterator);
|
|
||||||
|
|
||||||
LoadBreadCrumbs();
|
|
||||||
|
|
||||||
$scope.addPermission = function () {
|
|
||||||
if ($scope.PermissionAddAllowed) {
|
|
||||||
$location.path($location.path() + '/add');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// if the permission includes adhoc (and is not admin), display that
|
|
||||||
$scope.getPermissionText = function () {
|
|
||||||
if (this.permission.permission_type !== "admin" && this.permission.run_ad_hoc_commands) {
|
|
||||||
return this.permission.permission_type + " + run commands";
|
|
||||||
} else {
|
|
||||||
return this.permission.permission_type;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.editPermission = function (id) {
|
|
||||||
$location.path($location.path() + '/' + id);
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.deletePermission = function (id, name) {
|
|
||||||
var action = function () {
|
|
||||||
$('#prompt-modal').modal('hide');
|
|
||||||
Wait('start');
|
|
||||||
var url = GetBasePath('base') + 'permissions/' + id + '/';
|
|
||||||
Rest.setUrl(url);
|
|
||||||
Rest.destroy()
|
|
||||||
.success(function () {
|
|
||||||
$scope.search(list.iterator);
|
|
||||||
})
|
|
||||||
.error(function (data, status) {
|
|
||||||
Wait('stop');
|
|
||||||
ProcessErrors($scope, data, status, null, { hdr: 'Error!',
|
|
||||||
msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
if ($scope.PermissionAddAllowed) {
|
|
||||||
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', 'CheckAccess', 'Wait'
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
export function PermissionsAdd($scope, $rootScope, $compile, $location, $log, $routeParams, PermissionsForm,
|
|
||||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope,
|
|
||||||
GetBasePath, ReturnToCaller, InventoryList, ProjectList, LookUpInit, CheckAccess,
|
|
||||||
Wait, PermissionCategoryChange) {
|
|
||||||
|
|
||||||
ClearScope();
|
|
||||||
|
|
||||||
// Inject dynamic view
|
|
||||||
var form = PermissionsForm,
|
|
||||||
generator = GenerateForm,
|
|
||||||
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();
|
|
||||||
LoadBreadCrumbs();
|
|
||||||
|
|
||||||
$scope.inventoryrequired = true;
|
|
||||||
$scope.projectrequired = false;
|
|
||||||
$scope.category = 'Inventory';
|
|
||||||
master.category = 'Inventory';
|
|
||||||
master.inventoryrequired = true;
|
|
||||||
master.projectrequired = false;
|
|
||||||
$scope.run_ad_hoc_commands = false;
|
|
||||||
|
|
||||||
LookUpInit({
|
|
||||||
scope: $scope,
|
|
||||||
form: form,
|
|
||||||
current_item: null,
|
|
||||||
list: InventoryList,
|
|
||||||
field: 'inventory',
|
|
||||||
input_type: 'radio'
|
|
||||||
});
|
|
||||||
|
|
||||||
LookUpInit({
|
|
||||||
scope: $scope,
|
|
||||||
form: form,
|
|
||||||
current_item: null,
|
|
||||||
list: ProjectList,
|
|
||||||
field: 'project',
|
|
||||||
input_type: 'radio'
|
|
||||||
});
|
|
||||||
|
|
||||||
$scope.$watch("category", function(val) {
|
|
||||||
if (val === 'Deploy') {
|
|
||||||
$scope.projectrequired = true;
|
|
||||||
LookUpInit({
|
|
||||||
scope: $scope,
|
|
||||||
form: form,
|
|
||||||
current_item: null,
|
|
||||||
list: ProjectList,
|
|
||||||
field: 'project',
|
|
||||||
input_type: 'radio'
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
$scope.projectrequired = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$scope.changeAdhocCommandCheckbox = function () {
|
|
||||||
if ($scope.category === 'Deploy') {
|
|
||||||
$scope.run_ad_hoc_command = false;
|
|
||||||
} else {
|
|
||||||
if ($scope.permission_type === 'admin') {
|
|
||||||
$scope.run_ad_hoc_commands = true;
|
|
||||||
$("#permission_run_ad_hoc_commands_chbox").attr("disabled", true);
|
|
||||||
} else {
|
|
||||||
if (!$scope.run_ad_hoc_commands) {
|
|
||||||
$scope.run_ad_hoc_commands = false;
|
|
||||||
}
|
|
||||||
$("#permission_run_ad_hoc_commands_chbox").attr("disabled", false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Save
|
|
||||||
$scope.formSave = function () {
|
|
||||||
var fld, url, data = {};
|
|
||||||
generator.clearApiErrors();
|
|
||||||
Wait('start');
|
|
||||||
if ($scope.PermissionAddAllowed) {
|
|
||||||
data = {};
|
|
||||||
for (fld in form.fields) {
|
|
||||||
data[fld] = $scope[fld];
|
|
||||||
}
|
|
||||||
// job template (or deploy) based permissions do not have the run
|
|
||||||
// ad hoc commands parameter
|
|
||||||
if (data.category === "Deploy") {
|
|
||||||
data.run_ad_hoc_commands = false;
|
|
||||||
} else {
|
|
||||||
delete data.project;
|
|
||||||
}
|
|
||||||
|
|
||||||
url = (base === 'teams') ? GetBasePath('teams') + id + '/permissions/' : GetBasePath('users') + id + '/permissions/';
|
|
||||||
Rest.setUrl(url);
|
|
||||||
Rest.post(data)
|
|
||||||
.success(function () {
|
|
||||||
Wait('stop');
|
|
||||||
ReturnToCaller(1);
|
|
||||||
})
|
|
||||||
.error(function (data, status) {
|
|
||||||
Wait('stop');
|
|
||||||
ProcessErrors($scope, data, status, PermissionsForm, { hdr: 'Error!',
|
|
||||||
msg: 'Failed to create new permission. Post returned status: ' + status });
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
Alert('Access Denied', 'You do not have access to create new permission objects. Please contact a system administrator.',
|
|
||||||
'alert-danger');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Cancel
|
|
||||||
$scope.formReset = function () {
|
|
||||||
$rootScope.flashMessage = null;
|
|
||||||
generator.reset();
|
|
||||||
for (var fld in master) {
|
|
||||||
$scope[fld] = master[fld];
|
|
||||||
}
|
|
||||||
$scope.selectCategory();
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.selectCategory = function () {
|
|
||||||
PermissionCategoryChange({ scope: $scope, reset: true });
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
$scope.selectCategory();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
PermissionsAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'PermissionsForm',
|
|
||||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath', 'ReturnToCaller',
|
|
||||||
'InventoryList', 'ProjectList', 'LookUpInit', 'CheckAccess', 'Wait', 'PermissionCategoryChange'
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
export 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,
|
|
||||||
form = PermissionsForm,
|
|
||||||
base_id = ($routeParams.user_id !== undefined) ? $routeParams.user_id : $routeParams.team_id,
|
|
||||||
id = $routeParams.permission_id,
|
|
||||||
defaultUrl = GetBasePath('base') + 'permissions/' + id + '/',
|
|
||||||
master = {};
|
|
||||||
|
|
||||||
$scope.changeAdhocCommandCheckbox = function () {
|
|
||||||
if ($scope.category === 'Deploy') {
|
|
||||||
$scope.run_ad_hoc_command = false;
|
|
||||||
} else {
|
|
||||||
if ($scope.permission_type === 'admin') {
|
|
||||||
$scope.run_ad_hoc_commands = true;
|
|
||||||
$("#permission_run_ad_hoc_commands_chbox").attr("disabled", true);
|
|
||||||
} else {
|
|
||||||
if (!$scope.run_ad_hoc_commands) {
|
|
||||||
$scope.run_ad_hoc_commands = false;
|
|
||||||
}
|
|
||||||
$("#permission_run_ad_hoc_commands_chbox").attr("disabled", false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
generator.inject(form, { mode: 'edit', related: true, scope: $scope });
|
|
||||||
generator.reset();
|
|
||||||
|
|
||||||
$scope.selectCategory = function (resetIn) {
|
|
||||||
var reset = (resetIn === false) ? false : true;
|
|
||||||
PermissionCategoryChange({ scope: $scope, reset: reset });
|
|
||||||
};
|
|
||||||
if ($scope.removeFillForm) {
|
|
||||||
$scope.removeFillForm();
|
|
||||||
}
|
|
||||||
$scope.removeFillForm = $scope.$on('FillForm', function () {
|
|
||||||
// Retrieve detail record and prepopulate the form
|
|
||||||
Wait('start');
|
|
||||||
Rest.setUrl(defaultUrl);
|
|
||||||
Rest.get()
|
|
||||||
.success(function (data) {
|
|
||||||
var fld, sourceModel, sourceField;
|
|
||||||
LoadBreadCrumbs({ path: '/users/' + base_id + '/permissions/' + id, title: data.name });
|
|
||||||
for (fld in form.fields) {
|
|
||||||
if (data[fld]) {
|
|
||||||
if (form.fields[fld].sourceModel) {
|
|
||||||
sourceModel = form.fields[fld].sourceModel;
|
|
||||||
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' && data.permission_type !== 'create') {
|
|
||||||
$scope.category = 'Inventory';
|
|
||||||
}
|
|
||||||
master.category = $scope.category;
|
|
||||||
$scope.selectCategory(false); //call without resetting $scope.category value
|
|
||||||
|
|
||||||
LookUpInit({
|
|
||||||
scope: $scope,
|
|
||||||
form: form,
|
|
||||||
current_item: data.inventory,
|
|
||||||
list: InventoryList,
|
|
||||||
field: 'inventory',
|
|
||||||
input_type: "radio"
|
|
||||||
});
|
|
||||||
|
|
||||||
LookUpInit({
|
|
||||||
scope: $scope,
|
|
||||||
form: form,
|
|
||||||
current_item: data.project,
|
|
||||||
list: ProjectList,
|
|
||||||
field: 'project',
|
|
||||||
input_type: 'radio'
|
|
||||||
});
|
|
||||||
|
|
||||||
$scope.changeAdhocCommandCheckbox();
|
|
||||||
|
|
||||||
if (!$scope.PermissionAddAllowed) {
|
|
||||||
// If not a privileged user, disable access
|
|
||||||
$('form[name="permission_form"]').find('select, input, button').each(function () {
|
|
||||||
if ($(this).is('input') || $(this).is('select')) {
|
|
||||||
$(this).attr('readonly', 'readonly');
|
|
||||||
}
|
|
||||||
if ($(this).is('input[type="checkbox"]') ||
|
|
||||||
$(this).is('input[type="radio"]') ||
|
|
||||||
$(this).is('button')) {
|
|
||||||
$(this).attr('disabled', 'disabled');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Wait('stop');
|
|
||||||
})
|
|
||||||
.error(function (data, status) {
|
|
||||||
ProcessErrors($scope, data, status, form, { hdr: 'Error!',
|
|
||||||
msg: 'Failed to retrieve Permission: ' + id + '. GET status: ' + status });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
CheckAccess({
|
|
||||||
scope: $scope,
|
|
||||||
callback: 'FillForm'
|
|
||||||
});
|
|
||||||
|
|
||||||
// Save changes to the parent
|
|
||||||
$scope.formSave = function () {
|
|
||||||
var fld, data = {};
|
|
||||||
generator.clearApiErrors();
|
|
||||||
Wait('start');
|
|
||||||
for (fld in form.fields) {
|
|
||||||
data[fld] = $scope[fld];
|
|
||||||
}
|
|
||||||
// job template (or deploy) based permissions do not have the run
|
|
||||||
// ad hoc commands parameter
|
|
||||||
if (data.category === "Deploy") {
|
|
||||||
data.run_ad_hoc_commands = false;
|
|
||||||
} else {
|
|
||||||
delete data.project;
|
|
||||||
}
|
|
||||||
|
|
||||||
Rest.setUrl(defaultUrl);
|
|
||||||
if($scope.category === "Inventory"){
|
|
||||||
delete data.project;
|
|
||||||
}
|
|
||||||
Rest.put(data)
|
|
||||||
.success(function () {
|
|
||||||
Wait('stop');
|
|
||||||
ReturnToCaller(1);
|
|
||||||
})
|
|
||||||
.error(function (data, status) {
|
|
||||||
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];
|
|
||||||
}
|
|
||||||
$scope.selectCategory(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
PermissionsEdit.$inject = ['$scope', '$rootScope', '$compile', '$location',
|
|
||||||
'$log', '$routeParams', 'PermissionsForm', 'GenerateForm', 'Rest', 'Alert',
|
|
||||||
'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'Prompt',
|
|
||||||
'GetBasePath', 'InventoryList', 'ProjectList', 'LookUpInit', 'CheckAccess',
|
|
||||||
'Wait', 'PermissionCategoryChange'];
|
|
@ -176,7 +176,7 @@ TeamsAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$r
|
|||||||
|
|
||||||
export function TeamsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, TeamForm, GenerateForm, Rest, Alert, ProcessErrors,
|
export function TeamsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, TeamForm, GenerateForm, Rest, Alert, ProcessErrors,
|
||||||
LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, LookUpInit, Prompt, GetBasePath, CheckAccess,
|
LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, LookUpInit, Prompt, GetBasePath, CheckAccess,
|
||||||
OrganizationList, Wait, Stream) {
|
OrganizationList, Wait, Stream, permissionsLabel) {
|
||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
@ -188,6 +188,17 @@ export function TeamsEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
id = $routeParams.team_id,
|
id = $routeParams.team_id,
|
||||||
relatedSets = {};
|
relatedSets = {};
|
||||||
|
|
||||||
|
$scope.permission_label = {};
|
||||||
|
|
||||||
|
permissionsLabel({
|
||||||
|
scope: $scope,
|
||||||
|
url: 'api/v1/' + base + '/' + id + '/permissions/'
|
||||||
|
}).then(function(choices) {
|
||||||
|
_.map(choices, function(n, key) {
|
||||||
|
$scope.permission_label[key] = n;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
$scope.team_id = id;
|
$scope.team_id = id;
|
||||||
|
|
||||||
generator.inject(form, { mode: 'edit', related: true, scope: $scope });
|
generator.inject(form, { mode: 'edit', related: true, scope: $scope });
|
||||||
@ -277,6 +288,15 @@ export function TeamsEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
'. GET status: ' + status });
|
'. GET status: ' + status });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$scope.getPermissionText = function () {
|
||||||
|
if (this.permission.permission_type !== "admin" && this.permission.run_ad_hoc_commands) {
|
||||||
|
return $scope.permission_label[this.permission.permission_type] +
|
||||||
|
" and " + $scope.permission_label.adhoc;
|
||||||
|
} else {
|
||||||
|
return $scope.permission_label[this.permission.permission_type];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
$scope.showActivity = function () {
|
$scope.showActivity = function () {
|
||||||
Stream({ scope: $scope });
|
Stream({ scope: $scope });
|
||||||
};
|
};
|
||||||
@ -392,5 +412,5 @@ export function TeamsEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
|
|
||||||
TeamsEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'TeamForm',
|
TeamsEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'TeamForm',
|
||||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit',
|
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit',
|
||||||
'ReturnToCaller', 'ClearScope', 'LookUpInit', 'Prompt', 'GetBasePath', 'CheckAccess', 'OrganizationList', 'Wait', 'Stream'
|
'ReturnToCaller', 'ClearScope', 'LookUpInit', 'Prompt', 'GetBasePath', 'CheckAccess', 'OrganizationList', 'Wait', 'Stream', 'permissionsLabel'
|
||||||
];
|
];
|
||||||
|
@ -208,7 +208,7 @@ UsersAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$r
|
|||||||
|
|
||||||
export function UsersEdit($scope, $rootScope, $compile, $location, $log, $routeParams, UserForm, GenerateForm, Rest, Alert,
|
export function UsersEdit($scope, $rootScope, $compile, $location, $log, $routeParams, UserForm, GenerateForm, Rest, Alert,
|
||||||
ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, GetBasePath,
|
ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, GetBasePath,
|
||||||
Prompt, CheckAccess, ResetForm, Wait, Stream) {
|
Prompt, CheckAccess, ResetForm, Wait, Stream, permissionsLabel) {
|
||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
@ -220,10 +220,22 @@ export function UsersEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
id = $routeParams.user_id,
|
id = $routeParams.user_id,
|
||||||
relatedSets = {};
|
relatedSets = {};
|
||||||
|
|
||||||
|
$scope.permission_label = {};
|
||||||
|
|
||||||
|
permissionsLabel({
|
||||||
|
scope: $scope,
|
||||||
|
url: 'api/v1/' + base + '/' + id + '/permissions/'
|
||||||
|
}).then(function(choices) {
|
||||||
|
_.map(choices, function(n, key) {
|
||||||
|
$scope.permission_label[key] = n;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
if ($scope.removeFormReady) {
|
if ($scope.removeFormReady) {
|
||||||
$scope.removeFormReady();
|
$scope.removeFormReady();
|
||||||
}
|
}
|
||||||
$scope.removeFormReady = $scope.$on('formReady', function () {
|
$scope.removeFormReady = $scope.$on('formReady', function () {
|
||||||
|
|
||||||
generator.inject(form, { mode: 'edit', related: true, scope: $scope });
|
generator.inject(form, { mode: 'edit', related: true, scope: $scope });
|
||||||
generator.reset();
|
generator.reset();
|
||||||
|
|
||||||
@ -293,12 +305,12 @@ export function UsersEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
$routeParams.id + '. GET status: ' + status });
|
$routeParams.id + '. GET status: ' + status });
|
||||||
});
|
});
|
||||||
|
|
||||||
// if the permission includes adhoc (and is not admin), display that
|
|
||||||
$scope.getPermissionText = function () {
|
$scope.getPermissionText = function () {
|
||||||
if (this.permission.permission_type !== "admin" && this.permission.run_ad_hoc_commands) {
|
if (this.permission.permission_type !== "admin" && this.permission.run_ad_hoc_commands) {
|
||||||
return this.permission.permission_type + " + run commands";
|
return $scope.permission_label[this.permission.permission_type] +
|
||||||
|
" and " + $scope.permission_label.adhoc;
|
||||||
} else {
|
} else {
|
||||||
return this.permission.permission_type;
|
return $scope.permission_label[this.permission.permission_type];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -489,5 +501,5 @@ export function UsersEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
|
|
||||||
UsersEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'UserForm', 'GenerateForm',
|
UsersEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'UserForm', 'GenerateForm',
|
||||||
'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope',
|
'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope',
|
||||||
'GetBasePath', 'Prompt', 'CheckAccess', 'ResetForm', 'Wait', 'Stream'
|
'GetBasePath', 'Prompt', 'CheckAccess', 'ResetForm', 'Wait', 'Stream', 'permissionsLabel'
|
||||||
];
|
];
|
||||||
|
@ -23,7 +23,6 @@ import LicenseUpdate from "./forms/LicenseUpdate";
|
|||||||
import LogViewerOptions from "./forms/LogViewerOptions";
|
import LogViewerOptions from "./forms/LogViewerOptions";
|
||||||
import LogViewerStatus from "./forms/LogViewerStatus";
|
import LogViewerStatus from "./forms/LogViewerStatus";
|
||||||
import Organizations from "./forms/Organizations";
|
import Organizations from "./forms/Organizations";
|
||||||
import Permissions from "./forms/Permissions";
|
|
||||||
import ProjectStatus from "./forms/ProjectStatus";
|
import ProjectStatus from "./forms/ProjectStatus";
|
||||||
import Projects from "./forms/Projects";
|
import Projects from "./forms/Projects";
|
||||||
import Source from "./forms/Source";
|
import Source from "./forms/Source";
|
||||||
@ -51,7 +50,6 @@ export
|
|||||||
LogViewerOptions,
|
LogViewerOptions,
|
||||||
LogViewerStatus,
|
LogViewerStatus,
|
||||||
Organizations,
|
Organizations,
|
||||||
Permissions,
|
|
||||||
ProjectStatus,
|
ProjectStatus,
|
||||||
Projects,
|
Projects,
|
||||||
Source,
|
Source,
|
||||||
|
@ -1,159 +0,0 @@
|
|||||||
/*************************************************
|
|
||||||
* Copyright (c) 2015 Ansible, Inc.
|
|
||||||
*
|
|
||||||
* All Rights Reserved
|
|
||||||
*************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ngdoc function
|
|
||||||
* @name forms.function:Permissions
|
|
||||||
* @description This form is for adding/editing persmissions
|
|
||||||
*/
|
|
||||||
|
|
||||||
export default
|
|
||||||
angular.module('PermissionFormDefinition', [])
|
|
||||||
.value('PermissionsForm', {
|
|
||||||
|
|
||||||
addTitle: 'Add Permission', //Title in add mode
|
|
||||||
editTitle: '{{ name }}', //Title in edit mode
|
|
||||||
name: 'permission', //entity or model name in singular form
|
|
||||||
well: true, //Wrap the form with TB well
|
|
||||||
forceListeners: true,
|
|
||||||
|
|
||||||
stream: {
|
|
||||||
'class': "btn-primary btn-xs activity-btn",
|
|
||||||
ngClick: "showActivity()",
|
|
||||||
awToolTip: "View Activity Stream",
|
|
||||||
awFeature: 'activity_streams',
|
|
||||||
dataPlacement: "top",
|
|
||||||
icon: "icon-comments-alt",
|
|
||||||
mode: 'edit',
|
|
||||||
iconSize: 'large'
|
|
||||||
},
|
|
||||||
|
|
||||||
fields: {
|
|
||||||
category: {
|
|
||||||
label: 'Permission Type',
|
|
||||||
labelClass: 'prepend-asterisk',
|
|
||||||
type: 'radio_group',
|
|
||||||
options: [{
|
|
||||||
label: 'Inventory',
|
|
||||||
value: 'Inventory',
|
|
||||||
selected: true
|
|
||||||
}, {
|
|
||||||
label: 'Job Template',
|
|
||||||
value: 'Deploy'
|
|
||||||
}],
|
|
||||||
ngChange: 'selectCategory()'
|
|
||||||
},
|
|
||||||
name: {
|
|
||||||
label: 'Name',
|
|
||||||
type: 'text',
|
|
||||||
addRequired: true,
|
|
||||||
editRequired: true,
|
|
||||||
capitalize: false
|
|
||||||
},
|
|
||||||
description: {
|
|
||||||
label: 'Description',
|
|
||||||
type: 'text',
|
|
||||||
addRequired: false,
|
|
||||||
editRequired: false
|
|
||||||
},
|
|
||||||
user: {
|
|
||||||
label: 'User',
|
|
||||||
type: 'hidden'
|
|
||||||
},
|
|
||||||
team: {
|
|
||||||
label: 'Team',
|
|
||||||
type: 'hidden'
|
|
||||||
},
|
|
||||||
project: {
|
|
||||||
label: 'Project',
|
|
||||||
type: 'lookup',
|
|
||||||
sourceModel: 'project',
|
|
||||||
sourceField: 'name',
|
|
||||||
ngShow: "category == 'Deploy'",
|
|
||||||
ngClick: 'lookUpProject()',
|
|
||||||
awRequiredWhen: {
|
|
||||||
variable: "projectrequired",
|
|
||||||
init: "false"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
inventory: {
|
|
||||||
label: 'Inventory',
|
|
||||||
type: 'lookup',
|
|
||||||
sourceModel: 'inventory',
|
|
||||||
sourceField: 'name',
|
|
||||||
ngClick: 'lookUpInventory()',
|
|
||||||
awRequiredWhen: {
|
|
||||||
variable: "inventoryrequired",
|
|
||||||
init: "true"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
permission_type: {
|
|
||||||
label: 'Permission',
|
|
||||||
labelClass: 'prepend-asterisk',
|
|
||||||
type: 'radio_group',
|
|
||||||
class: 'squeeze',
|
|
||||||
ngChange: 'changeAdhocCommandCheckbox()',
|
|
||||||
options: [{
|
|
||||||
label: 'Read',
|
|
||||||
value: 'read',
|
|
||||||
ngShow: "category == 'Inventory'"
|
|
||||||
}, {
|
|
||||||
label: 'Write',
|
|
||||||
value: 'write',
|
|
||||||
ngShow: "category == 'Inventory'"
|
|
||||||
}, {
|
|
||||||
label: 'Admin',
|
|
||||||
value: 'admin',
|
|
||||||
ngShow: "category == 'Inventory'"
|
|
||||||
}, {
|
|
||||||
label: 'Create',
|
|
||||||
value: 'create',
|
|
||||||
ngShow: "category == 'Deploy'"
|
|
||||||
}, {
|
|
||||||
label: 'Run',
|
|
||||||
value: 'run',
|
|
||||||
ngShow: "category == 'Deploy'"
|
|
||||||
}, {
|
|
||||||
label: 'Check',
|
|
||||||
value: 'check',
|
|
||||||
ngShow: "category == 'Deploy'"
|
|
||||||
}],
|
|
||||||
// hack: attach helpCollapse here if the permissions
|
|
||||||
// category is deploy
|
|
||||||
helpCollapse: [{
|
|
||||||
hdr: 'Permission',
|
|
||||||
ngBind: 'permissionTypeHelp',
|
|
||||||
ngHide: "category == 'Inventory'"
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
run_ad_hoc_commands: {
|
|
||||||
label: 'Execute commands',
|
|
||||||
type: 'checkbox',
|
|
||||||
// hack: attach helpCollapse here if the permissions
|
|
||||||
// category is inventory
|
|
||||||
helpCollapse: [{
|
|
||||||
hdr: 'Permission',
|
|
||||||
ngBind: 'permissionTypeHelp'
|
|
||||||
}],
|
|
||||||
ngShow: "category == 'Inventory'",
|
|
||||||
associated: 'permission_type'
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
buttons: {
|
|
||||||
save: {
|
|
||||||
ngClick: 'formSave()',
|
|
||||||
ngDisabled: true
|
|
||||||
},
|
|
||||||
reset: {
|
|
||||||
ngClick: 'formReset()',
|
|
||||||
ngDisabled: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
related: { }
|
|
||||||
|
|
||||||
}); // Form
|
|
@ -156,7 +156,8 @@ export default
|
|||||||
ngBind: 'permission.summary_fields.project.name'
|
ngBind: 'permission.summary_fields.project.name'
|
||||||
},
|
},
|
||||||
permission_type: {
|
permission_type: {
|
||||||
label: 'Permission'
|
label: 'Permission',
|
||||||
|
ngBind: 'getPermissionText()'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ import LogViewer from "./helpers/LogViewer";
|
|||||||
import Lookup from "./helpers/Lookup";
|
import Lookup from "./helpers/Lookup";
|
||||||
import PaginationHelpers from "./helpers/PaginationHelpers";
|
import PaginationHelpers from "./helpers/PaginationHelpers";
|
||||||
import Parse from "./helpers/Parse";
|
import Parse from "./helpers/Parse";
|
||||||
import Permissions from "./helpers/Permissions";
|
|
||||||
import ProjectPath from "./helpers/ProjectPath";
|
import ProjectPath from "./helpers/ProjectPath";
|
||||||
import Projects from "./helpers/Projects";
|
import Projects from "./helpers/Projects";
|
||||||
import Schedules from "./helpers/Schedules";
|
import Schedules from "./helpers/Schedules";
|
||||||
@ -64,7 +63,6 @@ export
|
|||||||
Lookup,
|
Lookup,
|
||||||
PaginationHelpers,
|
PaginationHelpers,
|
||||||
Parse,
|
Parse,
|
||||||
Permissions,
|
|
||||||
ProjectPath,
|
ProjectPath,
|
||||||
Projects,
|
Projects,
|
||||||
Schedules,
|
Schedules,
|
||||||
|
@ -1,79 +0,0 @@
|
|||||||
/*************************************************
|
|
||||||
* Copyright (c) 2015 Ansible, Inc.
|
|
||||||
*
|
|
||||||
* All Rights Reserved
|
|
||||||
*************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ngdoc function
|
|
||||||
* @name helpers.function:Permissions
|
|
||||||
* @description
|
|
||||||
* Functions shared amongst Permission related controllers
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
export default
|
|
||||||
angular.module('PermissionsHelper', [])
|
|
||||||
|
|
||||||
// Handle category change event
|
|
||||||
.factory('PermissionCategoryChange', ['$sce',
|
|
||||||
function ($sce) {
|
|
||||||
return function (params) {
|
|
||||||
var scope = params.scope,
|
|
||||||
reset = params.reset,
|
|
||||||
html;
|
|
||||||
|
|
||||||
if (scope.category === 'Inventory') {
|
|
||||||
scope.projectrequired = false;
|
|
||||||
html = "<dl>\n" +
|
|
||||||
"<dt>Read</dt>\n" +
|
|
||||||
"<dd>Only allow the user or team to view the inventory." +
|
|
||||||
"</dd>\n" +
|
|
||||||
"<dt>Write</dt>\n" +
|
|
||||||
"<dd>Allow the user or team to modify hosts and groups " +
|
|
||||||
"contained in the inventory, add new hosts and groups" +
|
|
||||||
", and perform inventory sync operations.\n" +
|
|
||||||
"<dt>Admin</dt>\n" +
|
|
||||||
"<dd>Allow the user or team full access to the " +
|
|
||||||
"inventory. This includes reading, writing, deletion " +
|
|
||||||
"of the inventory, inventory sync operations, and " +
|
|
||||||
"the ability to execute commands on the inventory." +
|
|
||||||
"</dd>\n" +
|
|
||||||
"<dt>Execute commands</dt>\n" +
|
|
||||||
"<dd>Allow the user to execute commands on the " +
|
|
||||||
"inventory.</dd>\n" +
|
|
||||||
"</dl>\n";
|
|
||||||
scope.permissionTypeHelp = $sce.trustAsHtml(html);
|
|
||||||
} else {
|
|
||||||
scope.projectrequired = true;
|
|
||||||
html = "<dl>\n" +
|
|
||||||
"<dt>Create</dt>\n" +
|
|
||||||
"<dd>Allow the user or team to create job templates. " +
|
|
||||||
"This implies that they have the Run and Check " +
|
|
||||||
"permissions.</dd>\n" +
|
|
||||||
"<dt>Run</dt>\n" +
|
|
||||||
"<dd>Allow the user or team to run a job template from " +
|
|
||||||
"the project against the inventory. In Run mode " +
|
|
||||||
"modules will " +
|
|
||||||
"be executed, and changes to the inventory will occur." +
|
|
||||||
"</dd>\n" +
|
|
||||||
"<dt>Check</dt>\n" +
|
|
||||||
"<dd>Only allow the user or team to run the project " +
|
|
||||||
"against the inventory as a dry-run operation. In " +
|
|
||||||
"Check mode, module operations " +
|
|
||||||
"will only be simulated. No changes will occur." +
|
|
||||||
"</dd>\n" +
|
|
||||||
"</dl>\n";
|
|
||||||
scope.permissionTypeHelp = $sce.trustAsHtml(html);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reset) {
|
|
||||||
if (scope.category === "Inventory") {
|
|
||||||
scope.permission_type = "read";
|
|
||||||
} else {
|
|
||||||
scope.permission_type = "run";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
]);
|
|
@ -21,7 +21,6 @@ import JobHosts from "./lists/JobHosts";
|
|||||||
import JobTemplates from "./lists/JobTemplates";
|
import JobTemplates from "./lists/JobTemplates";
|
||||||
import Jobs from "./lists/Jobs";
|
import Jobs from "./lists/Jobs";
|
||||||
import Organizations from "./lists/Organizations";
|
import Organizations from "./lists/Organizations";
|
||||||
import Permissions from "./lists/Permissions";
|
|
||||||
import PortalJobTemplates from "./lists/PortalJobTemplates";
|
import PortalJobTemplates from "./lists/PortalJobTemplates";
|
||||||
import PortalJobs from "./lists/PortalJobs";
|
import PortalJobs from "./lists/PortalJobs";
|
||||||
import Projects from "./lists/Projects";
|
import Projects from "./lists/Projects";
|
||||||
@ -50,7 +49,6 @@ export
|
|||||||
JobTemplates,
|
JobTemplates,
|
||||||
Jobs,
|
Jobs,
|
||||||
Organizations,
|
Organizations,
|
||||||
Permissions,
|
|
||||||
PortalJobTemplates,
|
PortalJobTemplates,
|
||||||
PortalJobs,
|
PortalJobs,
|
||||||
Projects,
|
Projects,
|
||||||
|
24
awx/ui/client/src/permissions/main.js
Normal file
24
awx/ui/client/src/permissions/main.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
import permissionsList from './permissions-list/main';
|
||||||
|
import permissionsAdd from './permissions-add/main';
|
||||||
|
import permissionsEdit from './permissions-edit/main';
|
||||||
|
import list from './permissions-list';
|
||||||
|
import form from './permissions-form';
|
||||||
|
import permissionsCategoryChange from './permissions-category-change.factory';
|
||||||
|
import permissionsLabel from './permissions-labels.factory';
|
||||||
|
|
||||||
|
export default
|
||||||
|
angular.module('permissions', [
|
||||||
|
permissionsList.name,
|
||||||
|
permissionsAdd.name,
|
||||||
|
permissionsEdit.name
|
||||||
|
])
|
||||||
|
.factory('permissionsList', list)
|
||||||
|
.factory('permissionsForm', form)
|
||||||
|
.factory('permissionsCategoryChange', permissionsCategoryChange)
|
||||||
|
.factory('permissionsLabel', permissionsLabel);
|
21
awx/ui/client/src/permissions/permissions-add/main.js
Normal file
21
awx/ui/client/src/permissions/permissions-add/main.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
import userRoute from './permissions-user-add.route';
|
||||||
|
import teamRoute from './permissions-team-add.route';
|
||||||
|
import controller from './permissions-add.controller';
|
||||||
|
|
||||||
|
export default
|
||||||
|
angular.module('permissionsAdd', [])
|
||||||
|
.controller('addController', controller)
|
||||||
|
.config(['$routeProvider', function($routeProvider) {
|
||||||
|
var url = userRoute.route;
|
||||||
|
delete userRoute.route;
|
||||||
|
$routeProvider.when(url, userRoute);
|
||||||
|
url = teamRoute.route;
|
||||||
|
delete teamRoute.route;
|
||||||
|
$routeProvider.when(url, teamRoute);
|
||||||
|
}]);
|
@ -0,0 +1,151 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc function
|
||||||
|
* @name controllers.function:Permissions
|
||||||
|
* @description This controller for permissions add
|
||||||
|
*/
|
||||||
|
export default
|
||||||
|
['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'permissionsForm', 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath', 'ReturnToCaller', 'InventoryList', 'ProjectList', 'LookUpInit', 'CheckAccess', 'Wait', 'permissionsCategoryChange', 'permissionsLabel',
|
||||||
|
function($scope, $rootScope, $compile, $location, $log, $routeParams, permissionsForm, GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope, GetBasePath, ReturnToCaller, InventoryList, ProjectList, LookUpInit, CheckAccess, Wait, permissionsCategoryChange, permissionsLabel) {
|
||||||
|
|
||||||
|
ClearScope();
|
||||||
|
|
||||||
|
// Inject dynamic view
|
||||||
|
var form = permissionsForm,
|
||||||
|
generator = GenerateForm,
|
||||||
|
id = ($routeParams.user_id !== undefined) ? $routeParams.user_id : $routeParams.team_id,
|
||||||
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
|
master = {};
|
||||||
|
|
||||||
|
permissionsLabel({
|
||||||
|
scope: $scope,
|
||||||
|
url: 'api/v1/' + base + '/' + id + '/permissions/'
|
||||||
|
}).then(function(choices) {
|
||||||
|
_.map(choices, function(n, key) {
|
||||||
|
$scope.permission_label[key] = n;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
generator.inject(form, { mode: 'add', related: false, scope: $scope });
|
||||||
|
CheckAccess({ scope: $scope });
|
||||||
|
generator.reset();
|
||||||
|
LoadBreadCrumbs();
|
||||||
|
|
||||||
|
$scope.inventoryrequired = true;
|
||||||
|
$scope.projectrequired = false;
|
||||||
|
$scope.category = 'Inventory';
|
||||||
|
master.category = 'Inventory';
|
||||||
|
master.inventoryrequired = true;
|
||||||
|
master.projectrequired = false;
|
||||||
|
$scope.run_ad_hoc_commands = false;
|
||||||
|
$scope.permission_label = {};
|
||||||
|
|
||||||
|
LookUpInit({
|
||||||
|
scope: $scope,
|
||||||
|
form: form,
|
||||||
|
current_item: null,
|
||||||
|
list: InventoryList,
|
||||||
|
field: 'inventory',
|
||||||
|
input_type: 'radio'
|
||||||
|
});
|
||||||
|
|
||||||
|
LookUpInit({
|
||||||
|
scope: $scope,
|
||||||
|
form: form,
|
||||||
|
current_item: null,
|
||||||
|
list: ProjectList,
|
||||||
|
field: 'project',
|
||||||
|
input_type: 'radio'
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.$watch("category", function(val) {
|
||||||
|
if (val === 'Deploy') {
|
||||||
|
$scope.projectrequired = true;
|
||||||
|
LookUpInit({
|
||||||
|
scope: $scope,
|
||||||
|
form: form,
|
||||||
|
current_item: null,
|
||||||
|
list: ProjectList,
|
||||||
|
field: 'project',
|
||||||
|
input_type: 'radio'
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$scope.projectrequired = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.changeAdhocCommandCheckbox = function () {
|
||||||
|
if ($scope.category === 'Deploy') {
|
||||||
|
$scope.run_ad_hoc_command = false;
|
||||||
|
} else {
|
||||||
|
if ($scope.permission_type === 'admin') {
|
||||||
|
$scope.run_ad_hoc_commands = true;
|
||||||
|
$("#permission_run_ad_hoc_commands_chbox").attr("disabled", true);
|
||||||
|
} else {
|
||||||
|
if (!$scope.run_ad_hoc_commands) {
|
||||||
|
$scope.run_ad_hoc_commands = false;
|
||||||
|
}
|
||||||
|
$("#permission_run_ad_hoc_commands_chbox").attr("disabled", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Save
|
||||||
|
$scope.formSave = function () {
|
||||||
|
var fld, url, data = {};
|
||||||
|
generator.clearApiErrors();
|
||||||
|
Wait('start');
|
||||||
|
if ($scope.PermissionAddAllowed) {
|
||||||
|
data = {};
|
||||||
|
for (fld in form.fields) {
|
||||||
|
data[fld] = $scope[fld];
|
||||||
|
}
|
||||||
|
// job template (or deploy) based permissions do not have the run
|
||||||
|
// ad hoc commands parameter
|
||||||
|
if (data.category === "Deploy") {
|
||||||
|
data.run_ad_hoc_commands = false;
|
||||||
|
} else {
|
||||||
|
delete data.project;
|
||||||
|
}
|
||||||
|
|
||||||
|
url = (base === 'teams') ? GetBasePath('teams') + id + '/permissions/' : GetBasePath('users') + id + '/permissions/';
|
||||||
|
Rest.setUrl(url);
|
||||||
|
Rest.post(data)
|
||||||
|
.success(function () {
|
||||||
|
Wait('stop');
|
||||||
|
ReturnToCaller(1);
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
Wait('stop');
|
||||||
|
ProcessErrors($scope, data, status, permissionsForm, { hdr: 'Error!',
|
||||||
|
msg: 'Failed to create new permission. Post returned status: ' + status });
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Alert('Access Denied', 'You do not have access to create new permission objects. Please contact a system administrator.',
|
||||||
|
'alert-danger');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Cancel
|
||||||
|
$scope.formReset = function () {
|
||||||
|
$rootScope.flashMessage = null;
|
||||||
|
generator.reset();
|
||||||
|
for (var fld in master) {
|
||||||
|
$scope[fld] = master[fld];
|
||||||
|
}
|
||||||
|
$scope.selectCategory();
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.selectCategory = function () {
|
||||||
|
permissionsCategoryChange({ scope: $scope, reset: true });
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
$scope.selectCategory();
|
||||||
|
|
||||||
|
}];
|
@ -0,0 +1,19 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
import {templateUrl} from '../../shared/template-url/template-url.factory';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'teamPermissionsAdd',
|
||||||
|
route: '/teams/:team_id/permissions/add',
|
||||||
|
templateUrl: templateUrl('permissions/team-permissions'),
|
||||||
|
controller: 'addController',
|
||||||
|
resolve: {
|
||||||
|
features: ['FeaturesService', function(FeaturesService) {
|
||||||
|
return FeaturesService.get();
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,19 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
import {templateUrl} from '../../shared/template-url/template-url.factory';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'userPermissionsAdd',
|
||||||
|
route: '/users/:user_id/permissions/add',
|
||||||
|
templateUrl: templateUrl('permissions/user-permissions'),
|
||||||
|
controller: 'addController',
|
||||||
|
resolve: {
|
||||||
|
features: ['FeaturesService', function(FeaturesService) {
|
||||||
|
return FeaturesService.get();
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,74 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc function
|
||||||
|
* @name helpers.function:Permissions
|
||||||
|
* @description
|
||||||
|
* Functions shared amongst Permission related controllers
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
export default
|
||||||
|
['$sce', function($sce) {
|
||||||
|
return function (params) {
|
||||||
|
var scope = params.scope,
|
||||||
|
reset = params.reset,
|
||||||
|
html;
|
||||||
|
|
||||||
|
if (scope.category === 'Inventory') {
|
||||||
|
scope.projectrequired = false;
|
||||||
|
html = "<dl>\n" +
|
||||||
|
"<dt>Read Inventory</dt>\n" +
|
||||||
|
"<dd>Only allow the user or team to view the inventory." +
|
||||||
|
"</dd>\n" +
|
||||||
|
"<dt>Edit Inventory</dt>\n" +
|
||||||
|
"<dd>Allow the user or team to modify hosts and groups " +
|
||||||
|
"contained in the inventory, add new hosts and groups" +
|
||||||
|
", and perform inventory sync operations.\n" +
|
||||||
|
"<dt>Administrate Inventory</dt>\n" +
|
||||||
|
"<dd>Allow the user or team full access to the " +
|
||||||
|
"inventory. This includes reading, writing, deletion " +
|
||||||
|
"of the inventory, inventory sync operations, and " +
|
||||||
|
"the ability to execute commands on the inventory." +
|
||||||
|
"</dd>\n" +
|
||||||
|
"<dt>Execute Commands</dt>\n" +
|
||||||
|
"<dd>Allow the user to execute commands on the " +
|
||||||
|
"inventory.</dd>\n" +
|
||||||
|
"</dl>\n";
|
||||||
|
scope.permissionTypeHelp = $sce.trustAsHtml(html);
|
||||||
|
} else {
|
||||||
|
scope.projectrequired = true;
|
||||||
|
html = "<dl>\n" +
|
||||||
|
"<dt>Create a Job Template</dt>\n" +
|
||||||
|
"<dd>Allow the user or team to create job templates. " +
|
||||||
|
"This implies that they have the Run and Check " +
|
||||||
|
"permissions.</dd>\n" +
|
||||||
|
"<dt>Deploy To Inventory</dt>\n" +
|
||||||
|
"<dd>Allow the user or team to run a job template from " +
|
||||||
|
"the project against the inventory. In Run mode " +
|
||||||
|
"modules will " +
|
||||||
|
"be executed, and changes to the inventory will occur." +
|
||||||
|
"</dd>\n" +
|
||||||
|
"<dt>Deploy to Inventory (Dry Run)</dt>\n" +
|
||||||
|
"<dd>Only allow the user or team to run the project " +
|
||||||
|
"against the inventory as a dry-run operation. In " +
|
||||||
|
"Check mode, module operations " +
|
||||||
|
"will only be simulated. No changes will occur." +
|
||||||
|
"</dd>\n" +
|
||||||
|
"</dl>\n";
|
||||||
|
scope.permissionTypeHelp = $sce.trustAsHtml(html);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reset) {
|
||||||
|
if (scope.category === "Inventory") {
|
||||||
|
scope.permission_type = "read";
|
||||||
|
} else {
|
||||||
|
scope.permission_type = "run";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}];
|
21
awx/ui/client/src/permissions/permissions-edit/main.js
Normal file
21
awx/ui/client/src/permissions/permissions-edit/main.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
import userRoute from './permissions-user-edit.route';
|
||||||
|
import teamRoute from './permissions-team-edit.route';
|
||||||
|
import controller from './permissions-edit.controller';
|
||||||
|
|
||||||
|
export default
|
||||||
|
angular.module('permissionsEdit', [])
|
||||||
|
.controller('editController', controller)
|
||||||
|
.config(['$routeProvider', function($routeProvider) {
|
||||||
|
var url = userRoute.route;
|
||||||
|
delete userRoute.route;
|
||||||
|
$routeProvider.when(url, userRoute);
|
||||||
|
url = teamRoute.route;
|
||||||
|
delete teamRoute.route;
|
||||||
|
$routeProvider.when(url, teamRoute);
|
||||||
|
}]);
|
@ -0,0 +1,178 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc function
|
||||||
|
* @name controllers.function:Permissions
|
||||||
|
* @description This controller for permissions edit
|
||||||
|
*/
|
||||||
|
export default
|
||||||
|
['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'permissionsForm', 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'Prompt', 'GetBasePath', 'InventoryList', 'ProjectList', 'LookUpInit', 'CheckAccess', 'Wait', 'permissionsCategoryChange', 'permissionsLabel',
|
||||||
|
function($scope, $rootScope, $compile, $location, $log, $routeParams, permissionsForm, GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, Prompt, GetBasePath, InventoryList, ProjectList, LookUpInit, CheckAccess, Wait, permissionsCategoryChange, permissionsLabel) {
|
||||||
|
|
||||||
|
ClearScope();
|
||||||
|
|
||||||
|
var generator = GenerateForm,
|
||||||
|
form = permissionsForm,
|
||||||
|
base_id = ($routeParams.user_id !== undefined) ? $routeParams.user_id : $routeParams.team_id,
|
||||||
|
id = $routeParams.permission_id,
|
||||||
|
defaultUrl = GetBasePath('base') + 'permissions/' + id + '/',
|
||||||
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
|
master = {};
|
||||||
|
|
||||||
|
$scope.permission_label = {};
|
||||||
|
|
||||||
|
permissionsLabel({
|
||||||
|
scope: $scope,
|
||||||
|
url: 'api/v1/' + base + '/' + base_id + '/permissions/'
|
||||||
|
}).then(function(choices) {
|
||||||
|
_.map(choices, function(n, key) {
|
||||||
|
$scope.permission_label[key] = n;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.changeAdhocCommandCheckbox = function () {
|
||||||
|
if ($scope.category === 'Deploy') {
|
||||||
|
$scope.run_ad_hoc_command = false;
|
||||||
|
} else {
|
||||||
|
if ($scope.permission_type === 'admin') {
|
||||||
|
$scope.run_ad_hoc_commands = true;
|
||||||
|
$("#permission_run_ad_hoc_commands_chbox").attr("disabled", true);
|
||||||
|
} else {
|
||||||
|
if (!$scope.run_ad_hoc_commands) {
|
||||||
|
$scope.run_ad_hoc_commands = false;
|
||||||
|
}
|
||||||
|
$("#permission_run_ad_hoc_commands_chbox").attr("disabled", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
generator.inject(form, { mode: 'edit', related: true, scope: $scope });
|
||||||
|
generator.reset();
|
||||||
|
|
||||||
|
$scope.selectCategory = function (resetIn) {
|
||||||
|
var reset = (resetIn === false) ? false : true;
|
||||||
|
permissionsCategoryChange({ scope: $scope, reset: reset });
|
||||||
|
};
|
||||||
|
if ($scope.removeFillForm) {
|
||||||
|
$scope.removeFillForm();
|
||||||
|
}
|
||||||
|
$scope.removeFillForm = $scope.$on('FillForm', function () {
|
||||||
|
// Retrieve detail record and prepopulate the form
|
||||||
|
Wait('start');
|
||||||
|
Rest.setUrl(defaultUrl);
|
||||||
|
Rest.get()
|
||||||
|
.success(function (data) {
|
||||||
|
var fld, sourceModel, sourceField;
|
||||||
|
LoadBreadCrumbs({ path: '/users/' + base_id + '/permissions/' + id, title: data.name });
|
||||||
|
for (fld in form.fields) {
|
||||||
|
if (data[fld]) {
|
||||||
|
if (form.fields[fld].sourceModel) {
|
||||||
|
sourceModel = form.fields[fld].sourceModel;
|
||||||
|
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' && data.permission_type !== 'create') {
|
||||||
|
$scope.category = 'Inventory';
|
||||||
|
}
|
||||||
|
master.category = $scope.category;
|
||||||
|
$scope.selectCategory(false); //call without resetting $scope.category value
|
||||||
|
|
||||||
|
LookUpInit({
|
||||||
|
scope: $scope,
|
||||||
|
form: form,
|
||||||
|
current_item: data.inventory,
|
||||||
|
list: InventoryList,
|
||||||
|
field: 'inventory',
|
||||||
|
input_type: "radio"
|
||||||
|
});
|
||||||
|
|
||||||
|
LookUpInit({
|
||||||
|
scope: $scope,
|
||||||
|
form: form,
|
||||||
|
current_item: data.project,
|
||||||
|
list: ProjectList,
|
||||||
|
field: 'project',
|
||||||
|
input_type: 'radio'
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.changeAdhocCommandCheckbox();
|
||||||
|
|
||||||
|
if (!$scope.PermissionAddAllowed) {
|
||||||
|
// If not a privileged user, disable access
|
||||||
|
$('form[name="permission_form"]').find('select, input, button').each(function () {
|
||||||
|
if ($(this).is('input') || $(this).is('select')) {
|
||||||
|
$(this).attr('readonly', 'readonly');
|
||||||
|
}
|
||||||
|
if ($(this).is('input[type="checkbox"]') ||
|
||||||
|
$(this).is('input[type="radio"]') ||
|
||||||
|
$(this).is('button')) {
|
||||||
|
$(this).attr('disabled', 'disabled');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Wait('stop');
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
ProcessErrors($scope, data, status, form, { hdr: 'Error!',
|
||||||
|
msg: 'Failed to retrieve Permission: ' + id + '. GET status: ' + status });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
CheckAccess({
|
||||||
|
scope: $scope,
|
||||||
|
callback: 'FillForm'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Save changes to the parent
|
||||||
|
$scope.formSave = function () {
|
||||||
|
var fld, data = {};
|
||||||
|
generator.clearApiErrors();
|
||||||
|
Wait('start');
|
||||||
|
for (fld in form.fields) {
|
||||||
|
data[fld] = $scope[fld];
|
||||||
|
}
|
||||||
|
// job template (or deploy) based permissions do not have the run
|
||||||
|
// ad hoc commands parameter
|
||||||
|
if (data.category === "Deploy") {
|
||||||
|
data.run_ad_hoc_commands = false;
|
||||||
|
} else {
|
||||||
|
delete data.project;
|
||||||
|
}
|
||||||
|
|
||||||
|
Rest.setUrl(defaultUrl);
|
||||||
|
if($scope.category === "Inventory"){
|
||||||
|
delete data.project;
|
||||||
|
}
|
||||||
|
Rest.put(data)
|
||||||
|
.success(function () {
|
||||||
|
Wait('stop');
|
||||||
|
ReturnToCaller(1);
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
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];
|
||||||
|
}
|
||||||
|
$scope.selectCategory(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
}];
|
@ -0,0 +1,19 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
import {templateUrl} from '../../shared/template-url/template-url.factory';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'teamPermissionsEdit',
|
||||||
|
route: '/teams/:team_id/permissions/edit',
|
||||||
|
templateUrl: templateUrl('permissions/team-permissions'),
|
||||||
|
controller: 'editController',
|
||||||
|
resolve: {
|
||||||
|
features: ['FeaturesService', function(FeaturesService) {
|
||||||
|
return FeaturesService.get();
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,19 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
import {templateUrl} from '../../shared/template-url/template-url.factory';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'userPermissionsEdit',
|
||||||
|
route: '/users/:user_id/permissions/:permission_id',
|
||||||
|
templateUrl: templateUrl('permissions/user-permissions'),
|
||||||
|
controller: 'editController',
|
||||||
|
resolve: {
|
||||||
|
features: ['FeaturesService', function(FeaturesService) {
|
||||||
|
return FeaturesService.get();
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
};
|
158
awx/ui/client/src/permissions/permissions-form.js
Normal file
158
awx/ui/client/src/permissions/permissions-form.js
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc function
|
||||||
|
* @name forms.function:Permissions
|
||||||
|
* @description This form is for adding/editing persmissions
|
||||||
|
*/
|
||||||
|
|
||||||
|
export default function() {
|
||||||
|
return {
|
||||||
|
addTitle: 'Add Permission', //Title in add mode
|
||||||
|
editTitle: '{{ name }}', //Title in edit mode
|
||||||
|
name: 'permission', //entity or model name in singular form
|
||||||
|
well: true, //Wrap the form with TB well
|
||||||
|
forceListeners: true,
|
||||||
|
|
||||||
|
stream: {
|
||||||
|
'class': "btn-primary btn-xs activity-btn",
|
||||||
|
ngClick: "showActivity()",
|
||||||
|
awToolTip: "View Activity Stream",
|
||||||
|
awFeature: 'activity_streams',
|
||||||
|
dataPlacement: "top",
|
||||||
|
icon: "icon-comments-alt",
|
||||||
|
mode: 'edit',
|
||||||
|
iconSize: 'large'
|
||||||
|
},
|
||||||
|
|
||||||
|
fields: {
|
||||||
|
category: {
|
||||||
|
label: 'Permission Type',
|
||||||
|
labelClass: 'prepend-asterisk',
|
||||||
|
type: 'radio_group',
|
||||||
|
options: [{
|
||||||
|
label: 'Inventory',
|
||||||
|
value: 'Inventory',
|
||||||
|
selected: true
|
||||||
|
}, {
|
||||||
|
label: 'Job Template',
|
||||||
|
value: 'Deploy'
|
||||||
|
}],
|
||||||
|
ngChange: 'selectCategory()'
|
||||||
|
},
|
||||||
|
name: {
|
||||||
|
label: 'Name',
|
||||||
|
type: 'text',
|
||||||
|
addRequired: true,
|
||||||
|
editRequired: true,
|
||||||
|
capitalize: false
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
label: 'Description',
|
||||||
|
type: 'text',
|
||||||
|
addRequired: false,
|
||||||
|
editRequired: false
|
||||||
|
},
|
||||||
|
user: {
|
||||||
|
label: 'User',
|
||||||
|
type: 'hidden'
|
||||||
|
},
|
||||||
|
team: {
|
||||||
|
label: 'Team',
|
||||||
|
type: 'hidden'
|
||||||
|
},
|
||||||
|
project: {
|
||||||
|
label: 'Project',
|
||||||
|
type: 'lookup',
|
||||||
|
sourceModel: 'project',
|
||||||
|
sourceField: 'name',
|
||||||
|
ngShow: "category == 'Deploy'",
|
||||||
|
ngClick: 'lookUpProject()',
|
||||||
|
awRequiredWhen: {
|
||||||
|
variable: "projectrequired",
|
||||||
|
init: "false"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
inventory: {
|
||||||
|
label: 'Inventory',
|
||||||
|
type: 'lookup',
|
||||||
|
sourceModel: 'inventory',
|
||||||
|
sourceField: 'name',
|
||||||
|
ngClick: 'lookUpInventory()',
|
||||||
|
awRequiredWhen: {
|
||||||
|
variable: "inventoryrequired",
|
||||||
|
init: "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
permission_type: {
|
||||||
|
label: 'Permission',
|
||||||
|
labelClass: 'prepend-asterisk',
|
||||||
|
type: 'radio_group',
|
||||||
|
class: 'squeeze',
|
||||||
|
ngChange: 'changeAdhocCommandCheckbox()',
|
||||||
|
options: [{
|
||||||
|
label: '{{ permission_label.read }}',
|
||||||
|
value: 'read',
|
||||||
|
ngShow: "category == 'Inventory'"
|
||||||
|
}, {
|
||||||
|
label: '{{ permission_label.write }}',
|
||||||
|
value: 'write',
|
||||||
|
ngShow: "category == 'Inventory'"
|
||||||
|
}, {
|
||||||
|
label: '{{ permission_label.admin }}',
|
||||||
|
value: 'admin',
|
||||||
|
ngShow: "category == 'Inventory'"
|
||||||
|
}, {
|
||||||
|
label: '{{ permission_label.create }}',
|
||||||
|
value: 'create',
|
||||||
|
ngShow: "category == 'Deploy'"
|
||||||
|
}, {
|
||||||
|
label: '{{ permission_label.run }}',
|
||||||
|
value: 'run',
|
||||||
|
ngShow: "category == 'Deploy'"
|
||||||
|
}, {
|
||||||
|
label: '{{ permission_label.check }}',
|
||||||
|
value: 'check',
|
||||||
|
ngShow: "category == 'Deploy'"
|
||||||
|
}],
|
||||||
|
// hack: attach helpCollapse here if the permissions
|
||||||
|
// category is deploy
|
||||||
|
helpCollapse: [{
|
||||||
|
hdr: 'Permission',
|
||||||
|
ngBind: 'permissionTypeHelp',
|
||||||
|
ngHide: "category == 'Inventory'"
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
run_ad_hoc_commands: {
|
||||||
|
label: '{{ permission_label.adhoc }}',
|
||||||
|
type: 'checkbox',
|
||||||
|
// hack: attach helpCollapse here if the permissions
|
||||||
|
// category is inventory
|
||||||
|
helpCollapse: [{
|
||||||
|
hdr: 'Permission',
|
||||||
|
ngBind: 'permissionTypeHelp'
|
||||||
|
}],
|
||||||
|
ngShow: "category == 'Inventory'",
|
||||||
|
associated: 'permission_type'
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
buttons: {
|
||||||
|
save: {
|
||||||
|
ngClick: 'formSave()',
|
||||||
|
ngDisabled: true
|
||||||
|
},
|
||||||
|
reset: {
|
||||||
|
ngClick: 'formReset()',
|
||||||
|
ngDisabled: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
related: { }
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
46
awx/ui/client/src/permissions/permissions-labels.factory.js
Normal file
46
awx/ui/client/src/permissions/permissions-labels.factory.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc function
|
||||||
|
* @name helpers.function:Permissions
|
||||||
|
* @description
|
||||||
|
* Gets permission type labels from the API and sets them as the permissions labels on the relevant radio buttons
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
export default
|
||||||
|
['Rest', 'ProcessErrors', function(Rest, ProcessErrors) {
|
||||||
|
return function (params) {
|
||||||
|
var scope = params.scope,
|
||||||
|
url = params.url;
|
||||||
|
|
||||||
|
// Auto populate the field if there is only one result
|
||||||
|
Rest.setUrl(url);
|
||||||
|
return Rest.options()
|
||||||
|
.then(function (data) {
|
||||||
|
data = data.data;
|
||||||
|
var choices = data.actions.GET.permission_type.choices;
|
||||||
|
|
||||||
|
// convert the choices from the API from the format
|
||||||
|
// [["read", "Read Inventory"], ...] to
|
||||||
|
// {read: "Read Inventory", ...}
|
||||||
|
choices = choices.reduce(function(obj, kvp) {
|
||||||
|
obj[kvp[0]] = kvp[1];
|
||||||
|
return obj;
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
// manually add the adhoc label to the choices object
|
||||||
|
choices['adhoc'] = data.actions.GET.run_ad_hoc_commands.label;
|
||||||
|
|
||||||
|
return choices;
|
||||||
|
})
|
||||||
|
.catch(function (data, status) {
|
||||||
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||||
|
msg: 'Failed to get permission type labels. Options requrest returned status: ' + status });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}];
|
@ -5,9 +5,8 @@
|
|||||||
*************************************************/
|
*************************************************/
|
||||||
|
|
||||||
|
|
||||||
export default
|
export default function() {
|
||||||
angular.module('PermissionListDefinition', [])
|
return {
|
||||||
.value('PermissionList', {
|
|
||||||
|
|
||||||
name: 'permissions',
|
name: 'permissions',
|
||||||
iterator: 'permission',
|
iterator: 'permission',
|
||||||
@ -77,4 +76,5 @@ export default
|
|||||||
dataPlacement: 'top'
|
dataPlacement: 'top'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
}
|
21
awx/ui/client/src/permissions/permissions-list/main.js
Normal file
21
awx/ui/client/src/permissions/permissions-list/main.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
import userRoute from './permissions-user-list.route';
|
||||||
|
import teamRoute from './permissions-team-list.route';
|
||||||
|
import controller from './permissions-list.controller';
|
||||||
|
|
||||||
|
export default
|
||||||
|
angular.module('permissionsList', [])
|
||||||
|
.controller('permissionsListController', controller)
|
||||||
|
.config(['$routeProvider', function($routeProvider) {
|
||||||
|
var url = userRoute.route;
|
||||||
|
delete userRoute.route;
|
||||||
|
$routeProvider.when(url, userRoute);
|
||||||
|
url = teamRoute.route;
|
||||||
|
delete teamRoute.route;
|
||||||
|
$routeProvider.when(url, teamRoute);
|
||||||
|
}]);
|
@ -0,0 +1,116 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc function
|
||||||
|
* @name controllers.function:Permissions
|
||||||
|
* @description This controller for permissions list
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
export default
|
||||||
|
['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'permissionsList', 'generateList', 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors', 'GetBasePath', 'CheckAccess', 'Wait', 'permissionsLabel',
|
||||||
|
function ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, permissionsList, GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, CheckAccess, Wait, permissionsLabel) {
|
||||||
|
|
||||||
|
ClearScope();
|
||||||
|
|
||||||
|
var list = permissionsList,
|
||||||
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
|
base_id = ($routeParams.user_id !== undefined) ? $routeParams.user_id : $routeParams.team_id,
|
||||||
|
defaultUrl = GetBasePath(base),
|
||||||
|
generator = GenerateList;
|
||||||
|
|
||||||
|
$scope.permission_label = {};
|
||||||
|
|
||||||
|
permissionsLabel({
|
||||||
|
scope: $scope,
|
||||||
|
url: 'api/v1/' + base + '/' + base_id + '/permissions/'
|
||||||
|
}).then(function(choices) {
|
||||||
|
_.map(choices, function(n, key) {
|
||||||
|
$scope.permission_label[key] = n;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
generator.inject(list, { mode: 'edit', scope: $scope, breadCrumbs: true });
|
||||||
|
defaultUrl += ($routeParams.user_id !== undefined) ? $routeParams.user_id : $routeParams.team_id;
|
||||||
|
defaultUrl += '/permissions/';
|
||||||
|
|
||||||
|
$scope.selected = [];
|
||||||
|
|
||||||
|
CheckAccess({
|
||||||
|
scope: $scope
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($scope.removePostRefresh) {
|
||||||
|
$scope.removePostRefresh();
|
||||||
|
}
|
||||||
|
$scope.removePostRefresh = $scope.$on('PostRefresh', function () {
|
||||||
|
// Cleanup after a delete
|
||||||
|
Wait('stop');
|
||||||
|
$('#prompt-modal').modal('hide');
|
||||||
|
});
|
||||||
|
|
||||||
|
SearchInit({
|
||||||
|
scope: $scope,
|
||||||
|
set: 'permissions',
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
PaginateInit({
|
||||||
|
scope: $scope,
|
||||||
|
list: list,
|
||||||
|
url: defaultUrl
|
||||||
|
});
|
||||||
|
$scope.search(list.iterator);
|
||||||
|
|
||||||
|
LoadBreadCrumbs();
|
||||||
|
|
||||||
|
$scope.addPermission = function () {
|
||||||
|
if ($scope.PermissionAddAllowed) {
|
||||||
|
$location.path($location.path() + '/add');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// if the permission includes adhoc (and is not admin), display that
|
||||||
|
$scope.getPermissionText = function () {
|
||||||
|
if (this.permission.permission_type !== "admin" && this.permission.run_ad_hoc_commands) {
|
||||||
|
return $scope.permission_label[this.permission.permission_type] +
|
||||||
|
" and " + $scope.permission_label.adhoc;
|
||||||
|
} else {
|
||||||
|
return $scope.permission_label[this.permission.permission_type];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.editPermission = function (id) {
|
||||||
|
$location.path($location.path() + '/' + id);
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.deletePermission = function (id, name) {
|
||||||
|
var action = function () {
|
||||||
|
$('#prompt-modal').modal('hide');
|
||||||
|
Wait('start');
|
||||||
|
var url = GetBasePath('base') + 'permissions/' + id + '/';
|
||||||
|
Rest.setUrl(url);
|
||||||
|
Rest.destroy()
|
||||||
|
.success(function () {
|
||||||
|
$scope.search(list.iterator);
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
Wait('stop');
|
||||||
|
ProcessErrors($scope, data, status, null, { hdr: 'Error!',
|
||||||
|
msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
if ($scope.PermissionAddAllowed) {
|
||||||
|
Prompt({
|
||||||
|
hdr: 'Delete',
|
||||||
|
body: 'Are you sure you want to delete ' + name + '?',
|
||||||
|
action: action
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}];
|
@ -0,0 +1,19 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
import {templateUrl} from '../../shared/template-url/template-url.factory';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'teamPermissionsList',
|
||||||
|
route: '/teams/:team_id/permissions',
|
||||||
|
templateUrl: templateUrl('permissions/team-permissions'),
|
||||||
|
controller: 'permissionsListController',
|
||||||
|
resolve: {
|
||||||
|
features: ['FeaturesService', function(FeaturesService) {
|
||||||
|
return FeaturesService.get();
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,19 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
import {templateUrl} from '../../shared/template-url/template-url.factory';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'userPermissionsList',
|
||||||
|
route: '/users/:user_id/permissions',
|
||||||
|
templateUrl: templateUrl('permissions/user-permissions'),
|
||||||
|
controller: 'permissionsListController',
|
||||||
|
resolve: {
|
||||||
|
features: ['FeaturesService', function(FeaturesService) {
|
||||||
|
return FeaturesService.get();
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
};
|
18
awx/ui/client/src/permissions/team-permissions.partial.html
Normal file
18
awx/ui/client/src/permissions/team-permissions.partial.html
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<breadcrumbs>
|
||||||
|
<breadcrumb path="/setup" title="Setup"></breadcrumb>
|
||||||
|
<breadcrumb path="/teams" title="Teams"></breadcrumb>
|
||||||
|
<breadcrumb
|
||||||
|
path="/teams/add"
|
||||||
|
title="Create Team"
|
||||||
|
ng-if="mode == 'add'">
|
||||||
|
</breadcrumb>
|
||||||
|
<breadcrumb
|
||||||
|
path="/teams/{{team_id}}"
|
||||||
|
title="{{team_name}}"
|
||||||
|
ng-if="team_id">
|
||||||
|
</breadcrumb>
|
||||||
|
</breadcrumbs>
|
||||||
|
|
||||||
|
<div class="tab-pane" id="teams">
|
||||||
|
<div ng-cloak id="htmlTemplate"></div>
|
||||||
|
</div>
|
18
awx/ui/client/src/permissions/user-permissions.partial.html
Normal file
18
awx/ui/client/src/permissions/user-permissions.partial.html
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<breadcrumbs>
|
||||||
|
<breadcrumb path="/setup" title="Setup"></breadcrumb>
|
||||||
|
<breadcrumb path="/users" title="Users"></breadcrumb>
|
||||||
|
<breadcrumb
|
||||||
|
path="/users/add"
|
||||||
|
title="Create User"
|
||||||
|
ng-if="mode == 'add'">
|
||||||
|
</breadcrumb>
|
||||||
|
<breadcrumb
|
||||||
|
path="/users/{{user_id}}"
|
||||||
|
title="{{username_title}}"
|
||||||
|
ng-if="user_id">
|
||||||
|
</breadcrumb>
|
||||||
|
</breadcrumbs>
|
||||||
|
|
||||||
|
<div class="tab-pane" id="users">
|
||||||
|
<div ng-cloak id="htmlTemplate"></div>
|
||||||
|
</div>
|
Loading…
Reference in New Issue
Block a user