mirror of
https://github.com/ansible/awx.git
synced 2026-01-23 07:28:02 -03:30
Add WIP functionality for permissions
This commit is contained in:
parent
cea1f1bbe1
commit
488467c8c1
@ -32,7 +32,7 @@ function AddCredentialsController (models, $state) {
|
||||
};
|
||||
|
||||
vm.form.onSaveSuccess = res => {
|
||||
$state.go('credentials.edit', { id: res.data.id }, { reload: true });
|
||||
$state.go('credentials.edit', { credential_id: res.data.id }, { reload: true });
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
<div ui-view="permissions"></div>
|
||||
<at-panel>
|
||||
<at-panel-heading>{{ vm.panelTitle }}</at-panel-heading>
|
||||
|
||||
|
||||
@ -1,12 +1,40 @@
|
||||
import PermissionsList from '../../src/access/permissions-list.controller';
|
||||
import CredentialForm from '../../src/credentials/credentials.form';
|
||||
import CredentialList from '../../src/credentials/credentials.list';
|
||||
import ListController from '../../src/credentials/list/credentials-list.controller';
|
||||
import AddController from './add-credentials.controller.js';
|
||||
import EditController from './edit-credentials.controller.js';
|
||||
import { N_ } from '../../src/i18n';
|
||||
import {N_} from '../../src/i18n';
|
||||
|
||||
function config ($stateExtenderProvider, pathServiceProvider) {
|
||||
function CredentialsResolve ($q, $stateParams, Me, Credential, CredentialType) {
|
||||
let id = $stateParams.credential_id;
|
||||
|
||||
let promises = {
|
||||
me: new Me('get'),
|
||||
credentialType: new CredentialType('get')
|
||||
};
|
||||
|
||||
if (id) {
|
||||
promises.credential = new Credential(['get', 'options'], [id, id]);
|
||||
} else {
|
||||
promises.credential = new Credential('options');
|
||||
}
|
||||
|
||||
return $q.all(promises);
|
||||
}
|
||||
|
||||
CredentialsResolve.$inject = [
|
||||
'$q',
|
||||
'$stateParams',
|
||||
'MeModel',
|
||||
'CredentialModel',
|
||||
'CredentialTypeModel'
|
||||
];
|
||||
|
||||
function CredentialsConfig ($stateProvider, $stateExtenderProvider, stateDefinitionsProvider, pathServiceProvider) {
|
||||
let pathService = pathServiceProvider.$get();
|
||||
let stateExtender = $stateExtenderProvider.$get();
|
||||
let stateDefinitions = stateDefinitionsProvider.$get();
|
||||
|
||||
stateExtender.addState({
|
||||
name: 'credentials',
|
||||
@ -41,31 +69,6 @@ function config ($stateExtenderProvider, pathServiceProvider) {
|
||||
}
|
||||
});
|
||||
|
||||
function CredentialsResolve ($q, $stateParams, Me, Credential, CredentialType) {
|
||||
let id = $stateParams.id;
|
||||
|
||||
let promises = {
|
||||
me: new Me('get'),
|
||||
credentialType: new CredentialType('get')
|
||||
};
|
||||
|
||||
if (id) {
|
||||
promises.credential = new Credential(['get', 'options'], [id, id]);
|
||||
} else {
|
||||
promises.credential = new Credential('options');
|
||||
}
|
||||
|
||||
return $q.all(promises);
|
||||
}
|
||||
|
||||
CredentialsResolve.$inject = [
|
||||
'$q',
|
||||
'$stateParams',
|
||||
'MeModel',
|
||||
'CredentialModel',
|
||||
'CredentialTypeModel'
|
||||
];
|
||||
|
||||
stateExtender.addState({
|
||||
name: 'credentials.add',
|
||||
route: '/add',
|
||||
@ -86,7 +89,7 @@ function config ($stateExtenderProvider, pathServiceProvider) {
|
||||
|
||||
stateExtender.addState({
|
||||
name: 'credentials.edit',
|
||||
route: '/edit/:id',
|
||||
route: '/:credential_id',
|
||||
ncyBreadcrumb: {
|
||||
label: N_('EDIT')
|
||||
},
|
||||
@ -101,15 +104,80 @@ function config ($stateExtenderProvider, pathServiceProvider) {
|
||||
resolvedModels: CredentialsResolve
|
||||
}
|
||||
});
|
||||
|
||||
stateExtender.addState({
|
||||
name: "credentials.edit.permissions",
|
||||
url: "/permissions?{permission_search:queryset}",
|
||||
resolve: {
|
||||
ListDefinition: ['CredentialList', CredentialList => CredentialList],
|
||||
Dataset: [
|
||||
'CredentialList',
|
||||
'QuerySet',
|
||||
'$stateParams',
|
||||
'GetBasePath',
|
||||
'$interpolate',
|
||||
'$rootScope',
|
||||
'$state',
|
||||
(list, qs, $stateParams, GetBasePath, $interpolate, $rootScope, $state) => {
|
||||
list.basePath = 'api/v2/credentials/2/access_list/';
|
||||
// allow related list definitions to use interpolated $rootScope / $stateParams in basePath field
|
||||
let path, interpolator;
|
||||
if (GetBasePath(list.basePath)) {
|
||||
path = GetBasePath(list.basePath);
|
||||
} else {
|
||||
interpolator = $interpolate(list.basePath);
|
||||
path = interpolator({ $rootScope: $rootScope, $stateParams: $stateParams });
|
||||
}
|
||||
|
||||
$stateParams[`${list.iterator}_search`].order_by = 'username';
|
||||
return qs.search(path, $stateParams[`${list.iterator}_search`]);
|
||||
|
||||
}
|
||||
]
|
||||
},
|
||||
params: {
|
||||
permission_search: {
|
||||
value: {
|
||||
page_size: 20,
|
||||
order_by: 'username'
|
||||
},
|
||||
dynamic: true,
|
||||
squash: ""
|
||||
}
|
||||
},
|
||||
ncyBreadcrumb: {
|
||||
parent: "credentials.edit",
|
||||
label: "PERMISSIONS"
|
||||
},
|
||||
views: {
|
||||
'permissions': {
|
||||
controller: PermissionsList,
|
||||
templateProvider: function(CredentialForm, CredentialList, GenerateForm) {
|
||||
let form = CredentialForm;
|
||||
let list = CredentialList;
|
||||
|
||||
let html = GenerateForm.buildCollection({
|
||||
mode: 'edit',
|
||||
related: 'permissions',
|
||||
form: typeof(form) === 'function' ? form() : form
|
||||
});
|
||||
|
||||
return html;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
config.$inject = [
|
||||
CredentialsConfig.$inject = [
|
||||
'$stateProvider',
|
||||
'$stateExtenderProvider',
|
||||
'stateDefinitionsProvider',
|
||||
'PathServiceProvider'
|
||||
];
|
||||
|
||||
angular
|
||||
.module('at.features.credentials', [])
|
||||
.config(config)
|
||||
.config(CredentialsConfig)
|
||||
.controller('AddController', AddController)
|
||||
.controller('EditController', EditController);
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
<div ui-view="permissions"></div>
|
||||
<div ui-view="edit"></div>
|
||||
<div ui-view="add"></div>
|
||||
|
||||
|
||||
@ -12,11 +12,37 @@ function atInputLookupLink (scope, element, attrs, controllers) {
|
||||
function AtInputLookupController (baseInputController) {
|
||||
let vm = this || {};
|
||||
|
||||
vm.lookup = {};
|
||||
|
||||
vm.init = (scope, element, form) => {
|
||||
baseInputController.call(vm, 'input', scope, element, form);
|
||||
|
||||
vm.lookup.modal = {
|
||||
title: 'Select Organization',
|
||||
buttons: [
|
||||
{
|
||||
type: 'cancel'
|
||||
},
|
||||
{
|
||||
type: 'select'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
vm.lookup.search = {
|
||||
placeholder: 'test'
|
||||
};
|
||||
|
||||
vm.lookup.table = {
|
||||
|
||||
};
|
||||
|
||||
vm.check();
|
||||
};
|
||||
|
||||
vm.search = () => {
|
||||
vm.modal.show('test');
|
||||
};
|
||||
}
|
||||
|
||||
AtInputLookupController.$inject = ['BaseInputController'];
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
<div class="input-group">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn at-ButtonHollow--white at-Input-button"
|
||||
ng-disabled="state._disabled || form.disabled">
|
||||
ng-disabled="state._disabled || form.disabled"
|
||||
ng-click="vm.search()">
|
||||
<i class="fa fa-search"></i>
|
||||
</button>
|
||||
</span>
|
||||
@ -21,4 +22,9 @@
|
||||
|
||||
<at-input-message></at-input-message>
|
||||
</div>
|
||||
|
||||
<at-modal state="vm.lookup">
|
||||
<at-search></at-search>
|
||||
<at-table></at-table>
|
||||
</at-modal>
|
||||
</div>
|
||||
|
||||
@ -8,7 +8,8 @@
|
||||
<h4 class="modal-title at-Modal-title">{{ title }}</h4>
|
||||
</div>
|
||||
<div class="modal-body at-Modal-body">
|
||||
<p>{{ message }}</p>
|
||||
<p ng-show="message">{{ message }}</p>
|
||||
<ng-transclude></ng-transclude>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn at-ButtonHollow--white" ng-click="vm.hide()">
|
||||
|
||||
@ -18,12 +18,16 @@ function AtTabGroupController ($state) {
|
||||
};
|
||||
|
||||
vm.register = tab => {
|
||||
if (vm.tabs.length === 0) {
|
||||
tab.active = true;
|
||||
} else {
|
||||
tab.disabled = true;
|
||||
}
|
||||
|
||||
tab.active = true;
|
||||
/*
|
||||
* if (vm.tabs.length === 0) {
|
||||
* tab.active = true;
|
||||
* } else {
|
||||
* tab.disabled = true;
|
||||
* }
|
||||
*
|
||||
*/
|
||||
vm.tabs.push(tab);
|
||||
};
|
||||
}
|
||||
|
||||
@ -19,6 +19,11 @@ function AtTabController ($state) {
|
||||
|
||||
group.register(scope);
|
||||
};
|
||||
|
||||
vm.go = () => {
|
||||
console.log('test');
|
||||
$state.go('credentials.edit.permissions', { credential_id: 2 });
|
||||
};
|
||||
}
|
||||
|
||||
AtTabController.$inject = ['$state'];
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<button class="btn at-ButtonHollow--white at-Tab"
|
||||
ng-attr-disabled="{{ disabled || undefined }}"
|
||||
ng-class="{ 'at-Tab--active': active, 'at-Tab--disabled': disabled }">
|
||||
ng-class="{ 'at-Tab--active': active, 'at-Tab--disabled': disabled }"
|
||||
ng-click="vm.go()">
|
||||
<ng-transclude></ng-transclude>
|
||||
</button>
|
||||
|
||||
@ -40,7 +40,11 @@ function httpPost (data) {
|
||||
data
|
||||
};
|
||||
|
||||
return $http(req).then(res => res);
|
||||
return $http(req).then(res => {
|
||||
this.model.GET = res.data;
|
||||
|
||||
return res;
|
||||
});
|
||||
}
|
||||
|
||||
function httpPut (changes) {
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
|
||||
export default ['$scope', 'ListDefinition', 'Dataset', 'Wait', 'Rest', 'ProcessErrors', 'Prompt', '$state',
|
||||
function($scope, list, Dataset, Wait, Rest, ProcessErrors, Prompt, $state) {
|
||||
|
||||
init();
|
||||
|
||||
function init() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user