+
+ @if (image != null)
+ {
+
+ }
+
+
+ @foreach (string s in @comment.Content.Split("\n"))
+ {
+ @if (s.StartsWith(">"))
+ {
+ @s
+ }
+ else
+ {
+ @s
+ }
+ }
+
+
+
+}
+
+
+
+@code {
+
+ 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 || comment.UserID == foundusr.UserID)
+ {
+ await CommentsRepository.deleteCommentAsync(comment.CommentID);
+ }
+ }
+
+
+ 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 ImageData image;
+
+ protected override async Task OnInitializedAsync()
+ {
+ int i;
+ try
+ {
+ i = (int)comment.ImageID;
+ }
+ catch (InvalidOperationException ioe)
+ {
+ i = -1;
+ }
+ if (i != null)
+ {
+ image = await ImagesRepository.getImageByIdAsync(i);
+ }
+ }
+
+ private bool opened = true;
+
+ private string toggleText = "-";
+
+ private void ToggleOpened()
+ {
+ opened = !opened;
+ toggleText = opened ? "-" : "+";
+ }
+
+ [Parameter]
+ [Required]
+ public CommentData comment { get; set; }
+}
\ No newline at end of file
diff --git a/ImageBoardServerApp/Shared/Components/Comment.razor.css b/ImageBoardServerApp/Shared/Components/Comment.razor.css
new file mode 100644
index 0000000..4de11ba
--- /dev/null
+++ b/ImageBoardServerApp/Shared/Components/Comment.razor.css
@@ -0,0 +1,70 @@
+.toggleOpened{
+ color: #0a58ca;
+ text-decoration: none;
+}
+
+.toggleOpened:hover{
+ color: #0a58ca; !important;
+ cursor: pointer;
+}
+
+.title{
+ color: #1e5aaf;
+}
+
+.name{
+ color: #339305;
+}
+
+.threadHeader{
+ text-align: left;
+}
+
+.threadFooter{
+ text-align: right; !important;
+ align-self: end; !important;
+}
+
+.threadContent{
+ text-align: left;
+ display: flex;
+}
+
+.greenText{
+ color: #3caf03;
+}
+
+.threadImage{
+ margin: 6px;
+ max-width: 500px;
+ max-height: 500px;
+ padding: 5px;
+}
+
+.threadImage img{
+ max-width:150px;
+ width: 100%;
+}
+
+.threadImage img:hover{
+ /*transform: scale(3);*/
+ max-width:500px;
+ width: 100%;
+}
+
+.threadText{
+ display: grid;
+}
+
+.threadTextContainer{
+ margin: 0;
+}
+
+
+.Admin{
+ color: #ff191c;
+}
+
+.Mod{
+ color: #af13d7;
+}
\ No newline at end of file
diff --git a/ImageBoardServerApp/Shared/Components/Forms/CommentForm.razor b/ImageBoardServerApp/Shared/Components/Forms/CommentForm.razor
new file mode 100644
index 0000000..90bf2c6
--- /dev/null
+++ b/ImageBoardServerApp/Shared/Components/Forms/CommentForm.razor
@@ -0,0 +1,155 @@
+@using System.ComponentModel.DataAnnotations
+@using ImageBoardServerApp.Auth
+@using ImageBoardServerApp.Data.Repository
+
+@inject NavigationManager navigationManager
+@inject IWebHostEnvironment env
+@inject AuthenticationStateProvider authStateProvider
+
+
-
@if (@post.Image != null)
{
-
+
}
else
{
@@ -27,27 +36,42 @@
@foreach (string s in @post.Content.Split("\n"))
{
- @s
+ @if (@s.StartsWith(">"))
+ {
+ @s
+ }
+ else
+ {
+ @s
+ }
}
}
@code {
-
-
-
private static DateTime getTimeFromUnix(double javaTimeStamp)
{
var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
@@ -55,6 +79,18 @@
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 = "-";
@@ -68,4 +104,9 @@
[Parameter]
[Required]
public PostData post { get; set; }
+
+
+ [Parameter]
+ [Required]
+ public bool showOpenThread { get; set; }
}
\ No newline at end of file
diff --git a/ImageBoardServerApp/Shared/Components/Post.razor.css b/ImageBoardServerApp/Shared/Components/Post.razor.css
index da7824a..2cee082 100644
--- a/ImageBoardServerApp/Shared/Components/Post.razor.css
+++ b/ImageBoardServerApp/Shared/Components/Post.razor.css
@@ -16,6 +16,14 @@
color: #339305;
}
+.Admin{
+ color: #ff191c;
+}
+
+.Mod{
+ color: #af13d7;
+}
+
.threadHeader{
text-align: left;
}
@@ -30,6 +38,10 @@
display: flex;
}
+.greenText{
+ color: #3caf03;
+}
+
.threadImage{
margin: 6px;
max-width: 500px;
@@ -43,9 +55,9 @@
}
.threadImage img:hover{
- transform: scale(3);
- /*max-width:500px;
- width: 100%; */
+ /*transform: scale(3);*/
+ max-width:500px;
+ width: 100%;
}
.threadText{
diff --git a/ImageBoardServerApp/Shared/Components/PostForm.razor b/ImageBoardServerApp/Shared/Components/PostForm.razor
deleted file mode 100644
index bd52605..0000000
--- a/ImageBoardServerApp/Shared/Components/PostForm.razor
+++ /dev/null
@@ -1,139 +0,0 @@
-@using Radzen
-@using System.ComponentModel.DataAnnotations
-@using System.IO.Pipelines
-@using System.Net.Mime
-@using System.Reflection
-@using System.Runtime.CompilerServices
-@using ImageBoardServerApp.Data
-@using ImageBoardServerApp.Data.Repository
-
-@inject NavigationManager NavigationManager
-
-
-@if (opened)
-{
-
-
Post to /@board.Tag/ - @board.Topic
-
-
- OnChange(args, "username")) Class="w-100"/>
-
-
-
- OnChange(args, "title")) Class="w-100"/>
-
-
-
- OnChange(args, "Content")) Class="w-100"/>
-
-
-
-
-
-
-
-
-}
-
-
-@code {
-
- private bool opened = false;
-
- private string toggleText = "Open Post Formula";
-
- private void ToggleOpened()
- {
- opened = !opened;
- toggleText = opened ? "Close Post Formula" : "Open Post Formula";
- }
-
- [Parameter]
- [Required]
- public BoardData board { get; set; } = new BoardData();
-
- string postUsername = "Anonymous";
- string postTitle = "";
- string postContent = "";
-
- void OnChange(string value, string name)
- {
- switch (name)
- {
- case "title":
- postTitle = value;
- break;
- case "username":
- postUsername = value;
- break;
- case "content":
- postContent = value;
- break;
- default:
- Console.WriteLine("not found.");
- break;
- }
- Console.WriteLine($"Smth changed!: {value}");
- }
-
- private async Task SingleUpload(InputFileChangeEventArgs e)
- {
- MemoryStream ms = new MemoryStream();
- await e.File.OpenReadStream().CopyToAsync(ms);
- var bytes = ms.ToArray();
- image = bytes;
- Console.WriteLine("File has been selected!");
- ms.Close();
- }
-
- private Byte[] image;
-
- private async Task onPostClick()
- {
- var userToCreate = new UserData
- {
- Ipv4Address = "192.168.178.101",
- Banned = false,
- lastActionTimeStamp = DateTime.Now.Millisecond
- };
- int userID = await UsersRepository.createUserAsync(userToCreate);
-
- //TODO Add check if data is image
-
-
- var imageToUpload = new ImageData
- {
- Board = board.Tag,
- Image = image
- };
- int imageID = await ImagesRepository.createImageAsync(imageToUpload);
- var postToPost = new PostData
- {
- UserID = userID,
- ImageID = imageID,
- Username = postUsername,
- Title = postTitle,
- Content = postContent,
- Interactions = "",
- CreatedAt = DateTimeOffset.Now.ToUnixTimeMilliseconds(),
- Board = board.Tag
- };
- int postId = await PostsRepository.createPostAsync(postToPost);
- if (postId != -1)
- {
- //Open post successfull
- NavigationManager.NavigateTo("/SuccessfulPost");
- Console.WriteLine("Post created");
- }
- else
- {
- //Open post unsucessfull
- NavigationManager.NavigateTo("/UnSuccessfulPost");
- Console.WriteLine("Shit sucks and did not work.");
- }
- }
-}
\ No newline at end of file
diff --git a/ImageBoardServerApp/Shared/Components/Reports.razor b/ImageBoardServerApp/Shared/Components/Reports.razor
new file mode 100644
index 0000000..0fe0732
--- /dev/null
+++ b/ImageBoardServerApp/Shared/Components/Reports.razor
@@ -0,0 +1,5 @@
+
Reports
+
+@code {
+
+}
\ No newline at end of file
diff --git a/ImageBoardServerApp/Shared/MainLayout.razor b/ImageBoardServerApp/Shared/MainLayout.razor
index 63130fc..141e9c6 100644
--- a/ImageBoardServerApp/Shared/MainLayout.razor
+++ b/ImageBoardServerApp/Shared/MainLayout.razor
@@ -1,4 +1,7 @@
@inherits LayoutComponentBase
+@using ImageBoardServerApp.Auth
+@inject AuthenticationStateProvider authStateProvider
+@inject NavigationManager navManager
BulletBoard
@@ -8,13 +11,46 @@