Skip to content
Snippets Groups Projects
Commit 03f8bc1b authored by Lukas Maximilian Kimpel's avatar Lukas Maximilian Kimpel
Browse files

Merge branch '107-navigation-main-pages' into 'master'

Resolve "navigation (main pages)"

Closes #107

See merge request swtp-block-ws17/arsnova-angular-frontend!101
parents 444f2974 82504e1c
Branches
Tags
1 merge request!101Resolve "navigation (main pages)"
Pipeline #13783 passed with stage
in 33 seconds
<mat-toolbar color="primary">
<mat-toolbar-row>
<span>ARSnova</span>
<button *ngIf="router.url !== '/home'" (click)="goBack()" mat-icon-button>
<mat-icon aria-label="Go back">keyboard_arrow_left</mat-icon>
</button>
<span class="app-title" (click)="goToHomepage()">ARSnova</span>
<span class="fill-remaining-space"></span>
<mat-menu #appMenu="matMenu" [overlapTrigger]="false">
<button mat-menu-item (click)="logout()">
......
.app-title {
cursor: pointer;
}
......@@ -3,6 +3,8 @@ import { AuthenticationService } from '../../../services/http/authentication.ser
import { NotificationService } from '../../../services/util/notification.service';
import { Router } from '@angular/router';
import { User } from '../../../models/user';
import { UserRole } from '../../../models/user-roles.enum';
import { Location } from '@angular/common';
@Component({
selector: 'app-header',
......@@ -12,13 +14,14 @@ import { User } from '../../../models/user';
export class HeaderComponent implements OnInit {
user: User;
constructor(private authenticationService: AuthenticationService,
constructor(public location: Location,
private authenticationService: AuthenticationService,
private notification: NotificationService,
public router: Router) {
}
ngOnInit() {
// Subscribe to user data
// Subscribe to user data (update component's user when user data changes: e.g. login, logout)
this.authenticationService.watchUser.subscribe(newUser => this.user = newUser);
}
......@@ -27,4 +30,25 @@ export class HeaderComponent implements OnInit {
this.notification.show(`Logged out`);
this.router.navigate(['/']);
}
goBack() {
this.location.back();
}
goToHomepage() {
const role: UserRole = this.user !== undefined ? this.user.role : undefined;
let route: string;
switch (role) {
case UserRole.PARTICIPANT:
route = '/participant';
break;
case UserRole.CREATOR:
route = '/creator';
break;
default:
route = '/';
}
this.router.navigate([route]);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment