diff --git a/WatchIt.Website/WatchIt.Website/Components/ErrorComponent.razor b/WatchIt.Website/WatchIt.Website/Components/ErrorComponent.razor index 6f1c699..9624ad0 100644 --- a/WatchIt.Website/WatchIt.Website/Components/ErrorComponent.razor +++ b/WatchIt.Website/WatchIt.Website/Components/ErrorComponent.razor @@ -1,32 +1,28 @@ -
-
-
-
-
-
-
-
⚠︎
-
-
+
+
+
+
+
+
⚠︎
-
-
-
-

An error occured while loading a page

-
-
-
- @if (!string.IsNullOrWhiteSpace(ErrorMessage)) - { -
-
-
-

@ErrorMessage

-
-
-
- }
+
+
+
+

An error occured while loading a page

+
+
+
+ @if (!string.IsNullOrWhiteSpace(ErrorMessage)) + { +
+
+
+

@ErrorMessage

+
+
+
+ }
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/LoadingComponent.razor b/WatchIt.Website/WatchIt.Website/Components/LoadingComponent.razor index ea3d99a..a57afcc 100644 --- a/WatchIt.Website/WatchIt.Website/Components/LoadingComponent.razor +++ b/WatchIt.Website/WatchIt.Website/Components/LoadingComponent.razor @@ -1,12 +1,8 @@ -
-
-
-
-
-
-
-

Loading...

-
-
+
+
+
+
+
+

Loading...

