new ordering system added
This commit is contained in:
@@ -13,10 +13,10 @@
|
||||
<div class="d-inline-flex gap-2">
|
||||
<span id="ratingStar">★</span>
|
||||
<div class="d-inline-flex flex-column justify-content-center">
|
||||
<span id="ratingValue">@(_rating is not null && _rating.RatingCount > 0 ? _rating.RatingAverage : "--")/10</span>
|
||||
@if (_rating is not null && _rating.RatingCount > 0)
|
||||
<span id="ratingValue">@(Rating.Count > 0 ? Rating.Average : "--")/10</span>
|
||||
@if (Rating.Count > 0)
|
||||
{
|
||||
<span id="ratingCount">@(_rating.RatingCount)</span>
|
||||
<span id="ratingCount">@(Rating.Count)</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -11,8 +11,8 @@ public partial class ListItemComponent : ComponentBase
|
||||
[Parameter] public required long Id { get; set; }
|
||||
[Parameter] public required string Name { get; set; }
|
||||
[Parameter] public string? AdditionalNameInfo { get; set; }
|
||||
[Parameter] public required RatingResponse Rating { get; set; }
|
||||
[Parameter] public required Func<long, Action<Picture>, Task> PictureDownloadingTask { get; set; }
|
||||
[Parameter] public required Func<long, Action<RatingResponse>, Task> RatingDownloadingTask { get; set; }
|
||||
[Parameter] public int PictureHeight { get; set; } = 150;
|
||||
|
||||
#endregion
|
||||
@@ -24,7 +24,6 @@ public partial class ListItemComponent : ComponentBase
|
||||
private bool _loaded;
|
||||
|
||||
private Picture? _picture;
|
||||
private RatingResponse? _rating;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -42,7 +41,6 @@ public partial class ListItemComponent : ComponentBase
|
||||
endTasks.AddRange(
|
||||
[
|
||||
PictureDownloadingTask(Id, picture => _picture = picture),
|
||||
RatingDownloadingTask(Id, rating => _rating = rating)
|
||||
]);
|
||||
|
||||
await Task.WhenAll(endTasks);
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
<ListItemComponent Id="@(IdSource(_items[i]))"
|
||||
Name="@(NameSource(_items[i]))"
|
||||
AdditionalNameInfo="@(AdditionalNameInfoSource(_items[i]))"
|
||||
PictureDownloadingTask="@(PictureDownloadingTask)"
|
||||
RatingDownloadingTask="@(RatingDownloadingTask)"/>
|
||||
Rating="@(RatingSource(_items[i]))"
|
||||
PictureDownloadingTask="@(PictureDownloadingTask)"/>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -14,10 +14,10 @@ public partial class SearchResultComponent<TItem, TQuery> : ComponentBase where
|
||||
[Parameter] public required Func<TItem, long> IdSource { get; set; }
|
||||
[Parameter] public required Func<TItem, string> NameSource { get; set; }
|
||||
[Parameter] public Func<TItem, string?> AdditionalNameInfoSource { get; set; } = _ => null;
|
||||
[Parameter] public required Func<TItem, RatingResponse> RatingSource { get; set; }
|
||||
[Parameter] public required string UrlIdTemplate { get; set; }
|
||||
[Parameter] public required Func<TQuery, Action<IEnumerable<TItem>>, Task> ItemDownloadingTask { get; set; }
|
||||
[Parameter] public required Func<long, Action<Picture>, Task> PictureDownloadingTask { get; set; }
|
||||
[Parameter] public required Func<long, Action<RatingResponse>, Task> RatingDownloadingTask { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ else
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h4 class="text-dark">
|
||||
<strong>Global rating:</strong> @(_globalRating.RatingCount == 0 ? "no ratings" : $"{Math.Round(_globalRating.RatingAverage, 1)}/10")
|
||||
<strong>Global rating:</strong> @(_globalRating.Count == 0 ? "no ratings" : $"{Math.Round(_globalRating.Average, 1)}/10")
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -37,10 +37,10 @@
|
||||
IdSource="@(item => item.Id)"
|
||||
NameSource="@(item => item.Title)"
|
||||
AdditionalNameInfoSource="@(item => item.ReleaseDate.HasValue ? $" ({item.ReleaseDate.Value.Year})" : null)"
|
||||
Query="@(new MovieQueryParameters { Title = DecodedQuery })"
|
||||
RatingSource="@(item => item.Rating)"
|
||||
Query="@(new MovieQueryParameters { Title = DecodedQuery, OrderBy = "rating.count" })"
|
||||
ItemDownloadingTask="@(MoviesWebAPIService.GetAllMovies)"
|
||||
PictureDownloadingTask="@((id, action) => MediaWebAPIService.GetMediaPoster(id, action))"
|
||||
RatingDownloadingTask="@((id, action) => MediaWebAPIService.GetMediaRating(id, action))"/>
|
||||
PictureDownloadingTask="@((id, action) => MediaWebAPIService.GetMediaPoster(id, action))"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-3">
|
||||
@@ -52,10 +52,10 @@
|
||||
IdSource="@(item => item.Id)"
|
||||
NameSource="@(item => item.Title)"
|
||||
AdditionalNameInfoSource="@(item => item.ReleaseDate.HasValue ? $" ({item.ReleaseDate.Value.Year})" : null)"
|
||||
Query="@(new SeriesQueryParameters { Title = DecodedQuery })"
|
||||
RatingSource="@(item => item.Rating)"
|
||||
Query="@(new SeriesQueryParameters { Title = DecodedQuery, OrderBy = "rating.count" })"
|
||||
ItemDownloadingTask="@(SeriesWebAPIService.GetAllSeries)"
|
||||
PictureDownloadingTask="@((id, action) => MediaWebAPIService.GetMediaPoster(id, action))"
|
||||
RatingDownloadingTask="@((id, action) => MediaWebAPIService.GetMediaRating(id, action))"/>
|
||||
PictureDownloadingTask="@((id, action) => MediaWebAPIService.GetMediaPoster(id, action))"/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user