From a3eaf16fd65f88753c8b761b8f9d718bf8b8f01a Mon Sep 17 00:00:00 2001 From: GamerClassN7 Date: Tue, 23 Feb 2021 12:41:34 +0100 Subject: [PATCH] Automation Endpoints Create --- app/Routes.php | 12 +++++++++++- app/api/AutomationsApi.php | 11 +++++++++++ app/models/managers/AutomationManager.php | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/Routes.php b/app/Routes.php index 161cb23..9430f50 100644 --- a/app/Routes.php +++ b/app/Routes.php @@ -24,24 +24,34 @@ $router->any('/plugins', 'Plugins'); $router->any('/ajax', 'Ajax'); $router->any('/oauth', 'Oauth'); -//Vue APP +//Vue APP - Authentication $router->post('/api/login', 'AuthApi@login'); $router->post('/api/logout', 'AuthApi@logout'); + +//Vue APP - Rooms $router->get('/api/rooms', 'RoomsApi@default'); $router->get('/api/rooms/{roomId}/update', 'RoomsApi@update'); $router->get('/api/devices', 'DevicesApi@default'); + $router->get('/api/plugins', 'PluginsApi@default'); + $router->get('/api/users', 'UsersApi@default'); + +//Vue APP - Server Info $router->get('/api/server', 'ServerApi@default'); $router->get('/api/server/log', 'ServerApi@logStatus'); +//Vue APP - Widgets $router->post('/api/widgets/{widgetId}/run', 'WidgetApi@run'); $router->get('/api/widgets/{widgetId}/detail', 'WidgetApi@detail'); $router->get('/api/widgets/{widgetId}/detail/{period}', 'WidgetApi@detail'); +//Vue APP - Automations Endpoints $router->get('/api/automations', 'AutomationsApi@default'); $router->get('/api/automations/{automationId}/detail', 'AutomationsApi@detail'); +$router->post('/api/automations/create', 'AutomationsApi@create'); + //cron diff --git a/app/api/AutomationsApi.php b/app/api/AutomationsApi.php index 498d54e..00f051f 100644 --- a/app/api/AutomationsApi.php +++ b/app/api/AutomationsApi.php @@ -20,4 +20,15 @@ class AutomationsApi extends ApiController $this->response($response); } + + public function create() + { + //$this->requireAuth(); + $obj = $this->input; + + $response = []; + $response = AutomationManager::create($obj['name'],$obj['days'], $obj['tasks'], $obj['conditions']); + + $this->response(['value'=>'OK']); + } } diff --git a/app/models/managers/AutomationManager.php b/app/models/managers/AutomationManager.php index b191032..ed5ef4c 100644 --- a/app/models/managers/AutomationManager.php +++ b/app/models/managers/AutomationManager.php @@ -34,6 +34,7 @@ class AutomationManager{ } } catch(PDOException $error) { echo $error->getMessage(); + return false; die(); } }