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
This commit is contained in:
77
Sky_Art_shop/Views/AdminMenu/Create.cshtml
Normal file
77
Sky_Art_shop/Views/AdminMenu/Create.cshtml
Normal file
@@ -0,0 +1,77 @@
|
||||
@model SkyArtShop.Models.MenuItem
|
||||
@{
|
||||
Layout = "~/Views/Shared/_AdminLayout.cshtml";
|
||||
ViewData["Title"] = "Create Menu Item";
|
||||
}
|
||||
|
||||
<div class="mb-4">
|
||||
<a href="/admin/menu" class="btn btn-secondary">
|
||||
<i class="bi bi-arrow-left"></i> Back to Menu
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="mb-0">Create Menu Item</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="post" action="/admin/menu/create">
|
||||
<div asp-validation-summary="All" class="text-danger mb-3"></div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="Label" class="form-label">Label *</label>
|
||||
<input type="text" class="form-control" id="Label" name="Label" value="@Model.Label" required>
|
||||
<small class="form-text text-muted">The text that will appear in the navigation menu</small>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="Url" class="form-label">URL *</label>
|
||||
<input type="text" class="form-control" id="Url" name="Url" value="@Model.Url" required>
|
||||
<small class="form-text text-muted">Examples: /, /Shop, /About, /#promotion, #instagram</small>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="DisplayOrder" class="form-label">Display Order</label>
|
||||
<input type="number" class="form-control" id="DisplayOrder" name="DisplayOrder" value="@Model.DisplayOrder" min="0">
|
||||
<small class="form-text text-muted">Lower numbers appear first</small>
|
||||
</div>
|
||||
|
||||
<div class="form-check mb-3">
|
||||
<input asp-for="IsActive" class="form-check-input" type="checkbox" id="IsActive">
|
||||
<label class="form-check-label" for="IsActive">
|
||||
Active (Globally enable this menu item)
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check mb-3">
|
||||
<input asp-for="ShowInNavbar" class="form-check-input" type="checkbox" id="ShowInNavbar">
|
||||
<label class="form-check-label" for="ShowInNavbar">
|
||||
Show in Desktop Navbar
|
||||
</label>
|
||||
<small class="form-text text-muted d-block">Display in the horizontal navigation bar at the top</small>
|
||||
</div>
|
||||
|
||||
<div class="form-check mb-3">
|
||||
<input asp-for="ShowInDropdown" class="form-check-input" type="checkbox" id="ShowInDropdown">
|
||||
<label class="form-check-label" for="ShowInDropdown">
|
||||
Show in Hamburger Dropdown
|
||||
</label>
|
||||
<small class="form-text text-muted d-block">Display in the mobile menu and desktop hamburger dropdown</small>
|
||||
</div>
|
||||
|
||||
<div class="form-check mb-3">
|
||||
<input asp-for="OpenInNewTab" class="form-check-input" type="checkbox" id="OpenInNewTab">
|
||||
<label class="form-check-label" for="OpenInNewTab">
|
||||
Open in new tab
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="d-flex gap-2">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="bi bi-save"></i> Create Menu Item
|
||||
</button>
|
||||
<a href="/admin/menu" class="btn btn-secondary">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
77
Sky_Art_shop/Views/AdminMenu/Edit.cshtml
Normal file
77
Sky_Art_shop/Views/AdminMenu/Edit.cshtml
Normal file
@@ -0,0 +1,77 @@
|
||||
@model SkyArtShop.Models.MenuItem
|
||||
@{
|
||||
Layout = "~/Views/Shared/_AdminLayout.cshtml";
|
||||
ViewData["Title"] = "Edit Menu Item";
|
||||
}
|
||||
|
||||
<div class="mb-4">
|
||||
<a href="/admin/menu" class="btn btn-secondary">
|
||||
<i class="bi bi-arrow-left"></i> Back to Menu
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="mb-0">Edit Menu Item</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="post" action="/admin/menu/edit/@Model.Id">
|
||||
<div asp-validation-summary="All" class="text-danger mb-3"></div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="Label" class="form-label">Label *</label>
|
||||
<input type="text" class="form-control" id="Label" name="Label" value="@Model.Label" required>
|
||||
<small class="form-text text-muted">The text that will appear in the navigation menu</small>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="Url" class="form-label">URL *</label>
|
||||
<input type="text" class="form-control" id="Url" name="Url" value="@Model.Url" required>
|
||||
<small class="form-text text-muted">Examples: /, /Shop, /About, /#promotion, #instagram</small>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="DisplayOrder" class="form-label">Display Order</label>
|
||||
<input type="number" class="form-control" id="DisplayOrder" name="DisplayOrder" value="@Model.DisplayOrder" min="0">
|
||||
<small class="form-text text-muted">Lower numbers appear first</small>
|
||||
</div>
|
||||
|
||||
<div class="form-check mb-3">
|
||||
<input asp-for="IsActive" class="form-check-input" type="checkbox" id="IsActive">
|
||||
<label class="form-check-label" for="IsActive">
|
||||
Active (Globally enable this menu item)
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check mb-3">
|
||||
<input asp-for="ShowInNavbar" class="form-check-input" type="checkbox" id="ShowInNavbar">
|
||||
<label class="form-check-label" for="ShowInNavbar">
|
||||
Show in Desktop Navbar
|
||||
</label>
|
||||
<small class="form-text text-muted d-block">Display in the horizontal navigation bar at the top</small>
|
||||
</div>
|
||||
|
||||
<div class="form-check mb-3">
|
||||
<input asp-for="ShowInDropdown" class="form-check-input" type="checkbox" id="ShowInDropdown">
|
||||
<label class="form-check-label" for="ShowInDropdown">
|
||||
Show in Hamburger Dropdown
|
||||
</label>
|
||||
<small class="form-text text-muted d-block">Display in the mobile menu and desktop hamburger dropdown</small>
|
||||
</div>
|
||||
|
||||
<div class="form-check mb-3">
|
||||
<input asp-for="OpenInNewTab" class="form-check-input" type="checkbox" id="OpenInNewTab">
|
||||
<label class="form-check-label" for="OpenInNewTab">
|
||||
Open in new tab
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="d-flex gap-2">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="bi bi-save"></i> Update Menu Item
|
||||
</button>
|
||||
<a href="/admin/menu" class="btn btn-secondary">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
86
Sky_Art_shop/Views/AdminMenu/Index.cshtml
Normal file
86
Sky_Art_shop/Views/AdminMenu/Index.cshtml
Normal file
@@ -0,0 +1,86 @@
|
||||
@model List<SkyArtShop.Models.MenuItem>
|
||||
@{
|
||||
Layout = "~/Views/Shared/_AdminLayout.cshtml";
|
||||
ViewData["Title"] = "Manage Menu";
|
||||
}
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h2>Menu Items</h2>
|
||||
<div>
|
||||
<form method="post" action="/admin/menu/reseed" style="display:inline;" onsubmit="return confirm('This will delete all existing menu items and create new ones. Continue?')">
|
||||
<button type="submit" class="btn btn-warning">Reseed Menu</button>
|
||||
</form>
|
||||
<a href="/admin/menu/create" class="btn btn-primary">Add Menu Item</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (TempData["SuccessMessage"] != null)
|
||||
{
|
||||
<div class="alert alert-success">@TempData["SuccessMessage"]</div>
|
||||
}
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Order</th>
|
||||
<th>Label</th>
|
||||
<th>URL</th>
|
||||
<th>Status</th>
|
||||
<th>Navbar</th>
|
||||
<th>Dropdown</th>
|
||||
<th>New Tab</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>@item.DisplayOrder</td>
|
||||
<td>@item.Label</td>
|
||||
<td>@item.Url</td>
|
||||
<td>
|
||||
@if (item.IsActive)
|
||||
{
|
||||
<span class="badge bg-success">Active</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="badge bg-secondary">Inactive</span>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
@if (item.ShowInNavbar)
|
||||
{
|
||||
<span class="badge bg-primary">Yes</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="badge bg-light text-dark">No</span>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
@if (item.ShowInDropdown)
|
||||
{
|
||||
<span class="badge bg-info">Yes</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="badge bg-light text-dark">No</span>
|
||||
}
|
||||
</td>
|
||||
<td>@(item.OpenInNewTab ? "Yes" : "No")</td>
|
||||
<td>
|
||||
<a href="/admin/menu/edit/@item.Id" class="btn btn-sm btn-warning">Edit</a>
|
||||
<form method="post" action="/admin/menu/delete/@item.Id" style="display:inline;" onsubmit="return confirm('Delete this menu item?')">
|
||||
<button type="submit" class="btn btn-sm btn-danger">Delete</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user