From a715ae58afa15a98006e2271522bef5a00ca071f Mon Sep 17 00:00:00 2001 From: floppydiskette Date: Sat, 31 Aug 2024 00:47:01 +0100 Subject: Handle any errors if unable to get presence or weather data --- resources/views/components/discord-status.blade.php | 8 ++++++-- resources/views/components/weather.blade.php | 18 +++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) (limited to 'resources') diff --git a/resources/views/components/discord-status.blade.php b/resources/views/components/discord-status.blade.php index 00d2c7a..868fc03 100644 --- a/resources/views/components/discord-status.blade.php +++ b/resources/views/components/discord-status.blade.php @@ -1,3 +1,7 @@ -I'm -

{{ $status["text"] }}!

+@if($status == null) +

Status Unavailable

+@else + I'm +

{{ $status["text"] }}!

+@endif

Time in Britain:

diff --git a/resources/views/components/weather.blade.php b/resources/views/components/weather.blade.php index b4dfcaa..879f1cb 100644 --- a/resources/views/components/weather.blade.php +++ b/resources/views/components/weather.blade.php @@ -1,11 +1,15 @@

Weather Conditions:


-

Temperature: {{ round(($conditions[0]["temp"] - 32) * (5/9), 1) }} degC

-

Rain: {{ ($conditions[0]["rain_rate_last"] * 0.2) }}mm/hr ({{ $conditions[0]["rainfall_daily"] }}mm today)

-@if ($conditions[0]["wind_speed_last"] != 0) -

Wind: {{ round($conditions[0]["wind_speed_last"], 1) }}mph ({{ $conditions[0]["wind_dir_last"] }} deg)

+@if($conditions == null) +

Data Unavailable

@else -

Wind: 0mph

+

Temperature: {{ round(($conditions[0]["temp"] - 32) * (5/9), 1) }} degC

+

Rain: {{ ($conditions[0]["rain_rate_last"] * 0.2) }}mm/hr ({{ $conditions[0]["rainfall_daily"] }}mm today)

+ @if ($conditions[0]["wind_speed_last"] != 0) +

Wind: {{ round($conditions[0]["wind_speed_last"], 1) }}mph ({{ $conditions[0]["wind_dir_last"] }} deg)

+ @else +

Wind: 0mph

+ @endif +

Humidity: {{ round($conditions[0]["hum"], 1) }}%

+

Pressure: {{ round($conditions[2]["bar_sea_level"], 1) }} inHg

@endif -

Humidity: {{ round($conditions[0]["hum"], 1) }}%

-

Pressure: {{ round($conditions[2]["bar_sea_level"], 1) }} inHg

-- cgit v1.2.3-54-g00ecf