UserPage created
This commit is contained in:
@@ -20,6 +20,9 @@ public class AccountResponse : Account
|
|||||||
|
|
||||||
#region CONSTRUCTORS
|
#region CONSTRUCTORS
|
||||||
|
|
||||||
|
[JsonConstructor]
|
||||||
|
public AccountResponse() {}
|
||||||
|
|
||||||
[SetsRequiredMembers]
|
[SetsRequiredMembers]
|
||||||
public AccountResponse(Database.Model.Account.Account account)
|
public AccountResponse(Database.Model.Account.Account account)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<ProjectReference Include="..\..\..\WatchIt.Common\WatchIt.Common.Model\WatchIt.Common.Model.csproj" />
|
<ProjectReference Include="..\..\..\WatchIt.Common\WatchIt.Common.Model\WatchIt.Common.Model.csproj" />
|
||||||
<ProjectReference Include="..\..\..\WatchIt.Common\WatchIt.Common.Services\WatchIt.Common.Services.HttpClient\WatchIt.Common.Services.HttpClient.csproj" />
|
<ProjectReference Include="..\..\..\WatchIt.Common\WatchIt.Common.Services\WatchIt.Common.Services.HttpClient\WatchIt.Common.Services.HttpClient.csproj" />
|
||||||
<ProjectReference Include="..\WatchIt.Website.Services.Tokens\WatchIt.Website.Services.Tokens.csproj" />
|
<ProjectReference Include="..\WatchIt.Website.Services.Tokens\WatchIt.Website.Services.Tokens.csproj" />
|
||||||
<ProjectReference Include="..\WatchIt.Website.Services.Utility\WatchIt.Website.Services.Configuration\WatchIt.Website.Services.Configuration.csproj" />
|
<ProjectReference Include="..\WatchIt.Website.Services.Configuration\WatchIt.Website.Services.Configuration.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\..\WatchIt.Common\WatchIt.Common.Model\WatchIt.Common.Model.csproj" />
|
<ProjectReference Include="..\..\..\WatchIt.Common\WatchIt.Common.Model\WatchIt.Common.Model.csproj" />
|
||||||
<ProjectReference Include="..\WatchIt.Website.Services.Utility\WatchIt.Website.Services.Configuration\WatchIt.Website.Services.Configuration.csproj" />
|
<ProjectReference Include="..\WatchIt.Website.Services.Configuration\WatchIt.Website.Services.Configuration.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
|
namespace WatchIt.Website.Components.Pages.UserPage.Panels;
|
||||||
|
|
||||||
|
public partial class UserPageHeaderPanelComponent : ComponentBase
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -61,8 +61,10 @@
|
|||||||
</Button>
|
</Button>
|
||||||
<DropdownToggle Color="Color.Default" Split />
|
<DropdownToggle Color="Color.Default" Split />
|
||||||
<DropdownMenu >
|
<DropdownMenu >
|
||||||
|
<DropdownItem Clicked="@(() => NavigationManager.NavigateTo("/user"))">Your profile</DropdownItem>
|
||||||
@if (_user.IsAdmin)
|
@if (_user.IsAdmin)
|
||||||
{
|
{
|
||||||
|
<DropdownDivider/>
|
||||||
<DropdownItem Clicked="@(() => NavigationManager.NavigateTo("/admin"))">Administrator panel</DropdownItem>
|
<DropdownItem Clicked="@(() => NavigationManager.NavigateTo("/admin"))">Administrator panel</DropdownItem>
|
||||||
}
|
}
|
||||||
<DropdownDivider/>
|
<DropdownDivider/>
|
||||||
|
|||||||
@@ -1 +1,49 @@
|
|||||||
@page "/user/{id:long}"
|
@using System.Text
|
||||||
|
@using WatchIt.Website.Components.Pages.UserPage.Panels
|
||||||
|
|
||||||
|
@page "/user/{id:long?}"
|
||||||
|
|
||||||
|
@{
|
||||||
|
StringBuilder sb = new StringBuilder(" - WatchIt");
|
||||||
|
|
||||||
|
if (!_loaded) sb.Insert(0, "Loading...");
|
||||||
|
else if (_accountData is null) sb.Insert(0, "Error");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_owner) sb.Insert(0, "Your profile");
|
||||||
|
else sb.Insert(0, $"\"{_accountData.Username}\" profile");
|
||||||
|
}
|
||||||
|
|
||||||
|
<PageTitle>@(sb.ToString())</PageTitle>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="container-grid">
|
||||||
|
@if (!_loaded)
|
||||||
|
{
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<div class="m-5">
|
||||||
|
<LoadingComponent/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
else if (_accountData is null)
|
||||||
|
{
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<ErrorPanelComponent ErrorMessage="@($"User with ID {Id!.Value} was not found")"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<UserPageHeaderPanelComponent/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
@@ -1,7 +1,87 @@
|
|||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using WatchIt.Common.Model.Accounts;
|
||||||
|
using WatchIt.Website.Layout;
|
||||||
|
using WatchIt.Website.Services.Authentication;
|
||||||
|
using WatchIt.Website.Services.Client.Accounts;
|
||||||
|
|
||||||
namespace WatchIt.Website.Pages;
|
namespace WatchIt.Website.Pages;
|
||||||
|
|
||||||
public partial class UserPage : ComponentBase
|
public partial class UserPage : ComponentBase
|
||||||
{
|
{
|
||||||
|
#region SERVICES
|
||||||
|
|
||||||
|
[Inject] private NavigationManager NavigationManager { get; set; } = default!;
|
||||||
|
[Inject] private IAuthenticationService AuthenticationService { get; set; } = default!;
|
||||||
|
[Inject] private IAccountsClientService AccountsClientService { get; set; } = default!;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PARAMETERS
|
||||||
|
|
||||||
|
[Parameter] public long? Id { get; set; }
|
||||||
|
|
||||||
|
[CascadingParameter] public MainLayout Layout { get; set; } = default!;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region FIELDS
|
||||||
|
|
||||||
|
private bool _loaded;
|
||||||
|
private bool _redirection;
|
||||||
|
private bool _owner;
|
||||||
|
private AccountResponse? _accountData;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PRIVATE METHODS
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender)
|
||||||
|
{
|
||||||
|
List<Task> endTasks = new List<Task>();
|
||||||
|
|
||||||
|
// INIT
|
||||||
|
Layout.BackgroundPhoto = null;
|
||||||
|
|
||||||
|
// STEP 0
|
||||||
|
endTasks.AddRange(
|
||||||
|
[
|
||||||
|
GetUserData()
|
||||||
|
]);
|
||||||
|
|
||||||
|
// END
|
||||||
|
await Task.WhenAll(endTasks);
|
||||||
|
|
||||||
|
_loaded = !_redirection;
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task GetUserData()
|
||||||
|
{
|
||||||
|
User? user = await AuthenticationService.GetUserAsync();
|
||||||
|
if (!Id.HasValue)
|
||||||
|
{
|
||||||
|
if (user is null)
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo("/auth");
|
||||||
|
_redirection = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Id = user.Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
await AccountsClientService.GetAccountInfoById(Id.Value, data => _accountData = data);
|
||||||
|
_owner = Id.Value == user?.Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
<ProjectReference Include="..\..\WatchIt.Common\WatchIt.Common.Services\WatchIt.Common.Services.HttpClient\WatchIt.Common.Services.HttpClient.csproj" />
|
<ProjectReference Include="..\..\WatchIt.Common\WatchIt.Common.Services\WatchIt.Common.Services.HttpClient\WatchIt.Common.Services.HttpClient.csproj" />
|
||||||
<ProjectReference Include="..\..\WatchIt.WebAPI\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Utility\WatchIt.WebAPI.Services.Utility.Tokens\WatchIt.WebAPI.Services.Utility.Tokens.csproj" />
|
<ProjectReference Include="..\..\WatchIt.WebAPI\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Utility\WatchIt.WebAPI.Services.Utility.Tokens\WatchIt.WebAPI.Services.Utility.Tokens.csproj" />
|
||||||
<ProjectReference Include="..\WatchIt.Website.Services\WatchIt.Website.Services.Authentication\WatchIt.Website.Services.Authentication.csproj" />
|
<ProjectReference Include="..\WatchIt.Website.Services\WatchIt.Website.Services.Authentication\WatchIt.Website.Services.Authentication.csproj" />
|
||||||
<ProjectReference Include="..\WatchIt.Website.Services\WatchIt.Website.Services.Utility\WatchIt.Website.Services.Configuration\WatchIt.Website.Services.Configuration.csproj" />
|
<ProjectReference Include="..\WatchIt.Website.Services\WatchIt.Website.Services.Configuration\WatchIt.Website.Services.Configuration.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchIt.Common.Query", "Wat
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchIt.Common.Services.HttpClient", "WatchIt.Common\WatchIt.Common.Services\WatchIt.Common.Services.HttpClient\WatchIt.Common.Services.HttpClient.csproj", "{A4A75CCA-0DEE-4F1E-9816-60674CA807FA}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchIt.Common.Services.HttpClient", "WatchIt.Common\WatchIt.Common.Services\WatchIt.Common.Services.HttpClient\WatchIt.Common.Services.HttpClient.csproj", "{A4A75CCA-0DEE-4F1E-9816-60674CA807FA}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchIt.Website.Services.Configuration", "WatchIt.Website\WatchIt.Website.Services\WatchIt.Website.Services.Utility\WatchIt.Website.Services.Configuration\WatchIt.Website.Services.Configuration.csproj", "{0DBBE7EA-05FE-481F-8814-6FA0BC9E571F}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchIt.Website.Services.Configuration", "WatchIt.Website\WatchIt.Website.Services\WatchIt.Website.Services.Configuration\WatchIt.Website.Services.Configuration.csproj", "{0DBBE7EA-05FE-481F-8814-6FA0BC9E571F}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchIt.WebAPI.Services.Controllers.Media", "WatchIt.WebAPI\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Media\WatchIt.WebAPI.Services.Controllers.Media.csproj", "{3156AD7B-D6EC-4EB6-AEE8-4FBAF14C18E4}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchIt.WebAPI.Services.Controllers.Media", "WatchIt.WebAPI\WatchIt.WebAPI.Services\WatchIt.WebAPI.Services.Controllers\WatchIt.WebAPI.Services.Controllers.Media\WatchIt.WebAPI.Services.Controllers.Media.csproj", "{3156AD7B-D6EC-4EB6-AEE8-4FBAF14C18E4}"
|
||||||
EndProject
|
EndProject
|
||||||
|
|||||||
Reference in New Issue
Block a user