9 Commits

Author SHA1 Message Date
Maxime Adler
ab773f8b71 Fix wrong comportment
All checks were successful
Game Ideas build for PR / build_test (pull_request) Successful in 1m9s
2025-05-13 14:03:42 +02:00
Maxime Adler
78e67796e5 Working update game 2025-05-13 13:26:38 +02:00
Maxime Adler
e78f29ffac Working frontend update
All checks were successful
Game Ideas build for PR / build_test (pull_request) Successful in 43s
2025-05-13 11:09:34 +02:00
Maxime Adler
5d30c2353e Update game
All checks were successful
Game Ideas build for PR / build_test (pull_request) Successful in 50s
2025-05-12 16:25:28 +02:00
Maxime Adler
14dc1928bc Delete game
All checks were successful
Game Ideas build for PR / build_test (pull_request) Successful in 43s
2025-05-12 13:08:23 +02:00
Maxime Adler
bb42aa6dc1 Fix style for detail row option
All checks were successful
Game Ideas build for PR / build_test (pull_request) Successful in 55s
2025-05-12 11:35:22 +02:00
2fbcaa8f29 Add more action for game row
All checks were successful
Game Ideas build for PR / build_test (pull_request) Successful in 1m3s
2025-05-09 02:22:42 +02:00
fbf72db734 update css in user row 2025-05-09 01:42:54 +02:00
1da3e1f0a0 Add game add button in detail 2025-05-09 01:30:50 +02:00
40 changed files with 199 additions and 310 deletions

View File

@@ -3,4 +3,10 @@
<div class="page"> <div class="page">
@Body @Body
</div>
<div class="background">
<span class="orb red"></span>
<span class="orb blue"></span>
<span class="orb green"></span>
</div> </div>

View File

@@ -2,4 +2,47 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: 100%; height: 100%;
}
.orb {
position: absolute;
border-radius: 100%;
z-index: var(--index-orb);
}
.green {
width: 80vh;
height: 80vh;
top: -20vh;
background: #315941;
filter: blur(30vh);
}
.blue {
width: 80vw;
height: 80vw;
left: 10vw;
top: 50vh;
background: #3A4156;
filter: blur(30vh);
}
.red {
width: 100vh;
height: 100vh;
left: 60vw;
top: -40vh;
background: #593533;
filter: blur(30vh);
}
.background {
height: 100vh;
width: 100vw;
background: var(--background);
position: fixed;
overflow: hidden;
top: 0;
left: 0;
z-index: var(--index-background);
} }

View File

@@ -22,7 +22,7 @@ public partial class GameDetail : GameBaseComponent
private void HandleSubmitNewGame() private void HandleSubmitNewGame()
{ {
NavigationManager.NavigateTo("/Games"); NavigationManager.NavigateTo("/");
} }
private async Task FetchGameDetail() private async Task FetchGameDetail()
@@ -30,7 +30,6 @@ public partial class GameDetail : GameBaseComponent
try try
{ {
IsLoading = true; IsLoading = true;
StateHasChanged();
Game = await GameGateway.GetGameById(GameId); Game = await GameGateway.GetGameById(GameId);
} }
@@ -41,7 +40,6 @@ public partial class GameDetail : GameBaseComponent
finally finally
{ {
IsLoading = false; IsLoading = false;
StateHasChanged();
} }
} }
} }

View File

@@ -59,7 +59,6 @@ public partial class GameCreationForm
try try
{ {
IsLoading = true; IsLoading = true;
StateHasChanged();
int gameId; int gameId;
var authState = await AuthenticationState.GetAuthenticationStateAsync(); var authState = await AuthenticationState.GetAuthenticationStateAsync();
@@ -109,7 +108,6 @@ public partial class GameCreationForm
try try
{ {
IsLoading = true; IsLoading = true;
StateHasChanged();
GameDto = await GameGateway.GetGameById(gameId); GameDto = await GameGateway.GetGameById(gameId);
} }
@@ -120,8 +118,9 @@ public partial class GameCreationForm
finally finally
{ {
IsLoading = false; IsLoading = false;
EditContext = new(GameDto);
StateHasChanged();
} }
EditContext = new(GameDto);
StateHasChanged();
} }
} }

View File

@@ -34,7 +34,6 @@
grid-column: 2; grid-column: 2;
box-sizing: border-box; box-sizing: border-box;
color: var(--white); color: var(--white);
padding: 0 8px;
} }
::deep input[type="date"]::-webkit-calendar-picker-indicator { ::deep input[type="date"]::-webkit-calendar-picker-indicator {

View File

@@ -96,4 +96,16 @@
.tags, .storage { .tags, .storage {
display: none; display: none;
} }
}
@keyframes loading {
0% {
background: rgb(255, 255, 255, 0.05);
}
50% {
background: rgb(255, 255, 255, 0.2);
}
100% {
background: rgb(255, 255, 255, 0.05);
}
} }

View File

