diff --git a/web-angular/package.json b/web-angular/package.json index e1d40e05..15cdd4a7 100644 --- a/web-angular/package.json +++ b/web-angular/package.json @@ -5,6 +5,7 @@ "scripts": { "ng": "ng", "start": "ng serve", + "start:forecast": "ng serve weather-forecast-today", "build": "ng build", "build:forecast": "ng build --prod weather-forecast-today && npm run concat:forecast", "concat:forecast": "node ./ng-element-concat.js weather-forecast-today", diff --git a/web-angular/projects/weather-forecast-today/src/app/web-component/weather-forecast-today.component.ts b/web-angular/projects/weather-forecast-today/src/app/web-component/weather-forecast-today.component.ts index df8a4593..d8dfb44e 100644 --- a/web-angular/projects/weather-forecast-today/src/app/web-component/weather-forecast-today.component.ts +++ b/web-angular/projects/weather-forecast-today/src/app/web-component/weather-forecast-today.component.ts @@ -1,21 +1,22 @@ import { + AfterViewChecked, Component, - OnInit, - Input, - OnDestroy, - ViewEncapsulation, - ViewChild, ElementRef, HostListener, - AfterViewChecked + Input, + OnDestroy, + OnInit, + ViewChild, + ViewEncapsulation } from '@angular/core'; -import { Subscription, BehaviorSubject } from 'rxjs'; -import { ResourceService } from '../../../../../src/app/services/resource.service'; +import {BehaviorSubject, Subscription} from 'rxjs'; +import {ResourceService} from '../../../../../src/app/services/resource.service'; import { CityForecastService, + ForecastPeriod, WeatherConditionSummary } from '../../../../../src/app/services/city-forecast.service'; -import { DefaultService, City } from '../../../../../src/app/api'; +import {City, DefaultService} from '../../../../../src/app/api'; /** * Shows the current day forecast for a particular city. The main use is @@ -32,6 +33,7 @@ export class WeatherForecastTodayComponent implements OnInit, AfterViewChecked, @Input() cityId: number; @Input() langCode: 'de' | 'en'; + @Input() tomorrow: boolean; @Input() dayTime?: boolean; @Input() noHeader?: boolean; @Input() noFooter?: boolean; @@ -77,7 +79,9 @@ export class WeatherForecastTodayComponent implements OnInit, AfterViewChecked, (city: City) => { if (!this.noHeader) { this.setHeaderInfos(city); } const date = new Date(); - const { dayForecasts, daytimeForecasts, error } = this.cityForecastService.fetchForecasts(city, date, true); + // if (this.tomorrow) { date.setDate(date.getDate() + 1); } + const period = this.tomorrow ? ForecastPeriod.TOMORROW : ForecastPeriod.TODAY; + const { dayForecasts, daytimeForecasts, error } = this.cityForecastService.fetchForecasts(city, date, period); this.forecast$ = this.dayTime ? daytimeForecasts : dayForecasts; this.forecastReqErrorSubscr = error.subscribe( (forecastErr: any) => this.handleErrorMsg(forecastErr, 'An Error occured while fetching forecast information.') @@ -106,6 +110,7 @@ export class WeatherForecastTodayComponent implements OnInit, AfterViewChecked, private evalInputProperties(): void { if (!this.langCode) { this.langCode = 'de'; } + this.tomorrow = this.tomorrow !== undefined; this.dayTime = this.dayTime !== undefined; this.noHeader = this.noHeader !== undefined; this.noFooter = this.noFooter !== undefined; @@ -140,6 +145,7 @@ export class WeatherForecastTodayComponent implements OnInit, AfterViewChecked, const outerDiv: HTMLDivElement = this.outer.nativeElement; const innerDiv: HTMLDivElement = this.inner.nativeElement; if (this.dayTime) { + // Needs to check container size due to multiple tiles. if (this.outerBrkPt2 < outerDiv.clientWidth && outerDiv.clientWidth <= this.outerBrkPt1) { this.setHeaderTextSize(this.innerHeadMd); if (innerDiv.style.maxWidth !== this.innerMedium) { @@ -157,6 +163,7 @@ export class WeatherForecastTodayComponent implements OnInit, AfterViewChecked, } } } else { + // Container size always set to small because there is only one tile. this.setHeaderTextSize(this.innerHeadSm); if (innerDiv.style.maxWidth !== this.innerSmall) { innerDiv.style.maxWidth = this.innerSmall; diff --git a/web-angular/projects/weather-forecast-today/src/index.html b/web-angular/projects/weather-forecast-today/src/index.html index f745be74..8a8f01ff 100644 --- a/web-angular/projects/weather-forecast-today/src/index.html +++ b/web-angular/projects/weather-forecast-today/src/index.html @@ -7,6 +7,6 @@
-