2023-01-18 12:56:24 +00:00
|
|
|
@using System.ComponentModel.DataAnnotations
|
2023-02-02 17:50:50 +00:00
|
|
|
@using ImageBoardServerApp.Auth
|
2023-01-18 12:56:24 +00:00
|
|
|
@using ImageBoardServerApp.Data
|
2023-02-02 17:50:50 +00:00
|
|
|
@using ImageBoardServerApp.Data.Repository
|
|
|
|
@inject AuthenticationStateProvider authStateProvider
|
2023-01-18 12:56:24 +00:00
|
|
|
|
|
|
|
<div class="threadHeader">
|
2023-01-25 22:45:36 +00:00
|
|
|
@if (showOpenThread)
|
|
|
|
{
|
|
|
|
<span>[</span>
|
|
|
|
<a class="toggleOpened" onclick="@ToggleOpened">@toggleText</a>
|
|
|
|
<span>]</span>
|
|
|
|
}
|
2023-01-18 12:56:24 +00:00
|
|
|
<span class="title">@post.Title</span>
|
|
|
|
<span class="name">@post.Username</span>
|
2023-02-07 20:21:38 +00:00
|
|
|
@if (post.User.Role != "User")
|
2023-02-07 20:47:28 +00:00
|
|
|
{
|
|
|
|
<span class="@post.User.Role" >##@post.User.Role</span>
|
|
|
|
}
|
2023-01-18 12:56:24 +00:00
|
|
|
<span class="date">@getTimeFromUnix(post.CreatedAt)</span>
|
|
|
|
<span class="post-id">No.@post.PostID</span>
|
|
|
|
</div>
|
|
|
|
@if (opened)
|
|
|
|
{
|
|
|
|
<div class="threadContent">
|
|
|
|
<div class="threadImage">
|
|
|
|
@if (@post.Image != null)
|
|
|
|
{
|
2023-02-01 13:18:36 +00:00
|
|
|
<img src="@($"{@post.Image.ImageLocation}")" alt="No Image found" />
|
2023-01-18 12:56:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<span>[No Image]</span>
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
<div class="threadTextContainer">
|
|
|
|
@foreach (string s in @post.Content.Split("\n"))
|
|
|
|
{
|
2023-02-07 20:47:28 +00:00
|
|
|
@if (@s.StartsWith(">"))
|
2023-01-26 12:04:55 +00:00
|
|
|
{
|
|
|
|
<span class="threadText greenText">@s</span>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<span class='threadText'>@s</span>
|
|
|
|
}
|
2023-01-18 12:56:24 +00:00
|
|
|
}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="threadFooter">
|
2023-02-02 17:50:50 +00:00
|
|
|
<span>[</span>
|
|
|
|
<a @onclick="@deletePost" href="javascript:void(0)">Delete</a>
|
|
|
|
<span>]</span>
|
2023-01-18 12:56:24 +00:00
|
|
|
<span>[</span>
|
2023-02-12 16:01:46 +00:00
|
|
|
<a class="report" href="/sys/report/op/@post.Board/@post.PostID" target="_blank">Report</a>
|
2023-01-18 12:56:24 +00:00
|
|
|
<span>]</span>
|
2023-01-25 22:45:36 +00:00
|
|
|
@if (showOpenThread)
|
|
|
|
{
|
|
|
|
<span>[</span>
|
2023-02-02 17:50:50 +00:00
|
|
|
<a class="openThread" href="/@post.Board/thread/@post.PostID">(@post.Comments.Count) View Thread</a>
|
2023-01-25 22:45:36 +00:00
|
|
|
<span>]</span>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<span>[</span>
|
|
|
|
<span class="openThread">@post.Comments.Count Comments</span>
|
|
|
|
<span>]</span>
|
|
|
|
}
|
2023-01-18 12:56:24 +00:00
|
|
|
</div>
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@code {
|
|
|
|
private static DateTime getTimeFromUnix(double javaTimeStamp)
|
|
|
|
{
|
|
|
|
var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
|
|
|
dateTime = dateTime.AddMilliseconds( javaTimeStamp ).ToLocalTime();
|
|
|
|
return dateTime;
|
|
|
|
}
|
|
|
|
|
2023-02-02 17:50:50 +00:00
|
|
|
private async Task deletePost()
|
|
|
|
{
|
|
|
|
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
|
|
|
|
var user = await cauthStateProvder.GetAuthenticationStateAsync();
|
|
|
|
var usr = user.User;
|
|
|
|
UserData foundusr = await UsersRepository.getUserByEmailAsync(usr.Identity.Name);
|
|
|
|
if (foundusr.PermissionInteger >= 50 || post.UserID == foundusr.UserID)
|
|
|
|
{
|
|
|
|
await PostsRepository.deletePostAsync(post.PostID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-18 12:56:24 +00:00
|
|
|
private bool opened = true;
|
|
|
|
|
|
|
|
private string toggleText = "-";
|
|
|
|
|
|
|
|
private void ToggleOpened()
|
|
|
|
{
|
|
|
|
opened = !opened;
|
|
|
|
toggleText = opened ? "-" : "+";
|
|
|
|
}
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
[Required]
|
|
|
|
public PostData post { get; set; }
|
2023-01-25 22:45:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
[Required]
|
|
|
|
public bool showOpenThread { get; set; }
|
2023-01-18 12:56:24 +00:00
|
|
|
}
|