mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
move users tokens to features folder
This commit is contained in:
parent
8babac49a6
commit
cbc20093d7
@ -1 +1,2 @@
|
||||
@import 'credentials/_index';
|
||||
@import 'users/tokens/_index';
|
||||
|
||||
@ -5,6 +5,7 @@ import atLibModels from '~models';
|
||||
import atFeaturesApplications from '~features/applications';
|
||||
import atFeaturesCredentials from '~features/credentials';
|
||||
import atFeaturesTemplates from '~features/templates';
|
||||
import atFeaturesUsers from '~features/users';
|
||||
|
||||
const MODULE_NAME = 'at.features';
|
||||
|
||||
@ -14,7 +15,8 @@ angular.module(MODULE_NAME, [
|
||||
atLibModels,
|
||||
atFeaturesApplications,
|
||||
atFeaturesCredentials,
|
||||
atFeaturesTemplates
|
||||
atFeaturesTemplates,
|
||||
atFeaturesUsers
|
||||
]);
|
||||
|
||||
export default MODULE_NAME;
|
||||
|
||||
8
awx/ui/client/features/users/index.js
Normal file
8
awx/ui/client/features/users/index.js
Normal file
@ -0,0 +1,8 @@
|
||||
import atFeaturesUsersTokens from '~features/users/tokens';
|
||||
|
||||
const MODULE_NAME = 'at.features.users';
|
||||
|
||||
angular
|
||||
.module(MODULE_NAME, [atFeaturesUsersTokens]);
|
||||
|
||||
export default MODULE_NAME;
|
||||
@ -7,6 +7,3 @@
|
||||
font-weight: bold;
|
||||
width: 130px;
|
||||
}
|
||||
|
||||
.TokenModal-value {
|
||||
}
|
||||
9
awx/ui/client/features/users/tokens/index.js
Normal file
9
awx/ui/client/features/users/tokens/index.js
Normal file
@ -0,0 +1,9 @@
|
||||
import TokensStrings from './tokens.strings';
|
||||
|
||||
const MODULE_NAME = 'at.features.users.tokens';
|
||||
|
||||
angular
|
||||
.module(MODULE_NAME, [])
|
||||
.service('TokensStrings', TokensStrings);
|
||||
|
||||
export default MODULE_NAME;
|
||||
@ -25,7 +25,10 @@ function TokensStrings (BaseString) {
|
||||
ERROR_HEADER: t.s('COULD NOT CREATE TOKEN'),
|
||||
ERROR_BODY_LABEL: t.s('Returned status:'),
|
||||
LAST_USED_LABEL: t.s('by'),
|
||||
DELETE_ACTION_LABEL: t.s('DELETE')
|
||||
DELETE_ACTION_LABEL: t.s('DELETE'),
|
||||
SCOPE_PLACEHOLDER: t.s('Select a scope'),
|
||||
SCOPE_READ_LABEL: t.s('Read'),
|
||||
SCOPE_WRITE_LABEL: t.s('Write')
|
||||
};
|
||||
|
||||
ns.list = {
|
||||
@ -33,27 +33,25 @@ export default {
|
||||
}
|
||||
},
|
||||
resolve: {
|
||||
ListDefinition: [() => {
|
||||
return {
|
||||
name: 'applications',
|
||||
iterator: 'application',
|
||||
hover: true,
|
||||
index: false,
|
||||
fields: {
|
||||
name: {
|
||||
key: true,
|
||||
label: 'Name',
|
||||
columnClass: 'col-lg-4 col-md-6 col-sm-8 col-xs-8',
|
||||
awToolTip: '{{application.description | sanitize}}',
|
||||
dataPlacement: 'top'
|
||||
},
|
||||
ListDefinition: [() => ({
|
||||
name: 'applications',
|
||||
iterator: 'application',
|
||||
hover: true,
|
||||
index: false,
|
||||
fields: {
|
||||
name: {
|
||||
key: true,
|
||||
label: 'Name',
|
||||
columnClass: 'col-lg-4 col-md-6 col-sm-8 col-xs-8',
|
||||
awToolTip: '{{application.description | sanitize}}',
|
||||
dataPlacement: 'top'
|
||||
},
|
||||
actions: {
|
||||
},
|
||||
fieldActions: {
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
},
|
||||
fieldActions: {
|
||||
}
|
||||
}],
|
||||
})],
|
||||
Dataset: ['QuerySet', 'GetBasePath', '$stateParams', 'ListDefinition',
|
||||
(qs, GetBasePath, $stateParams, list) => qs.search(
|
||||
GetBasePath('applications'),
|
||||
@ -68,4 +66,4 @@ export default {
|
||||
$('body').removeClass('modal-open');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1,4 +1,7 @@
|
||||
function AddTokensController (models, $state, strings, Rest, Alert, Wait, GetBasePath, $filter) {
|
||||
function AddTokensController (
|
||||
models, $state, strings, Rest, Alert, Wait, GetBasePath,
|
||||
$filter, ProcessErrors
|
||||
) {
|
||||
const vm = this || {};
|
||||
const { application } = models;
|
||||
|
||||
@ -28,21 +31,29 @@ function AddTokensController (models, $state, strings, Rest, Alert, Wait, GetBas
|
||||
vm.form.description.required = false;
|
||||
|
||||
vm.form.scope = {
|
||||
choices: ['', 'read', 'write'],
|
||||
choices: [
|
||||
'',
|
||||
'read',
|
||||
'write'
|
||||
],
|
||||
help_text: strings.get('add.SCOPE_HELP_TEXT'),
|
||||
id: 'scope',
|
||||
label: 'Scope',
|
||||
required: true,
|
||||
_component: 'at-input-select',
|
||||
_data: ['', 'read', 'write'],
|
||||
_data: [
|
||||
strings.get('add.SCOPE_PLACEHOLDER'),
|
||||
strings.get('add.SCOPE_READ_LABEL'),
|
||||
strings.get('add.SCOPE_WRITE_LABEL')
|
||||
],
|
||||
_exp: 'choice for (index, choice) in state._data',
|
||||
_format: 'array'
|
||||
}
|
||||
};
|
||||
|
||||
vm.form.save = data => {
|
||||
Rest.setUrl(GetBasePath('users') + $state.params.user_id + '/authorized_tokens');
|
||||
return Rest.post(data)
|
||||
.then(({data}) => {
|
||||
vm.form.save = payload => {
|
||||
Rest.setUrl(`${GetBasePath('users')}${$state.params.user_id}/authorized_tokens`);
|
||||
return Rest.post(payload)
|
||||
.then(({ data }) => {
|
||||
Alert(strings.get('add.TOKEN_MODAL_HEADER'), `
|
||||
<div class="TokenModal">
|
||||
<div class="TokenModal-label">
|
||||
@ -71,8 +82,8 @@ function AddTokensController (models, $state, strings, Rest, Alert, Wait, GetBas
|
||||
`, null, null, null, null, null, true);
|
||||
Wait('stop');
|
||||
})
|
||||
.catch(({data, status}) => {
|
||||
ProcessErrors($scope, data, status, null, {
|
||||
.catch(({ data, status }) => {
|
||||
ProcessErrors(null, data, status, null, {
|
||||
hdr: strings.get('add.ERROR_HEADER'),
|
||||
msg: `${strings.get('add.ERROR_BODY_LABEL')} ${status}`
|
||||
});
|
||||
@ -80,7 +91,7 @@ function AddTokensController (models, $state, strings, Rest, Alert, Wait, GetBas
|
||||
});
|
||||
};
|
||||
|
||||
vm.form.onSaveSuccess = res => {
|
||||
vm.form.onSaveSuccess = () => {
|
||||
$state.go('^', { user_id: $state.params.user_id }, { reload: true });
|
||||
};
|
||||
}
|
||||
@ -88,12 +99,13 @@ function AddTokensController (models, $state, strings, Rest, Alert, Wait, GetBas
|
||||
AddTokensController.$inject = [
|
||||
'resolvedModels',
|
||||
'$state',
|
||||
'ApplicationsStrings',
|
||||
'TokensStrings',
|
||||
'Rest',
|
||||
'Alert',
|
||||
'Wait',
|
||||
'GetBasePath',
|
||||
'$filter'
|
||||
'$filter',
|
||||
'ProcessErrors'
|
||||
];
|
||||
|
||||
export default AddTokensController;
|
||||
@ -1,10 +1,9 @@
|
||||
import { N_ } from '../i18n';
|
||||
import { N_ } from '../../../src/i18n';
|
||||
import AddController from './users-tokens-add.controller';
|
||||
|
||||
const addTemplate = require('~src/users/users-tokens-add.partial.html');
|
||||
const addTemplate = require('~features/users/tokens/users-tokens-add.partial.html');
|
||||
|
||||
function TokensDetailResolve ($q, Application) {
|
||||
|
||||
const promises = {};
|
||||
|
||||
promises.application = new Application('options');
|
||||
@ -18,12 +17,12 @@ TokensDetailResolve.$inject = [
|
||||
];
|
||||
|
||||
export default {
|
||||
url: "/add-token",
|
||||
url: '/add-token',
|
||||
name: 'users.edit.tokens.add',
|
||||
params: {
|
||||
},
|
||||
ncyBreadcrumb: {
|
||||
label: N_("CREATE TOKEN")
|
||||
label: N_('CREATE TOKEN')
|
||||
},
|
||||
views: {
|
||||
'preFormView@users.edit': {
|
||||
@ -47,7 +47,7 @@ function ListTokensController (
|
||||
|
||||
let html = $filter('longDate')(lastUsed);
|
||||
|
||||
const { username, id } = _.get(user, 'summary_fields.last_used', {});
|
||||
const { username, id } = _.get(token, 'summary_fields.last_used', {});
|
||||
|
||||
if (username && id) {
|
||||
html += ` ${strings.get('add.LAST_USED_LABEL')} <a href="/#/users/${id}">${$filter('sanitize')(username)}</a>`;
|
||||
@ -1,19 +1,17 @@
|
||||
import { N_ } from '../i18n';
|
||||
import { N_ } from '../../../src/i18n';
|
||||
|
||||
import ListController from './users-tokens-list.controller';
|
||||
|
||||
const listTemplate = require('~src/users/users-tokens-list.partial.html');
|
||||
const listTemplate = require('~features/users/tokens/users-tokens-list.partial.html');
|
||||
|
||||
export default {
|
||||
url: "/tokens",
|
||||
url: '/tokens',
|
||||
name: 'users.edit.tokens',
|
||||
params: {
|
||||
},
|
||||
ncyBreadcrumb: {
|
||||
label: N_("TOKENS")
|
||||
label: N_('TOKENS')
|
||||
},
|
||||
views: {
|
||||
'related': {
|
||||
related: {
|
||||
templateUrl: listTemplate,
|
||||
controller: ListController,
|
||||
controllerAs: 'vm'
|
||||
@ -36,7 +34,7 @@ export default {
|
||||
'QuerySet',
|
||||
($stateParams, Wait, GetBasePath, qs) => {
|
||||
const searchParam = $stateParams.token_search;
|
||||
const searchPath = GetBasePath('users') + $stateParams.user_id + '/tokens';
|
||||
const searchPath = `${GetBasePath('users')}${$stateParams.user_id}/tokens`;
|
||||
Wait('start');
|
||||
return qs.search(searchPath, searchParam)
|
||||
.finally(() => {
|
||||
@ -12,7 +12,7 @@
|
||||
|
||||
<select class="form-control at-InputSelect-select"
|
||||
ng-model="state._value"
|
||||
ng-attr-tabindex="{{ tab || undefined }}"
|
||||
ng-attr-tabindex="{{ tab || undefined }}"
|
||||
ng-disabled="state._disabled || form.disabled"
|
||||
ng-options="{{ state._exp }}">
|
||||
<option style="display:none"></option>
|
||||
|
||||
@ -136,7 +136,6 @@
|
||||
@import '../../src/tooltip/tooltip.block.less';
|
||||
@import '../../src/workflow-results/workflow-status-bar/workflow-status-bar.block.less';
|
||||
@import '../../src/workflow-results/workflow-results.block.less';
|
||||
@import '../../src/users/token-modal.block.less';
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -9,10 +9,10 @@ import UsersAdd from './add/users-add.controller';
|
||||
import UsersEdit from './edit/users-edit.controller';
|
||||
import UserForm from './users.form';
|
||||
import UserList from './users.list';
|
||||
import UserTokensListRoute from './users-tokens-list.route';
|
||||
import UserTokensAddRoute from './users-tokens-add.route';
|
||||
import UserTokensAddApplicationRoute from './users-tokens-add-application.route';
|
||||
import TokensStrings from './tokens.strings';
|
||||
|
||||
import UserTokensListRoute from '../../features/users/tokens/users-tokens-list.route';
|
||||
import UserTokensAddRoute from '../../features/users/tokens/users-tokens-add.route';
|
||||
import UserTokensAddApplicationRoute from '../../features/users/tokens/users-tokens-add-application.route';
|
||||
|
||||
import { N_ } from '../i18n';
|
||||
|
||||
@ -23,8 +23,6 @@ angular.module('Users', [])
|
||||
.controller('UsersEdit', UsersEdit)
|
||||
.factory('UserForm', UserForm)
|
||||
.factory('UserList', UserList)
|
||||
.service('TokensStrings', TokensStrings)
|
||||
|
||||
.config(['$stateProvider', 'stateDefinitionsProvider', '$stateExtenderProvider',
|
||||
function($stateProvider, stateDefinitionsProvider, $stateExtenderProvider) {
|
||||
let stateDefinitions = stateDefinitionsProvider.$get();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user