role rating in mediapage added
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
<link rel="stylesheet" href="css/panel.css?version=0.3.0.3"/>
|
<link rel="stylesheet" href="css/panel.css?version=0.3.0.3"/>
|
||||||
<link rel="stylesheet" href="css/main_button.css?version=0.3.0.0"/>
|
<link rel="stylesheet" href="css/main_button.css?version=0.3.0.0"/>
|
||||||
<link rel="stylesheet" href="css/gaps.css?version=0.3.0.1"/>
|
<link rel="stylesheet" href="css/gaps.css?version=0.3.0.1"/>
|
||||||
<link rel="stylesheet" href="WatchIt.Website.styles.css?version=0.2.0.13"/>
|
<link rel="stylesheet" href="WatchIt.Website.styles.css?version=0.3.0.16"/>
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||||
|
|
||||||
<!-- BOOTSTRAP -->
|
<!-- BOOTSTRAP -->
|
||||||
|
|||||||
@@ -8,7 +8,11 @@
|
|||||||
<RoleListComponent Id="@(Id)"
|
<RoleListComponent Id="@(Id)"
|
||||||
TRole="WatchIt.Common.Model.Roles.ActorRoleResponse"
|
TRole="WatchIt.Common.Model.Roles.ActorRoleResponse"
|
||||||
TQuery="WatchIt.Common.Model.Roles.ActorRoleMediaQueryParameters"
|
TQuery="WatchIt.Common.Model.Roles.ActorRoleMediaQueryParameters"
|
||||||
GetRolesAction="MediaWebAPIService.GetMediaAllActorRoles"
|
AdditionalTextSource="@(data => data.Name)"
|
||||||
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)"
|
||||||
|
PutRatingAction="(id, request) => RolesWebAPIService.PutActorRoleRating(id, request)"
|
||||||
|
DeleteRatingAction="(id) => RolesWebAPIService.DeleteActorRoleRating(id)"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using WatchIt.Website.Services.Utility.Authentication;
|
||||||
using WatchIt.Website.Services.WebAPI.Media;
|
using WatchIt.Website.Services.WebAPI.Media;
|
||||||
|
using WatchIt.Website.Services.WebAPI.Roles;
|
||||||
|
|
||||||
namespace WatchIt.Website.Components.Pages.MediaPage.Panels;
|
namespace WatchIt.Website.Components.Pages.MediaPage.Panels;
|
||||||
|
|
||||||
@@ -8,6 +10,8 @@ public partial class ActorRolesPanelComponent : ComponentBase
|
|||||||
#region SERVICES
|
#region SERVICES
|
||||||
|
|
||||||
[Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!;
|
[Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!;
|
||||||
|
[Inject] private IRolesWebAPIService RolesWebAPIService { get; set; } = default!;
|
||||||
|
[Inject] private IAuthenticationService AuthenticationService { get; set; } = default!;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -19,4 +23,23 @@ 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
|
||||||
}
|
}
|
||||||
@@ -20,8 +20,12 @@
|
|||||||
Id="@(Id)"
|
Id="@(Id)"
|
||||||
TRole="CreatorRoleResponse"
|
TRole="CreatorRoleResponse"
|
||||||
TQuery="CreatorRoleMediaQueryParameters"
|
TQuery="CreatorRoleMediaQueryParameters"
|
||||||
|
Query="@(_query)"
|
||||||
GetRolesAction="MediaWebAPIService.GetMediaAllCreatorRoles"
|
GetRolesAction="MediaWebAPIService.GetMediaAllCreatorRoles"
|
||||||
Query="@(_query)"/>
|
GetGlobalRatingAction="@((id, action) => RolesWebAPIService.GetCreatorRoleRating(id, action))"
|
||||||
|
GetUserRatingAction="@(_user is not null ? (id, actionSuccess, actionNotFound) => RolesWebAPIService.GetCreatorRoleRatingByUser(id, _user.Id, actionSuccess, actionNotFound) : null)"
|
||||||
|
PutRatingAction="(id, request) => RolesWebAPIService.PutActorRoleRating(id, request)"
|
||||||
|
DeleteRatingAction="(id) => RolesWebAPIService.DeleteActorRoleRating(id)"/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using WatchIt.Common.Model.Roles;
|
using WatchIt.Common.Model.Roles;
|
||||||
using WatchIt.Website.Components.Pages.MediaPage.Subcomponents;
|
using WatchIt.Website.Components.Pages.MediaPage.Subcomponents;
|
||||||
|
using WatchIt.Website.Services.Utility.Authentication;
|
||||||
using WatchIt.Website.Services.WebAPI.Media;
|
using WatchIt.Website.Services.WebAPI.Media;
|
||||||
using WatchIt.Website.Services.WebAPI.Roles;
|
using WatchIt.Website.Services.WebAPI.Roles;
|
||||||
|
|
||||||
@@ -12,6 +13,7 @@ public partial class CreatorRolesPanelComponent : 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
|
||||||
|
|
||||||
@@ -27,6 +29,8 @@ public partial class CreatorRolesPanelComponent : ComponentBase
|
|||||||
|
|
||||||
|
|
||||||
#region FIELDS
|
#region FIELDS
|
||||||
|
|
||||||
|
private User? _user;
|
||||||
|
|
||||||
private RoleListComponent<CreatorRoleResponse, CreatorRoleMediaQueryParameters> _roleListComponent;
|
private RoleListComponent<CreatorRoleResponse, CreatorRoleMediaQueryParameters> _roleListComponent;
|
||||||
|
|
||||||
@@ -40,6 +44,11 @@ public partial class CreatorRolesPanelComponent : ComponentBase
|
|||||||
|
|
||||||
|
|
||||||
#region PRIVATE METHODS
|
#region PRIVATE METHODS
|
||||||
|
|
||||||
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
_user = await AuthenticationService.GetUserAsync();
|
||||||
|
}
|
||||||
|
|
||||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,9 @@
|
|||||||
<div class="container-grid">
|
<div class="container-grid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
<PictureComponent Picture="@(_picture)" Placeholder="/assets/person_poster.png" AlternativeText="poster" Height="100"/>
|
<a class="text-reset text-decoration-none" href="/person/@(Role.PersonId)">
|
||||||
|
<PictureComponent Picture="@(_picture)" Placeholder="/assets/person_poster.png" AlternativeText="poster" Height="110"/>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="d-flex align-items-start flex-column h-100">
|
<div class="d-flex align-items-start flex-column h-100">
|
||||||
@@ -16,10 +18,48 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<strong>@(_person.Name)</strong>@(Role is ActorRoleResponse actor ? $" as {actor.Name}" : string.Empty)
|
<a class="text-reset text-decoration-none" href="/person/@(Role.PersonId)">
|
||||||
|
<strong>@(_person.Name)</strong>@(Role is ActorRoleResponse actor ? $" as {actor.Name}" : string.Empty)
|
||||||
|
</a>
|
||||||
}
|
}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="d-inline-flex gap-3">
|
||||||
|
<div class="vstack">
|
||||||
|
<span id="ratingNameText">Global rating:</span>
|
||||||
|
<div class="hstack gap-2">
|
||||||
|
<span id="ratingStar">★</span>
|
||||||
|
<div class="d-inline-flex flex-column justify-content-center">
|
||||||
|
@if (_globalRating is not null)
|
||||||
|
{
|
||||||
|
<span id="ratingValue">@(_globalRating.Count > 0 ? _globalRating.Average : "--")/10</span>
|
||||||
|
if (_globalRating.Count > 0)
|
||||||
|
{
|
||||||
|
<span id="ratingCount">@(_globalRating.Count)</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="spinner-border spinner-border-sm text-light"></div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="vr"></div>
|
||||||
|
<div class="vstack">
|
||||||
|
<span id="ratingNameText">Your rating:</span>
|
||||||
|
<div class="d-inline-flex align-items-center h-100">
|
||||||
|
@if (_authenticated)
|
||||||
|
{
|
||||||
|
<Rating Color="Color.Light" MaxValue="10" @bind-SelectedValue="@(_yourRating)" @onclick="@(RatingChanged)"/>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<span id="ratingLoginInfoText">You must be logged in to rate the role</span>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using WatchIt.Common.Model;
|
using WatchIt.Common.Model;
|
||||||
using WatchIt.Common.Model.Persons;
|
using WatchIt.Common.Model.Persons;
|
||||||
|
using WatchIt.Common.Model.Rating;
|
||||||
using WatchIt.Common.Model.Roles;
|
using WatchIt.Common.Model.Roles;
|
||||||
|
using WatchIt.Website.Services.Utility.Authentication;
|
||||||
using WatchIt.Website.Services.WebAPI.Persons;
|
using WatchIt.Website.Services.WebAPI.Persons;
|
||||||
|
|
||||||
namespace WatchIt.Website.Components.Pages.MediaPage.Subcomponents;
|
namespace WatchIt.Website.Components.Pages.MediaPage.Subcomponents;
|
||||||
@@ -11,6 +13,7 @@ public partial class RoleComponent<TRole> : ComponentBase where TRole : IRoleRes
|
|||||||
#region SERVICES
|
#region SERVICES
|
||||||
|
|
||||||
[Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!;
|
[Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!;
|
||||||
|
[Inject] private IAuthenticationService AuthenticationService { get; set; } = default!;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -19,6 +22,10 @@ public partial class RoleComponent<TRole> : ComponentBase where TRole : IRoleRes
|
|||||||
#region PARAMETERS
|
#region PARAMETERS
|
||||||
|
|
||||||
[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<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; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -26,8 +33,12 @@ public partial class RoleComponent<TRole> : ComponentBase where TRole : IRoleRes
|
|||||||
|
|
||||||
#region FIELDS
|
#region FIELDS
|
||||||
|
|
||||||
|
private bool _authenticated;
|
||||||
private PersonResponse? _person;
|
private PersonResponse? _person;
|
||||||
private Picture? _picture;
|
private Picture? _picture;
|
||||||
|
private RatingResponse? _globalRating;
|
||||||
|
|
||||||
|
private int _yourRating;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -44,22 +55,33 @@ public partial class RoleComponent<TRole> : ComponentBase where TRole : IRoleRes
|
|||||||
// STEP 0
|
// STEP 0
|
||||||
endTasks.AddRange(
|
endTasks.AddRange(
|
||||||
[
|
[
|
||||||
PersonsWebAPIService.GetPersonPhoto(Role.PersonId, data =>
|
Task.Run(async () => _authenticated = await AuthenticationService.GetAuthenticationStatusAsync()),
|
||||||
{
|
PersonsWebAPIService.GetPersonPhoto(Role.PersonId, data => _picture = data),
|
||||||
_picture = data;
|
PersonsWebAPIService.GetPerson(Role.PersonId, data => _person = data),
|
||||||
StateHasChanged();
|
GetGlobalRatingAction(Role.Id, data => _globalRating = data),
|
||||||
}),
|
GetUserRatingAction(Role.Id, data => _yourRating = data, () => _yourRating = 0)
|
||||||
PersonsWebAPIService.GetPerson(Role.PersonId, data =>
|
|
||||||
{
|
|
||||||
_person = data;
|
|
||||||
StateHasChanged();
|
|
||||||
})
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// END
|
// END
|
||||||
await Task.WhenAll(endTasks);
|
await Task.WhenAll(endTasks);
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task RatingChanged()
|
||||||
|
{
|
||||||
|
if (_yourRating == 0)
|
||||||
|
{
|
||||||
|
await DeleteRatingAction(Role.Id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await PutRatingAction(Role.Id, new RatingRequest((short)_yourRating));
|
||||||
|
}
|
||||||
|
|
||||||
|
await GetGlobalRatingAction(Role.Id, data => _globalRating = data);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
/* IDS */
|
||||||
|
|
||||||
|
#nameText {
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ratingNameText {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ratingLoginInfoText {
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ratingStar {
|
||||||
|
font-size: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ratingValue {
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ratingCount {
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
@@ -8,14 +8,19 @@
|
|||||||
<div class="vstack">
|
<div class="vstack">
|
||||||
@for (int i = 0; i < _roles.Count; i++)
|
@for (int i = 0; i < _roles.Count; i++)
|
||||||
{
|
{
|
||||||
if (i > 0)
|
|
||||||
{
|
{
|
||||||
<hr/>
|
int iCopy = i;
|
||||||
}
|
if (i > 0)
|
||||||
<a class="text-reset text-decoration-none" href="/person/@(_roles[i].PersonId)">
|
{
|
||||||
|
<hr/>
|
||||||
|
}
|
||||||
<RoleComponent TRole="TRole"
|
<RoleComponent TRole="TRole"
|
||||||
Role="@(_roles[i])"/>
|
Role="@(_roles[i])"
|
||||||
</a>
|
GetGlobalRatingAction="@(GetGlobalRatingAction)"
|
||||||
|
GetUserRatingAction="@(GetUserRatingAction)"
|
||||||
|
PutRatingAction="@(PutRatingAction)"
|
||||||
|
DeleteRatingAction="@(DeleteRatingAction)"/>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@if (!_allItemsLoaded)
|
@if (!_allItemsLoaded)
|
||||||
{
|
{
|
||||||
@@ -36,5 +41,5 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<LoadingComponent/>
|
<LoadingComponent Color="LoadingComponent.LoadingComponentColors.Light"/>
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using WatchIt.Common.Model.Rating;
|
||||||
using WatchIt.Common.Model.Roles;
|
using WatchIt.Common.Model.Roles;
|
||||||
using WatchIt.Common.Query;
|
using WatchIt.Common.Query;
|
||||||
|
|
||||||
@@ -7,12 +8,25 @@ namespace WatchIt.Website.Components.Pages.MediaPage.Subcomponents;
|
|||||||
|
|
||||||
public partial class RoleListComponent<TRole, TQuery> : ComponentBase where TRole : IRoleResponse, IQueryOrderable<TRole> where TQuery : QueryParameters<TRole>
|
public partial class RoleListComponent<TRole, TQuery> : ComponentBase where TRole : IRoleResponse, IQueryOrderable<TRole> where TQuery : QueryParameters<TRole>
|
||||||
{
|
{
|
||||||
|
#region SERVICES
|
||||||
|
|
||||||
|
[Inject] private NavigationManager NavigationManager { get; set; } = default!;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region PROPERTIES
|
#region PROPERTIES
|
||||||
|
|
||||||
[Parameter] public required long Id { get; set; }
|
[Parameter] public required long Id { get; set; }
|
||||||
[Parameter] public required Func<long, TQuery, Action<IEnumerable<TRole>>, Task> GetRolesAction { get; set; }
|
|
||||||
[Parameter] public TQuery Query { get; set; } = Activator.CreateInstance<TQuery>();
|
[Parameter] public TQuery Query { get; set; } = Activator.CreateInstance<TQuery>();
|
||||||
[Parameter] public Func<TRole, string>? AdditionalTextSource { get; set; }
|
[Parameter] public Func<TRole, string>? AdditionalTextSource { 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<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; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user