Be more resilient in DateTimeWeather widget about custom temperature/humidity names or non-numeric data

This commit is contained in:
Fabio Manganiello 2023-04-24 12:48:51 +02:00
parent 5638c567ff
commit e955ffc018
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774
15 changed files with 28 additions and 22 deletions

View file

@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><link rel="stylesheet" href="/fonts/poppins.css"><title>platypush</title><script defer="defer" type="module" src="/static/js/chunk-vendors.95bedba1.js"></script><script defer="defer" type="module" src="/static/js/app.43713bf2.js"></script><link href="/static/css/chunk-vendors.0fcd36f0.css" rel="stylesheet"><link href="/static/css/app.11a00465.css" rel="stylesheet"><script defer="defer" src="/static/js/chunk-vendors-legacy.79dede0c.js" nomodule></script><script defer="defer" src="/static/js/app-legacy.39523ae1.js" nomodule></script></head><body><noscript><strong>We're sorry but platypush doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><link rel="stylesheet" href="/fonts/poppins.css"><title>platypush</title><script defer="defer" type="module" src="/static/js/chunk-vendors.95bedba1.js"></script><script defer="defer" type="module" src="/static/js/app.6a5f1fbc.js"></script><link href="/static/css/chunk-vendors.0fcd36f0.css" rel="stylesheet"><link href="/static/css/app.11a00465.css" rel="stylesheet"><script defer="defer" src="/static/js/chunk-vendors-legacy.79dede0c.js" nomodule></script><script defer="defer" src="/static/js/app-legacy.4538d5dd.js" nomodule></script></head><body><noscript><strong>We're sorry but platypush doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -13,15 +13,15 @@
<div class="row sensors-container">
<div class="row" v-if="_showSensors && Object.keys(sensors).length">
<div class="col-3">
<Sensor icon-class="fas fa-thermometer-half" :value="sensors.temperature" unit="°"
v-if="typeof sensors.temperature === 'number'" />
<Sensor icon-class="fas fa-thermometer-half" :value="sensors[sensorTemperatureAttr]" unit="°"
v-if="sensors[sensorTemperatureAttr] != null" />
</div>
<div class="col-6">&nbsp;</div>
<div class="col-3">
<Sensor icon-class="fas fa-tint" :value="sensors.humidity" unit="%"
v-if="typeof sensors.humidity === 'number'" />
<Sensor icon-class="fas fa-tint" :value="sensors[sensorHumidityAttr]" unit="%"
v-if="sensors[sensorHumidityAttr] != null" />
</div>
</div>
</div>
@ -152,11 +152,17 @@ export default {
methods: {
onSensorData(event) {
if (this.sensorTemperatureAttr in event.data)
this.sensors.temperature = event.data.temperature
if (
this.sensorTemperatureAttr in event.data &&
typeof event.data[this.sensorTemperatureAttr] === 'number'
)
this.sensors.temperature = event.data[this.sensorTemperatureAttr]
if (this.sensorHumidityAttr in event.data)
this.sensors.humidity = event.data.humidity
if (
this.sensorHumidityAttr in event.data &&
typeof event.data[this.sensorHumidityAttr] === 'number'
)
this.sensors.humidity = event.data[this.sensorHumidityAttr]
},
},