mirror of https://github.com/ErsatzTV/ErsatzTV.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
213 lines
10 KiB
213 lines
10 KiB
@page "/media/movies/{MovieId:int}" |
|
@using ErsatzTV.Application.Movies |
|
@using ErsatzTV.Application.Movies.Queries |
|
@using System.Globalization |
|
@using ErsatzTV.Application.MediaCards |
|
@using ErsatzTV.Application.MediaCollections |
|
@using ErsatzTV.Application.MediaCollections.Commands |
|
@using ErsatzTV.Extensions |
|
@inject IMediator _mediator |
|
@inject IDialogService _dialog |
|
@inject NavigationManager _navigationManager |
|
|
|
<MudContainer MaxWidth="MaxWidth.False" Style="padding: 0" Class="fanart-container"> |
|
<div class="fanart-tint"></div> |
|
@if (!string.IsNullOrWhiteSpace(_movie.FanArt)) |
|
{ |
|
if (_movie.FanArt.StartsWith("http://") || _movie.FanArt.StartsWith("https://")) |
|
{ |
|
<img src="@_movie.FanArt" alt="fan art"/> |
|
} |
|
else |
|
{ |
|
<img src="@($"/artwork/fanart/{_movie.FanArt}")" alt="fan art"/> |
|
} |
|
} |
|
</MudContainer> |
|
<MudContainer MaxWidth="MaxWidth.Large" Style="margin-top: 200px"> |
|
<div style="display: flex; flex-direction: row;" class="mb-6"> |
|
@if (!string.IsNullOrWhiteSpace(_movie.Poster)) |
|
{ |
|
if (_movie.Poster.StartsWith("http://") || _movie.Poster.StartsWith("https://")) |
|
{ |
|
<img class="mud-elevation-2 mr-6" |
|
style="border-radius: 4px; flex-shrink: 0; max-height: 440px;" |
|
src="@_movie.Poster" alt="movie poster"/> |
|
} |
|
else |
|
{ |
|
<img class="mud-elevation-2 mr-6" |
|
style="border-radius: 4px; flex-shrink: 0; max-height: 440px;" |
|
src="@($"/artwork/posters/{_movie.Poster}")" alt="movie poster"/> |
|
} |
|
} |
|
<div style="display: flex; flex-direction: column; height: 100%"> |
|
<MudText Typo="Typo.h2" Class="media-item-title">@_movie.Title</MudText> |
|
<MudText Typo="Typo.subtitle1" Class="media-item-subtitle mb-6 mud-text-secondary">@_movie.Year</MudText> |
|
@if (!string.IsNullOrWhiteSpace(_movie.Plot)) |
|
{ |
|
<MudCard Elevation="2" Class="mb-6"> |
|
<MudCardContent Class="mx-3 my-3" Style="height: 100%"> |
|
<MudText Style="flex-grow: 1">@_movie.Plot</MudText> |
|
</MudCardContent> |
|
</MudCard> |
|
} |
|
<div> |
|
<MudButton Variant="Variant.Filled" |
|
Color="Color.Primary" |
|
StartIcon="@Icons.Material.Filled.Add" |
|
OnClick="@AddToCollection"> |
|
Add To Collection |
|
</MudButton> |
|
</div> |
|
</div> |
|
</div> |
|
<MudCard Class="mb-6"> |
|
<MudCardContent> |
|
@if (_sortedContentRatings.Any()) |
|
{ |
|
<div style="display: flex; flex-direction: row; flex-wrap: wrap"> |
|
<MudText GutterBottom="true">Content Ratings: </MudText> |
|
<MudLink Href="@(@$"content_rating:""{_sortedContentRatings.Head()}""".GetRelativeSearchQuery())">@_sortedContentRatings.Head()</MudLink> |
|
@foreach (string contentRating in _sortedContentRatings.Skip(1)) |
|
{ |
|
<MudText>, </MudText> |
|
<MudLink Href="@(@$"content_rating:""{contentRating}""".GetRelativeSearchQuery())">@contentRating</MudLink> |
|
} |
|
</div> |
|
} |
|
@if (_sortedLanguages.Any()) |
|
{ |
|
<div style="display: flex; flex-direction: row; flex-wrap: wrap"> |
|
<MudText GutterBottom="true">Languages: </MudText> |
|
<MudLink Href="@(@$"language:""{_sortedLanguages.Head().EnglishName.ToLowerInvariant()}""".GetRelativeSearchQuery())">@_sortedLanguages.Head().EnglishName</MudLink> |
|
@foreach (CultureInfo language in _sortedLanguages.Skip(1)) |
|
{ |
|
<MudText>, </MudText> |
|
<MudLink Href="@(@$"language:""{language.EnglishName.ToLowerInvariant()}""".GetRelativeSearchQuery())">@language.EnglishName</MudLink> |
|
} |
|
</div> |
|
} |
|
@if (_sortedStudios.Any()) |
|
{ |
|
<div style="display: flex; flex-direction: row; flex-wrap: wrap"> |
|
<MudText GutterBottom="true">Studios: </MudText> |
|
<MudLink Href="@(@$"studio:""{_sortedStudios.Head().ToLowerInvariant()}""".GetRelativeSearchQuery())">@_sortedStudios.Head()</MudLink> |
|
@foreach (string studio in _sortedStudios.Skip(1)) |
|
{ |
|
<MudText>, </MudText> |
|
<MudLink Href="@(@$"studio:""{studio.ToLowerInvariant()}""".GetRelativeSearchQuery())">@studio</MudLink> |
|
} |
|
</div> |
|
} |
|
@if (_sortedDirectors.Any()) |
|
{ |
|
<div style="display: flex; flex-direction: row; flex-wrap: wrap"> |
|
<MudText GutterBottom="true">Directors: </MudText> |
|
<MudLink Href="@(@$"director:""{_sortedDirectors.Head().ToLowerInvariant()}""".GetRelativeSearchQuery())">@_sortedDirectors.Head()</MudLink> |
|
@foreach (string director in _sortedDirectors.Skip(1)) |
|
{ |
|
<MudText>, </MudText> |
|
<MudLink Href="@(@$"director:""{director.ToLowerInvariant()}""".GetRelativeSearchQuery())">@director</MudLink> |
|
} |
|
</div> |
|
} |
|
@if (_sortedWriters.Any()) |
|
{ |
|
<div style="display: flex; flex-direction: row; flex-wrap: wrap"> |
|
<MudText GutterBottom="true">Writers: </MudText> |
|
<MudLink Href="@(@$"writer:""{_sortedWriters.Head().ToLowerInvariant()}""".GetRelativeSearchQuery())">@_sortedWriters.Head()</MudLink> |
|
@foreach (string writer in _sortedWriters.Skip(1)) |
|
{ |
|
<MudText>, </MudText> |
|
<MudLink Href="@(@$"writer:""{writer.ToLowerInvariant()}""".GetRelativeSearchQuery())">@writer</MudLink> |
|
} |
|
</div> |
|
} |
|
@if (_sortedGenres.Any()) |
|
{ |
|
<div style="display: flex; flex-direction: row; flex-wrap: wrap"> |
|
<MudText GutterBottom="true">Genres: </MudText> |
|
<MudLink Href="@(@$"genre:""{_sortedGenres.Head().ToLowerInvariant()}""".GetRelativeSearchQuery())">@_sortedGenres.Head()</MudLink> |
|
@foreach (string genre in _sortedGenres.Skip(1)) |
|
{ |
|
<MudText>, </MudText> |
|
<MudLink Href="@(@$"genre:""{genre.ToLowerInvariant()}""".GetRelativeSearchQuery())">@genre</MudLink> |
|
} |
|
</div> |
|
} |
|
@if (_sortedTags.Any()) |
|
{ |
|
<div style="display: flex; flex-direction: row; flex-wrap: wrap"> |
|
<MudText GutterBottom="true">Tags: </MudText> |
|
<MudLink Href="@(@$"tag:""{_sortedTags.Head().ToLowerInvariant()}""".GetRelativeSearchQuery())">@_sortedTags.Head()</MudLink> |
|
@foreach (string tag in _sortedTags.Skip(1)) |
|
{ |
|
<MudText>, </MudText> |
|
<MudLink Href="@(@$"tag:""{tag.ToLowerInvariant()}""".GetRelativeSearchQuery())">@tag</MudLink> |
|
} |
|
</div> |
|
} |
|
</MudCardContent> |
|
</MudCard> |
|
</MudContainer> |
|
@if (_movie.Actors.Any()) |
|
{ |
|
<MudContainer MaxWidth="MaxWidth.Large"> |
|
<MudText Class="mb-4">Actors</MudText> |
|
</MudContainer> |
|
<MudContainer MaxWidth="MaxWidth.Large" Class="media-card-grid"> |
|
@foreach (ActorCardViewModel actor in _movie.Actors) |
|
{ |
|
<MediaCard Data="@actor" |
|
Link="@(@$"actor:""{actor.Name.ToLowerInvariant()}""".GetRelativeSearchQuery())" |
|
IsRemoteArtwork="true" |
|
ArtworkKind="ArtworkKind.Thumbnail"/> |
|
} |
|
</MudContainer> |
|
} |
|
|
|
@code { |
|
|
|
[Parameter] |
|
public int MovieId { get; set; } |
|
|
|
private MovieViewModel _movie; |
|
private List<string> _sortedContentRatings = new(); |
|
private List<CultureInfo> _sortedLanguages = new(); |
|
private List<string> _sortedDirectors = new(); |
|
private List<string> _sortedWriters = new(); |
|
private List<string> _sortedStudios = new(); |
|
private List<string> _sortedGenres = new(); |
|
private List<string> _sortedTags = new(); |
|
|
|
protected override Task OnParametersSetAsync() => RefreshData(); |
|
|
|
private Task RefreshData() => |
|
_mediator.Send(new GetMovieById(MovieId)).IfSomeAsync(vm => |
|
{ |
|
_movie = vm; |
|
_sortedContentRatings = _movie.ContentRatings.OrderBy(cr => cr).ToList(); |
|
_sortedLanguages = _movie.Languages.OrderBy(ci => ci.EnglishName).ToList(); |
|
_sortedStudios = _movie.Studios.OrderBy(s => s).ToList(); |
|
_sortedGenres = _movie.Genres.OrderBy(g => g).ToList(); |
|
_sortedTags = _movie.Tags.OrderBy(t => t).ToList(); |
|
_sortedDirectors = _movie.Directors.OrderBy(d => d).ToList(); |
|
_sortedWriters = _movie.Writers.OrderBy(w => w).ToList(); |
|
}); |
|
|
|
private async Task AddToCollection() |
|
{ |
|
var parameters = new DialogParameters { { "EntityType", "movie" }, { "EntityName", _movie.Title } }; |
|
var options = new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall }; |
|
|
|
IDialogReference dialog = _dialog.Show<AddToCollectionDialog>("Add To Collection", parameters, options); |
|
DialogResult result = await dialog.Result; |
|
if (!result.Cancelled && result.Data is MediaCollectionViewModel collection) |
|
{ |
|
await _mediator.Send(new AddMovieToCollection(collection.Id, MovieId)); |
|
_navigationManager.NavigateTo($"/media/collections/{collection.Id}"); |
|
} |
|
} |
|
|
|
} |