mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-08 04:48:44 +00:00
Major refactor and reorganization of types (#652)
* Start of reorganization and cleanup * Remove duplicate title id * Refactor types * Fix Release building * Move classes in /Types to a Types namespace * Fix compilation error (RoomVisualizerPage strikes again) * Fix bugs created from auto merge * Fix auto-merge compilation error * Changes from review/fix failed merge
This commit is contained in:
parent
c8120b3388
commit
f1c5ad4002
316 changed files with 1623 additions and 1518 deletions
|
@ -1,7 +1,6 @@
|
|||
@page "/admin/keys"
|
||||
|
||||
@using LBPUnion.ProjectLighthouse.PlayerData
|
||||
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Admin.AdminAPIKeyPageModel
|
||||
@using LBPUnion.ProjectLighthouse.Types.Entities.Token
|
||||
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Admin.AdminApiKeyPageModel
|
||||
@{
|
||||
Layout = "Layouts/BaseLayout";
|
||||
Model.Title = "API Keys";
|
||||
|
@ -9,7 +8,7 @@
|
|||
|
||||
@inject Microsoft.AspNetCore.Antiforgery.IAntiforgery Antiforgery
|
||||
@{
|
||||
var token = Antiforgery.GetAndStoreTokens(HttpContext).RequestToken;
|
||||
string? token = Antiforgery.GetAndStoreTokens(HttpContext).RequestToken;
|
||||
}
|
||||
|
||||
<script>function deleteKey(keyID) {
|
||||
|
@ -39,7 +38,7 @@
|
|||
}
|
||||
|
||||
<div class="ui four column grid">
|
||||
@foreach (APIKey key in Model.APIKeys)
|
||||
@foreach (ApiKey key in Model.ApiKeys)
|
||||
{
|
||||
<div id="keyitem-@key.Id" class="five wide column">
|
||||
<div class="ui blue segment">
|
|
@ -1,17 +1,17 @@
|
|||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.PlayerData;
|
||||
using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Admin
|
||||
{
|
||||
public class AdminAPIKeyPageModel : BaseLayout
|
||||
namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Admin;
|
||||
|
||||
public class AdminApiKeyPageModel : BaseLayout
|
||||
{
|
||||
public List<APIKey> APIKeys = new();
|
||||
public List<ApiKey> ApiKeys = new();
|
||||
public int KeyCount;
|
||||
|
||||
public AdminAPIKeyPageModel(Database database) : base(database)
|
||||
public AdminApiKeyPageModel(Database database) : base(database)
|
||||
{ }
|
||||
|
||||
public async Task<IActionResult> OnGet()
|
||||
|
@ -20,18 +20,18 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Admin
|
|||
if (user == null) return this.Redirect("~/login");
|
||||
if (!user.IsAdmin) return this.NotFound();
|
||||
|
||||
this.APIKeys = await this.Database.APIKeys.OrderByDescending(k => k.Id).ToListAsync();
|
||||
this.KeyCount = this.APIKeys.Count;
|
||||
this.ApiKeys = await this.Database.APIKeys.OrderByDescending(k => k.Id).ToListAsync();
|
||||
this.KeyCount = this.ApiKeys.Count;
|
||||
|
||||
return this.Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPost(string keyID)
|
||||
public async Task<IActionResult> OnPost(string keyId)
|
||||
{
|
||||
User? user = this.Database.UserFromWebRequest(this.Request);
|
||||
if (user == null || !user.IsAdmin) return this.NotFound();
|
||||
|
||||
APIKey? apiKey = await this.Database.APIKeys.FirstOrDefaultAsync(k => k.Id == int.Parse(keyID));
|
||||
ApiKey? apiKey = await this.Database.APIKeys.FirstOrDefaultAsync(k => k.Id == int.Parse(keyId));
|
||||
if (apiKey == null) return this.NotFound();
|
||||
this.Database.APIKeys.Remove(apiKey);
|
||||
await this.Database.SaveChangesAsync();
|
||||
|
@ -39,5 +39,4 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Admin
|
|||
return this.Page();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,8 @@
|
|||
@page "/admin"
|
||||
@using LBPUnion.ProjectLighthouse.Administration
|
||||
@using LBPUnion.ProjectLighthouse.Administration.Maintenance
|
||||
@using LBPUnion.ProjectLighthouse.Extensions
|
||||
@using LBPUnion.ProjectLighthouse.Helpers
|
||||
@using LBPUnion.ProjectLighthouse.Types
|
||||
@using LBPUnion.ProjectLighthouse.Servers.Website.Types
|
||||
@using LBPUnion.ProjectLighthouse.Types.Maintenance
|
||||
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Admin.AdminPanelPage
|
||||
|
||||
@{
|
||||
|
@ -22,7 +21,7 @@
|
|||
</div>
|
||||
}
|
||||
|
||||
@if (!this.Request.IsMobile())
|
||||
@if (!Request.IsMobile())
|
||||
{
|
||||
<div class="ui grid">
|
||||
@foreach (AdminPanelStatistic statistic in Model.Statistics)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Administration;
|
||||
using LBPUnion.ProjectLighthouse.Administration.Maintenance;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Logging;
|
||||
using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Types;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using LBPUnion.ProjectLighthouse.Types.Logging;
|
||||
using LBPUnion.ProjectLighthouse.Types.Maintenance;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Admin;
|
||||
|
@ -30,7 +30,7 @@ public class AdminPanelPage : BaseLayout
|
|||
this.Statistics.Add(new AdminPanelStatistic("Users", await StatisticsHelper.UserCount(this.Database), "/admin/users"));
|
||||
this.Statistics.Add(new AdminPanelStatistic("Slots", await StatisticsHelper.SlotCount(this.Database)));
|
||||
this.Statistics.Add(new AdminPanelStatistic("Photos", await StatisticsHelper.PhotoCount(this.Database)));
|
||||
this.Statistics.Add(new AdminPanelStatistic("API Keys", await StatisticsHelper.APIKeyCount(this.Database), "/admin/keys"));
|
||||
this.Statistics.Add(new AdminPanelStatistic("API Keys", await StatisticsHelper.ApiKeyCount(this.Database), "/admin/keys"));
|
||||
|
||||
if (!string.IsNullOrEmpty(command))
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
@page "/admin/users"
|
||||
@using LBPUnion.ProjectLighthouse.Administration
|
||||
@using LBPUnion.ProjectLighthouse.PlayerData.Profiles
|
||||
@using LBPUnion.ProjectLighthouse.Types.Entities.Profile
|
||||
@using LBPUnion.ProjectLighthouse.Types.Users
|
||||
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Admin.AdminPanelUsersPage
|
||||
|
||||
@{
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue