feat: added User Screen for admins
This commit is contained in:
parent
0279df06fa
commit
df1ac86636
11 changed files with 163 additions and 31 deletions
|
@ -9,6 +9,12 @@
|
|||
<span>We're currently hosting @amountOfPosts Threads, @amountOfComments Comments and @amountOfUsers Users.</span>
|
||||
<sr/>
|
||||
<span>@Details</span>
|
||||
<AuthorizeView>
|
||||
<Authorized>
|
||||
<br/>
|
||||
<a href="/sys/you">Edit your account</a>
|
||||
</Authorized>
|
||||
</AuthorizeView>
|
||||
|
||||
@code{
|
||||
private string Details { get; set; }
|
||||
|
|
104
ImageBoardServerApp/Pages/Basic/ReportPage.razor
Normal file
104
ImageBoardServerApp/Pages/Basic/ReportPage.razor
Normal file
|
@ -0,0 +1,104 @@
|
|||
@page "/sys/report/{type}/{board}/{id}"
|
||||
@using System.ComponentModel.DataAnnotations
|
||||
@using System.Data
|
||||
@using ImageBoardServerApp.Auth
|
||||
@using ImageBoardServerApp.Data.Repository
|
||||
@inject AuthenticationStateProvider authStateProvider
|
||||
@inject IJSRuntime js
|
||||
<AuthorizeView>
|
||||
<Authorized>
|
||||
<h3>Report @type#@id on /@board/</h3>
|
||||
<div>
|
||||
<select name="rule" id="rule" @bind="@selectedItem">
|
||||
<option value="none">Select</option>
|
||||
@foreach (var r in RulesConv.dict.Keys)
|
||||
{
|
||||
<option value="@r">@RulesConv.dict[r]</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<span>@selectedItem</span>
|
||||
<br/>
|
||||
<span>Explain further (optional)</span>
|
||||
<div class="pd centered marg">
|
||||
<RadzenTextArea Placeholder="Specify..." @bind-Value="@explaination" Cols="30" Rows="6" Class="w-100"/>
|
||||
</div>
|
||||
<RadzenButton class="pd" Click="@onReportClick" Text="Report"></RadzenButton>
|
||||
</Authorized>
|
||||
<NotAuthorized>
|
||||
<span>Please login to report</span>
|
||||
</NotAuthorized>
|
||||
</AuthorizeView>
|
||||
|
||||
@code {
|
||||
private IEnumerable<Rule> rules;
|
||||
private string selectedItem;
|
||||
private string explaination;
|
||||
|
||||
|
||||
[Parameter]
|
||||
[Required]
|
||||
public string type { get; set; }
|
||||
|
||||
[Parameter]
|
||||
[Required]
|
||||
public string board { get; set; }
|
||||
|
||||
[Parameter]
|
||||
[Required]
|
||||
public string id { get; set; }
|
||||
|
||||
|
||||
private async Task onReportClick()
|
||||
{
|
||||
if (selectedItem == null || selectedItem == "none")
|
||||
return;
|
||||
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
|
||||
var user = await cauthStateProvder.GetAuthenticationStateAsync();
|
||||
var usr = user.User;
|
||||
UserData foundusr = await UsersRepository.getUserByEmailAsync(usr.Identity.Name);
|
||||
if (foundusr == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (foundusr.TimeBanned != -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foundusr.lastActionTimeStamp = DateTimeOffset.UnixEpoch.ToUnixTimeMilliseconds();
|
||||
await UsersRepository.updateUserAsync(foundusr);
|
||||
int targetID = 0;
|
||||
if (type == "op")
|
||||
{
|
||||
var post = await PostsRepository.getPostByIdAsync(Int32.Parse(id));
|
||||
targetID = post.User.UserID;
|
||||
}
|
||||
else
|
||||
{
|
||||
var comment = await CommentsRepository.getCommentByIdAsync(Int32.Parse(id));
|
||||
targetID = comment.User.UserID;
|
||||
}
|
||||
|
||||
ReportData reportData = new ReportData()
|
||||
{
|
||||
Type = type,
|
||||
ReportedCommentID = type == "op" ? null : Int32.Parse(id),
|
||||
ReportedPostID = type == "op" ? Int32.Parse(id) : null,
|
||||
UserReporterID = foundusr.UserID,
|
||||
UserReportedID = targetID,
|
||||
ReportReason = RulesConv.dict[RulesConv.dict2[selectedItem]],
|
||||
ReportExlaination = explaination
|
||||
};
|
||||
|
||||
List<ReportData> submittedReports = foundusr.RecivedReports;
|
||||
foreach(var r in submittedReports)
|
||||
{
|
||||
if (r.ReportedPostID == reportData.ReportedPostID && r.ReportedCommentID == reportData.ReportedCommentID)
|
||||
return;
|
||||
}
|
||||
|
||||
var reportID = await ReportsRepository.createReportAsync(reportData);
|
||||
js.InvokeVoidAsync("window.close");
|
||||
}
|
||||
}
|
13
ImageBoardServerApp/Pages/Basic/ReportPage.razor.css
Normal file
13
ImageBoardServerApp/Pages/Basic/ReportPage.razor.css
Normal file
|
@ -0,0 +1,13 @@
|
|||
.centered {
|
||||
text-align: center;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.pd {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.marg{
|
||||
margin: 2px
|
||||
}
|
44
ImageBoardServerApp/Pages/Basic/ThreadPage.razor
Normal file
44
ImageBoardServerApp/Pages/Basic/ThreadPage.razor
Normal file
|
@ -0,0 +1,44 @@
|
|||
@page "/{boardName}/thread/{threadId}"
|
||||
@using System.ComponentModel.DataAnnotations
|
||||
@using ImageBoardServerApp.Data.Repository
|
||||
@inject NavigationManager NavigationManager
|
||||
|
||||
<h3>Thread #@threadId on /@boardName/</h3>
|
||||
<Post post="@post" showOpenThread="false"/>
|
||||
<hr/>
|
||||
|
||||
@foreach (var comment in post.Comments)
|
||||
{
|
||||
<Comment comment="comment"/>
|
||||
<hr/>
|
||||
}
|
||||
<CommentForm post="post"/>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
[Required]
|
||||
public string boardName { get; set; }
|
||||
|
||||
[Parameter]
|
||||
[Required]
|
||||
public string threadId { get; set; }
|
||||
|
||||
private PostData post;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
post = await PostsRepository.getPostByIdAsync(int.Parse(threadId));
|
||||
}
|
||||
catch (FormatException fe)
|
||||
{
|
||||
NavigationManager.NavigateTo("/notfound");
|
||||
return;
|
||||
}
|
||||
if(post.Board != boardName)
|
||||
NavigationManager.NavigateTo("/notfound");
|
||||
if(post == null)
|
||||
NavigationManager.NavigateTo("/notfound");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue