Refactored the weather-forecast web component and cleaned up main project.

This commit is contained in:
Adriano Markovic
2020-05-24 17:20:32 +02:00
parent d45f9bbb7a
commit ffc10b4a24
10 changed files with 140 additions and 116 deletions
+1 -6
View File
@@ -46,7 +46,7 @@ import { ToolbarButtonComponent, DecisionPanelComponent, EmailFieldComponent, La
import { CitiesListComponent, WeatherConditionComponent, WeatherVideoComponent,
WeatherVideoBarComponent, WeatherVideoListComponent, WeatherStationsListComponent, WeatherReportsListComponent,
WeatherReportComponent, WeatherSummaryComponent, WeatherDiagramComponent } from './widgets-weather';
import { LoginComponent, ActivateComponent, ChangeComponent, RegisterComponent, ResetComponent,
import { LoginComponent, ActivateComponent, ChangeComponent, RegisterComponent, ResetComponent,
LoadingComponent } from './views-common';
import { CitiesComponent, CityComponent, CountryComponent, StateComponent, VideosComponent,
StationsComponent, StationComponent } from './views-weather';
@@ -71,9 +71,6 @@ import { HumidityPipe, CloudPipe, PressurePipe, TemperaturePipe, SpeedPipe, Snow
GoogleMapsPipe, WikipediaPipe, CityTypePipe, VideoSourcePipe, VideoTypePipe, LocationIconPipe, WeatherIconPipe,
DirectionIconPipe, MeasurementTypePipe, MeasurementTypeIconPipe, OsIconPipe } from './pipes';
// TODO: Remove
import { TestSiteComponent } from './test-site/test-site.component';
/**
* Computes the api domain from the browser location.
@@ -120,8 +117,6 @@ registerLocaleData(LocaleDE);
UseParentFormDirective,
ClickButtonComponent,
CodeDialogComponent,
// TODO: Remove
TestSiteComponent
],
imports: [
BrowserModule, BrowserAnimationsModule,
+1 -5
View File
@@ -8,16 +8,12 @@ import { CityComponent, StateComponent, CountryComponent, CitiesComponent, Video
StationsComponent, StationComponent } from './views-weather';
import { UserDevicesComponent, UserAccountComponent, UserFavoritesComponent, UserDeviceComponent } from './views-user';
import { ManageLogComponent, ManageSystemComponent, ManageUsersComponent } from './views-manage';
import { CityResolver, StateResolver, CountryResolver, UserResolver, StationResolver, LanguageResolver,
import { CityResolver, StateResolver, CountryResolver, UserResolver, StationResolver, LanguageResolver,
BootstrapResolver,
DeviceResolver} from './resolvers';
// TODO: Remove
import { TestSiteComponent } from './test-site/test-site.component';
export const routes: Routes = [
// TODO: Remove
{ path: 'web-test', component: TestSiteComponent },
// backwards compatibility
{ path: 'activate/:token', resolve: { bs: BootstrapResolver}, component: LoadingComponent },
{ path: 'reset/:token', resolve: { bs: BootstrapResolver}, component: LoadingComponent },
@@ -117,6 +117,7 @@ export class ResourceService {
'label_yesterday' : 'Gestern',
'label_today' : 'Heute',
'label_tomorrow' : 'Morgen',
'city_code_dialog_title': 'Wettervorhersagen einbetten',
'city_code_dialog_stylesheet': 'Das Stylesheet verlinken.',
'city_code_dialog_scripts': 'Die Skripte einbetten.',
@@ -125,6 +126,13 @@ export class ResourceService {
'city_code_dialog_example': 'Beispiel',
'city_code_dialog_default_lang': 'Standard: lang-code="de"',
'web_comp_err_title': 'Fehler',
'web_comp_err_no_city_id': 'Das Attribut "city-id" darf nicht leer sein!',
'web_comp_err_fetch_city': 'Dienst momentan nicht erreichbar! Stadt kann nicht abgerufen werden.',
'web_comp_err_fetch_forecast': 'Dienst momentan nicht erreichbar! Wettervorhersage kann nicht abgerufen werden.',
'web_comp_footer_computed': 'Vorhersage berechnet vom ',
'web_comp_footer_provided': ' und bereitgestellt von ',
'station_title': 'Station',
'station_latest_report' : 'Letzte Messung',
@@ -545,6 +553,7 @@ export class ResourceService {
'label_yesterday' : 'Yesterday',
'label_today' : 'Today',
'label_tomorrow' : 'Tomorrow',
'city_code_dialog_title': 'Embed Weather Forecasts',
'city_code_dialog_stylesheet': 'Link the stylesheet.',
'city_code_dialog_scripts': 'Embed the scripts.',
@@ -553,6 +562,13 @@ export class ResourceService {
'city_code_dialog_example': 'Example',
'city_code_dialog_default_lang': 'Default: lang-code="de"',
'web_comp_err_title': 'Error',
'web_comp_err_no_city_id': 'The Attribute "city-id" must not be empty!',
'web_comp_err_fetch_city': 'Service currently not available! Cannot fetch city data.',
'web_comp_err_fetch_forecast': 'Service currently not available! Cannot fetch any forecast data.',
'web_comp_footer_computed': 'Forecast computed by ',
'web_comp_footer_provided': ' and provided by ',
'station_title': 'Station',
'station_latest_report' : 'Latest Measurement',
@@ -1,48 +1,49 @@
<mat-card style="width: 300px;" *ngIf="hasCondition()" (click)="onClick()" class="clickable hov-accent mt-sm mb-sm">
<mat-card style="width: 300px;" *ngIf="hasCondition()" (click)="onClick()" class="clickable hov-accent"
[ngClass]="noMargin ? '' : 'mt-sm mb-sm'">
<div class="fx-column">
<div class="fx-row">
<div class="fg-gray" style="font-size: 42px; width: 60px; height: 50px;" [matTooltip]="min.type | weather"><i [class]="min.type | weatherIcon"></i></div>
<div class="ta-c" style="margin-right: 5px; font-size: 42px; width: 65px; height: 50px;" [matTooltip]="max.type | weather"><i [class]="max.type | weatherIcon"></i></div>
<div class="fx-column fx-stretch" style="margin-top: 5px; margin-left: 5px;">
<div>{{ displayTitle }}</div>
<div>{{ displayTitle }}</div>
<div>{{ displaySubtitle }} </div>
</div>
</div>
<div class="fx-fill mb-sm fw-b ta-c" style="margin-top: 5px;">{{ max.type | weather }}</div>
<div class="fx-row fx-fill">
<div class="mr-sm" style="width: 40px; text-align: center;" [matTooltip]="res.strings('label_temperature')" matTooltipPosition="right"><i class="wi wi-thermometer"></i></div>
<div class="fs-sm fx-fill ta-r fw-b">{{ min.temperature | temperature }}</div>
<div class="fs-sm fx-fill ta-r fw-b">{{ max.temperature | temperature }}</div>
<div class="fs-sm fx-fill ta-r fw-b">{{ min.temperature | temperature }}</div>
<div class="fs-sm fx-fill ta-r fw-b">{{ max.temperature | temperature }}</div>
</div>
<div class="fx-row fx-fill">
<div class="mr-sm" style="width: 40px; text-align: center;" [matTooltip]="res.strings('label_precipitation')" matTooltipPosition="right"><i class="wi wi-raindrops"></i></div>
<div class="fs-sm fx-fill ta-r">{{ min.precipitation | precipitation }}</div>
<div class="fs-sm fx-fill ta-r">{{ max.precipitation | precipitation }}</div>
<div class="fs-sm fx-fill ta-r">{{ min.precipitation | precipitation }}</div>
<div class="fs-sm fx-fill ta-r">{{ max.precipitation | precipitation }}</div>
</div>
<div class="fx-row fx-fill">
<div class="mr-sm" style="width: 40px; text-align: center;" [matTooltip]="min.windDirection | direction" matTooltipPosition="right"><i [class]="max.windDirection | directionIcon"></i></div>
<div class="fs-sm fx-fill ta-r" [matTooltip]="res.strings('label_wind_speed')" matTooltipPosition="right">{{ min.windSpeed | speed }}</div>
<div class="fs-sm fx-fill ta-r" [matTooltip]="res.strings('label_wind_speed')" matTooltipPosition="right">{{ max.windSpeed | speed }}</div>
<div class="fs-sm fx-fill ta-r" [matTooltip]="res.strings('label_wind_speed')" matTooltipPosition="right">{{ min.windSpeed | speed }}</div>
<div class="fs-sm fx-fill ta-r" [matTooltip]="res.strings('label_wind_speed')" matTooltipPosition="right">{{ max.windSpeed | speed }}</div>
</div>
<div class="fx-row fx-fill">
<div class="mr-sm" style="width: 40px; text-align: center;" [matTooltip]="res.strings('label_cloud_coverage')" matTooltipPosition="right"><i class="wi wi-cloud"></i></div>
<div class="fs-sm fx-fill ta-r" >{{ min.cloudCoverage | cloud }}</div>
<div class="fs-sm fx-fill ta-r" >{{ max.cloudCoverage | cloud }}</div>
<div class="fs-sm fx-fill ta-r" >{{ min.cloudCoverage | cloud }}</div>
<div class="fs-sm fx-fill ta-r" >{{ max.cloudCoverage | cloud }}</div>
</div>
<div class="fx-row fx-fill">
<div class="mr-sm" style="width: 40px; text-align: center;" [matTooltip]="res.strings('label_humidity')" matTooltipPosition="right"><i class="wi wi-humidity"></i></div>
<div class="fs-sm fx-fill ta-r" >{{ min.humidity | humidity }}</div>
<div class="fs-sm fx-fill ta-r" >{{ max.humidity | humidity }}</div>
<div class="fs-sm fx-fill ta-r" >{{ min.humidity | humidity }}</div>
<div class="fs-sm fx-fill ta-r" >{{ max.humidity | humidity }}</div>
</div>
<div class="fx-row fx-fill">
<div class="mr-sm" style="width: 40px; text-align: center;" [matTooltip]="res.strings('label_snow_depth')" matTooltipPosition="right"><i class="wi wi-snowflake-cold"></i></div>
<div class="fs-sm fx-fill ta-r">{{ min.snowDepth | snow }}</div>
<div class="fs-sm fx-fill ta-r">{{ max.snowDepth | snow }}</div>
<div class="fs-sm fx-fill ta-r">{{ min.snowDepth | snow }}</div>
<div class="fs-sm fx-fill ta-r">{{ max.snowDepth | snow }}</div>
</div>
<div class="fx-row fx-fill ">
<div class="mr-sm" style="width: 40px; text-align: center;" [matTooltip]="res.strings('label_pressure')" matTooltipPosition="right"><i class="wi wi-barometer"></i></div>
<div class="fs-sm fx-fill ta-r">{{ min.pressure | pressure }}</div>
<div class="fs-sm fx-fill ta-r">{{ max.pressure | pressure }}</div>
<div class="fs-sm fx-fill ta-r">{{ min.pressure | pressure }}</div>
<div class="fs-sm fx-fill ta-r">{{ max.pressure | pressure }}</div>
</div>
</div>
</mat-card>
@@ -20,6 +20,7 @@ export class WeatherSummaryComponent implements OnInit, OnChanges {
@Input() title: string;
@Input() subtitle: string;
@Input() clickHandler: () => void;
@Input() noMargin: boolean;
min: WeatherCondition = null;
max: WeatherCondition = null;