Browse Source

Add button Copy JWT token to profile

pull/5262/head
ArtemDzhereleiko 5 years ago
parent
commit
06708c4746
  1. 9
      ui-ngx/src/app/modules/home/pages/profile/profile.component.html
  2. 23
      ui-ngx/src/app/modules/home/pages/profile/profile.component.ts
  3. 5
      ui-ngx/src/assets/locale/locale.constant-en_US.json
  4. 5
      ui-ngx/src/assets/locale/locale.constant-ru_RU.json
  5. 5
      ui-ngx/src/assets/locale/locale.constant-uk_UA.json

9
ui-ngx/src/app/modules/home/pages/profile/profile.component.html

@ -84,6 +84,15 @@
{{'profile.change-password' | translate}}
</button>
</div>
<div fxLayout="row" fxLayoutAlign=" center" style="padding-bottom: 16px;">
<button mat-raised-button ngxClipboard
(cbOnSuccess)="onTokenCopied($event)"
[cbContent]="token">
<mat-icon svgIcon="mdi:clipboard-arrow-left"></mat-icon>
<span>{{ 'profile.copy-jwt-token' | translate }}</span>
</button>
<span style="padding: 10px; opacity: 0.7;">{{getExpirationDate}}</span>
</div>
<div fxLayout="row" class="layout-wrap">
<span fxFlex></span>
<button mat-button mat-raised-button color="primary"

23
ui-ngx/src/app/modules/home/pages/profile/profile.component.ts

@ -34,6 +34,8 @@ import { AuthService } from '@core/auth/auth.service';
import { ActivatedRoute } from '@angular/router';
import { isDefinedAndNotNull } from '@core/utils';
import { getCurrentAuthUser } from '@core/auth/auth.selectors';
import {ActionNotificationShow} from "@core/notification/notification.actions";
import { DatePipe } from '@angular/common';
@Component({
selector: 'tb-profile',
@ -48,6 +50,15 @@ export class ProfileComponent extends PageComponent implements OnInit, HasConfir
languageList = env.supportedLangs;
private readonly authUser: AuthUser;
get token() {
return `Bearer ${localStorage.getItem('jwt_token')}`;
}
get getExpirationDate() {
const expirationData = this.datePipe.transform(localStorage.getItem('jwt_token_expiration'), 'yyyy-MM-dd HH:mm:ss');
return this.translate.instant('profile.valid-till', {expirationData});
};
constructor(protected store: Store<AppState>,
private route: ActivatedRoute,
private userService: UserService,
@ -55,7 +66,8 @@ export class ProfileComponent extends PageComponent implements OnInit, HasConfir
private translate: TranslateService,
public dialog: MatDialog,
public dialogService: DialogService,
public fb: FormBuilder) {
public fb: FormBuilder,
private datePipe: DatePipe) {
super(store);
this.authUser = getCurrentAuthUser(this.store);
}
@ -141,4 +153,13 @@ export class ProfileComponent extends PageComponent implements OnInit, HasConfir
return this.authUser.authority === Authority.SYS_ADMIN;
}
onTokenCopied($event) {
this.store.dispatch(new ActionNotificationShow({
message: this.translate.instant('profile.tokenCopiedMessage'),
type: 'success',
duration: 750,
verticalPosition: 'bottom',
horizontalPosition: 'right'
}));
}
}

5
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -2364,7 +2364,10 @@
"profile": "Profile",
"last-login-time": "Last Login",
"change-password": "Change Password",
"current-password": "Current password"
"current-password": "Current password",
"copy-jwt-token": "Copy JWT token",
"valid-till": "Valid till {{expirationData}}",
"tokenCopiedMessage": "JWT token has been copied to clipboard"
},
"relation": {
"relations": "Relations",

5
ui-ngx/src/assets/locale/locale.constant-ru_RU.json

@ -1262,7 +1262,10 @@
"profile": "Профиль",
"last-login-time": "Время последнего входа в систему",
"change-password": "Изменить пароль",
"current-password": "Текущий пароль"
"current-password": "Текущий пароль",
"copy-jwt-token": "Копировать JWT токен",
"valid-till": "Годен до {{expirationData}}",
"tokenCopiedMessage": "JWT токен скопирован в буфер обмена"
},
"relation": {
"relations": "Отношения",

5
ui-ngx/src/assets/locale/locale.constant-uk_UA.json

@ -1677,7 +1677,10 @@
"profile": "Профіль",
"last-login-time": "Час останнього входу",
"change-password": "Змінити пароль",
"current-password": "Поточний пароль"
"current-password": "Поточний пароль",
"copy-jwt-token": "Копіювати JWT токен",
"valid-till": "Придатний до {{expirationData}}",
"tokenCopiedMessage": "JWT токен скопійовано в буфер обміну"
},
"relation": {
"relations": "Відношення",

Loading…
Cancel
Save