diff --git a/apps/taiga-lumbermill/src/dashboards/iot/components/weather/weather.component.html b/apps/taiga-lumbermill/src/dashboards/iot/components/weather/weather.component.html index f031cb999..ddbed7a7c 100644 --- a/apps/taiga-lumbermill/src/dashboards/iot/components/weather/weather.component.html +++ b/apps/taiga-lumbermill/src/dashboards/iot/components/weather/weather.component.html @@ -51,7 +51,7 @@

{{ info?.current?.temp_c }}°

{{ info?.current?.temp_c }}° - {{ card.day }} + {{ weatherService.getWeekDay(info.forecast.forecastday[ind + 1].date) }} +

+

+ {{ info.forecast.forecastday[ind + 1].day.mintemp_c }}°/{{ + info.forecast.forecastday[ind + 1].day.maxtemp_c + }}°

-

{{ card.temp }}

diff --git a/apps/taiga-lumbermill/src/dashboards/iot/components/weather/weather.interface.ts b/apps/taiga-lumbermill/src/dashboards/iot/components/weather/weather.interface.ts index bac4cb62c..41d7c20eb 100644 --- a/apps/taiga-lumbermill/src/dashboards/iot/components/weather/weather.interface.ts +++ b/apps/taiga-lumbermill/src/dashboards/iot/components/weather/weather.interface.ts @@ -23,7 +23,13 @@ export interface ResponseCurrent { wind_kph: string; } +export interface ForecastDay { + mintemp_c: string; + maxtemp_c: string; +} + export interface ResponseData { location: ResponseLocation; current: ResponseCurrent; + forecast: ForecastDay; } diff --git a/apps/taiga-lumbermill/src/dashboards/iot/components/weather/weather.service.ts b/apps/taiga-lumbermill/src/dashboards/iot/components/weather/weather.service.ts index 546128edc..d5f5347d8 100644 --- a/apps/taiga-lumbermill/src/dashboards/iot/components/weather/weather.service.ts +++ b/apps/taiga-lumbermill/src/dashboards/iot/components/weather/weather.service.ts @@ -20,15 +20,29 @@ export class WeatherService { public readonly weatherData = INITIAL_DATA; public getTest(): Observable { - return this.http.get('http://api.weatherapi.com/v1/current.json', { + return this.http.get('http://api.weatherapi.com/v1/forecast.json', { params: { key: this.API_KEY, q: this.city, api: 'yes', + days: '4', }, }); } + public getWeekDay(value: string): string { + const days = ['Sun', 'Mon', 'Tues', 'Wed', 'Thurs', 'Fri', 'Sat']; + + const valueSplit = value.split('-'); + const date = new Date( + parseInt(valueSplit[0], 10), + parseInt(valueSplit[1], 10) - 1, + parseInt(valueSplit[2], 10), + ); + + return days[date.getDay()]; + } + public getTypeOfWeather(value: number): string { const clouds = [1003, 1006, 1030, 1087, 1135]; const rain = [