Refactoring, database structure changed

This commit is contained in:
2025-03-03 00:56:32 +01:00
Unverified
parent d3805ef3db
commit c603c41c0b
913 changed files with 21764 additions and 32775 deletions

View File

@@ -0,0 +1,36 @@
@using WatchIt.DTO.Models.Controllers.Accounts.Account
@using WatchIt.Website.Components.Subcomponents.Common
@inherits Component
<div class="vstack gap-default">
<div class="panel panel-section-header">
<h3 class="fw-bold m-0">@(Title)</h3>
</div>
@if (!_loaded)
{
<div class="panel">
<Loading Color="Loading.Colors.Light"/>
</div>
}
else if (!_items.Any())
{
<div class="panel">
<div class="d-flex justify-content-center">
No items
</div>
</div>
}
else
{
foreach (AccountResponse item in _items)
{
<div class="panel">
<VerticalListUserItem Item="item"
PictureSize="50"/>
</div>
}
}
</div>

View File

@@ -0,0 +1,38 @@
using Microsoft.AspNetCore.Components;
using WatchIt.DTO.Models.Controllers.Accounts.Account;
namespace WatchIt.Website.Components.Panels.Pages.UserPage;
public partial class FollowListPanel : Component
{
#region PARAMETERS
[Parameter] public required string Title { get; set; }
[Parameter] public required Func<Task<IEnumerable<AccountResponse>>> GetItemsMethod { get; set; }
#endregion
#region FIELDS
private bool _loaded;
private IEnumerable<AccountResponse> _items = [];
#endregion
#region PRIVATE METHODS
protected override async Task OnFirstRenderAsync()
{
_items = await GetItemsMethod();
_loaded = true;
StateHasChanged();
}
#endregion
}

View File

@@ -0,0 +1,56 @@
@using WatchIt.Website.Components.Subcomponents.Common
@inherits Component
<div id="base" class="vstack">
<AccountPicture Class="shadow position-absolute z-1 start-50 translate-middle" Item="@(Data)" Size="240"/>
<div class="panel z-0">
<div class="vstack gap-3">
<div id="space" class="container-grid"></div>
<div class="d-flex justify-content-center">
<h3 class="fw-bold m-0">@(Data.Username)</h3>
</div>
@if (!string.IsNullOrWhiteSpace(Data.Description))
{
<span class="text-center w-100 mb-2">
@(Data.Description)
</span>
}
<div class="d-flex flex-wrap justify-content-center metadata-pill-container">
<div class="metadata-pill"><strong>Email:</strong> @(Data.Email)</div>
@if (!string.IsNullOrWhiteSpace(Data.Gender?.Name))
{
<div class="metadata-pill"><strong>Gender:</strong> @(Data.Gender?.Name)</div>
}
<div class="metadata-pill"><strong>Joined:</strong> @(Data.JoinDate.LocalDateTime.ToShortDateString())</div>
<div class="metadata-pill"><strong>Last active:</strong> @(Data.ActiveDate.LocalDateTime.ToShortDateString())</div>
@if (Data.IsAdmin)
{
<div class="metadata-pill"><strong>Admin</strong></div>
}
@if (LoggedUserData is not null && Data.Id != LoggedUserData.Id)
{
<div role="button" class="metadata-pill @(!_followLoading ? "metadata-pill-hoverable" : string.Empty)" @onclick="@(Follow)">
@if (_followLoading)
{
<div class="spinner-border spinner-border-sm"></div>
}
else
{
if (Followers.Any(x => x.Id == LoggedUserData.Id))
{
<span><i class="fa fa-eye-slash" aria-hidden="true"></i> Unfollow</span>
}
else
{
<span><i class="fa fa-eye" aria-hidden="true"></i> Follow</span>
}
}
</div>
}
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,71 @@
using Microsoft.AspNetCore.Components;
using Refit;
using WatchIt.DTO.Models.Controllers.Accounts.Account;
using WatchIt.Website.Clients;
using WatchIt.Website.Services.Authentication;
namespace WatchIt.Website.Components.Panels.Pages.UserPage;
public partial class HeaderPanel : Component
{
#region SERVICES
[Inject] private IAuthenticationService AuthenticationService { get; set; } = default!;
[Inject] private IAccountsClient AccountsClient { get; set; } = default!;
#endregion
#region PARAMETERS
[Parameter] public required AccountResponse Data { get; set; }
[Parameter] public required List<AccountResponse> Followers { get; set; }
[Parameter] public AccountResponse? LoggedUserData { get; set; }
[Parameter] public Action<bool>? FollowingChanged { get; set; }
#endregion
#region FIELDS
private bool _followLoading;
#endregion
#region PRIVATE METHODS
private async Task Follow()
{
string token = await AuthenticationService.GetRawAccessTokenAsync() ?? string.Empty;
_followLoading = true;
IApiResponse response;
if (Followers.Any(x => x.Id == LoggedUserData!.Id))
{
response = await AccountsClient.DeleteAccountFollow(token, Data.Id);
if (response.IsSuccessful)
{
Followers.RemoveAll(x => x.Id == LoggedUserData!.Id);
FollowingChanged?.Invoke(false);
}
}
else
{
response = await AccountsClient.PostAccountFollow(token, Data.Id);
if (response.IsSuccessful)
{
Followers.Add(LoggedUserData);
FollowingChanged?.Invoke(true);
}
}
if (response.IsSuccessful)
{
_followLoading = false;
}
}
#endregion
}

View File

@@ -0,0 +1,9 @@
/* IDS */
#base {
margin-top: 120px;
}
#space {
height: 100px;
}