person searching added, bug fix
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
AdditionalTextSource="@(data => data.Name)"
|
||||
GetRolesAction="@(MediaWebAPIService.GetMediaAllActorRoles)"
|
||||
GetGlobalRatingAction="@((id, action) => RolesWebAPIService.GetActorRoleRating(id, action))"
|
||||
GetUserRatingAction="@(_user is not null ? (id, actionSuccess, actionNotFound) => RolesWebAPIService.GetActorRoleRatingByUser(id, _user.Id, actionSuccess, actionNotFound) : null)"
|
||||
GetUserRatingAction="@((id, userId, actionSuccess, actionNotFound) => RolesWebAPIService.GetActorRoleRatingByUser(id, userId, actionSuccess, actionNotFound))"
|
||||
PutRatingAction="(id, request) => RolesWebAPIService.PutActorRoleRating(id, request)"
|
||||
DeleteRatingAction="(id) => RolesWebAPIService.DeleteActorRoleRating(id)"/>
|
||||
</div>
|
||||
|
||||
@@ -11,7 +11,6 @@ public partial class ActorRolesPanelComponent : ComponentBase
|
||||
|
||||
[Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!;
|
||||
[Inject] private IRolesWebAPIService RolesWebAPIService { get; set; } = default!;
|
||||
[Inject] private IAuthenticationService AuthenticationService { get; set; } = default!;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -23,23 +22,4 @@ public partial class ActorRolesPanelComponent : ComponentBase
|
||||
[Parameter] public required long Id { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region FIELDS
|
||||
|
||||
private User? _user;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PRIVATE METHODS
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
_user = await AuthenticationService.GetUserAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -23,7 +23,7 @@
|
||||
Query="@(_query)"
|
||||
GetRolesAction="MediaWebAPIService.GetMediaAllCreatorRoles"
|
||||
GetGlobalRatingAction="@((id, action) => RolesWebAPIService.GetCreatorRoleRating(id, action))"
|
||||
GetUserRatingAction="@(_user is not null ? (id, actionSuccess, actionNotFound) => RolesWebAPIService.GetCreatorRoleRatingByUser(id, _user.Id, actionSuccess, actionNotFound) : null)"
|
||||
GetUserRatingAction="@((id, userId, actionSuccess, actionNotFound) => RolesWebAPIService.GetCreatorRoleRatingByUser(id, userId, actionSuccess, actionNotFound))"
|
||||
PutRatingAction="(id, request) => RolesWebAPIService.PutActorRoleRating(id, request)"
|
||||
DeleteRatingAction="(id) => RolesWebAPIService.DeleteActorRoleRating(id)"/>
|
||||
</div>
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
<div class="vstack">
|
||||
<span id="ratingNameText">Your rating:</span>
|
||||
<div class="d-inline-flex align-items-center h-100">
|
||||
@if (_authenticated)
|
||||
@if (_user is not null)
|
||||
{
|
||||
<Rating Color="Color.Light" MaxValue="10" @bind-SelectedValue="@(_yourRating)" @onclick="@(RatingChanged)"/>
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public partial class RoleComponent<TRole> : ComponentBase where TRole : IRoleRes
|
||||
|
||||
[Parameter] public required TRole Role { get; set; }
|
||||
[Parameter] public required Func<Guid, Action<RatingResponse>, Task> GetGlobalRatingAction { get; set; }
|
||||
[Parameter] public required Func<Guid, Action<short>, Action, Task> GetUserRatingAction { get; set; }
|
||||
[Parameter] public required Func<Guid, long, Action<short>, Action, Task> GetUserRatingAction { get; set; }
|
||||
[Parameter] public required Func<Guid, RatingRequest, Task> PutRatingAction { get; set; }
|
||||
[Parameter] public required Func<Guid, Task> DeleteRatingAction { get; set; }
|
||||
|
||||
@@ -33,7 +33,7 @@ public partial class RoleComponent<TRole> : ComponentBase where TRole : IRoleRes
|
||||
|
||||
#region FIELDS
|
||||
|
||||
private bool _authenticated;
|
||||
private User? _user;
|
||||
private PersonResponse? _person;
|
||||
private Picture? _picture;
|
||||
private RatingResponse? _globalRating;
|
||||
@@ -50,18 +50,31 @@ public partial class RoleComponent<TRole> : ComponentBase where TRole : IRoleRes
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
List<Task> step1Tasks = new List<Task>();
|
||||
List<Task> endTasks = new List<Task>();
|
||||
|
||||
// STEP 0
|
||||
step1Tasks.AddRange(
|
||||
[
|
||||
Task.Run(async () => _user = await AuthenticationService.GetUserAsync()),
|
||||
]);
|
||||
endTasks.AddRange(
|
||||
[
|
||||
Task.Run(async () => _authenticated = await AuthenticationService.GetAuthenticationStatusAsync()),
|
||||
PersonsWebAPIService.GetPersonPhoto(Role.PersonId, data => _picture = data),
|
||||
PersonsWebAPIService.GetPerson(Role.PersonId, data => _person = data),
|
||||
GetGlobalRatingAction(Role.Id, data => _globalRating = data),
|
||||
GetUserRatingAction(Role.Id, data => _yourRating = data, () => _yourRating = 0)
|
||||
GetGlobalRatingAction(Role.Id, data => _globalRating = data)
|
||||
]);
|
||||
|
||||
// STEP 1
|
||||
await Task.WhenAll(step1Tasks);
|
||||
if (_user is not null)
|
||||
{
|
||||
endTasks.AddRange(
|
||||
[
|
||||
GetUserRatingAction(Role.Id, _user.Id, data => _yourRating = data, () => _yourRating = 0)
|
||||
]);
|
||||
}
|
||||
|
||||
// END
|
||||
await Task.WhenAll(endTasks);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public partial class RoleListComponent<TRole, TQuery> : ComponentBase where TRol
|
||||
|
||||
|
||||
|
||||
#region PROPERTIES
|
||||
#region PARAMETERS
|
||||
|
||||
[Parameter] public required long Id { get; set; }
|
||||
[Parameter] public TQuery Query { get; set; } = Activator.CreateInstance<TQuery>();
|
||||
@@ -24,7 +24,7 @@ public partial class RoleListComponent<TRole, TQuery> : ComponentBase where TRol
|
||||
|
||||
[Parameter] public required Func<long, TQuery, Action<IEnumerable<TRole>>, Task> GetRolesAction { get; set; }
|
||||
[Parameter] public required Func<Guid, Action<RatingResponse>, Task> GetGlobalRatingAction { get; set; }
|
||||
[Parameter] public required Func<Guid, Action<short>, Action, Task> GetUserRatingAction { get; set; }
|
||||
[Parameter] public required Func<Guid, long, Action<short>, Action, Task> GetUserRatingAction { get; set; }
|
||||
[Parameter] public required Func<Guid, RatingRequest, Task> PutRatingAction { get; set; }
|
||||
[Parameter] public required Func<Guid, Task> DeleteRatingAction { get; set; }
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
@using WatchIt.Common.Model.Movies
|
||||
@using WatchIt.Common.Model.Persons
|
||||
@using WatchIt.Common.Model.Series
|
||||
@using WatchIt.Common.Query
|
||||
@using WatchIt.Website.Components.Pages.SearchPage.Panels
|
||||
@using WatchIt.Website.Services.WebAPI.Movies
|
||||
|
||||
@layout MainLayout
|
||||
|
||||
@@ -12,13 +11,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="container-grid">
|
||||
@if (_loaded)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_error))
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="vstack gap-default">
|
||||
<div class="rounded-3 panel panel-regular p-3">
|
||||
<div class="d-flex justify-content-center">
|
||||
<h3 class="m-0">
|
||||
@@ -26,10 +19,6 @@
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-3">
|
||||
<div class="col">
|
||||
<SearchResultPanelComponent TItem="MovieResponse"
|
||||
TQuery="MovieQueryParameters"
|
||||
Title="Movies"
|
||||
@@ -41,10 +30,6 @@
|
||||
Query="@(new MovieQueryParameters { Title = DecodedQuery, OrderBy = "rating.count" })"
|
||||
ItemDownloadingTask="@(MoviesWebAPIService.GetAllMovies)"
|
||||
PictureDownloadingTask="@((id, action) => MediaWebAPIService.GetMediaPoster(id, action))"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-3">
|
||||
<div class="col">
|
||||
<SearchResultPanelComponent TItem="SeriesResponse"
|
||||
TQuery="SeriesQueryParameters"
|
||||
Title="TV series"
|
||||
@@ -56,24 +41,14 @@
|
||||
Query="@(new SeriesQueryParameters { Title = DecodedQuery, OrderBy = "rating.count" })"
|
||||
ItemDownloadingTask="@(SeriesWebAPIService.GetAllSeries)"
|
||||
PictureDownloadingTask="@((id, action) => MediaWebAPIService.GetMediaPoster(id, action))"/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<ErrorPanelComponent ErrorMessage="@(_error)"/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<LoadingComponent/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
<SearchResultPanelComponent TItem="PersonResponse"
|
||||
TQuery="PersonQueryParameters"
|
||||
Title="People"
|
||||
UrlIdTemplate="/person/{0}"
|
||||
IdSource="@(item => item.Id)"
|
||||
NameSource="@(item => item.Name)"
|
||||
RatingSource="@(item => item.Rating)"
|
||||
Query="@(new PersonQueryParameters { Name = DecodedQuery, OrderBy = "rating.count" })"
|
||||
ItemDownloadingTask="@(PersonsWebAPIService.GetAllPersons)"
|
||||
PictureDownloadingTask="@((id, action) => PersonsWebAPIService.GetPersonPhoto(id, action))"/>
|
||||
</div>
|
||||
@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Components;
|
||||
using WatchIt.Website.Layout;
|
||||
using WatchIt.Website.Services.WebAPI.Media;
|
||||
using WatchIt.Website.Services.WebAPI.Movies;
|
||||
using WatchIt.Website.Services.WebAPI.Persons;
|
||||
using WatchIt.Website.Services.WebAPI.Series;
|
||||
|
||||
namespace WatchIt.Website.Pages;
|
||||
@@ -14,15 +15,7 @@ public partial class SearchPage : ComponentBase
|
||||
[Inject] private IMoviesWebAPIService MoviesWebAPIService { get; set; } = default!;
|
||||
[Inject] private ISeriesWebAPIService SeriesWebAPIService { get; set; } = default!;
|
||||
[Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region FIELDS
|
||||
|
||||
private bool _loaded;
|
||||
private string? _error;
|
||||
[Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -43,19 +36,4 @@ public partial class SearchPage : ComponentBase
|
||||
public string DecodedQuery => WebUtility.UrlDecode(Query);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PRIVATE METHODS
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
_loaded = true;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user