Skip to content

Commit

Permalink
feat: wind direction (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
69pmb authored Sep 29, 2024
1 parent 23fdfe0 commit 78c5675
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,19 @@ export class DashboardDetailsComponent implements OnInit, OnDestroy {
formatFields: Record<string, (h: Hour) => string> = {
feels_like: h => `${h.feelsLikeC} ${UNITS[WeatherField.FEELS_LIKE]}`,
cloud: h => `${h.cloud} ${UNITS[WeatherField.CLOUD]}`,
humidity: h => `${h.humidity} ${UNITS[WeatherField.HUMIDITY]}`,
wind_direction: h =>
[...h.windDir]
.map(d => this.translate.instant(`forecast.wind_dir.${d}`) as string)
.join('-'),
uv: h => `${h.uv} ${UNITS[WeatherField.UV]}`,
pressure: h => `${h.pressureMb} ${UNITS[WeatherField.PRESSURE]}`,
will_it_rain: h =>
`${this.translate.instant(`global.${h.willItRain === 1}`)}`,
will_it_snow: h =>
`${this.translate.instant(`global.${h.willItSnow === 1}`)}`,
chance_of_snow: h =>
`${h.chanceOfSnow} ${UNITS[WeatherField.CHANCE_OF_SNOW]}`,
humidity: h => `${h.humidity} ${UNITS[WeatherField.HUMIDITY]}`,
pressure: h => `${h.pressureMb} ${UNITS[WeatherField.PRESSURE]}`,
};

constructor(
Expand Down
4 changes: 3 additions & 1 deletion src/app/model/weather/hour.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import {Condition} from './condition';

export type WindDirection = 'E' | 'N' | 'NE' | 'NW' | 'S' | 'SE' | 'SW' | 'W';

export type Hour = {
time: string;
tempC: number;
isDay: boolean;
condition: Condition;
windKph: number;
windDir: string;
windDir: WindDirection;
pressureMb: number;
precipMm: number;
humidity: number;
Expand Down
9 changes: 8 additions & 1 deletion src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@
"feels_like": "Feels like temperature",
"will_it_rain": "Will it rain",
"will_it_snow": "Will it snow",
"uv": "UV index"
"uv": "UV index",
"wind_direction": "Wind direction",
"wind_dir": {
"S": "South",
"N": "North",
"W": "West",
"E": "East"
}
},
"dashboard": {
"show_all": "Show all"
Expand Down
9 changes: 8 additions & 1 deletion src/assets/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@
"feels_like": "Température ressentie",
"will_it_rain": "Va-t-il pleuvoir",
"will_it_snow": "Va-t-il neiger",
"uv": "Indice UV"
"uv": "Indice UV",
"wind_direction": "Direction du vent",
"wind_dir": {
"S": "Sud",
"N": "Nord",
"W": "Ouest",
"E": "Est"
}
},
"dashboard": {
"show_all": "Afficher tout"
Expand Down

0 comments on commit 78c5675

Please sign in to comment.