From bcdd859be948fcb2ef7177db443340171e19f9be Mon Sep 17 00:00:00 2001 From: Tim Herbst Date: Tue, 22 Dec 2020 16:09:26 +0100 Subject: [PATCH] adjust api invocation order to eliminate race-condition and easier access to necessary objects * add start-Datepicker * add end-Datepicker * toggle-Sidenav --- .../app/dashboard/dashboard.component.html | 43 ++++++++++++++----- .../app/dashboard/dashboard.component.scss | 43 ++++++++++++------- .../src/app/dashboard/dashboard.component.ts | 24 ++++++++++- .../src/app/service/dashboard.service.ts | 13 +----- 4 files changed, 83 insertions(+), 40 deletions(-) diff --git a/projects/project-3/frontend/src/app/dashboard/dashboard.component.html b/projects/project-3/frontend/src/app/dashboard/dashboard.component.html index 8ba2c4c..11d764e 100644 --- a/projects/project-3/frontend/src/app/dashboard/dashboard.component.html +++ b/projects/project-3/frontend/src/app/dashboard/dashboard.component.html @@ -1,4 +1,9 @@ - + + + Bike Stations in London library_books Wiki + + map + back to map -
- -
Main
- - Choose a date - - + + + + Start der Zeitmessung + + - -
- + + Ende der Zeitmessung + + + + + + +
+ test +
+
+ diff --git a/projects/project-3/frontend/src/app/dashboard/dashboard.component.scss b/projects/project-3/frontend/src/app/dashboard/dashboard.component.scss index b46a059..11259ca 100644 --- a/projects/project-3/frontend/src/app/dashboard/dashboard.component.scss +++ b/projects/project-3/frontend/src/app/dashboard/dashboard.component.scss @@ -1,21 +1,32 @@ - - -.sidenav-container { - height: 100%; - width: 10vw; - position: fixed; - top: auto; - left: 0; - .sidenav { - background-color: gray; - height: 100%; - } -} - .toolbar-spacer { flex: 1 1 auto; } -.mat-toolbar { - top: 0; +.sidenav { + height: 100vh; + width: 20vw; + min-width: 20em; +} + +mat-sidenav-container, mat-sidenav-content, mat-sidenav { + height: 100vh; +} + +.main-area { +} + +.button-back:hover { + background: #5a34a0; +} + +.button-wiki:hover { + background: #5a34a0; +} + +.datepicker-start { + margin-top: 50px; +} + +.datepicker-end { + margin-top: 20px; } diff --git a/projects/project-3/frontend/src/app/dashboard/dashboard.component.ts b/projects/project-3/frontend/src/app/dashboard/dashboard.component.ts index 1f768fb..23d7532 100644 --- a/projects/project-3/frontend/src/app/dashboard/dashboard.component.ts +++ b/projects/project-3/frontend/src/app/dashboard/dashboard.component.ts @@ -1,6 +1,8 @@ import {Component, OnInit} from '@angular/core'; import {ActivatedRoute} from '@angular/router'; import {DashboardService} from '../service/dashboard.service'; +import {IDashboardCommonBikePoint} from '../service/domain/dashboard-common-bike-point'; +import {MatDatepickerInputEvent} from '@angular/material/datepicker'; @Component({ selector: 'app-dashboard', @@ -8,6 +10,12 @@ import {DashboardService} from '../service/dashboard.service'; styleUrls: ['./dashboard.component.scss'] }) export class DashboardComponent implements OnInit { + station: IDashboardCommonBikePoint; + maxStartDate: Date; + maxEndDate: Date; + actualStartDate: Date; + actualEndDate: Date; + constructor( private route: ActivatedRoute, @@ -16,8 +24,22 @@ export class DashboardComponent implements OnInit { } ngOnInit(): void { - this.service.setBikeStation(this.route.snapshot.paramMap.get('id')); + this.service.initialDashboardStationFetch(this.route.snapshot.paramMap.get('id')).then(data => { + this.station = data; + this.maxStartDate = new Date(data.maxStartDate); + this.maxEndDate = new Date(data.maxEndDate); + console.log(data); + }); } + addStartDate(type: string, event: MatDatepickerInputEvent): void { + this.actualStartDate = event.value; + console.log(this.actualStartDate); + } + + addEndDate(type: string, event: MatDatepickerInputEvent): void { + this.actualEndDate = event.value; + console.log(this.actualEndDate); + } } diff --git a/projects/project-3/frontend/src/app/service/dashboard.service.ts b/projects/project-3/frontend/src/app/service/dashboard.service.ts index 23f83ac..3961f0b 100644 --- a/projects/project-3/frontend/src/app/service/dashboard.service.ts +++ b/projects/project-3/frontend/src/app/service/dashboard.service.ts @@ -1,5 +1,4 @@ import {Injectable} from '@angular/core'; -import {IDashboardCommonBikePoint} from './domain/dashboard-common-bike-point'; import {HttpClient} from '@angular/common/http'; import {environment} from '../../environments/environment'; @@ -7,21 +6,11 @@ import {environment} from '../../environments/environment'; providedIn: 'root' }) export class DashboardService { - public station: IDashboardCommonBikePoint; constructor(private client: HttpClient) { } - setBikeStation(id: string): void { - this.initialDashboardStationFetch(id).then((data) => { - this.station = data; - console.log(this.station); - }).catch((error) => { - console.log('something went wrong: ' + JSON.stringify(error)); - }); - } - - private async initialDashboardStationFetch(id: string): Promise { + public async initialDashboardStationFetch(id: string): Promise { return await this.client.get(environment.apiUrl + 'latest/dashboard/' + id + '/').toPromise(); } }