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.Schema;
|
||||
using System.Net;
|
||||
|
||||
namespace ImageBoardServerApp.Data;
|
||||
|
||||
|
@ -34,4 +33,6 @@ public class UserData
|
|||
public List<ReportData> SubmittedReports { get; set; }
|
||||
|
||||
public List<ReportData> RecivedReports { get; set; }
|
||||
|
||||
public string LastUsedName { get; set; }
|
||||
}
|
|
@ -43,7 +43,8 @@
|
|||
Email = Email,
|
||||
Password = BCrypt.Net.BCrypt.HashPassword(Password),
|
||||
Role = "User",
|
||||
TimeBanned = -1
|
||||
TimeBanned = -1,
|
||||
LastUsedName = "Anonymous"
|
||||
};
|
||||
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 System.ComponentModel.DataAnnotations
|
||||
@inject NavigationManager navigationManager;
|
||||
|
||||
<img class="banner" src="img/static/banner/@board.Tag ban.png" alt="No Banner found"/>
|
||||
<PageTitle>/@board.Tag/ - @board.Topic - BulletBoard</PageTitle>
|
||||
|
||||
|
@ -49,7 +51,14 @@
|
|||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
posts = await TheManager.getPostList(board.Tag);
|
||||
try
|
||||
{
|
||||
posts = await TheManager.getPostList(board.Tag);
|
||||
}
|
||||
catch
|
||||
{
|
||||
navigationManager.NavigateTo("/sys/dead");
|
||||
}
|
||||
}
|
||||
|
||||
[Parameter]
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
@using System.ComponentModel.DataAnnotations
|
||||
@using ImageBoardServerApp.Auth
|
||||
@using ImageBoardServerApp.Data.Repository
|
||||
|
||||
@inject NavigationManager navigationManager
|
||||
@inject IWebHostEnvironment env
|
||||
@inject AuthenticationStateProvider authStateProvider
|
||||
|
@ -56,9 +55,25 @@
|
|||
[Required]
|
||||
public PostData post { get; set; }
|
||||
|
||||
string postUsername { get; set; } = "Anonymous";
|
||||
string postUsername { 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 async Task SingleUpload(InputFileChangeEventArgs e)
|
||||
|
@ -96,6 +111,11 @@
|
|||
return;
|
||||
}
|
||||
foundusr.lastActionTimeStamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||
if (postUsername == null || postUsername == "")
|
||||
{
|
||||
postUsername = "Anonymous";
|
||||
}
|
||||
foundusr.LastUsedName = postUsername;
|
||||
await UsersRepository.updateUserAsync(foundusr);
|
||||
|
||||
PostData updatedPost = await PostsRepository.getPostByIdAsync(post.PostID);
|
||||
|
@ -115,10 +135,6 @@
|
|||
}
|
||||
|
||||
bool hasImage = selectedFile != null;
|
||||
if (postUsername == null || postUsername == "")
|
||||
{
|
||||
postUsername = "Anonymous";
|
||||
}
|
||||
int thisGET = b.NumberOfGETs + 1;
|
||||
b.NumberOfGETs++;
|
||||
await BoardsRepository.updateBoardAsync(b);
|
||||
|
@ -133,7 +149,6 @@
|
|||
stream.Close();
|
||||
fs.Close();
|
||||
|
||||
|
||||
var imageToUpload = new ImageData
|
||||
{
|
||||
Board = post.Board,
|
||||
|
|
|
@ -60,10 +60,26 @@
|
|||
[Required]
|
||||
public BoardData board { get; set; } = new BoardData();
|
||||
|
||||
string postUsername { get; set; } = "Anonymous";
|
||||
string postUsername { get; set; }
|
||||
string postTitle { 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;
|
||||
|
||||
|
@ -79,7 +95,6 @@
|
|||
|
||||
private async Task onPostClick()
|
||||
{
|
||||
|
||||
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
|
||||
var user = await cauthStateProvder.GetAuthenticationStateAsync();
|
||||
var usr = user.User;
|
||||
|
@ -113,6 +128,11 @@
|
|||
}
|
||||
|
||||
foundusr.lastActionTimeStamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||
if (postUsername == null || postUsername == "")
|
||||
{
|
||||
postUsername = "Anonymous";
|
||||
}
|
||||
foundusr.LastUsedName = postUsername;
|
||||
await UsersRepository.updateUserAsync(foundusr);
|
||||
|
||||
|
||||
|
@ -139,10 +159,6 @@
|
|||
ImageLocation = $"/img/dynamic/op/{@board.Tag}/{@file}"
|
||||
};
|
||||
int imageID = await ImagesRepository.createImageAsync(imageToUpload);
|
||||
if (postUsername == null || postUsername == "")
|
||||
{
|
||||
postUsername = "Anonymous";
|
||||
}
|
||||
|
||||
int thisGET = b.NumberOfGETs + 1;
|
||||
b.NumberOfGETs++;
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background-color: #181223;
|
||||
}
|
||||
|
||||
main {
|
||||
flex: 1;
|
||||
background-color: #282a36;
|
||||
background-color: #181223;
|
||||
color: #f8f8f2;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
|
|
|
@ -24,6 +24,7 @@ a, .btn-link {
|
|||
|
||||
.content {
|
||||
padding-top: 1.1rem;
|
||||
background-color: #181223;
|
||||
}
|
||||
|
||||
.valid.modified:not([type=checkbox]) {
|
||||
|
|
Loading…
Reference in a new issue