Files
SkyArtShop/Views/AdminUsers/Index.cshtml
Local Server 703ab57984 Fix admin route access and backend configuration
- Added /admin redirect to login page in nginx config
- Fixed backend server.js route ordering for proper admin handling
- Updated authentication middleware and routes
- Added user management routes
- Configured PostgreSQL integration
- Updated environment configuration
2025-12-13 22:34:11 -06:00

179 lines
8.0 KiB
Plaintext
Executable File

@model List<SkyArtShop.Models.AdminUser>
@{
ViewData["Title"] = "User Management";
Layout = "~/Views/Shared/_AdminLayout.cshtml";
}
<div class="container-fluid py-4">
<div class="d-flex justify-content-between align-items-center mb-4">
<h2><i class="fas fa-users"></i> User Management</h2>
<a href="/admin/users/create" class="btn btn-primary">
<i class="fas fa-plus"></i> Add New User
</a>
</div>
@if (TempData["Success"] != null)
{
<div class="alert alert-success alert-dismissible fade show" role="alert">
@TempData["Success"]
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
}
@if (TempData["Error"] != null)
{
<div class="alert alert-danger alert-dismissible fade show" role="alert">
@TempData["Error"]
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
}
<div class="card">
<div class="card-body">
@if (Model.Any())
{
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Role</th>
<th>Phone</th>
<th>Status</th>
<th>Created</th>
<th>Last Login</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach (var user in Model)
{
<tr>
<td>
<strong>@user.Name</strong>
@if (user.Role == "MasterAdmin")
{
<span class="badge bg-danger ms-1">Master</span>
}
</td>
<td>@user.Email</td>
<td>
@if (user.Role == "MasterAdmin")
{
<span class="badge bg-danger">Master Admin</span>
}
else if (user.Role == "Admin")
{
<span class="badge bg-primary">Admin</span>
}
else if (user.Role == "Cashier")
{
<span class="badge bg-success">Cashier</span>
}
else if (user.Role == "Accountant")
{
<span class="badge bg-info">Accountant</span>
}
</td>
<td>@user.Phone</td>
<td>
@if (user.IsActive)
{
<span class="badge bg-success">Active</span>
}
else
{
<span class="badge bg-secondary">Inactive</span>
}
</td>
<td>@user.CreatedAt.ToString("MMM dd, yyyy")</td>
<td>
@if (user.LastLogin.HasValue)
{
@user.LastLogin.Value.ToString("MMM dd, yyyy HH:mm")
}
else
{
<span class="text-muted">Never</span>
}
</td>
<td>
<div class="btn-group" role="group">
<a href="/admin/users/view/@user.Id" class="btn btn-sm btn-info" title="View">
<i class="fas fa-eye"></i>
</a>
<a href="/admin/users/edit/@user.Id" class="btn btn-sm btn-warning" title="Edit">
<i class="fas fa-edit"></i>
</a>
@if (user.Role != "MasterAdmin")
{
<button type="button" class="btn btn-sm btn-danger" title="Delete"
onclick="deleteUser('@user.Id', '@user.Name')">
<i class="fas fa-trash"></i>
</button>
}
</div>
</td>
</tr>
}
</tbody>
</table>
</div>
}
else
{
<div class="text-center py-5">
<i class="fas fa-users fa-3x text-muted mb-3"></i>
<p class="text-muted">No users found. Create your first user to get started.</p>
<a href="/admin/users/create" class="btn btn-primary">
<i class="fas fa-plus"></i> Add New User
</a>
</div>
}
</div>
</div>
<!-- Role Permissions Reference -->
<div class="card mt-4">
<div class="card-header">
<h5 class="mb-0"><i class="fas fa-info-circle"></i> Role Permissions</h5>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-3">
<h6 class="text-danger"><i class="fas fa-crown"></i> Master Admin</h6>
<small class="text-muted">Full system access, can manage all users and settings</small>
</div>
<div class="col-md-3">
<h6 class="text-primary"><i class="fas fa-user-shield"></i> Admin</h6>
<small class="text-muted">Manage products, orders, content, and reports</small>
</div>
<div class="col-md-3">
<h6 class="text-success"><i class="fas fa-cash-register"></i> Cashier</h6>
<small class="text-muted">Process orders and payments, view products</small>
</div>
<div class="col-md-3">
<h6 class="text-info"><i class="fas fa-calculator"></i> Accountant</h6>
<small class="text-muted">View reports, manage finances, export data</small>
</div>
</div>
</div>
</div>
</div>
<!-- Delete Confirmation Modal -->
<form method="post" id="deleteForm">
<input type="hidden" name="id" id="deleteUserId" />
</form>
<script>
function deleteUser(id, name) {
if (confirm('Are you sure you want to delete user: ' + name + '?')) {
var form = document.getElementById('deleteForm');
form.action = '/admin/users/delete/' + id;
form.submit();
}
}
</script>