112 lines
No EOL
3.2 KiB
Text
112 lines
No EOL
3.2 KiB
Text
@using System.ComponentModel.DataAnnotations
|
|
@using ImageBoardServerApp.Auth
|
|
@using ImageBoardServerApp.Data
|
|
@using ImageBoardServerApp.Data.Repository
|
|
@inject AuthenticationStateProvider authStateProvider
|
|
|
|
<div class="threadHeader">
|
|
@if (showOpenThread)
|
|
{
|
|
<span>[</span>
|
|
<a class="toggleOpened" onclick="@ToggleOpened">@toggleText</a>
|
|
<span>]</span>
|
|
}
|
|
<span class="title">@post.Title</span>
|
|
<span class="name">@post.Username</span>
|
|
@if (post.User.Role != "User")
|
|
{
|
|
<span class="@post.User.Role" >##@post.User.Role</span>
|
|
}
|
|
<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)
|
|
{
|
|
<img src="@($"{@post.Image.ImageLocation}")" alt="No Image found" />
|
|
}
|
|
else
|
|
{
|
|
<span>[No Image]</span>
|
|
}
|
|
</div>
|
|
<div class="threadTextContainer">
|
|
@foreach (string s in @post.Content.Split("\n"))
|
|
{
|
|
@if (@s.StartsWith(">"))
|
|
{
|
|
<span class="threadText greenText">@s</span>
|
|
}
|
|
else
|
|
{
|
|
<span class='threadText'>@s</span>
|
|
}
|
|
}
|
|
</div>
|
|
</div>
|
|
<div class="threadFooter">
|
|
<span>[</span>
|
|
<a @onclick="@deletePost" href="javascript:void(0)">Delete</a>
|
|
<span>]</span>
|
|
<span>[</span>
|
|
<a class="report" href="/report/op/@post.Board/@post.PostID" target="_blank">Report</a>
|
|
<span>]</span>
|
|
@if (showOpenThread)
|
|
{
|
|
<span>[</span>
|
|
<a class="openThread" href="/@post.Board/thread/@post.PostID">(@post.Comments.Count) View Thread</a>
|
|
<span>]</span>
|
|
}
|
|
else
|
|
{
|
|
<span>[</span>
|
|
<span class="openThread">@post.Comments.Count Comments</span>
|
|
<span>]</span>
|
|
}
|
|
</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;
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
private bool opened = true;
|
|
|
|
private string toggleText = "-";
|
|
|
|
private void ToggleOpened()
|
|
{
|
|
opened = !opened;
|
|
toggleText = opened ? "-" : "+";
|
|
}
|
|
|
|
[Parameter]
|
|
[Required]
|
|
public PostData post { get; set; }
|
|
|
|
|
|
[Parameter]
|
|
[Required]
|
|
public bool showOpenThread { get; set; }
|
|
} |