feat: the page now saves the last used username, changed the bg color of the main pages
Signed-off-by: limited_dev <loginakkisativ@gmail.com>
This commit is contained in:
parent
3a6ffaec46
commit
3c3bf898ca
8 changed files with 61 additions and 77 deletions
|
@ -1,6 +1,5 @@
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Net;
|
|
||||||
|
|
||||||
namespace ImageBoardServerApp.Data;
|
namespace ImageBoardServerApp.Data;
|
||||||
|
|
||||||
|
@ -34,4 +33,6 @@ public class UserData
|
||||||
public List<ReportData> SubmittedReports { get; set; }
|
public List<ReportData> SubmittedReports { get; set; }
|
||||||
|
|
||||||
public List<ReportData> RecivedReports { get; set; }
|
public List<ReportData> RecivedReports { get; set; }
|
||||||
|
|
||||||
|
public string LastUsedName { get; set; }
|
||||||
}
|
}
|
|
@ -43,7 +43,8 @@
|
||||||
Email = Email,
|
Email = Email,
|
||||||
Password = BCrypt.Net.BCrypt.HashPassword(Password),
|
Password = BCrypt.Net.BCrypt.HashPassword(Password),
|
||||||
Role = "User",
|
Role = "User",
|
||||||
TimeBanned = -1
|
TimeBanned = -1,
|
||||||
|
LastUsedName = "Anonymous"
|
||||||
};
|
};
|
||||||
if (await UsersRepository.getUserByEmailAsync(Email) != null)
|
if (await UsersRepository.getUserByEmailAsync(Email) != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,60 +0,0 @@
|
||||||
@page "/fetchdata"
|
|
||||||
@inject HttpClient Http
|
|
||||||
|
|
||||||
<PageTitle>Weather forecast</PageTitle>
|
|
||||||
|
|
||||||
<h1>Weather forecast</h1>
|
|
||||||
|
|
||||||
<p>This component demonstrates fetching data from the server.</p>
|
|
||||||
|
|
||||||
@if (forecasts == null)
|
|
||||||
{
|
|
||||||
<p>
|
|
||||||
<em>Loading...</em>
|
|
||||||
</p>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<table class="table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Date</th>
|
|
||||||
<th>Temp. (C)</th>
|
|
||||||
<th>Temp. (F)</th>
|
|
||||||
<th>Summary</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
@foreach (var forecast in forecasts)
|
|
||||||
{
|
|
||||||
<tr>
|
|
||||||
<td>@forecast.Date.ToShortDateString()</td>
|
|
||||||
<td>@forecast.TemperatureC</td>
|
|
||||||
<td>@forecast.TemperatureF</td>
|
|
||||||
<td>@forecast.Summary</td>
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
}
|
|
||||||
|
|
||||||
@code {
|
|
||||||
private WeatherForecast[]? forecasts;
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
|
||||||
{
|
|
||||||
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json");
|
|
||||||
}
|
|
||||||
|
|
||||||
public class WeatherForecast
|
|
||||||
{
|
|
||||||
public DateTime Date { get; set; }
|
|
||||||
|
|
||||||
public int TemperatureC { get; set; }
|
|
||||||
|
|
||||||
public string? Summary { get; set; }
|
|
||||||
|
|
||||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,5 +1,7 @@
|
||||||
@using ImageBoardServerApp.Util
|
@using ImageBoardServerApp.Util
|
||||||
@using System.ComponentModel.DataAnnotations
|
@using System.ComponentModel.DataAnnotations
|
||||||
|
@inject NavigationManager navigationManager;
|
||||||
|
|
||||||
<img class="banner" src="img/static/banner/@board.Tag ban.png" alt="No Banner found"/>
|
<img class="banner" src="img/static/banner/@board.Tag ban.png" alt="No Banner found"/>
|
||||||
<PageTitle>/@board.Tag/ - @board.Topic - BulletBoard</PageTitle>
|
<PageTitle>/@board.Tag/ - @board.Topic - BulletBoard</PageTitle>
|
||||||
|
|
||||||
|
@ -48,9 +50,16 @@
|
||||||
private List<PostData> posts;
|
private List<PostData> posts;
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
posts = await TheManager.getPostList(board.Tag);
|
posts = await TheManager.getPostList(board.Tag);
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
navigationManager.NavigateTo("/sys/dead");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
[Required]
|
[Required]
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
@using System.ComponentModel.DataAnnotations
|
@using System.ComponentModel.DataAnnotations
|
||||||
@using ImageBoardServerApp.Auth
|
@using ImageBoardServerApp.Auth
|
||||||
@using ImageBoardServerApp.Data.Repository
|
@using ImageBoardServerApp.Data.Repository
|
||||||
|
|
||||||
@inject NavigationManager navigationManager
|
@inject NavigationManager navigationManager
|
||||||
@inject IWebHostEnvironment env
|
@inject IWebHostEnvironment env
|
||||||
@inject AuthenticationStateProvider authStateProvider
|
@inject AuthenticationStateProvider authStateProvider
|
||||||
|
@ -56,9 +55,25 @@
|
||||||
[Required]
|
[Required]
|
||||||
public PostData post { get; set; }
|
public PostData post { get; set; }
|
||||||
|
|
||||||
string postUsername { get; set; } = "Anonymous";
|
string postUsername { get; set; }
|
||||||
string postContent { get; set; } = "";
|
string postContent { get; set; } = "";
|
||||||
|
|
||||||
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
|
||||||
|
var user = await cauthStateProvder.GetAuthenticationStateAsync();
|
||||||
|
var usr = user.User;
|
||||||
|
UserData foundusr = await UsersRepository.getUserByEmailAsync(usr.Identity.Name);
|
||||||
|
if (foundusr == null)
|
||||||
|
{
|
||||||
|
hasErr = true;
|
||||||
|
postErr = "You are not logged in.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
postUsername = foundusr.LastUsedName;
|
||||||
|
await base.OnParametersSetAsync();
|
||||||
|
}
|
||||||
|
|
||||||
private IBrowserFile selectedFile;
|
private IBrowserFile selectedFile;
|
||||||
|
|
||||||
private async Task SingleUpload(InputFileChangeEventArgs e)
|
private async Task SingleUpload(InputFileChangeEventArgs e)
|
||||||
|
@ -96,6 +111,11 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
foundusr.lastActionTimeStamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
foundusr.lastActionTimeStamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||||
|
if (postUsername == null || postUsername == "")
|
||||||
|
{
|
||||||
|
postUsername = "Anonymous";
|
||||||
|
}
|
||||||
|
foundusr.LastUsedName = postUsername;
|
||||||
await UsersRepository.updateUserAsync(foundusr);
|
await UsersRepository.updateUserAsync(foundusr);
|
||||||
|
|
||||||
PostData updatedPost = await PostsRepository.getPostByIdAsync(post.PostID);
|
PostData updatedPost = await PostsRepository.getPostByIdAsync(post.PostID);
|
||||||
|
@ -115,10 +135,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasImage = selectedFile != null;
|
bool hasImage = selectedFile != null;
|
||||||
if (postUsername == null || postUsername == "")
|
|
||||||
{
|
|
||||||
postUsername = "Anonymous";
|
|
||||||
}
|
|
||||||
int thisGET = b.NumberOfGETs + 1;
|
int thisGET = b.NumberOfGETs + 1;
|
||||||
b.NumberOfGETs++;
|
b.NumberOfGETs++;
|
||||||
await BoardsRepository.updateBoardAsync(b);
|
await BoardsRepository.updateBoardAsync(b);
|
||||||
|
@ -133,7 +149,6 @@
|
||||||
stream.Close();
|
stream.Close();
|
||||||
fs.Close();
|
fs.Close();
|
||||||
|
|
||||||
|
|
||||||
var imageToUpload = new ImageData
|
var imageToUpload = new ImageData
|
||||||
{
|
{
|
||||||
Board = post.Board,
|
Board = post.Board,
|
||||||
|
|
|
@ -60,10 +60,26 @@
|
||||||
[Required]
|
[Required]
|
||||||
public BoardData board { get; set; } = new BoardData();
|
public BoardData board { get; set; } = new BoardData();
|
||||||
|
|
||||||
string postUsername { get; set; } = "Anonymous";
|
string postUsername { get; set; }
|
||||||
string postTitle { get; set; } = "";
|
string postTitle { get; set; } = "";
|
||||||
string postContent { get; set; } = "";
|
string postContent { get; set; } = "";
|
||||||
|
|
||||||
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
|
||||||
|
var user = await cauthStateProvder.GetAuthenticationStateAsync();
|
||||||
|
var usr = user.User;
|
||||||
|
UserData foundusr = await UsersRepository.getUserByEmailAsync(usr.Identity.Name);
|
||||||
|
if (foundusr == null)
|
||||||
|
{
|
||||||
|
hasErr = true;
|
||||||
|
postErr = "You are not logged in.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
postUsername = foundusr.LastUsedName;
|
||||||
|
await base.OnParametersSetAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private IBrowserFile selectedFile;
|
private IBrowserFile selectedFile;
|
||||||
|
|
||||||
|
@ -79,7 +95,6 @@
|
||||||
|
|
||||||
private async Task onPostClick()
|
private async Task onPostClick()
|
||||||
{
|
{
|
||||||
|
|
||||||
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
|
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
|
||||||
var user = await cauthStateProvder.GetAuthenticationStateAsync();
|
var user = await cauthStateProvder.GetAuthenticationStateAsync();
|
||||||
var usr = user.User;
|
var usr = user.User;
|
||||||
|
@ -113,6 +128,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
foundusr.lastActionTimeStamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
foundusr.lastActionTimeStamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||||
|
if (postUsername == null || postUsername == "")
|
||||||
|
{
|
||||||
|
postUsername = "Anonymous";
|
||||||
|
}
|
||||||
|
foundusr.LastUsedName = postUsername;
|
||||||
await UsersRepository.updateUserAsync(foundusr);
|
await UsersRepository.updateUserAsync(foundusr);
|
||||||
|
|
||||||
|
|
||||||
|
@ -139,10 +159,6 @@
|
||||||
ImageLocation = $"/img/dynamic/op/{@board.Tag}/{@file}"
|
ImageLocation = $"/img/dynamic/op/{@board.Tag}/{@file}"
|
||||||
};
|
};
|
||||||
int imageID = await ImagesRepository.createImageAsync(imageToUpload);
|
int imageID = await ImagesRepository.createImageAsync(imageToUpload);
|
||||||
if (postUsername == null || postUsername == "")
|
|
||||||
{
|
|
||||||
postUsername = "Anonymous";
|
|
||||||
}
|
|
||||||
|
|
||||||
int thisGET = b.NumberOfGETs + 1;
|
int thisGET = b.NumberOfGETs + 1;
|
||||||
b.NumberOfGETs++;
|
b.NumberOfGETs++;
|
||||||
|
|
|
@ -2,11 +2,12 @@
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
background-color: #181223;
|
||||||
}
|
}
|
||||||
|
|
||||||
main {
|
main {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
background-color: #282a36;
|
background-color: #181223;
|
||||||
color: #f8f8f2;
|
color: #f8f8f2;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|
|
@ -24,6 +24,7 @@ a, .btn-link {
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
padding-top: 1.1rem;
|
padding-top: 1.1rem;
|
||||||
|
background-color: #181223;
|
||||||
}
|
}
|
||||||
|
|
||||||
.valid.modified:not([type=checkbox]) {
|
.valid.modified:not([type=checkbox]) {
|
||||||
|
|
Loading…
Reference in a new issue