user settings, users management, project settings, bug fixes
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Проекты</title>
|
||||
<title>Настройки</title>
|
||||
<link rel="icon" type="image/x-icon" href="../img/favicon.png">
|
||||
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
|
||||
<link rel="stylesheet" href="../styles/main.css">
|
||||
@@ -114,7 +114,7 @@
|
||||
|
||||
<div class="line"></div>
|
||||
|
||||
<button class="button">Связаться с нами</button>
|
||||
<button onclick="location.href='/'" class="button">Связаться с нами</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -124,9 +124,14 @@
|
||||
<nav class="sections">
|
||||
<a href="/projects">Проекты</a>
|
||||
<a class="selected" href="/user/settings">Настройки</a>
|
||||
{{#if IsAdmin}}
|
||||
<a href="/admin/users">Пользователи</a>
|
||||
{{/if}}
|
||||
|
||||
</nav>
|
||||
|
||||
<div class="notifications"></div>
|
||||
|
||||
<section class="content-bg">
|
||||
|
||||
<div class="project-name-section">
|
||||
@@ -135,39 +140,52 @@
|
||||
|
||||
<div class="account-content">
|
||||
|
||||
<div class="setting-section">
|
||||
<div class="setting-top">
|
||||
<h1>Отображаемое Имя</h1>
|
||||
<h2>Пожалуйста, укажите своё полное имя.</h2>
|
||||
<input id="name-input" type="text" value="{{User.name}}" required>
|
||||
<div class="setting-section">
|
||||
<div class="setting-top">
|
||||
<h1>Отображаемое Имя</h1>
|
||||
<h2>Пожалуйста, укажите своё полное имя</h2>
|
||||
<input oninput="handleInputChange(this)" id="name-input" type="text" value="{{User.name}}" required>
|
||||
</div>
|
||||
<div class="setting-bottom">
|
||||
<h2>Используйте максимум 20 символов.</h2>
|
||||
<button id="name-button" type="button" onclick="updateName();">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="setting-bottom">
|
||||
<h2>Используйте максимум 20 символов.</h2>
|
||||
<button type="button">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-section">
|
||||
<div class="setting-top">
|
||||
<h1>Электронная почта</h1>
|
||||
<h2>Пожалуйста, укажите почту для авторизации.</h2>
|
||||
<input id="email-input" type="text" value="{{User.email}}" required>
|
||||
<h2>Пожалуйста, укажите почту для авторизации</h2>
|
||||
<input oninput="handleInputChange(this)" id="email-input" type="text" value="{{User.email}}" required>
|
||||
</div>
|
||||
<div class="setting-bottom">
|
||||
<h2>Используйте только свою актуальную почту.</h2>
|
||||
<button type="button">Сохранить</button>
|
||||
<button id="email-button" type="button" onclick="updateEmail();">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-section">
|
||||
<div class="setting-top">
|
||||
<h1>Номер телефона</h1>
|
||||
<h2>Пожалуйста, укажите свой номер телефона.</h2>
|
||||
<input id="phone-input" type="text" value="{{User.phone}}" required>
|
||||
<h2>Пожалуйста, укажите свой номер телефона</h2>
|
||||
<input oninput="handleInputChange(this)" id="phone-input" type="text" value="{{User.phone}}" required>
|
||||
</div>
|
||||
<div class="setting-bottom">
|
||||
<h2>Необязательно, но определенно рекомендовано.</h2>
|
||||
<button type="button">Сохранить</button>
|
||||
<button id="phone-button" onclick="updatePhone();" type="button">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="setting-section">
|
||||
<div class="setting-top">
|
||||
<h1>Пароль</h1>
|
||||
<h2>Если хотите изменить пароль, укажите новый ниже</h2>
|
||||
<input oninput="handlePasswordChange(this)" id="password-input" type="password" required>
|
||||
</div>
|
||||
<div class="setting-bottom">
|
||||
<h2>Используйте минимум 5 символов.</h2>
|
||||
<button id="password-button" class="inactive" onclick="updatePassword();" type="button">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -222,6 +240,150 @@
|
||||
}
|
||||
|
||||
</script>
|
||||
<script src="../scripts/notifications.js"></script>
|
||||
|
||||
<script>
|
||||
function handleInputChange(input) {
|
||||
const settingBottom = input.parentElement.nextElementSibling;
|
||||
|
||||
const button = settingBottom.querySelector('button');
|
||||
|
||||
button.classList.remove('inactive');
|
||||
}
|
||||
|
||||
function handlePasswordChange(input) {
|
||||
const settingBottom = input.parentElement.nextElementSibling;
|
||||
const button = settingBottom.querySelector('button');
|
||||
|
||||
if (input.value.length >= 5) {
|
||||
button.classList.remove('inactive');
|
||||
} else {
|
||||
button.classList.add('inactive');
|
||||
}
|
||||
}
|
||||
|
||||
function getCookie(name) {
|
||||
var cookies = document.cookie.split(";");
|
||||
for (var i = 0; i < cookies.length; i++) {
|
||||
var cookie = cookies[i].trim();
|
||||
if (cookie.startsWith(name + "=")) {
|
||||
return cookie.substring(name.length + 1);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
async function updateName() {
|
||||
$("#name-button").addClass("inactive");
|
||||
$("#name-button").blur();
|
||||
const id = '{{User.id}}';
|
||||
const name = $("#name-input").val();
|
||||
|
||||
const response = await fetch("{{API_SERVER}}/user", {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
Authorization: getCookie("token"),
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({ id, name })
|
||||
});
|
||||
|
||||
if (response.status === 201) {
|
||||
notis.create(
|
||||
"Изменения сохранены",
|
||||
"Имя пользователя успешно обновлено!",
|
||||
5
|
||||
);
|
||||
} else {
|
||||
alert("Ошибка при обновлении данных.");
|
||||
}
|
||||
}
|
||||
|
||||
async function updateEmail() {
|
||||
$("#email-button").addClass("inactive");
|
||||
$("#email-button").blur();
|
||||
const id = '{{User.id}}';
|
||||
const email = $("#email-input").val();
|
||||
|
||||
const response = await fetch("{{API_SERVER}}/user", {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
Authorization: getCookie("token"),
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({ id, email })
|
||||
});
|
||||
|
||||
if (response.status === 201) {
|
||||
notis.create(
|
||||
"Изменения сохранены",
|
||||
"Адрес электронной почты успешно обновлён!",
|
||||
5
|
||||
);
|
||||
} else {
|
||||
alert("Ошибка при обновлении данных.");
|
||||
}
|
||||
}
|
||||
|
||||
async function updatePhone() {
|
||||
$("#phone-button").addClass("inactive");
|
||||
$("#phone-button").blur();
|
||||
const id = '{{User.id}}';
|
||||
const phone = $("#phone-input").val();
|
||||
|
||||
const response = await fetch("{{API_SERVER}}/user", {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
Authorization: getCookie("token"),
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({ id, phone })
|
||||
});
|
||||
|
||||
if (response.status === 201) {
|
||||
notis.create(
|
||||
"Изменения сохранены",
|
||||
"Номер телефона успешно обновлён!",
|
||||
5
|
||||
);
|
||||
} else {
|
||||
alert("Ошибка при обновлении данных.");
|
||||
}
|
||||
}
|
||||
|
||||
async function updatePassword() {
|
||||
if ($("#password-input").val().length < 5) {
|
||||
alert("Используйте минимум 5 символов в пароле");
|
||||
return;
|
||||
}
|
||||
$("#password-button").addClass("inactive");
|
||||
$("#password-button").blur();
|
||||
const id = '{{User.id}}';
|
||||
const password = $("#password-input").val();
|
||||
|
||||
const response = await fetch("{{API_SERVER}}/user", {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
Authorization: getCookie("token"),
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({ id, password })
|
||||
});
|
||||
|
||||
if (response.status === 201) {
|
||||
notis.create(
|
||||
"Изменения сохранены",
|
||||
"Пароль успешно обновлён!",
|
||||
5
|
||||
);
|
||||
} else {
|
||||
alert("Ошибка при обновлении данных.");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user