V1.0.0-beta.15 Update 2
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Note: We appreciate your feedback and bug reports to continue improving our platform. Thank you for your continued support!
This commit is contained in:
180
views/profile.ejs
Normal file
180
views/profile.ejs
Normal file
@@ -0,0 +1,180 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Profil Utilisateur</title>
|
||||
<style>
|
||||
body {
|
||||
background-image: url('<%= user.wallpaper %>');
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
background-attachment: fixed;
|
||||
margin: 0;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
font-family: Arial, sans-serif;
|
||||
color: #333;
|
||||
}
|
||||
.container {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
background: rgba(255, 255, 255, 0.8);
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
h1 {
|
||||
margin-top: 0;
|
||||
}
|
||||
label {
|
||||
display: block;
|
||||
margin: 10px 0 5px;
|
||||
}
|
||||
input[type="text"] {
|
||||
width: calc(100% - 22px);
|
||||
padding: 10px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 5px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
button {
|
||||
padding: 10px 20px;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
background-color: #007bff;
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
}
|
||||
button:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
.user-info {
|
||||
margin: 20px 0;
|
||||
text-align: left;
|
||||
}
|
||||
.profile-picture {
|
||||
margin: 20px 0;
|
||||
text-align: center;
|
||||
}
|
||||
.profile-picture img {
|
||||
max-width: 150px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
.return-btn {
|
||||
display: block;
|
||||
margin: 20px 0;
|
||||
text-align: center;
|
||||
}
|
||||
.badge {
|
||||
display: inline-block;
|
||||
padding: 5px 10px;
|
||||
border-radius: 12px;
|
||||
background-color: #007bff;
|
||||
color: white;
|
||||
font-size: 0.9em;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="profile-picture">
|
||||
<a class="btn dropdown-toggle" id="accountDropdownBtn" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<img
|
||||
src="<%= user.profilePicture || 'https://api.dicebear.com/7.x/initials/svg?seed=' + user.name %>"
|
||||
alt="User Icon"
|
||||
class="rounded-circle"
|
||||
style="width: 30px; height: 30px;"
|
||||
/>
|
||||
</a> </div>
|
||||
<h1>Bienvenue, <span id="userName"><%= user.name %></span> !</h1>
|
||||
|
||||
<div class="user-info">
|
||||
<p><strong>ID :</strong> <span id="userId"><%= user.id %></span></p>
|
||||
<p><strong>Rôle :</strong> <span id="userRole" class="badge"><%= user.role %></span></p>
|
||||
</div>
|
||||
|
||||
<form id="wallpaperForm">
|
||||
<div>
|
||||
<label for="wallpaperUrl">Entrez l'URL du fond d'écran :</label>
|
||||
<input type="text" id="wallpaperUrl" name="wallpaperUrl" placeholder="http://example.com/image.jpg">
|
||||
</div>
|
||||
<button type="submit">Mettre à jour le fond d'écran</button>
|
||||
</form>
|
||||
|
||||
<form id="profilePictureForm">
|
||||
<div>
|
||||
<label for="profilePictureUrl">Entrez l'URL de la photo de profil :</label>
|
||||
<input type="text" id="profilePictureUrl" name="profilePictureUrl" placeholder="http://example.com/path/to/profile.jpg">
|
||||
</div>
|
||||
<button type="submit">Mettre à jour la photo de profil</button>
|
||||
</form>
|
||||
|
||||
<div class="return-btn">
|
||||
<button onclick="window.location.href='/dpanel/dashboard';">Retour au Dashboard</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const userId = '<%= user.id %>'; // Ensure this is set correctly by EJS
|
||||
|
||||
document.getElementById('wallpaperForm').addEventListener('submit', async (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
const urlInput = document.getElementById('wallpaperUrl').value;
|
||||
|
||||
if (urlInput) {
|
||||
const response = await fetch('/api/dpanel/dashboard/backgroundcustom/wallpaper', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem('token'),
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
wallpaperUrl: urlInput,
|
||||
userId: userId // Ensure this is passed correctly
|
||||
})
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
document.body.style.backgroundImage = `url('${data.wallpaper}')`;
|
||||
alert('Fond d\'écran mis à jour avec succès !');
|
||||
} else {
|
||||
alert('Échec de la mise à jour du fond d\'écran');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('profilePictureForm').addEventListener('submit', async (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
const urlInput = document.getElementById('profilePictureUrl').value;
|
||||
|
||||
if (urlInput) {
|
||||
const response = await fetch('/api/dpanel/dashboard/profilpicture', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem('token'),
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
profilePictureUrl: urlInput,
|
||||
userId: userId
|
||||
})
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
document.getElementById('currentProfilePicture').src = data.profilePicture;
|
||||
alert('Photo de profil mise à jour avec succès !');
|
||||
} else {
|
||||
alert('Échec de la mise à jour de la photo de profil');
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user