@@ -4,8 +4,6 @@
@using GameIdeas.BlazorApp.Shared.Constants @using GameIdeas.BlazorApp.Shared.Constants
@using GameIdeas.Shared.Dto @using GameIdeas.Shared.Dto
<NavigationLock OnBeforeInternalNavigation="HandleLocationChanged" />
<div class="advanced-filter-container" style="@(ExpandedFilter ? "display: flex" : "")"> <div class="advanced-filter-container" style="@(ExpandedFilter ? "display: flex" : "")">
<span class="title">@ResourcesKey.Filters</span> <span class="title">@ResourcesKey.Filters</span>
@@ -29,15 +27,15 @@
<SelectSearch TItem="int" Placeholder="@ResourcesKey.ReleaseDate" GetLabel="@(p => p.ToString())" <SelectSearch TItem="int" Placeholder="@ResourcesKey.ReleaseDate" GetLabel="@(p => p.ToString())"
@bind-Values=GameFilter.ReleaseYears @bind-Values:after=HandleValueChanged Theme="Theme" Items="Categories?.ReleaseYears" /> @bind-Values=GameFilter.ReleaseYears @bind-Values:after=HandleValueChanged Theme="Theme" Items="Categories?.ReleaseYears" />
<SelectSearch TItem="int" Placeholder="@ResourcesKey.StorageSize" GetLabel="@GetStorageSpaceLabel" OrderBy="@(item => item.ToString())" <SelectSearch TItem="int" Placeholder="@ResourcesKey.StorageSize" GetLabel="@GetStorageSpaceLabel"
@bind-Values=GameFilter.StorageSpaceIds @bind-Values:after=HandleValueChanged Theme="Theme" Items="@(Categories?.StorageSpaces?.Select(stor => stor.Id).ToList())" /> @bind-Values=GameFilter.StorageSpaceIds @bind-Values:after=HandleValueChanged Theme="Theme" Items="@(Categories?.StorageSpaces?.Select(stor => stor.Id).ToList())" />
<span class="title">@ResourcesKey.LastAdd</span> <span class="title">@ResourcesKey.LastAdd</span>
</div> </div>
<button type="button" class="open-filter" @onclick=HandleExpandFilterAsync> <button type="button" class="open-filter" @onclick=HandleExpandFilter>
@Icons.Filter @Icons.Filter
</button> </button>
<BackdropFilter @ref="BackdropFilter" OnClick="HandleBackdropFilterClickedAsync" CloseOnClick="true" <BackdropFilter @ref="BackdropFilter" OnClick="HandleBackdropFilterClicked" CloseOnClick="true"
AllowBodyScroll="false" Color="BackdropFilterColor.Overlay" /> AllowBodyScroll="false" Color="BackdropFilterColor.Overlay" />

View File

@@ -4,7 +4,6 @@ using GameIdeas.BlazorApp.Shared.Components.Select.Models;
using GameIdeas.Resources; using GameIdeas.Resources;
using GameIdeas.Shared.Dto; using GameIdeas.Shared.Dto;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Routing;
namespace GameIdeas.BlazorApp.Pages.Games.Filter; namespace GameIdeas.BlazorApp.Pages.Games.Filter;
@@ -49,24 +48,13 @@ public partial class AdvancedGameFilter
throw new ArgumentNullException(ResourcesKey.ErrorStorageSpaceLabel); throw new ArgumentNullException(ResourcesKey.ErrorStorageSpaceLabel);
} }
private void HandleExpandFilterAsync(Microsoft.AspNetCore.Components.Web.MouseEventArgs args) private void HandleExpandFilter(Microsoft.AspNetCore.Components.Web.MouseEventArgs args)
{ {
ExpandedFilter = true; ExpandedFilter = true;
BackdropFilter?.Show(); BackdropFilter?.Show();
} }
private void HandleBackdropFilterClicked()
private void HandleBackdropFilterClickedAsync()
{ {
ExpandedFilter = false; ExpandedFilter = false;
} }
private void HandleLocationChanged(LocationChangingContext locationContext)
{
if (ExpandedFilter)
{
ExpandedFilter = false;
BackdropFilter?.Hide();
locationContext.PreventNavigation();
}
}
} }

View File

