Initial commit for the Angular part. We are nowhere yet.
This commit is contained in:
0
bookie/src/app/home/home.component.css
Normal file
0
bookie/src/app/home/home.component.css
Normal file
16
bookie/src/app/home/home.component.html
Normal file
16
bookie/src/app/home/home.component.html
Normal file
@ -0,0 +1,16 @@
|
||||
<a mat-raised-button routerLink="/login" *ngIf="!(nameObject | async)">
|
||||
<mat-icon>account_box</mat-icon>
|
||||
Login</a>
|
||||
<a mat-raised-button routerLink="/guest-book/list">
|
||||
Guest Book
|
||||
</a>
|
||||
<a mat-raised-button routerLink="/running-tables">
|
||||
Sales
|
||||
</a>
|
||||
<a mat-raised-button routerLink="/tables">
|
||||
Tables
|
||||
</a>
|
||||
<a mat-raised-button routerLink="/logout" *ngIf="nameObject | async as name">
|
||||
<mat-icon>account_box</mat-icon>
|
||||
Logout {{name}}
|
||||
</a>
|
||||
25
bookie/src/app/home/home.component.spec.ts
Normal file
25
bookie/src/app/home/home.component.spec.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {HomeComponent} from './home.component';
|
||||
|
||||
describe('HomeComponent', () => {
|
||||
let component: HomeComponent;
|
||||
let fixture: ComponentFixture<HomeComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [HomeComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(HomeComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
25
bookie/src/app/home/home.component.ts
Normal file
25
bookie/src/app/home/home.component.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Subject} from "rxjs";
|
||||
import {AuthService} from "../auth/auth.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
templateUrl: './home.component.html',
|
||||
styleUrls: ['./home.component.css']
|
||||
})
|
||||
export class HomeComponent implements OnInit {
|
||||
public nameObject = new Subject<string>();
|
||||
|
||||
constructor(private auth: AuthService) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.auth.userObservable.subscribe((user) => {
|
||||
if (user.isAuthenticated) {
|
||||
this.nameObject.next(user.name);
|
||||
} else {
|
||||
this.nameObject.next(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user