movie page added
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
public class Media
|
||||
{
|
||||
public string Base { get; set; }
|
||||
public string Get { get; set; }
|
||||
public string GetGenres { get; set; }
|
||||
public string PostGenre { get; set; }
|
||||
public string DeleteGenre { get; set; }
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace WatchIt.Website.Services.WebAPI.Media;
|
||||
|
||||
public interface IMediaWebAPIService
|
||||
{
|
||||
Task Get(long mediaId, Action<MediaResponse> successAction = null, Action? notFoundAction = null);
|
||||
Task GetGenres(long mediaId, Action<IEnumerable<GenreResponse>>? successAction = null, Action? notFoundAction = null);
|
||||
Task PostGenre(long mediaId, long genreId, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null, Action? notFoundAction = null);
|
||||
Task GetPhotoRandomBackground(Action<MediaPhotoResponse>? successAction = null, Action? notFoundAction = null);
|
||||
|
||||
@@ -10,6 +10,18 @@ namespace WatchIt.Website.Services.WebAPI.Media;
|
||||
public class MediaWebAPIService(IHttpClientService httpClientService, IConfigurationService configurationService) : BaseWebAPIService(configurationService), IMediaWebAPIService
|
||||
{
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public async Task Get(long mediaId, Action<MediaResponse> successAction = null, Action? notFoundAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Media.Get, mediaId);
|
||||
|
||||
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
|
||||
|
||||
HttpResponse response = await httpClientService.SendRequestAsync(request);
|
||||
response.RegisterActionFor2XXSuccess(successAction)
|
||||
.RegisterActionFor404NotFound(notFoundAction)
|
||||
.ExecuteAction();
|
||||
}
|
||||
|
||||
public async Task GetGenres(long mediaId, Action<IEnumerable<GenreResponse>>? successAction = null, Action? notFoundAction = null)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<link rel="icon" type="image/png" href="favicon.png"/>
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" href="app.css?version=0.13"/>
|
||||
<link rel="stylesheet" href="app.css?version=0.14"/>
|
||||
<link rel="stylesheet" href="WatchIt.Website.styles.css?version=0.12"/>
|
||||
|
||||
<!-- BOOTSTRAP -->
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="d-flex flex-column m-5">
|
||||
<div class="d-flex justify-content-center">
|
||||
<div id="spinner" class="spinner-border text-dark"></div>
|
||||
</div>
|
||||
<div class="d-flex justify-content-center">
|
||||
<p id="text" class="text-dark">Loading...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,11 @@
|
||||
/* IDS */
|
||||
|
||||
#spinner {
|
||||
width: 5rem;
|
||||
height: 5rem;
|
||||
}
|
||||
|
||||
#text {
|
||||
font-size: 25px;
|
||||
border-width: 0.4rem;
|
||||
}
|
||||
45
WatchIt.Website/WatchIt.Website/Pages/MediaDataPage.razor
Normal file
45
WatchIt.Website/WatchIt.Website/Pages/MediaDataPage.razor
Normal file
@@ -0,0 +1,45 @@
|
||||
@page "/media/{id:long}"
|
||||
@using System.Text
|
||||
|
||||
@layout MainLayout
|
||||
|
||||
|
||||
<div class="container-fluid p-1 gy-2 gx-2">
|
||||
@if (_loaded)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_error))
|
||||
{
|
||||
<div class="row mt-9">
|
||||
<div class="col-auto">
|
||||
<img class="rounded-2 shadow" src="@(_poster is not null ? $"data:{_poster.MimeType};base64,{Encoding.UTF8.GetString(_poster.Image)}" : "assets/poster.png")" alt="poster" width="200" height="333"/>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="d-flex h-100">
|
||||
<h1 class="align-self-end font-weight-bold">@_media.Title</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-2">
|
||||
<div class="col">
|
||||
<div class="rounded-3 panel panel-regular">
|
||||
Test
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col rounded-3 panel panel-regular m-1">
|
||||
<div>
|
||||
<h2 class="text-danger">@_error</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<LoadingPageComponent/>
|
||||
}
|
||||
</div>
|
||||
72
WatchIt.Website/WatchIt.Website/Pages/MediaDataPage.razor.cs
Normal file
72
WatchIt.Website/WatchIt.Website/Pages/MediaDataPage.razor.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using WatchIt.Common.Model.Media;
|
||||
using WatchIt.Website.Services.Utility.Authentication;
|
||||
using WatchIt.Website.Services.WebAPI.Media;
|
||||
using WatchIt.Website.Services.WebAPI.Movies;
|
||||
|
||||
namespace WatchIt.Website.Pages;
|
||||
|
||||
public partial class MediaDataPage : ComponentBase
|
||||
{
|
||||
#region SERVICES
|
||||
|
||||
[Inject] public NavigationManager NavigationManager { get; set; } = default!;
|
||||
[Inject] public IAuthenticationService AuthenticationService { get; set; } = default!;
|
||||
[Inject] public IMoviesWebAPIService MoviesWebAPIService { get; set; } = default!;
|
||||
[Inject] public IMediaWebAPIService MediaWebAPIService { get; set; } = default!;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PARAMETERS
|
||||
|
||||
[Parameter]
|
||||
public long Id { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region FIELDS
|
||||
|
||||
private bool _loaded = false;
|
||||
private string? _error;
|
||||
|
||||
private MediaResponse? _media;
|
||||
private MediaPosterResponse? _poster;
|
||||
private User? _user;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PRIVATE METHODS
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
await MediaWebAPIService.Get(Id, data => _media = data, () => _error = $"Media with id {Id} was not found");
|
||||
|
||||
if (_error is null)
|
||||
{
|
||||
Task<User?> userTask = AuthenticationService.GetUserAsync();
|
||||
Task posterTask = MediaWebAPIService.GetPoster(Id, data => _poster = data);
|
||||
|
||||
await Task.WhenAll(
|
||||
[
|
||||
userTask,
|
||||
posterTask
|
||||
]);
|
||||
|
||||
_user = await userTask;
|
||||
}
|
||||
|
||||
_loaded = true;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
@page "/movies/{id:long}"
|
||||
@@ -1,7 +0,0 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace WatchIt.Website.Pages;
|
||||
|
||||
public partial class MovieDataPage : ComponentBase
|
||||
{
|
||||
}
|
||||
@@ -37,7 +37,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<AdditionalFiles Include="Layout\MainLayout.razor" />
|
||||
<AdditionalFiles Include="Pages\Home.razor" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
},
|
||||
"Media": {
|
||||
"Base": "/media",
|
||||
"Get": "/{0}",
|
||||
"GetGenres": "/{0}/genres",
|
||||
"PostGenre": "/{0}/genres/{1}",
|
||||
"DeleteGenre": "/{0}/genres/{1}",
|
||||
|
||||
@@ -15,6 +15,10 @@ body, html {
|
||||
-webkit-text-fill-color: transparent;
|
||||
}
|
||||
|
||||
.mt-9 {
|
||||
margin-top: 9rem !important;
|
||||
}
|
||||
|
||||
.panel-header {
|
||||
background-color: rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user