Compare commits
4 Commits
edd3ac78de
...
feature/fi
| Author | SHA1 | Date | |
|---|---|---|---|
| 36360efa6f | |||
| 564cadb945 | |||
| a1cc9dec99 | |||
| 1baa2a73fe |
13
src/GameIdeas/.idea/.idea.GameIdeas/.idea/.gitignore
generated
vendored
Normal file
13
src/GameIdeas/.idea/.idea.GameIdeas/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Rider ignored files
|
||||||
|
/projectSettingsUpdater.xml
|
||||||
|
/.idea.GameIdeas.iml
|
||||||
|
/modules.xml
|
||||||
|
/contentModel.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
8
src/GameIdeas/.idea/.idea.GameIdeas/.idea/indexLayout.xml
generated
Normal file
8
src/GameIdeas/.idea/.idea.GameIdeas/.idea/indexLayout.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="UserContentModel">
|
||||||
|
<attachedFolders />
|
||||||
|
<explicitIncludes />
|
||||||
|
<explicitExcludes />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
7
src/GameIdeas/.idea/.idea.GameIdeas/.idea/vcs.xml
generated
Normal file
7
src/GameIdeas/.idea/.idea.GameIdeas/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
51
src/GameIdeas/.vscode/launch.json
vendored
Normal file
51
src/GameIdeas/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"dotNetConfig": {},
|
||||||
|
"name": "Debug Blazor Application",
|
||||||
|
"type": "blazorwasm",
|
||||||
|
"request": "launch",
|
||||||
|
"browser": "chrome",
|
||||||
|
"cwd": "${workspaceFolder}/Client/GameIdeas.BlazorApp",
|
||||||
|
"url": "http://localhost:5172",
|
||||||
|
"presentation": {
|
||||||
|
"group": "group 2: Single",
|
||||||
|
"order": 2
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Debug API Server",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "launch",
|
||||||
|
"preLaunchTask": "Build API Server",
|
||||||
|
"program": "${workspaceFolder}/Server/GameIdeas.WebAPI/bin/Debug/net9.0/GameIdeas.WebAPI.dll",
|
||||||
|
"cwd": "${workspaceFolder}/Server/GameIdeas.WebAPI",
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"env": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
},
|
||||||
|
"presentation": {
|
||||||
|
"group": "group 2: Single",
|
||||||
|
"order": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"compounds": [
|
||||||
|
{
|
||||||
|
"name": "Launch GameIdeas",
|
||||||
|
"configurations": [
|
||||||
|
"Debug API Server",
|
||||||
|
"Debug Blazor Application"
|
||||||
|
],
|
||||||
|
"stopAll": true,
|
||||||
|
"presentation": {
|
||||||
|
"group": "group 1: Group",
|
||||||
|
"order": 1
|
||||||
|
},
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
27
src/GameIdeas/.vscode/tasks.json
vendored
Normal file
27
src/GameIdeas/.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"type": "shell",
|
||||||
|
"command": "dotnet build",
|
||||||
|
"label": "Build API Server",
|
||||||
|
"isBackground": true,
|
||||||
|
"options": {
|
||||||
|
"cwd": "${workspaceFolder}"
|
||||||
|
},
|
||||||
|
"problemMatcher":{
|
||||||
|
"pattern": {
|
||||||
|
"regexp": "^.*$",
|
||||||
|
"file": 0,
|
||||||
|
"location": 1,
|
||||||
|
"message": 2
|
||||||
|
},
|
||||||
|
"background": {
|
||||||
|
"activeOnStart": true,
|
||||||
|
"beginsPattern": ".*",
|
||||||
|
"endsPattern": "Compiled|Failed|compiled|failed|ready"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -3,10 +3,4 @@
|
|||||||
|
|
||||||
<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>
|
||||||
@@ -2,47 +2,4 @@
|
|||||||
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);
|
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,7 @@ public partial class GameDetail : GameBaseComponent
|
|||||||
|
|
||||||
private void HandleSubmitNewGame()
|
private void HandleSubmitNewGame()
|
||||||
{
|
{
|
||||||
NavigationManager.NavigateTo("/");
|
NavigationManager.NavigateTo("/Games");
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task FetchGameDetail()
|
private async Task FetchGameDetail()
|
||||||
@@ -30,6 +30,7 @@ public partial class GameDetail : GameBaseComponent
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
IsLoading = true;
|
IsLoading = true;
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
Game = await GameGateway.GetGameById(GameId);
|
Game = await GameGateway.GetGameById(GameId);
|
||||||
}
|
}
|
||||||
@@ -40,6 +41,7 @@ public partial class GameDetail : GameBaseComponent
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
IsLoading = false;
|
IsLoading = false;
|
||||||
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -59,6 +59,7 @@ 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();
|
||||||
@@ -108,6 +109,7 @@ public partial class GameCreationForm
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
IsLoading = true;
|
IsLoading = true;
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
GameDto = await GameGateway.GetGameById(gameId);
|
GameDto = await GameGateway.GetGameById(gameId);
|
||||||
}
|
}
|
||||||
@@ -118,9 +120,8 @@ public partial class GameCreationForm
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
IsLoading = false;
|
IsLoading = false;
|
||||||
|
EditContext = new(GameDto);
|
||||||
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
EditContext = new(GameDto);
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,6 +34,7 @@
|
|||||||
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 {
|
||||||
|
|||||||
@@ -96,16 +96,4 @@
|
|||||||
.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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,8 @@
|
|||||||
@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>
|
||||||
|
|
||||||
@@ -27,15 +29,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"
|
<SelectSearch TItem="int" Placeholder="@ResourcesKey.StorageSize" GetLabel="@GetStorageSpaceLabel" OrderBy="@(item => item.ToString())"
|
||||||
@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=HandleExpandFilter>
|
<button type="button" class="open-filter" @onclick=HandleExpandFilterAsync>
|
||||||
@Icons.Filter
|
@Icons.Filter
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<BackdropFilter @ref="BackdropFilter" OnClick="HandleBackdropFilterClicked" CloseOnClick="true"
|
<BackdropFilter @ref="BackdropFilter" OnClick="HandleBackdropFilterClickedAsync" CloseOnClick="true"
|
||||||
AllowBodyScroll="false" Color="BackdropFilterColor.Overlay" />
|
AllowBodyScroll="false" Color="BackdropFilterColor.Overlay" />
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ 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;
|
||||||
|
|
||||||
@@ -48,13 +49,24 @@ public partial class AdvancedGameFilter
|
|||||||
|
|
||||||
throw new ArgumentNullException(ResourcesKey.ErrorStorageSpaceLabel);
|
throw new ArgumentNullException(ResourcesKey.ErrorStorageSpaceLabel);
|
||||||
}
|
}
|
||||||
private void HandleExpandFilter(Microsoft.AspNetCore.Components.Web.MouseEventArgs args)
|
private void HandleExpandFilterAsync(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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
@page "/"
|
@page "/Games"
|
||||||
@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,10 +23,20 @@
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
@if (!IsLoading)
|
@if (!IsLoading)
|
||||||
{
|
{
|
||||||
@foreach (var game in GamesDto)
|
@if (GamesDto.NumberOfGames != 0)
|
||||||
{
|
{
|
||||||
<GameRow GameDto="game" OnDelete="HandleDeleteGame" OnEdit="HandleEditGame" />
|
<div class="games-number">@string.Format(ResourcesKey.GamesNumberFormat, GamesDto.NumberOfGames)</div>
|
||||||
|
|
||||||
|
@foreach (var game in GamesDto.Games)
|
||||||
|
{
|
||||||
|
<GameRow GameDto="game" OnDelete="HandleDeleteGame" OnEdit="HandleEditGame" />
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="no-games">@ResourcesKey.NoGames</div>
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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 IEnumerable<GameDto> GamesDto = [];
|
private GameListDto GamesDto = new();
|
||||||
private int CurrentPage;
|
private int CurrentPage;
|
||||||
private Popup? DeletePopup;
|
private Popup? DeletePopup;
|
||||||
private GameDto? GameToDelete;
|
private GameDto? GameToDelete;
|
||||||
@@ -37,6 +37,7 @@ public partial class Games : GameBaseComponent
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
IsLoading = displayLoader;
|
IsLoading = displayLoader;
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
GamesDto = await GameGateway.FetchGames(GameFilter, CurrentPage);
|
GamesDto = await GameGateway.FetchGames(GameFilter, CurrentPage);
|
||||||
}
|
}
|
||||||
@@ -47,6 +48,7 @@ public partial class Games : GameBaseComponent
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
IsLoading = false;
|
IsLoading = false;
|
||||||
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private async Task HandleFilterChanged(GameFilterParams args)
|
private async Task HandleFilterChanged(GameFilterParams args)
|
||||||
@@ -91,6 +93,7 @@ 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);
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class GameGateway(IHttpClientService httpClientService) : IGameGateway
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<GameDto>> FetchGames(GameFilterParams filterParams, int currentPage)
|
public async Task<GameListDto> FetchGames(GameFilterParams filterParams, int currentPage)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -52,9 +52,11 @@ 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<IEnumerable<GameDto>>(Endpoints.Game.Fetch(filter));
|
var result = await httpClientService.FetchDataAsync<GameListDto>(Endpoints.Game.Fetch(filter));
|
||||||
return result ?? throw new InvalidOperationException(ResourcesKey.ErrorFetchGames);
|
return result ?? throw new InvalidOperationException(ResourcesKey.ErrorFetchGames);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ public interface IGameGateway
|
|||||||
{
|
{
|
||||||
Task<CategoriesDto> FetchCategories();
|
Task<CategoriesDto> FetchCategories();
|
||||||
Task<int> CreateGame(GameDetailDto game);
|
Task<int> CreateGame(GameDetailDto game);
|
||||||
Task<IEnumerable<GameDto>> FetchGames(GameFilterParams filter, int currentPage);
|
Task<GameListDto> 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);
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
@page "/"
|
||||||
|
|
||||||
|
@inject NavigationManager navigationManager
|
||||||
|
|
||||||
|
@code {
|
||||||
|
protected override void OnInitialized()
|
||||||
|
{
|
||||||
|
navigationManager.NavigateTo("/Games");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,6 +28,8 @@ public partial class Login
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
IsLoading = true;
|
IsLoading = true;
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
await AuthGateway.Login(UserDto);
|
await AuthGateway.Login(UserDto);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
|
|||||||
@@ -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: loading 1s linear infinite;
|
animation: spin 1s linear infinite;
|
||||||
justify-self: center;
|
justify-self: center;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public partial class UserMenu
|
|||||||
{
|
{
|
||||||
ContentVisile = false;
|
ContentVisile = false;
|
||||||
await AuthGateway.Logout();
|
await AuthGateway.Logout();
|
||||||
NavigationManager.NavigateTo("/");
|
NavigationManager.NavigateTo("/Games");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleAccountClicked()
|
private void HandleAccountClicked()
|
||||||
|
|||||||
@@ -54,16 +54,3 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -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,9 +28,18 @@
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
@if (!IsLoading)
|
@if (!IsLoading)
|
||||||
{
|
{
|
||||||
@foreach (var user in UserList.Users ?? [])
|
@if (UserList.UsersCount != 0)
|
||||||
{
|
{
|
||||||
<UserRow User="user" Roles="Roles.ToList()" OnRemove="HandleOpenConfirmationPopup" OnSubmit="HandleUpdateUser" Validator="@(new UserUpdateValidator())" CanDelete=@(user.Id != currentUserId) />
|
<div class="user-number">@string.Format(ResourcesKey.UsersNumberFormat, UserList.UsersCount)</div>
|
||||||
|
|
||||||
|
@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
|
||||||
|
|||||||
@@ -36,18 +36,17 @@ public partial class Users
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
await FetchData();
|
await FetchUsers();
|
||||||
|
await FetchRoles();
|
||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task FetchData(bool fetchRoles = true)
|
private async Task FetchUsers(bool displayLoading = true)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IsLoading = true;
|
IsLoading = displayLoading;
|
||||||
|
StateHasChanged();
|
||||||
if (fetchRoles)
|
|
||||||
Roles = await UserGateway.GetRoles();
|
|
||||||
|
|
||||||
UserList = await UserGateway.GetUsers(FilterParams, CurrentPage);
|
UserList = await UserGateway.GetUsers(FilterParams, CurrentPage);
|
||||||
}
|
}
|
||||||
@@ -58,6 +57,27 @@ 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,9 +86,10 @@ public partial class Users
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
IsLoading = true;
|
IsLoading = true;
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
await UserGateway.CreateUser(user);
|
await UserGateway.CreateUser(user);
|
||||||
await FetchData(false);
|
await FetchUsers();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
@@ -77,9 +98,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)
|
||||||
@@ -87,9 +108,10 @@ public partial class Users
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
IsLoading = true;
|
IsLoading = true;
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
await UserGateway.UpdateUser(user);
|
await UserGateway.UpdateUser(user);
|
||||||
await FetchData(false);
|
await FetchUsers();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
@@ -98,6 +120,7 @@ public partial class Users
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
IsLoading = false;
|
IsLoading = false;
|
||||||
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,9 +136,10 @@ public partial class Users
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
IsLoading = true;
|
IsLoading = true;
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
await UserGateway.DeleteUser(UserDelete.Id);
|
await UserGateway.DeleteUser(UserDelete.Id);
|
||||||
await FetchData(false);
|
await FetchUsers();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
@@ -124,6 +148,7 @@ public partial class Users
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
IsLoading = false;
|
IsLoading = false;
|
||||||
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
UserDelete = null;
|
UserDelete = null;
|
||||||
@@ -134,7 +159,7 @@ public partial class Users
|
|||||||
}
|
}
|
||||||
private async Task HandleFilterChanged()
|
private async Task HandleFilterChanged()
|
||||||
{
|
{
|
||||||
await FetchData(false);
|
await FetchUsers(false);
|
||||||
}
|
}
|
||||||
private void HandleCancelPopupClicked()
|
private void HandleCancelPopupClicked()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,13 +19,3 @@
|
|||||||
height: 60px;
|
height: 60px;
|
||||||
animation: spin 1s linear infinite;
|
animation: spin 1s linear infinite;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes spin {
|
|
||||||
0% {
|
|
||||||
transform: rotate(0deg);
|
|
||||||
}
|
|
||||||
|
|
||||||
100% {
|
|
||||||
transform: rotate(360deg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public class GameBaseComponent : ComponentBase
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
IsLoading = true;
|
IsLoading = true;
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
Categories = await GameGateway.FetchCategories();
|
Categories = await GameGateway.FetchCategories();
|
||||||
}
|
}
|
||||||
@@ -34,6 +35,7 @@ public class GameBaseComponent : ComponentBase
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
IsLoading = false;
|
IsLoading = false;
|
||||||
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
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"
|
||||||
|
|||||||
@@ -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,6 +34,7 @@
|
|||||||
min-width: 18px;
|
min-width: 18px;
|
||||||
height: 18px;
|
height: 18px;
|
||||||
width: 18px;
|
width: 18px;
|
||||||
|
z-index: 800;
|
||||||
}
|
}
|
||||||
|
|
||||||
.clear-icon:hover {
|
.clear-icon:hover {
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ 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; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
@if (Params.Headers != null)
|
@if (Params.Headers != null)
|
||||||
{
|
{
|
||||||
@foreach (var header in (HeaderValues ?? []).UnionBy(Params.Headers, Params.GetHeaderLabel))
|
@foreach (var header in GetHeaders())
|
||||||
{
|
{
|
||||||
<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 (Values ?? []).UnionBy(Params.Items, Params.GetItemLabel))
|
@foreach (var item in GetItems())
|
||||||
{
|
{
|
||||||
<SelectRow IsSelected=@(Values?.Contains(item))
|
<SelectRow IsSelected=@(Values?.Contains(item))
|
||||||
Label="@Params.GetItemLabel(item)" Theme=Theme
|
Label="@Params.GetItemLabel(item)" Theme=Theme
|
||||||
|
|||||||
@@ -101,4 +101,12 @@ 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)];
|
||||||
}
|
}
|
||||||
@@ -22,8 +22,6 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
animation-name: fade-in;
|
|
||||||
animation-duration: 0.2s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.line {
|
.line {
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
|
|
||||||
@typeparam TItem
|
@typeparam TItem
|
||||||
|
|
||||||
<Select @ref=Select TItem="TItem" THeader="string" Theme="Theme" Type="SelectType"
|
<Select @ref=Select TItem="TItem" THeader="string" Theme="Theme" Type="SelectType" DisableClicked=true
|
||||||
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="HandleClearClicked" ClearClicked="HandleClearClicked" IsDisable=QuickAdd
|
TextChanged="HandleTextChanged" ClearClicked="HandleClearClicked" IsDisable=false
|
||||||
FocusIn="HandleFocusIn" SearchClicked="HandleFocusIn" />
|
FocusIn="HandleFocusIn" SearchClicked="HandleFocusIn" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
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;
|
||||||
@@ -10,6 +11,7 @@ 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;
|
||||||
@@ -27,6 +29,7 @@ public partial class SelectSearch<TItem>
|
|||||||
{
|
{
|
||||||
Items = Items,
|
Items = Items,
|
||||||
GetItemLabel = GetLabel,
|
GetItemLabel = GetLabel,
|
||||||
|
GetItemOrder = OrderBy,
|
||||||
AddItem = AddItem
|
AddItem = AddItem
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -35,7 +38,7 @@ public partial class SelectSearch<TItem>
|
|||||||
|
|
||||||
protected override void OnAfterRender(bool firstRender)
|
protected override void OnAfterRender(bool firstRender)
|
||||||
{
|
{
|
||||||
if (Values != null)
|
if (firstRender && Values != null)
|
||||||
{
|
{
|
||||||
SearchInput?.SetText(string.Join(", ", Values.Select(GetLabel)));
|
SearchInput?.SetText(string.Join(", ", Values.Select(GetLabel)));
|
||||||
}
|
}
|
||||||
@@ -51,11 +54,37 @@ public partial class SelectSearch<TItem>
|
|||||||
private async Task HandleClearClicked()
|
private async Task HandleClearClicked()
|
||||||
{
|
{
|
||||||
Values = [];
|
Values = [];
|
||||||
await ValuesChanged.InvokeAsync([.. Values]);
|
Select?.Close();
|
||||||
|
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) ?? []));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -82,64 +82,20 @@ html, body, #app {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.loading-progress {
|
.loading-progress {
|
||||||
position: relative;
|
display: flex;
|
||||||
display: block;
|
width: 100vw;
|
||||||
width: 8rem;
|
height: 100vh;
|
||||||
height: 8rem;
|
justify-content: center;
|
||||||
margin: 20vh auto 1rem auto;
|
align-items: center;
|
||||||
|
animation: loading-background 4s linear infinite;
|
||||||
}
|
}
|
||||||
|
|
||||||
.loading-progress circle {
|
.loading-progress > #loading-icon {
|
||||||
fill: none;
|
max-width: 200px;
|
||||||
stroke: #e0e0e0;
|
max-height: 200px;
|
||||||
stroke-width: 0.6rem;
|
animation: loading-icon 4s ease-in-out infinite;
|
||||||
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
|
||||||
}
|
}
|
||||||
@@ -158,14 +114,59 @@ code {
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:focus-visible {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes fade-in {
|
@keyframes loading-background {
|
||||||
0% {opacity: 0}
|
0% {
|
||||||
100% {opacity: 1}
|
background: rgb(0, 0, 0, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
to {
|
0% {
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
.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);
|
||||||
|
}
|
||||||
@@ -7,17 +7,22 @@
|
|||||||
<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">
|
||||||
<svg class="loading-progress">
|
<div class="loading-progress">
|
||||||
<circle r="40%" cx="50%" cy="50%" />
|
<img src="icon.png" alt="" id="loading-icon">
|
||||||
<circle r="40%" cx="50%" cy="50%" />
|
</div>
|
||||||
</svg>
|
</div>
|
||||||
<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">
|
||||||
@@ -25,6 +30,7 @@
|
|||||||
<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>
|
||||||
|
|||||||
@@ -74,6 +74,10 @@ 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
|
||||||
@@ -156,4 +160,8 @@ 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.");
|
||||||
}
|
}
|
||||||
@@ -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 = 500;
|
public const double DELAY_INPUT_MS = 450;
|
||||||
|
|
||||||
public const int MAX_DESCRIPTION_LENGTH = 350;
|
public const int MAX_DESCRIPTION_LENGTH = 350;
|
||||||
}
|
}
|
||||||
|
|||||||
7
src/GameIdeas/GameIdeas.Shared/Dto/GameListDto.cs
Normal file
7
src/GameIdeas/GameIdeas.Shared/Dto/GameListDto.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace GameIdeas.Shared.Dto;
|
||||||
|
|
||||||
|
public class GameListDto
|
||||||
|
{
|
||||||
|
public IEnumerable<GameDto> Games { get; set; } = [];
|
||||||
|
public int NumberOfGames { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
namespace GameIdeas.Shared.Exceptions;
|
||||||
|
|
||||||
|
public class EnvironmentVariableMissingException(string message) : Exception(message);
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace GameIdeas.WebAPI.Exceptions;
|
namespace GameIdeas.Shared.Exceptions;
|
||||||
|
|
||||||
public class UserInvalidException(string message) : Exception(message);
|
public class UserInvalidException(string message) : Exception(message);
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace GameIdeas.WebAPI.Exceptions;
|
namespace GameIdeas.Shared.Exceptions;
|
||||||
|
|
||||||
public class UserUnauthorizedException(string message) : Exception(message);
|
public class UserUnauthorizedException(string message) : Exception(message);
|
||||||
12
src/GameIdeas/GameIdeas.Shared/Options/GameIdeasOptions.cs
Normal file
12
src/GameIdeas/GameIdeas.Shared/Options/GameIdeasOptions.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
namespace GameIdeas.Shared.Options;
|
||||||
|
|
||||||
|
public class GameIdeasOptions
|
||||||
|
{
|
||||||
|
public string DbHost { get; set; } = string.Empty;
|
||||||
|
public string DbUsername { get; set; } = string.Empty;
|
||||||
|
public string DbPassword { get; set; } = string.Empty;
|
||||||
|
public string DbDatabase { get; set; } = string.Empty;
|
||||||
|
public string JwtKey { get; set; } = string.Empty;
|
||||||
|
public string JwtIssuer { get; set; } = string.Empty;
|
||||||
|
public string JwtAudience { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
@@ -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<IEnumerable<GameDto>>> SearchGames([FromQuery] GameFilterDto filter)
|
public async Task<ActionResult<GameListDto>> SearchGames([FromQuery] GameFilterDto filter)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using GameIdeas.Shared.Constants;
|
using GameIdeas.Shared.Constants;
|
||||||
using GameIdeas.Shared.Dto;
|
using GameIdeas.Shared.Dto;
|
||||||
using GameIdeas.WebAPI.Exceptions;
|
using GameIdeas.Shared.Exceptions;
|
||||||
using GameIdeas.WebAPI.Services.Users;
|
using GameIdeas.WebAPI.Services.Users;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
using GameIdeas.Shared.Exceptions;
|
||||||
|
using GameIdeas.Shared.Options;
|
||||||
|
|
||||||
|
namespace GameIdeas.WebAPI.Extensions;
|
||||||
|
|
||||||
|
public static class ServiceCollectionExtension
|
||||||
|
{
|
||||||
|
public static IServiceCollection AddGameIdeasOptions(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
var dictionary = LoadEnvironmentVariable("../../../../.env");
|
||||||
|
#else
|
||||||
|
var dictionary = LoadEnvironmentVariable("../.env");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
services.Configure<GameIdeasOptions>(options =>
|
||||||
|
{
|
||||||
|
options.DbHost = GetEnvVar("DB_HOST", dictionary);
|
||||||
|
options.DbUsername = GetEnvVar("DB_USERNAME", dictionary);
|
||||||
|
options.DbPassword = GetEnvVar("DB_PASSWORD", dictionary);
|
||||||
|
options.DbDatabase = GetEnvVar("DB_DATABASE", dictionary);
|
||||||
|
options.JwtKey = GetEnvVar("JWT_KEY", dictionary);
|
||||||
|
options.JwtIssuer = GetEnvVar("JWT_ISSUER", dictionary);
|
||||||
|
options.JwtAudience = GetEnvVar("JWT_AUDIENCE", dictionary);
|
||||||
|
});
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetEnvVar(string name, Dictionary<string, string> dictionary)
|
||||||
|
{
|
||||||
|
return Environment.GetEnvironmentVariable(name)
|
||||||
|
?? dictionary.GetValueOrDefault(name)
|
||||||
|
?? throw new EnvironmentVariableMissingException($"Missing environment variable with key: {name}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Dictionary<string, string> LoadEnvironmentVariable(string filePath)
|
||||||
|
{
|
||||||
|
if (!File.Exists(filePath))
|
||||||
|
return [];
|
||||||
|
|
||||||
|
return File.ReadAllLines(filePath)
|
||||||
|
.Select(line => line.Split('=', StringSplitOptions.RemoveEmptyEntries))
|
||||||
|
.Where(parts => parts.Length == 2)
|
||||||
|
.ToDictionary(parts => parts[0], parts => parts[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -69,5 +69,9 @@
|
|||||||
"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}"
|
||||||
}
|
}
|
||||||
@@ -10,37 +10,18 @@ using Microsoft.AspNetCore.Identity;
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using GameIdeas.WebAPI.Extensions;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
var services = builder.Services;
|
var services = builder.Services;
|
||||||
|
|
||||||
#if DEBUG
|
services.AddGameIdeasOptions();
|
||||||
LoadEnvironmentVariable("../../../../.env");
|
services.AddDbContext<GameIdeasContext>(ContextOptions);
|
||||||
#else
|
|
||||||
LoadEnvironmentVariable("../.env");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Action<DbContextOptionsBuilder> dbContextOptions = options =>
|
|
||||||
{
|
|
||||||
options.UseNpgsql(
|
|
||||||
GetConnectionString(),
|
|
||||||
npgOption =>
|
|
||||||
{
|
|
||||||
npgOption.CommandTimeout(60);
|
|
||||||
npgOption.MigrationsAssembly("GameIdeas.WebAPI");
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Add services to the container.
|
|
||||||
services.AddDbContext<GameIdeasContext>(dbContextOptions);
|
|
||||||
|
|
||||||
services.AddIdentity<User, IdentityRole>()
|
services.AddIdentity<User, IdentityRole>()
|
||||||
.AddEntityFrameworkStores<GameIdeasContext>()
|
.AddEntityFrameworkStores<GameIdeasContext>()
|
||||||
.AddDefaultTokenProviders();
|
.AddDefaultTokenProviders();
|
||||||
|
|
||||||
var jwtKey = Environment.GetEnvironmentVariable("JWT_KEY")
|
|
||||||
?? throw new ArgumentNullException(message: "Invalid key for JWT token", null);
|
|
||||||
|
|
||||||
services.AddAuthentication(options =>
|
services.AddAuthentication(options =>
|
||||||
{
|
{
|
||||||
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||||
@@ -86,7 +67,6 @@ services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
|
|||||||
|
|
||||||
services.AddControllers();
|
services.AddControllers();
|
||||||
|
|
||||||
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
|
||||||
services.AddOpenApi();
|
services.AddOpenApi();
|
||||||
|
|
||||||
services.AddCors(option => option.AddDefaultPolicy(policy =>
|
services.AddCors(option => option.AddDefaultPolicy(policy =>
|
||||||
@@ -118,6 +98,16 @@ app.UseAuthorization();
|
|||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
return;
|
||||||
|
|
||||||
|
void ContextOptions(DbContextOptionsBuilder options)
|
||||||
|
{
|
||||||
|
options.UseNpgsql(GetConnectionString(), npgOption =>
|
||||||
|
{
|
||||||
|
npgOption.CommandTimeout(60);
|
||||||
|
npgOption.MigrationsAssembly("GameIdeas.WebAPI");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async Task LoadTranslations()
|
async Task LoadTranslations()
|
||||||
{
|
{
|
||||||
@@ -134,7 +124,6 @@ async Task LoadTranslations()
|
|||||||
|
|
||||||
app.Services.GetRequiredService<TranslationService>().Initialize(dictionary);
|
app.Services.GetRequiredService<TranslationService>().Initialize(dictionary);
|
||||||
ResourcesKey.Initialize(app.Services.GetRequiredService<Translations>());
|
ResourcesKey.Initialize(app.Services.GetRequiredService<Translations>());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string GetConnectionString()
|
string GetConnectionString()
|
||||||
@@ -146,21 +135,3 @@ string GetConnectionString()
|
|||||||
|
|
||||||
return $"Host={host};Username={login};Password={pass};Database={database}";
|
return $"Host={host};Username={login};Password={pass};Database={database}";
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LoadEnvironmentVariable(string filePath)
|
|
||||||
{
|
|
||||||
if (!File.Exists(filePath))
|
|
||||||
return;
|
|
||||||
|
|
||||||
foreach (var line in File.ReadAllLines(filePath))
|
|
||||||
{
|
|
||||||
var parts = line.Split(
|
|
||||||
'=',
|
|
||||||
StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
|
|
||||||
if (parts.Length != 2)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
Environment.SetEnvironmentVariable(parts[0], parts[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -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<IEnumerable<GameDto>> GetGames(GameFilterDto filter)
|
public async Task<GameListDto> 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,13 +26,19 @@ public class GameReadService(GameIdeasContext context, IMapper mapper, ICategory
|
|||||||
|
|
||||||
ApplyOrder(ref query, filter);
|
ApplyOrder(ref query, filter);
|
||||||
|
|
||||||
var games = await query.Skip((filter.CurrentPage - 1) * GlobalConstants.NUMBER_PER_PAGE)
|
var games = await query.ToListAsync();
|
||||||
.Take(GlobalConstants.NUMBER_PER_PAGE)
|
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
ApplyStaticFilter(ref games, filter);
|
ApplyStaticFilter(ref games, filter);
|
||||||
|
|
||||||
return mapper.Map<IEnumerable<GameDto>>(games);
|
games = [.. 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)
|
||||||
|
|||||||
@@ -4,6 +4,6 @@ namespace GameIdeas.WebAPI.Services.Games;
|
|||||||
|
|
||||||
public interface IGameReadService
|
public interface IGameReadService
|
||||||
{
|
{
|
||||||
Task<IEnumerable<GameDto>> GetGames(GameFilterDto filter);
|
Task<GameListDto> GetGames(GameFilterDto filter);
|
||||||
Task<GameDetailDto> GetGameById(int gameId);
|
Task<GameDetailDto> GetGameById(int gameId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,19 +4,22 @@ using GameIdeas.Shared.Constants;
|
|||||||
using GameIdeas.Shared.Dto;
|
using GameIdeas.Shared.Dto;
|
||||||
using GameIdeas.Shared.Model;
|
using GameIdeas.Shared.Model;
|
||||||
using GameIdeas.WebAPI.Context;
|
using GameIdeas.WebAPI.Context;
|
||||||
using GameIdeas.WebAPI.Exceptions;
|
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using System.IdentityModel.Tokens.Jwt;
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using GameIdeas.Shared.Exceptions;
|
||||||
|
using GameIdeas.Shared.Options;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace GameIdeas.WebAPI.Services.Users;
|
namespace GameIdeas.WebAPI.Services.Users;
|
||||||
|
|
||||||
public class UserReadService(
|
public class UserReadService(
|
||||||
UserManager<User> userManager,
|
UserManager<User> userManager,
|
||||||
GameIdeasContext context,
|
GameIdeasContext context,
|
||||||
|
IOptions<GameIdeasOptions> options,
|
||||||
IMapper mapper) : IUserReadService
|
IMapper mapper) : IUserReadService
|
||||||
{
|
{
|
||||||
public async Task<IEnumerable<RoleDto>> GetRoles()
|
public async Task<IEnumerable<RoleDto>> GetRoles()
|
||||||
@@ -33,8 +36,9 @@ public class UserReadService(
|
|||||||
.OrderBy(u => u.UserName)
|
.OrderBy(u => u.UserName)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
var count = users.Count;
|
|
||||||
ApplyStaticFilter(ref users, filter);
|
ApplyStaticFilter(ref users, filter);
|
||||||
|
|
||||||
|
var count = users.Count;
|
||||||
|
|
||||||
var usersDto = mapper.Map<IEnumerable<UserDto>>(users);
|
var usersDto = mapper.Map<IEnumerable<UserDto>>(users);
|
||||||
usersDto = await ApplyRoles(usersDto, filter);
|
usersDto = await ApplyRoles(usersDto, filter);
|
||||||
@@ -124,14 +128,11 @@ public class UserReadService(
|
|||||||
authClaims.AddRange((await userManager.GetRolesAsync(user))
|
authClaims.AddRange((await userManager.GetRolesAsync(user))
|
||||||
.Select(r => new Claim(ClaimTypes.Role, r)));
|
.Select(r => new Claim(ClaimTypes.Role, r)));
|
||||||
|
|
||||||
var jwtKey = Environment.GetEnvironmentVariable("JWT_KEY")
|
var authSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(options.Value.JwtKey));
|
||||||
?? throw new ArgumentNullException(message: ResourcesKey.InvalidToken, null);
|
|
||||||
|
|
||||||
var authSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtKey));
|
|
||||||
|
|
||||||
var token = new JwtSecurityToken(
|
var token = new JwtSecurityToken(
|
||||||
issuer: Environment.GetEnvironmentVariable("JWT_ISSUER"),
|
issuer: options.Value.JwtIssuer,
|
||||||
audience: Environment.GetEnvironmentVariable("JWT_AUDIENCE"),
|
audience: options.Value.JwtAudience,
|
||||||
expires: DateTime.Now.AddHours(GlobalConstants.JWT_DURATION_HOUR),
|
expires: DateTime.Now.AddHours(GlobalConstants.JWT_DURATION_HOUR),
|
||||||
claims: authClaims,
|
claims: authClaims,
|
||||||
signingCredentials: new SigningCredentials(authSigningKey, SecurityAlgorithms.HmacSha256)
|
signingCredentials: new SigningCredentials(authSigningKey, SecurityAlgorithms.HmacSha256)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using GameIdeas.Resources;
|
using GameIdeas.Resources;
|
||||||
using GameIdeas.Shared.Dto;
|
using GameIdeas.Shared.Dto;
|
||||||
|
using GameIdeas.Shared.Exceptions;
|
||||||
using GameIdeas.Shared.Model;
|
using GameIdeas.Shared.Model;
|
||||||
using GameIdeas.WebAPI.Exceptions;
|
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
|
|
||||||
namespace GameIdeas.WebAPI.Services.Users;
|
namespace GameIdeas.WebAPI.Services.Users;
|
||||||
|
|||||||
Reference in New Issue
Block a user