From ffa2681071aae235e3dc78bbd3d7650139573397 Mon Sep 17 00:00:00 2001 From: veeck Date: Fri, 17 Feb 2023 18:23:59 +0100 Subject: [PATCH 1/6] Fix classnames for precipation --- modules/default/weather/forecast.njk | 4 ++-- modules/default/weather/hourly.njk | 4 ++-- modules/default/weather/weather.css | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/default/weather/forecast.njk b/modules/default/weather/forecast.njk index aa0ac8b462..f0780bc03c 100644 --- a/modules/default/weather/forecast.njk +++ b/modules/default/weather/forecast.njk @@ -23,12 +23,12 @@ {{ f.minTemperature | roundValue | unit("temperature") | decimalSymbol }} {% if config.showPrecipitationAmount %} - + {{ f.precipitationAmount | unit("precip", f.precipitationUnits) }} {% endif %} {% if config.showPrecipitationProbability %} - + {{ f.precipitationProbability }}% {% endif %} diff --git a/modules/default/weather/hourly.njk b/modules/default/weather/hourly.njk index 2904e51699..fcd2687c3a 100644 --- a/modules/default/weather/hourly.njk +++ b/modules/default/weather/hourly.njk @@ -11,12 +11,12 @@ {{ hour.temperature | roundValue | unit("temperature") }} {% if config.showPrecipitationAmount %} - + {{ hour.precipitationAmount | unit("precip", hour.precipitationUnits) }} {% endif %} {% if config.showPrecipitationProbability %} - + {{ hour.precipitationProbability }}% {% endif %} diff --git a/modules/default/weather/weather.css b/modules/default/weather/weather.css index 2d7600ad17..9590fafe27 100644 --- a/modules/default/weather/weather.css +++ b/modules/default/weather/weather.css @@ -29,7 +29,8 @@ padding-right: 0; } -.weather .precipitation { +.weather .precipitation-amount, +.weather .precipitation-prob { padding-left: 20px; padding-right: 0; } From 847d3ec12721e5f03e82c68a4a94b915762af2cf Mon Sep 17 00:00:00 2001 From: veeck Date: Fri, 17 Feb 2023 22:37:57 +0100 Subject: [PATCH 2/6] Add test for metric units and fix imperial one --- tests/e2e/modules/weather_forecast_spec.js | 13 +++++++++++-- tests/e2e/modules/weather_hourly_spec.js | 8 ++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/tests/e2e/modules/weather_forecast_spec.js b/tests/e2e/modules/weather_forecast_spec.js index 9988249118..b0f7103919 100644 --- a/tests/e2e/modules/weather_forecast_spec.js +++ b/tests/e2e/modules/weather_forecast_spec.js @@ -79,6 +79,15 @@ describe("Weather module: Weather Forecast", () => { expect(table.rows).not.toBe(null); expect(table.rows.length).toBe(5); }); + + const precipitations = [undefined, "2.51 mm"]; + for (const [index, precipitation] of precipitations.entries()) { + if (precipitation) { + it("should render precipitation amount " + precipitation, async () => { + await weatherFunc.getText(`.weather table tr:nth-child(${index + 1}) td.precipitation-amount`, precipitation); + }); + } + } }); describe("Forecast weather with imperial units", () => { @@ -99,8 +108,8 @@ describe("Weather module: Weather Forecast", () => { const precipitations = [undefined, "0.10 in"]; for (const [index, precipitation] of precipitations.entries()) { if (precipitation) { - it("should render precipitation value " + precipitation, async () => { - await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.precipitationAmount`, precipitation); + it("should render precipitation amount " + precipitation, async () => { + await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.precipitation-amount`, precipitation); }); } } diff --git a/tests/e2e/modules/weather_hourly_spec.js b/tests/e2e/modules/weather_hourly_spec.js index 2c98623d30..a4f5c17d72 100644 --- a/tests/e2e/modules/weather_hourly_spec.js +++ b/tests/e2e/modules/weather_hourly_spec.js @@ -44,18 +44,18 @@ describe("Weather module: Weather Hourly Forecast", () => { for (const [index, amount] of amounts.entries()) { if (amount) { it(`should render precipitation amount ${amount}`, async () => { - await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.precipitationAmount`, amount); + await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.precipitation-amount`, amount); }); } } }); - describe("Shows precipitation propability", () => { + describe("Shows precipitation probability", () => { const propabilities = [undefined, undefined, "12%", "36%", "44%"]; for (const [index, pop] of propabilities.entries()) { if (pop) { - it(`should render propability ${pop}`, async () => { - await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.precipitationProbability`, pop); + it(`should render probability ${pop}`, async () => { + await weatherFunc.getText(`.weather table.small tr:nth-child(${index + 1}) td.precipitation-prob`, pop); }); } } From a7f4bf0ddcd76f0ea705b3d316f5dbe03ad147be Mon Sep 17 00:00:00 2001 From: veeck Date: Fri, 17 Feb 2023 23:28:01 +0100 Subject: [PATCH 3/6] Use unit macro for precipitationProbability otherwise undefined values display only the % char --- modules/default/weather/forecast.njk | 2 +- modules/default/weather/hourly.njk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/default/weather/forecast.njk b/modules/default/weather/forecast.njk index f0780bc03c..0ea390f0a5 100644 --- a/modules/default/weather/forecast.njk +++ b/modules/default/weather/forecast.njk @@ -29,7 +29,7 @@ {% endif %} {% if config.showPrecipitationProbability %} - {{ f.precipitationProbability }}% + {{ f.precipitationProbability | unit("precip", "%") }} {% endif %} diff --git a/modules/default/weather/hourly.njk b/modules/default/weather/hourly.njk index fcd2687c3a..a0699fab39 100644 --- a/modules/default/weather/hourly.njk +++ b/modules/default/weather/hourly.njk @@ -17,7 +17,7 @@ {% endif %} {% if config.showPrecipitationProbability %} - {{ hour.precipitationProbability }}% + {{ hour.precipitationProbability | unit("precip", "%") }} {% endif %} From 74c2fe432965f0bbc718e2d44a783dc94322770e Mon Sep 17 00:00:00 2001 From: veeck Date: Sat, 18 Feb 2023 00:19:06 +0100 Subject: [PATCH 4/6] Add extra case for converting precipationProp value --- modules/default/weather/weatherutils.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/default/weather/weatherutils.js b/modules/default/weather/weatherutils.js index 233b07428f..75f9d6b05d 100644 --- a/modules/default/weather/weatherutils.js +++ b/modules/default/weather/weatherutils.js @@ -40,6 +40,8 @@ const WeatherUtils = { valueUnit = valueUnit ? valueUnit : "mm"; } + if (valueUnit === "%") return `${value}${valueUnit}`; + return `${value.toFixed(2)} ${valueUnit}`; }, From 27f7449aa2369c877f8c00e616ef0c65f5d76682 Mon Sep 17 00:00:00 2001 From: veeck Date: Sat, 18 Feb 2023 08:09:27 +0100 Subject: [PATCH 5/6] Add more tests for wind conversion --- modules/default/weather/weatherutils.js | 2 +- tests/unit/functions/weather_object_spec.js | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/default/weather/weatherutils.js b/modules/default/weather/weatherutils.js index 75f9d6b05d..69c4bbca20 100644 --- a/modules/default/weather/weatherutils.js +++ b/modules/default/weather/weatherutils.js @@ -12,7 +12,7 @@ const WeatherUtils = { * @returns {number} the speed in beaufort */ beaufortWindSpeed(speedInMS) { - const windInKmh = (speedInMS * 3600) / 1000; + const windInKmh = this.convertWind(speedInMS, "kmh"); const speeds = [1, 5, 11, 19, 28, 38, 49, 61, 74, 88, 102, 117, 1000]; for (const [index, speed] of speeds.entries()) { if (speed > windInKmh) { diff --git a/tests/unit/functions/weather_object_spec.js b/tests/unit/functions/weather_object_spec.js index ee6578af78..0b24737b95 100644 --- a/tests/unit/functions/weather_object_spec.js +++ b/tests/unit/functions/weather_object_spec.js @@ -51,7 +51,15 @@ describe("WeatherObject", () => { describe("WeatherUtils", () => { it("should convert windspeed correctly from mps to beaufort", () => { expect(Math.round(WeatherUtils.convertWind(5, "beaufort"))).toBe(3); - expect(Math.round(WeatherUtils.convertWind(42, "beaufort"))).toBe(12); + expect(Math.round(WeatherUtils.convertWind(300, "beaufort"))).toBe(12); + }); + + it("should convert windspeed correctly from mps to kmh", () => { + expect(Math.round(WeatherUtils.convertWind(11.75, "kmh"))).toBe(42); + }); + + it("should convert windspeed correctly from mps to knots", () => { + expect(Math.round(WeatherUtils.convertWind(10, "knots"))).toBe(19); }); it("should convert windspeed correctly from mph to mps", () => { From c3e51ece2f059bd3dc7ada1c54db4d79b6badbaa Mon Sep 17 00:00:00 2001 From: veeck Date: Fri, 27 Jan 2023 23:16:09 +0100 Subject: [PATCH 6/6] Update CHANGELOG --- CHANGELOG.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5509934fe4..c93a83f840 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,13 +39,14 @@ _This release is scheduled to be released on 2023-04-01._ - Fix wrong day labels in envcanada forecast (#2987) - Fix for missing default class name prefix for customEvents in calendar -- Fixed electron flashing white screen on startup (#1919) +- Fix electron flashing white screen on startup (#1919) - Fix weathergov provider hourly forecast (#3008) - Fix message display with HTML code into alert module (#2828) -- Fix typo into french translation +- Fix typo in french translation - Yr wind direction is no longer inverted - Fix async node_helper stopping electron start (#2487) - The wind direction arrow now points in the direction the wind is flowing, not into the wind (#3019) +- Fix precipitation css styles ## [2.22.0] - 2023-01-01 @@ -58,7 +59,6 @@ Special thanks to @khassel, @rejas and @sdetweil for taking over most (if not al - Added new calendar options for colored entries and improved styling (#3033) - Added test for remoteFile option in compliments module - Added hourlyWeather functionality to Weather.gov weather provider -- Removed weatherEndpoint definition from weathergov.js (not used) - Added css class names "today" and "tomorrow" for default calendar - Added Collaboration.md - Added new github action for dependency review (#2862) @@ -71,6 +71,7 @@ Special thanks to @khassel, @rejas and @sdetweil for taking over most (if not al ### Removed - Removed usage of internal fetch function of node until it is more stable +- Removed weatherEndpoint definition from weathergov.js (not used) ### Updated @@ -84,7 +85,7 @@ Special thanks to @khassel, @rejas and @sdetweil for taking over most (if not al - Reworked how weatherproviders handle units (#2849) - Use unix() method for parsing times, fix suntimes on the way (#2950) - Refactor conversion functions into utils class (#2958) -- The `cors`-method in `server.js` now supports sending and recieving HTTP headers +- The `cors`-method in `server.js` now supports sending and receiving HTTP headers - Replace `…` by `…` - Cleanup compliments module - Updated dependencies including electron to v22 (#2903)