From d6196d880f98e8988c2efc68486f895d4561fab1 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Thu, 4 Feb 2021 13:55:34 +0200 Subject: Added the admin panel to profile settings page; moved where isAdminUser is checked in profile page --- .../components/profile-settings/profile-settings.component.html | 1 + .../app/components/profile-settings/profile-settings.component.ts | 7 +++++++ .../src/app/components/profile/profile.component.ts | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.html b/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.html index d87c35c..f67940b 100644 --- a/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.html +++ b/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.html @@ -3,6 +3,7 @@

diff --git a/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.ts b/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.ts index 463b980..a484665 100644 --- a/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.ts +++ b/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.ts @@ -13,6 +13,7 @@ import { Language } from 'src/models/language'; import { Technology } from 'src/models/technology'; import { TokenService } from 'src/app/services/token.service'; import { Title } from '@angular/platform-browser'; +import { AppConstants } from 'src/app/app-constants.module'; @Component({ selector: 'app-profile-settings', @@ -24,6 +25,7 @@ export class ProfileSettingsComponent implements OnInit { @ViewChild(ErrorBarComponent) private _errorBar: ErrorBarComponent; @ViewChild(SuccessBarComponent) private _successBar: SuccessBarComponent; private _urlUsername: string; + public isAdminUser = false; public dataArrived = false; public deleteAccountConfirm = false; public showLanguages = false; @@ -51,6 +53,7 @@ export class ProfileSettingsComponent implements OnInit { this._userService.getUserByUsernameRequest(this._urlUsername).subscribe( (res: object) => { Object.assign(this.user, res); + this.isAdminUser = this.user.roles.map(x => x.name).includes(AppConstants.ADMIN_ROLE_NAME); this.finishUserLoading(); }, (err: HttpErrorResponse) => { @@ -262,6 +265,10 @@ export class ProfileSettingsComponent implements OnInit { this._router.navigate([this._router.url.substring(0, this._router.url.length - 9)]); } + navigateToAdminPanel(): void { + this._router.navigate(['/admin-panel']); + } + logout(): void { this._tokenService.logoutUserFromSessionStorage(); this.goToProfile(); diff --git a/src/DevHive.Angular/src/app/components/profile/profile.component.ts b/src/DevHive.Angular/src/app/components/profile/profile.component.ts index f364c0d..a60250c 100644 --- a/src/DevHive.Angular/src/app/components/profile/profile.component.ts +++ b/src/DevHive.Angular/src/app/components/profile/profile.component.ts @@ -53,6 +53,7 @@ export class ProfileComponent implements OnInit { this._userService.getUserByUsernameRequest(this._urlUsername).subscribe( (res: object) => { Object.assign(this.user, res); + this.isAdminUser = this.user.roles.map(x => x.name).includes(AppConstants.ADMIN_ROLE_NAME); this.loadLanguages(); }, (err: HttpErrorResponse) => { @@ -117,7 +118,6 @@ export class ProfileComponent implements OnInit { this.isTheLoggedInUser = true; } this.dataArrived = true; - this.isAdminUser = this.user.roles.map(x => x.name).includes(AppConstants.ADMIN_ROLE_NAME); }, (err: HttpErrorResponse) => { this.logout(); -- cgit v1.2.3