add new pages

This commit is contained in:
2021-08-30 15:55:08 +02:00
parent 083badeacc
commit 829aefc514
28 changed files with 538 additions and 40 deletions

View File

@ -0,0 +1,3 @@
table {
width: 75%;
}

View File

@ -0,0 +1,25 @@
<section class="mat-typography">
<mat-card class="defaultCard">
<mat-card-header>
<mat-card-title>
Meine Garagen
</mat-card-title>
</mat-card-header>
<mat-card-content>
<div>
<table mat-table [dataSource]="dataSource" #zftable>
<ng-container matColumnDef="description">
<th mat-header-cell *matHeaderCellDef>Beschreibung</th>
<td mat-cell *matCellDef="let element">{{element.description}}</td>
</ng-container>
<ng-container matColumnDef="premise">
<th mat-header-cell *matHeaderCellDef>Haus</th>
<td mat-cell *matCellDef="let element">{{element.premise}}</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="['/parking/', row.id]"></tr>
</table>
</div>
</mat-card-content>
</mat-card>
</section>

View File

@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MyParkingsComponent } from './my-parkings.component';
describe('MyParkingsComponent', () => {
let component: MyParkingsComponent;
let fixture: ComponentFixture<MyParkingsComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ MyParkingsComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(MyParkingsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,37 @@
import { Component, OnInit } from '@angular/core';
import { MessageService } from '../message.service';
import { ParkingService } from '../data-object-service';
import { Parking } from '../data-objects';
import { MatTableDataSource } from '@angular/material/table'
@Component({
selector: 'app-my-parkings',
templateUrl: './my-parkings.component.html',
styleUrls: ['./my-parkings.component.css']
})
export class MyParkingsComponent implements OnInit {
parkings: Parking[]
dataSource: MatTableDataSource<Parking>
displayedColumns: string[] = ["description", "premise"]
constructor(private parkingService: ParkingService, private messageService: MessageService) { }
async getParkings(): Promise<void> {
try {
this.messageService.add("Trying to load parkings")
this.parkings = await this.parkingService.getParkings()
this.messageService.add("Parkings loaded")
this.dataSource = new MatTableDataSource<Parking>(this.parkings)
} catch (err) {
this.messageService.add(JSON.stringify(err, undefined, 4))
}
}
ngOnInit(): void {
this.messageService.add("MyParkingsComponent.ngOnInit")
this.getParkings()
}
}