Merge pull request #125 from mateuszskoczek/features/person_searching
Features/person searching
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
AdditionalTextSource="@(data => data.Name)"
|
AdditionalTextSource="@(data => data.Name)"
|
||||||
GetRolesAction="@(MediaWebAPIService.GetMediaAllActorRoles)"
|
GetRolesAction="@(MediaWebAPIService.GetMediaAllActorRoles)"
|
||||||
GetGlobalRatingAction="@((id, action) => RolesWebAPIService.GetActorRoleRating(id, action))"
|
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)"
|
PutRatingAction="(id, request) => RolesWebAPIService.PutActorRoleRating(id, request)"
|
||||||
DeleteRatingAction="(id) => RolesWebAPIService.DeleteActorRoleRating(id)"/>
|
DeleteRatingAction="(id) => RolesWebAPIService.DeleteActorRoleRating(id)"/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ public partial class ActorRolesPanelComponent : ComponentBase
|
|||||||
|
|
||||||
[Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!;
|
[Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!;
|
||||||
[Inject] private IRolesWebAPIService RolesWebAPIService { get; set; } = default!;
|
[Inject] private IRolesWebAPIService RolesWebAPIService { get; set; } = default!;
|
||||||
[Inject] private IAuthenticationService AuthenticationService { get; set; } = default!;
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -23,23 +22,4 @@ public partial class ActorRolesPanelComponent : ComponentBase
|
|||||||
[Parameter] public required long Id { get; set; }
|
[Parameter] public required long Id { get; set; }
|
||||||
|
|
||||||
#endregion
|
#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)"
|
Query="@(_query)"
|
||||||
GetRolesAction="MediaWebAPIService.GetMediaAllCreatorRoles"
|
GetRolesAction="MediaWebAPIService.GetMediaAllCreatorRoles"
|
||||||
GetGlobalRatingAction="@((id, action) => RolesWebAPIService.GetCreatorRoleRating(id, action))"
|
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)"
|
PutRatingAction="(id, request) => RolesWebAPIService.PutActorRoleRating(id, request)"
|
||||||
DeleteRatingAction="(id) => RolesWebAPIService.DeleteActorRoleRating(id)"/>
|
DeleteRatingAction="(id) => RolesWebAPIService.DeleteActorRoleRating(id)"/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
<div class="vstack">
|
<div class="vstack">
|
||||||
<span id="ratingNameText">Your rating:</span>
|
<span id="ratingNameText">Your rating:</span>
|
||||||
<div class="d-inline-flex align-items-center h-100">
|
<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)"/>
|
<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 TRole Role { get; set; }
|
||||||
[Parameter] public required Func<Guid, Action<RatingResponse>, Task> GetGlobalRatingAction { 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, RatingRequest, Task> PutRatingAction { get; set; }
|
||||||
[Parameter] public required Func<Guid, Task> DeleteRatingAction { 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
|
#region FIELDS
|
||||||
|
|
||||||
private bool _authenticated;
|
private User? _user;
|
||||||
private PersonResponse? _person;
|
private PersonResponse? _person;
|
||||||
private Picture? _picture;
|
private Picture? _picture;
|
||||||
private RatingResponse? _globalRating;
|
private RatingResponse? _globalRating;
|
||||||
@@ -50,18 +50,31 @@ public partial class RoleComponent<TRole> : ComponentBase where TRole : IRoleRes
|
|||||||
{
|
{
|
||||||
if (firstRender)
|
if (firstRender)
|
||||||
{
|
{
|
||||||
|
List<Task> step1Tasks = new List<Task>();
|
||||||
List<Task> endTasks = new List<Task>();
|
List<Task> endTasks = new List<Task>();
|
||||||
|
|
||||||
// STEP 0
|
// STEP 0
|
||||||
|
step1Tasks.AddRange(
|
||||||
|
[
|
||||||
|
Task.Run(async () => _user = await AuthenticationService.GetUserAsync()),
|
||||||
|
]);
|
||||||
endTasks.AddRange(
|
endTasks.AddRange(
|
||||||
[
|
[
|
||||||
Task.Run(async () => _authenticated = await AuthenticationService.GetAuthenticationStatusAsync()),
|
|
||||||
PersonsWebAPIService.GetPersonPhoto(Role.PersonId, data => _picture = data),
|
PersonsWebAPIService.GetPersonPhoto(Role.PersonId, data => _picture = data),
|
||||||
PersonsWebAPIService.GetPerson(Role.PersonId, data => _person = data),
|
PersonsWebAPIService.GetPerson(Role.PersonId, data => _person = data),
|
||||||
GetGlobalRatingAction(Role.Id, data => _globalRating = data),
|
GetGlobalRatingAction(Role.Id, data => _globalRating = data)
|
||||||
GetUserRatingAction(Role.Id, data => _yourRating = data, () => _yourRating = 0)
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// STEP 1
|
||||||
|
await Task.WhenAll(step1Tasks);
|
||||||
|
if (_user is not null)
|
||||||
|
{
|
||||||
|
endTasks.AddRange(
|
||||||
|
[
|
||||||
|
GetUserRatingAction(Role.Id, _user.Id, data => _yourRating = data, () => _yourRating = 0)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
// END
|
// END
|
||||||
await Task.WhenAll(endTasks);
|
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 required long Id { get; set; }
|
||||||
[Parameter] public TQuery Query { get; set; } = Activator.CreateInstance<TQuery>();
|
[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<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<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, RatingRequest, Task> PutRatingAction { get; set; }
|
||||||
[Parameter] public required Func<Guid, Task> DeleteRatingAction { get; set; }
|
[Parameter] public required Func<Guid, Task> DeleteRatingAction { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
@using WatchIt.Common.Model.Movies
|
@using WatchIt.Common.Model.Movies
|
||||||
|
@using WatchIt.Common.Model.Persons
|
||||||
@using WatchIt.Common.Model.Series
|
@using WatchIt.Common.Model.Series
|
||||||
@using WatchIt.Common.Query
|
|
||||||
@using WatchIt.Website.Components.Pages.SearchPage.Panels
|
@using WatchIt.Website.Components.Pages.SearchPage.Panels
|
||||||
@using WatchIt.Website.Services.WebAPI.Movies
|
|
||||||
|
|
||||||
@layout MainLayout
|
@layout MainLayout
|
||||||
|
|
||||||
@@ -12,68 +11,44 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="container-grid">
|
<div class="vstack gap-default">
|
||||||
@if (_loaded)
|
<div class="rounded-3 panel panel-regular p-3">
|
||||||
{
|
<div class="d-flex justify-content-center">
|
||||||
if (string.IsNullOrWhiteSpace(_error))
|
<h3 class="m-0">
|
||||||
{
|
<strong>Search results for phrase:</strong> "@(DecodedQuery)"
|
||||||
<div class="row">
|
</h3>
|
||||||
<div class="col">
|
|
||||||
<div class="rounded-3 panel panel-regular p-3">
|
|
||||||
<div class="d-flex justify-content-center">
|
|
||||||
<h3 class="m-0">
|
|
||||||
<strong>Search results for phrase:</strong> "@(DecodedQuery)"
|
|
||||||
</h3>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mt-3">
|
|
||||||
<div class="col">
|
|
||||||
<SearchResultPanelComponent TItem="MovieResponse"
|
|
||||||
TQuery="MovieQueryParameters"
|
|
||||||
Title="Movies"
|
|
||||||
UrlIdTemplate="/media/{0}"
|
|
||||||
IdSource="@(item => item.Id)"
|
|
||||||
NameSource="@(item => item.Title)"
|
|
||||||
AdditionalNameInfoSource="@(item => item.ReleaseDate.HasValue ? $" ({item.ReleaseDate.Value.Year})" : null)"
|
|
||||||
RatingSource="@(item => item.Rating)"
|
|
||||||
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"
|
|
||||||
UrlIdTemplate="/media/{0}"
|
|
||||||
IdSource="@(item => item.Id)"
|
|
||||||
NameSource="@(item => item.Title)"
|
|
||||||
AdditionalNameInfoSource="@(item => item.ReleaseDate.HasValue ? $" ({item.ReleaseDate.Value.Year})" : null)"
|
|
||||||
RatingSource="@(item => item.Rating)"
|
|
||||||
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>
|
</div>
|
||||||
}
|
</div>
|
||||||
|
<SearchResultPanelComponent TItem="MovieResponse"
|
||||||
|
TQuery="MovieQueryParameters"
|
||||||
|
Title="Movies"
|
||||||
|
UrlIdTemplate="/media/{0}"
|
||||||
|
IdSource="@(item => item.Id)"
|
||||||
|
NameSource="@(item => item.Title)"
|
||||||
|
AdditionalNameInfoSource="@(item => item.ReleaseDate.HasValue ? $" ({item.ReleaseDate.Value.Year})" : null)"
|
||||||
|
RatingSource="@(item => item.Rating)"
|
||||||
|
Query="@(new MovieQueryParameters { Title = DecodedQuery, OrderBy = "rating.count" })"
|
||||||
|
ItemDownloadingTask="@(MoviesWebAPIService.GetAllMovies)"
|
||||||
|
PictureDownloadingTask="@((id, action) => MediaWebAPIService.GetMediaPoster(id, action))"/>
|
||||||
|
<SearchResultPanelComponent TItem="SeriesResponse"
|
||||||
|
TQuery="SeriesQueryParameters"
|
||||||
|
Title="TV series"
|
||||||
|
UrlIdTemplate="/media/{0}"
|
||||||
|
IdSource="@(item => item.Id)"
|
||||||
|
NameSource="@(item => item.Title)"
|
||||||
|
AdditionalNameInfoSource="@(item => item.ReleaseDate.HasValue ? $" ({item.ReleaseDate.Value.Year})" : null)"
|
||||||
|
RatingSource="@(item => item.Rating)"
|
||||||
|
Query="@(new SeriesQueryParameters { Title = DecodedQuery, OrderBy = "rating.count" })"
|
||||||
|
ItemDownloadingTask="@(SeriesWebAPIService.GetAllSeries)"
|
||||||
|
PictureDownloadingTask="@((id, action) => MediaWebAPIService.GetMediaPoster(id, action))"/>
|
||||||
|
<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>
|
</div>
|
||||||
@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Components;
|
|||||||
using WatchIt.Website.Layout;
|
using WatchIt.Website.Layout;
|
||||||
using WatchIt.Website.Services.WebAPI.Media;
|
using WatchIt.Website.Services.WebAPI.Media;
|
||||||
using WatchIt.Website.Services.WebAPI.Movies;
|
using WatchIt.Website.Services.WebAPI.Movies;
|
||||||
|
using WatchIt.Website.Services.WebAPI.Persons;
|
||||||
using WatchIt.Website.Services.WebAPI.Series;
|
using WatchIt.Website.Services.WebAPI.Series;
|
||||||
|
|
||||||
namespace WatchIt.Website.Pages;
|
namespace WatchIt.Website.Pages;
|
||||||
@@ -14,15 +15,7 @@ public partial class SearchPage : ComponentBase
|
|||||||
[Inject] private IMoviesWebAPIService MoviesWebAPIService { get; set; } = default!;
|
[Inject] private IMoviesWebAPIService MoviesWebAPIService { get; set; } = default!;
|
||||||
[Inject] private ISeriesWebAPIService SeriesWebAPIService { get; set; } = default!;
|
[Inject] private ISeriesWebAPIService SeriesWebAPIService { get; set; } = default!;
|
||||||
[Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!;
|
[Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!;
|
||||||
|
[Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!;
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region FIELDS
|
|
||||||
|
|
||||||
private bool _loaded;
|
|
||||||
private string? _error;
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -43,19 +36,4 @@ public partial class SearchPage : ComponentBase
|
|||||||
public string DecodedQuery => WebUtility.UrlDecode(Query);
|
public string DecodedQuery => WebUtility.UrlDecode(Query);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region PRIVATE METHODS
|
|
||||||
|
|
||||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
||||||
{
|
|
||||||
if (firstRender)
|
|
||||||
{
|
|
||||||
_loaded = true;
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user