\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor b/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor index b816a89..24e27be 100644 --- a/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor +++ b/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor @@ -56,7 +56,7 @@ } diff --git a/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor.cs b/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor.cs index feeecbe..9485fc0 100644 --- a/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor.cs @@ -28,6 +28,8 @@ public partial class MainLayout : LayoutComponentBase #region FIELDS private bool _loaded = false; + + private PhotoResponse? _defaultBackgroundPhoto; private User? _user = null; private AccountProfilePictureResponse? _userProfilePicture; @@ -39,8 +41,17 @@ public partial class MainLayout : LayoutComponentBase #region PROPERTIES - - public PhotoResponse? BackgroundPhoto { get; set; } + + private PhotoResponse? _backgroundPhoto; + public PhotoResponse? BackgroundPhoto + { + get => _backgroundPhoto; + set + { + _backgroundPhoto = value; + StateHasChanged(); + } + } #endregion @@ -64,7 +75,7 @@ public partial class MainLayout : LayoutComponentBase ]); endTasks.AddRange( [ - PhotosWebAPIService.GetPhotoRandomBackground(data => BackgroundPhoto = data) + PhotosWebAPIService.GetPhotoRandomBackground(data => _defaultBackgroundPhoto = data) ]); // STEP 1 @@ -84,6 +95,19 @@ public partial class MainLayout : LayoutComponentBase StateHasChanged(); } } + + private PhotoResponse? GetBackgroundPhoto() + { + if (BackgroundPhoto?.Background is not null) + { + return BackgroundPhoto; + } + else if (_defaultBackgroundPhoto?.Background is not null) + { + return _defaultBackgroundPhoto; + } + return null; + } #endregion diff --git a/WatchIt.Website/WatchIt.Website/Pages/AdminPage.razor b/WatchIt.Website/WatchIt.Website/Pages/AdminPage.razor index fed8def..8946ac8 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/AdminPage.razor +++ b/WatchIt.Website/WatchIt.Website/Pages/AdminPage.razor @@ -26,11 +26,19 @@ } else { - +
+
+ +
+
} } else { - +
+
+ +
+
}
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Pages/AdminPage.razor.cs b/WatchIt.Website/WatchIt.Website/Pages/AdminPage.razor.cs index 2a9306a..3817611 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/AdminPage.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Pages/AdminPage.razor.cs @@ -1,15 +1,24 @@ using Microsoft.AspNetCore.Components; +using WatchIt.Website.Layout; using WatchIt.Website.Services.Utility.Authentication; namespace WatchIt.Website.Pages; public partial class AdminPage { - #region SERVICE + #region SERVICES [Inject] public IAuthenticationService AuthenticationService { get; set; } = default!; #endregion + + + + #region PARAMETERS + + [CascadingParameter] public MainLayout Layout { get; set; } + + #endregion @@ -28,6 +37,8 @@ public partial class AdminPage { if (firstRender) { + Layout.BackgroundPhoto = null; + User? user = await AuthenticationService.GetUserAsync(); if (user is not null && user.IsAdmin) { diff --git a/WatchIt.Website/WatchIt.Website/Pages/HomePage.razor b/WatchIt.Website/WatchIt.Website/Pages/HomePage.razor index 2d99b94..0e9cc89 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/HomePage.razor +++ b/WatchIt.Website/WatchIt.Website/Pages/HomePage.razor @@ -87,11 +87,19 @@ } else { - +
+
+ +
+
} } else { - +
+
+ +
+
}
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Pages/HomePage.razor.cs b/WatchIt.Website/WatchIt.Website/Pages/HomePage.razor.cs index 706a9c6..5f528db 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/HomePage.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Pages/HomePage.razor.cs @@ -2,6 +2,7 @@ using WatchIt.Common.Model.Media; using WatchIt.Common.Model.Movies; using WatchIt.Common.Model.Series; +using WatchIt.Website.Layout; using WatchIt.Website.Services.WebAPI.Media; using WatchIt.Website.Services.WebAPI.Movies; using WatchIt.Website.Services.WebAPI.Series; @@ -21,6 +22,14 @@ public partial class HomePage + #region PARAMETERS + + [CascadingParameter] public MainLayout Layout { get; set; } + + #endregion + + + #region FIELDS private bool _loaded; @@ -39,6 +48,8 @@ public partial class HomePage { if (firstRender) { + Layout.BackgroundPhoto = null; + List step1Tasks = new List(); List endTasks = new List(); diff --git a/WatchIt.Website/WatchIt.Website/Pages/MediaEditPage.razor b/WatchIt.Website/WatchIt.Website/Pages/MediaEditPage.razor index 616d826..bcfcac0 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/MediaEditPage.razor +++ b/WatchIt.Website/WatchIt.Website/Pages/MediaEditPage.razor @@ -362,31 +362,28 @@ } else { - +
+
+ +
+
} } else { - +
+
+ +
+
} } else { - +
+
+ +
+
} -
- - - -@if (_background is not null) -{ - -} \ No newline at end of file +
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Pages/MediaEditPage.razor.cs b/WatchIt.Website/WatchIt.Website/Pages/MediaEditPage.razor.cs index 780d580..e034282 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/MediaEditPage.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Pages/MediaEditPage.razor.cs @@ -5,6 +5,7 @@ using WatchIt.Common.Model.Media; using WatchIt.Common.Model.Movies; using WatchIt.Common.Model.Photos; using WatchIt.Common.Model.Series; +using WatchIt.Website.Layout; using WatchIt.Website.Services.Utility.Authentication; using WatchIt.Website.Services.WebAPI.Media; using WatchIt.Website.Services.WebAPI.Movies; @@ -33,6 +34,8 @@ public partial class MediaEditPage : ComponentBase [Parameter] public long? Id { get; set; } [Parameter] public string? Type { get; set; } + [CascadingParameter] public MainLayout Layout { get; set; } + #endregion @@ -43,8 +46,6 @@ public partial class MediaEditPage : ComponentBase private string? _error; private User? _user; - - private PhotoResponse? _background; private MediaResponse? _media; private MovieRequest? _movieRequest; @@ -86,6 +87,8 @@ public partial class MediaEditPage : ComponentBase { if (firstRender) { + Layout.BackgroundPhoto = null; + List step1Tasks = new List(); List step2Tasks = new List(); List endTasks = new List(); @@ -112,7 +115,7 @@ public partial class MediaEditPage : ComponentBase { endTasks.AddRange( [ - MediaWebAPIService.GetMediaPhotoRandomBackground(Id.Value, data => _background = data), + MediaWebAPIService.GetMediaPhotoRandomBackground(Id.Value, data => Layout.BackgroundPhoto = data), MediaWebAPIService.GetMediaPoster(Id.Value, data => { _mediaPosterSaved = data; diff --git a/WatchIt.Website/WatchIt.Website/Pages/MediaPage.razor b/WatchIt.Website/WatchIt.Website/Pages/MediaPage.razor index a59a95f..b6b6a6f 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/MediaPage.razor +++ b/WatchIt.Website/WatchIt.Website/Pages/MediaPage.razor @@ -193,26 +193,19 @@ else } else { - +
+
+ +
+
} } else { - +
+
+ +
+
} -
- - - -@if (_background is not null) -{ - -} \ No newline at end of file +
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Pages/MediaPage.razor.cs b/WatchIt.Website/WatchIt.Website/Pages/MediaPage.razor.cs index 0df1dc3..50ad2f4 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/MediaPage.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Pages/MediaPage.razor.cs @@ -5,6 +5,7 @@ using WatchIt.Common.Model.Media; using WatchIt.Common.Model.Movies; using WatchIt.Common.Model.Photos; using WatchIt.Common.Model.Series; +using WatchIt.Website.Layout; using WatchIt.Website.Services.Utility.Authentication; using WatchIt.Website.Services.WebAPI.Media; using WatchIt.Website.Services.WebAPI.Movies; @@ -30,6 +31,8 @@ public partial class MediaPage : ComponentBase [Parameter] public long Id { get; set; } + [CascadingParameter] public MainLayout Layout { get; set; } + #endregion @@ -43,7 +46,6 @@ public partial class MediaPage : ComponentBase private User? _user; - private PhotoResponse? _background; private MediaPosterResponse? _poster; private IEnumerable _genres; private MediaRatingResponse _globalRating; @@ -62,6 +64,8 @@ public partial class MediaPage : ComponentBase { if (firstRender) { + Layout.BackgroundPhoto = null; + List step1Tasks = new List(); List step2Tasks = new List(); List endTasks = new List(); @@ -84,7 +88,7 @@ public partial class MediaPage : ComponentBase endTasks.AddRange( [ MediaWebAPIService.PostMediaView(Id), - MediaWebAPIService.GetMediaPhotoRandomBackground(Id, data => _background = data), + MediaWebAPIService.GetMediaPhotoRandomBackground(Id, data => Layout.BackgroundPhoto = data), MediaWebAPIService.GetMediaPoster(Id, data => _poster = data), MediaWebAPIService.GetMediaGenres(Id, data => _genres = data), MediaWebAPIService.GetMediaRating(Id, data => _globalRating = data),