@@ -1,4 +1,4 @@
@page "/Games" @page "/"
@using GameIdeas.BlazorApp.Pages.Games.Components @using GameIdeas.BlazorApp.Pages.Games.Components
@using GameIdeas.BlazorApp.Pages.Games.Filter @using GameIdeas.BlazorApp.Pages.Games.Filter
@using GameIdeas.BlazorApp.Shared.Components @using GameIdeas.BlazorApp.Shared.Components
@@ -23,20 +23,10 @@
<div class="content"> <div class="content">
@if (!IsLoading) @if (!IsLoading)
{ {
@if (GamesDto.NumberOfGames != 0) @foreach (var game in GamesDto)
{ {
<div class="games-number">@string.Format(ResourcesKey.GamesNumberFormat, GamesDto.NumberOfGames)</div> <GameRow GameDto="game" OnDelete="HandleDeleteGame" OnEdit="HandleEditGame" />
@foreach (var game in GamesDto.Games)
{
<GameRow GameDto="game" OnDelete="HandleDeleteGame" OnEdit="HandleEditGame" />
}
} }
else
{
<div class="no-games">@ResourcesKey.NoGames</div>
}
} }
else else
{ {

View File

@@ -12,7 +12,7 @@ public partial class Games : GameBaseComponent
{ {
private DisplayType DisplayType = DisplayType.List; private DisplayType DisplayType = DisplayType.List;
private GameFilterParams GameFilter = new(); private GameFilterParams GameFilter = new();
private GameListDto GamesDto = new(); private IEnumerable<GameDto> GamesDto = [];
private int CurrentPage; private int CurrentPage;
private Popup? DeletePopup; private Popup? DeletePopup;
private GameDto? GameToDelete; private GameDto? GameToDelete;
@@ -37,7 +37,6 @@ public partial class Games : GameBaseComponent
try try
{ {
IsLoading = displayLoader; IsLoading = displayLoader;
StateHasChanged();
GamesDto = await GameGateway.FetchGames(GameFilter, CurrentPage); GamesDto = await GameGateway.FetchGames(GameFilter, CurrentPage);
} }
@@ -48,7 +47,6 @@ public partial class Games : GameBaseComponent
finally finally
{ {
IsLoading = false; IsLoading = false;
StateHasChanged();
} }
} }
private async Task HandleFilterChanged(GameFilterParams args) private async Task HandleFilterChanged(GameFilterParams args)
@@ -93,7 +91,6 @@ public partial class Games : GameBaseComponent
try try
{ {
IsLoading = true; IsLoading = true;
StateHasChanged();
await GameGateway.DeleteGame(GameToDelete?.Id ?? 0); await GameGateway.DeleteGame(GameToDelete?.Id ?? 0);
await HandleFetchDatas(false); await HandleFetchDatas(false);

View File

@@ -35,7 +35,7 @@ public class GameGateway(IHttpClientService httpClientService) : IGameGateway
} }
} }
public async Task<GameListDto> FetchGames(GameFilterParams filterParams, int currentPage) public async Task<IEnumerable<GameDto>> FetchGames(GameFilterParams filterParams, int currentPage)
{ {
try try
{ {
@@ -52,11 +52,9 @@ public class GameGateway(IHttpClientService httpClientService) : IGameGateway
PropertyIds = filterParams.Properties?.Select(d => d.Id ?? 0).ToList(), PropertyIds = filterParams.Properties?.Select(d => d.Id ?? 0).ToList(),
ReleaseYears = filterParams.ReleaseYears, ReleaseYears = filterParams.ReleaseYears,
TagIds = filterParams.Tags?.Select(d => d.Id ?? 0).ToList(), TagIds = filterParams.Tags?.Select(d => d.Id ?? 0).ToList(),
SortPropertyName = filterParams.SortProperty?.PropertyName,
SortType = filterParams.SortType?.SortType
}; };
var result = await httpClientService.FetchDataAsync<GameListDto>(Endpoints.Game.Fetch(filter)); var result = await httpClientService.FetchDataAsync<IEnumerable<GameDto>>(Endpoints.Game.Fetch(filter));
return result ?? throw new InvalidOperationException(ResourcesKey.ErrorFetchGames); return result ?? throw new InvalidOperationException(ResourcesKey.ErrorFetchGames);
} }
catch (Exception) catch (Exception)

View File

@@ -7,7 +7,7 @@ public interface IGameGateway
{ {
Task<CategoriesDto> FetchCategories(); Task<CategoriesDto> FetchCategories();
Task<int> CreateGame(GameDetailDto game); Task<int> CreateGame(GameDetailDto game);
Task<GameListDto> FetchGames(GameFilterParams filter, int currentPage); Task<IEnumerable<GameDto>> FetchGames(GameFilterParams filter, int currentPage);
Task<GameDetailDto> GetGameById(int gameId); Task<GameDetailDto> GetGameById(int gameId);
Task<bool> DeleteGame(int gameIdToDelete); Task<bool> DeleteGame(int gameIdToDelete);
Task<int> UpdateGame(GameDetailDto gameDto); Task<int> UpdateGame(GameDetailDto gameDto);

View File

@@ -1,10 +0,0 @@
@page "/"
@inject NavigationManager navigationManager
@code {
protected override void OnInitialized()
{
navigationManager.NavigateTo("/Games");
}
}

View File

@@ -28,8 +28,6 @@ public partial class Login
try try
{ {
IsLoading = true; IsLoading = true;
StateHasChanged();
await AuthGateway.Login(UserDto); await AuthGateway.Login(UserDto);
} }
catch (Exception) catch (Exception)

View File

@@ -50,6 +50,6 @@
border-radius: 50%; border-radius: 50%;
border: 3px solid rgba(0, 0, 0, 0.2); border: 3px solid rgba(0, 0, 0, 0.2);
border-top-color: var(--white); border-top-color: var(--white);
animation: spin 1s linear infinite; animation: loading 1s linear infinite;
justify-self: center; justify-self: center;
} }

View File

@@ -14,7 +14,7 @@ public partial class UserMenu
{ {
ContentVisile = false; ContentVisile = false;
await AuthGateway.Logout(); await AuthGateway.Logout();
NavigationManager.NavigateTo("/Games"); NavigationManager.NavigateTo("/");
} }
private void HandleAccountClicked() private void HandleAccountClicked()

View File

@@ -54,3 +54,16 @@
fill: var(--yellow); fill: var(--yellow);
} }
@keyframes loading {
0% {
background: rgb(255, 255, 255, 0.05);
}
50% {
background: rgb(255, 255, 255, 0.2);
}
100% {
background: rgb(255, 255, 255, 0.05);
}
}

