From a2bb4e46f764a3be415cb3ffdee83a162fc4fbcc Mon Sep 17 00:00:00 2001 From: fet1sov Date: Wed, 24 Apr 2024 01:58:20 +0500 Subject: [PATCH] User Settings : New frontend part Settings: - Updated the events for the drag and drop image - Added the categories for the user settings Locales: - Changed the service for the IP location check Model (User): - Renamed the user model file to user.mdl --- www/_styles/_css/styles.css | 69 +++++++ www/backend/models/{user.php => user.mdl.php} | 2 +- www/backend/routes/user/user.ctrl.php | 74 ++++--- www/backend/routes/user/user.view.php | 128 ++++++------- www/data/locales/en-US.json | 23 ++- www/data/locales/ru-RU.json | 23 ++- .../components/settings/settingsBlock.php | 180 ++++++++++++++++++ www/includes/wtframework/locales.php | 2 +- 8 files changed, 401 insertions(+), 100 deletions(-) rename www/backend/models/{user.php => user.mdl.php} (99%) create mode 100644 www/frontend/components/settings/settingsBlock.php diff --git a/www/_styles/_css/styles.css b/www/_styles/_css/styles.css index 2b2a66b..b92d4bf 100644 --- a/www/_styles/_css/styles.css +++ b/www/_styles/_css/styles.css @@ -7,6 +7,7 @@ --secondary-color-02: #a0a0a0; --secondary-color-03: #000000; --secondary-color-04: #F0F0F0; + --secondary-color-05: #cecece; } @font-face { @@ -38,6 +39,17 @@ } } +@keyframes appearAnimation-Y { + from { + margin-top: -20px; + opacity: 0; + } + to { + margin-top: 0; + opacity: 1; + } +} + * { transition: 0.5s all; scroll-behavior: smooth; @@ -298,6 +310,63 @@ img.small-avatar { border-radius: 10px; } +.small-primary-button { + display: flex; + justify-content: center; + + background-color: var(--primary-color-01); + color: var(--secondary-color-01); + + border-radius: 10px; + + padding: 10px; + width: 100%; + + user-select: none; + outline: none; + + box-shadow: none; + cursor: pointer; + border: none; +} + +.small-primary-button:hover { + background-color: var(--primary-color-02); +} + +.small-primary-button:focus { + outline: none; +} + +.round-button { + display: flex; + justify-content: center; + + background-color: var(--primary-color-01); + color: var(--secondary-color-01); + + border-radius: 50%; + + padding: 10px; + + user-select: none; +} + +.round-button:hover { + background-color: var(--primary-color-02); +} + +.primary-link-button { + padding: 10px; + user-select: none; + + text-align: center; +} + +.primary-link-button:hover { + color: var(--primary-color-01); +} + /* Small Desktop */ @media (width <= 1024px) { body { diff --git a/www/backend/models/user.php b/www/backend/models/user.mdl.php similarity index 99% rename from www/backend/models/user.php rename to www/backend/models/user.mdl.php index ac8ceff..825790b 100644 --- a/www/backend/models/user.php +++ b/www/backend/models/user.mdl.php @@ -74,7 +74,7 @@ public function saveData() : void { $stmt = $GLOBALS["dbAdapter"]->prepare("UPDATE `user` SET `username`=?, `password`=?, `company`=?, `email`=? WHERE `id`=?"); $stmt->bind_param( - 'ssss', + 'ssssi', $this->username, $this->password, $this->company, diff --git a/www/backend/routes/user/user.ctrl.php b/www/backend/routes/user/user.ctrl.php index c1948c8..4348475 100644 --- a/www/backend/routes/user/user.ctrl.php +++ b/www/backend/routes/user/user.ctrl.php @@ -1,36 +1,60 @@ ROUTE_ROOT . "user/user.view.php", - "layout_data" => [ - "category" => $params['category'], - "footerShow" => false - ] - ]); + case "settings": { + $userData = unserialize($_SESSION["userData"]); + + if ($_SERVER['REQUEST_METHOD'] == "POST") { + $userData->setCompany(isset($_POST["companyName"]) ? $_POST["companyName"] : $userData->getCompany()); + $userData->saveData(); + + Renderer::includeTemplate("frontend/components/layout.php", [ + "layout_path" => ROUTE_ROOT . "user/user.view.php", + "layout_data" => [ + "category" => $params['category'], + "message" => [ + "type" => "success" + ], + "footerShow" => false, + "userData" => [ + "email" => $userData->getEmail(), + "company" => $userData->getCompany() + ] + ] + ]); + + } else { + Renderer::includeTemplate("frontend/components/layout.php", [ + "layout_path" => ROUTE_ROOT . "user/user.view.php", + "layout_data" => [ + "category" => $params['category'], + "footerShow" => false, + "userData" => [ + "email" => $userData->getEmail(), + "company" => $userData->getCompany() + ] + ] + ]); + } break; } - } - } else { - Renderer::includeTemplate("frontend/components/layout.php", [ - "layout_path" => ROUTE_ROOT . "user/user.view.php", - "layout_data" => [ - "footerShow" => false - ] - ]); } +} else { + Renderer::includeTemplate("frontend/components/layout.php", [ + "layout_path" => ROUTE_ROOT . "user/user.view.php", + "layout_data" => [ + "footerShow" => false + ] + ]); } diff --git a/www/backend/routes/user/user.view.php b/www/backend/routes/user/user.view.php index 023fab7..af90c55 100644 --- a/www/backend/routes/user/user.view.php +++ b/www/backend/routes/user/user.view.php @@ -1,11 +1,4 @@ - - - + - - -
-
-
-
- Small avatar previewgetId(); ?>"> - Small avatar previewgetId(); ?>"> - Small avatar previewgetId(); ?>"> -
- -
-

