From 774b8832b58d77b9b31a2902bd7b0c9f39b7e5bb Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Thu, 19 Sep 2024 22:58:39 +0200 Subject: [PATCH] MediaDataPage - info section completed --- .../Genres/GenreResponse.cs | 3 + .../IMediaWebAPIService.cs | 1 + .../MediaWebAPIService.cs | 16 ++- WatchIt.Website/WatchIt.Website/App.razor | 4 +- .../WatchIt.Website/Layout/MainLayout.razor | 1 + .../WatchIt.Website/Pages/MediaDataPage.razor | 109 +++++++++++++++++- .../Pages/MediaDataPage.razor.cs | 26 ++++- .../Pages/MediaDataPage.razor.css | 19 ++- .../WatchIt.Website/wwwroot/app.css | 4 + 9 files changed, 170 insertions(+), 13 deletions(-) diff --git a/WatchIt.Common/WatchIt.Common.Model/Genres/GenreResponse.cs b/WatchIt.Common/WatchIt.Common.Model/Genres/GenreResponse.cs index 469e317..357d0d0 100644 --- a/WatchIt.Common/WatchIt.Common.Model/Genres/GenreResponse.cs +++ b/WatchIt.Common/WatchIt.Common.Model/Genres/GenreResponse.cs @@ -15,6 +15,9 @@ public class GenreResponse : Genre #region CONSTRUCTORS + + [JsonConstructor] + public GenreResponse() {} [SetsRequiredMembers] public GenreResponse(Database.Model.Common.Genre genre) diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Media/IMediaWebAPIService.cs b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Media/IMediaWebAPIService.cs index 20a851f..6c4ab8f 100644 --- a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Media/IMediaWebAPIService.cs +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Media/IMediaWebAPIService.cs @@ -8,6 +8,7 @@ public interface IMediaWebAPIService Task Get(long mediaId, Action successAction = null, Action? notFoundAction = null); Task GetGenres(long mediaId, Action>? successAction = null, Action? notFoundAction = null); Task PostGenre(long mediaId, long genreId, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null, Action? notFoundAction = null); + Task GetPhotoMediaRandomBackground(long mediaId, Action? successAction = null, Action? notFoundAction = null); Task GetPhotoRandomBackground(Action? successAction = null, Action? notFoundAction = null); Task GetPoster(long mediaId, Action? successAction = null, Action>? badRequestAction = null, Action? notFoundAction = null); Task PutPoster(long mediaId, MediaPosterRequest data, Action? successAction = null, Action>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null); diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Media/MediaWebAPIService.cs b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Media/MediaWebAPIService.cs index fbdb905..99d73cb 100644 --- a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Media/MediaWebAPIService.cs +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.WebAPI/WatchIt.Website.Services.WebAPI.Media/MediaWebAPIService.cs @@ -49,6 +49,18 @@ public class MediaWebAPIService(IHttpClientService httpClientService, IConfigura .ExecuteAction(); } + public async Task GetPhotoMediaRandomBackground(long mediaId, Action? successAction = null, Action? notFoundAction = null) + { + string url = GetUrl(EndpointsConfiguration.Media.GetPhotoMediaRandomBackground, mediaId); + + HttpRequest request = new HttpRequest(HttpMethodType.Get, url); + + HttpResponse response = await httpClientService.SendRequestAsync(request); + response.RegisterActionFor2XXSuccess(successAction) + .RegisterActionFor404NotFound(notFoundAction) + .ExecuteAction(); + } + public async Task GetPhotoRandomBackground(Action? successAction = null, Action? notFoundAction = null) { string url = GetUrl(EndpointsConfiguration.Media.GetPhotoRandomBackground); @@ -57,8 +69,8 @@ public class MediaWebAPIService(IHttpClientService httpClientService, IConfigura HttpResponse response = await httpClientService.SendRequestAsync(request); response.RegisterActionFor2XXSuccess(successAction) - .RegisterActionFor404NotFound(notFoundAction) - .ExecuteAction(); + .RegisterActionFor404NotFound(notFoundAction) + .ExecuteAction(); } public async Task GetPoster(long mediaId, Action? successAction = null, Action>? badRequestAction = null, Action? notFoundAction = null) diff --git a/WatchIt.Website/WatchIt.Website/App.razor b/WatchIt.Website/WatchIt.Website/App.razor index 0f46276..2bbaf6c 100644 --- a/WatchIt.Website/WatchIt.Website/App.razor +++ b/WatchIt.Website/WatchIt.Website/App.razor @@ -9,8 +9,8 @@ - - + + diff --git a/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor b/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor index a39f9ab..8daab63 100644 --- a/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor +++ b/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor @@ -60,6 +60,7 @@ background-position: center; background-repeat: no-repeat; background-size: cover; + background-attachment: fixed; } .logo, .main-button { diff --git a/WatchIt.Website/WatchIt.Website/Pages/MediaDataPage.razor b/WatchIt.Website/WatchIt.Website/Pages/MediaDataPage.razor index c8a89ca..03c88ff 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/MediaDataPage.razor +++ b/WatchIt.Website/WatchIt.Website/Pages/MediaDataPage.razor @@ -1,5 +1,7 @@ @page "/media/{id:long}" @using System.Text +@using Microsoft.IdentityModel.Tokens +@using WatchIt.Common.Model.Genres @layout MainLayout @@ -15,14 +17,96 @@
-

