Running tables: Initial working sample just shows a row of buttons
This commit is contained in:
parent
5093bdc391
commit
3dcf1c4c42
@ -9,6 +9,10 @@ const routes: Routes = [
|
||||
path: 'guest-book',
|
||||
loadChildren: () => import('./guest-book/guest-book.module').then(mod => mod.GuestBookModule)
|
||||
},
|
||||
{
|
||||
path: 'running-tables',
|
||||
loadChildren: () => import('./running-tables/running-tables.module').then(mod => mod.RunningTablesModule)
|
||||
},
|
||||
{
|
||||
path: 'tables',
|
||||
loadChildren: () => import('./tables/tables.module').then(mod => mod.TableModule)
|
||||
|
@ -0,0 +1,18 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot} from '@angular/router';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {Table} from "../core/table";
|
||||
import {TableService} from "../tables/table.service";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class RunningTablesResolver implements Resolve<Table[]> {
|
||||
|
||||
constructor(private ser: TableService, private router: Router) {
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Table[]> {
|
||||
return this.ser.list();
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
import { AuthGuard } from "../auth/auth-guard.service";
|
||||
import { RunningTablesComponent } from "./running-tables.component";
|
||||
import { RunningTablesResolver } from "./running-tables-resolver.service";
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: RunningTablesComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Guest Book'
|
||||
},
|
||||
resolve: {
|
||||
list: RunningTablesResolver
|
||||
}
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
component: RunningTablesComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Guest Book'
|
||||
},
|
||||
resolve: {
|
||||
item: RunningTablesResolver
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
declarations: [],
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule],
|
||||
providers: [
|
||||
RunningTablesResolver
|
||||
]
|
||||
})
|
||||
export class RunningTablesRoutingModule { }
|
@ -0,0 +1,5 @@
|
||||
.square-button {
|
||||
min-width: 150px;
|
||||
max-width: 150px;
|
||||
min-height: 150px;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<mat-card>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Running Tables</mat-card-title>
|
||||
</mat-card-title-group>
|
||||
<mat-card-content fxLayout="row wrap" fxLayoutGap="grid 20px">
|
||||
<button mat-raised-button class="square-button"
|
||||
*ngFor="let table of list" [routerLink]="[table.id]">{{table.name}}</button>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { RunningTablesComponent } from './running-tables.component';
|
||||
|
||||
describe('RunningTablesComponent', () => {
|
||||
let component: RunningTablesComponent;
|
||||
let fixture: ComponentFixture<RunningTablesComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ RunningTablesComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(RunningTablesComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
22
bookie/src/app/running-tables/running-tables.component.ts
Normal file
22
bookie/src/app/running-tables/running-tables.component.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { Table } from "../core/table";
|
||||
|
||||
@Component({
|
||||
selector: 'app-running-tables',
|
||||
templateUrl: './running-tables.component.html',
|
||||
styleUrls: ['./running-tables.component.css']
|
||||
})
|
||||
export class RunningTablesComponent implements OnInit {
|
||||
list: Table[];
|
||||
|
||||
constructor(private route: ActivatedRoute) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { list: Table[] }) => {
|
||||
this.list = data.list;
|
||||
});
|
||||
}
|
||||
}
|
20
bookie/src/app/running-tables/running-tables.module.ts
Normal file
20
bookie/src/app/running-tables/running-tables.module.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
import { RunningTablesRoutingModule } from './running-tables-routing.module';
|
||||
import { RunningTablesComponent } from './running-tables.component';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
|
||||
@NgModule({
|
||||
declarations: [RunningTablesComponent],
|
||||
imports: [
|
||||
CommonModule,
|
||||
FlexLayoutModule,
|
||||
MatButtonModule,
|
||||
MatCardModule,
|
||||
RunningTablesRoutingModule
|
||||
]
|
||||
})
|
||||
export class RunningTablesModule { }
|
Loading…
Reference in New Issue
Block a user