Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@callemand: Weather - Change UI from date to day and add sentence into chat #1105

Merged
merged 27 commits into from
Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions front/src/actions/dashboard/boxes/weather.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ function createActions(store) {
hour.weatherIcon = translateWeatherToFeIcon(hour.weather);
hour.datetime_beautiful = dayjs(hour.datetime).format('HH');
});
weather.days.shift();
weather.days.map(day => {
day.weatherIcon = translateWeatherToFeIcon(day.weather);
day.datetime_beautiful = dayjs(day.datetime).format('D MMM');
day.weather_icon = translateWeatherToFeIcon(day.weather);
day.datetime_beautiful = dayjs(day.datetime).format('dddd');
});

boxActions.mergeBoxData(state, BOX_KEY, x, y, {
Expand Down
19 changes: 15 additions & 4 deletions front/src/components/boxs/weather/WeatherBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { connect } from 'unistore/preact';
import { Text } from 'preact-i18n';
import { Link } from 'preact-router/match';
import cx from 'classnames';
import dayjs from 'dayjs';

import { WEATHER_UNITS } from '../../../../../server/utils/constants';

import actions from '../../../actions/dashboard/boxes/weather';
import {
Expand Down Expand Up @@ -123,7 +126,7 @@ const WeatherBox = ({ children, ...props }) => (
fontSize: '30px'
}}
>
{props.units === 'metric' ? 'C' : 'F'}
{props.units === WEATHER_UNITS.METRIC ? <Text id="global.celsius" /> : <Text id="global.fahrenheit" />}
</span>
</div>
</div>
Expand Down Expand Up @@ -176,7 +179,11 @@ const WeatherBox = ({ children, ...props }) => (
color: 'grey'
}}
>
{props.units === 'si' ? 'km/h' : 'm/h'}
{props.units === WEATHER_UNITS.METRIC ? (
<Text id="global.metersPerSec" />
) : (
<Text id="global.milesPerHour" />
)}
</span>
</span>
</div>
Expand Down Expand Up @@ -205,7 +212,7 @@ const WeatherBox = ({ children, ...props }) => (
</div>
);

@connect('DashboardBoxDataWeather,DashboardBoxStatusWeather', actions)
@connect('DashboardBoxDataWeather,DashboardBoxStatusWeather,user', actions)
class WeatherBoxComponent extends Component {
componentDidMount() {
// get the weather
Expand Down Expand Up @@ -267,7 +274,11 @@ class WeatherBoxComponent extends Component {
daysDisplay = days.map(day => {
return (
<div className="row" style={{ marginTop: '0.5em' }}>
<div className="col-5">{day.datetime_beautiful}</div>
<div className="col-5" style={{ textTransform: 'capitalize' }}>
{dayjs(day.datetime)
.locale(props.user.language)
.format('dddd')}
</div>
<div className="col-3">
<i className={cx('fe', day.weatherIcon)} style={{ fontSize: '20px' }} />
</div>
Expand Down
6 changes: 5 additions & 1 deletion front/src/config/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
"percent": "%",
"degreeValue": "{{value}}°",
"workInProgress": "Work in progress...",
"save": "Save"
"save": "Save",
"celsius": "C",
"fahrenheit": "F",
"metersPerSec": "m/s",
"milesPerHour": "m/h"
},
"calendar": {
"allDay": "All Day",
Expand Down
6 changes: 5 additions & 1 deletion front/src/config/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
"percent": "%",
"degreeValue": "{{value}}°",
"workInProgress": "Travail en cours...",
"save": "Enregistrer"
"save": "Enregistrer",
"celsius": "C",
"fahrenheit": "F",
"metersPerSec": "m/s",
"milesPerHour": "m/h"
},
"calendar": {
"allDay": "Toute la journée",
Expand Down
12 changes: 10 additions & 2 deletions server/config/brain/taxi/questions.en.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
[
{
"label": "taxi.order",
"questions": ["Order me a taxi in %datetime% to %city%"],
"answers": ["Ok, got it. I'll order a taxi in {{datetime}} to {{city}}"],
"questions": ["Order me a taxi from %from% to %city% %datetime% "],
"answers": ["Ok, got it. I'll order a taxi in {{datetime}} from {{from}} to {{city}}"],
"slots": [
{
"key": "from",
"mandatory": true,
"ifMissing": "Where should I pick you?",
"betweenCondition": {
"between": ["from", "to"]
}
},
{
"key": "city",
"mandatory": true,
Expand Down
215 changes: 207 additions & 8 deletions server/config/brain/weather/answers.en.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,231 @@
[
{
"label": "weather.get.success.snow",
"label": "weather.get.success.now.snow",
"answers": ["It's snowing outside and the temperature is {{ temperature }} {{ units }}."]
},
{
"label": "weather.get.success.rain",
"label": "weather.get.success.now.rain",
"answers": ["It's raining and temperature outside is {{ temperature }} {{ units }}."]
},
{
"label": "weather.get.success.clear",
"label": "weather.get.success.now.clear",
"answers": ["It's a clear day today. Temperature outside is {{ temperature }} {{ units }}."]
},
{
"label": "weather.get.success.cloud",
"label": "weather.get.success.now.cloud",
"answers": ["It's cloudy outside and temperature is {{ temperature }} {{ units }}."]
},
{
"label": "weather.get.success.fog",
"label": "weather.get.success.now.fog",
"answers": ["Foggy day today. Temperature outside is {{ temperature }} {{ units }}."]
},
{
"label": "weather.get.success.sleet",
"label": "weather.get.success.now.sleet",
"answers": ["Temperature outside is {{ temperature }} {{ units }}, with freezing rain and sleet."]
},
{
"label": "weather.get.success.wind",
"label": "weather.get.success.now.wind",
"answers": ["Windy day today. Temperature outside is {{ temperature }} {{ units }}."]
},
{
"label": "weather.get.success.unknown",
"label": "weather.get.success.now.unknown",
"answers": ["Temperature outside is {{ temperature }} {{ units }}."]
},

{
"label": "weather.get.success.today.snow",
"answers": [
"Today, it's snowing and the temperature is between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},
{
"label": "weather.get.success.today.rain",
"answers": [
"Today, it's raining and the temperature is between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},
{
"label": "weather.get.success.today.clear",
"answers": [
"Today, the sky is clear and the temperature is between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},
{
"label": "weather.get.success.today.cloud",
"answers": [
"Today, the sky is cloudy and the temperature is between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},
{
"label": "weather.get.success.today.fog",
"answers": [
"Today, it is foggy and the temperature is between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},
{
"label": "weather.get.success.today.sleet",
"answers": [
"Today, the temperature is between {{temperature min}} {{units}} and {{temperature max}} {{units}} with freezing rain."
]
},
{
"label": "weather.get.success.today.wind",
"answers": [
"Today, it's very windy and the temperature is between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},
{
"label": "weather.get.success.today.unknown",
"answers": ["Today, the temperature is between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."]
},

{
"label": "weather.get.success.tomorrow.snow",
"answers": [
"Tomorrow snow will fall out and the temperature will be between {{ temperature_min }} {{ units }} and {{ temperature_max }} {{ units }}."
]
},
{
"label": "weather.get.success.tomorrow.rain",
"answers": [
"Tomorrow it will rain outside and the temperature will be between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},
{
"label": "weather.get.success.tomorrow.clear",
"answers": [
"Tomorrow the sky will be clear outside and the temperature will be between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},
{
"label": "weather.get.success.tomorrow.cloud",
"answers": [
"Tomorrow there will be clouds outside and the temperature will be between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},
{
"label": "weather.get.success.tomorrow.fog",
"answers": [
"Tomorrow there will be fog outside and the temperature will be between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},
{
"label": "weather.get.success.tomorrow.sleet",
"answers": [
"Tomorrow the temperature will be between {{temperature_min}} {{units}} and {{temperature_max}} {{units}} with freezing rain."
]
},
{
"label": "weather.get.success.tomorrow.wind",
"answers": [
"Tomorrow the weather will be windy outside and the temperature will be between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},
{
"label": "weather.get.success.tomorrow.unknown",
"answers": [
"Tomorrow the temperature will be between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},

{
"label": "weather.get.success.after-tomorrow.snow",
"answers": [
"The day after tomorrow it will snow outside and the temperature will be between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},
{
"label": "weather.get.success.after-tomorrow.rain",
"answers": [
"The day after tomorrow it will rain outside and the temperature will be between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},
{
"label": "weather.get.success.after-tomorrow.clear",
"answers": [
"The day after tomorrow the sky will be clear outside and the temperature will be between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},
{
"label": "weather.get.success.after-tomorrow.cloud",
"answers": [
"The day after tomorrow there will be clouds outside and the temperature will be between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},
{
"label": "weather.get.success.after-tomorrow.fog",
"answers": [
"The day after tomorrow there will be fog outside and the temperature will be between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},
{
"label": "weather.get.success.after-tomorrow.sleet",
"answers": [
"The day after tomorrow the temperature is between {{temperature_min}} {{units}} and {{temperature_max}} {{units}} with freezing rain."
]
},
{
"label": "weather.get.success.after-tomorrow.wind",
"answers": [
"The day after tomorrow it will be windy outside and the temperature will be between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},
{
"label": "weather.get.success.after-tomorrow.unknown",
"answers": [
"The day after tomorrow the temperature will be between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},

{
"label": "weather.get.success.day.snow",
"answers": [
"{{day}}, it's going to snow outside and the temperature will be between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},
{
"label": "weather.get.success.day.rain",
"answers": [
"{{ day }}, it will rain outside and the temperature will be between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},
{
"label": "weather.get.success.day.clear",
"answers": [
"{{ day }}, the sky will be clear outside and the temperature will be between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},
{
"label": "weather.get.success.day.cloud",
"answers": [
"{{ day }}, there will be clouds outside and the temperature will be between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},
{
"label": "weather.get.success.day.fog",
"answers": [
"{{ day }} there will be fog outside and the temperature will be between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},
{
"label": "weather.get.success.day.sleet",
"answers": [
"{{ day }} the temperature is between {{temperature_min}} {{units}} and {{temperature_max}} {{units}} with freezing rain."
]
},
{
"label": "weather.get.success.day.wind",
"answers": [
"{{ day }} it will be windy outside and the temperature will be between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},
{
"label": "weather.get.success.day.unknown",
"answers": [
"{{ day }} the temperature will be between {{temperature_min}} {{units}} and {{temperature_max}} {{units}}."
]
},

{
"label": "weather.get.fail",
"answers": ["There was an error while getting the weather."]
Expand All @@ -39,6 +234,10 @@
"label": "weather.get.fail.not-configured",
"answers": ["You need to configure the OpenWeather API in the Integration tab before using this feature."]
},
{
"label": "weather.get.fail.no-weather",
"answers": ["The weather forecast for that day couldn't be found."]
},
{
"label": "weather.get.fail.no-house",
"answers": ["You need to first configure your house and its location in parameters."]
Expand Down
Loading