View File

@@ -16,7 +16,7 @@
<div class="header-content"> <div class="header-content">
<SearchInput Placeholder="@ResourcesKey.EnterUsername" @bind-Text="FilterParams.Name" @bind-Text:after=HandleFilterChanged /> <SearchInput Placeholder="@ResourcesKey.EnterUsername" @bind-Text="FilterParams.Name" @bind-Text:after=HandleFilterChanged />
<SelectSearch TItem="RoleDto" Placeholder="@ResourcesKey.Roles" @bind-Values="FilterParams.Roles" @bind-Values:after=HandleFilterChanged <SelectSearch TItem="RoleDto" Placeholder="@ResourcesKey.Roles" @bind-Values="FilterParams.Roles" @bind-Values:after=HandleFilterChanged
Items="Roles.ToList()" GetLabel="@(role => role.Name)" Theme="SelectTheme.Filter" /> Items="Roles.ToList()" GetLabel="@(role => role.Name)" Theme="SelectTheme.Filter" />
</div> </div>
</HeaderGameIdeas> </HeaderGameIdeas>
@@ -28,18 +28,9 @@
<div class="content"> <div class="content">
@if (!IsLoading) @if (!IsLoading)
{ {
@if (UserList.UsersCount != 0) @foreach (var user in UserList.Users ?? [])
{ {
<div class="user-number">@string.Format(ResourcesKey.UsersNumberFormat, UserList.UsersCount)</div> <UserRow User="user" Roles="Roles.ToList()" OnRemove="HandleOpenConfirmationPopup" OnSubmit="HandleUpdateUser" Validator="@(new UserUpdateValidator())" CanDelete=@(user.Id != currentUserId) />
@foreach (var user in UserList.Users ?? [])
{
<UserRow User="user" Roles="Roles.ToList()" OnRemove="HandleOpenConfirmationPopup" OnSubmit="HandleUpdateUser" Validator="@(new UserUpdateValidator())" CanDelete=@(user.Id != currentUserId) />
}
}
else
{
<div class="no-users">@ResourcesKey.NoUsers</div>
} }
} }
else else

View File

@@ -36,17 +36,18 @@ public partial class Users
} }
await FetchUsers(); await FetchData();
await FetchRoles();
await base.OnInitializedAsync(); await base.OnInitializedAsync();
} }
private async Task FetchUsers(bool displayLoading = true) private async Task FetchData(bool fetchRoles = true)
{ {
try try
{ {
IsLoading = displayLoading; IsLoading = true;
StateHasChanged();
if (fetchRoles)
Roles = await UserGateway.GetRoles();
UserList = await UserGateway.GetUsers(FilterParams, CurrentPage); UserList = await UserGateway.GetUsers(FilterParams, CurrentPage);
} }
@@ -57,27 +58,6 @@ public partial class Users
finally finally
{ {
IsLoading = false; IsLoading = false;
StateHasChanged();
}
}
private async Task FetchRoles()
{
try
{
IsLoading = true;
StateHasChanged();
Roles = await UserGateway.GetRoles();
}
catch (Exception)
{
throw;
}
finally
{
IsLoading = false;
StateHasChanged();
} }
} }
@@ -86,10 +66,9 @@ public partial class Users
try try
{ {
IsLoading = true; IsLoading = true;
StateHasChanged();
await UserGateway.CreateUser(user); await UserGateway.CreateUser(user);
await FetchUsers(); await FetchData(false);
} }
catch (Exception) catch (Exception)
{ {
@@ -98,9 +77,9 @@ public partial class Users
finally finally
{ {
IsLoading = false; IsLoading = false;
StateHasChanged();
UserAdd = new();
} }
UserAdd = new();
} }
private async Task HandleUpdateUser(UserDto user) private async Task HandleUpdateUser(UserDto user)
@@ -108,10 +87,9 @@ public partial class Users
try try
{ {
IsLoading = true; IsLoading = true;
StateHasChanged();
await UserGateway.UpdateUser(user); await UserGateway.UpdateUser(user);
await FetchUsers(); await FetchData(false);
} }
catch (Exception) catch (Exception)
{ {
@@ -120,7 +98,6 @@ public partial class Users
finally finally
{ {
IsLoading = false; IsLoading = false;
StateHasChanged();
} }
} }
@@ -136,10 +113,9 @@ public partial class Users
try try
{ {
IsLoading = true; IsLoading = true;
StateHasChanged();
await UserGateway.DeleteUser(UserDelete.Id); await UserGateway.DeleteUser(UserDelete.Id);
await FetchUsers(); await FetchData(false);
} }
catch (Exception) catch (Exception)
{ {
@@ -148,7 +124,6 @@ public partial class Users
finally finally
{ {
IsLoading = false; IsLoading = false;
StateHasChanged();
} }
UserDelete = null; UserDelete = null;
@@ -159,7 +134,7 @@ public partial class Users
} }
private async Task HandleFilterChanged() private async Task HandleFilterChanged()
{ {
await FetchUsers(false); await FetchData(false);
} }
private void HandleCancelPopupClicked() private void HandleCancelPopupClicked()
{ {

View File

@@ -19,3 +19,13 @@
height: 60px; height: 60px;
animation: spin 1s linear infinite; animation: spin 1s linear infinite;
} }
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}

