Compare commits
9 Commits
d9d036896d
...
feature/fi
| Author | SHA1 | Date | |
|---|---|---|---|
| 36360efa6f | |||
| 564cadb945 | |||
| a1cc9dec99 | |||
| 1baa2a73fe | |||
| edd3ac78de | |||
| ae39e15d32 | |||
| 58da2e6843 | |||
| b58ffe10e0 | |||
| e4fe2495ef |
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -20,6 +20,20 @@ public static class GameHelper
|
|||||||
game.CreationDate = DateTime.Now;
|
game.CreationDate = DateTime.Now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void UpdateTrackingDto(GameDetailDto game, AuthenticationState authState)
|
||||||
|
{
|
||||||
|
if (authState == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(authState), "Authentication state missing");
|
||||||
|
}
|
||||||
|
|
||||||
|
var userId = authState.User.FindFirstValue(ClaimTypes.Sid)
|
||||||
|
?? throw new ArgumentNullException(nameof(authState), "user state missing");
|
||||||
|
|
||||||
|
game.ModificationUserId = userId;
|
||||||
|
game.ModificationDate = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
public static string GetInterestColor(int interest, int maxInterest)
|
public static string GetInterestColor(int interest, int maxInterest)
|
||||||
{
|
{
|
||||||
int firstTier = (int)Math.Floor(0.33 * maxInterest);
|
int firstTier = (int)Math.Floor(0.33 * maxInterest);
|
||||||
|
|||||||
@@ -4,9 +4,3 @@
|
|||||||
<div class="page">
|
<div class="page">
|
||||||
@Body
|
@Body
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="background">
|
|
||||||
<span class="orb red"></span>
|
|
||||||
<span class="orb blue"></span>
|
|
||||||
<span class="orb green"></span>
|
|
||||||
</div>
|
|
||||||
@@ -3,46 +3,3 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
@@ -1,12 +1,22 @@
|
|||||||
@page "/Detail/{GameId:int}"
|
@page "/Detail/{GameId:int}"
|
||||||
@using GameIdeas.BlazorApp.Helpers
|
@using GameIdeas.BlazorApp.Helpers
|
||||||
|
@using GameIdeas.BlazorApp.Pages.Games.Components
|
||||||
|
@using GameIdeas.BlazorApp.Shared.Components
|
||||||
|
@using GameIdeas.BlazorApp.Shared.Components.ButtonAdd
|
||||||
@using GameIdeas.BlazorApp.Shared.Components.Header
|
@using GameIdeas.BlazorApp.Shared.Components.Header
|
||||||
@using GameIdeas.BlazorApp.Shared.Components.Interest
|
@using GameIdeas.BlazorApp.Shared.Components.Interest
|
||||||
|
@using GameIdeas.BlazorApp.Shared.Components.Popup
|
||||||
|
@using GameIdeas.BlazorApp.Shared.Components.ReadMore
|
||||||
@using GameIdeas.BlazorApp.Shared.Constants
|
@using GameIdeas.BlazorApp.Shared.Constants
|
||||||
|
@using GameIdeas.Shared.Constants
|
||||||
|
|
||||||
|
@inherits GameBaseComponent
|
||||||
@layout MainLayout
|
@layout MainLayout
|
||||||
|
|
||||||
<HeaderGameIdeas>
|
<HeaderGameIdeas>
|
||||||
|
<div class="button">
|
||||||
|
<ButtonAdd AddTypeChanged="HandleAddClicked" />
|
||||||
|
</div>
|
||||||
</HeaderGameIdeas>
|
</HeaderGameIdeas>
|
||||||
|
|
||||||
<div class="detail-container">
|
<div class="detail-container">
|
||||||
@@ -18,7 +28,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<div class="section col-2">
|
<div class="section col-2">
|
||||||
<span class="description">@Game.Description</span>
|
<ReadMore Text="@Game.Description" MaxLength="GlobalConstants.MAX_DESCRIPTION_LENGTH" />
|
||||||
|
|
||||||
<div class="medias"></div>
|
<div class="medias"></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -96,3 +106,7 @@
|
|||||||
<div class="section">
|
<div class="section">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<Popup @ref=ManualAddPopup BackdropFilterClicked="HandleBackdropManualAddClicked" Closable=false>
|
||||||
|
<GameCreationForm Categories="Categories" OnSubmit="HandleSubmitNewGame" />
|
||||||
|
</Popup>
|
||||||
@@ -1,19 +1,47 @@
|
|||||||
using GameIdeas.BlazorApp.Pages.Games.Gateways;
|
using GameIdeas.BlazorApp.Shared.Components;
|
||||||
|
using GameIdeas.BlazorApp.Shared.Exceptions;
|
||||||
|
using GameIdeas.Resources;
|
||||||
using GameIdeas.Shared.Dto;
|
using GameIdeas.Shared.Dto;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
namespace GameIdeas.BlazorApp.Pages.Detail;
|
namespace GameIdeas.BlazorApp.Pages.Detail;
|
||||||
|
|
||||||
public partial class GameDetail
|
public partial class GameDetail : GameBaseComponent
|
||||||
{
|
{
|
||||||
[Inject] private IGameGateway GameGateway { get; set; } = default!;
|
[Inject] private NavigationManager NavigationManager { get; set; } = default!;
|
||||||
[Parameter] public int GameId { get; set; }
|
[Parameter] public int GameId { get; set; }
|
||||||
|
|
||||||
private GameDetailDto Game = new();
|
private GameDetailDto Game = new();
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
Game = await GameGateway.GetGameById(GameId);
|
await FetchGameDetail();
|
||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void HandleSubmitNewGame()
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo("/Games");
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task FetchGameDetail()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IsLoading = true;
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
|
Game = await GameGateway.GetGameById(GameId);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw new FetchGameDetailException(ResourcesKey.ErrorFetchDetail);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IsLoading = false;
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
.detail-container, .properties-tags {
|
.detail-container, .properties-tags {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-gap: 20px;
|
grid-gap: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.flex {
|
.flex {
|
||||||
@@ -41,6 +41,10 @@
|
|||||||
gap: 34px;
|
gap: 34px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pills {
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
.additional-informations, .platforms {
|
.additional-informations, .platforms {
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
background: var(--input-secondary);
|
background: var(--input-secondary);
|
||||||
@@ -86,6 +90,12 @@
|
|||||||
background: var(--input-selected);
|
background: var(--input-selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.button {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
justify-content: end;
|
||||||
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 1000px) {
|
@media screen and (max-width: 1000px) {
|
||||||
.section {
|
.section {
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
namespace GameIdeas.BlazorApp.Pages.Games.Components;
|
||||||
|
|
||||||
|
public enum DetailOptions
|
||||||
|
{
|
||||||
|
Detail,
|
||||||
|
Edit,
|
||||||
|
Delete
|
||||||
|
}
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
using GameIdeas.Shared.Dto;
|
using GameIdeas.BlazorApp.Shared.Components.Select;
|
||||||
|
using GameIdeas.BlazorApp.Shared.Components.Select.Models;
|
||||||
|
using GameIdeas.Resources;
|
||||||
|
using GameIdeas.Shared.Dto;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
namespace GameIdeas.BlazorApp.Pages.Games.Components;
|
namespace GameIdeas.BlazorApp.Pages.Games.Components;
|
||||||
@@ -6,10 +9,51 @@ namespace GameIdeas.BlazorApp.Pages.Games.Components;
|
|||||||
public class GameBase : ComponentBase
|
public class GameBase : ComponentBase
|
||||||
{
|
{
|
||||||
[Parameter] public GameDto GameDto { get; set; } = new();
|
[Parameter] public GameDto GameDto { get; set; } = new();
|
||||||
|
[Parameter] public EventCallback<GameDto> OnDelete { get; set; } = new();
|
||||||
|
[Parameter] public EventCallback<GameDto> OnEdit { get; set; } = new();
|
||||||
[Inject] public NavigationManager NavigationManager { get; set; } = default!;
|
[Inject] public NavigationManager NavigationManager { get; set; } = default!;
|
||||||
|
|
||||||
protected void HandleDetailClicked()
|
protected SelectParams<DetailOptions, object> SelectParams = default!;
|
||||||
|
protected Select<DetailOptions, object>? SelectOption;
|
||||||
|
|
||||||
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
NavigationManager.NavigateTo($"/Games/Detail/{GameDto.Id}");
|
SelectParams = new()
|
||||||
|
{
|
||||||
|
Items = [DetailOptions.Detail, DetailOptions.Edit, DetailOptions.Delete],
|
||||||
|
GetItemLabel = GetDetailOptionsLabel
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async Task HandlerSelectValuesChanged(IEnumerable<DetailOptions> detailOptions)
|
||||||
|
{
|
||||||
|
var option = detailOptions.First();
|
||||||
|
switch (option)
|
||||||
|
{
|
||||||
|
case DetailOptions.Detail:
|
||||||
|
NavigationManager.NavigateTo($"/Detail/{GameDto.Id}");
|
||||||
|
break;
|
||||||
|
case DetailOptions.Edit:
|
||||||
|
await OnEdit.InvokeAsync(GameDto);
|
||||||
|
break;
|
||||||
|
case DetailOptions.Delete:
|
||||||
|
await OnDelete.InvokeAsync(GameDto);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectOption?.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetDetailOptionsLabel(DetailOptions options)
|
||||||
|
{
|
||||||
|
return options switch
|
||||||
|
{
|
||||||
|
DetailOptions.Detail => ResourcesKey.Detail,
|
||||||
|
DetailOptions.Edit => ResourcesKey.Edit,
|
||||||
|
DetailOptions.Delete => ResourcesKey.Delete,
|
||||||
|
_ => ResourcesKey.Unknown
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,13 +24,13 @@
|
|||||||
<div class="input-game">
|
<div class="input-game">
|
||||||
<div class="label">@ResourcesKey.Developer :</div>
|
<div class="label">@ResourcesKey.Developer :</div>
|
||||||
<SelectSearch TItem="DeveloperDto" Theme="Theme" GetLabel="@(i => i.Name)" QuickAdd=true
|
<SelectSearch TItem="DeveloperDto" Theme="Theme" GetLabel="@(i => i.Name)" QuickAdd=true
|
||||||
Items="Categories?.Developers" ValuesChanged="HandleDeveloperChanged"
|
Items="Categories?.Developers" ValuesChanged="HandleDeveloperChanged" Values="@(GameDto.Developer != null ? [GameDto.Developer] : [])"
|
||||||
AddItem="@(str => new DeveloperDto() { Name = str })" SelectType="SelectType.Single" />
|
AddItem="@(str => new DeveloperDto() { Name = str })" SelectType="SelectType.Single" />
|
||||||
</div>
|
</div>
|
||||||
<div class="input-game">
|
<div class="input-game">
|
||||||
<div class="label">@ResourcesKey.Publisher :</div>
|
<div class="label">@ResourcesKey.Publisher :</div>
|
||||||
<SelectSearch TItem="PublisherDto" Theme="Theme" GetLabel="@(i => i.Name)" QuickAdd=true
|
<SelectSearch TItem="PublisherDto" Theme="Theme" GetLabel="@(i => i.Name)" QuickAdd=true
|
||||||
Items="Categories?.Publishers" ValuesChanged="HandlePublisherChanged"
|
Items="Categories?.Publishers" ValuesChanged="HandlePublisherChanged" Values="@(GameDto.Publisher != null ? [GameDto.Publisher] : [])"
|
||||||
AddItem="@(str => new PublisherDto() { Name = str })" SelectType="SelectType.Single" />
|
AddItem="@(str => new PublisherDto() { Name = str })" SelectType="SelectType.Single" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,12 +3,13 @@ using GameIdeas.BlazorApp.Pages.Games.Gateways;
|
|||||||
using GameIdeas.BlazorApp.Shared.Components.Popup;
|
using GameIdeas.BlazorApp.Shared.Components.Popup;
|
||||||
using GameIdeas.BlazorApp.Shared.Components.Select.Models;
|
using GameIdeas.BlazorApp.Shared.Components.Select.Models;
|
||||||
using GameIdeas.BlazorApp.Shared.Components.Slider;
|
using GameIdeas.BlazorApp.Shared.Components.Slider;
|
||||||
|
using GameIdeas.BlazorApp.Shared.Exceptions;
|
||||||
|
using GameIdeas.Resources;
|
||||||
using GameIdeas.Shared.Dto;
|
using GameIdeas.Shared.Dto;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using Microsoft.AspNetCore.Components.Authorization;
|
using Microsoft.AspNetCore.Components.Authorization;
|
||||||
using Microsoft.AspNetCore.Components.Forms;
|
using Microsoft.AspNetCore.Components.Forms;
|
||||||
using Microsoft.JSInterop;
|
using Microsoft.JSInterop;
|
||||||
using System.Security.Claims;
|
|
||||||
|
|
||||||
namespace GameIdeas.BlazorApp.Pages.Games.Components;
|
namespace GameIdeas.BlazorApp.Pages.Games.Components;
|
||||||
|
|
||||||
@@ -20,6 +21,7 @@ public partial class GameCreationForm
|
|||||||
[CascadingParameter] private Popup? Popup { get; set; }
|
[CascadingParameter] private Popup? Popup { get; set; }
|
||||||
[Parameter] public CategoriesDto? Categories { get; set; }
|
[Parameter] public CategoriesDto? Categories { get; set; }
|
||||||
[Parameter] public EventCallback OnSubmit { get; set; }
|
[Parameter] public EventCallback OnSubmit { get; set; }
|
||||||
|
[Parameter] public EventCallback OnRender { get; set; }
|
||||||
|
|
||||||
private GameDetailDto GameDto = new();
|
private GameDetailDto GameDto = new();
|
||||||
private EditContext? EditContext;
|
private EditContext? EditContext;
|
||||||
@@ -27,15 +29,19 @@ public partial class GameCreationForm
|
|||||||
private readonly SliderParams SliderParams = new() { Gap = 1, Min = 1, Max = 5 };
|
private readonly SliderParams SliderParams = new() { Gap = 1, Min = 1, Max = 5 };
|
||||||
private bool IsLoading = false;
|
private bool IsLoading = false;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
EditContext = new(GameDto);
|
EditContext = new(GameDto);
|
||||||
await base.OnInitializedAsync();
|
base.OnInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
{
|
{
|
||||||
await Js.InvokeVoidAsync("resizeGameForm");
|
await Js.InvokeVoidAsync("resizeGameForm");
|
||||||
|
if (firstRender)
|
||||||
|
{
|
||||||
|
await OnRender.InvokeAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleOnCancel()
|
private void HandleOnCancel()
|
||||||
@@ -53,16 +59,24 @@ public partial class GameCreationForm
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
IsLoading = true;
|
IsLoading = true;
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
|
int gameId;
|
||||||
var authState = await AuthenticationState.GetAuthenticationStateAsync();
|
var authState = await AuthenticationState.GetAuthenticationStateAsync();
|
||||||
GameHelper.WriteTrackingDto(GameDto, authState);
|
GameHelper.WriteTrackingDto(GameDto, authState);
|
||||||
|
|
||||||
var gameId = await GameGateway.CreateGame(GameDto);
|
if (GameDto.Id != null)
|
||||||
|
|
||||||
if (gameId != 0)
|
|
||||||
{
|
{
|
||||||
Popup?.Close();
|
gameId = await GameGateway.UpdateGame(GameDto);
|
||||||
await OnSubmit.InvokeAsync();
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gameId = await GameGateway.CreateGame(GameDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gameId == 0)
|
||||||
|
{
|
||||||
|
throw new GameCreationException(ResourcesKey.ErrorCreateGame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
@@ -74,13 +88,40 @@ public partial class GameCreationForm
|
|||||||
IsLoading = false;
|
IsLoading = false;
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Popup?.Close();
|
||||||
|
|
||||||
|
await OnSubmit.InvokeAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandlePublisherChanged(List<PublisherDto> pubs)
|
private void HandlePublisherChanged(List<PublisherDto> pubs)
|
||||||
{
|
{
|
||||||
GameDto.Publisher = pubs.FirstOrDefault();
|
GameDto.Publisher = pubs.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleDeveloperChanged(List<DeveloperDto> devs)
|
private void HandleDeveloperChanged(List<DeveloperDto> devs)
|
||||||
{
|
{
|
||||||
GameDto.Developer = devs.FirstOrDefault();
|
GameDto.Developer = devs.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task SetGameToUpdateAsync(int gameId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IsLoading = true;
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
|
GameDto = await GameGateway.GetGameById(gameId);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw new FetchGameDetailException(ResourcesKey.ErrorFetchDetail);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IsLoading = false;
|
||||||
|
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 {
|
||||||
@@ -118,3 +119,20 @@
|
|||||||
.buttons button:hover {
|
.buttons button:hover {
|
||||||
background: var(--violet-selected);
|
background: var(--violet-selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 400px) {
|
||||||
|
.input-game {
|
||||||
|
grid-template-columns: auto 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
#label-description {
|
||||||
|
width: auto !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 700px) {
|
||||||
|
.game-form {
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
@using GameIdeas.BlazorApp.Helpers
|
@using GameIdeas.BlazorApp.Helpers
|
||||||
@using GameIdeas.BlazorApp.Shared.Components.Interest
|
@using GameIdeas.BlazorApp.Shared.Components.Interest
|
||||||
|
@using GameIdeas.BlazorApp.Shared.Components.Select
|
||||||
|
@using GameIdeas.BlazorApp.Shared.Components.Select.Models
|
||||||
@using GameIdeas.BlazorApp.Shared.Constants
|
@using GameIdeas.BlazorApp.Shared.Constants
|
||||||
@inherits GameBase
|
@inherits GameBase
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<img class="icon" src="~/icon.png" />
|
<img class="icon" src="icon.png" />
|
||||||
|
|
||||||
<a class="title" href="@($"/Detail/{GameDto.Id}")">@GameDto.Title</a>
|
<a class="title" href="@($"/Detail/{GameDto.Id}")">@GameDto.Title</a>
|
||||||
|
|
||||||
@@ -33,5 +35,8 @@
|
|||||||
|
|
||||||
<Interest Value="GameDto.Interest" />
|
<Interest Value="GameDto.Interest" />
|
||||||
|
|
||||||
<button class="detail">@Icons.Triangle</button>
|
<Select @ref="SelectOption" TItem="DetailOptions" THeader="object" Type="SelectType.Single" Theme="SelectTheme.RowOption"
|
||||||
|
Params="SelectParams" ValuesChanged="HandlerSelectValuesChanged">
|
||||||
|
@Icons.Triangle
|
||||||
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
@@ -8,7 +8,6 @@
|
|||||||
box-shadow: var(--drop-shadow);
|
box-shadow: var(--drop-shadow);
|
||||||
border-radius: var(--big-radius);
|
border-radius: var(--big-radius);
|
||||||
align-items: center;
|
align-items: center;
|
||||||
overflow: hidden;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.row > * {
|
.row > * {
|
||||||
@@ -40,6 +39,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.release-date, .storage {
|
.release-date, .storage {
|
||||||
|
display: block;
|
||||||
color: rgb(184, 184, 184);
|
color: rgb(184, 184, 184);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,21 +68,37 @@
|
|||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
.detail {
|
::deep .button {
|
||||||
transform: scale(0.6, 1) rotate(-90deg);
|
width: fit-content;
|
||||||
background: none;
|
transform: rotate(-90deg);
|
||||||
border: none;
|
transition: transform 0.2s ease-in-out;
|
||||||
outline: none;
|
justify-self: center;
|
||||||
cursor: pointer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
::deep .detail svg {
|
::deep .button svg {
|
||||||
fill: var(--white);
|
fill: var(--white);
|
||||||
|
height: 20px;
|
||||||
|
width: 20px;
|
||||||
|
transform: scale(1, 0.6);
|
||||||
|
}
|
||||||
|
|
||||||
|
::deep .button:hover, ::deep .button.selected {
|
||||||
|
transform: translate(-4px, 2px);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 700px) {
|
||||||
|
.release-date, .tags, .storage {
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 1000px) {
|
|
||||||
.row {
|
.row {
|
||||||
grid-template-columns: 48px 3fr 2fr 3fr 30px 30px;
|
grid-template-columns: auto 3fr 3fr 30px 30px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (min-width: 700px) and (max-width: 1000px) {
|
||||||
|
.row {
|
||||||
|
grid-template-columns: auto 3fr 2fr 3fr 30px 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tags, .storage {
|
.tags, .storage {
|
||||||
|
|||||||
@@ -97,15 +97,3 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,12 @@
|
|||||||
@using GameIdeas.BlazorApp.Shared.Components.Select.Models
|
@using GameIdeas.BlazorApp.Shared.Components.BackdropFilter
|
||||||
|
@using GameIdeas.BlazorApp.Shared.Components.Select.Models
|
||||||
@using GameIdeas.BlazorApp.Shared.Components.SelectSearch
|
@using GameIdeas.BlazorApp.Shared.Components.SelectSearch
|
||||||
|
@using GameIdeas.BlazorApp.Shared.Constants
|
||||||
@using GameIdeas.Shared.Dto
|
@using GameIdeas.Shared.Dto
|
||||||
|
|
||||||
<div class="advanced-filter-container">
|
<NavigationLock OnBeforeInternalNavigation="HandleLocationChanged" />
|
||||||
|
|
||||||
|
<div class="advanced-filter-container" style="@(ExpandedFilter ? "display: flex" : "")">
|
||||||
<span class="title">@ResourcesKey.Filters</span>
|
<span class="title">@ResourcesKey.Filters</span>
|
||||||
|
|
||||||
<div class="duplicate">
|
<div class="duplicate">
|
||||||
@@ -25,8 +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=HandleExpandFilterAsync>
|
||||||
|
@Icons.Filter
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<BackdropFilter @ref="BackdropFilter" OnClick="HandleBackdropFilterClickedAsync" CloseOnClick="true"
|
||||||
|
AllowBodyScroll="false" Color="BackdropFilterColor.Overlay" />
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
using GameIdeas.BlazorApp.Helpers;
|
using GameIdeas.BlazorApp.Helpers;
|
||||||
|
using GameIdeas.BlazorApp.Shared.Components.BackdropFilter;
|
||||||
using GameIdeas.BlazorApp.Shared.Components.Select.Models;
|
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;
|
||||||
|
|
||||||
@@ -13,6 +15,8 @@ public partial class AdvancedGameFilter
|
|||||||
[Parameter] public EventCallback<GameFilterParams> GameFilterChanged { get; set; }
|
[Parameter] public EventCallback<GameFilterParams> GameFilterChanged { get; set; }
|
||||||
|
|
||||||
private readonly SelectTheme Theme = SelectTheme.AdvancedFilter;
|
private readonly SelectTheme Theme = SelectTheme.AdvancedFilter;
|
||||||
|
private bool ExpandedFilter;
|
||||||
|
private BackdropFilter? BackdropFilter;
|
||||||
|
|
||||||
private async Task HandleValueChanged()
|
private async Task HandleValueChanged()
|
||||||
{
|
{
|
||||||
@@ -45,4 +49,24 @@ public partial class AdvancedGameFilter
|
|||||||
|
|
||||||
throw new ArgumentNullException(ResourcesKey.ErrorStorageSpaceLabel);
|
throw new ArgumentNullException(ResourcesKey.ErrorStorageSpaceLabel);
|
||||||
}
|
}
|
||||||
|
private void HandleExpandFilterAsync(Microsoft.AspNetCore.Components.Web.MouseEventArgs args)
|
||||||
|
{
|
||||||
|
ExpandedFilter = true;
|
||||||
|
BackdropFilter?.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleBackdropFilterClickedAsync()
|
||||||
|
{
|
||||||
|
ExpandedFilter = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleLocationChanged(LocationChangingContext locationContext)
|
||||||
|
{
|
||||||
|
if (ExpandedFilter)
|
||||||
|
{
|
||||||
|
ExpandedFilter = false;
|
||||||
|
BackdropFilter?.Hide();
|
||||||
|
locationContext.PreventNavigation();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,15 +2,39 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
padding-right: 20px;
|
padding: 0 20px;
|
||||||
padding-left: 10px;
|
|
||||||
min-height: calc(100vh - 80px);
|
min-height: calc(100vh - 80px);
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
width: 100%;
|
width: 260px;
|
||||||
border-left: 2px solid var(--line);
|
border-left: 2px solid var(--line);
|
||||||
z-index: var(--index-content);
|
z-index: var(--index-content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.open-filter {
|
||||||
|
padding: 0;
|
||||||
|
display: none;
|
||||||
|
position: fixed;
|
||||||
|
outline: none;
|
||||||
|
border: none;
|
||||||
|
background: var(--input-primary);
|
||||||
|
border-radius: 100px;
|
||||||
|
right: 10px;
|
||||||
|
bottom: 10px;
|
||||||
|
overflow: hidden;
|
||||||
|
z-index: var(--index-floating);
|
||||||
|
}
|
||||||
|
|
||||||
|
.open-filter ::deep svg {
|
||||||
|
fill: var(--white);
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.open-filter:hover ::deep svg {
|
||||||
|
background: var(--input-selected);
|
||||||
|
}
|
||||||
|
|
||||||
.duplicate {
|
.duplicate {
|
||||||
display: none;
|
display: none;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -30,3 +54,28 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 700px) {
|
||||||
|
.advanced-filter-container {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.open-filter {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.advanced-filter-container {
|
||||||
|
border-radius: var(--big-radius) 0 0 var(--big-radius);
|
||||||
|
background: var(--input-primary);
|
||||||
|
border: none;
|
||||||
|
right: 0;
|
||||||
|
position: fixed;
|
||||||
|
z-index: 800;
|
||||||
|
width: auto;
|
||||||
|
height: auto;
|
||||||
|
left: 25vw;
|
||||||
|
bottom: 0;
|
||||||
|
top: 0;
|
||||||
|
padding: 60px 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,16 +7,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.search-container {
|
.search-container {
|
||||||
width: 150px;
|
min-width: 50px;
|
||||||
min-width: 150px;
|
max-width: 150px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.slider-container {
|
.slider-container, .select-container {
|
||||||
width: 150px;
|
|
||||||
min-width: 150px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.select-container {
|
|
||||||
width: 150px;
|
width: 150px;
|
||||||
min-width: 150px;
|
min-width: 150px;
|
||||||
}
|
}
|
||||||
@@ -63,6 +58,16 @@
|
|||||||
padding-right: 1px;
|
padding-right: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 700px) {
|
||||||
|
.slider-container {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.square-button:first-child {
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 1000px) {
|
@media screen and (max-width: 1000px) {
|
||||||
.select-container {
|
.select-container {
|
||||||
display: none;
|
display: none;
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
@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
|
||||||
@using GameIdeas.BlazorApp.Shared.Components.ButtonAdd
|
@using GameIdeas.BlazorApp.Shared.Components.ButtonAdd
|
||||||
@using GameIdeas.BlazorApp.Shared.Components.Header
|
@using GameIdeas.BlazorApp.Shared.Components.Header
|
||||||
@using GameIdeas.BlazorApp.Shared.Components.Popup
|
@using GameIdeas.BlazorApp.Shared.Components.Popup
|
||||||
|
@using GameIdeas.BlazorApp.Shared.Components.Popup.Components
|
||||||
@using GameIdeas.Resources
|
@using GameIdeas.Resources
|
||||||
|
@inherits GameBaseComponent
|
||||||
@layout MainLayout
|
@layout MainLayout
|
||||||
|
|
||||||
<PageTitle>@ResourcesKey.GamesIdeas</PageTitle>
|
<PageTitle>@ResourcesKey.GamesIdeas</PageTitle>
|
||||||
@@ -22,12 +23,22 @@
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
@if (!IsLoading)
|
@if (!IsLoading)
|
||||||
{
|
{
|
||||||
@foreach (var game in GamesDto)
|
@if (GamesDto.NumberOfGames != 0)
|
||||||
{
|
{
|
||||||
<GameRow GameDto="game" />
|
<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
|
else
|
||||||
|
{
|
||||||
|
<div class="no-games">@ResourcesKey.NoGames</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
@for (int i = 0; i < 20; i++)
|
@for (int i = 0; i < 20; i++)
|
||||||
{
|
{
|
||||||
@@ -41,5 +52,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Popup @ref=ManualAddPopup BackdropFilterClicked="HandleBackdropManualAddClicked" Closable=false>
|
<Popup @ref=ManualAddPopup BackdropFilterClicked="HandleBackdropManualAddClicked" Closable=false>
|
||||||
<GameCreationForm Categories="Categories" OnSubmit="() => HandleFetchDatas()" />
|
<GameCreationForm @ref="CreationForm" Categories="Categories" OnSubmit="HandleOnSubmitGame" OnRender="HandleRenderCreationForm" />
|
||||||
|
</Popup>
|
||||||
|
|
||||||
|
<Popup @ref=DeletePopup Closable=false>
|
||||||
|
<ConfirmDelete OnCancel="HandleCancelPopupClicked" OnConfirm="HandleRemoveGame" />
|
||||||
</Popup>
|
</Popup>
|
||||||
@@ -1,24 +1,23 @@
|
|||||||
|
using GameIdeas.BlazorApp.Pages.Games.Components;
|
||||||
using GameIdeas.BlazorApp.Pages.Games.Filter;
|
using GameIdeas.BlazorApp.Pages.Games.Filter;
|
||||||
using GameIdeas.BlazorApp.Pages.Games.Gateways;
|
using GameIdeas.BlazorApp.Shared.Components;
|
||||||
using GameIdeas.BlazorApp.Shared.Components.Popup;
|
using GameIdeas.BlazorApp.Shared.Components.Popup;
|
||||||
using GameIdeas.BlazorApp.Shared.Models;
|
using GameIdeas.BlazorApp.Shared.Models;
|
||||||
using GameIdeas.Shared.Dto;
|
using GameIdeas.Shared.Dto;
|
||||||
using GameIdeas.Shared.Enum;
|
using GameIdeas.Shared.Enum;
|
||||||
using Microsoft.AspNetCore.Components;
|
|
||||||
|
|
||||||
namespace GameIdeas.BlazorApp.Pages.Games;
|
namespace GameIdeas.BlazorApp.Pages.Games;
|
||||||
|
|
||||||
public partial class Games
|
public partial class Games : GameBaseComponent
|
||||||
{
|
{
|
||||||
[Inject] private IGameGateway GameGateway { get; set; } = default!;
|
|
||||||
|
|
||||||
private DisplayType DisplayType = DisplayType.List;
|
private DisplayType DisplayType = DisplayType.List;
|
||||||
private GameFilterParams GameFilter = new();
|
private GameFilterParams GameFilter = new();
|
||||||
private Popup? ManualAddPopup;
|
private GameListDto GamesDto = new();
|
||||||
private bool IsLoading = false;
|
|
||||||
private CategoriesDto? Categories;
|
|
||||||
private IEnumerable<GameDto> GamesDto = [];
|
|
||||||
private int CurrentPage;
|
private int CurrentPage;
|
||||||
|
private Popup? DeletePopup;
|
||||||
|
private GameDto? GameToDelete;
|
||||||
|
private int? GameIdToUpdate;
|
||||||
|
private GameCreationForm? CreationForm;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
@@ -33,31 +32,12 @@ public partial class Games
|
|||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleAddClicked(AddType addType)
|
private async Task HandleFetchDatas(bool displayLoader = true)
|
||||||
{
|
|
||||||
switch (addType)
|
|
||||||
{
|
|
||||||
case AddType.Manual:
|
|
||||||
ManualAddPopup?.Open();
|
|
||||||
break;
|
|
||||||
case AddType.Auto:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void HandleBackdropManualAddClicked()
|
|
||||||
{
|
|
||||||
ManualAddPopup?.Close();
|
|
||||||
}
|
|
||||||
private async Task HandleFetchDatas(bool loadCategories = true, bool displayLoader = true)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IsLoading = displayLoader;
|
IsLoading = displayLoader;
|
||||||
|
StateHasChanged();
|
||||||
if (loadCategories)
|
|
||||||
Categories = await GameGateway.FetchCategories();
|
|
||||||
|
|
||||||
GamesDto = await GameGateway.FetchGames(GameFilter, CurrentPage);
|
GamesDto = await GameGateway.FetchGames(GameFilter, CurrentPage);
|
||||||
}
|
}
|
||||||
@@ -68,11 +48,75 @@ public partial class Games
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
IsLoading = false;
|
IsLoading = false;
|
||||||
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private async Task HandleFilterChanged(GameFilterParams args)
|
private async Task HandleFilterChanged(GameFilterParams args)
|
||||||
{
|
{
|
||||||
GameFilter = args;
|
GameFilter = args;
|
||||||
await HandleFetchDatas(loadCategories: false, displayLoader: false);
|
await HandleFetchDatas(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleDeleteGame(GameDto args)
|
||||||
|
{
|
||||||
|
DeletePopup?.Open();
|
||||||
|
GameToDelete = args;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleCancelPopupClicked()
|
||||||
|
{
|
||||||
|
DeletePopup?.Close();
|
||||||
|
GameToDelete = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleEditGame(GameDto args)
|
||||||
|
{
|
||||||
|
if (args.Id == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameIdToUpdate = args.Id;
|
||||||
|
|
||||||
|
ManualAddPopup?.Open();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task HandleRemoveGame()
|
||||||
|
{
|
||||||
|
DeletePopup?.Close();
|
||||||
|
|
||||||
|
if (GameToDelete?.Id == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IsLoading = true;
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
|
await GameGateway.DeleteGame(GameToDelete?.Id ?? 0);
|
||||||
|
await HandleFetchDatas(false);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameToDelete = null;
|
||||||
|
}
|
||||||
|
private async Task HandleRenderCreationForm()
|
||||||
|
{
|
||||||
|
if (GameIdToUpdate != null && CreationForm != null)
|
||||||
|
{
|
||||||
|
await CreationForm.SetGameToUpdateAsync(GameIdToUpdate ?? 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
GameIdToUpdate = null;
|
||||||
|
}
|
||||||
|
private async Task HandleOnSubmitGame()
|
||||||
|
{
|
||||||
|
await HandleFetchDatas(false);
|
||||||
|
await HandleFetchCategories();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
.container {
|
.container {
|
||||||
display: grid;
|
display: flex;
|
||||||
grid-template-columns: 1fr 240px;
|
|
||||||
padding: 20px 0;
|
padding: 20px 0;
|
||||||
height: fit-content;
|
height: fit-content;
|
||||||
}
|
}
|
||||||
@@ -11,4 +10,5 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 20px;
|
gap: 20px;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
@@ -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)
|
||||||
@@ -76,4 +78,28 @@ public class GameGateway(IHttpClientService httpClientService) : IGameGateway
|
|||||||
throw new CategoryNotFoundException(ResourcesKey.ErrorFetchGames);
|
throw new CategoryNotFoundException(ResourcesKey.ErrorFetchGames);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<bool> DeleteGame(int gameIdToDelete)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return await httpClientService.DeleteAsync<bool>(Endpoints.Game.Delete(gameIdToDelete));
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw new GameDeletionException(ResourcesKey.ErrorDeleteGame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> UpdateGame(GameDetailDto gameDto)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return await httpClientService.PutAsync<int>(Endpoints.Game.Update, gameDto);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw new GameUpdateException(ResourcesKey.ErrorUpdateGame);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ 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<int> UpdateGame(GameDetailDto gameDto);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
@page "/"
|
||||||
|
|
||||||
|
@inject NavigationManager navigationManager
|
||||||
|
|
||||||
|
@code {
|
||||||
|
protected override void OnInitialized()
|
||||||
|
{
|
||||||
|
navigationManager.NavigateTo("/Games");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,9 +10,9 @@ public partial class Login
|
|||||||
[Parameter] public IAuthGateway AuthGateway { get; set; } = default!;
|
[Parameter] public IAuthGateway AuthGateway { get; set; } = default!;
|
||||||
|
|
||||||
private EditContext? EditContext;
|
private EditContext? EditContext;
|
||||||
private UserDto UserDto = new();
|
private readonly UserDto UserDto = new();
|
||||||
private bool IsLoading = false;
|
private bool IsLoading = false;
|
||||||
private LoginValidator Validator = new();
|
private readonly LoginValidator Validator = new();
|
||||||
protected override void OnInitialized()
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
EditContext = new EditContext(UserDto);
|
EditContext = new EditContext(UserDto);
|
||||||
@@ -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()
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using GameIdeas.BlazorApp.Shared.Components.Select;
|
|
||||||
using GameIdeas.BlazorApp.Shared.Components.Select.Models;
|
using GameIdeas.BlazorApp.Shared.Components.Select.Models;
|
||||||
using GameIdeas.Shared.Dto;
|
using GameIdeas.Shared.Dto;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|||||||
@@ -89,3 +89,16 @@
|
|||||||
.submit ::deep svg {
|
.submit ::deep svg {
|
||||||
fill: var(--green);
|
fill: var(--green);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 700px) {
|
||||||
|
.row {
|
||||||
|
height: 104px;
|
||||||
|
display: grid;
|
||||||
|
grid-template-rows: 48px 48px;
|
||||||
|
grid-template-columns: 48px 1fr 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.role {
|
||||||
|
grid-column: 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -28,12 +28,21 @@
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
@if (!IsLoading)
|
@if (!IsLoading)
|
||||||
{
|
{
|
||||||
|
@if (UserList.UsersCount != 0)
|
||||||
|
{
|
||||||
|
<div class="user-number">@string.Format(ResourcesKey.UsersNumberFormat, UserList.UsersCount)</div>
|
||||||
|
|
||||||
@foreach (var user in UserList.Users ?? [])
|
@foreach (var user in UserList.Users ?? [])
|
||||||
{
|
{
|
||||||
<UserRow User="user" Roles="Roles.ToList()" OnRemove="HandleOpenConfirmationPopup" OnSubmit="HandleUpdateUser" Validator="@(new UserUpdateValidator())" CanDelete=@(user.Id != currentUserId) />
|
<UserRow User="user" Roles="Roles.ToList()" OnRemove="HandleOpenConfirmationPopup" OnSubmit="HandleUpdateUser" Validator="@(new UserUpdateValidator())" CanDelete=@(user.Id != currentUserId) />
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
<div class="no-users">@ResourcesKey.NoUsers</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
@for (int i = 0; i < 20; i++)
|
@for (int i = 0; i < 20; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ public partial class Users
|
|||||||
|
|
||||||
private Popup? Popup;
|
private Popup? Popup;
|
||||||
private bool IsLoading = false;
|
private bool IsLoading = false;
|
||||||
private UserFilterParams FilterParams = new();
|
private readonly UserFilterParams FilterParams = new();
|
||||||
private UserListDto UserList = new();
|
private UserListDto UserList = new();
|
||||||
private IEnumerable<RoleDto> Roles = [];
|
private IEnumerable<RoleDto> Roles = [];
|
||||||
private int CurrentPage = 1;
|
private readonly int CurrentPage = 1;
|
||||||
private UserDto UserAdd = new();
|
private UserDto UserAdd = new();
|
||||||
private UserDto? UserDelete;
|
private UserDto? UserDelete;
|
||||||
private string? currentUserId;
|
private string? currentUserId;
|
||||||
@@ -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,19 +98,20 @@ 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)
|
||||||
{
|
{
|
||||||
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()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using System.Net.Http.Json;
|
|
||||||
using Blazored.LocalStorage;
|
using Blazored.LocalStorage;
|
||||||
using GameIdeas.BlazorApp;
|
using GameIdeas.BlazorApp;
|
||||||
using GameIdeas.BlazorApp.Pages.Games.Gateways;
|
using GameIdeas.BlazorApp.Pages.Games.Gateways;
|
||||||
@@ -10,6 +9,7 @@ using GameIdeas.Shared.Constants;
|
|||||||
using Microsoft.AspNetCore.Components.Authorization;
|
using Microsoft.AspNetCore.Components.Authorization;
|
||||||
using Microsoft.AspNetCore.Components.Web;
|
using Microsoft.AspNetCore.Components.Web;
|
||||||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
||||||
|
using System.Net.Http.Json;
|
||||||
|
|
||||||
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
||||||
var services = builder.Services;
|
var services = builder.Services;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
using GameIdeas.Resources;
|
using Blazored.LocalStorage;
|
||||||
using System.Net.Http.Headers;
|
using GameIdeas.Resources;
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
using System.Text.Json;
|
|
||||||
using System.Text;
|
|
||||||
using Blazored.LocalStorage;
|
|
||||||
using GameIdeas.Shared.Constants;
|
using GameIdeas.Shared.Constants;
|
||||||
using Microsoft.AspNetCore.Components.Authorization;
|
using Microsoft.AspNetCore.Components.Authorization;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace GameIdeas.BlazorApp.Services;
|
namespace GameIdeas.BlazorApp.Services;
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
using Blazored.LocalStorage;
|
using Blazored.LocalStorage;
|
||||||
using Microsoft.AspNetCore.Components.Authorization;
|
|
||||||
using System.Security.Claims;
|
|
||||||
using System.IdentityModel.Tokens.Jwt;
|
|
||||||
using GameIdeas.Shared.Constants;
|
using GameIdeas.Shared.Constants;
|
||||||
using GameIdeas.Shared.Dto;
|
using GameIdeas.Shared.Dto;
|
||||||
|
using Microsoft.AspNetCore.Components.Authorization;
|
||||||
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
|
using System.Security.Claims;
|
||||||
|
|
||||||
namespace GameIdeas.BlazorApp.Services;
|
namespace GameIdeas.BlazorApp.Services;
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await Js.InvokeVoidAsync("setBodyOverflow", "auto");
|
await Js.InvokeVoidAsync("setBodyOverflow", "visible");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using GameIdeas.BlazorApp.Shared.Components.Select.Models;
|
|
||||||
using GameIdeas.BlazorApp.Shared.Components.Select;
|
using GameIdeas.BlazorApp.Shared.Components.Select;
|
||||||
|
using GameIdeas.BlazorApp.Shared.Components.Select.Models;
|
||||||
using GameIdeas.BlazorApp.Shared.Models;
|
using GameIdeas.BlazorApp.Shared.Models;
|
||||||
using GameIdeas.Resources;
|
using GameIdeas.Resources;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|||||||
@@ -35,3 +35,9 @@
|
|||||||
background: var(--violet-selected);
|
background: var(--violet-selected);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 700px) {
|
||||||
|
.add-buttons {
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
using GameIdeas.BlazorApp.Pages.Games.Gateways;
|
||||||
|
using GameIdeas.BlazorApp.Shared.Models;
|
||||||
|
using GameIdeas.Shared.Dto;
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
|
namespace GameIdeas.BlazorApp.Shared.Components;
|
||||||
|
|
||||||
|
public class GameBaseComponent : ComponentBase
|
||||||
|
{
|
||||||
|
[Inject] protected IGameGateway GameGateway { get; set; } = default!;
|
||||||
|
|
||||||
|
protected Popup.Popup? ManualAddPopup;
|
||||||
|
protected CategoriesDto? Categories;
|
||||||
|
protected bool IsLoading = false;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
await HandleFetchCategories();
|
||||||
|
await base.OnInitializedAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async Task HandleFetchCategories()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IsLoading = true;
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
|
Categories = await GameGateway.FetchCategories();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IsLoading = false;
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void HandleAddClicked(AddType addType)
|
||||||
|
{
|
||||||
|
switch (addType)
|
||||||
|
{
|
||||||
|
case AddType.Manual:
|
||||||
|
ManualAddPopup?.Open();
|
||||||
|
break;
|
||||||
|
case AddType.Auto:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void HandleBackdropManualAddClicked()
|
||||||
|
{
|
||||||
|
ManualAddPopup?.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,3 @@
|
|||||||
using GameIdeas.BlazorApp.Shared.Components.Select;
|
|
||||||
using GameIdeas.BlazorApp.Shared.Components.Select.Models;
|
|
||||||
using GameIdeas.BlazorApp.Shared.Models;
|
|
||||||
using GameIdeas.Resources;
|
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
namespace GameIdeas.BlazorApp.Shared.Components.Header;
|
namespace GameIdeas.BlazorApp.Shared.Components.Header;
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: flex-end;
|
align-items: flex-end;
|
||||||
padding: 0px 10px;
|
padding: 0px 10px;
|
||||||
height: 40px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-container {
|
.icon-container {
|
||||||
@@ -12,14 +11,14 @@
|
|||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
width: 40px;
|
|
||||||
height: 100%;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
margin-right: 10px;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-container img {
|
.icon-container img {
|
||||||
max-height: 85%;
|
width: 34px;
|
||||||
max-width: 85%;
|
height: 34px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<div class="readmore-container">
|
||||||
|
<div class="text">
|
||||||
|
@DisplayedText()
|
||||||
|
</div>
|
||||||
|
@if (Text?.Length > MaxLength && !_showFullText)
|
||||||
|
{
|
||||||
|
<div class="fade-overlay"></div>
|
||||||
|
}
|
||||||
|
@if (Text?.Length > MaxLength)
|
||||||
|
{
|
||||||
|
<button type="button" class="button" @onclick=ToggleFullText>
|
||||||
|
@(_showFullText ? @ResourcesKey.ReadLess : @ResourcesKey.ReadMore)
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
|
namespace GameIdeas.BlazorApp.Shared.Components.ReadMore;
|
||||||
|
|
||||||
|
public partial class ReadMore
|
||||||
|
{
|
||||||
|
private bool _showFullText = false;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string? Text { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public int MaxLength { get; set; } = 100;
|
||||||
|
|
||||||
|
private string DisplayedText()
|
||||||
|
{
|
||||||
|
if (Text == null) return string.Empty;
|
||||||
|
if (_showFullText || Text.Length <= MaxLength) return Text;
|
||||||
|
|
||||||
|
return Text[..MaxLength] + "...";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ToggleFullText() => _showFullText = !_showFullText;
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
.button {
|
||||||
|
margin: 0 auto 10px auto;
|
||||||
|
border: none;
|
||||||
|
outline: none;
|
||||||
|
background: var(--violet);
|
||||||
|
border-radius: var(--small-radius);
|
||||||
|
z-index: var(--index-floating);
|
||||||
|
color: var(--white);
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 22px;
|
||||||
|
padding: 2px 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button:hover {
|
||||||
|
background: var(--violet-selected);
|
||||||
|
}
|
||||||
|
|
||||||
|
.text {
|
||||||
|
overflow-wrap: break-word;
|
||||||
|
margin: 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.readmore-container {
|
||||||
|
width: 100%;
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
color: var(--white);
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 22px;
|
||||||
|
white-space: break-spaces;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fade-overlay {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 4.5em;
|
||||||
|
background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.4));
|
||||||
|
border-radius: 0 0 var(--big-radius) var(--big-radius);
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
@@ -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"
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -52,3 +52,20 @@
|
|||||||
.single .selected {
|
.single .selected {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***** Navigation Theme *****/
|
||||||
|
.row-option {
|
||||||
|
padding: 4px 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row-option:hover {
|
||||||
|
background: var(--violet-selected);
|
||||||
|
}
|
||||||
|
|
||||||
|
.row-option .selected {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row-option:last-child {
|
||||||
|
color: var(--red);
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@ public static class SelectHelper
|
|||||||
SelectTheme.AdvancedFilter => "advanced-filter",
|
SelectTheme.AdvancedFilter => "advanced-filter",
|
||||||
SelectTheme.Creation => "creation",
|
SelectTheme.Creation => "creation",
|
||||||
SelectTheme.Single => "single",
|
SelectTheme.Single => "single",
|
||||||
|
SelectTheme.RowOption => "row-option",
|
||||||
_ => string.Empty
|
_ => string.Empty
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,5 +7,6 @@ public enum SelectTheme
|
|||||||
Filter,
|
Filter,
|
||||||
AdvancedFilter,
|
AdvancedFilter,
|
||||||
Creation,
|
Creation,
|
||||||
Single
|
Single,
|
||||||
|
RowOption
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
@typeparam THeader
|
@typeparam THeader
|
||||||
|
|
||||||
<div class="select-container">
|
<div class="select-container">
|
||||||
<div class="button" @onclick=HandleButtonClicked>
|
<div class="button @(IsContentOpen ? "selected" : "")" @onclick=HandleButtonClicked>
|
||||||
@ChildContent
|
@ChildContent
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -27,9 +27,9 @@
|
|||||||
|
|
||||||
@if (Params.Headers != null)
|
@if (Params.Headers != null)
|
||||||
{
|
{
|
||||||
@foreach (var header in Params.Headers.Union(HeaderValues ?? []))
|
@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
|
||||||
OnClick="_ => HandleHeaderClicked(header)" />
|
OnClick="_ => HandleHeaderClicked(header)" />
|
||||||
}
|
}
|
||||||
@@ -42,9 +42,9 @@
|
|||||||
|
|
||||||
@if (Params.Items != null)
|
@if (Params.Items != null)
|
||||||
{
|
{
|
||||||
@foreach (var item in Params.Items.Union(Values ?? []))
|
@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
|
||||||
OnClick="_ => HandleValueClicked(item)" />
|
OnClick="_ => HandleValueClicked(item)" />
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
using GameIdeas.BlazorApp.Shared.Components.Select.Models;
|
using GameIdeas.BlazorApp.Shared.Components.Select.Models;
|
||||||
using GameIdeas.Resources;
|
|
||||||
using GameIdeas.Shared.Constants;
|
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using Microsoft.AspNetCore.Components.Forms;
|
using Microsoft.AspNetCore.Components.Forms;
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
|
|
||||||
namespace GameIdeas.BlazorApp.Shared.Components.Select;
|
namespace GameIdeas.BlazorApp.Shared.Components.Select;
|
||||||
|
|
||||||
@@ -92,11 +89,24 @@ public partial class Select<TItem, THeader>
|
|||||||
if (Params.AddItem != null)
|
if (Params.AddItem != null)
|
||||||
{
|
{
|
||||||
Values ??= [];
|
Values ??= [];
|
||||||
Values.Add(Params.AddItem(AddLabel));
|
|
||||||
|
|
||||||
|
if (Type != SelectType.Multiple)
|
||||||
|
{
|
||||||
|
Values = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
Values.Add(Params.AddItem(AddLabel));
|
||||||
AddLabel = string.Empty;
|
AddLabel = string.Empty;
|
||||||
|
|
||||||
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 {
|
||||||
@@ -104,3 +102,13 @@
|
|||||||
.single {
|
.single {
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***** Row Option Theme *****/
|
||||||
|
.dropdown.row-option {
|
||||||
|
width: auto;
|
||||||
|
right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row-option .content {
|
||||||
|
background: var(--violet);
|
||||||
|
}
|
||||||
|
|||||||
@@ -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,6 +1,7 @@
|
|||||||
|
using GameIdeas.BlazorApp.Pages.Games;
|
||||||
using GameIdeas.BlazorApp.Shared.Components.Search;
|
using GameIdeas.BlazorApp.Shared.Components.Search;
|
||||||
using GameIdeas.BlazorApp.Shared.Components.Select.Models;
|
|
||||||
using GameIdeas.BlazorApp.Shared.Components.Select;
|
using GameIdeas.BlazorApp.Shared.Components.Select;
|
||||||
|
using GameIdeas.BlazorApp.Shared.Components.Select.Models;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
namespace GameIdeas.BlazorApp.Shared.Components.SelectSearch;
|
namespace GameIdeas.BlazorApp.Shared.Components.SelectSearch;
|
||||||
@@ -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,26 +29,62 @@ public partial class SelectSearch<TItem>
|
|||||||
{
|
{
|
||||||
Items = Items,
|
Items = Items,
|
||||||
GetItemLabel = GetLabel,
|
GetItemLabel = GetLabel,
|
||||||
|
GetItemOrder = OrderBy,
|
||||||
AddItem = AddItem
|
AddItem = AddItem
|
||||||
};
|
};
|
||||||
|
|
||||||
base.OnParametersSet();
|
base.OnParametersSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnAfterRender(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender && Values != null)
|
||||||
|
{
|
||||||
|
SearchInput?.SetText(string.Join(", ", Values.Select(GetLabel)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task HandleValuesChanged(IEnumerable<TItem> values)
|
private async Task HandleValuesChanged(IEnumerable<TItem> values)
|
||||||
{
|
{
|
||||||
Values = values.ToList();
|
Values = [.. values];
|
||||||
SearchInput?.SetText(string.Join(", ", Values.Select(GetLabel)));
|
SearchInput?.SetText(string.Join(", ", Values.Select(GetLabel)));
|
||||||
await ValuesChanged.InvokeAsync(Values.ToList());
|
await ValuesChanged.InvokeAsync([.. Values]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task HandleClearClicked()
|
private async Task HandleClearClicked()
|
||||||
{
|
{
|
||||||
Values = [];
|
Values = [];
|
||||||
await ValuesChanged.InvokeAsync(Values.ToList());
|
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) ?? []));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,8 @@ public static class Endpoints
|
|||||||
public const string Create = "api/Game/Create";
|
public const string Create = "api/Game/Create";
|
||||||
public static string Fetch(GameFilterDto filter) => $"api/Game?{UrlHelper.BuildUrlParams(filter)}";
|
public static string Fetch(GameFilterDto filter) => $"api/Game?{UrlHelper.BuildUrlParams(filter)}";
|
||||||
public static string FetchById(int gameId) => $"api/Game/{gameId}";
|
public static string FetchById(int gameId) => $"api/Game/{gameId}";
|
||||||
|
public static string Delete(int gameId) => $"api/Game/Delete/{gameId}";
|
||||||
|
public const string Update = "api/Game/Update";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Category
|
public static class Category
|
||||||
|
|||||||
@@ -43,4 +43,8 @@ public static class Icons
|
|||||||
public readonly static MarkupString Back = new(OpenBraket +
|
public readonly static MarkupString Back = new(OpenBraket +
|
||||||
"<path d=\"M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z\" />" +
|
"<path d=\"M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z\" />" +
|
||||||
CloseBraket);
|
CloseBraket);
|
||||||
|
|
||||||
|
public readonly static MarkupString Filter = new(OpenBraket +
|
||||||
|
"<path d=\"M15,19.88C15.04,20.18 14.94,20.5 14.71,20.71C14.32,21.1 13.69,21.1 13.3,20.71L9.29,16.7C9.06,16.47 8.96,16.16 9,15.87V10.75L4.21,4.62C3.87,4.19 3.95,3.56 4.38,3.22C4.57,3.08 4.78,3 5,3V3H19V3C19.22,3 19.43,3.08 19.62,3.22C20.05,3.56 20.13,4.19 19.79,4.62L15,10.75V19.88M7.04,5L11,10.06V15.58L13,17.58V10.05L16.96,5H7.04Z\" />" +
|
||||||
|
CloseBraket);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
namespace GameIdeas.BlazorApp.Shared.Exceptions;
|
||||||
|
|
||||||
|
public class FetchGameDetailException(string message) : Exception(message);
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
namespace GameIdeas.BlazorApp.Shared.Exceptions;
|
||||||
|
|
||||||
|
public class GameDeletionException(string message) : Exception(message);
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
namespace GameIdeas.BlazorApp.Shared.Exceptions;
|
||||||
|
|
||||||
|
public class GameUpdateException(string message) : Exception(message);
|
||||||
@@ -82,62 +82,18 @@ 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 {
|
||||||
@@ -147,9 +103,10 @@ code {
|
|||||||
.body-lg {
|
.body-lg {
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-1, .header-2, span, a {
|
.header-1, .header-2 {
|
||||||
display: block;
|
display: block;
|
||||||
color: var(--white);
|
color: var(--white);
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -157,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>
|
||||||
|
|||||||
@@ -39,10 +39,13 @@ public class Translations (TranslationService translationService)
|
|||||||
public string ErrorFetchCategories => translationService.Translate(nameof(ErrorFetchCategories));
|
public string ErrorFetchCategories => translationService.Translate(nameof(ErrorFetchCategories));
|
||||||
public string PlaceholderAdd => translationService.Translate(nameof(PlaceholderAdd));
|
public string PlaceholderAdd => translationService.Translate(nameof(PlaceholderAdd));
|
||||||
public string ErrorCreateGame => translationService.Translate(nameof(ErrorCreateGame));
|
public string ErrorCreateGame => translationService.Translate(nameof(ErrorCreateGame));
|
||||||
|
public string ErrorDeleteGame => translationService.Translate(nameof(ErrorDeleteGame));
|
||||||
|
public string ErrorUpdateGame => translationService.Translate(nameof(ErrorUpdateGame));
|
||||||
public string InvalidTitle => translationService.Translate(nameof(InvalidTitle));
|
public string InvalidTitle => translationService.Translate(nameof(InvalidTitle));
|
||||||
public string InvalidInterest => translationService.Translate(nameof(InvalidInterest));
|
public string InvalidInterest => translationService.Translate(nameof(InvalidInterest));
|
||||||
public string Unknown => translationService.Translate(nameof(Unknown));
|
public string Unknown => translationService.Translate(nameof(Unknown));
|
||||||
public string ErrorFetchGames => translationService.Translate(nameof(ErrorFetchGames));
|
public string ErrorFetchGames => translationService.Translate(nameof(ErrorFetchGames));
|
||||||
|
public string ErrorFetchDetail => translationService.Translate(nameof(ErrorFetchDetail));
|
||||||
public string Ascending => translationService.Translate(nameof(Ascending));
|
public string Ascending => translationService.Translate(nameof(Ascending));
|
||||||
public string Descending => translationService.Translate(nameof(Descending));
|
public string Descending => translationService.Translate(nameof(Descending));
|
||||||
public string ErrorStorageSpaceLabel => translationService.Translate(nameof(ErrorStorageSpaceLabel));
|
public string ErrorStorageSpaceLabel => translationService.Translate(nameof(ErrorStorageSpaceLabel));
|
||||||
@@ -66,6 +69,15 @@ public class Translations (TranslationService translationService)
|
|||||||
public string ConfirmDeleteDescription => translationService.Translate(nameof(ConfirmDeleteDescription));
|
public string ConfirmDeleteDescription => translationService.Translate(nameof(ConfirmDeleteDescription));
|
||||||
public string Informations => translationService.Translate(nameof(Informations));
|
public string Informations => translationService.Translate(nameof(Informations));
|
||||||
public string About => translationService.Translate(nameof(About));
|
public string About => translationService.Translate(nameof(About));
|
||||||
|
public string ReadMore => translationService.Translate(nameof(ReadMore));
|
||||||
|
public string ReadLess => translationService.Translate(nameof(ReadLess));
|
||||||
|
public string Detail => translationService.Translate(nameof(Detail));
|
||||||
|
public string Edit => translationService.Translate(nameof(Edit));
|
||||||
|
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
|
||||||
@@ -113,10 +125,13 @@ public static class ResourcesKey
|
|||||||
public static string ErrorFetchCategories => _instance?.ErrorFetchCategories ?? throw new InvalidOperationException("ResourcesKey.ErrorFetchCategories is not initialized.");
|
public static string ErrorFetchCategories => _instance?.ErrorFetchCategories ?? throw new InvalidOperationException("ResourcesKey.ErrorFetchCategories is not initialized.");
|
||||||
public static string PlaceholderAdd => _instance?.PlaceholderAdd ?? throw new InvalidOperationException("ResourcesKey.PlaceholderAdd is not initialized.");
|
public static string PlaceholderAdd => _instance?.PlaceholderAdd ?? throw new InvalidOperationException("ResourcesKey.PlaceholderAdd is not initialized.");
|
||||||
public static string ErrorCreateGame => _instance?.ErrorCreateGame ?? throw new InvalidOperationException("ResourcesKey.ErrorCreateGame is not initialized.");
|
public static string ErrorCreateGame => _instance?.ErrorCreateGame ?? throw new InvalidOperationException("ResourcesKey.ErrorCreateGame is not initialized.");
|
||||||
|
public static string ErrorDeleteGame => _instance?.ErrorDeleteGame ?? throw new InvalidOperationException("ResourcesKey.ErrorDeleteGame is not initialized.");
|
||||||
|
public static string ErrorUpdateGame => _instance?.ErrorUpdateGame ?? throw new InvalidOperationException("ResourcesKey.ErrorUpdateGame is not initialized.");
|
||||||
public static string InvalidTitle => _instance?.InvalidTitle ?? throw new InvalidOperationException("ResourcesKey.InvalidTitle is not initialized.");
|
public static string InvalidTitle => _instance?.InvalidTitle ?? throw new InvalidOperationException("ResourcesKey.InvalidTitle is not initialized.");
|
||||||
public static string InvalidInterest => _instance?.InvalidInterest ?? throw new InvalidOperationException("ResourcesKey.InvalidInterest is not initialized.");
|
public static string InvalidInterest => _instance?.InvalidInterest ?? throw new InvalidOperationException("ResourcesKey.InvalidInterest is not initialized.");
|
||||||
public static string Unknown => _instance?.Unknown ?? throw new InvalidOperationException("ResourcesKey.Unknown is not initialized.");
|
public static string Unknown => _instance?.Unknown ?? throw new InvalidOperationException("ResourcesKey.Unknown is not initialized.");
|
||||||
public static string ErrorFetchGames => _instance?.ErrorFetchGames ?? throw new InvalidOperationException("ResourcesKey.ErrorFetchGames is not initialized.");
|
public static string ErrorFetchGames => _instance?.ErrorFetchGames ?? throw new InvalidOperationException("ResourcesKey.ErrorFetchGames is not initialized.");
|
||||||
|
public static string ErrorFetchDetail => _instance?.ErrorFetchDetail ?? throw new InvalidOperationException("ResourcesKey.ErrorFetchDetail is not initialized.");
|
||||||
public static string Ascending => _instance?.Ascending ?? throw new InvalidOperationException("ResourcesKey.Ascending is not initialized.");
|
public static string Ascending => _instance?.Ascending ?? throw new InvalidOperationException("ResourcesKey.Ascending is not initialized.");
|
||||||
public static string Descending => _instance?.Descending ?? throw new InvalidOperationException("ResourcesKey.Descending is not initialized.");
|
public static string Descending => _instance?.Descending ?? throw new InvalidOperationException("ResourcesKey.Descending is not initialized.");
|
||||||
public static string ErrorStorageSpaceLabel => _instance?.ErrorStorageSpaceLabel ?? throw new InvalidOperationException("ResourcesKey.ErrorStorageSpaceLabel is not initialized.");
|
public static string ErrorStorageSpaceLabel => _instance?.ErrorStorageSpaceLabel ?? throw new InvalidOperationException("ResourcesKey.ErrorStorageSpaceLabel is not initialized.");
|
||||||
@@ -140,4 +155,13 @@ public static class ResourcesKey
|
|||||||
public static string ConfirmDeleteDescription => _instance?.ConfirmDeleteDescription ?? throw new InvalidOperationException("ResourcesKey.ConfirmDeleteDescription is not initialized.");
|
public static string ConfirmDeleteDescription => _instance?.ConfirmDeleteDescription ?? throw new InvalidOperationException("ResourcesKey.ConfirmDeleteDescription is not initialized.");
|
||||||
public static string Informations => _instance?.Informations ?? throw new InvalidOperationException("ResourcesKey.Informations is not initialized.");
|
public static string Informations => _instance?.Informations ?? throw new InvalidOperationException("ResourcesKey.Informations is not initialized.");
|
||||||
public static string About => _instance?.About ?? throw new InvalidOperationException("ResourcesKey.About is not initialized.");
|
public static string About => _instance?.About ?? throw new InvalidOperationException("ResourcesKey.About is not initialized.");
|
||||||
|
public static string ReadMore => _instance?.ReadMore ?? throw new InvalidOperationException("ResourcesKey.ReadMore is not initialized.");
|
||||||
|
public static string ReadLess => _instance?.ReadLess ?? throw new InvalidOperationException("ResourcesKey.ReadLess 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 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.");
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@ namespace GameIdeas.Resources;
|
|||||||
|
|
||||||
public class TranslationService
|
public class TranslationService
|
||||||
{
|
{
|
||||||
private readonly Dictionary<string, Dictionary<string, string>?> _translations = new();
|
private readonly Dictionary<string, Dictionary<string, string>?> _translations = [];
|
||||||
|
|
||||||
public void Initialize(Dictionary<string, string> translations)
|
public void Initialize(Dictionary<string, string> translations)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,5 +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;
|
||||||
}
|
}
|
||||||
|
|||||||
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; }
|
||||||
|
}
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
using GameIdeas.Shared.Enum;
|
namespace GameIdeas.Shared.Dto;
|
||||||
|
|
||||||
namespace GameIdeas.Shared.Dto;
|
|
||||||
|
|
||||||
public class UserDto
|
public class UserDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
namespace GameIdeas.Shared.Exceptions;
|
||||||
|
|
||||||
|
public class EnvironmentVariableMissingException(string message) : Exception(message);
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
namespace GameIdeas.Shared.Exceptions;
|
||||||
|
|
||||||
|
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);
|
||||||
@@ -31,4 +31,3 @@ public partial class Game
|
|||||||
public virtual ICollection<GameProperty> GameProperties { get; set; }
|
public virtual ICollection<GameProperty> GameProperties { get; set; }
|
||||||
public virtual ICollection<GameTag> GameTags { get; set; }
|
public virtual ICollection<GameTag> GameTags { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
}
|
||||||
@@ -25,14 +25,16 @@ public class GameIdeasContext : IdentityDbContext<User>
|
|||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
modelBuilder.Entity<Developer>(entity => {
|
modelBuilder.Entity<Developer>(entity =>
|
||||||
|
{
|
||||||
entity.ToTable("Developer");
|
entity.ToTable("Developer");
|
||||||
|
|
||||||
entity.HasIndex(e => e.Name)
|
entity.HasIndex(e => e.Name)
|
||||||
.IsUnique();
|
.IsUnique();
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<Platform>(entity => {
|
modelBuilder.Entity<Platform>(entity =>
|
||||||
|
{
|
||||||
entity.ToTable("Platform");
|
entity.ToTable("Platform");
|
||||||
|
|
||||||
entity.HasIndex(e => e.Label)
|
entity.HasIndex(e => e.Label)
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
namespace GameIdeas.WebAPI.Exceptions;
|
|
||||||
|
|
||||||
public class UserInvalidException (string message) : Exception(message);
|
|
||||||
@@ -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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -35,10 +35,13 @@
|
|||||||
"ErrorFetchCategories": "Erreur lors de la récupération des catégories",
|
"ErrorFetchCategories": "Erreur lors de la récupération des catégories",
|
||||||
"PlaceholderAdd": "Ajouter un nouveau",
|
"PlaceholderAdd": "Ajouter un nouveau",
|
||||||
"ErrorCreateGame": "Erreur lors de la création d'un jeu",
|
"ErrorCreateGame": "Erreur lors de la création d'un jeu",
|
||||||
|
"ErrorDeleteGame": "Erreur lors de la suppression d'un jeu",
|
||||||
|
"ErrorUpdateGame": "Erreur lors de la modification d'un jeu",
|
||||||
"InvalidTitle": "Le titre est incorrect",
|
"InvalidTitle": "Le titre est incorrect",
|
||||||
"InvalidInterest": "L'interêt est incorrect",
|
"InvalidInterest": "L'interêt est incorrect",
|
||||||
"Unknown": "Inconnu",
|
"Unknown": "Inconnu",
|
||||||
"ErrorFetchGames": "Erreur lors de la récupération des jeux",
|
"ErrorFetchGames": "Erreur lors de la récupération des jeux",
|
||||||
|
"ErrorFetchDetail": "Erreur lors de la récupération des détails d'un jeu",
|
||||||
"Ascending": "Ascendant",
|
"Ascending": "Ascendant",
|
||||||
"Descending": "Descendant",
|
"Descending": "Descendant",
|
||||||
"ErrorStorageSpaceLabel": "Erreur lors de la génération des label de l'espace de stockage",
|
"ErrorStorageSpaceLabel": "Erreur lors de la génération des label de l'espace de stockage",
|
||||||
@@ -61,5 +64,14 @@
|
|||||||
"Confirm": "Confirmer",
|
"Confirm": "Confirmer",
|
||||||
"ConfirmDeleteDescription": "Êtes-vous sur de vouloir supprimer cet élément ?",
|
"ConfirmDeleteDescription": "Êtes-vous sur de vouloir supprimer cet élément ?",
|
||||||
"Informations": "Informations",
|
"Informations": "Informations",
|
||||||
"About": "À propos"
|
"About": "À propos",
|
||||||
|
"ReadMore": "Afficher",
|
||||||
|
"ReadLess": "Réduire",
|
||||||
|
"Detail": "Détail",
|
||||||
|
"Edit": "Modifier",
|
||||||
|
"Delete": "Supprimer",
|
||||||
|
"NoGames": "Pas de jeux disponible",
|
||||||
|
"NoUsers": "Pas d'utilisateurs disponible",
|
||||||
|
"GamesNumberFormat": "Nombre de jeux : {0}",
|
||||||
|
"UsersNumberFormat": "Nombre d'utilisateurs : {0}"
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ namespace GameIdeas.WebAPI.Migrations
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.Sql(@$"DELETE FROM ""AspNetUserRoles"" WHERE ""UserId"" = '{GlobalConstants.ADMINISTRATOR_USER_ID.ToString()}' AND ""RoleId"" = '{GlobalConstants.ADMINISTRATOR_ID.ToString()}'");
|
migrationBuilder.Sql(@$"DELETE FROM ""AspNetUserRoles"" WHERE ""UserId"" = '{GlobalConstants.ADMINISTRATOR_USER_ID}' AND ""RoleId"" = '{GlobalConstants.ADMINISTRATOR_ID}'");
|
||||||
migrationBuilder.DeleteData("AspNetUsers", "Id", GlobalConstants.ADMINISTRATOR_USER_ID.ToString());
|
migrationBuilder.DeleteData("AspNetUsers", "Id", GlobalConstants.ADMINISTRATOR_USER_ID.ToString());
|
||||||
migrationBuilder.DeleteData("AspNetRoles", "Id", GlobalConstants.ADMINISTRATOR_ID.ToString());
|
migrationBuilder.DeleteData("AspNetRoles", "Id", GlobalConstants.ADMINISTRATOR_ID.ToString());
|
||||||
migrationBuilder.DeleteData("AspNetRoles", "Id", GlobalConstants.MEMBER_ID.ToString());
|
migrationBuilder.DeleteData("AspNetRoles", "Id", GlobalConstants.MEMBER_ID.ToString());
|
||||||
|
|||||||
@@ -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)
|
||||||
@@ -130,15 +136,14 @@ public class GameReadService(GameIdeasContext context, IMapper mapper, ICategory
|
|||||||
.Select(k => k.Trim())
|
.Select(k => k.Trim())
|
||||||
.ToArray() ?? [];
|
.ToArray() ?? [];
|
||||||
|
|
||||||
games = games
|
games = [.. games
|
||||||
.Where(game => keywords.All(
|
.Where(game => keywords.All(
|
||||||
kw => game.Title.Contains(kw, StringComparison.OrdinalIgnoreCase)
|
kw => game.Title.Contains(kw, StringComparison.OrdinalIgnoreCase)
|
||||||
))
|
))
|
||||||
.OrderBy(game => keywords.Min(kw =>
|
.OrderBy(game => keywords.Min(kw =>
|
||||||
game.Title.IndexOf(kw, StringComparison.OrdinalIgnoreCase)
|
game.Title.IndexOf(kw, StringComparison.OrdinalIgnoreCase)
|
||||||
))
|
))
|
||||||
.ThenBy(game => game.Title.Length)
|
.ThenBy(game => game.Title.Length)];
|
||||||
.ToList();
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -147,10 +152,9 @@ public class GameReadService(GameIdeasContext context, IMapper mapper, ICategory
|
|||||||
{
|
{
|
||||||
var storageSpaces = categoryService.GetStorageSpaces().Where(stor => filter.StorageSpaces.Contains(stor.Id));
|
var storageSpaces = categoryService.GetStorageSpaces().Where(stor => filter.StorageSpaces.Contains(stor.Id));
|
||||||
|
|
||||||
games = games
|
games = [.. games
|
||||||
.Where(game => storageSpaces.Any(stor =>
|
.Where(game => storageSpaces.Any(stor =>
|
||||||
(stor.MinSize ?? int.MinValue) <= game.StorageSpace && (stor.MaxSize ?? int.MaxValue) > game.StorageSpace))
|
(stor.MinSize ?? int.MinValue) <= game.StorageSpace && (stor.MaxSize ?? int.MaxValue) > game.StorageSpace))];
|
||||||
.ToList();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using GameIdeas.Shared.Exceptions;
|
|||||||
using GameIdeas.Shared.Model;
|
using GameIdeas.Shared.Model;
|
||||||
using GameIdeas.WebAPI.Context;
|
using GameIdeas.WebAPI.Context;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace GameIdeas.WebAPI.Services.Games;
|
namespace GameIdeas.WebAPI.Services.Games;
|
||||||
|
|
||||||
@@ -13,7 +14,7 @@ public class GameWriteService(GameIdeasContext context, IMapper mapper) : IGameW
|
|||||||
{
|
{
|
||||||
var gameToCreate = mapper.Map<Game>(gameDto);
|
var gameToCreate = mapper.Map<Game>(gameDto);
|
||||||
|
|
||||||
HandleDeveloperPublisherCreation(gameToCreate);
|
await HandleDeveloperPublisherCreation(gameToCreate);
|
||||||
await context.Games.AddAsync(gameToCreate);
|
await context.Games.AddAsync(gameToCreate);
|
||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync();
|
||||||
|
|
||||||
@@ -35,7 +36,7 @@ public class GameWriteService(GameIdeasContext context, IMapper mapper) : IGameW
|
|||||||
|
|
||||||
var gameToUpdate = mapper.Map<Game>(gameDto);
|
var gameToUpdate = mapper.Map<Game>(gameDto);
|
||||||
|
|
||||||
HandleDeveloperPublisherCreation(gameToUpdate);
|
await HandleDeveloperPublisherCreation(gameToUpdate);
|
||||||
await HandlePlatformsCreation(gameDto.Platforms, gameToUpdate.Id);
|
await HandlePlatformsCreation(gameDto.Platforms, gameToUpdate.Id);
|
||||||
await HandlePropertiesCreation(gameDto.Properties, gameToUpdate.Id);
|
await HandlePropertiesCreation(gameDto.Properties, gameToUpdate.Id);
|
||||||
await HandleTagsCreation(gameDto.Tags, gameToUpdate.Id);
|
await HandleTagsCreation(gameDto.Tags, gameToUpdate.Id);
|
||||||
@@ -48,12 +49,27 @@ public class GameWriteService(GameIdeasContext context, IMapper mapper) : IGameW
|
|||||||
|
|
||||||
public async Task<bool> DeleteGame(int gameId)
|
public async Task<bool> DeleteGame(int gameId)
|
||||||
{
|
{
|
||||||
|
await HandlePlatformsCreation([], gameId);
|
||||||
|
await HandlePropertiesCreation([], gameId);
|
||||||
|
await HandleTagsCreation([], gameId);
|
||||||
|
|
||||||
var gameToRemove = await context.Games
|
var gameToRemove = await context.Games
|
||||||
.FirstOrDefaultAsync(g => g.Id == gameId)
|
.FirstOrDefaultAsync(g => g.Id == gameId)
|
||||||
?? throw new NotFoundException($"[{typeof(Game).FullName}] with ID {gameId} has not been found in context");
|
?? throw new NotFoundException($"[{typeof(Game).FullName}] with ID {gameId} has not been found in context");
|
||||||
|
|
||||||
context.Games.Remove(gameToRemove);
|
context.Games.Remove(gameToRemove);
|
||||||
return await context.SaveChangesAsync() != 0;
|
await context.SaveChangesAsync();
|
||||||
|
|
||||||
|
context.Publishers.RemoveRange(
|
||||||
|
context.Publishers.Include(p => p.Games)
|
||||||
|
.Where(p => p.Games.Count == 0));
|
||||||
|
|
||||||
|
context.Developers.RemoveRange(
|
||||||
|
context.Developers.Include(d => d.Games)
|
||||||
|
.Where(d => d.Games.Count == 0));
|
||||||
|
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task HandlePlatformsCreation(IEnumerable<PlatformDto>? categoriesToCreate, int gameId)
|
private async Task HandlePlatformsCreation(IEnumerable<PlatformDto>? categoriesToCreate, int gameId)
|
||||||
@@ -62,6 +78,9 @@ public class GameWriteService(GameIdeasContext context, IMapper mapper) : IGameW
|
|||||||
{
|
{
|
||||||
var gps = mapper.Map<ICollection<GamePlatform>>(categoriesToCreate);
|
var gps = mapper.Map<ICollection<GamePlatform>>(categoriesToCreate);
|
||||||
|
|
||||||
|
context.GamePlatforms.RemoveRange(
|
||||||
|
context.GamePlatforms.Where(gp => gp.GameId == gameId));
|
||||||
|
|
||||||
foreach (var gp in gps)
|
foreach (var gp in gps)
|
||||||
{
|
{
|
||||||
gp.GameId = gameId;
|
gp.GameId = gameId;
|
||||||
@@ -69,6 +88,14 @@ public class GameWriteService(GameIdeasContext context, IMapper mapper) : IGameW
|
|||||||
|
|
||||||
context.Platforms.AttachRange(gps.Select(gp => gp.Platform));
|
context.Platforms.AttachRange(gps.Select(gp => gp.Platform));
|
||||||
await context.GamePlatforms.AddRangeAsync(gps);
|
await context.GamePlatforms.AddRangeAsync(gps);
|
||||||
|
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
|
||||||
|
context.Platforms.RemoveRange(
|
||||||
|
context.Platforms.Include(p => p.GamePlatforms)
|
||||||
|
.Where(p => p.GamePlatforms.Count == 0));
|
||||||
|
|
||||||
|
await context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,6 +105,9 @@ public class GameWriteService(GameIdeasContext context, IMapper mapper) : IGameW
|
|||||||
{
|
{
|
||||||
var gps = mapper.Map<ICollection<GameProperty>>(categoriesToCreate);
|
var gps = mapper.Map<ICollection<GameProperty>>(categoriesToCreate);
|
||||||
|
|
||||||
|
context.GameProperties.RemoveRange(
|
||||||
|
context.GameProperties.Where(gp => gp.GameId == gameId));
|
||||||
|
|
||||||
foreach (var gp in gps)
|
foreach (var gp in gps)
|
||||||
{
|
{
|
||||||
gp.GameId = gameId;
|
gp.GameId = gameId;
|
||||||
@@ -85,6 +115,14 @@ public class GameWriteService(GameIdeasContext context, IMapper mapper) : IGameW
|
|||||||
|
|
||||||
context.Properties.AttachRange(gps.Select(gp => gp.Property));
|
context.Properties.AttachRange(gps.Select(gp => gp.Property));
|
||||||
await context.GameProperties.AddRangeAsync(gps);
|
await context.GameProperties.AddRangeAsync(gps);
|
||||||
|
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
|
||||||
|
context.Properties.RemoveRange(
|
||||||
|
context.Properties.Include(p => p.GameProperties)
|
||||||
|
.Where(p => p.GameProperties.Count == 0));
|
||||||
|
|
||||||
|
await context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,6 +132,9 @@ public class GameWriteService(GameIdeasContext context, IMapper mapper) : IGameW
|
|||||||
{
|
{
|
||||||
var gts = mapper.Map<ICollection<GameTag>>(categoriesToCreate);
|
var gts = mapper.Map<ICollection<GameTag>>(categoriesToCreate);
|
||||||
|
|
||||||
|
context.GameTags.RemoveRange(
|
||||||
|
context.GameTags.Where(gt => gt.GameId == gameId));
|
||||||
|
|
||||||
foreach (var gt in gts)
|
foreach (var gt in gts)
|
||||||
{
|
{
|
||||||
gt.GameId = gameId;
|
gt.GameId = gameId;
|
||||||
@@ -101,11 +142,30 @@ public class GameWriteService(GameIdeasContext context, IMapper mapper) : IGameW
|
|||||||
|
|
||||||
context.Tags.AttachRange(gts.Select(gt => gt.Tag));
|
context.Tags.AttachRange(gts.Select(gt => gt.Tag));
|
||||||
await context.GameTags.AddRangeAsync(gts);
|
await context.GameTags.AddRangeAsync(gts);
|
||||||
|
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
|
||||||
|
context.Tags.RemoveRange(
|
||||||
|
context.Tags.Include(t => t.GameTags)
|
||||||
|
.Where(t => t.GameTags.Count == 0));
|
||||||
|
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleDeveloperPublisherCreation(Game? game)
|
private async Task HandleDeveloperPublisherCreation(Game? game)
|
||||||
{
|
{
|
||||||
|
context.Publishers.RemoveRange(
|
||||||
|
context.Publishers.Include(p => p.Games)
|
||||||
|
.Where(p => p.Games.Count == 0));
|
||||||
|
|
||||||
|
context.Developers.RemoveRange(
|
||||||
|
context.Developers.Include(d => d.Games)
|
||||||
|
.Where(d => d.Games.Count == 0));
|
||||||
|
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
|
||||||
if (game?.Publisher != null)
|
if (game?.Publisher != null)
|
||||||
{
|
{
|
||||||
context.Publishers.Attach(game.Publisher);
|
context.Publishers.Attach(game.Publisher);
|
||||||
|
|||||||
@@ -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,9 +36,10 @@ 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);
|
||||||
|
|
||||||
@@ -91,15 +95,14 @@ public class UserReadService(
|
|||||||
.Select(k => k.Trim())
|
.Select(k => k.Trim())
|
||||||
.ToArray() ?? [];
|
.ToArray() ?? [];
|
||||||
|
|
||||||
users = users
|
users = [.. users
|
||||||
.Where(user => keywords.All(
|
.Where(user => keywords.All(
|
||||||
kw => user.UserName?.Contains(kw, StringComparison.OrdinalIgnoreCase) ?? true
|
kw => user.UserName?.Contains(kw, StringComparison.OrdinalIgnoreCase) ?? true
|
||||||
))
|
))
|
||||||
.OrderBy(user => keywords.Min(kw =>
|
.OrderBy(user => keywords.Min(kw =>
|
||||||
user.UserName?.IndexOf(kw, StringComparison.OrdinalIgnoreCase)
|
user.UserName?.IndexOf(kw, StringComparison.OrdinalIgnoreCase)
|
||||||
))
|
))
|
||||||
.ThenBy(user => user.UserName?.Length)
|
.ThenBy(user => user.UserName?.Length)];
|
||||||
.ToList();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,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,8 +1,7 @@
|
|||||||
using AutoMapper;
|
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