mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-16 14:42:28 +00:00
Add basic mod panel
This commit is contained in:
parent
1037a6eddb
commit
693f0a3855
9 changed files with 84 additions and 22 deletions
|
@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore;
|
|||
namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Admin;
|
||||
|
||||
[ApiController]
|
||||
[Route("admin/report/{id:int}")]
|
||||
[Route("/modPanel/report/{id:int}")]
|
||||
public class AdminReportController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
|
@ -73,6 +73,6 @@ public class AdminReportController : ControllerBase
|
|||
|
||||
await this.database.SaveChangesAsync();
|
||||
|
||||
return this.Redirect("~/admin/reports/0");
|
||||
return this.Redirect("~/modPanel/reports/0");
|
||||
}
|
||||
}
|
|
@ -41,6 +41,11 @@ else
|
|||
}
|
||||
}
|
||||
|
||||
<a class="ui blue button" href="/modPanel">
|
||||
<i class="user shield icon"></i>
|
||||
<span>View Mod Panel</span>
|
||||
</a>
|
||||
|
||||
<h2>Commands</h2>
|
||||
@foreach (ICommand command in MaintenanceHelper.Commands)
|
||||
{
|
||||
|
|
|
@ -27,10 +27,9 @@ public class AdminPanelPage : BaseLayout
|
|||
if (user == null) return this.Redirect("~/login");
|
||||
if (!user.IsAdmin) return this.NotFound();
|
||||
|
||||
this.Statistics.Add(new AdminPanelStatistic("Users", await StatisticsHelper.UserCount(), "users"));
|
||||
this.Statistics.Add(new AdminPanelStatistic("Users", await StatisticsHelper.UserCount(), "/admin/users"));
|
||||
this.Statistics.Add(new AdminPanelStatistic("Slots", await StatisticsHelper.SlotCount()));
|
||||
this.Statistics.Add(new AdminPanelStatistic("Photos", await StatisticsHelper.PhotoCount()));
|
||||
this.Statistics.Add(new AdminPanelStatistic("Reports", await StatisticsHelper.ReportCount(), "reports/0"));
|
||||
|
||||
if (!string.IsNullOrEmpty(command))
|
||||
{
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
@page "/modPanel"
|
||||
@using LBPUnion.ProjectLighthouse.Administration
|
||||
@using LBPUnion.ProjectLighthouse.Extensions
|
||||
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Admin.ModPanelPage
|
||||
|
||||
@{
|
||||
Layout = "Layouts/BaseLayout";
|
||||
Model.Title = "Moderator Panel";
|
||||
}
|
||||
|
||||
@if (!this.Request.IsMobile())
|
||||
{
|
||||
<div class="ui grid">
|
||||
@foreach (AdminPanelStatistic statistic in Model.Statistics)
|
||||
{
|
||||
@await Html.PartialAsync("Partials/AdminPanelStatisticPartial", statistic)
|
||||
}
|
||||
</div>
|
||||
<br>
|
||||
}
|
||||
else
|
||||
{
|
||||
@foreach (AdminPanelStatistic statistic in Model.Statistics)
|
||||
{
|
||||
@await Html.PartialAsync("Partials/AdminPanelStatisticPartial", statistic)
|
||||
<br>
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using LBPUnion.ProjectLighthouse.Administration;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Admin;
|
||||
|
||||
public class ModPanelPage : BaseLayout
|
||||
{
|
||||
public ModPanelPage(Database database) : base(database)
|
||||
{}
|
||||
|
||||
public List<AdminPanelStatistic> Statistics = new();
|
||||
|
||||
public async Task<IActionResult> OnGet()
|
||||
{
|
||||
User? user = this.Database.UserFromWebRequest(this.Request);
|
||||
if (user == null) return this.Redirect("~/login");
|
||||
if (!user.IsModerator) return this.NotFound();
|
||||
|
||||
this.Statistics.Add(new AdminPanelStatistic("Reports", await StatisticsHelper.ReportCount(), "/modPanel/reports/0"));
|
||||
|
||||
return this.Page();
|
||||
}
|
||||
}
|
|
@ -21,6 +21,10 @@
|
|||
{
|
||||
Model.NavigationItemsRight.Add(new PageNavigationItem("Admin Panel", "/admin", "cogs"));
|
||||
}
|
||||
else if(Model.User.IsModerator)
|
||||
{
|
||||
Model.NavigationItemsRight.Add(new PageNavigationItem("Mod Panel", "/modPanel", "user shield"));
|
||||
}
|
||||
Model.NavigationItemsRight.Add(new PageNavigationItem("Log out", "/logout", "user alternate slash")); // should always be last
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
@if (Model.ViewAllEndpoint != null)
|
||||
{
|
||||
<h2>
|
||||
<a href="/admin/@Model.ViewAllEndpoint">@Model.StatisticNamePlural</a>
|
||||
<a href="@Model.ViewAllEndpoint">@Model.StatisticNamePlural</a>
|
||||
</h2>
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@page "/admin/reports/{pageNumber:int}"
|
||||
@page "/modPanel/reports/{pageNumber:int}"
|
||||
@using LBPUnion.ProjectLighthouse.Administration.Reports
|
||||
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.ReportsPage
|
||||
|
||||
|
@ -7,9 +7,9 @@
|
|||
Model.Title = "Reports";
|
||||
}
|
||||
|
||||
<p>There are @Model.ReportCount total reports!</p>
|
||||
<p>There are @Model.ReportCount total reports.</p>
|
||||
|
||||
<form action="/admin/reports/0">
|
||||
<form action="/modPanel/reports/0">
|
||||
<div class="ui icon input">
|
||||
<input type="text" name="name" placeholder="Search reports..." value="@Model.SearchValue">
|
||||
<i class="search icon"></i>
|
||||
|
@ -69,11 +69,11 @@
|
|||
</div>
|
||||
<br>
|
||||
|
||||
<a class="ui green small button" href="/admin/report/@report.ReportId/dismiss">
|
||||
<a class="ui green small button" href="/modPanel/report/@report.ReportId/dismiss">
|
||||
<i class="checkmark icon"></i>
|
||||
<span>Dismiss</span>
|
||||
</a>
|
||||
<a class="ui red small button" href="/admin/report/@report.ReportId/remove">
|
||||
<a class="ui red small button" href="/modPanel/report/@report.ReportId/remove">
|
||||
<i class="trash icon"></i>
|
||||
<span>Remove all related assets</span>
|
||||
</a>
|
||||
|
@ -239,10 +239,10 @@
|
|||
|
||||
@if (Model.PageNumber != 0)
|
||||
{
|
||||
<a href="/admin/reports/@(Model.PageNumber - 1)@(Model.SearchValue.Length == 0 ? "" : "?name=" + Model.SearchValue)">Previous Page</a>
|
||||
<a href="/modPanel/reports/@(Model.PageNumber - 1)@(Model.SearchValue.Length == 0 ? "" : "?name=" + Model.SearchValue)">Previous Page</a>
|
||||
}
|
||||
@(Model.PageNumber + 1) / @(Model.PageAmount)
|
||||
@if (Model.PageNumber < Model.PageAmount - 1)
|
||||
{
|
||||
<a href="/admin/reports/@(Model.PageNumber + 1)@(Model.SearchValue.Length == 0 ? "" : "?name=" + Model.SearchValue)">Next Page</a>
|
||||
<a href="/modPanel/reports/@(Model.PageNumber + 1)@(Model.SearchValue.Length == 0 ? "" : "?name=" + Model.SearchValue)">Next Page</a>
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue