diff --git a/frontend/admin/src/App.vue b/frontend/admin/src/App.vue index af18536..6cda36b 100644 --- a/frontend/admin/src/App.vue +++ b/frontend/admin/src/App.vue @@ -45,6 +45,10 @@
  • Журнал событий
  • + +
  • + CRON +
  • diff --git a/frontend/admin/src/router/index.js b/frontend/admin/src/router/index.js index 985d688..1d77fba 100644 --- a/frontend/admin/src/router/index.js +++ b/frontend/admin/src/router/index.js @@ -10,6 +10,7 @@ import LogsView from "@/views/LogsView.vue"; import FormBuilderView from "@/views/FormBuilderView.vue"; import CustomersView from "@/views/CustomersView.vue"; import TeleCartPulseView from "@/views/TeleCartPulseView.vue"; +import CronView from "@/views/CronView.vue"; const router = createRouter({ history: createMemoryHistory(), @@ -25,6 +26,7 @@ const router = createRouter({ {path: '/store', name: 'store', component: StoreView}, {path: '/telegram', name: 'telegram', component: TelegramView}, {path: '/texts', name: 'texts', component: TextsView}, + {path: '/cron', name: 'cron', component: CronView}, ], }); diff --git a/frontend/admin/src/stores/settings.js b/frontend/admin/src/stores/settings.js index 9a2696d..f8ba88d 100644 --- a/frontend/admin/src/stores/settings.js +++ b/frontend/admin/src/stores/settings.js @@ -78,6 +78,10 @@ export const useSettingsStore = defineStore('settings', { pulse: { api_key: '', }, + + cron: { + mode: 'disabled', + }, }, }), diff --git a/frontend/admin/src/views/CronView.vue b/frontend/admin/src/views/CronView.vue new file mode 100644 index 0000000..76dc620 --- /dev/null +++ b/frontend/admin/src/views/CronView.vue @@ -0,0 +1,108 @@ + + + diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/bastion/Handlers/SettingsHandler.php b/module/oc_telegram_shop/upload/oc_telegram_shop/bastion/Handlers/SettingsHandler.php index e7e7dbf..d48aade 100755 --- a/module/oc_telegram_shop/upload/oc_telegram_shop/bastion/Handlers/SettingsHandler.php +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/bastion/Handlers/SettingsHandler.php @@ -69,10 +69,19 @@ class SettingsHandler 'sliders', 'mainpage_blocks', 'pulse', + 'cron', ]); + if (!isset($data['cron']['mode'])) { + $data['cron']['mode'] = 'disabled'; + } + $data['forms'] = []; + // Add CRON system details (read-only) + $data['cron']['cli_path'] = realpath(DIR_SYSTEM . '../cli.php'); + $data['cron']['last_run'] = $this->getLastCronRunDate(); + $forms = $this->builder->newQuery() ->from('telecart_forms') ->get(); @@ -103,6 +112,12 @@ class SettingsHandler $this->validate($input); + // Remove dynamic properties before saving + if (isset($input['cron'])) { + unset($input['cron']['cli_path']); + unset($input['cron']['last_run']); + } + $this->settingsUpdateService->update( Arr::getWithKeys($input, [ 'app', @@ -114,6 +129,7 @@ class SettingsHandler 'sliders', 'mainpage_blocks', 'pulse', + 'cron', ]), ); @@ -145,4 +161,25 @@ class SettingsHandler return new JsonResponse([], Response::HTTP_ACCEPTED); } + + private function getLastCronRunDate(): ?string + { + try { + // Since we are in SettingsHandler, we already have access to container or we can inject SchedulerService + // But SettingsHandler is constructed via DI. Let's add SchedulerService to constructor. + // For now, let's use global retrieval via cache if possible, or assume it's injected. + // But wait, getLastCronRunDate logic was in controller. + // SchedulerService stores last run in cache. We have $this->cache here. + + $lastRunTimestamp = $this->cache->get("scheduler.global_last_run"); + + if ($lastRunTimestamp) { + return date('d.m.Y H:i:s', (int)$lastRunTimestamp); + } + + return null; + } catch (Exception $e) { + return null; + } + } }