From 723e99ebedc231e502707621ec169cd1da57aa57 Mon Sep 17 00:00:00 2001 From: Focuslinkstech <45756999+Focuslinkstech@users.noreply.github.com> Date: Wed, 11 Sep 2024 14:19:13 +0100 Subject: [PATCH] fix panel headers in css, add cron job monitor to check if cron is running, has run, or not setup --- system/controllers/dashboard.php | 6 +++ system/cron.php | 69 ++++++++++++++++++-------------- ui/ui/dashboard.tpl | 17 ++++++++ ui/ui/sections/header.tpl | 30 ++++++++++++-- 4 files changed, 87 insertions(+), 35 deletions(-) diff --git a/system/controllers/dashboard.php b/system/controllers/dashboard.php index 4d1c9849..9f1185b0 100644 --- a/system/controllers/dashboard.php +++ b/system/controllers/dashboard.php @@ -214,6 +214,12 @@ if ($config['router_check']) { $ui->assign('routeroffs', $routeroffs); } +$timestampFile = "$UPLOAD_PATH/cron_last_run.txt"; +if (file_exists($timestampFile)) { + $lastRunTime = file_get_contents($timestampFile); + $ui->assign('run_date', date('Y-m-d h:i:s A', $lastRunTime)); +} + // Assign the monthly sales data to Smarty $ui->assign('start_date', $start_date); $ui->assign('current_date', $current_date); diff --git a/system/cron.php b/system/cron.php index e4e6719c..81d9f423 100644 --- a/system/cron.php +++ b/system/cron.php @@ -1,6 +1,27 @@ where('enabled', '1')->find_many(); if (!$routers) { echo "No active routers found in the database.\n"; @@ -186,14 +187,20 @@ if ($config['router_check']) { Message::SendEmail($adminEmail, $subject, $message); sendTelegram($message); } - - if (defined('PHP_SAPI') && PHP_SAPI === 'cli') { - echo "Cronjob finished\n"; - } else { - echo ""; - } - - flock($lock, LOCK_UN); - fclose($lock); - unlink($lockFile); + echo "Router monitoring finished\n"; } + + +if (defined('PHP_SAPI') && PHP_SAPI === 'cli') { + echo "Cronjob finished\n"; +} else { + echo ""; +} + +flock($lock, LOCK_UN); +fclose($lock); +unlink($lockFile); + +$timestampFile = "$UPLOAD_PATH/cron_last_run.txt"; +file_put_contents($timestampFile, time()); + diff --git a/ui/ui/dashboard.tpl b/ui/ui/dashboard.tpl index eb6788da..7a998ba8 100644 --- a/ui/ui/dashboard.tpl +++ b/ui/ui/dashboard.tpl @@ -194,6 +194,23 @@ {/if} + {if $run_date} + {if $current_time - $run_time > 3600} +
+
  {Lang::T('Cron has not run for over 1 hour. Please + check your setup.')}
+
+ {else} +
+
{Lang::T('Cron Job last ran on')}: {$run_date}
+
+ {/if} + {else} +
+
  {Lang::T('Cron appear not been setup, please check + your cron setup.')}
+
+ {/if} {if $_c['hide_pg'] != 'yes'}
{Lang::T('Payment Gateway')}: {str_replace(',',', ',$_c['payment_gateway'])} diff --git a/ui/ui/sections/header.tpl b/ui/ui/sections/header.tpl index bba3dbce..34b7f1e9 100644 --- a/ui/ui/sections/header.tpl +++ b/ui/ui/sections/header.tpl @@ -148,12 +148,26 @@ color: inherit; background-color: transparent; border-color: transparent; + border-bottom-right-radius: 21px; + border-bottom-left-radius: 21px; } - .panel-primary>.panel-heading { - color: inherit; - background-color: transparent; - border-color: transparent; + .panel-success>.panel-heading { + border-bottom-right-radius: 21px; + border-bottom-left-radius: 21px; + } + + .panel-warning>.panel-heading { + border-bottom-right-radius: 21px; + border-bottom-left-radius: 21px; + } + + .panel-danger>.panel-heading { + color: #a94442; + background-color: #f2dede; + border-color: #ebccd1; + border-bottom-right-radius: 21px; + border-bottom-left-radius: 21px; } .panel-heading { @@ -656,6 +670,9 @@ } .toggle-container { + position: absolute; + top: 17px; + right: 15px; cursor: pointer; } @@ -666,6 +683,11 @@ } @media (max-width: 600px) { + .toggle-container { + top: 15px; + right: 60px; + } + .toggle-container .toggle-icon { font-size: 20px; color: rgb(100 116 139);