From d50373f4baf2218775a65c1d7ac7fbce8f1ca736 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Sat, 12 Oct 2024 01:51:39 +0200 Subject: [PATCH 1/5] ActorRolesPanelComponent added, other fixes --- .../Roles/ActorRoleResponse.cs | 2 +- .../Roles/CreatorRoleResponse.cs | 2 +- .../Roles/IRoleResponse.cs | 9 +++ WatchIt.WebAPI/WatchIt.WebAPI/Program.cs | 9 ++- .../Model/ConfigurationData.cs | 1 + .../Model/Style.cs | 6 ++ WatchIt.Website/WatchIt.Website/App.razor | 4 +- .../MediaPage/ActorRolesPanelComponent.razor | 14 ++++ .../ActorRolesPanelComponent.razor.cs | 57 ++++++++++++++++ .../ActorRolesPanelComponent.razor.css | 0 .../MediaPage/RoleListComponent.razor | 5 ++ .../MediaPage/RoleListComponent.razor.cs | 13 ++++ .../MediaPage/RoleListComponent.razor.css | 0 .../WatchIt.Website/Layout/MainLayout.razor | 2 +- .../WatchIt.Website/Pages/MediaPage.razor | 23 +++++++ .../WatchIt.Website/_Imports.razor | 1 + .../WatchIt.Website/appsettings.json | 3 + .../WatchIt.Website/wwwroot/css/gaps.css | 17 +++++ .../WatchIt.Website/wwwroot/css/general.css | 16 ++--- .../WatchIt.Website/wwwroot/css/panel.css | 68 +++++++++++++++++++ 20 files changed, 238 insertions(+), 14 deletions(-) create mode 100644 WatchIt.Common/WatchIt.Common.Model/Roles/IRoleResponse.cs create mode 100644 WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/Style.cs create mode 100644 WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor create mode 100644 WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor.cs create mode 100644 WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor.css create mode 100644 WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor create mode 100644 WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor.cs create mode 100644 WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor.css create mode 100644 WatchIt.Website/WatchIt.Website/wwwroot/css/gaps.css create mode 100644 WatchIt.Website/WatchIt.Website/wwwroot/css/panel.css diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRoleResponse.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRoleResponse.cs index 692e5a9..31d3926 100644 --- a/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRoleResponse.cs +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/ActorRoleResponse.cs @@ -4,7 +4,7 @@ using WatchIt.Common.Query; namespace WatchIt.Common.Model.Roles; -public class ActorRoleResponse : ActorRole, IQueryOrderable +public class ActorRoleResponse : ActorRole, IQueryOrderable, IRoleResponse { #region PROPERTIES diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRoleResponse.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRoleResponse.cs index 986989d..d0611ea 100644 --- a/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRoleResponse.cs +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/CreatorRoleResponse.cs @@ -4,7 +4,7 @@ using WatchIt.Common.Query; namespace WatchIt.Common.Model.Roles; -public class CreatorRoleResponse : CreatorRole, IQueryOrderable +public class CreatorRoleResponse : CreatorRole, IQueryOrderable, IRoleResponse { #region PROPERTIES diff --git a/WatchIt.Common/WatchIt.Common.Model/Roles/IRoleResponse.cs b/WatchIt.Common/WatchIt.Common.Model/Roles/IRoleResponse.cs new file mode 100644 index 0000000..dbd62e3 --- /dev/null +++ b/WatchIt.Common/WatchIt.Common.Model/Roles/IRoleResponse.cs @@ -0,0 +1,9 @@ +namespace WatchIt.Common.Model.Roles; + +public interface IRoleResponse +{ + Guid Id { get; set; } + long MediaId { get; set; } + long PersonId { get; set; } + short TypeId { get; set; } +} \ No newline at end of file diff --git a/WatchIt.WebAPI/WatchIt.WebAPI/Program.cs b/WatchIt.WebAPI/WatchIt.WebAPI/Program.cs index 7d987e4..d6c6797 100644 --- a/WatchIt.WebAPI/WatchIt.WebAPI/Program.cs +++ b/WatchIt.WebAPI/WatchIt.WebAPI/Program.cs @@ -42,7 +42,14 @@ public static class Program using (IServiceScope scope = app.Services.CreateScope()) { - scope.ServiceProvider.GetService().Database.Migrate(); + DatabaseContext dbContext = scope.ServiceProvider.GetRequiredService(); + + while (!dbContext.Database.CanConnect()) + { + Thread.Sleep(1000); + } + + dbContext.Database.Migrate(); } if (app.Environment.IsDevelopment()) diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/ConfigurationData.cs b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/ConfigurationData.cs index cac866a..7709295 100644 --- a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/ConfigurationData.cs +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/ConfigurationData.cs @@ -5,5 +5,6 @@ public class ConfigurationData public Logging Logging { get; set; } public string AllowedHosts { get; set; } public StorageKeys StorageKeys { get; set; } + public Style Style { get; set; } public Endpoints Endpoints { get; set; } } \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/Style.cs b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/Style.cs new file mode 100644 index 0000000..00abcbd --- /dev/null +++ b/WatchIt.Website/WatchIt.Website.Services/WatchIt.Website.Services.Utility/WatchIt.Website.Services.Utility.Configuration/Model/Style.cs @@ -0,0 +1,6 @@ +namespace WatchIt.Website.Services.Utility.Configuration.Model; + +public class Style +{ + public int DefaultPanelPadding { get; set; } +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/App.razor b/WatchIt.Website/WatchIt.Website/App.razor index 059458f..de1a4c4 100644 --- a/WatchIt.Website/WatchIt.Website/App.razor +++ b/WatchIt.Website/WatchIt.Website/App.razor @@ -9,8 +9,10 @@ - + + + diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor b/WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor new file mode 100644 index 0000000..be9ddba --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor @@ -0,0 +1,14 @@ +@using WatchIt.Common.Model.Roles +
+
+ Actors + @if (_loaded) + { + + } + else + { + + } +
+
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor.cs new file mode 100644 index 0000000..ab64709 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor.cs @@ -0,0 +1,57 @@ +using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model.Roles; +using WatchIt.Website.Services.Utility.Configuration; +using WatchIt.Website.Services.WebAPI.Media; + +namespace WatchIt.Website.Components.MediaPage; + +public partial class ActorRolesPanelComponent : ComponentBase +{ + #region SERVICES + + [Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!; + + #endregion + + + + #region PARAMETERS + + [Parameter] public string Class { get; set; } = string.Empty; + [Parameter] public required long Id { get; set; } + + #endregion + + + + #region FIELDS + + private bool _loaded; + + private IEnumerable _roles = []; + + #endregion + + + + #region PUBLIC METHODS + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + List endTasks = new List(); + + // STEP 0 + endTasks.AddRange( + [ + MediaWebAPIService.GetMediaAllActorRoles(Id, successAction: data => _roles = data) + ]); + + // END + await Task.WhenAll(endTasks); + + _loaded = true; + StateHasChanged(); + } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor.css b/WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor.css new file mode 100644 index 0000000..e69de29 diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor new file mode 100644 index 0000000..09cba8c --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor @@ -0,0 +1,5 @@ +@typeparam TRole where TRole : WatchIt.Common.Model.Roles.IRoleResponse + +
+ +
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor.cs new file mode 100644 index 0000000..d0ea30a --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor.cs @@ -0,0 +1,13 @@ +using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model.Roles; + +namespace WatchIt.Website.Components.MediaPage; + +public partial class RoleListComponent : ComponentBase where TRole : IRoleResponse +{ + #region PROPERTIES + + [Parameter] public required IEnumerable Role { get; set; } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor.css b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor.css new file mode 100644 index 0000000..e69de29 diff --git a/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor b/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor index 6e23112..d6e9886 100644 --- a/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor +++ b/WatchIt.Website/WatchIt.Website/Layout/MainLayout.razor @@ -12,7 +12,7 @@
-
+
diff --git a/WatchIt.Website/WatchIt.Website/Pages/MediaPage.razor b/WatchIt.Website/WatchIt.Website/Pages/MediaPage.razor index 6c144cc..1e5ac8e 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/MediaPage.razor +++ b/WatchIt.Website/WatchIt.Website/Pages/MediaPage.razor @@ -190,6 +190,29 @@ else
+
+
+ + + Actors + Creators + + + +
+ +
+
+ + Test2 + +
+
+
+
} else { diff --git a/WatchIt.Website/WatchIt.Website/_Imports.razor b/WatchIt.Website/WatchIt.Website/_Imports.razor index 41dfd4d..6a1890c 100644 --- a/WatchIt.Website/WatchIt.Website/_Imports.razor +++ b/WatchIt.Website/WatchIt.Website/_Imports.razor @@ -11,6 +11,7 @@ @using WatchIt.Website.Components @using WatchIt.Website.Components.PersonEditPage @using WatchIt.Website.Components.MediaEditPage +@using WatchIt.Website.Components.MediaPage @using WatchIt.Common.Model.Accounts @using WatchIt.Common.Model.Media @using WatchIt.Website.Services.Utility.Tokens diff --git a/WatchIt.Website/WatchIt.Website/appsettings.json b/WatchIt.Website/WatchIt.Website/appsettings.json index aa46c17..e9ee01b 100644 --- a/WatchIt.Website/WatchIt.Website/appsettings.json +++ b/WatchIt.Website/WatchIt.Website/appsettings.json @@ -10,6 +10,9 @@ "AccessToken": "access_token", "RefreshToken": "refresh_token" }, + "Style": { + "DefaultPanelPadding": 4 + }, "Endpoints": { "Base": "https://localhost:7160", "Accounts": { diff --git a/WatchIt.Website/WatchIt.Website/wwwroot/css/gaps.css b/WatchIt.Website/WatchIt.Website/wwwroot/css/gaps.css new file mode 100644 index 0000000..9f37147 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/wwwroot/css/gaps.css @@ -0,0 +1,17 @@ +/* DEFAULT */ + +.mt-default { + margin-top: 1rem !important; +} + +.gx-default { + --bs-gutter-x: 1rem !important; +} + + + +/* OTHERS */ + +.mt-over-panel-menu { + margin-top: 3rem !important; +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/wwwroot/css/general.css b/WatchIt.Website/WatchIt.Website/wwwroot/css/general.css index 263c518..3ac06ff 100644 --- a/WatchIt.Website/WatchIt.Website/wwwroot/css/general.css +++ b/WatchIt.Website/WatchIt.Website/wwwroot/css/general.css @@ -25,6 +25,8 @@ body, html { font-family: "PT Sans"; } + + /* CLASSES */ .container-grid { @@ -53,6 +55,8 @@ body, html { + + .top-3 { top: 1rem !important; } @@ -69,22 +73,16 @@ body, html { margin-top: 9rem !important; } -.panel-header { - background-color: rgba(0, 0, 0, 0.8); -} .panel-regular { - background-color: rgba(0, 0, 0, 0.6); + background-color: rgba(0, 0, 0, 0.6) !important; } .panel-yellow { - background-color: rgba(255, 184, 58, 0.6); + background-color: rgba(255, 184, 58, 0.6) !important; } -.panel { - box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5); - backdrop-filter: blur(25px); -} + diff --git a/WatchIt.Website/WatchIt.Website/wwwroot/css/panel.css b/WatchIt.Website/WatchIt.Website/wwwroot/css/panel.css new file mode 100644 index 0000000..0e200f3 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/wwwroot/css/panel.css @@ -0,0 +1,68 @@ +/* MAIN */ + +.panel { + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5); + backdrop-filter: blur(25px); + + background-color: rgba(0, 0, 0, 0.6); + + border-radius: 0.5rem; + padding: 1.5rem; +} + + + +/* HEADER */ + +.panel-header { + padding: 0 1rem !important; + + background-color: rgba(0, 0, 0, 0.8); +} + + + +/* MENU */ + +.panel-menu { + gap: 1rem; + padding: 1rem 1.5rem !important; + + background-color: rgba(0, 0, 0, 0.8); +} + +.panel-menu > li > a { + --bs-nav-pills-link-active-bg: transparent; + --bs-nav-link-hover-color: white; + --bs-nav-link-color: #a6a6a6; + + --bs-nav-pills-border-radius: 1.25rem; + + padding: 0.25rem 0.5rem; + + border-style: solid; + border-width: 2px; + border-color: transparent; +} + +.panel-menu > li > a.active { + --bs-nav-link-color: white; + border-color: white; +} + + + +/* BACKGROUNDS */ + +.panel-background-gold { + background-color: rgba(255, 184, 58, 0.6); +} + + + +/* OTHERS */ + +.panel-text-title { + font-size: 1.5rem; + font-weight: bold; +} \ No newline at end of file From f5a72d7a83238df6b19bf36f802eb302d246261c Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Sun, 13 Oct 2024 12:10:52 +0200 Subject: [PATCH 2/5] actor roles panel added --- .../LoadingButtonContentComponent.razor | 16 ++++ .../LoadingButtonContentComponent.razor.cs | 15 ++++ .../MediaPage/ActorRolesPanelComponent.razor | 14 ++-- .../ActorRolesPanelComponent.razor.cs | 35 --------- .../Components/MediaPage/RoleComponent.razor | 0 .../MediaPage/RoleComponent.razor.cs | 14 ++++ .../MediaPage/RoleComponent.razor.css | 0 .../MediaPage/RoleListComponent.razor | 30 +++++++- .../MediaPage/RoleListComponent.razor.cs | 73 ++++++++++++++++++- 9 files changed, 147 insertions(+), 50 deletions(-) create mode 100644 WatchIt.Website/WatchIt.Website/Components/LoadingButtonContentComponent.razor create mode 100644 WatchIt.Website/WatchIt.Website/Components/LoadingButtonContentComponent.razor.cs create mode 100644 WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleComponent.razor create mode 100644 WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleComponent.razor.cs create mode 100644 WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleComponent.razor.css diff --git a/WatchIt.Website/WatchIt.Website/Components/LoadingButtonContentComponent.razor b/WatchIt.Website/WatchIt.Website/Components/LoadingButtonContentComponent.razor new file mode 100644 index 0000000..dcf57c2 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/LoadingButtonContentComponent.razor @@ -0,0 +1,16 @@ +@if (IsLoading) +{ + + @LoadingContent +} +else +{ + if (ChildContent is null) + { + @Content + } + else + { + @(ChildContent) + } +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/LoadingButtonContentComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/LoadingButtonContentComponent.razor.cs new file mode 100644 index 0000000..bb99d79 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/LoadingButtonContentComponent.razor.cs @@ -0,0 +1,15 @@ +using Microsoft.AspNetCore.Components; + +namespace WatchIt.Website.Components; + +public partial class LoadingButtonContentComponent : ComponentBase +{ + #region PARAMETERS + + [Parameter] public bool IsLoading { get; set; } + [Parameter] public string? LoadingContent { get; set; } + [Parameter] public string Content { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor b/WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor index be9ddba..c83bd6e 100644 --- a/WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor +++ b/WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor @@ -1,14 +1,10 @@ -@using WatchIt.Common.Model.Roles
Actors - @if (_loaded) - { - - } - else - { - - } +
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor.cs index ab64709..4a98650 100644 --- a/WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor.cs @@ -1,6 +1,4 @@ using Microsoft.AspNetCore.Components; -using WatchIt.Common.Model.Roles; -using WatchIt.Website.Services.Utility.Configuration; using WatchIt.Website.Services.WebAPI.Media; namespace WatchIt.Website.Components.MediaPage; @@ -21,37 +19,4 @@ public partial class ActorRolesPanelComponent : ComponentBase [Parameter] public required long Id { get; set; } #endregion - - - - #region FIELDS - - private bool _loaded; - - private IEnumerable _roles = []; - - #endregion - - - - #region PUBLIC METHODS - - protected override async Task OnAfterRenderAsync(bool firstRender) - { - List endTasks = new List(); - - // STEP 0 - endTasks.AddRange( - [ - MediaWebAPIService.GetMediaAllActorRoles(Id, successAction: data => _roles = data) - ]); - - // END - await Task.WhenAll(endTasks); - - _loaded = true; - StateHasChanged(); - } - - #endregion } \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleComponent.razor b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleComponent.razor new file mode 100644 index 0000000..e69de29 diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleComponent.razor.cs new file mode 100644 index 0000000..993df6f --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleComponent.razor.cs @@ -0,0 +1,14 @@ +using Microsoft.AspNetCore.Components; + +namespace WatchIt.Website.Components.MediaPage; + +public partial class RoleComponent : ComponentBase +{ + #region PARAMETERS + + [Parameter] public string? AdditionalName { get; set; } + + #endregion + + +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleComponent.razor.css b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleComponent.razor.css new file mode 100644 index 0000000..e69de29 diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor index 09cba8c..604aee1 100644 --- a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor +++ b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor @@ -1,5 +1,27 @@ -@typeparam TRole where TRole : WatchIt.Common.Model.Roles.IRoleResponse +@typeparam TRole where TRole : WatchIt.Common.Model.Roles.IRoleResponse, WatchIt.Common.Query.IQueryOrderable +@typeparam TQuery where TQuery : WatchIt.Common.Query.QueryParameters -
- -
\ No newline at end of file +@if (_loaded) +{ +
+ @for (int i = 0; i < _roles.Count; i++) + { + if (i > 0) + { +
+ } + + } +
+ +
+
+} +else +{ + +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor.cs index d0ea30a..92d0736 100644 --- a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor.cs @@ -1,13 +1,82 @@ using Microsoft.AspNetCore.Components; using WatchIt.Common.Model.Roles; +using WatchIt.Common.Query; namespace WatchIt.Website.Components.MediaPage; -public partial class RoleListComponent : ComponentBase where TRole : IRoleResponse +public partial class RoleListComponent : ComponentBase where TRole : IRoleResponse, IQueryOrderable where TQuery : QueryParameters { #region PROPERTIES - [Parameter] public required IEnumerable Role { get; set; } + [Parameter] public required long Id { get; set; } + [Parameter] public required Func>, Task> GetRolesAction { get; set; } + [Parameter] public TQuery Query { get; set; } = Activator.CreateInstance(); + [Parameter] public Func? AdditionalTextSource { get; set; } + + #endregion + + + #region FIELDS + + private readonly int _pageSize = 20; + + private bool _loaded; + private bool _allItemsLoaded; + + private List _roles = new List(); + private bool _rolesFetching; + + #endregion + + + + #region PRIVATE METHODS + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + List endTasks = new List(); + + // INIT + Query.First = _pageSize; + + // STEP 0 + endTasks.AddRange( + [ + GetRoles(true) + ]); + + // END + await Task.WhenAll(endTasks); + + _loaded = true; + StateHasChanged(); + } + } + + private async Task GetRoles(bool firstFetch = false) + { + _rolesFetching = true; + await GetRolesAction(Id, Query, data => + { + _roles.AddRange(data); + if (data.Count() < _pageSize) + { + _allItemsLoaded = true; + } + else + { + if (firstFetch) + { + Query.After = 0; + } + Query.After += _pageSize; + } + _rolesFetching = false; + }); + } + #endregion } \ No newline at end of file From a664bdc489ec0ce25239960194c206d5b7888e49 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Fri, 18 Oct 2024 03:04:48 +0200 Subject: [PATCH 3/5] changes in actor roles panel --- .../MediaPage/ActorRolesPanelComponent.razor | 2 +- .../Components/MediaPage/RoleComponent.razor | 36 +++++++++++ .../MediaPage/RoleComponent.razor.cs | 59 +++++++++++++++++-- .../MediaPage/RoleListComponent.razor | 22 ++++--- .../MediaPage/RoleListComponent.razor.cs | 2 +- 5 files changed, 107 insertions(+), 14 deletions(-) diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor b/WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor index c83bd6e..875dc3c 100644 --- a/WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor +++ b/WatchIt.Website/WatchIt.Website/Components/MediaPage/ActorRolesPanelComponent.razor @@ -1,5 +1,5 @@
-
+
Actors +
+
+ picture +
+
+
+
+ + @if (_person is null) + { + Loading... + } + else + { + @(_person.Name)@(Role is ActorRoleResponse actor ? $" as {actor.Name}" : string.Empty) + } + +
+
+
+
+
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleComponent.razor.cs index 993df6f..6e060fa 100644 --- a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleComponent.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleComponent.razor.cs @@ -1,14 +1,65 @@ using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model; +using WatchIt.Common.Model.Persons; +using WatchIt.Common.Model.Roles; +using WatchIt.Website.Services.WebAPI.Persons; namespace WatchIt.Website.Components.MediaPage; -public partial class RoleComponent : ComponentBase +public partial class RoleComponent : ComponentBase where TRole : IRoleResponse { - #region PARAMETERS - - [Parameter] public string? AdditionalName { get; set; } + #region SERVICES + + [Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!; #endregion + + #region PARAMETERS + + [Parameter] public required TRole Role { get; set; } + + #endregion + + + + #region FIELDS + + private PersonResponse? _person; + private Picture? _picture; + + #endregion + + + + #region PRIVATE METHODS + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + List endTasks = new List(); + + // STEP 0 + endTasks.AddRange( + [ + PersonsWebAPIService.GetPersonPhoto(Role.PersonId, data => + { + _picture = data; + StateHasChanged(); + }), + PersonsWebAPIService.GetPerson(Role.PersonId, data => + { + _person = data; + StateHasChanged(); + }) + ]); + + // END + await Task.WhenAll(endTasks); + } + } + + #endregion } \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor index 604aee1..ad41b4c 100644 --- a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor +++ b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor @@ -10,15 +10,21 @@ {
} - + + + + } + @if (!_allItemsLoaded) + { +
+ +
} -
- -
} else diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor.cs index 92d0736..a9809de 100644 --- a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor.cs @@ -72,8 +72,8 @@ public partial class RoleListComponent : ComponentBase where TRol { Query.After = 0; } - Query.After += _pageSize; } + Query.After += data.Count(); _rolesFetching = false; }); } From e1f3c754c1f3ed84af6d5e02904d57e99feb452a Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Sat, 19 Oct 2024 01:07:10 +0200 Subject: [PATCH 4/5] media page role panels finished --- .../CreatorRolesPanelComponent.razor | 10 +++++++++ .../CreatorRolesPanelComponent.razor.cs | 22 +++++++++++++++++++ .../CreatorRolesPanelComponent.razor.css | 0 3 files changed, 32 insertions(+) create mode 100644 WatchIt.Website/WatchIt.Website/Components/MediaPage/CreatorRolesPanelComponent.razor create mode 100644 WatchIt.Website/WatchIt.Website/Components/MediaPage/CreatorRolesPanelComponent.razor.cs create mode 100644 WatchIt.Website/WatchIt.Website/Components/MediaPage/CreatorRolesPanelComponent.razor.css diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/CreatorRolesPanelComponent.razor b/WatchIt.Website/WatchIt.Website/Components/MediaPage/CreatorRolesPanelComponent.razor new file mode 100644 index 0000000..875dc3c --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/MediaPage/CreatorRolesPanelComponent.razor @@ -0,0 +1,10 @@ +
+
+ Actors + +
+
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/CreatorRolesPanelComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/MediaPage/CreatorRolesPanelComponent.razor.cs new file mode 100644 index 0000000..4a98650 --- /dev/null +++ b/WatchIt.Website/WatchIt.Website/Components/MediaPage/CreatorRolesPanelComponent.razor.cs @@ -0,0 +1,22 @@ +using Microsoft.AspNetCore.Components; +using WatchIt.Website.Services.WebAPI.Media; + +namespace WatchIt.Website.Components.MediaPage; + +public partial class ActorRolesPanelComponent : ComponentBase +{ + #region SERVICES + + [Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!; + + #endregion + + + + #region PARAMETERS + + [Parameter] public string Class { get; set; } = string.Empty; + [Parameter] public required long Id { get; set; } + + #endregion +} \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/CreatorRolesPanelComponent.razor.css b/WatchIt.Website/WatchIt.Website/Components/MediaPage/CreatorRolesPanelComponent.razor.css new file mode 100644 index 0000000..e69de29 From 922da3670b8b7f3e031628eb8d45029854b5a651 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Sat, 19 Oct 2024 01:07:42 +0200 Subject: [PATCH 5/5] additional files --- .../CreatorRolesPanelComponent.razor | 36 ++++++++++--- .../CreatorRolesPanelComponent.razor.cs | 51 ++++++++++++++++++- .../Components/MediaPage/RoleComponent.razor | 12 +---- .../MediaPage/RoleListComponent.razor | 49 ++++++++++-------- .../MediaPage/RoleListComponent.razor.cs | 17 +++++++ .../WatchIt.Website/Pages/MediaPage.razor | 4 +- 6 files changed, 127 insertions(+), 42 deletions(-) diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/CreatorRolesPanelComponent.razor b/WatchIt.Website/WatchIt.Website/Components/MediaPage/CreatorRolesPanelComponent.razor index 875dc3c..faade18 100644 --- a/WatchIt.Website/WatchIt.Website/Components/MediaPage/CreatorRolesPanelComponent.razor +++ b/WatchIt.Website/WatchIt.Website/Components/MediaPage/CreatorRolesPanelComponent.razor @@ -1,10 +1,30 @@ +@using WatchIt.Common.Model.Roles + + +
-
- Actors - -
+ @if (_loaded) + { +
+ Creators +
+ + @foreach (RoleTypeResponse roleType in _roleTypes) + { + @roleType.Name + } + +
+ +
+ } + else + { + + }
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/CreatorRolesPanelComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/MediaPage/CreatorRolesPanelComponent.razor.cs index 4a98650..a9fcc8d 100644 --- a/WatchIt.Website/WatchIt.Website/Components/MediaPage/CreatorRolesPanelComponent.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Components/MediaPage/CreatorRolesPanelComponent.razor.cs @@ -1,13 +1,16 @@ using Microsoft.AspNetCore.Components; +using WatchIt.Common.Model.Roles; using WatchIt.Website.Services.WebAPI.Media; +using WatchIt.Website.Services.WebAPI.Roles; namespace WatchIt.Website.Components.MediaPage; -public partial class ActorRolesPanelComponent : ComponentBase +public partial class CreatorRolesPanelComponent : ComponentBase { #region SERVICES [Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!; + [Inject] private IRolesWebAPIService RolesWebAPIService { get; set; } = default!; #endregion @@ -19,4 +22,50 @@ public partial class ActorRolesPanelComponent : ComponentBase [Parameter] public required long Id { get; set; } #endregion + + + + #region FIELDS + + private RoleListComponent _roleListComponent; + + private bool _loaded; + + private IEnumerable _roleTypes; + private CreatorRoleMediaQueryParameters _query; + + #endregion + + + + #region PRIVATE METHODS + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + List endTasks = new List(); + + // STEP 0 + endTasks.AddRange( + [ + RolesWebAPIService.GetAllCreatorRoleTypes(successAction: data => _roleTypes = data) + ]); + + // END + await Task.WhenAll(endTasks); + _query = new CreatorRoleMediaQueryParameters { TypeId = _roleTypes.First().Id }; + + _loaded = true; + StateHasChanged(); + } + } + + private async Task CheckedTypeChanged(short value) + { + _query.TypeId = value; + await _roleListComponent.Refresh(); + } + + #endregion } \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleComponent.razor b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleComponent.razor index b132811..c1389a2 100644 --- a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleComponent.razor +++ b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleComponent.razor @@ -19,17 +19,7 @@ @(_person.Name)@(Role is ActorRoleResponse actor ? $" as {actor.Name}" : string.Empty) } -
+
diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor index ad41b4c..d5fce9b 100644 --- a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor +++ b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor @@ -3,29 +3,36 @@ @if (_loaded) { -
- @for (int i = 0; i < _roles.Count; i++) - { - if (i > 0) + if (_roles.Count > 0) + { +
+ @for (int i = 0; i < _roles.Count; i++) { -
+ if (i > 0) + { +
+ } + + + } - - - - } - @if (!_allItemsLoaded) - { -
- -
- } -
+ @if (!_allItemsLoaded) + { +
+ +
+ } +
+ } + else + { + No roles found + } } else { diff --git a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor.cs index a9809de..fcf3306 100644 --- a/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Components/MediaPage/RoleListComponent.razor.cs @@ -1,3 +1,4 @@ +using System.ComponentModel; using Microsoft.AspNetCore.Components; using WatchIt.Common.Model.Roles; using WatchIt.Common.Query; @@ -31,6 +32,22 @@ public partial class RoleListComponent : ComponentBase where TRol + #region PUBLIC METHODS + + public async Task Refresh() + { + _loaded = false; + _roles.Clear(); + Query.After = null; + Query.First = _pageSize; + await GetRoles(true); + _loaded = true; + } + + #endregion + + + #region PRIVATE METHODS protected override async Task OnAfterRenderAsync(bool firstRender) diff --git a/WatchIt.Website/WatchIt.Website/Pages/MediaPage.razor b/WatchIt.Website/WatchIt.Website/Pages/MediaPage.razor index 1e5ac8e..4785305 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/MediaPage.razor +++ b/WatchIt.Website/WatchIt.Website/Pages/MediaPage.razor @@ -207,7 +207,9 @@ else
- Test2 +
+ +