update users token crud list to utilize string file

This commit is contained in:
John Mitchell 2018-03-16 15:56:30 -04:00
parent e7a0bbb5db
commit 8babac49a6
No known key found for this signature in database
GPG Key ID: FE6A9B5BD4EB5C94
4 changed files with 23 additions and 13 deletions

View File

@ -15,11 +15,21 @@ function TokensStrings (BaseString) {
};
ns.add = {
PANEL_TITLE: t.s('CREATE TOKEN')
PANEL_TITLE: t.s('CREATE TOKEN'),
APP_PLACEHOLDER: t.s('SELECT AN APPLICATION'),
SCOPE_HELP_TEXT: t.s('Specify a scope for the token\'s access'),
TOKEN_MODAL_HEADER: t.s('TOKEN INFORMATION'),
TOKEN_LABEL: t.s('TOKEN'),
REFRESH_TOKEN_LABEL: t.s('REFRESH TOKEN'),
TOKEN_EXPIRES_LABEL: t.s('EXPIRES'),
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')
};
ns.list = {
ROW_ITEM_LABEL_EXPIRED: t.s('DESCRIPTION'),
ROW_ITEM_LABEL_DESCRIPTION: t.s('DESCRIPTION'),
ROW_ITEM_LABEL_EXPIRED: t.s('EXPIRATION'),
ROW_ITEM_LABEL_USED: t.s('LAST USED')
};

View File

@ -22,14 +22,14 @@ function AddTokensController (models, $state, strings, Rest, Alert, Wait, GetBas
vm.form.application._resource = 'application';
vm.form.application._route = 'users.edit.tokens.add.application';
vm.form.application._model = application;
vm.form.application._placeholder = strings.get('SELECT AN APPLICATION');
vm.form.application._placeholder = strings.get('add.APP_PLACEHOLDER');
vm.form.application.required = true;
vm.form.description.required = false;
vm.form.scope = {
choices: ['', 'read', 'write'],
help_text: 'Specify a scope for the token\'s access',
help_text: strings.get('add.SCOPE_HELP_TEXT'),
id: 'scope',
label: 'Scope',
required: true,
@ -43,10 +43,10 @@ function AddTokensController (models, $state, strings, Rest, Alert, Wait, GetBas
Rest.setUrl(GetBasePath('users') + $state.params.user_id + '/authorized_tokens');
return Rest.post(data)
.then(({data}) => {
Alert('TOKEN INFORMATION', `
Alert(strings.get('add.TOKEN_MODAL_HEADER'), `
<div class="TokenModal">
<div class="TokenModal-label">
TOKEN
${strings.get('add.TOKEN_LABEL')}
</div>
<div class="TokenModal-value">
${data.token}
@ -54,7 +54,7 @@ function AddTokensController (models, $state, strings, Rest, Alert, Wait, GetBas
</div>
<div class="TokenModal">
<div class="TokenModal-label">
REFRESH TOKEN
${strings.get('add.REFRESH_TOKEN_LABEL')}
</div>
<div class="TokenModal-value">
${data.refresh_token}
@ -62,7 +62,7 @@ function AddTokensController (models, $state, strings, Rest, Alert, Wait, GetBas
</div>
<div class="TokenModal">
<div class="TokenModal-label">
EXPIRES
${strings.get('add.TOKEN_EXPIRES_LABEL')}
</div>
<div class="TokenModal-value">
${$filter('longDate')(data.expires)}
@ -73,8 +73,8 @@ function AddTokensController (models, $state, strings, Rest, Alert, Wait, GetBas
})
.catch(({data, status}) => {
ProcessErrors($scope, data, status, null, {
hdr: 'COULD NOT CREATE TOKEN',
msg: `Returned status: ${status}`
hdr: strings.get('add.ERROR_HEADER'),
msg: `${strings.get('add.ERROR_BODY_LABEL')} ${status}`
});
Wait('stop');
});

View File

@ -23,7 +23,7 @@ export default {
params: {
},
ncyBreadcrumb: {
label: N_("ADD TOKEN")
label: N_("CREATE TOKEN")
},
views: {
'preFormView@users.edit': {

View File

@ -50,7 +50,7 @@ function ListTokensController (
const { username, id } = _.get(user, 'summary_fields.last_used', {});
if (username && id) {
html += ` by <a href="/#/users/${id}">${$filter('sanitize')(username)}</a>`;
html += ` ${strings.get('add.LAST_USED_LABEL')} <a href="/#/users/${id}">${$filter('sanitize')(username)}</a>`;
}
return html;
@ -98,7 +98,7 @@ function ListTokensController (
resourceName: 'token',
body: deleteModalBody,
action,
actionText: 'DELETE'
actionText: strings.get('add.DELETE_ACTION_LABEL')
});
};
}