View File

@@ -24,7 +24,6 @@ public class GameBaseComponent : ComponentBase
try try
{ {
IsLoading = true; IsLoading = true;
StateHasChanged();
Categories = await GameGateway.FetchCategories(); Categories = await GameGateway.FetchCategories();
} }
@@ -35,7 +34,6 @@ public class GameBaseComponent : ComponentBase
finally finally
{ {
IsLoading = false; IsLoading = false;
StateHasChanged();
} }
} }

View File

@@ -7,7 +7,6 @@
placeholder="@Placeholder" placeholder="@Placeholder"
disabled="@IsDisable" disabled="@IsDisable"
style="@(IsDisable ? "pointer-events: none" : "")" style="@(IsDisable ? "pointer-events: none" : "")"
onClick="this.select();"
@bind=@Text @bind=@Text
@bind:event="oninput" @bind:event="oninput"
@bind:after="HandleTextChanged" @bind:after="HandleTextChanged"

View File

@@ -26,7 +26,7 @@
height: 100%; height: 100%;
width: 100%; width: 100%;
padding: 0; padding: 0;
min-width: 0; min-width: 0;
} }
.clear-icon { .clear-icon {
@@ -34,7 +34,6 @@
min-width: 18px; min-width: 18px;
height: 18px; height: 18px;
width: 18px; width: 18px;
z-index: 800;
} }
.clear-icon:hover { .clear-icon:hover {

View File

@@ -4,10 +4,8 @@ public class SelectParams<TItem, THeader>
{ {
public List<TItem> Items { get; set; } = []; public List<TItem> Items { get; set; } = [];
public Func<TItem, string> GetItemLabel { get; set; } = _ => string.Empty; public Func<TItem, string> GetItemLabel { get; set; } = _ => string.Empty;
public Func<TItem, string>? GetItemOrder { get; set; }
public List<THeader> Headers { get; set; } = []; public List<THeader> Headers { get; set; } = [];
public Func<THeader, string> GetHeaderLabel { get; set; } = _ => string.Empty; public Func<THeader, string> GetHeaderLabel { get; set; } = _ => string.Empty;
public Func<THeader, string>? GetHeaderOrder { get; set; }
public Func<string, TItem>? AddItem { get; set; } public Func<string, TItem>? AddItem { get; set; }
} }

View File

@@ -27,7 +27,7 @@
@if (Params.Headers != null) @if (Params.Headers != null)
{ {
@foreach (var header in GetHeaders()) @foreach (var header in (HeaderValues ?? []).UnionBy(Params.Headers, Params.GetHeaderLabel).OrderBy(Params.GetHeaderLabel))
{ {
<SelectRow IsSelected=@(HeaderValues?.Contains(header)) <SelectRow IsSelected=@(HeaderValues?.Contains(header))
Label="@Params.GetHeaderLabel(header)" Theme=Theme Label="@Params.GetHeaderLabel(header)" Theme=Theme
@@ -42,7 +42,7 @@
@if (Params.Items != null) @if (Params.Items != null)
{ {
@foreach (var item in GetItems()) @foreach (var item in (Values ?? []).UnionBy(Params.Items, Params.GetItemLabel).OrderBy(Params.GetItemLabel))
{ {
<SelectRow IsSelected=@(Values?.Contains(item)) <SelectRow IsSelected=@(Values?.Contains(item))
Label="@Params.GetItemLabel(item)" Theme=Theme Label="@Params.GetItemLabel(item)" Theme=Theme

View File

@@ -101,12 +101,4 @@ public partial class Select<TItem, THeader>
await ValuesChanged.InvokeAsync(Values); await ValuesChanged.InvokeAsync(Values);
} }
} }
private List<THeader> GetHeaders() => [.. (HeaderValues ?? [])
.UnionBy(Params.Headers, Params.GetHeaderLabel)
.OrderBy(Params.GetHeaderOrder ?? Params.GetHeaderLabel)];
private List<TItem> GetItems() => [.. (Values ?? [])
.UnionBy(Params.Items, Params.GetItemLabel)
.OrderBy(Params.GetItemOrder ?? Params.GetItemLabel)];
} }

View File

@@ -22,6 +22,8 @@
overflow: hidden; overflow: hidden;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
animation-name: fade-in;
animation-duration: 0.2s;
} }
.line { .line {

View File

@@ -5,12 +5,12 @@
@typeparam TItem @typeparam TItem
<Select @ref=Select TItem="TItem" THeader="string" Theme="Theme" Type="SelectType" DisableClicked=true <Select @ref=Select TItem="TItem" THeader="string" Theme="Theme" Type="SelectType"
Params="SelectParams" Values=Values ValuesChanged="HandleValuesChanged" QuickAdd=QuickAdd> Params="SelectParams" Values=Values ValuesChanged="HandleValuesChanged" QuickAdd=QuickAdd>
<div class="@SelectHelper.GetClassFromTheme(Theme)"> <div class="@SelectHelper.GetClassFromTheme(Theme)">
<SearchInput @ref=SearchInput Icon="SearchInputIcon.Dropdown" Placeholder="@Placeholder" <SearchInput @ref=SearchInput Icon="SearchInputIcon.Dropdown" Placeholder="@Placeholder"
TextChanged="HandleTextChanged" ClearClicked="HandleClearClicked" IsDisable=false TextChanged="HandleClearClicked" ClearClicked="HandleClearClicked" IsDisable=QuickAdd
FocusIn="HandleFocusIn" SearchClicked="HandleFocusIn" /> FocusIn="HandleFocusIn" SearchClicked="HandleFocusIn" />
</div> </div>

View File

@@ -1,4 +1,3 @@
using GameIdeas.BlazorApp.Pages.Games;
using GameIdeas.BlazorApp.Shared.Components.Search; using GameIdeas.BlazorApp.Shared.Components.Search;
using GameIdeas.BlazorApp.Shared.Components.Select; using GameIdeas.BlazorApp.Shared.Components.Select;
using GameIdeas.BlazorApp.Shared.Components.Select.Models; using GameIdeas.BlazorApp.Shared.Components.Select.Models;
@@ -11,7 +10,6 @@ public partial class SelectSearch<TItem>
[Parameter] public SelectTheme Theme { get; set; } [Parameter] public SelectTheme Theme { get; set; }
[Parameter] public List<TItem> Items { get; set; } = []; [Parameter] public List<TItem> Items { get; set; } = [];
[Parameter] public Func<TItem, string> GetLabel { get; set; } = _ => string.Empty; [Parameter] public Func<TItem, string> GetLabel { get; set; } = _ => string.Empty;
[Parameter] public Func<TItem, string>? OrderBy { get; set; }
[Parameter] public List<TItem> Values { get; set; } = []; [Parameter] public List<TItem> Values { get; set; } = [];
[Parameter] public EventCallback<List<TItem>> ValuesChanged { get; set; } [Parameter] public EventCallback<List<TItem>> ValuesChanged { get; set; }
[Parameter] public string Placeholder { get; set; } = string.Empty; [Parameter] public string Placeholder { get; set; } = string.Empty;
@@ -29,7 +27,6 @@ public partial class SelectSearch<TItem>
{ {
Items = Items, Items = Items,
GetItemLabel = GetLabel, GetItemLabel = GetLabel,
GetItemOrder = OrderBy,
AddItem = AddItem AddItem = AddItem
}; };
@@ -38,7 +35,7 @@ public partial class SelectSearch<TItem>
protected override void OnAfterRender(bool firstRender) protected override void OnAfterRender(bool firstRender)
{ {
if (firstRender && Values != null) if (Values != null)
{ {
SearchInput?.SetText(string.Join(", ", Values.Select(GetLabel))); SearchInput?.SetText(string.Join(", ", Values.Select(GetLabel)));
} }
@@ -54,37 +51,11 @@ public partial class SelectSearch<TItem>
private async Task HandleClearClicked() private async Task HandleClearClicked()
{ {
Values = []; Values = [];
Select?.Close(); await ValuesChanged.InvokeAsync([.. Values]);
SearchInput?.SetText(string.Empty);
await ValuesChanged.InvokeAsync([]);
} }
private void HandleFocusIn() private void HandleFocusIn()
{ {
Select?.Open(); Select?.Open();
} }
private void HandleTextChanged(string args)
{
if (!string.IsNullOrEmpty(args))
{
var keywords = args
.Split([' '], StringSplitOptions.RemoveEmptyEntries)
.Select(k => k.Trim())
.ToArray() ?? [];
SelectParams.Items = [.. Items
.Where(game => keywords.All(
kw => SelectParams.GetItemLabel(game).Contains(kw, StringComparison.OrdinalIgnoreCase)
))
.OrderBy(game => keywords.Min(kw =>
SelectParams.GetItemLabel(game).IndexOf(kw, StringComparison.OrdinalIgnoreCase)
))
.ThenBy(game => SelectParams.GetItemLabel(game).Length)];
}
else
{
SelectParams.Items = Items;
SearchInput?.SetText(string.Join(", ", Values?.Select(GetLabel) ?? []));
}
}
} }

View File

@@ -82,20 +82,64 @@ html, body, #app {
} }
.loading-progress { .loading-progress {
display: flex; position: relative;
width: 100vw; display: block;
height: 100vh; width: 8rem;
justify-content: center; height: 8rem;
align-items: center; margin: 20vh auto 1rem auto;
animation: loading-background 4s linear infinite;
} }
.loading-progress > #loading-icon { .loading-progress circle {
max-width: 200px; fill: none;
max-height: 200px; stroke: #e0e0e0;
animation: loading-icon 4s ease-in-out infinite; stroke-width: 0.6rem;
transform-origin: 50% 50%;
transform: rotate(-90deg);
} }
.loading-progress circle:last-child {
stroke: #1b6ec2;
stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
transition: stroke-dasharray 0.05s ease-in-out;
}
.loading-progress-text {
color: #000;
position: absolute;
text-align: center;
font-weight: bold;
inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}
.loading-progress-text:after {
content: var(--blazor-load-percentage-text, "Loading");
}
code {
color: #c02d76;
}
.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
color: var(--bs-secondary-color);
text-align: end;
}
.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
text-align: start;
}
:focus-visible {
outline: none;
}
.expand-col-2 {
grid-column: 1 / 3;
}
.expand-row-2 {
grid-row: 1 / 3;
}
.body-sm { .body-sm {
color: #ccc color: #ccc
} }
@@ -114,59 +158,14 @@ html, body, #app {
text-decoration: none; text-decoration: none;
} }
:focus-visible {
outline: none;
}
@keyframes loading-background { @keyframes fade-in {
0% { 0% {opacity: 0}
background: rgb(0, 0, 0, 0.2); 100% {opacity: 1}
}
50% {
background: rgb(0, 0, 0, 0.3);
}
100% {
background: rgb(0, 0, 0, 0.2);
}
}
@keyframes loading-icon {
0% {
transform: scale(1);
}
50% {
transform: scale(0.95);
}
100% {
transform: scale(1);
}
} }
@keyframes loading { @keyframes loading {
0% { to {
background: rgb(255, 255, 255, 0.05);
}
50% {
background: rgb(255, 255, 255, 0.2);
}
100% {
background: rgb(255, 255, 255, 0.05);
}
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg); transform: rotate(360deg);
} }
} }

