|
|
@ -34,6 +34,9 @@ import { AuthService } from '@core/auth/auth.service'; |
|
|
import { ActivatedRoute } from '@angular/router'; |
|
|
import { ActivatedRoute } from '@angular/router'; |
|
|
import { isDefinedAndNotNull } from '@core/utils'; |
|
|
import { isDefinedAndNotNull } from '@core/utils'; |
|
|
import { getCurrentAuthUser } from '@core/auth/auth.selectors'; |
|
|
import { getCurrentAuthUser } from '@core/auth/auth.selectors'; |
|
|
|
|
|
import { ActionNotificationShow } from '@core/notification/notification.actions'; |
|
|
|
|
|
import { DatePipe } from '@angular/common'; |
|
|
|
|
|
import { ClipboardService } from 'ngx-clipboard'; |
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
|
selector: 'tb-profile', |
|
|
selector: 'tb-profile', |
|
|
@ -48,6 +51,19 @@ export class ProfileComponent extends PageComponent implements OnInit, HasConfir |
|
|
languageList = env.supportedLangs; |
|
|
languageList = env.supportedLangs; |
|
|
private readonly authUser: AuthUser; |
|
|
private readonly authUser: AuthUser; |
|
|
|
|
|
|
|
|
|
|
|
get jwtToken(): string { |
|
|
|
|
|
return `Bearer ${localStorage.getItem('jwt_token')}`; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
get jwtTokenExpiration(): string { |
|
|
|
|
|
return localStorage.getItem('jwt_token_expiration'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
get expirationJwtData(): string { |
|
|
|
|
|
const expirationData = this.datePipe.transform(this.jwtTokenExpiration, 'yyyy-MM-dd HH:mm:ss'); |
|
|
|
|
|
return this.translate.instant('profile.valid-till', { expirationData }); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
constructor(protected store: Store<AppState>, |
|
|
constructor(protected store: Store<AppState>, |
|
|
private route: ActivatedRoute, |
|
|
private route: ActivatedRoute, |
|
|
private userService: UserService, |
|
|
private userService: UserService, |
|
|
@ -55,7 +71,9 @@ export class ProfileComponent extends PageComponent implements OnInit, HasConfir |
|
|
private translate: TranslateService, |
|
|
private translate: TranslateService, |
|
|
public dialog: MatDialog, |
|
|
public dialog: MatDialog, |
|
|
public dialogService: DialogService, |
|
|
public dialogService: DialogService, |
|
|
public fb: FormBuilder) { |
|
|
public fb: FormBuilder, |
|
|
|
|
|
private datePipe: DatePipe, |
|
|
|
|
|
private clipboardService: ClipboardService) { |
|
|
super(store); |
|
|
super(store); |
|
|
this.authUser = getCurrentAuthUser(this.store); |
|
|
this.authUser = getCurrentAuthUser(this.store); |
|
|
} |
|
|
} |
|
|
@ -141,4 +159,24 @@ export class ProfileComponent extends PageComponent implements OnInit, HasConfir |
|
|
return this.authUser.authority === Authority.SYS_ADMIN; |
|
|
return this.authUser.authority === Authority.SYS_ADMIN; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
copyToken() { |
|
|
|
|
|
if (+this.jwtTokenExpiration < Date.now()) { |
|
|
|
|
|
this.store.dispatch(new ActionNotificationShow({ |
|
|
|
|
|
message: this.translate.instant('profile.tokenCopiedWarnMessage'), |
|
|
|
|
|
type: 'warn', |
|
|
|
|
|
duration: 1500, |
|
|
|
|
|
verticalPosition: 'bottom', |
|
|
|
|
|
horizontalPosition: 'right' |
|
|
|
|
|
})); |
|
|
|
|
|
} else { |
|
|
|
|
|
this.clipboardService.copyFromContent(this.jwtToken); |
|
|
|
|
|
this.store.dispatch(new ActionNotificationShow({ |
|
|
|
|
|
message: this.translate.instant('profile.tokenCopiedSuccessMessage'), |
|
|
|
|
|
type: 'success', |
|
|
|
|
|
duration: 750, |
|
|
|
|
|
verticalPosition: 'bottom', |
|
|
|
|
|
horizontalPosition: 'right' |
|
|
|
|
|
})); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|