@_media.Title

+
+
+
+

+ @_media.Title +

+
+
+ @if (!string.IsNullOrWhiteSpace(_media.Description)) + { +
+
+
+ @_media.Description +
+
+
+ } +
-
+
-
- Test +
+
+
+
+
+ @if (!string.IsNullOrWhiteSpace(_media.OriginalTitle)) + { + + } + @if (_media.ReleaseDate is not null) + { + + } + @if (_media.Length is not null) + { + + } + @if (_movie?.Budget is not null) + { + + } +
+
+
+
+
+

Genres:

+
+
+
+
+
+ @if (_genres.IsNullOrEmpty()) + { +
+ No genres assigned. +
+ } + else + { + foreach (GenreResponse genre in _genres) + { + + + + } + } +
+
+
+
+
+
+
+
+ Oceny tutaj będą
@@ -42,4 +126,19 @@ { } -
\ No newline at end of file +
+ + + +@if (_background is not null) +{ + +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Pages/MediaDataPage.razor.cs b/WatchIt.Website/WatchIt.Website/Pages/MediaDataPage.razor.cs index cb813b2..c204e4e 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/MediaDataPage.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Pages/MediaDataPage.razor.cs @@ -1,5 +1,7 @@ using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model.Genres; using WatchIt.Common.Model.Media; +using WatchIt.Common.Model.Movies; using WatchIt.Website.Services.Utility.Authentication; using WatchIt.Website.Services.WebAPI.Media; using WatchIt.Website.Services.WebAPI.Movies; @@ -34,6 +36,9 @@ public partial class MediaDataPage : ComponentBase private string? _error; private MediaResponse? _media; + private MovieResponse? _movie; + private IEnumerable _genres; + private MediaPhotoResponse? _background; private MediaPosterResponse? _poster; private User? _user; @@ -51,13 +56,28 @@ public partial class MediaDataPage : ComponentBase if (_error is null) { - Task userTask = AuthenticationService.GetUserAsync(); + Task backgroundTask = MediaWebAPIService.GetPhotoMediaRandomBackground(Id, data => _background = data); Task posterTask = MediaWebAPIService.GetPoster(Id, data => _poster = data); + Task userTask = AuthenticationService.GetUserAsync(); + Task genresTask = MediaWebAPIService.GetGenres(Id, data => _genres = data); + Task specificMediaTask; + if (_media.Type == MediaType.Movie) + { + specificMediaTask = MoviesWebAPIService.Get(Id, data => _movie = data); + } + else + { + // TODO: download tv series info + specificMediaTask = null; + } await Task.WhenAll( [ - userTask, - posterTask + userTask, + specificMediaTask, + genresTask, + backgroundTask, + posterTask, ]); _user = await userTask; diff --git a/WatchIt.Website/WatchIt.Website/Pages/MediaDataPage.razor.css b/WatchIt.Website/WatchIt.Website/Pages/MediaDataPage.razor.css index 5f28270..9ae511b 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/MediaDataPage.razor.css +++ b/WatchIt.Website/WatchIt.Website/Pages/MediaDataPage.razor.css @@ -1 +1,18 @@ - \ No newline at end of file +/* CLASSES */ + +.metadata-pill { + border-color: gray; + border-width: 2px; + border-radius: 30px; + border-style: solid; + + padding: 2px 10px; +} + +.title-shadow { + text-shadow: 2px 2px 2px #000; +} + +.description-shadow { + text-shadow: 1px 1px 1px #000; +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/wwwroot/app.css b/WatchIt.Website/WatchIt.Website/wwwroot/app.css index 265d789..3504642 100644 --- a/WatchIt.Website/WatchIt.Website/wwwroot/app.css +++ b/WatchIt.Website/WatchIt.Website/wwwroot/app.css @@ -27,6 +27,10 @@ body, html { background-color: rgba(0, 0, 0, 0.6); } +.panel-yellow { + background-color: rgba(255, 184, 58, 0.6); +} + .panel { box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5); backdrop-filter: blur(25px);