rating panel added
This commit is contained in:
@@ -45,6 +45,11 @@ public class RatingResponse
|
|||||||
{
|
{
|
||||||
IEnumerable<RatingPersonActorRole> ratingsActorRoles = personActorRoles.SelectMany(x => x.RatingPersonActorRole);
|
IEnumerable<RatingPersonActorRole> ratingsActorRoles = personActorRoles.SelectMany(x => x.RatingPersonActorRole);
|
||||||
IEnumerable<RatingPersonCreatorRole> ratingsCreatorRoles = personCreatorRoles.SelectMany(x => x.RatingPersonCreatorRole);
|
IEnumerable<RatingPersonCreatorRole> ratingsCreatorRoles = personCreatorRoles.SelectMany(x => x.RatingPersonCreatorRole);
|
||||||
|
return Create(ratingsActorRoles, ratingsCreatorRoles);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RatingResponse Create(IEnumerable<RatingPersonActorRole> ratingsActorRoles, IEnumerable<RatingPersonCreatorRole> ratingsCreatorRoles)
|
||||||
|
{
|
||||||
long ratingSum = ratingsActorRoles.Sum(x => x.Rating) + ratingsCreatorRoles.Sum(x => x.Rating);
|
long ratingSum = ratingsActorRoles.Sum(x => x.Rating) + ratingsCreatorRoles.Sum(x => x.Rating);
|
||||||
long ratingCount = ratingsActorRoles.Count() + ratingsCreatorRoles.Count();
|
long ratingCount = ratingsActorRoles.Count() + ratingsCreatorRoles.Count();
|
||||||
return new RatingResponse(ratingSum, ratingCount);
|
return new RatingResponse(ratingSum, ratingCount);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
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.WebAPI.Services.Controllers.Persons;
|
using WatchIt.WebAPI.Services.Controllers.Persons;
|
||||||
|
|
||||||
@@ -147,5 +148,21 @@ public class PersonsController : ControllerBase
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Rating
|
||||||
|
|
||||||
|
[HttpGet("{id}/rating")]
|
||||||
|
[AllowAnonymous]
|
||||||
|
[ProducesResponseType(typeof(RatingResponse), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
public async Task<ActionResult> GetPersonGlobalRating([FromRoute]long id) => await _personsControllerService.GetPersonGlobalRating(id);
|
||||||
|
|
||||||
|
[HttpGet("{id}/rating/{user_id}")]
|
||||||
|
[AllowAnonymous]
|
||||||
|
[ProducesResponseType(typeof(RatingResponse), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
public async Task<ActionResult> GetPersonUserRating([FromRoute]long id, [FromRoute(Name = "user_id")]long userId) => await _personsControllerService.GetPersonUserRating(id, userId);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -23,4 +23,7 @@ public interface IPersonsControllerService
|
|||||||
Task<RequestResult> PostPersonActorRole(long personId, ActorRolePersonRequest data);
|
Task<RequestResult> PostPersonActorRole(long personId, ActorRolePersonRequest data);
|
||||||
Task<RequestResult> GetPersonAllCreatorRoles(long personId, CreatorRolePersonQueryParameters queryParameters);
|
Task<RequestResult> GetPersonAllCreatorRoles(long personId, CreatorRolePersonQueryParameters queryParameters);
|
||||||
Task<RequestResult> PostPersonCreatorRole(long personId, CreatorRolePersonRequest data);
|
Task<RequestResult> PostPersonCreatorRole(long personId, CreatorRolePersonRequest data);
|
||||||
|
|
||||||
|
Task<RequestResult> GetPersonGlobalRating(long id);
|
||||||
|
Task<RequestResult> GetPersonUserRating(long id, long userId);
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
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.Database;
|
using WatchIt.Database;
|
||||||
using WatchIt.Database.Model.Person;
|
using WatchIt.Database.Model.Person;
|
||||||
|
using WatchIt.Database.Model.Rating;
|
||||||
using WatchIt.Database.Model.ViewCount;
|
using WatchIt.Database.Model.ViewCount;
|
||||||
using WatchIt.WebAPI.Services.Controllers.Common;
|
using WatchIt.WebAPI.Services.Controllers.Common;
|
||||||
using WatchIt.WebAPI.Services.Utility.User;
|
using WatchIt.WebAPI.Services.Utility.User;
|
||||||
@@ -323,5 +325,37 @@ public class PersonsControllerService : IPersonsControllerService
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Rating
|
||||||
|
|
||||||
|
public async Task<RequestResult> GetPersonGlobalRating(long id)
|
||||||
|
{
|
||||||
|
Person? item = await _database.Persons.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (item is null)
|
||||||
|
{
|
||||||
|
return RequestResult.NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
RatingResponse ratingResponse = RatingResponse.Create(item.PersonActorRoles, item.PersonCreatorRoles);
|
||||||
|
|
||||||
|
return RequestResult.Ok(ratingResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<RequestResult> GetPersonUserRating(long id, long userId)
|
||||||
|
{
|
||||||
|
Person? item = await _database.Persons.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (item is null)
|
||||||
|
{
|
||||||
|
return RequestResult.NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerable<RatingPersonActorRole> actorRoleRatings = item.PersonActorRoles.SelectMany(x => x.RatingPersonActorRole).Where(x => x.AccountId == userId);
|
||||||
|
IEnumerable<RatingPersonCreatorRole> creatorRoleRatings = item.PersonCreatorRoles.SelectMany(x => x.RatingPersonCreatorRole).Where(x => x.AccountId == userId);
|
||||||
|
RatingResponse ratingResponse = RatingResponse.Create(actorRoleRatings, creatorRoleRatings);
|
||||||
|
|
||||||
|
return RequestResult.Ok(ratingResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -17,4 +17,6 @@ public class Persons
|
|||||||
public string PostPersonActorRole { get; set; }
|
public string PostPersonActorRole { get; set; }
|
||||||
public string GetPersonAllCreatorRoles { get; set; }
|
public string GetPersonAllCreatorRoles { get; set; }
|
||||||
public string PostPersonCreatorRole { get; set; }
|
public string PostPersonCreatorRole { get; set; }
|
||||||
|
public string GetPersonGlobalRating { get; set; }
|
||||||
|
public string GetPersonUserRating { get; set; }
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
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;
|
||||||
|
|
||||||
namespace WatchIt.Website.Services.WebAPI.Persons;
|
namespace WatchIt.Website.Services.WebAPI.Persons;
|
||||||
@@ -22,4 +23,7 @@ public interface IPersonsWebAPIService
|
|||||||
Task PostPersonActorRole(long id, ActorRolePersonRequest data, Action<ActorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
Task PostPersonActorRole(long id, ActorRolePersonRequest data, Action<ActorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||||
Task GetPersonAllCreatorRoles(long id, CreatorRolePersonQueryParameters? query = null, Action<IEnumerable<CreatorRoleResponse>>? successAction = null);
|
Task GetPersonAllCreatorRoles(long id, CreatorRolePersonQueryParameters? query = null, Action<IEnumerable<CreatorRoleResponse>>? successAction = null);
|
||||||
Task PostPersonCreatorRole(long id, CreatorRolePersonRequest data, Action<CreatorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
Task PostPersonCreatorRole(long id, CreatorRolePersonRequest data, Action<CreatorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||||
|
|
||||||
|
Task GetPersonGlobalRating(long id, Action<RatingResponse>? successAction = null, Action? notFoundAction = null);
|
||||||
|
Task GetPersonUserRating(long id, long userId, Action<RatingResponse>? successAction = null, Action? notFoundAction = null);
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using Microsoft.Extensions.Primitives;
|
using Microsoft.Extensions.Primitives;
|
||||||
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.Common.Services.HttpClient;
|
using WatchIt.Common.Services.HttpClient;
|
||||||
using WatchIt.Website.Services.Utility.Configuration;
|
using WatchIt.Website.Services.Utility.Configuration;
|
||||||
@@ -258,6 +259,34 @@ public class PersonsWebAPIService : BaseWebAPIService, IPersonsWebAPIService
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Rating
|
||||||
|
|
||||||
|
public async Task GetPersonGlobalRating(long id, Action<RatingResponse>? successAction = null, Action? notFoundAction = null)
|
||||||
|
{
|
||||||
|
string url = GetUrl(EndpointsConfiguration.Persons.GetPersonGlobalRating, id);
|
||||||
|
|
||||||
|
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
|
||||||
|
|
||||||
|
HttpResponse response = await _httpClientService.SendRequestAsync(request);
|
||||||
|
response.RegisterActionFor2XXSuccess(successAction)
|
||||||
|
.RegisterActionFor404NotFound(notFoundAction)
|
||||||
|
.ExecuteAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task GetPersonUserRating(long id, long userId, Action<RatingResponse>? successAction = null, Action? notFoundAction = null)
|
||||||
|
{
|
||||||
|
string url = GetUrl(EndpointsConfiguration.Persons.GetPersonUserRating, id, userId);
|
||||||
|
|
||||||
|
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
|
||||||
|
|
||||||
|
HttpResponse response = await _httpClientService.SendRequestAsync(request);
|
||||||
|
response.RegisterActionFor2XXSuccess(successAction)
|
||||||
|
.RegisterActionFor404NotFound(notFoundAction)
|
||||||
|
.ExecuteAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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.3.0.16"/>
|
<link rel="stylesheet" href="WatchIt.Website.styles.css?version=0.3.0.22"/>
|
||||||
<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 -->
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
@using Blazorise.Extensions
|
||||||
|
<div class="d-flex align-items-center gap-2">
|
||||||
|
@if (Rating is null || Rating.Count > 0 || EmptyMode == DisplayRatingComponentEmptyMode.DoubleDash)
|
||||||
|
{
|
||||||
|
<i id="star" class="fas fa-star"></i>
|
||||||
|
}
|
||||||
|
<div class="vstack">
|
||||||
|
@if (Rating is not null && Rating.Count > 0)
|
||||||
|
{
|
||||||
|
<span id="ratingAverage">@($"{Math.Round(Rating.Average, 2)}/10")</span>
|
||||||
|
<span id="ratingCount">@(Rating.Count)</span>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div id="ratingNoItems">
|
||||||
|
@if (Rating is null)
|
||||||
|
{
|
||||||
|
<span><div class="spinner-border spinner-border-sm"></div>/10</span>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (EmptyMode)
|
||||||
|
{
|
||||||
|
case DisplayRatingComponentEmptyMode.NoRatings: @("no ratings"); break;
|
||||||
|
case DisplayRatingComponentEmptyMode.DoubleDash: @("--/10"); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
#star {
|
||||||
|
font-size: @((2 * Scale).ToCultureInvariantString())rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ratingAverage {
|
||||||
|
margin-top: @((-5 * Scale).ToCultureInvariantString())px;
|
||||||
|
font-size: @((1.3 * Scale).ToCultureInvariantString())rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ratingNoItems {
|
||||||
|
font-size: @((1.3 * Scale).ToCultureInvariantString())rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ratingCount {
|
||||||
|
margin-top: @((-5 * Scale).ToCultureInvariantString())px;
|
||||||
|
font-size: @((0.8 * Scale).ToCultureInvariantString())rem;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using WatchIt.Common.Model.Rating;
|
||||||
|
|
||||||
|
namespace WatchIt.Website.Components.Common.Subcomponents;
|
||||||
|
|
||||||
|
public partial class DisplayRatingComponent : ComponentBase
|
||||||
|
{
|
||||||
|
#region PARAMETERS
|
||||||
|
|
||||||
|
[Parameter] public RatingResponse? Rating { get; set; }
|
||||||
|
[Parameter] public DisplayRatingComponentEmptyMode EmptyMode { get; set; } = DisplayRatingComponentEmptyMode.NoRatings;
|
||||||
|
[Parameter] public double Scale { get; set; } = 1;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region ENUMS
|
||||||
|
|
||||||
|
public enum DisplayRatingComponentEmptyMode
|
||||||
|
{
|
||||||
|
NoRatings,
|
||||||
|
DoubleDash,
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<div class="container-grid">
|
||||||
|
<div class="row gx-3">
|
||||||
|
<div class="col">
|
||||||
|
<span id="title" class="fw-bold">@(Title)</span>
|
||||||
|
</div>
|
||||||
|
<div class="col-auto align-self-center">
|
||||||
|
<DisplayRatingComponent Rating="@(Rating)"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using WatchIt.Common.Model.Rating;
|
||||||
|
|
||||||
|
namespace WatchIt.Website.Components.Common.Subcomponents;
|
||||||
|
|
||||||
|
public partial class TitledDisplayRatingComponent : ComponentBase
|
||||||
|
{
|
||||||
|
#region PARAMETERS
|
||||||
|
|
||||||
|
[Parameter] public required RatingResponse Rating { get; set; }
|
||||||
|
[Parameter] public required string Title { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
/* IDS */
|
||||||
|
|
||||||
|
#title {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
@@ -25,28 +25,14 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-inline-flex gap-3">
|
<div class="d-inline-flex gap-3">
|
||||||
<div class="vstack">
|
<div class="vstack gap-2">
|
||||||
<span id="ratingNameText">Global rating:</span>
|
<span id="ratingNameText">Global rating:</span>
|
||||||
<div class="hstack gap-2">
|
<DisplayRatingComponent Rating="_globalRating"
|
||||||
<span id="ratingStar">★</span>
|
EmptyMode="DisplayRatingComponent.DisplayRatingComponentEmptyMode.DoubleDash"
|
||||||
<div class="d-inline-flex flex-column justify-content-center">
|
Scale="0.85"/>
|
||||||
@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>
|
||||||
<div class="vr"></div>
|
<div class="vr"></div>
|
||||||
<div class="vstack">
|
<div class="vstack gap-2">
|
||||||
<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 (_user is not null)
|
@if (_user is not null)
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<div class="panel panel-background-gold h-100 text-dark">
|
||||||
|
<div class="vstack">
|
||||||
|
<TitledDisplayRatingComponent Rating="@(Rating)" Title="Global rating:"/>
|
||||||
|
<hr/>
|
||||||
|
@if (_user is not null)
|
||||||
|
{
|
||||||
|
<TitledDisplayRatingComponent Rating="@(_userRating)" Title="Your rating:"/>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="vstack">
|
||||||
|
<h4 class="fw-bold">Your rating:</h4>
|
||||||
|
<span>Log in to see your rating</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using WatchIt.Common.Model.Rating;
|
||||||
|
using WatchIt.Website.Services.Utility.Authentication;
|
||||||
|
using WatchIt.Website.Services.WebAPI.Persons;
|
||||||
|
|
||||||
|
namespace WatchIt.Website.Components.Pages.PersonPage.Panels;
|
||||||
|
|
||||||
|
public partial class PersonRatingPanel : ComponentBase
|
||||||
|
{
|
||||||
|
#region SERVICES
|
||||||
|
|
||||||
|
[Inject] private IAuthenticationService AuthenticationService { get; set; } = default!;
|
||||||
|
[Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PARAMETERS
|
||||||
|
|
||||||
|
[Parameter] public required long Id { get; set; }
|
||||||
|
[Parameter] public RatingResponse? Rating { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region FIELDS
|
||||||
|
|
||||||
|
private User? _user;
|
||||||
|
|
||||||
|
private RatingResponse? _userRating;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PUBLIC METHODS
|
||||||
|
|
||||||
|
public async Task UpdateRating() => await Task.WhenAll(UpdateGlobalRating(), UpdateUserRating());
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PRIVATE METHODS
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender)
|
||||||
|
{
|
||||||
|
List<Task> step1Tasks = new List<Task>(1);
|
||||||
|
List<Task> endTasks = new List<Task>(2);
|
||||||
|
|
||||||
|
// STEP 0
|
||||||
|
step1Tasks.AddRange(
|
||||||
|
[
|
||||||
|
Task.Run(async () => _user = await AuthenticationService.GetUserAsync())
|
||||||
|
]);
|
||||||
|
if (Rating is null)
|
||||||
|
{
|
||||||
|
endTasks.AddRange(
|
||||||
|
[
|
||||||
|
UpdateGlobalRating()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// STEP 1
|
||||||
|
await Task.WhenAll(step1Tasks);
|
||||||
|
endTasks.AddRange(
|
||||||
|
[
|
||||||
|
UpdateUserRating()
|
||||||
|
]);
|
||||||
|
|
||||||
|
// END
|
||||||
|
await Task.WhenAll(endTasks);
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async Task UpdateGlobalRating() => await PersonsWebAPIService.GetPersonGlobalRating(Id, data => Rating = data);
|
||||||
|
|
||||||
|
protected async Task UpdateUserRating()
|
||||||
|
{
|
||||||
|
if (_user is not null)
|
||||||
|
{
|
||||||
|
await PersonsWebAPIService.GetPersonUserRating(Id, _user.Id, data => _userRating = data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
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.Persons;
|
||||||
@@ -24,6 +25,8 @@ public partial class DatabasePage : ComponentBase
|
|||||||
|
|
||||||
[Parameter] public string? Type { get; set; }
|
[Parameter] public string? Type { get; set; }
|
||||||
|
|
||||||
|
[CascadingParameter] public MainLayout Layout { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
@@ -46,5 +49,16 @@ public partial class DatabasePage : ComponentBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnAfterRender(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender)
|
||||||
|
{
|
||||||
|
// INIT
|
||||||
|
Layout.BackgroundPhoto = null;
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,7 @@ else
|
|||||||
</div>
|
</div>
|
||||||
<div class="row mt-3 gx-3">
|
<div class="row mt-3 gx-3">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="rounded-3 panel panel-regular p-4 h-100">
|
<div class="panel panel-regular h-100">
|
||||||
<div class="container-grid">
|
<div class="container-grid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
@@ -108,13 +108,11 @@ else
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
<div class="rounded-3 panel panel-yellow p-4 h-100">
|
<div class="panel panel-background-gold h-100 text-dark">
|
||||||
<div class="container-grid">
|
<div class="container-grid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<h4 class="text-dark">
|
<TitledRatingComponent Rating="@(_globalRating)" Title="Global rating:"/>
|
||||||
<strong>Global rating:</strong> @(_globalRating.Count == 0 ? "no ratings" : $"{Math.Round(_globalRating.Average, 1)}/10")
|
|
||||||
</h4>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
@using System.Text
|
@using System.Text
|
||||||
|
@using WatchIt.Website.Components.Pages.PersonPage.Panels
|
||||||
|
|
||||||
@page "/person/{id:long}"
|
@page "/person/{id:long}"
|
||||||
|
|
||||||
@{
|
@{
|
||||||
StringBuilder sb = new StringBuilder(" - WatchIt");
|
StringBuilder sb = new StringBuilder(" - WatchIt");
|
||||||
|
|
||||||
if (!_loaded) { sb.Insert(0, "Loading..."); }
|
if (!_loaded) sb.Insert(0, "Loading...");
|
||||||
else if (_person is null) { sb.Insert(0, "Error"); }
|
else if (_person is null) sb.Insert(0, "Error");
|
||||||
else { sb.Insert(0, _person.Name); }
|
else sb.Insert(0, _person.Name);
|
||||||
|
|
||||||
<PageTitle>@(sb.ToString())</PageTitle>
|
<PageTitle>@(sb.ToString())</PageTitle>
|
||||||
}
|
}
|
||||||
@@ -28,6 +29,16 @@
|
|||||||
GetPosterMethod="@(action => PersonsWebAPIService.GetPersonPhoto(_person.Id, action))"/>
|
GetPosterMethod="@(action => PersonsWebAPIService.GetPersonPhoto(_person.Id, action))"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row mt-default gx-default">
|
||||||
|
<div class="col">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="col-auto">
|
||||||
|
<PersonRatingPanel @ref="_ratingPanel"
|
||||||
|
Id="@(_person.Id)"
|
||||||
|
Rating="@(_person.Rating)"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using WatchIt.Common.Model.Persons;
|
using WatchIt.Common.Model.Persons;
|
||||||
|
using WatchIt.Website.Components.Pages.PersonPage.Panels;
|
||||||
using WatchIt.Website.Layout;
|
using WatchIt.Website.Layout;
|
||||||
using WatchIt.Website.Services.WebAPI.Persons;
|
using WatchIt.Website.Services.WebAPI.Persons;
|
||||||
|
|
||||||
@@ -29,6 +30,8 @@ public partial class PersonPage : ComponentBase
|
|||||||
|
|
||||||
private bool _loaded;
|
private bool _loaded;
|
||||||
|
|
||||||
|
private PersonRatingPanel _ratingPanel = default!;
|
||||||
|
|
||||||
private PersonResponse? _person;
|
private PersonResponse? _person;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -55,10 +58,13 @@ public partial class PersonPage : ComponentBase
|
|||||||
|
|
||||||
// STEP 1
|
// STEP 1
|
||||||
await Task.WhenAll(step1Tasks);
|
await Task.WhenAll(step1Tasks);
|
||||||
|
if (_person is not null)
|
||||||
|
{
|
||||||
endTasks.AddRange(
|
endTasks.AddRange(
|
||||||
[
|
[
|
||||||
PersonsWebAPIService.PostPersonView(Id),
|
PersonsWebAPIService.PostPersonView(Id),
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
// END
|
// END
|
||||||
await Task.WhenAll(endTasks);
|
await Task.WhenAll(endTasks);
|
||||||
|
|||||||
@@ -52,7 +52,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Components\Pages\PersonPage\Panels\" />
|
|
||||||
<Folder Include="Components\Pages\PersonPage\Subcomponents\" />
|
<Folder Include="Components\Pages\PersonPage\Subcomponents\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -101,7 +101,9 @@
|
|||||||
"GetPersonAllActorRoles": "/{0}/roles/actor",
|
"GetPersonAllActorRoles": "/{0}/roles/actor",
|
||||||
"PostPersonActorRole": "/{0}/roles/actor",
|
"PostPersonActorRole": "/{0}/roles/actor",
|
||||||
"GetPersonAllCreatorRoles": "/{0}/roles/creator",
|
"GetPersonAllCreatorRoles": "/{0}/roles/creator",
|
||||||
"PostPersonCreatorRole": "/{0}/roles/creator"
|
"PostPersonCreatorRole": "/{0}/roles/creator",
|
||||||
|
"GetPersonGlobalRating": "/{0}/rating",
|
||||||
|
"GetPersonUserRating": "/{0}/rating/{1}"
|
||||||
},
|
},
|
||||||
"Roles": {
|
"Roles": {
|
||||||
"Base": "/roles",
|
"Base": "/roles",
|
||||||
|
|||||||
Reference in New Issue
Block a user