View File

@@ -1,42 +0,0 @@
.orb {
position: absolute;
border-radius: 100%;
z-index: var(--index-orb);
}
.green {
width: 80vh;
height: 80vh;
top: -20vh;
background: #315941;
filter: blur(30vh);
}
.blue {
width: 80vw;
height: 80vw;
left: 10vw;
top: 50vh;
background: #3A4156;
filter: blur(30vh);
}
.red {
width: 100vh;
height: 100vh;
left: 60vw;
top: -40vh;
background: #593533;
filter: blur(30vh);
}
#background {
height: 100vh;
width: 100vw;
background: var(--background);
position: fixed;
overflow: hidden;
top: 0;
left: 0;
z-index: var(--index-background);
}

View File

@@ -7,22 +7,17 @@
<title>Game Ideas</title> <title>Game Ideas</title>
<base href="/" /> <base href="/" />
<link rel="stylesheet" href="css/app.css" /> <link rel="stylesheet" href="css/app.css" />
<link rel="stylesheet" href="css/background.css" />
<link rel="icon" type="image/png" href="icon.png" /> <link rel="icon" type="image/png" href="icon.png" />
<link href="GameIdeas.BlazorApp.styles.css" rel="stylesheet" /> <link href="GameIdeas.BlazorApp.styles.css" rel="stylesheet" />
</head> </head>
<body> <body>
<div id="app"> <div id="app">
<div class="loading-progress"> <svg class="loading-progress">
<img src="icon.png" alt="" id="loading-icon"> <circle r="40%" cx="50%" cy="50%" />
</div> <circle r="40%" cx="50%" cy="50%" />
</div> </svg>
<div class="loading-progress-text"></div>
<div id="background">
<span class="orb red"></span>
<span class="orb blue"></span>
<span class="orb green"></span>
</div> </div>
<div id="blazor-error-ui"> <div id="blazor-error-ui">
@@ -30,7 +25,6 @@
<a href="." class="reload">Reload</a> <a href="." class="reload">Reload</a>
<span class="dismiss">🗙</span> <span class="dismiss">🗙</span>
</div> </div>
<script src="_framework/blazor.webassembly.js"></script> <script src="_framework/blazor.webassembly.js"></script>
<script src="Shared/Components/BackdropFilter/BackdropFilter.razor.js"></script> <script src="Shared/Components/BackdropFilter/BackdropFilter.razor.js"></script>
<script src="Pages/Games/Components/GameCreationForm.razor.js"></script> <script src="Pages/Games/Components/GameCreationForm.razor.js"></script>

