> nonApiRoutes = swaggerDoc.Paths.Where(x => !x.Key.ToLower().StartsWith("/api/v1")).ToList();
+ nonApiRoutes.ForEach(x => swaggerDoc.Paths.Remove(x.Key));
+ }
+}
\ No newline at end of file
diff --git a/ProjectLighthouse/Helpers/WebhookHelper.cs b/ProjectLighthouse/Helpers/WebhookHelper.cs
index c624fc45..9d0ea1c2 100644
--- a/ProjectLighthouse/Helpers/WebhookHelper.cs
+++ b/ProjectLighthouse/Helpers/WebhookHelper.cs
@@ -7,7 +7,7 @@ namespace LBPUnion.ProjectLighthouse.Helpers;
public static class WebhookHelper
{
- private static readonly DiscordWebhookClient client = new(ServerSettings.Instance.DiscordWebhookUrl);
+ private static readonly DiscordWebhookClient client = (ServerSettings.Instance.DiscordWebhookEnabled ? new DiscordWebhookClient(ServerSettings.Instance.DiscordWebhookUrl) : null);
public static readonly Color UnionColor = new(0, 140, 255);
public static Task SendWebhook(EmbedBuilder builder) => SendWebhook(builder.Build());
diff --git a/ProjectLighthouse/Maintenance/Commands/TestWebhookCommand.cs b/ProjectLighthouse/Maintenance/Commands/TestWebhookCommand.cs
new file mode 100644
index 00000000..93ed05b5
--- /dev/null
+++ b/ProjectLighthouse/Maintenance/Commands/TestWebhookCommand.cs
@@ -0,0 +1,22 @@
+using System.Threading.Tasks;
+using JetBrains.Annotations;
+using LBPUnion.ProjectLighthouse.Helpers;
+
+namespace LBPUnion.ProjectLighthouse.Maintenance.Commands;
+
+[UsedImplicitly]
+public class TestWebhookCommand : ICommand
+{
+ public async Task Run(string[] args)
+ {
+ await WebhookHelper.SendWebhook("Testing 123", "Someone is testing the Discord webhook from the admin panel.");
+ }
+ public string Name() => "Test Discord Webhook";
+ public string[] Aliases()
+ => new[]
+ {
+ "testWebhook", "testDiscordWebhook",
+ };
+ public string Arguments() => "";
+ public int RequiredArgs() => 0;
+}
\ No newline at end of file
diff --git a/ProjectLighthouse/Pages/Admin/AdminPanelPage.cshtml b/ProjectLighthouse/Pages/Admin/AdminPanelPage.cshtml
index cb28e826..97228b43 100644
--- a/ProjectLighthouse/Pages/Admin/AdminPanelPage.cshtml
+++ b/ProjectLighthouse/Pages/Admin/AdminPanelPage.cshtml
@@ -1,7 +1,8 @@
@page "/admin"
@using LBPUnion.ProjectLighthouse.Helpers
+@using LBPUnion.ProjectLighthouse.Helpers.Extensions
@using LBPUnion.ProjectLighthouse.Maintenance
-@using LBPUnion.ProjectLighthouse.Types.Settings
+@using LBPUnion.ProjectLighthouse.Types
@model LBPUnion.ProjectLighthouse.Pages.Admin.AdminPanelPage
@{
@@ -9,61 +10,63 @@
Model.Title = "Admin Panel";
}
-
-
- View Users
-
-
-@if (ServerSettings.Instance.DiscordWebhookEnabled)
+@if (!this.Request.IsMobile())
{
-
-
- Test Discord Webhook
-
-
+
+ @foreach (AdminPanelStatistic statistic in Model.Statistics)
+ {
+ @await Html.PartialAsync("Partials/AdminPanelStatisticPartial", statistic)
+ }
+
+
+}
+else
+{
+ @foreach (AdminPanelStatistic statistic in Model.Statistics)
+ {
+ @await Html.PartialAsync("Partials/AdminPanelStatisticPartial", statistic)
+
+ }
}
Commands
-
- @foreach (ICommand command in MaintenanceHelper.Commands)
- {
-
- }
-
+@foreach (ICommand command in MaintenanceHelper.Commands)
+{
+
+}
Maintenance Jobs
Warning: Interrupting Lighthouse during maintenance may leave the database in an unclean state.
-
- @foreach (IMaintenanceJob job in MaintenanceHelper.MaintenanceJobs)
- {
-
-
-
@job.Name()
-
@job.Description()
-
-
-
- }
-
\ No newline at end of file
+@foreach (IMaintenanceJob job in MaintenanceHelper.MaintenanceJobs)
+{
+
+
@job.Name()
+
@job.Description()
+
+
+}
\ No newline at end of file
diff --git a/ProjectLighthouse/Pages/Admin/AdminPanelPage.cshtml.cs b/ProjectLighthouse/Pages/Admin/AdminPanelPage.cshtml.cs
index 4df3a805..92e5a5b0 100644
--- a/ProjectLighthouse/Pages/Admin/AdminPanelPage.cshtml.cs
+++ b/ProjectLighthouse/Pages/Admin/AdminPanelPage.cshtml.cs
@@ -15,12 +15,18 @@ public class AdminPanelPage : BaseLayout
public AdminPanelPage(Database database) : base(database)
{}
+ public List Statistics = new();
+
public async Task OnGet([FromQuery] string? args, [FromQuery] string? command, [FromQuery] string? maintenanceJob)
{
User? user = this.Database.UserFromWebRequest(this.Request);
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("Slots", await StatisticsHelper.SlotCount()));
+ this.Statistics.Add(new AdminPanelStatistic("Photos", await StatisticsHelper.PhotoCount()));
+
if (!string.IsNullOrEmpty(command))
{
args ??= "";
diff --git a/ProjectLighthouse/Pages/LoginForm.cshtml b/ProjectLighthouse/Pages/LoginForm.cshtml
index ede86b66..2e5494a4 100644
--- a/ProjectLighthouse/Pages/LoginForm.cshtml
+++ b/ProjectLighthouse/Pages/LoginForm.cshtml
@@ -11,9 +11,10 @@