-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanageUsers.jsp
More file actions
224 lines (224 loc) 路 9.2 KB
/
Copy pathmanageUsers.jsp
File metadata and controls
224 lines (224 loc) 路 9.2 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Manage Users</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
<style>
body {
background-color: #f8f9fa;
color: #333;
padding-top: 70px;
}
.navbar {
background-color: #1b5e20;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
padding: 10px 0;
position: fixed;
top: 0;
width: 100%;
z-index: 1000;
}
.navbar-brand {
font-weight: 600;
font-size: 1.5rem;
color: white;
transition: all 0.3s ease;
}
.navbar-brand:hover {
color: #8bc34a;
}
.nav-link {
color: rgba(255, 255, 255, 0.85);
font-weight: 500;
margin: 0 8px;
padding: 8px 12px;
border-radius: 4px;
transition: all 0.3s ease;
}
.nav-link:hover, .nav-link.active {
color: white;
background-color: rgba(255, 255, 255, 0.1);
}
.nav-link i {
margin-right: 6px;
}
.container {
margin-top: 40px;
}
.table-responsive {
margin-top: 20px;
}
.badge {
font-size: 0.95em;
padding: 6px 12px;
}
.page-title {
font-weight: 600;
color: #1b5e20;
margin-bottom: 30px;
position: relative;
padding-bottom: 10px;
}
.page-title:after {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 60px;
height: 3px;
background-color: #8bc34a;
}
</style>
</head>
<body>
<!-- Top Navigation Bar -->
<nav class="navbar navbar-expand-lg">
<div class="container">
<a class="navbar-brand" href="dashboard.jsp">
<i class="fas fa-book-open me-2"></i>Library System
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav me-auto">
<li class="nav-item">
<a class="nav-link" href="dashboard.jsp">
<i class="fas fa-tachometer-alt"></i>Dashboard
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="searchBook.jsp">
<i class="fas fa-book"></i>Search Books
</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="manageUsers">
<i class="fas fa-users"></i>Manage Users
</a>
</li>
</ul>
<a class="btn btn-outline-light" href="logout.jsp"><i class="fas fa-sign-out-alt me-1"></i>Logout</a>
</div>
</div>
</nav>
<div class="container">
<h2 class="page-title">User Management</h2>
<div class="row mb-3">
<div class="col">
<a href="dashboard.jsp" class="btn btn-secondary"><i class="fas fa-arrow-left me-1"></i>Back to Dashboard</a>
<c:if test="${sessionScope.user.role == 'Admin'}">
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addUserModal">
<i class="fas fa-user-plus me-1"></i>Add New User
</button>
</c:if>
</div>
</div>
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead class="table-dark">
<tr>
<th>User ID</th>
<th>Username</th>
<th>Full Name</th>
<th>Email</th>
<th>Role</th>
<th>Created At</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<c:forEach var="user" items="${users}">
<tr>
<td>${user.userId}</td>
<td>${user.username}</td>
<td>${user.fullName}</td>
<td>${user.email}</td>
<td>
<span class="badge ${user.role == 'Admin' ? 'bg-danger' : 'bg-primary'}">
${user.role}
</span>
</td>
<td>${user.createdAt}</td>
<td>
<c:if test="${sessionScope.user.role == 'Admin'}">
<button class="btn btn-warning btn-sm"
onclick="editUser(${user.userId})">
<i class="fas fa-edit"></i> Edit
</button>
<button class="btn btn-danger btn-sm"
onclick="deleteUser(${user.userId})">
<i class="fas fa-trash"></i> Delete
</button>
</c:if>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
<c:if test="${empty users}">
<div class="alert alert-info">
No users found.
</div>
</c:if>
</div>
<!-- Add User Modal -->
<div class="modal fade" id="addUserModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Add New User</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<form action="addUser" method="post">
<div class="modal-body">
<div class="mb-3">
<label for="username" class="form-label">Username</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<div class="mb-3">
<label for="fullName" class="form-label">Full Name</label>
<input type="text" class="form-control" id="fullName" name="fullName" required>
</div>
<div class="mb-3">
<label for="email" class="form-label">Email</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<div class="mb-3">
<label for="role" class="form-label">Role</label>
<select class="form-select" id="role" name="role" required>
<option value="Student">Student</option>
<option value="Admin">Admin</option>
</select>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Add User</button>
</div>
</form>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script>
function editUser(userId) {
window.location.href = 'editUser?id=' + userId;
}
function deleteUser(userId) {
if (confirm('Are you sure you want to delete this user?')) {
window.location.href = 'deleteUser?id=' + userId;
}
}
</script>
</body>
</html>