View File

@@ -74,10 +74,6 @@ public class Translations (TranslationService translationService)
public string Detail => translationService.Translate(nameof(Detail)); public string Detail => translationService.Translate(nameof(Detail));
public string Edit => translationService.Translate(nameof(Edit)); public string Edit => translationService.Translate(nameof(Edit));
public string Delete => translationService.Translate(nameof(Delete)); public string Delete => translationService.Translate(nameof(Delete));
public string NoGames => translationService.Translate(nameof(NoGames));
public string NoUsers => translationService.Translate(nameof(NoUsers));
public string GamesNumberFormat => translationService.Translate(nameof(GamesNumberFormat));
public string UsersNumberFormat => translationService.Translate(nameof(UsersNumberFormat));
} }
public static class ResourcesKey public static class ResourcesKey
@@ -160,8 +156,4 @@ public static class ResourcesKey
public static string Detail => _instance?.Detail ?? throw new InvalidOperationException("ResourcesKey.Detail is not initialized."); public static string Detail => _instance?.Detail ?? throw new InvalidOperationException("ResourcesKey.Detail is not initialized.");
public static string Edit => _instance?.Edit ?? throw new InvalidOperationException("ResourcesKey.Edit is not initialized."); public static string Edit => _instance?.Edit ?? throw new InvalidOperationException("ResourcesKey.Edit is not initialized.");
public static string Delete => _instance?.Delete ?? throw new InvalidOperationException("ResourcesKey.Delete is not initialized."); public static string Delete => _instance?.Delete ?? throw new InvalidOperationException("ResourcesKey.Delete is not initialized.");
public static string NoGames => _instance?.NoGames ?? throw new InvalidOperationException("ResourcesKey.NoGames is not initialized.");
public static string NoUsers => _instance?.NoUsers ?? throw new InvalidOperationException("ResourcesKey.NoUsers is not initialized.");
public static string GamesNumberFormat => _instance?.GamesNumberFormat ?? throw new InvalidOperationException("ResourcesKey.GamesNumberFormat is not initialized.");
public static string UsersNumberFormat => _instance?.UsersNumberFormat ?? throw new InvalidOperationException("ResourcesKey.UsersNumberFormat is not initialized.");
} }