48px

-

64px

-

128px

-
- -

- + +
+
+
    + +
  • + +
  • + +
- -
- [ + "type" => "success" + ], + "userData" => $userData + ]); + break; + ?> +
+ +

getUsername(); ?>

- = "12" && $time < "17") { ?> + = "12" && $time < "19") { ?>

getUsername(); ?>

= "19") { ?>

getUsername(); ?>

@@ -162,5 +148,5 @@
-
- \ No newline at end of file +
+ \ No newline at end of file diff --git a/www/data/locales/en-US.json b/www/data/locales/en-US.json index cb85dac..d910e5b 100644 --- a/www/data/locales/en-US.json +++ b/www/data/locales/en-US.json @@ -22,6 +22,11 @@ } } }, + "success": { + "settings": { + "profileSettings": "Profile information was sucessfully updated" + } + }, "titles": { "authorization": "Log In", "registration": "Registration", @@ -34,8 +39,22 @@ "goodnight": "Good night, " }, "settings": { + "settingsNavigation": { + "profile": "Profile", + "security": "Security" + }, "avatar": { + "header": "Profile picture", "placeholder": "Upload the avatar less than 5 Mb. Formats: .png, .jpg, .gif" + }, + "personalInfomation": { + "header": "Personal information", + "email": { + "placeholder": "Contact email" + }, + "companyName": { + "placeholder": "Company name" + } } } }, @@ -71,6 +90,8 @@ "logout": "Log out" }, "buttons": { - "upload": "Upload" + "upload": "Upload", + "saveButton": "Save changes", + "discardButton": "Discard changes" } } \ No newline at end of file diff --git a/www/data/locales/ru-RU.json b/www/data/locales/ru-RU.json index 8704edc..124a39f 100644 --- a/www/data/locales/ru-RU.json +++ b/www/data/locales/ru-RU.json @@ -22,6 +22,11 @@ } } }, + "success": { + "settings": { + "profileSettings": "Информация о профиле была обновлена" + } + }, "titles": { "authorization": "Авторизация", "registration": "Регистрация", @@ -34,8 +39,22 @@ "goodnight": "Доброй ночи, " }, "settings": { + "settingsNavigation": { + "profile": "Профиль", + "security": "Безопасность" + }, "avatar": { + "header": "Изображение профиля", "placeholder": "Загрузите аватар не более 5 МБ. Формат: .png, .jpg, .gif" + }, + "personalInfomation": { + "header": "Персональная информация", + "email": { + "placeholder": "Контактная почта" + }, + "companyName": { + "placeholder": "Название компании" + } } } }, @@ -71,6 +90,8 @@ "logout": "Выйти" }, "buttons": { - "upload": "Загрузить" + "upload": "Загрузить", + "saveButton": "Сохранить изменения", + "discardButton": "Отменить изменения" } } \ No newline at end of file diff --git a/www/frontend/components/settings/settingsBlock.php b/www/frontend/components/settings/settingsBlock.php new file mode 100644 index 0000000..6579ddc --- /dev/null +++ b/www/frontend/components/settings/settingsBlock.php @@ -0,0 +1,180 @@ + + + + +
+
+
+
+ Small avatar previewgetId(); ?>"> +
+ +
+
+ +

+
+ +
+

Персональная информация

+ +
+ + " name="email" value=""> +
+ +
+ + " name="company" value=""> +
+ +
+ + +

+ + +
+ + +
+
+
\ No newline at end of file diff --git a/www/includes/wtframework/locales.php b/www/includes/wtframework/locales.php index 4e39cda..8514f82 100644 --- a/www/includes/wtframework/locales.php +++ b/www/includes/wtframework/locales.php @@ -3,7 +3,7 @@ if (!in_array($ip, ["localhost", "127.0.0.1"])) { - $geoDetails = json_decode(file_get_contents("http://ipinfo.io/{$ip}/json")); + $geoDetails = json_decode(file_get_contents("http://ip-api.com/json/{$ip}")); $regionLocales = array( "Russian" => array(