From 825d3df7762836d161451728dee042ff51fc48a2 Mon Sep 17 00:00:00 2001 From: Kavalar Date: Tue, 5 Nov 2024 13:44:08 +0300 Subject: [PATCH] module shop client fix --- .env.example | 3 +++ .../ModuleShopClientController.php | 4 ++-- kernel/views/module/index.php | 24 ++++++++++++++----- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/.env.example b/.env.example index a9a285c..ac75a63 100644 --- a/.env.example +++ b/.env.example @@ -10,4 +10,7 @@ DB_PREFIX='' VIEWS_PATH=/views VIEWS_CACHE_PATH=/views_cache +MODULE_SHOP_URL='http://localhost:8383/api' +MODULE_SHOP_TOKEN='eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.W10.Sisyc1bgy03TI0wT11oKhgh5J6vR9XWDOV56L6BiTJY' + SECRET_KEY='' \ No newline at end of file diff --git a/kernel/modules/module_shop_client/controllers/ModuleShopClientController.php b/kernel/modules/module_shop_client/controllers/ModuleShopClientController.php index a35dd06..abcdb6f 100644 --- a/kernel/modules/module_shop_client/controllers/ModuleShopClientController.php +++ b/kernel/modules/module_shop_client/controllers/ModuleShopClientController.php @@ -33,8 +33,8 @@ class ModuleShopClientController extends AdminController { $per_page = 8; - $token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.W10.POQZmGB7EZIayINtYhzu5r1rdgZhF9qPJpaQkl_g6pU'; - $modules_info = $this->client->request('GET', 'http://igfs.loc/api/module_shop/gb_slug', [ + $token = $_ENV['MODULE_SHOP_TOKEN']; + $modules_info = $this->client->request('GET', $_ENV['MODULE_SHOP_URL'] . '/module_shop/gb_slug', [ 'headers' => [ 'Authorization' => 'Bearer ' . $token, ] diff --git a/kernel/views/module/index.php b/kernel/views/module/index.php index 6cdc2fd..70c8696 100644 --- a/kernel/views/module/index.php +++ b/kernel/views/module/index.php @@ -26,15 +26,14 @@ $info_to_table['data'] = $modules_info; $table = new \Itguild\Tables\ListJsonTable(json_encode($info_to_table, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); -$table->addAction(function ($row, $url) use ($moduleService){ +$table->addAction(function ($row, $url) use ($moduleService) { $slug = $row['slug']; - if ($moduleService->isActive($slug)){ + if ($moduleService->isActive($slug)) { $label = "Деактивировать"; $btn_type = "warning"; $btn = "$label"; - } - else { + } else { $label = "Активировать"; $btn_type = "primary"; $btn = "$label"; @@ -43,15 +42,28 @@ $table->addAction(function ($row, $url) use ($moduleService){ return $btn; }); -$table->addAction(function ($row, $url) use ($moduleService){ +$table->addAction(function ($row, $url) use ($moduleService) { $slug = $row['slug']; return "Просмотр"; }); -$table->addAction(function ($row, $url) use ($moduleService){ +$table->addAction(function ($row, $url) use ($moduleService) { $slug = $row['slug']; return "Обновить"; }); $table->create(); + + +?> + +
+render();