View File

@@ -22,7 +22,7 @@ public class GlobalConstants
public const int API_PORT = 8000; public const int API_PORT = 8000;
public const string SUB_DOMAIN_NAME = "api-"; public const string SUB_DOMAIN_NAME = "api-";
public const double DELAY_INPUT_MS = 450; public const double DELAY_INPUT_MS = 500;
public const int MAX_DESCRIPTION_LENGTH = 350; public const int MAX_DESCRIPTION_LENGTH = 350;
} }

View File

@@ -1,7 +0,0 @@
namespace GameIdeas.Shared.Dto;
public class GameListDto
{
public IEnumerable<GameDto> Games { get; set; } = [];
public int NumberOfGames { get; set; }
}

View File

@@ -17,7 +17,7 @@ public class GameController(
private readonly ILogger<GameController> logger = loggerFactory.CreateLogger<GameController>(); private readonly ILogger<GameController> logger = loggerFactory.CreateLogger<GameController>();
[HttpGet] [HttpGet]
public async Task<ActionResult<GameListDto>> SearchGames([FromQuery] GameFilterDto filter) public async Task<ActionResult<IEnumerable<GameDto>>> SearchGames([FromQuery] GameFilterDto filter)
{ {
try try
{ {

View File

@@ -69,9 +69,5 @@
"ReadLess": "Réduire", "ReadLess": "Réduire",
"Detail": "Détail", "Detail": "Détail",
"Edit": "Modifier", "Edit": "Modifier",
"Delete": "Supprimer", "Delete": "Supprimer"
"NoGames": "Pas de jeux disponible",
"NoUsers": "Pas d'utilisateurs disponible",
"GamesNumberFormat": "Nombre de jeux : {0}",
"UsersNumberFormat": "Nombre d'utilisateurs : {0}"
} }

View File

@@ -12,7 +12,7 @@ namespace GameIdeas.WebAPI.Services.Games;
public class GameReadService(GameIdeasContext context, IMapper mapper, ICategoryService categoryService) : IGameReadService public class GameReadService(GameIdeasContext context, IMapper mapper, ICategoryService categoryService) : IGameReadService
{ {
public async Task<GameListDto> GetGames(GameFilterDto filter) public async Task<IEnumerable<GameDto>> GetGames(GameFilterDto filter)
{ {
var query = context.Games var query = context.Games
.Include(g => g.GamePlatforms).ThenInclude(gp => gp.Platform) .Include(g => g.GamePlatforms).ThenInclude(gp => gp.Platform)
@@ -26,19 +26,13 @@ public class GameReadService(GameIdeasContext context, IMapper mapper, ICategory
ApplyOrder(ref query, filter); ApplyOrder(ref query, filter);
var games = await query.ToListAsync(); var games = await query.Skip((filter.CurrentPage - 1) * GlobalConstants.NUMBER_PER_PAGE)
.Take(GlobalConstants.NUMBER_PER_PAGE)
.ToListAsync();
ApplyStaticFilter(ref games, filter); ApplyStaticFilter(ref games, filter);
games = [.. games return mapper.Map<IEnumerable<GameDto>>(games);
.Skip((filter.CurrentPage - 1) * GlobalConstants.NUMBER_PER_PAGE)
.Take(GlobalConstants.NUMBER_PER_PAGE)];
return new()
{
Games = mapper.Map<IEnumerable<GameDto>>(games),
NumberOfGames = games.Count
};
} }
public async Task<GameDetailDto> GetGameById(int gameId) public async Task<GameDetailDto> GetGameById(int gameId)

View File

@@ -4,6 +4,6 @@ namespace GameIdeas.WebAPI.Services.Games;
public interface IGameReadService public interface IGameReadService
{ {
Task<GameListDto> GetGames(GameFilterDto filter); Task<IEnumerable<GameDto>> GetGames(GameFilterDto filter);
Task<GameDetailDto> GetGameById(int gameId); Task<GameDetailDto> GetGameById(int gameId);
} }

View File

@@ -33,9 +33,8 @@ public class UserReadService(
.OrderBy(u => u.UserName) .OrderBy(u => u.UserName)
.ToListAsync(); .ToListAsync();
ApplyStaticFilter(ref users, filter);
var count = users.Count; var count = users.Count;
ApplyStaticFilter(ref users, filter);
var usersDto = mapper.Map<IEnumerable<UserDto>>(users); var usersDto = mapper.Map<IEnumerable<UserDto>>(users);
usersDto = await ApplyRoles(usersDto, filter); usersDto = await ApplyRoles(usersDto, filter);