From d60383211c8f4c1a687b278b3eedfc24e7de2b3d Mon Sep 17 00:00:00 2001 From: James Collins Date: Fri, 3 Feb 2023 09:39:26 +1000 Subject: [PATCH 1/9] rename components to match --- resources/js/components/{DTab.vue => SMTab.vue} | 0 resources/js/components/{DTabGroup.vue => SMTabGroup.vue} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename resources/js/components/{DTab.vue => SMTab.vue} (100%) rename resources/js/components/{DTabGroup.vue => SMTabGroup.vue} (100%) diff --git a/resources/js/components/DTab.vue b/resources/js/components/SMTab.vue similarity index 100% rename from resources/js/components/DTab.vue rename to resources/js/components/SMTab.vue diff --git a/resources/js/components/DTabGroup.vue b/resources/js/components/SMTabGroup.vue similarity index 100% rename from resources/js/components/DTabGroup.vue rename to resources/js/components/SMTabGroup.vue -- 2.49.1 From 4ec4b5b10b56dbb05bcfaf29ae2ef9752817b621 Mon Sep 17 00:00:00 2001 From: James Collins Date: Fri, 3 Feb 2023 09:39:37 +1000 Subject: [PATCH 2/9] add log controller --- app/Http/Controllers/Api/LogController.php | 41 ++++++++++++++++++++++ routes/api.php | 1 + 2 files changed, 42 insertions(+) create mode 100644 app/Http/Controllers/Api/LogController.php diff --git a/app/Http/Controllers/Api/LogController.php b/app/Http/Controllers/Api/LogController.php new file mode 100644 index 0000000..5b046cb --- /dev/null +++ b/app/Http/Controllers/Api/LogController.php @@ -0,0 +1,41 @@ +middleware('auth:sanctum') + ->only(['show']); + } + + /** + * Display the specified resource. + * + * @param Request $request The log request. + * @return \Illuminate\Http\Response + */ + public function show(Request $request) + { + if($request->has('name') && $request->user()?->hasPermission('logs/' . $request->get('name'))) { + switch(strtolower($request->has('name'))) { + case 'discord': + $contents = ''; + $filePath = '/opt/discordbot/discordbot.log'; + if(file_exists($filePath) === true) { + $contents = file_get_contents($filePath); + } + + return $this->respondJson(['log' => $contents]); + } + } + + return $this->respondForbidden(); + } +} diff --git a/routes/api.php b/routes/api.php index 164a20f..acfe81f 100644 --- a/routes/api.php +++ b/routes/api.php @@ -42,6 +42,7 @@ Route::delete('subscriptions', [SubscriptionController::class, 'destroyByEmail'] Route::post('/contact', [ContactController::class, 'send']); +Route::get('/logs/{name}', [LogController::class, 'show']); Route::middleware('auth:sanctum')->group(function () { Route::post('/logout', [AuthController::class, 'logout']); -- 2.49.1 From 0d1a0cf130c95dbb12a5209ed48f2cef5d04726f Mon Sep 17 00:00:00 2001 From: James Collins Date: Fri, 3 Feb 2023 09:39:47 +1000 Subject: [PATCH 3/9] add discord log module --- resources/js/router/index.js | 9 ++++ resources/js/views/dashboard/Dashboard.vue | 7 +++ .../js/views/dashboard/DiscordBotLogs.vue | 45 +++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 resources/js/views/dashboard/DiscordBotLogs.vue diff --git a/resources/js/router/index.js b/resources/js/router/index.js index 799029a..4353299 100644 --- a/resources/js/router/index.js +++ b/resources/js/router/index.js @@ -304,6 +304,15 @@ export const routes = [ }, ], }, + { + path: "discord-bot-logs", + name: "discord-bot-logs", + meta: { + title: "Discord Bot Logs", + middleware: "authenticated", + }, + component: () => import("@/views/dashboard/DiscordBotLogs.vue"), + }, ], }, { diff --git a/resources/js/views/dashboard/Dashboard.vue b/resources/js/views/dashboard/Dashboard.vue index cc517b9..b65b579 100644 --- a/resources/js/views/dashboard/Dashboard.vue +++ b/resources/js/views/dashboard/Dashboard.vue @@ -41,6 +41,13 @@

Media

+ + +

Discord Bot Logs

+
diff --git a/resources/js/views/dashboard/DiscordBotLogs.vue b/resources/js/views/dashboard/DiscordBotLogs.vue new file mode 100644 index 0000000..48b4295 --- /dev/null +++ b/resources/js/views/dashboard/DiscordBotLogs.vue @@ -0,0 +1,45 @@ + + + -- 2.49.1 From c378d683db3088ccec9ad6f637b124799b65ef75 Mon Sep 17 00:00:00 2001 From: James Collins Date: Fri, 3 Feb 2023 09:54:11 +1000 Subject: [PATCH 4/9] update dependencies --- composer.lock | 128 +++++++++++++++++++++++++------------------------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/composer.lock b/composer.lock index fc3a780..dc96e61 100644 --- a/composer.lock +++ b/composer.lock @@ -8,26 +8,25 @@ "packages": [ { "name": "brick/math", - "version": "0.10.2", + "version": "0.11.0", "source": { "type": "git", "url": "https://github.com/brick/math.git", - "reference": "459f2781e1a08d52ee56b0b1444086e038561e3f" + "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/brick/math/zipball/459f2781e1a08d52ee56b0b1444086e038561e3f", - "reference": "459f2781e1a08d52ee56b0b1444086e038561e3f", + "url": "https://api.github.com/repos/brick/math/zipball/0ad82ce168c82ba30d1c01ec86116ab52f589478", + "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478", "shasum": "" }, "require": { - "ext-json": "*", - "php": "^7.4 || ^8.0" + "php": "^8.0" }, "require-dev": { "php-coveralls/php-coveralls": "^2.2", "phpunit/phpunit": "^9.0", - "vimeo/psalm": "4.25.0" + "vimeo/psalm": "5.0.0" }, "type": "library", "autoload": { @@ -52,7 +51,7 @@ ], "support": { "issues": "https://github.com/brick/math/issues", - "source": "https://github.com/brick/math/tree/0.10.2" + "source": "https://github.com/brick/math/tree/0.11.0" }, "funding": [ { @@ -60,7 +59,7 @@ "type": "github" } ], - "time": "2022-08-10T22:54:19+00:00" + "time": "2023-01-15T23:15:59+00:00" }, { "name": "dflydev/dot-access-data", @@ -1321,21 +1320,21 @@ }, { "name": "laravel/framework", - "version": "v9.48.0", + "version": "v9.50.2", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "c78ae7aeb0cbcb1a205050d3592247ba07f5b711" + "reference": "39932773c09658ddea9045958f305e67f9304995" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/c78ae7aeb0cbcb1a205050d3592247ba07f5b711", - "reference": "c78ae7aeb0cbcb1a205050d3592247ba07f5b711", + "url": "https://api.github.com/repos/laravel/framework/zipball/39932773c09658ddea9045958f305e67f9304995", + "reference": "39932773c09658ddea9045958f305e67f9304995", "shasum": "" }, "require": { - "brick/math": "^0.10.2", - "doctrine/inflector": "^2.0", + "brick/math": "^0.9.3|^0.10.2|^0.11", + "doctrine/inflector": "^2.0.5", "dragonmantank/cron-expression": "^3.3.2", "egulias/email-validator": "^3.2.1|^4.0", "ext-mbstring": "*", @@ -1434,7 +1433,6 @@ "aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage, and SES mail driver (^3.235.5).", "brianium/paratest": "Required to run tests in parallel (^6.0).", "doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.13.3|^3.1.4).", - "ext-bcmath": "Required to use the multiple_of validation rule.", "ext-ftp": "Required to use the Flysystem FTP driver.", "ext-gd": "Required to use Illuminate\\Http\\Testing\\FileFactory::image().", "ext-memcached": "Required to use the memcache cache driver.", @@ -1506,7 +1504,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2023-01-17T15:06:19+00:00" + "time": "2023-02-02T20:52:46+00:00" }, { "name": "laravel/sanctum", @@ -1575,16 +1573,16 @@ }, { "name": "laravel/serializable-closure", - "version": "v1.2.2", + "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/laravel/serializable-closure.git", - "reference": "47afb7fae28ed29057fdca37e16a84f90cc62fae" + "reference": "f23fe9d4e95255dacee1bf3525e0810d1a1b0f37" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/47afb7fae28ed29057fdca37e16a84f90cc62fae", - "reference": "47afb7fae28ed29057fdca37e16a84f90cc62fae", + "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/f23fe9d4e95255dacee1bf3525e0810d1a1b0f37", + "reference": "f23fe9d4e95255dacee1bf3525e0810d1a1b0f37", "shasum": "" }, "require": { @@ -1631,7 +1629,7 @@ "issues": "https://github.com/laravel/serializable-closure/issues", "source": "https://github.com/laravel/serializable-closure" }, - "time": "2022-09-08T13:45:54+00:00" + "time": "2023-01-30T18:31:20+00:00" }, { "name": "laravel/tinker", @@ -2304,29 +2302,30 @@ }, { "name": "nette/utils", - "version": "v3.2.9", + "version": "v4.0.0", "source": { "type": "git", "url": "https://github.com/nette/utils.git", - "reference": "c91bac3470c34b2ecd5400f6e6fdf0b64a836a5c" + "reference": "cacdbf5a91a657ede665c541eda28941d4b09c1e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/utils/zipball/c91bac3470c34b2ecd5400f6e6fdf0b64a836a5c", - "reference": "c91bac3470c34b2ecd5400f6e6fdf0b64a836a5c", + "url": "https://api.github.com/repos/nette/utils/zipball/cacdbf5a91a657ede665c541eda28941d4b09c1e", + "reference": "cacdbf5a91a657ede665c541eda28941d4b09c1e", "shasum": "" }, "require": { - "php": ">=7.2 <8.3" + "php": ">=8.0 <8.3" }, "conflict": { - "nette/di": "<3.0.6" + "nette/finder": "<3", + "nette/schema": "<1.2.2" }, "require-dev": { "jetbrains/phpstorm-attributes": "dev-master", - "nette/tester": "~2.0", + "nette/tester": "^2.4", "phpstan/phpstan": "^1.0", - "tracy/tracy": "^2.3" + "tracy/tracy": "^2.9" }, "suggest": { "ext-gd": "to use Image", @@ -2340,7 +2339,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -2384,9 +2383,9 @@ ], "support": { "issues": "https://github.com/nette/utils/issues", - "source": "https://github.com/nette/utils/tree/v3.2.9" + "source": "https://github.com/nette/utils/tree/v4.0.0" }, - "time": "2023-01-18T03:26:20+00:00" + "time": "2023-02-02T10:41:53+00:00" }, { "name": "nikic/php-parser", @@ -3317,20 +3316,20 @@ }, { "name": "ramsey/uuid", - "version": "4.7.3", + "version": "4.x-dev", "source": { "type": "git", "url": "https://github.com/ramsey/uuid.git", - "reference": "433b2014e3979047db08a17a205f410ba3869cf2" + "reference": "25c4faac19549ebfcd3a6a73732dddeb188eaf5a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/uuid/zipball/433b2014e3979047db08a17a205f410ba3869cf2", - "reference": "433b2014e3979047db08a17a205f410ba3869cf2", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/25c4faac19549ebfcd3a6a73732dddeb188eaf5a", + "reference": "25c4faac19549ebfcd3a6a73732dddeb188eaf5a", "shasum": "" }, "require": { - "brick/math": "^0.8.8 || ^0.9 || ^0.10", + "brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11", "ext-json": "*", "php": "^8.0", "ramsey/collection": "^1.2 || ^2.0" @@ -3367,6 +3366,7 @@ "paragonie/random-lib": "Provides RandomLib for use with the RandomLibAdapter", "ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type." }, + "default-branch": true, "type": "library", "extra": { "captainhook": { @@ -3393,7 +3393,7 @@ ], "support": { "issues": "https://github.com/ramsey/uuid/issues", - "source": "https://github.com/ramsey/uuid/tree/4.7.3" + "source": "https://github.com/ramsey/uuid/tree/4.x" }, "funding": [ { @@ -3405,7 +3405,7 @@ "type": "tidelift" } ], - "time": "2023-01-12T18:13:24+00:00" + "time": "2023-01-28T17:00:47+00:00" }, { "name": "symfony/console", @@ -3934,16 +3934,16 @@ }, { "name": "symfony/http-foundation", - "version": "v6.2.5", + "version": "v6.2.6", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "9d081ead9d3432e2e8002178d14c4c9dd4b8ffbf" + "reference": "e8dd1f502bc2b3371d05092aa233b064b03ce7ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/9d081ead9d3432e2e8002178d14c4c9dd4b8ffbf", - "reference": "9d081ead9d3432e2e8002178d14c4c9dd4b8ffbf", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/e8dd1f502bc2b3371d05092aa233b064b03ce7ed", + "reference": "e8dd1f502bc2b3371d05092aa233b064b03ce7ed", "shasum": "" }, "require": { @@ -3992,7 +3992,7 @@ "description": "Defines an object-oriented layer for the HTTP specification", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-foundation/tree/v6.2.5" + "source": "https://github.com/symfony/http-foundation/tree/v6.2.6" }, "funding": [ { @@ -4008,20 +4008,20 @@ "type": "tidelift" } ], - "time": "2023-01-01T08:38:09+00:00" + "time": "2023-01-30T15:46:28+00:00" }, { "name": "symfony/http-kernel", - "version": "v6.2.5", + "version": "v6.2.6", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "f68aaa11eee6b21c99bce0f3d98815924888fe62" + "reference": "7122db07b0d8dbf0de682267c84217573aee3ea7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/f68aaa11eee6b21c99bce0f3d98815924888fe62", - "reference": "f68aaa11eee6b21c99bce0f3d98815924888fe62", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/7122db07b0d8dbf0de682267c84217573aee3ea7", + "reference": "7122db07b0d8dbf0de682267c84217573aee3ea7", "shasum": "" }, "require": { @@ -4103,7 +4103,7 @@ "description": "Provides a structured process for converting a Request into a Response", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v6.2.5" + "source": "https://github.com/symfony/http-kernel/tree/v6.2.6" }, "funding": [ { @@ -4119,7 +4119,7 @@ "type": "tidelift" } ], - "time": "2023-01-24T15:33:24+00:00" + "time": "2023-02-01T08:32:25+00:00" }, { "name": "symfony/mailer", @@ -6135,16 +6135,16 @@ }, { "name": "laravel/pint", - "version": "v1.4.0", + "version": "v1.4.1", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "0e7ffdb0af871be10d798e234772ea5d4020ae4a" + "reference": "80ddf23a5d97825e79bb1018eebb6f3f985d4fa8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/0e7ffdb0af871be10d798e234772ea5d4020ae4a", - "reference": "0e7ffdb0af871be10d798e234772ea5d4020ae4a", + "url": "https://api.github.com/repos/laravel/pint/zipball/80ddf23a5d97825e79bb1018eebb6f3f985d4fa8", + "reference": "80ddf23a5d97825e79bb1018eebb6f3f985d4fa8", "shasum": "" }, "require": { @@ -6155,7 +6155,7 @@ "php": "^8.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "~3.13.1", + "friendsofphp/php-cs-fixer": "^3.14", "illuminate/view": "^9.32.0", "laravel-zero/framework": "^9.2.0", "mockery/mockery": "^1.5.1", @@ -6197,20 +6197,20 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2023-01-10T20:03:42+00:00" + "time": "2023-01-31T15:50:45+00:00" }, { "name": "laravel/sail", - "version": "v1.18.1", + "version": "v1.19.0", "source": { "type": "git", "url": "https://github.com/laravel/sail.git", - "reference": "a64f78a4ab86c04a4c5de39bea20a8d36ad48a22" + "reference": "4f230634a3163f3442def6a4e6ffdb02b02e14d6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/sail/zipball/a64f78a4ab86c04a4c5de39bea20a8d36ad48a22", - "reference": "a64f78a4ab86c04a4c5de39bea20a8d36ad48a22", + "url": "https://api.github.com/repos/laravel/sail/zipball/4f230634a3163f3442def6a4e6ffdb02b02e14d6", + "reference": "4f230634a3163f3442def6a4e6ffdb02b02e14d6", "shasum": "" }, "require": { @@ -6257,7 +6257,7 @@ "issues": "https://github.com/laravel/sail/issues", "source": "https://github.com/laravel/sail" }, - "time": "2023-01-11T14:35:04+00:00" + "time": "2023-01-31T13:37:57+00:00" }, { "name": "mockery/mockery", @@ -8328,5 +8328,5 @@ "php": "^8.0.2" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.1.0" } -- 2.49.1 From 1f8b83fc8c5bfafd3e2d56a6f19198a642436afe Mon Sep 17 00:00:00 2001 From: James Collins Date: Fri, 3 Feb 2023 10:25:08 +1000 Subject: [PATCH 5/9] fix permissions and split lines --- app/Http/Controllers/Api/LogController.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Api/LogController.php b/app/Http/Controllers/Api/LogController.php index 5b046cb..9a6035f 100644 --- a/app/Http/Controllers/Api/LogController.php +++ b/app/Http/Controllers/Api/LogController.php @@ -21,10 +21,10 @@ class LogController extends ApiController * @param Request $request The log request. * @return \Illuminate\Http\Response */ - public function show(Request $request) + public function show(Request $request, string $name) { - if($request->has('name') && $request->user()?->hasPermission('logs/' . $request->get('name'))) { - switch(strtolower($request->has('name'))) { + if($request->user()?->hasPermission('logs/' . $name)) { + switch(strtolower($name)) { case 'discord': $contents = ''; $filePath = '/opt/discordbot/discordbot.log'; @@ -32,7 +32,8 @@ class LogController extends ApiController $contents = file_get_contents($filePath); } - return $this->respondJson(['log' => $contents]); + $lines = preg_split("/(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}: (?:(?!\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}: )[\s\S])*)/", $contents, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + return $this->respondJson(['log' => implode('', array_reverse($lines))]); } } -- 2.49.1 From a135c7e8fdcacf1e2d3e32f5f0ca0d8507a27cb3 Mon Sep 17 00:00:00 2001 From: James Collins Date: Fri, 3 Feb 2023 10:25:16 +1000 Subject: [PATCH 6/9] style code block --- resources/css/app.scss | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/resources/css/app.scss b/resources/css/app.scss index c36c6a2..fe38fea 100644 --- a/resources/css/app.scss +++ b/resources/css/app.scss @@ -142,6 +142,17 @@ button { @extend .prevent-select; } +code { + font-size: 0.8rem; + background-color: #eee; + padding: 1rem; + border: 1px solid #ddd; + white-space: pre-wrap; + overflow-x: auto; + max-height: 30rem; + margin-bottom: 1rem; +} + /* Dialog */ .modal { position: fixed; -- 2.49.1 From 89ebab5134945de8f265e3ca8aebc3d3fac48ef3 Mon Sep 17 00:00:00 2001 From: James Collins Date: Fri, 3 Feb 2023 10:25:27 +1000 Subject: [PATCH 7/9] remove plural --- resources/js/router/index.js | 8 ++++---- resources/js/views/dashboard/Dashboard.vue | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/js/router/index.js b/resources/js/router/index.js index 4353299..cf0a18d 100644 --- a/resources/js/router/index.js +++ b/resources/js/router/index.js @@ -305,13 +305,13 @@ export const routes = [ ], }, { - path: "discord-bot-logs", - name: "discord-bot-logs", + path: "discord-bot-log", + name: "discord-bot-log", meta: { - title: "Discord Bot Logs", + title: "Discord Bot Log", middleware: "authenticated", }, - component: () => import("@/views/dashboard/DiscordBotLogs.vue"), + component: () => import("@/views/dashboard/DiscordBotLog.vue"), }, ], }, diff --git a/resources/js/views/dashboard/Dashboard.vue b/resources/js/views/dashboard/Dashboard.vue index b65b579..2e14e9f 100644 --- a/resources/js/views/dashboard/Dashboard.vue +++ b/resources/js/views/dashboard/Dashboard.vue @@ -46,7 +46,7 @@ to="/dashboard/discord-bot-logs" class="box"> -

Discord Bot Logs

+

Discord Bot Log

-- 2.49.1 From dd01a075d8a0e55df3c34c76844fff3e5557c9d7 Mon Sep 17 00:00:00 2001 From: James Collins Date: Fri, 3 Feb 2023 10:25:35 +1000 Subject: [PATCH 8/9] discord log view --- .../{DiscordBotLogs.vue => DiscordBotLog.vue} | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) rename resources/js/views/dashboard/{DiscordBotLogs.vue => DiscordBotLog.vue} (77%) diff --git a/resources/js/views/dashboard/DiscordBotLogs.vue b/resources/js/views/dashboard/DiscordBotLog.vue similarity index 77% rename from resources/js/views/dashboard/DiscordBotLogs.vue rename to resources/js/views/dashboard/DiscordBotLog.vue index 48b4295..ec68af8 100644 --- a/resources/js/views/dashboard/DiscordBotLogs.vue +++ b/resources/js/views/dashboard/DiscordBotLog.vue @@ -1,17 +1,18 @@