From 122c360504a8a4b1b4fcc006770a3d1b1b0b6b70 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 22 Oct 2022 10:36:24 +0200 Subject: [PATCH] continue drafting NO_CI --- app/server/cOMS | 2 +- app/server/main.cpp | 37 ++++- app/web/Controllers/FrontController.php | 129 ++++++++++++++++++ app/web/WebApplication.php | 14 +- .../App flow.drawio.png | Bin 5 files changed, 178 insertions(+), 4 deletions(-) rename Untitled Diagram.drawio(4).png => img/App flow.drawio.png (100%) diff --git a/app/server/cOMS b/app/server/cOMS index 7b31df3..324801f 160000 --- a/app/server/cOMS +++ b/app/server/cOMS @@ -1 +1 @@ -Subproject commit 7b31df32bccde804f13ed288f4881a27bf6f5ac9 +Subproject commit 324801f79a04c39558c4ca0d5dcb88236a851d26 diff --git a/app/server/main.cpp b/app/server/main.cpp index 69f7846..48a8bcc 100644 --- a/app/server/main.cpp +++ b/app/server/main.cpp @@ -31,6 +31,8 @@ App app; int main(int argc, char **argv) { + /* --------------- Basic setup --------------- */ + char *arg = Utils::ApplicationUtils::compile_arg_line(argc, argv); // Set program path as cwd @@ -43,13 +45,40 @@ int main(int argc, char **argv) Utils::ApplicationUtils::chdir_application(cwd, argv[0]); - // Load config + // Check config if (!Utils::FileUtils::file_exists("config.json")) { Controller::ApiController::notInstalled(argc, argv); return -1; } + /* --------------- App setup --------------- */ + + // Load config + FILE *in = fopen("config.json", "r"); + if (in == NULL) { + return -1; + } + + app.config = nlohmann::json::parse(in); + + fclose(in); + + // Setup db connection + DataStorage::Database::DbConnectionConfig dbdata = (DataStorage::Database::DbConnectionConfig) { + db = DataStorage::Database::database_type_from_str(&app.config["db"]["core"]["masters"]["admin"]["db"]), + database = &app.config["db"]["core"]["masters"]["admin"]["database"], + host = &app.config["db"]["core"]["masters"]["admin"]["host"], + port = app.config["db"]["core"]["masters"]["admin"]["port"], + login = &app.config["db"]["core"]["masters"]["admin"]["login"], + password = &app.config["db"]["core"]["masters"]["admin"]["password"], + }; + + app->db = DataStorage::Database::create_connection(dbdata); + app->db->connect(); + + /* --------------- Handle request --------------- */ + // Handle routes Stdlib::HashTable::ht *routes = generate_routes(); if (routes == NULL) { @@ -61,8 +90,14 @@ int main(int argc, char **argv) // Dispatch found endpoint (*ptr)(argc, argv); + /* --------------- Cleanup --------------- */ + + app->db->close(); + $app->db = NULL; + Stdlib::HashTable::free_table(routes); free(routes); + routes = NULL; free(arg); arg = NULL; diff --git a/app/web/Controllers/FrontController.php b/app/web/Controllers/FrontController.php index 6413a9f..012631b 100644 --- a/app/web/Controllers/FrontController.php +++ b/app/web/Controllers/FrontController.php @@ -5,4 +5,133 @@ namespace Controllers; class FrontController { + + /* Service provider */ + + public function viewFrontend(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + + } + + public function viewFrontendLogin(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + + } + + public function viewFrontendForgot(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + + } + + public function viewFrontendPricing(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + + } + + public function viewFrontendContact(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + + } + + public function viewFrontendImprint(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + + } + + public function viewFrontendTerms(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + + } + + public function viewFrontendAbout(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + + } + + public function viewFrontendPrivacy(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + + } + + public function viewFrontendDemo(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + + } + + public function viewFrontendOrganizationList(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + + } + + public function viewFrontendOrganizationSetting(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + + } + + public function viewFrontendUserList(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + + } + + public function viewFrontendUserSetting(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + + } + + /* User */ + + public function viewBackendDashboard(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + + } + + public function viewBackendLogin(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + + } + + public function viewBackendForgot(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + + } + + public function viewBackendOrgSettings(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + + } + + public function viewBackendUserList(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + + } + + public function viewBackendUserSettings(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + + } + + public function viewBackendPosts(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + + } + + public function viewBackendImprint(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + + } + + public function viewBackendTerms(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + + } + + public function viewBackendPrivacy(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + + } + + public function viewBuildSoftware(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + + } } diff --git a/app/web/WebApplication.php b/app/web/WebApplication.php index 74d0122..6c0df97 100644 --- a/app/web/WebApplication.php +++ b/app/web/WebApplication.php @@ -159,7 +159,12 @@ class WebApplication extends ApplicationAbstract $appName = $this->getApplicationNameFromString($appName); if ($appName !== 'E500') { - UriFactory::setQuery('/prefix', (empty(UriFactory::getQuery('/prefix')) ? '' : UriFactory::getQuery('/prefix') . '/') . $uri->getPathElement($subDirDepth + 1) . '/'); + UriFactory::setQuery( + '/prefix', + empty(UriFactory::getQuery('/prefix') + ? '' + : UriFactory::getQuery('/prefix') . '/') . $uri->getPathElement($subDirDepth + 1) . '/' + ); return $appName; } @@ -170,7 +175,12 @@ class WebApplication extends ApplicationAbstract $appName = $this->getApplicationNameFromString($appName); if ($appName !== 'E500') { - UriFactory::setQuery('/prefix', (empty(UriFactory::getQuery('/prefix')) ? '' : UriFactory::getQuery('/prefix') . '/') . $uri->getPathElement($subDirDepth + 1) . '/'); + UriFactory::setQuery( + '/prefix', + empty(UriFactory::getQuery('/prefix') + ? '' + : UriFactory::getQuery('/prefix') . '/') . $uri->getPathElement($subDirDepth + 1) . '/' + ); return $appName; } diff --git a/Untitled Diagram.drawio(4).png b/img/App flow.drawio.png similarity index 100% rename from Untitled Diagram.drawio(4).png rename to img/App flow.drawio.png