|
@@ -36,6 +36,7 @@ import { isDefinedAndNotNull } from '@core/utils'; |
|
@@ -36,6 +36,7 @@ import { isDefinedAndNotNull } from '@core/utils'; |
36
|
import { getCurrentAuthUser } from '@core/auth/auth.selectors';
|
36
|
import { getCurrentAuthUser } from '@core/auth/auth.selectors';
|
37
|
import { ActionNotificationShow } from '@core/notification/notification.actions';
|
37
|
import { ActionNotificationShow } from '@core/notification/notification.actions';
|
38
|
import { DatePipe } from '@angular/common';
|
38
|
import { DatePipe } from '@angular/common';
|
|
|
39
|
+import { ClipboardService } from 'ngx-clipboard';
|
39
|
|
40
|
|
40
|
@Component({
|
41
|
@Component({
|
41
|
selector: 'tb-profile',
|
42
|
selector: 'tb-profile',
|
|
@@ -54,8 +55,12 @@ export class ProfileComponent extends PageComponent implements OnInit, HasConfir |
|
@@ -54,8 +55,12 @@ export class ProfileComponent extends PageComponent implements OnInit, HasConfir |
54
|
return `Bearer ${localStorage.getItem('jwt_token')}`;
|
55
|
return `Bearer ${localStorage.getItem('jwt_token')}`;
|
55
|
}
|
56
|
}
|
56
|
|
57
|
|
|
|
58
|
+ get jwtTokenExpiration(): string {
|
|
|
59
|
+ return localStorage.getItem('jwt_token_expiration');
|
|
|
60
|
+ }
|
|
|
61
|
+
|
57
|
get expirationJwtData(): string {
|
62
|
get expirationJwtData(): string {
|
58
|
- const expirationData = this.datePipe.transform(localStorage.getItem('jwt_token_expiration'), 'yyyy-MM-dd HH:mm:ss');
|
63
|
+ const expirationData = this.datePipe.transform(this.jwtTokenExpiration, 'yyyy-MM-dd HH:mm:ss');
|
59
|
return this.translate.instant('profile.valid-till', { expirationData });
|
64
|
return this.translate.instant('profile.valid-till', { expirationData });
|
60
|
}
|
65
|
}
|
61
|
|
66
|
|
|
@@ -67,7 +72,8 @@ export class ProfileComponent extends PageComponent implements OnInit, HasConfir |
|
@@ -67,7 +72,8 @@ export class ProfileComponent extends PageComponent implements OnInit, HasConfir |
67
|
public dialog: MatDialog,
|
72
|
public dialog: MatDialog,
|
68
|
public dialogService: DialogService,
|
73
|
public dialogService: DialogService,
|
69
|
public fb: FormBuilder,
|
74
|
public fb: FormBuilder,
|
70
|
- private datePipe: DatePipe) {
|
75
|
+ private datePipe: DatePipe,
|
|
|
76
|
+ private clipboardService: ClipboardService) {
|
71
|
super(store);
|
77
|
super(store);
|
72
|
this.authUser = getCurrentAuthUser(this.store);
|
78
|
this.authUser = getCurrentAuthUser(this.store);
|
73
|
}
|
79
|
}
|
|
@@ -153,13 +159,24 @@ export class ProfileComponent extends PageComponent implements OnInit, HasConfir |
|
@@ -153,13 +159,24 @@ export class ProfileComponent extends PageComponent implements OnInit, HasConfir |
153
|
return this.authUser.authority === Authority.SYS_ADMIN;
|
159
|
return this.authUser.authority === Authority.SYS_ADMIN;
|
154
|
}
|
160
|
}
|
155
|
|
161
|
|
156
|
- onTokenCopied() {
|
|
|
157
|
- this.store.dispatch(new ActionNotificationShow({
|
|
|
158
|
- message: this.translate.instant('profile.tokenCopiedMessage'),
|
|
|
159
|
- type: 'success',
|
|
|
160
|
- duration: 750,
|
|
|
161
|
- verticalPosition: 'bottom',
|
|
|
162
|
- horizontalPosition: 'right'
|
|
|
163
|
- }));
|
162
|
+ copyToken() {
|
|
|
163
|
+ if (+this.jwtTokenExpiration < Date.now()) {
|
|
|
164
|
+ this.store.dispatch(new ActionNotificationShow({
|
|
|
165
|
+ message: this.translate.instant('profile.tokenCopiedWarnMessage'),
|
|
|
166
|
+ type: 'warn',
|
|
|
167
|
+ duration: 1500,
|
|
|
168
|
+ verticalPosition: 'bottom',
|
|
|
169
|
+ horizontalPosition: 'right'
|
|
|
170
|
+ }));
|
|
|
171
|
+ } else {
|
|
|
172
|
+ this.clipboardService.copyFromContent(this.jwtToken);
|
|
|
173
|
+ this.store.dispatch(new ActionNotificationShow({
|
|
|
174
|
+ message: this.translate.instant('profile.tokenCopiedSuccessMessage'),
|
|
|
175
|
+ type: 'success',
|
|
|
176
|
+ duration: 750,
|
|
|
177
|
+ verticalPosition: 'bottom',
|
|
|
178
|
+ horizontalPosition: 'right'
|
|
|
179
|
+ }));
|
|
|
180
|
+ }
|
164
|
}
|
181
|
}
|
165
|
} |
182
|
} |