-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
69 lines (63 loc) · 2.36 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Display Users</title>
<style>
body {
font-family: Arial, sans-serif;
}
.user {
border: 1px solid #ddd;
margin: 10px;
padding: 10px;
border-radius: 5px;
display: flex;
align-items: center;
}
.user img {
border-radius: 50%;
margin-right: 10px;
}
</style>
</head>
<body>
<h1>Users</h1>
<div id="user-list"></div>
<script>
document.addEventListener("DOMContentLoaded", function() {
fetch('http://localhost:8080/user/?keyword=')
.then(response => response.json())
.then(data => {
const userList = document.getElementById('user-list');
data.data.forEach(user => {
// Create user element
const userDiv = document.createElement('div');
userDiv.classList.add('user');
// Create profile image element
const img = document.createElement('img');
img.src = user.Profile; // Set image source to profile URL
img.alt = 'Profile Picture';
img.width = 300; // Set width or any desired size
// Create user info element
const userInfo = document.createElement('div');
userInfo.innerHTML = `
<strong>Username:</strong> ${user.Username}<br>
<strong>Email:</strong> ${user.Email}<br>
<strong>Role:</strong> ${user.Role}
`;
// Append image and user info to userDiv
userDiv.appendChild(img);
userDiv.appendChild(userInfo);
// Append userDiv to userList
userList.appendChild(userDiv);
});
})
.catch(error => {
console.error('Error fetching user data:', error);
});
});
</script>
</body>
</html>