From fb353d1bc83ec9e10ab43188c3b49757e353f8ff Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 2 May 2024 14:16:04 +0200 Subject: [PATCH] Removed AdminLTE, some minor improvements --- Core/API/TestRedis.class.php | 36 +++ Core/Localization/de_DE/account.php | 1 + Core/Localization/de_DE/general.php | 4 + Core/Localization/de_DE/settings.php | 3 + Core/Localization/en_US/account.php | 1 + Core/Localization/en_US/general.php | 4 + Core/Localization/en_US/settings.php | 3 + Core/Templates/admin.twig | 1 - README.md | 12 +- docs/LICENSE_ADMINLTE | 20 -- react/admin-panel/public/index.html | 3 - react/admin-panel/src/AdminDashboard.jsx | 55 ++-- react/admin-panel/src/App.jsx | 5 +- react/admin-panel/src/elements/footer.jsx | 21 +- react/admin-panel/src/elements/header.jsx | 57 ---- react/admin-panel/src/elements/sidebar.js | 292 +++++++++++++----- .../admin-panel/src/elements/view-content.jsx | 31 ++ react/admin-panel/src/res/adminlte.min.css | 12 - .../admin-panel/src/res/adminlte.min.css.map | 1 - .../src/views/access-control-list.js | 94 +++--- .../admin-panel/src/views/group/group-edit.js | 147 ++++----- .../admin-panel/src/views/group/group-list.js | 60 ++-- react/admin-panel/src/views/log-view.js | 132 ++++---- react/admin-panel/src/views/overview.js | 243 ++++++++------- .../src/views/profile/change-password-box.js | 2 +- .../admin-panel/src/views/profile/profile.js | 40 +-- .../admin-panel/src/views/route/route-edit.js | 70 ++--- .../admin-panel/src/views/route/route-list.js | 182 ++++++----- .../src/views/settings/settings.js | 107 +++---- react/admin-panel/src/views/user/user-edit.js | 39 +-- react/admin-panel/src/views/user/user-list.js | 62 ++-- react/package.json | 3 +- react/shared/api.js | 5 + react/shared/elements/data-table.js | 5 +- react/shared/elements/icon.jsx | 24 -- react/shared/elements/table-body-striped.jsx | 12 + 36 files changed, 916 insertions(+), 873 deletions(-) create mode 100644 Core/API/TestRedis.class.php delete mode 100644 docs/LICENSE_ADMINLTE delete mode 100644 react/admin-panel/src/elements/header.jsx create mode 100644 react/admin-panel/src/elements/view-content.jsx delete mode 100644 react/admin-panel/src/res/adminlte.min.css delete mode 100644 react/admin-panel/src/res/adminlte.min.css.map delete mode 100644 react/shared/elements/icon.jsx create mode 100644 react/shared/elements/table-body-striped.jsx diff --git a/Core/API/TestRedis.class.php b/Core/API/TestRedis.class.php new file mode 100644 index 0000000..dcdb313 --- /dev/null +++ b/Core/API/TestRedis.class.php @@ -0,0 +1,36 @@ +context->getSettings(); + if (!$settings->isRateLimitingEnabled()) { + return $this->createError("Rate Limiting is currently disabled"); + } + + $connection = $this->context->getRedis(); + if ($connection === null || !$connection->isConnected()) { + return $this->createError("Redis connection failed"); + } + + return $this->success; + } + + public static function getDescription(): string { + return "Allows users to test the redis connection with the configured credentials."; + } + + public static function getDefaultPermittedGroups(): array { + return [Group::ADMIN]; + } +} diff --git a/Core/Localization/de_DE/account.php b/Core/Localization/de_DE/account.php index 998c4d5..603b938 100644 --- a/Core/Localization/de_DE/account.php +++ b/Core/Localization/de_DE/account.php @@ -55,6 +55,7 @@ return [ "active" => "Aktiv", "group" => "Gruppe", "no_members" => "Keine Mitglieder in dieser Gruppe", + "user_list_placeholder" => "Keine Benutzer zum Anzeigen", # profile picture "change_picture" => "Profilbild ändern", diff --git a/Core/Localization/de_DE/general.php b/Core/Localization/de_DE/general.php index c7e307a..a994ede 100644 --- a/Core/Localization/de_DE/general.php +++ b/Core/Localization/de_DE/general.php @@ -83,4 +83,8 @@ return [ "datefns_time_format_precise" => "HH:mm:ss", "datefns_datetime_format" => "dd.MM.yyyy HH:mm", "datefns_datetime_format_precise" => "dd.MM.yyyy HH:mm:ss", + + # localization + "error_language_fetch" => "Fehler beim Holen der Sprachen", + "error_language_set" => "Fehler beim Setzen der Sprache", ]; \ No newline at end of file diff --git a/Core/Localization/de_DE/settings.php b/Core/Localization/de_DE/settings.php index 4c3c14a..a286569 100644 --- a/Core/Localization/de_DE/settings.php +++ b/Core/Localization/de_DE/settings.php @@ -55,6 +55,9 @@ return [ "redis_host" => "Redis Host", "redis_port" => "Redis Port", "redis_password" => "Redis Passwort", + "redis_test" => "Verbindung testen", + "redis_test_error" => "Redis-Verbindung fehlgeschlagen, überprüfen Sie die Daten.", + "redis_test_success" => "Redis-Verbindung erfolgreich aufgebaut.", # dialog "fetch_settings_error" => "Fehler beim Holen der Einstellungen", diff --git a/Core/Localization/en_US/account.php b/Core/Localization/en_US/account.php index a3ba6e6..4454a39 100644 --- a/Core/Localization/en_US/account.php +++ b/Core/Localization/en_US/account.php @@ -57,6 +57,7 @@ return [ "group" => "Group", "no_members" => "No members in this group", "edit_profile" => "Edit Profile", + "user_list_placeholder" => "No users to display", # profile picture "change_picture" => "Change profile picture", diff --git a/Core/Localization/en_US/general.php b/Core/Localization/en_US/general.php index aaa8366..8dff1b9 100644 --- a/Core/Localization/en_US/general.php +++ b/Core/Localization/en_US/general.php @@ -83,4 +83,8 @@ return [ "datefns_time_format_precise" => "pp", "datefns_datetime_format" => "MM/dd/yyyy p", "datefns_datetime_format_precise" => "MM/dd/yyyy pp", + + # localization + "error_language_fetch" => "Error fetching languages", + "error_language_set" => "Error setting language", ]; \ No newline at end of file diff --git a/Core/Localization/en_US/settings.php b/Core/Localization/en_US/settings.php index 06a42b4..3cf055d 100644 --- a/Core/Localization/en_US/settings.php +++ b/Core/Localization/en_US/settings.php @@ -55,6 +55,9 @@ return [ "redis_host" => "Redis host", "redis_port" => "Redis port", "redis_password" => "Redis password", + "redis_test" => "Test Connection", + "redis_test_error" => "Redis Connection failed, check your credentials.", + "redis_test_success" => "Redis Connection successfully established.", # dialog "fetch_settings_error" => "Error fetching settings", diff --git a/Core/Templates/admin.twig b/Core/Templates/admin.twig index 221aaa3..bfc3328 100644 --- a/Core/Templates/admin.twig +++ b/Core/Templates/admin.twig @@ -2,7 +2,6 @@ {% block head %} {{ site.name }} - {{ L("admin.title") }} - {% endblock %} {% block body %} diff --git a/README.md b/README.md index 05b23b9..567d297 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,10 @@ The compiled dist files will be automatically moved to `/js`. To spawn a temporary development server, run: ```bash +php cli frontend dev +``` +or directly via yarn: +```bash cd react yarn workspace $project run dev ``` @@ -97,7 +101,11 @@ An endpoint consists of two important functions: To create an API category containing multiple endpoints, a parent class inheriting from `Request`, e.g. `class MultipleAPI extends Request` is required. All endpoints inside this category then inherit from the `MultipleAPI` class. -The classes must be present inside the [API](/Core/API) directory according to the other endpoints. +The classes must be present inside the [API](/Site/API) directory according to the other endpoints. +You can easily create new classes using the template command: +```bash +php cli.php api add +``` ### Access Control @@ -355,7 +363,7 @@ php cli.php api # interactive wizard │ ├── shared # shared source files, including API and localization │ ├── admin-panel # the admin panel source files │ ├── dist # compiler output -├── [js/css/img/fonts/files/docs] # static web assets, files, licenses +├── [js/css/img/fonts/files] # static web assets, files ├── docker # docker configuration files and build scripts └── test # php unit & integraton test files ``` diff --git a/docs/LICENSE_ADMINLTE b/docs/LICENSE_ADMINLTE deleted file mode 100644 index 0ed9554..0000000 --- a/docs/LICENSE_ADMINLTE +++ /dev/null @@ -1,20 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014-2018 almasaeed2010 - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/react/admin-panel/public/index.html b/react/admin-panel/public/index.html index a3437de..5b726a7 100644 --- a/react/admin-panel/public/index.html +++ b/react/admin-panel/public/index.html @@ -1,8 +1,5 @@ - - -
diff --git a/react/admin-panel/src/AdminDashboard.jsx b/react/admin-panel/src/AdminDashboard.jsx index 4c7391d..54a423d 100644 --- a/react/admin-panel/src/AdminDashboard.jsx +++ b/react/admin-panel/src/AdminDashboard.jsx @@ -6,9 +6,6 @@ import Footer from "./elements/footer"; import {useContext, useEffect} from "react"; import {LocaleContext} from "shared/locale"; -// css -import './res/adminlte.min.css'; - // views import View404 from "./views/404"; import clsx from "clsx"; @@ -61,37 +58,27 @@ export default function AdminDashboard(props) { hideDialog: hideDialog }; - // add fixed-layout to body, I don't want to rewrite my base.twig template - if (!document.body.className.includes("layout-fixed")) { - document.body.className = clsx(document.body.className, "layout-fixed"); - } - return - -
-
-
- {L("general.loading")}...
}> - - }/> - }/> - }/> - }/> - }/> - }/> - }/> - }/> - }/> - }/> - }/> - }/> - } /> - - - - -
- -