Merge pull request #2820 from Haokun-Chen/2815

show client id and secret when create application
This commit is contained in:
Haokun Chen 2018-08-13 16:30:34 -04:00 committed by GitHub
commit 15480a56db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 67 additions and 22 deletions

View File

@ -1,3 +1,16 @@
@import 'portalMode/_index';
@import 'output/_index';
@import 'users/tokens/_index';
/** @define Popup Modal after create new token and applicaiton and save form */
.PopupModal {
display: flex;
}
.PopupModal-label {
font-weight: bold;
width: 130px;
}
.PopupModal-value {
width: 70%;
}

View File

@ -1,4 +1,4 @@
function AddApplicationsController (models, $state, strings, $scope) {
function AddApplicationsController (models, $state, strings, $scope, Alert, $filter) {
const vm = this || {};
const { application, me, organization } = models;
@ -60,6 +60,41 @@ function AddApplicationsController (models, $state, strings, $scope) {
};
vm.form.onSaveSuccess = res => {
if (res.data && res.data.client_id) {
const name = res.data.name ?
`<div class="PopupModal">
<div class="PopupModal-label">
${strings.get('add.NAME_LABEL')}
</div>
<div class="PopupModal-value">
${res.data.name}
</div>
</div>` : '';
const clientId = res.data.client_id ?
`<div class="PopupModal">
<div class="PopupModal-label">
${strings.get('add.CLIENT_ID_LABEL')}
</div>
<div class="PopupModal-value">
${res.data.client_id}
</div>
</div>` : '';
const clientSecret = res.data.client_secret ?
`<div class="PopupModal">
<div class="PopupModal-label">
${strings.get('add.CLIENT_SECRECT_LABEL')}
</div>
<div class="PopupModal-value">
${res.data.client_secret}
</div>
</div>` : '';
Alert(strings.get('add.MODAL_HEADER'), `
${$filter('sanitize')(name)}
${clientId}
${clientSecret}
`, null, null, null, null, null, true);
}
$state.go('applications.edit', { application_id: res.data.id }, { reload: true });
};
@ -74,7 +109,9 @@ AddApplicationsController.$inject = [
'resolvedModels',
'$state',
'ApplicationsStrings',
'$scope'
'$scope',
'Alert',
'$filter',
];
export default AddApplicationsController;

View File

@ -21,7 +21,11 @@ function ApplicationsStrings (BaseString) {
};
ns.add = {
PANEL_TITLE: t.s('NEW APPLICATION')
PANEL_TITLE: t.s('NEW APPLICATION'),
CLIENT_ID_LABEL: t.s('CLIENT ID'),
CLIENT_SECRECT_LABEL: t.s('CLIENT SECRET'),
MODAL_HEADER: t.s('APPLICATION INFORMATION'),
NAME_LABEL: t.s('NAME'),
};
ns.list = {

View File

@ -1,9 +0,0 @@
/** @define TokenModal */
.TokenModal {
display: flex;
}
.TokenModal-label {
font-weight: bold;
width: 130px;
}

View File

@ -58,30 +58,30 @@ function AddTokensController (
return postToken
.then(({ data }) => {
const refreshHTML = data.refresh_token ?
`<div class="TokenModal">
<div class="TokenModal-label">
`<div class="PopupModal">
<div class="PopupModal-label">
${strings.get('add.REFRESH_TOKEN_LABEL')}
</div>
<div class="TokenModal-value">
<div class="PopupModal-value">
${data.refresh_token}
</div>
</div>` : '';
Alert(strings.get('add.TOKEN_MODAL_HEADER'), `
<div class="TokenModal">
<div class="TokenModal-label">
<div class="PopupModal">
<div class="PopupModal-label">
${strings.get('add.TOKEN_LABEL')}
</div>
<div class="TokenModal-value">
<div class="PopupModal-value">
${data.token}
</div>
</div>
${refreshHTML}
<div class="TokenModal">
<div class="TokenModal-label">
<div class="PopupModal">
<div class="PopupModal-label">
${strings.get('add.TOKEN_EXPIRES_LABEL')}
</div>
<div class="TokenModal-value">
<div class="PopupModal-value">
${$filter('longDate')(data.expires)}
</div>
</div>