diff --git a/app/Http/Controllers/API/SettingsAPIController.php b/app/Http/Controllers/API/SettingsAPIController.php new file mode 100644 index 0000000..caf50ca --- /dev/null +++ b/app/Http/Controllers/API/SettingsAPIController.php @@ -0,0 +1,27 @@ +settings = $settingsService; + $this->render = $renderService; + } + + public function publish(Request $request) + { + $body = json_decode($request->getContent()); + $result = $this->render->publishAll(); + return response()->json($result)->header('Content-Type', 'application/json'); + } +} diff --git a/app/Services/RenderService.php b/app/Services/RenderService.php index f0ea49b..63fd4dd 100644 --- a/app/Services/RenderService.php +++ b/app/Services/RenderService.php @@ -25,6 +25,35 @@ class RenderService $this->theme = $this->settings->getGlobal()['theme']; } + public function publishAll() + { + $message = []; + $dynamicRender = $this->settings->getGlobal()['dynamicRender']; + if (isset($dynamicRender) && $dynamicRender === 'true') { + $message = [ + 'message' => 'Auto Rendering is already enabled!', + 'type' => 'RENDER_SUCCESS', + ]; + } else { + try { + $this->archive(); + $this->tags(); + $this->pages(); + $message = [ + 'message' => 'Site Rendered. GOOD EFFORT', + 'type' => 'RENDER_SUCCESS', + ]; + } catch (Error $error) { + $message = [ + 'message' => 'Issue With Rendering. DONT PANIC', + 'type' => 'RENDER_ERROR', + ]; + } + } + + return $message; + } + public function archive() { $template = $this->theme . '.archive'; diff --git a/public/assets/scripts/dash/app/EditSettings.js b/public/assets/scripts/dash/app/EditSettings.js new file mode 100644 index 0000000..bf352ad --- /dev/null +++ b/public/assets/scripts/dash/app/EditSettings.js @@ -0,0 +1,9 @@ +import Settings from './controllers/SettingsIndex.js'; + +document.addEventListener( + 'DOMContentLoaded', + function () { + new Settings(); + }, + false +); diff --git a/public/assets/scripts/dash/app/actions/Mailer.js b/public/assets/scripts/dash/app/actions/Mailer.js index 20e1eb4..d099153 100644 --- a/public/assets/scripts/dash/app/actions/Mailer.js +++ b/public/assets/scripts/dash/app/actions/Mailer.js @@ -1,44 +1,44 @@ -import FipamoAdminAPI from "../../libraries/FipamoAdminAPI"; -import Notficaton from "../ui/Notifications"; +import FipamoAdminAPI from '../../libraries/FipamoAdminAPI.js'; +import Notficaton from '../ui/Notifications.js'; const notify = new Notficaton(); export default class Mailer { - //-------------------------- - // constructor - //-------------------------- - constructor() {} - //-------------------------- - // methods - //-------------------------- - sendMail() { - let mailData = { - content: "This is a test email" - }; - let admin = new FipamoAdminAPI(); - admin - .sendMail(mailData) - .then((result) => { - notify.alert(result.message, true); - }) - .catch((err) => { - notify.alert(err.message, false); - }); - } - testMail() { - let mailData = { - content: "This is a test email", - mail_task: "TESTING" - }; - let admin = new FipamoAdminAPI(); - admin - .sendMail(mailData) - .then((result) => { - notify.alert(result.message, true); - }) - .catch((err) => { - notify.alert(err.message, false); - }); - } - //-------------------------- - // event handlers - //-------------------------- + //-------------------------- + // constructor + //-------------------------- + constructor() {} + //-------------------------- + // methods + //-------------------------- + sendMail() { + let mailData = { + content: 'This is a test email' + }; + let admin = new FipamoAdminAPI(); + admin + .sendMail(mailData) + .then(result => { + notify.alert(result.message, true); + }) + .catch(err => { + notify.alert(err.message, false); + }); + } + testMail() { + let mailData = { + content: 'This is a test email', + mail_task: 'TESTING' + }; + let admin = new FipamoAdminAPI(); + admin + .sendMail(mailData) + .then(result => { + notify.alert(result.message, true); + }) + .catch(err => { + notify.alert(err.message, false); + }); + } + //-------------------------- + // event handlers + //-------------------------- } diff --git a/public/assets/scripts/dash/app/controllers/SettingsIndex.js b/public/assets/scripts/dash/app/controllers/SettingsIndex.js index e6e04eb..b30a938 100644 --- a/public/assets/scripts/dash/app/controllers/SettingsIndex.js +++ b/public/assets/scripts/dash/app/controllers/SettingsIndex.js @@ -1,9 +1,9 @@ -import SettingsActions from '../actions/SettingsActions'; -import Maintenance from './MaintenanceManager'; -import FipamoAdminAPI, { TASK_SYNC_SETTNIGS } from '../../libraries/FipamoAdminAPI'; -import * as DataEvent from '../../../src/com/events/DataEvent'; -import Mailer from '../actions/Mailer'; -import Notifications from '../ui/Notifications'; +import SettingsActions from '../actions/SettingsActions.js'; +import Maintenance from './MaintenanceManager.js'; +import FipamoAdminAPI, { TASK_SYNC_SETTNIGS } from '../../libraries/FipamoAdminAPI.js'; +import * as DataEvent from '../../../dash/app/events/DataEvent.js'; +import Mailer from '../actions/Mailer.js'; +import Notifications from '../ui/Notifications.js'; const notify = new Notifications(); export default class SettingsIndex { //-------------------------- diff --git a/public/assets/scripts/dash/libraries/FipamoAdminAPI.js b/public/assets/scripts/dash/libraries/FipamoAdminAPI.js index d27d7fc..8290439 100644 --- a/public/assets/scripts/dash/libraries/FipamoAdminAPI.js +++ b/public/assets/scripts/dash/libraries/FipamoAdminAPI.js @@ -189,7 +189,7 @@ class FipamoAdminAPI { //API_PUBLISH_PAGES, this.baseURL ? this.baseURL + API_PUBLISH_PAGES : API_PUBLISH_PAGES, TASK_PUBLISH_SITE, - REQUEST_TYPE_POST, + REQUEST_TYPE_PUT, CONTENT_TYPE_JSON, data ) diff --git a/resources/views/back/settings.blade.php b/resources/views/back/settings.blade.php index 684f7a8..897bd2c 100644 --- a/resources/views/back/settings.blade.php +++ b/resources/views/back/settings.blade.php @@ -110,3 +110,6 @@ @endsection + @section('scripting') + + @endsection diff --git a/routes/api.php b/routes/api.php index ee66c67..5a90610 100644 --- a/routes/api.php +++ b/routes/api.php @@ -4,6 +4,7 @@ use Illuminate\Support\Facades\Route; use App\Http\Controllers\API\AuthAPIController; use App\Http\Controllers\API\PageAPIController; use App\Http\Controllers\API\FileUploadAPIController; +use App\Http\Controllers\API\SettingsAPIController; /* |-------------------------------------------------------------------------- @@ -23,3 +24,5 @@ Route::put("/v1/page/write", [PageAPIController::class, 'write']); Route::post("/v1/page/create", [PageAPIController::class, 'create']); //handle file uploads Route::post("/v1/files", [FileUploadAPIController::class, 'upload']); +//settings +Route::put("/v1/settings/publish", [SettingsAPIController::class, 'publish']);