mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-22 17:12:26 +00:00
Add debug option to create new cases in the database
Used until we have a system to create cases when moderation actions are taken
This commit is contained in:
parent
ea25751e71
commit
13f935ffde
6 changed files with 104 additions and 31 deletions
|
@ -7,6 +7,18 @@
|
|||
Model.Title = "Cases";
|
||||
}
|
||||
|
||||
<p>There are @Model.CaseCount total cases.</p>
|
||||
|
||||
<form action="/moderation/cases/0">
|
||||
<div class="ui icon input">
|
||||
<input type="text" autocomplete="off" name="name" placeholder="Search cases..." value="@Model.SearchValue">
|
||||
<i class="search icon"></i>
|
||||
</div>
|
||||
<a class="ui red button" href="/debug/newCase">DEBUG: Create Case</a>
|
||||
</form>
|
||||
|
||||
<div class="ui divider"></div>
|
||||
|
||||
@foreach (ModerationCase @case in Model.Cases)
|
||||
{
|
||||
@(await Html.PartialAsync("Partials/ModerationCasePartial", @case))
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
using LBPUnion.ProjectLighthouse.Administration;
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages;
|
||||
|
||||
|
@ -11,37 +13,28 @@ public class CasePage : BaseLayout
|
|||
public CasePage(Database database) : base(database)
|
||||
{}
|
||||
|
||||
public List<ModerationCase> Cases = new();
|
||||
public List<ModerationCase> Cases;
|
||||
public int CaseCount;
|
||||
|
||||
public async Task<IActionResult> OnGet(int pageNumber)
|
||||
public int PageAmount;
|
||||
public int PageNumber;
|
||||
public string SearchValue = "";
|
||||
|
||||
public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string? name)
|
||||
{
|
||||
User? user = this.Database.UserFromWebRequest(this.Request);
|
||||
if (user == null) return this.NotFound();
|
||||
if (!user.IsModerator) return this.NotFound();
|
||||
|
||||
this.Cases.Add(new ModerationCase
|
||||
{
|
||||
CaseId = 1,
|
||||
CaseCreated = DateTime.Now,
|
||||
CaseExpires = new DateTime(2011, 11, 17),
|
||||
CaseCreatorId = user.UserId,
|
||||
CaseCreator = user,
|
||||
CaseDescription = "Being a dumbass",
|
||||
CaseType = CaseType.UserBan,
|
||||
AffectedId = user.UserId,
|
||||
});
|
||||
if (string.IsNullOrWhiteSpace(name)) name = "";
|
||||
|
||||
this.Cases.Add(new ModerationCase
|
||||
{
|
||||
CaseId = 2,
|
||||
CaseCreated = DateTime.Now,
|
||||
CaseExpires = new DateTime(2023, 11, 17),
|
||||
CaseCreatorId = user.UserId,
|
||||
CaseCreator = user,
|
||||
CaseDescription = "Being too cool",
|
||||
CaseType = CaseType.UserSilence,
|
||||
AffectedId = user.UserId,
|
||||
});
|
||||
this.SearchValue = name.Replace(" ", string.Empty);
|
||||
|
||||
this.Cases = await this.Database.Cases.ToListAsync();
|
||||
this.CaseCount = await this.Database.Cases.CountAsync(c => c.CaseDescription.Contains(this.SearchValue));
|
||||
|
||||
this.PageNumber = pageNumber;
|
||||
this.PageAmount = Math.Max(1, (int)Math.Ceiling((double)this.CaseCount / ServerStatics.PageSize));
|
||||
|
||||
return this.Page();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
@page "/debug/newCase"
|
||||
@using LBPUnion.ProjectLighthouse.Administration
|
||||
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Debug.NewCasePage
|
||||
|
||||
@{
|
||||
Layout = "Layouts/BaseLayout";
|
||||
Model.Title = "DEBUG - New Case";
|
||||
}
|
||||
|
||||
<form method="post">
|
||||
@Html.AntiForgeryToken()
|
||||
<label for="type">Case Type: </label>
|
||||
<select name="type" id="type">
|
||||
@foreach (CaseType type in Enum.GetValues<CaseType>())
|
||||
{
|
||||
<option value="@((int)type)">@type.ToString()</option>
|
||||
}
|
||||
</select><br/>
|
||||
|
||||
<label for="description">Description: </label>
|
||||
<input type="text" name="description" id="description"/><br/>
|
||||
|
||||
<label for="expires">Expires: </label>
|
||||
<input type="datetime-local" name="expires" id="expires"/><br/>
|
||||
|
||||
<label for="affected-id">Affected ID: </label>
|
||||
<input type="number" name="affectedId" id="affected-id"/><br/>
|
||||
|
||||
<br/><input type="submit"/>
|
||||
</form>
|
|
@ -0,0 +1,38 @@
|
|||
using System.Diagnostics;
|
||||
using LBPUnion.ProjectLighthouse.Administration;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Debug;
|
||||
|
||||
public class NewCasePage : BaseLayout
|
||||
{
|
||||
public NewCasePage(Database database) : base(database)
|
||||
{}
|
||||
|
||||
public IActionResult OnGet() => this.Page();
|
||||
|
||||
public async Task<IActionResult> OnPost(
|
||||
int type,
|
||||
string description,
|
||||
DateTime expires,
|
||||
int affectedId
|
||||
)
|
||||
{
|
||||
ModerationCase @case = new()
|
||||
{
|
||||
CaseType = (CaseType)type,
|
||||
CaseDescription = description,
|
||||
CaseExpires = expires,
|
||||
CaseCreated = DateTime.Now,
|
||||
CaseCreatorId = 1,
|
||||
AffectedId = affectedId,
|
||||
};
|
||||
|
||||
this.Database.Cases.Add(@case);
|
||||
await this.Database.SaveChangesAsync();
|
||||
|
||||
return this.Redirect("/moderation/cases/0");
|
||||
}
|
||||
}
|
|
@ -58,7 +58,7 @@
|
|||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/TYPE_DECLARATION_BRACES/@EntryValue">NEXT_LINE</s:String>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_AFTER_DECLARATION_LPAR/@EntryValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_AFTER_INVOCATION_LPAR/@EntryValue">False</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_ARGUMENTS_STYLE/@EntryValue">CHOP_ALWAYS</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_ARGUMENTS_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_ARRAY_INITIALIZER_STYLE/@EntryValue">CHOP_IF_LONG</s:String>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_BEFORE_DECLARATION_LPAR/@EntryValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_BEFORE_DECLARATION_RPAR/@EntryValue">True</s:Boolean>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
"Default": "Debug",
|
||||
"Microsoft": "Debug",
|
||||
"Microsoft.Hosting.Lifetime": "Debug"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue