From 4bc0d2a707a08ea9f7359f46f9989bf156358026 Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 22 May 2024 17:36:33 +0200 Subject: [PATCH] Catch empty grid and inform user to correct config --- application/controllers/Sattimers.php | 16 ++++++++++++++-- application/views/sattimers/index.php | 10 +++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/application/controllers/Sattimers.php b/application/controllers/Sattimers.php index 66332e392..7de010f91 100644 --- a/application/controllers/Sattimers.php +++ b/application/controllers/Sattimers.php @@ -24,10 +24,22 @@ class Sattimers extends CI_Controller { $this->cache->save('SatTimers'.strtoupper($this->stations->find_gridsquare()), $RawData, (60*1)); } - $json = $RawData; - $data['activations'] = json_decode($json, true)['data']; + $json = $RawData; + $response = json_decode($json, true); + if (array_key_exists('data', $response)) { + $data['activations'] = json_decode($json, true)['data'] ?? []; + } else if (array_key_exists('error', $response)) { + $this->session->set_flashdata('message', 'Error: '.$response['error']); + $data['activations'] = []; + } else { + $data['activations'] = []; + } + $data['gridsquare'] = strtoupper($this->stations->find_gridsquare()); + if ($data['gridsquare'] == "0") { + $this->session->set_flashdata('message', lang('dashboard_locations_warning')); + } $data['page_title'] = "Satellite Timers"; diff --git a/application/views/sattimers/index.php b/application/views/sattimers/index.php index 3a05c895d..344b5db89 100644 --- a/application/views/sattimers/index.php +++ b/application/views/sattimers/index.php @@ -2,10 +2,18 @@ var custom_date_format = "";
+ session->flashdata('message')) { ?> + + +

Satellite Timers

-

This data is from https://www.df2et.de/tevel/ calculated for current station location grid .

+ +

This data is from https://www.df2et.de/tevel/ calculated for current station location grid .

+