diff --git a/README.md b/README.md index 80e91ff8..ec35fbfb 100644 --- a/README.md +++ b/README.md @@ -193,7 +193,7 @@ JS modules are added as attributes to the `PhpRenderer` (`$this` in the template // CSS $this->addAttribute('css', ['assets/general/page-component/form/form.css',]); // JS -$this->addAttribute('js', ['assets/error/generic-error-page.js',]); +$this->addAttribute('js', ['assets/error/prod-error-page.js',]); // JS module $this->addAttribute('jsModules', ['assets/general/dark-mode/dark-mode.js',]); ``` diff --git a/config/defaults.php b/config/defaults.php index e3c46784..10275fca 100644 --- a/config/defaults.php +++ b/config/defaults.php @@ -26,9 +26,7 @@ $settings['error'] = [ // Should be set to false in production. When set to true, it will throw an ErrorException for notices and warnings. 'display_error_details' => false, - // Should be set to false for unit tests 'log_errors' => true, - // Display error details in error log 'log_error_details' => true, ]; diff --git a/public/assets/error/error-details.css b/public/assets/error/error-details.css index 952ed90f..48b0b3a4 100644 --- a/public/assets/error/error-details.css +++ b/public/assets/error/error-details.css @@ -4,155 +4,151 @@ font-weight: normal; } -* { - /*white-space: break-spaces;*/ - overflow-wrap: anywhere; -} - -body { - margin: 0; - background: #ffd9d0; - font-family: Poppins, Geneva, AppleGothic, sans-serif; -} +/* mobile first min-width sets base and content is adapted to computers. */ +@media (min-width: 100px) { -body.warning { - background: #ffead0; -} + * { + overflow-wrap: anywhere; + } -body.error { - background: #ffd9d0; -} + body { + margin: 0; + background: #ffd9d0; + font-family: Poppins, Geneva, AppleGothic, sans-serif; + } -#title-div { - padding: 5px 10%; - color: black; - margin: 30px; - background: tomato; - border-radius: 0 35px; - box-shadow: 0 0 17px tomato; -} + body.warning { + background: #ffead0; + } -#title-div h1 { - margin-top: 4px; -} + body.error { + background: #ffd9d0; + } -#title-div.warning { - background: orange; - box-shadow: 0 0 17px orange; -} + #title-div { + padding: 5px 10%; + color: black; + background: tomato; + border-radius: 0 35px; + box-shadow: 0 0 17px tomato; + box-sizing: border-box; + margin: 30px 0; + font-size: 0.8em; + } -#title-div.error { - background: tomato; - box-shadow: 0 0 17px tomato; -} + #title-div h1 { + margin-top: 4px; + } -#first-path-chunk { - font-size: 0.7em; -} + #title-div.warning { + background: orange; + box-shadow: 0 0 17px orange; + } -#trace-div { - width: 80%; - margin: auto auto 40px; - min-width: 350px; - padding: 20px; - background: #ff9e88; - border-radius: 0 35px; - box-shadow: 0 0 10px #ff856e; -} + #title-div.error { + background: tomato; + box-shadow: 0 0 17px tomato; + } -#trace-div.warning { - background: #ffc588; - box-shadow: 0 0 10px #ffad6e; -} + #first-path-chunk { + font-size: 0.7em; + } -#trace-div.error { - background: #ff9e88; - box-shadow: 0 0 10px #ff856e; -} + #trace-div { + font-size: 0.8em; + margin: auto auto 40px; + min-width: 350px; + padding: 20px; + background: #ff9e88; + border-radius: 0 35px; + box-shadow: 0 0 10px #ff856e; + width: 90%; + } -#trace-div h2 { - margin-top: 0; - padding-top: 19px; - text-align: center; -} + #trace-div.warning { + background: #ffc588; + box-shadow: 0 0 10px #ffad6e; + } -#trace-div table { - border-collapse: collapse; - width: 100%; - overflow-x: auto; -} + #trace-div.error { + background: #ff9e88; + box-shadow: 0 0 10px #ff856e; + } -#trace-div table td, #trace-div table th { /*border-top: 6px solid red;*/ - padding: 8px; - text-align: left; -} + #trace-div h2 { + margin-top: 0; + padding-top: 19px; + text-align: center; + } -#trace-div table tr td:nth-child(3) { - min-width: 100px; -} + #trace-div table { + border-collapse: collapse; + width: 100%; + overflow-x: auto; + } -#num-th { - font-size: 2em; - color: #a46856; - margin-right: 50px; -} + #trace-div table td, #trace-div table th { /*border-top: 6px solid red;*/ + padding: 8px; + text-align: left; + } -.non-vendor { - font-weight: bold; - font-size: 1.2em; -} + #trace-div table tr td:nth-child(3) { + min-width: 100px; + } -.non-vendor .lineSpan { - font-weight: bold; - color: #b00000; - font-size: 1.1em; -} + #num-th { + font-size: 2em; + color: #a46856; + margin-right: 50px; + } -.is-vendor { - font-weight: normal; -} + .non-vendor { + font-weight: bold; + font-size: 1.2em; + } -.args-span { - color: #395186; - cursor: pointer; -} + .non-vendor .lineSpan { + font-weight: bold; + color: #b00000; + font-size: 1.1em; + } -#exception-name { - float: right -} + .is-vendor { + font-weight: normal; + } -.function-td{ - font-size: 0.9em; -} + .args-span { + color: #395186; + cursor: pointer; + } -/* When screen smaller than 1000px */ -@media screen and (max-width: 1000px) { - #trace-div { - font-size: 0.8em; + #exception-name { + float: right } - #title-div h1 { - font-size: 1.6em; + .function-td { + font-size: 0.9em; } } -/* When screen smaller than 810px */ -@media screen and (max-width: 810px) { - #trace-div table { - font-size: 1.1em; +@media (min-width: 641px) { + #trace-div { + width: 80%; } - +} +@media (min-width: 810px) { #title-div { - box-sizing: border-box; - margin-left: 0; - margin-right: 0; - width: 100%; + margin: 30px; } -} - -/* When screen bigger than 810px */ -@media screen and (min-width: 810px) { #trace-div table tr td:first-child, #trace-div table tr th:first-child { padding-left: 20px; } + #title-div{ + font-size: 1em; + } +} +@media (min-width: 1000px) { + #trace-div { + font-size: 1em; + } } \ No newline at end of file diff --git a/public/assets/error/generic-error-page.css b/public/assets/error/prod-error-page.css similarity index 85% rename from public/assets/error/generic-error-page.css rename to public/assets/error/prod-error-page.css index 2a1f1654..4690844d 100644 --- a/public/assets/error/generic-error-page.css +++ b/public/assets/error/prod-error-page.css @@ -10,15 +10,20 @@ } :root { - --error-body-gradient-color-1: rgb(213, 210, 255); - --error-body-gradient-color-2: rgba(158, 247, 255, 1); + --error-body-gradient-color-1: #49d2ff; + --error-body-gradient-color-2: #ea9bc2; + --error-inner-section-background: rgba(255, 255, 255, 0.4); --error-reason-phrase-color: #535353; + + --error-status-code-gradient-color-1: #00c1ff; + --error-status-code-gradient-color-2: #ff6bb4; + } [data-theme="dark"] { - --error-body-gradient-color-1: rgb(84, 79, 131); - --error-body-gradient-color-2: rgb(44, 110, 117); + --error-body-gradient-color-1: rgb(102, 93, 182); + --error-body-gradient-color-2: rgb(64, 148, 157); --error-inner-section-background: rgba(0, 0, 0, 0.4); --error-reason-phrase-color: #a9a9a9; } @@ -67,7 +72,8 @@ margin-bottom: 0; margin-top: 0px; position: relative; - background: linear-gradient(to bottom right, #2acaff 0%, #ff86c0 100%); + background: linear-gradient(to bottom right, var(--error-status-code-gradient-color-1) 0%, + var(--error-status-code-gradient-color-2) 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; } diff --git a/public/assets/error/generic-error-page.js b/public/assets/error/prod-error-page.js similarity index 73% rename from public/assets/error/generic-error-page.js rename to public/assets/error/prod-error-page.js index e9aa1935..a2d45c6d 100644 --- a/public/assets/error/generic-error-page.js +++ b/public/assets/error/prod-error-page.js @@ -1,5 +1,6 @@ const statusCode = document.getElementById('error-status-code'); +// Make the linear gradient direction of the status code follow the cursor document.documentElement.addEventListener("mousemove", function(event) { // Retrieve the bounding rectangle of the "statusCode" element const { left, top, width, height } = statusCode.getBoundingClientRect(); @@ -18,5 +19,8 @@ document.documentElement.addEventListener("mousemove", function(event) { const gradientDirection = degrees + 90; // Apply the linear gradient background to the "statusCode" element - statusCode.style.backgroundImage = `linear-gradient(${gradientDirection}deg, #2acaff 0%, #ff86c0 100%)`; + const style = getComputedStyle(document.body); + const color1 = style.getPropertyValue('--error-status-code-gradient-color-1'); + const color2 = style.getPropertyValue('--error-status-code-gradient-color-2'); + statusCode.style.backgroundImage = `linear-gradient(${gradientDirection}deg, ${color1} 0%, ${color2} 100%)`; }); \ No newline at end of file diff --git a/resources/schema/schema.sql b/resources/schema/schema.sql index 34959c07..0df6efee 100644 --- a/resources/schema/schema.sql +++ b/resources/schema/schema.sql @@ -7,7 +7,7 @@ CREATE TABLE `authentication_log` ( `created_at` datetime DEFAULT current_timestamp(), PRIMARY KEY (`id`), KEY `authentication_log_user_id_fk` (`user_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; CREATE TABLE `client` ( `id` int(11) NOT NULL AUTO_INCREMENT, @@ -29,14 +29,14 @@ CREATE TABLE `client` ( PRIMARY KEY (`id`), KEY `FK_client_user` (`user_id`), KEY `FK_client_status` (`client_status_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='Advisors help and consult clients'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='Advisors help and consult clients'; CREATE TABLE `client_status` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL DEFAULT '0', `deleted_at` int(11) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='Client status'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='Client status'; CREATE TABLE `email_log` ( `id` int(11) NOT NULL AUTO_INCREMENT, @@ -63,7 +63,7 @@ CREATE TABLE `note` ( PRIMARY KEY (`id`), KEY `FK__user` (`user_id`), KEY `FK_note_client` (`client_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ROW_FORMAT=DYNAMIC; CREATE TABLE `phinx_migration_log` ( `version` bigint(20) NOT NULL, @@ -89,7 +89,7 @@ CREATE TABLE `user` ( `deleted_at` datetime DEFAULT NULL, PRIMARY KEY (`id`), KEY `FK_user_user_role` (`user_role_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC; CREATE TABLE `user_activity` ( `id` int(11) NOT NULL AUTO_INCREMENT, @@ -103,7 +103,7 @@ CREATE TABLE `user_activity` ( `user_agent` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`), KEY `user_activity_user_id_fk` (`user_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC; CREATE TABLE `user_filter_setting` ( `user_id` int(11) NOT NULL, @@ -117,7 +117,7 @@ CREATE TABLE `user_role` ( `name` varchar(30) NOT NULL, `hierarchy` int(11) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; CREATE TABLE `user_verification` ( `id` int(11) NOT NULL AUTO_INCREMENT, diff --git a/src/Application/Action/Dashboard/DashboardPageAction.php b/src/Application/Action/Dashboard/DashboardPageAction.php index adc58225..2f9f6070 100644 --- a/src/Application/Action/Dashboard/DashboardPageAction.php +++ b/src/Application/Action/Dashboard/DashboardPageAction.php @@ -36,7 +36,6 @@ public function __invoke( ResponseInterface $response, array $args ): ResponseInterface { - $a->asd(); $dashboards = $this->dashboardGetter->getAuthorizedDashboards(); return $this->templateRenderer->render( diff --git a/src/Application/ErrorHandler/DefaultErrorHandler.php b/src/Application/ErrorHandler/DefaultErrorHandler.php index c7d6f59b..2f627f38 100644 --- a/src/Application/ErrorHandler/DefaultErrorHandler.php +++ b/src/Application/ErrorHandler/DefaultErrorHandler.php @@ -104,9 +104,10 @@ public function __invoke( */ private function getHttpStatusCode(Throwable $exception): int { - // Detect status code + // Default status code $statusCode = StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR; // 500 + // HttpExceptions have a status code if ($exception instanceof HttpException) { $statusCode = (int)$exception->getCode(); } diff --git a/templates/error/error-details.html.php b/templates/error/error-details.html.php index f8a5debe..76cde641 100644 --- a/templates/error/error-details.html.php +++ b/templates/error/error-details.html.php @@ -55,7 +55,7 @@ foreach ($entry['args'] as $argument) { ?> , - ) diff --git a/templates/error/error-page.html.php b/templates/error/error-page.html.php index 16687703..fb3a8feb 100644 --- a/templates/error/error-page.html.php +++ b/templates/error/error-page.html.php @@ -10,8 +10,8 @@ ?> addAttribute('css', ['assets/error/generic-error-page.css']); -$this->addAttribute('js', ['assets/error/generic-error-page.js']); +$this->addAttribute('css', ['assets/error/prod-error-page.css']); +$this->addAttribute('js', ['assets/error/prod-error-page.js']); ?>