563 lines
15 KiB
HTML
563 lines
15 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>User Management - Sky Art Shop</title>
|
|
<link
|
|
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"
|
|
rel="stylesheet"
|
|
/>
|
|
<link
|
|
rel="stylesheet"
|
|
href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css"
|
|
/>
|
|
<link rel="stylesheet" href="/admin/css/admin-style.css" />
|
|
<style>
|
|
.role-badge {
|
|
padding: 6px 12px;
|
|
border-radius: 6px;
|
|
font-weight: 600;
|
|
font-size: 0.75rem;
|
|
text-transform: uppercase;
|
|
}
|
|
.role-master-admin {
|
|
background: #f59e0b;
|
|
color: white;
|
|
}
|
|
.role-admin {
|
|
background: #8b5cf6;
|
|
color: white;
|
|
}
|
|
.role-accountant {
|
|
background: #3b82f6;
|
|
color: white;
|
|
}
|
|
.role-cashier {
|
|
background: #10b981;
|
|
color: white;
|
|
}
|
|
|
|
.permissions-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
|
|
gap: 12px;
|
|
margin-top: 15px;
|
|
}
|
|
.permission-item {
|
|
padding: 12px;
|
|
border: 2px solid #e9ecef;
|
|
border-radius: 8px;
|
|
background: #f8f9fa;
|
|
transition: all 0.2s ease;
|
|
}
|
|
.permission-item:hover {
|
|
border-color: #667eea;
|
|
}
|
|
.permission-item.active {
|
|
border-color: #667eea;
|
|
background: #f0f3ff;
|
|
}
|
|
|
|
/* Custom Notification Styles */
|
|
#notificationContainer {
|
|
position: fixed;
|
|
top: 20px;
|
|
right: 20px;
|
|
z-index: 9999;
|
|
max-width: 400px;
|
|
}
|
|
|
|
.notification {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
padding: 16px 20px;
|
|
margin-bottom: 12px;
|
|
border-radius: 8px;
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
background: white;
|
|
border-left: 4px solid;
|
|
animation: slideIn 0.3s ease-out, fadeOut 0.3s ease-in 2.7s;
|
|
opacity: 1;
|
|
transform: translateX(0);
|
|
min-width: 320px;
|
|
}
|
|
|
|
.notification.removing {
|
|
animation: slideOut 0.3s ease-in;
|
|
}
|
|
|
|
.notification-success {
|
|
border-left-color: #10b981;
|
|
background: linear-gradient(to right, #f0fdf4 0%, #ffffff 100%);
|
|
}
|
|
|
|
.notification-error {
|
|
border-left-color: #ef4444;
|
|
background: linear-gradient(to right, #fef2f2 0%, #ffffff 100%);
|
|
}
|
|
|
|
.notification-icon {
|
|
font-size: 24px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.notification-success .notification-icon {
|
|
color: #10b981;
|
|
}
|
|
|
|
.notification-error .notification-icon {
|
|
color: #ef4444;
|
|
}
|
|
|
|
.notification-content {
|
|
flex: 1;
|
|
}
|
|
|
|
.notification-title {
|
|
font-weight: 600;
|
|
font-size: 14px;
|
|
margin-bottom: 4px;
|
|
color: #111;
|
|
}
|
|
|
|
.notification-message {
|
|
font-size: 13px;
|
|
color: #666;
|
|
line-height: 1.4;
|
|
}
|
|
|
|
.notification-close {
|
|
background: none;
|
|
border: none;
|
|
font-size: 20px;
|
|
color: #999;
|
|
cursor: pointer;
|
|
padding: 0;
|
|
width: 24px;
|
|
height: 24px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
border-radius: 4px;
|
|
transition: all 0.2s;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.notification-close:hover {
|
|
background: rgba(0, 0, 0, 0.05);
|
|
color: #333;
|
|
}
|
|
|
|
@keyframes slideIn {
|
|
from {
|
|
transform: translateX(400px);
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
transform: translateX(0);
|
|
opacity: 1;
|
|
}
|
|
}
|
|
|
|
@keyframes slideOut {
|
|
from {
|
|
transform: translateX(0);
|
|
opacity: 1;
|
|
}
|
|
to {
|
|
transform: translateX(400px);
|
|
opacity: 0;
|
|
}
|
|
}
|
|
|
|
@keyframes fadeOut {
|
|
from {
|
|
opacity: 1;
|
|
}
|
|
to {
|
|
opacity: 0.7;
|
|
}
|
|
}
|
|
|
|
/* Loading Spinner Overlay */
|
|
.loading-overlay {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background: rgba(0, 0, 0, 0.3);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
z-index: 9998;
|
|
backdrop-filter: blur(2px);
|
|
}
|
|
|
|
.loading-spinner-container {
|
|
background: white;
|
|
padding: 30px 40px;
|
|
border-radius: 12px;
|
|
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
|
|
text-align: center;
|
|
}
|
|
|
|
.loading-spinner-icon {
|
|
width: 50px;
|
|
height: 50px;
|
|
border: 4px solid #f3f3f3;
|
|
border-top: 4px solid #667eea;
|
|
border-radius: 50%;
|
|
animation: spin 1s linear infinite;
|
|
margin: 0 auto 15px;
|
|
}
|
|
|
|
.loading-spinner-text {
|
|
color: #333;
|
|
font-size: 16px;
|
|
font-weight: 500;
|
|
}
|
|
|
|
@keyframes spin {
|
|
0% {
|
|
transform: rotate(0deg);
|
|
}
|
|
100% {
|
|
transform: rotate(360deg);
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="sidebar">
|
|
<div class="sidebar-brand">🛍️ Sky Art Shop</div>
|
|
<ul class="sidebar-menu">
|
|
<li>
|
|
<a href="/admin/dashboard"
|
|
><i class="bi bi-speedometer2"></i> Dashboard</a
|
|
>
|
|
</li>
|
|
<li>
|
|
<a href="/admin/homepage"
|
|
><i class="bi bi-house"></i> Homepage Editor</a
|
|
>
|
|
</li>
|
|
<li>
|
|
<a href="/admin/products"><i class="bi bi-box"></i> Products</a>
|
|
</li>
|
|
<li>
|
|
<a href="/admin/portfolio"
|
|
><i class="bi bi-easel"></i> Portfolio</a
|
|
>
|
|
</li>
|
|
<li>
|
|
<a href="/admin/blog"><i class="bi bi-newspaper"></i> Blog</a>
|
|
</li>
|
|
<li>
|
|
<a href="/admin/pages"
|
|
><i class="bi bi-file-text"></i> Custom Pages</a
|
|
>
|
|
</li>
|
|
<li>
|
|
<a href="/admin/media-library"
|
|
><i class="bi bi-images"></i> Media Library</a
|
|
>
|
|
</li>
|
|
<li>
|
|
<a href="/admin/menu"><i class="bi bi-list"></i> Menu</a>
|
|
</li>
|
|
<li>
|
|
<a href="/admin/settings"><i class="bi bi-gear"></i> Settings</a>
|
|
</li>
|
|
<li>
|
|
<a href="/admin/users" class="active"
|
|
><i class="bi bi-people"></i> Users</a
|
|
>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="main-content">
|
|
<div class="top-bar">
|
|
<div>
|
|
<h3>User Management</h3>
|
|
<p class="mb-0 text-muted">Manage admin users and permissions</p>
|
|
</div>
|
|
<div>
|
|
<button class="btn-logout" onclick="logout()">
|
|
<i class="bi bi-box-arrow-right"></i> Logout
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="actions-bar">
|
|
<button class="btn btn-primary" onclick="showCreateUser()">
|
|
<i class="bi bi-person-plus"></i> Create New User
|
|
</button>
|
|
<div class="search-box">
|
|
<i class="bi bi-search"></i>
|
|
<input
|
|
type="text"
|
|
placeholder="Search users..."
|
|
id="searchInput"
|
|
oninput="filterUsers()"
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="table-responsive">
|
|
<table class="table table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th>ID</th>
|
|
<th>Name</th>
|
|
<th>Email</th>
|
|
<th>Username</th>
|
|
<th>Role</th>
|
|
<th>Status</th>
|
|
<th>Created</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="usersTableBody">
|
|
<tr>
|
|
<td colspan="8" class="text-center">
|
|
<div class="loading-spinner"></div>
|
|
Loading users...
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Create/Edit User Modal -->
|
|
<div class="modal fade" id="userModal" tabindex="-1">
|
|
<div class="modal-dialog modal-lg">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="modalTitle">Create New User</h5>
|
|
<button
|
|
type="button"
|
|
class="btn-close"
|
|
data-bs-dismiss="modal"
|
|
></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<form id="userForm">
|
|
<input type="hidden" id="userId" />
|
|
|
|
<div class="row">
|
|
<div class="col-md-6 mb-3">
|
|
<label for="userName" class="form-label">Full Name *</label>
|
|
<input
|
|
type="text"
|
|
class="form-control"
|
|
id="userName"
|
|
required
|
|
/>
|
|
</div>
|
|
<div class="col-md-6 mb-3">
|
|
<label for="userUsername" class="form-label"
|
|
>Username *</label
|
|
>
|
|
<input
|
|
type="text"
|
|
class="form-control"
|
|
id="userUsername"
|
|
required
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="userEmail" class="form-label"
|
|
>Email Address *</label
|
|
>
|
|
<input
|
|
type="email"
|
|
class="form-control"
|
|
id="userEmail"
|
|
required
|
|
/>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-md-6 mb-3">
|
|
<label for="userPassword" class="form-label"
|
|
>Password *</label
|
|
>
|
|
<input
|
|
type="password"
|
|
class="form-control"
|
|
id="userPassword"
|
|
/>
|
|
<small class="text-muted"
|
|
>Leave blank to keep current password (when editing)</small
|
|
>
|
|
</div>
|
|
<div class="col-md-6 mb-3">
|
|
<label for="userPasswordConfirm" class="form-label"
|
|
>Confirm Password *</label
|
|
>
|
|
<input
|
|
type="password"
|
|
class="form-control"
|
|
id="userPasswordConfirm"
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="userRole" class="form-label">User Role *</label>
|
|
<select
|
|
class="form-control"
|
|
id="userRole"
|
|
onchange="updatePermissionsPreview()"
|
|
>
|
|
<option value="Cashier">Cashier</option>
|
|
<option value="Accountant">Accountant</option>
|
|
<option value="Admin">Admin</option>
|
|
<option value="MasterAdmin">Master Admin</option>
|
|
</select>
|
|
<small class="text-muted"
|
|
>Role determines access permissions</small
|
|
>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Role Permissions Preview</label>
|
|
<div class="permissions-grid" id="permissionsPreview">
|
|
<!-- Dynamically populated -->
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-md-6 mb-3">
|
|
<div class="form-check form-switch">
|
|
<input
|
|
class="form-check-input"
|
|
type="checkbox"
|
|
id="userActive"
|
|
checked
|
|
/>
|
|
<label class="form-check-label" for="userActive">
|
|
Active Account
|
|
</label>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6 mb-3">
|
|
<div class="form-check form-switch">
|
|
<input
|
|
class="form-check-input"
|
|
type="checkbox"
|
|
id="userPasswordNeverExpires"
|
|
/>
|
|
<label
|
|
class="form-check-label"
|
|
for="userPasswordNeverExpires"
|
|
>
|
|
Password Never Expires
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button
|
|
type="button"
|
|
class="btn btn-secondary"
|
|
data-bs-dismiss="modal"
|
|
>
|
|
Cancel
|
|
</button>
|
|
<button type="button" class="btn btn-primary" onclick="saveUser()">
|
|
<i class="bi bi-save"></i> Save User
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Change Password Modal -->
|
|
<div class="modal fade" id="passwordModal" tabindex="-1">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title">Change Password</h5>
|
|
<button
|
|
type="button"
|
|
class="btn-close"
|
|
data-bs-dismiss="modal"
|
|
></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<form id="passwordForm">
|
|
<input type="hidden" id="passwordUserId" />
|
|
<input type="hidden" id="passwordUserName" />
|
|
|
|
<div class="alert alert-info">
|
|
<i class="bi bi-info-circle"></i> Changing password for:
|
|
<strong id="passwordUserDisplay"></strong>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="newPassword" class="form-label"
|
|
>New Password *</label
|
|
>
|
|
<input
|
|
type="password"
|
|
class="form-control"
|
|
id="newPassword"
|
|
required
|
|
/>
|
|
<small class="text-muted">Minimum 8 characters</small>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="confirmNewPassword" class="form-label"
|
|
>Confirm New Password *</label
|
|
>
|
|
<input
|
|
type="password"
|
|
class="form-control"
|
|
id="confirmNewPassword"
|
|
required
|
|
/>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button
|
|
type="button"
|
|
class="btn btn-secondary"
|
|
data-bs-dismiss="modal"
|
|
>
|
|
Cancel
|
|
</button>
|
|
<button
|
|
type="button"
|
|
class="btn btn-primary"
|
|
onclick="changePassword()"
|
|
>
|
|
<i class="bi bi-key"></i> Change Password
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Custom Notification Container -->
|
|
<div id="notificationContainer"></div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script src="/admin/js/auth.js"></script>
|
|
<script src="/admin/js/users.js"></script>
|
|
</body>
|
|
</html>
|