From b9663831fd916a8547cd6c553a19b018854688f7 Mon Sep 17 00:00:00 2001 From: David Ralph Date: Sat, 1 May 2021 22:27:44 +0100 Subject: [PATCH] fix: search autocomplete, add visibility to weather --- .../modals/main/settings/sections/Weather.jsx | 1 + src/components/widgets/search/Search.jsx | 12 ++++++++++-- src/components/widgets/weather/Weather.jsx | 4 ++++ src/translations/de_DE.json | 1 + src/translations/en_GB.json | 1 + src/translations/en_US.json | 1 + src/translations/es.json | 1 + src/translations/fr.json | 1 + src/translations/nl.json | 1 + src/translations/no.json | 1 + src/translations/ru.json | 1 + src/translations/zh_CN.json | 1 + 12 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/components/modals/main/settings/sections/Weather.jsx b/src/components/modals/main/settings/sections/Weather.jsx index 564d9863..17ab6851 100644 --- a/src/components/modals/main/settings/sections/Weather.jsx +++ b/src/components/modals/main/settings/sections/Weather.jsx @@ -76,6 +76,7 @@ export default class TimeSettings extends React.PureComponent { + diff --git a/src/components/widgets/search/Search.jsx b/src/components/widgets/search/Search.jsx index ac20e704..5febe9d3 100644 --- a/src/components/widgets/search/Search.jsx +++ b/src/components/widgets/search/Search.jsx @@ -45,8 +45,15 @@ export default class Search extends React.PureComponent { }; } - searchButton = () => { - const value = document.getElementById('searchtext').value || 'mue fast'; + searchButton = (e) => { + let value; + + if (e) { + value = e; + } else { + value = document.getElementById('searchtext').value || 'mue fast'; + } + window.location.href = this.state.url + `?${this.state.query}=` + value; } @@ -54,6 +61,7 @@ export default class Search extends React.PureComponent { const data = await (await fetchJSONP(this.state.autocompleteURL + this.state.autocompleteQuery + input, { jsonpCallback: this.state.autocompleteCallback })).json(); + this.setState({ suggestions: data[1].splice(0, 3) }); diff --git a/src/components/widgets/weather/Weather.jsx b/src/components/widgets/weather/Weather.jsx index 1d6a3acf..ca6eef2f 100644 --- a/src/components/widgets/weather/Weather.jsx +++ b/src/components/widgets/weather/Weather.jsx @@ -24,6 +24,7 @@ export default class Weather extends React.PureComponent { wind_speed: '', wind_degrees: '', cloudiness: '', + visibility: '', pressure: '' } }; @@ -48,6 +49,7 @@ export default class Weather extends React.PureComponent { humidity: this.state.weather.humidity, pressure: this.state.weather.pressure }, + visibility: this.state.weather.visibility, wind: { speed: this.state.weather.wind_speed, deg: this.state.weather.wind_degrees @@ -101,6 +103,7 @@ export default class Weather extends React.PureComponent { wind_speed: data.wind.speed, wind_degrees: data.wind.deg, cloudiness: data.clouds.all, + visibility: data.visibility, pressure: data.main.pressure, original_temp: data.main.temp, original_temp_min: data.main.temp_min, @@ -162,6 +165,7 @@ export default class Weather extends React.PureComponent { {enabled('humidity') ?
{this.state.weather.humidity}%
: null} {enabled('windspeed') ?
{this.state.weather.wind_speed} m/s {enabled('windDirection') ? : null}
: null} {enabled('cloudiness') ?
{this.state.weather.cloudiness}%
: null} + {enabled('visibility') ?
{this.state.weather.visibility} meters
: null} {enabled('atmosphericpressure') ?
{this.state.weather.pressure} hPa
: null}
{enabled('showlocation') ? {this.state.location} : null} diff --git a/src/translations/de_DE.json b/src/translations/de_DE.json index d11d763c..40309f5e 100644 --- a/src/translations/de_DE.json +++ b/src/translations/de_DE.json @@ -185,6 +185,7 @@ "show_text": "Show text", "cloudiness": "Cloudiness", "humidity": "Luftfeuchtigkeit", + "visibility": "Visibility", "wind_speed": "Windgeschwindigkeit", "wind_direction": "Wind direction", "min_temp": "Mindesttemperatur", diff --git a/src/translations/en_GB.json b/src/translations/en_GB.json index a8f63b88..24f21d12 100644 --- a/src/translations/en_GB.json +++ b/src/translations/en_GB.json @@ -185,6 +185,7 @@ "show_text": "Show text", "cloudiness": "Cloudiness", "humidity": "Humidity", + "visibility": "Visibility", "wind_speed": "Wind speed", "wind_direction": "Wind direction", "min_temp": "Minimum temperature", diff --git a/src/translations/en_US.json b/src/translations/en_US.json index 8e6a1497..74e4adf1 100644 --- a/src/translations/en_US.json +++ b/src/translations/en_US.json @@ -185,6 +185,7 @@ "show_text": "Show text", "cloudiness": "Cloudiness", "humidity": "Humidity", + "visibility": "Visibility", "wind_speed": "Wind speed", "wind_direction": "Wind direction", "min_temp": "Minimum temperature", diff --git a/src/translations/es.json b/src/translations/es.json index 25624d1e..e2611825 100644 --- a/src/translations/es.json +++ b/src/translations/es.json @@ -185,6 +185,7 @@ "show_text": "Show text", "cloudiness": "Cloudiness", "humidity": "Humedad", + "visibility": "Visibility", "wind_speed": "Velocidad del viento", "wind_direction": "Wind direction", "min_temp": "Temperatura mínima", diff --git a/src/translations/fr.json b/src/translations/fr.json index bcfe6659..b00515d1 100644 --- a/src/translations/fr.json +++ b/src/translations/fr.json @@ -185,6 +185,7 @@ "show_text": "Show text", "cloudiness": "Cloudiness", "humidity": "Humidité", + "visibility": "Visibility", "wind_speed": "Vitesse du vent", "wind_direction": "Wind direction", "min_temp": "Température minimale", diff --git a/src/translations/nl.json b/src/translations/nl.json index c655f4c7..d4106d63 100644 --- a/src/translations/nl.json +++ b/src/translations/nl.json @@ -185,6 +185,7 @@ "show_text": "Show text", "cloudiness": "Cloudiness", "humidity": "Humidity", + "visibility": "Visibility", "wind_speed": "Wind speed", "wind_direction": "Wind direction", "min_temp": "Minimum temperature", diff --git a/src/translations/no.json b/src/translations/no.json index 26466a62..043ed1ea 100644 --- a/src/translations/no.json +++ b/src/translations/no.json @@ -185,6 +185,7 @@ "show_text": "Show text", "cloudiness": "Cloudiness", "humidity": "Humidity", + "visibility": "Visibility", "wind_speed": "Wind speed", "wind_direction": "Wind direction", "min_temp": "Minimum temperature", diff --git a/src/translations/ru.json b/src/translations/ru.json index 79be8961..b3e9772c 100644 --- a/src/translations/ru.json +++ b/src/translations/ru.json @@ -185,6 +185,7 @@ "show_text": "Show text", "cloudiness": "Cloudiness", "humidity": "Humidity", + "visibility": "Visibility", "wind_speed": "Wind speed", "wind_direction": "Wind direction", "min_temp": "Minimum temperature", diff --git a/src/translations/zh_CN.json b/src/translations/zh_CN.json index 3058c57d..99514593 100644 --- a/src/translations/zh_CN.json +++ b/src/translations/zh_CN.json @@ -185,6 +185,7 @@ "show_text": "Show text", "cloudiness": "Cloudiness", "humidity": "Humidity", + "visibility": "Visibility", "wind_speed": "Wind speed", "wind_direction": "Wind direction", "min_temp": "Minimum temperature",