Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d0c280a

Browse files
Creates header with menu
1 parent 0f0e356 commit d0c280a

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<mat-toolbar color="primary">
2+
<mat-toolbar-row>
3+
<!-- <button mat-icon-button>
4+
<mat-icon>menu</mat-icon>
5+
</button> -->
6+
7+
<span>User Hub</span>
8+
<span class="spacer"></span>
9+
10+
<ng-container *ngIf="isAuthenticated$ | async">
11+
<button mat-button [routerLink]="'/users'">Users</button>
12+
<button mat-button [routerLink]="'/users/report'">Report</button>
13+
<button mat-icon-button [matMenuTriggerFor]="menu">
14+
<mat-icon>account_circle</mat-icon>
15+
</button>
16+
<mat-menu #menu="matMenu">
17+
<button mat-menu-item [routerLink]="'/users/profile'">Profile</button>
18+
<button mat-menu-item (click)="logOut()">Logout</button>
19+
</mat-menu>
20+
</ng-container>
21+
</mat-toolbar-row>
22+
</mat-toolbar>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.spacer {
2+
flex: 1 1 auto;
3+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { HeaderComponent } from './header.component';
4+
5+
describe('HeaderComponent', () => {
6+
let component: HeaderComponent;
7+
let fixture: ComponentFixture<HeaderComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
declarations: [ HeaderComponent ]
12+
})
13+
.compileComponents();
14+
15+
fixture = TestBed.createComponent(HeaderComponent);
16+
component = fixture.componentInstance;
17+
fixture.detectChanges();
18+
});
19+
20+
it('should create', () => {
21+
expect(component).toBeTruthy();
22+
});
23+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { Observable } from 'rxjs';
3+
import { AuthService } from '../../auth/auth.service';
4+
5+
@Component({
6+
selector: 'app-header',
7+
templateUrl: './header.component.html',
8+
styleUrls: ['./header.component.scss'],
9+
})
10+
export class HeaderComponent implements OnInit {
11+
isAuthenticated$: Observable<boolean> | undefined;
12+
13+
constructor(private authService: AuthService) {}
14+
15+
ngOnInit() {
16+
this.isAuthenticated$ = this.authService.isAuthenticated$;
17+
}
18+
19+
logOut() {
20+
this.authService.logout();
21+
}
22+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /