131 lines
3.0 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="en">
<head>
<title>Utilisateurs</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
table, th, td {
border:1px solid black;
2023-12-12 14:34:57 +01:00
/*border-collapse: collapse;*/
padding: 5px;
}
2023-12-12 16:35:22 +01:00
tr:hover {background-color: #D6EEEE;}
body {
font-family: Arial, Helvetica, sans-serif;
/*background-color: black;*/
}
* {
box-sizing: border-box;
}
/* Add padding to containers */
.container {
padding: 16px;
background-color: white;
display: block;
position: relative;
padding-left: 35px;
margin-bottom: 12px;
cursor: pointer;
font-size: 22px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
/* Full-width input fields */
input[type=text], input[type=password] {
width: 100%;
padding: 15px;
margin: 5px 0 22px 0;
display: inline-block;
border: none;
background: #f1f1f1;
}
input[type=text]:focus, input[type=password]:focus {
background-color: #ddd;
outline: none;
}
/* Overwrite default styles of hr */
hr {
border: 1px solid #f1f1f1;
margin-bottom: 25px;
}
/* Set a style for the submit button */
.registerbtn {
background-color: #04AA6D;
color: white;
padding: 16px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
opacity: 0.9;
}
.registerbtn:hover {
opacity: 1;
}
/* Add a blue text color to links */
a {
color: dodgerblue;
}
/* Set a grey background color and center the text of the "sign in" section */
.signin {
background-color: #f1f1f1;
text-align: center;
}
</style>
</head>
<body>
<script>
function deleteUser(username) {
fetch(`/api/users/${username}`, {
method: "DELETE",
})
.then(async (response) => {
const res = await response.json();
console.log(res);
if(!response.ok) return alert(res.message);
location.reload();
});
}
2023-12-12 16:19:50 +01:00
function editUserFromForm() {
const form = document.getElementById("userEditForm");
let perms = 1;
for(const node of form.querySelectorAll('input[name="permissions"]')) {
perms += node.checked ? Number(node.value) : 0;
}
console.log(perms)
fetch(`/api/users/${form.oldName.value}`, {
method: "PUT",
body: JSON.stringify({
newname: form.username.value,
permissions: perms,
}),
headers: {
"Content-type": "application/json; charset=UTF-8"
}
})
.then(async (response) => {
const res = await response.json();
console.log(res);
if(!response.ok) return alert(res.message);
window.location = `/dashboard/users/${res.username}`;
});
}
</script>
<NAVBAR>
<USERINFO>
<a href='./'><p>Retour</p></a>
</body>
</html>