Correct bunch of issues (#36)
All checks were successful
Game Ideas deploy / build-test-deploy (push) Successful in 1m28s

Reviewed-on: #36
This commit was merged in pull request #36.
This commit is contained in:
2025-04-29 23:49:11 +02:00
parent d3d16493e6
commit f3c9e1d9da
37 changed files with 246 additions and 186 deletions

View File

@@ -69,7 +69,7 @@
}
.slider {
padding: 0 20px;
margin-right: 20px;
align-content: center;
}

View File

@@ -1,5 +1,4 @@
using GameIdeas.BlazorApp.Helpers;
using GameIdeas.BlazorApp.Pages.Games.Header;
using GameIdeas.BlazorApp.Shared.Components.Select.Models;
using GameIdeas.Resources;
using GameIdeas.Shared.Dto;

View File

@@ -47,8 +47,7 @@
<div class="slider-container">
<SliderRange Params="SliderRangeParams"
@bind-Max="Value.MaxInterest" @bind-Max:after="HandleValueChanged"
@bind-Min="Value.MinInterest" @bind-Min:after="HandleValueChanged" />
@bind-Value="Value.Interest" @bind-Value:after="HandleValueChanged" />
</div>
</div>

View File

@@ -2,7 +2,7 @@
display: flex;
flex-direction: row;
gap: 8px;
margin: 0 8px;
margin: 0 auto;
align-items: center;
}

View File

@@ -12,8 +12,7 @@ public class GameFilterParams
public List<TagDto>? Tags { get; set; }
public List<PublisherDto>? Publishers { get; set; }
public List<DeveloperDto>? Developers { get; set; }
public int MinInterest { get; set; } = 1;
public int MaxInterest { get; set; } = 5;
public MinMaxDto Interest { get; set; } = new() { Min = 1, Max = 5 };
public List<int>? ReleaseYears { get; set; }
public List<int>? StorageSpaceIds { get; set; }
}

View File

@@ -1,9 +1,10 @@
@page "/Games"
@page "/"
@using GameIdeas.BlazorApp.Layouts
@using GameIdeas.BlazorApp.Pages.Games.Components
@using GameIdeas.BlazorApp.Pages.Games.Filter
@using GameIdeas.BlazorApp.Pages.Games.Header
@using GameIdeas.BlazorApp.Shared.Components
@using GameIdeas.BlazorApp.Shared.Components.ButtonAdd
@using GameIdeas.BlazorApp.Shared.Components.Header
@using GameIdeas.BlazorApp.Shared.Components.Popup
@using GameIdeas.Resources
@@ -11,11 +12,12 @@
<PageTitle>@ResourcesKey.GamesIdeas</PageTitle>
<GameHeader AddTypeChanged="HandleAddClicked">
<HeaderGameIdeas>
<GameFilter Categories="Categories"
@bind-DisplayType=DisplayType
Value=GameFilter ValueChanged="HandleFilterChanged" />
</GameHeader>
<ButtonAdd AddTypeChanged="HandleAddClicked" />
</HeaderGameIdeas>
<div class="container">
<div class="content">

View File

@@ -43,8 +43,8 @@ public class GameGateway(IHttpClientService httpClientService) : IGameGateway
{
CurrentPage = currentPage,
Title = filterParams.Title,
MaxInterest = filterParams.MaxInterest,
MinInterest = filterParams.MinInterest,
MaxInterest = filterParams.Interest.Max,
MinInterest = filterParams.Interest.Min,
StorageSpaces = filterParams.StorageSpaceIds,
DeveloperIds = filterParams.Developers?.Select(d => d.Id ?? 0).ToList(),
PublisherIds = filterParams.Publishers?.Select(d => d.Id ?? 0).ToList(),

View File

@@ -1,45 +0,0 @@
@using GameIdeas.BlazorApp.Pages.Games
@using GameIdeas.BlazorApp.Pages.UserMenu
@using GameIdeas.BlazorApp.Shared.Components.Select
@using GameIdeas.BlazorApp.Shared.Components.Select.Models
@using GameIdeas.BlazorApp.Shared.Models
@using GameIdeas.Resources
@using GameIdeas.Shared.Constants
@using Microsoft.AspNetCore.Components.Authorization
@inherits ComponentBase
<div class="header-tab">
<a href="/Games" class="icon-container">
<img src="icon.png" alt="Game Ideas">
</a>
@ChildContent
<div class="account-add-container">
@if (DisplayAdd)
{
<AuthorizeView Roles="@GlobalConstants.ADMIN_MEMBER">
<Authorized>
<div class="add-buttons">
<div class="first-button button">
<svg class="button-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z" />
</svg>
</div>
<Select @ref="SelectListAdd" TItem="KeyValuePair<AddType, string>" THeader="object"
ValuesChanged=HandleAddTypeClicked Params=SelectParams Theme="SelectTheme.Navigation">
<div class="second-button button">
<svg class="button-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M1 3H23L12 22" />
</svg>
</div>
</Select>
</div>
</Authorized>
</AuthorizeView>
}
<UserMenu />
</div>
</div>

View File

@@ -1,40 +0,0 @@
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;
namespace GameIdeas.BlazorApp.Pages.Games.Header;
public partial class GameHeader : ComponentBase
{
[Parameter] public bool DisplayAdd { get; set; } = true;
[Parameter] public EventCallback<AddType> AddTypeChanged { get; set; }
[Parameter] public RenderFragment? ChildContent { get; set; }
private readonly Dictionary<AddType, string> AddTypes = new() {
{ AddType.Manual, ResourcesKey.ManualAdd },
{ AddType.Auto, ResourcesKey.AutoAdd }
};
private Select<KeyValuePair<AddType, string>, object>? SelectListAdd;
private SelectParams<KeyValuePair<AddType, string>, object> SelectParams = new();
protected override void OnInitialized()
{
SelectParams = new()
{
Items = [.. AddTypes],
GetItemLabel = item => item.Value
};
base.OnInitialized();
}
private async Task HandleAddTypeClicked(IEnumerable<KeyValuePair<AddType, string>> values)
{
SelectListAdd?.Close();
await AddTypeChanged.InvokeAsync(values.FirstOrDefault().Key);
}
}

View File

@@ -1,67 +0,0 @@
.header-tab {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: flex-end;
padding: 0px 10px;
height: 40px;
}
.icon-container {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
width: 40px;
height: 100%;
cursor: pointer;
}
.icon-container img {
max-height: 85%;
max-width: 85%;
}
.account-add-container {
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: flex-end;
}
.add-buttons {
display: flex;
flex-direction: row;
background: var(--violet);
border-radius: var(--small-radius);
margin-right: 40px;
}
.button {
display: flex;
justify-content: center;
align-items: center;
width: 28px;
height: 28px;
}
.first-button {
border-right: 2px solid var(--violet-selected);
border-radius: var(--small-radius) 0 0 var(--small-radius);
overflow: hidden;
}
.second-button .button-icon {
padding: 6px;
border-radius: 0 var(--small-radius) var(--small-radius) 0;
overflow: hidden;
}
.button-icon {
fill: var(--white);
}
.button-icon:hover {
background: var(--violet-selected);
cursor: pointer;
}

View File

@@ -14,8 +14,10 @@ public class AuthGateway(IHttpClientService httpClient,
{
try
{
var token = await httpClient.PostAsync<TokenDto>(Endpoints.Auth.Login, userDto);
await ((JwtAuthenticationStateProvider)stateProvider).NotifyUserAuthenticationAsync(token!.Token!);
var token = await httpClient.PostAsync<TokenDto>(Endpoints.Auth.Login, userDto)
?? throw new InvalidOperationException("Could not retrieve token");
await ((JwtAuthenticationStateProvider)stateProvider).NotifyUserAuthenticationAsync(token);
return true;
}
catch (Exception)

View File

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

View File

@@ -23,7 +23,10 @@
</Select>
</div>
<div class="buttons">
<button type="button" class="remove" @onclick="HandleRemoveClicked">@Icons.Bin</button>
@if (CanDelete)
{
<button type="button" class="remove" @onclick="HandleRemoveClicked">@Icons.Bin</button>
}
@if (CanEdit)
{
<button type="button" class="edit @(IsEditing ? "selected" : "")" @onclick="HandleEditClicked">@Icons.Pen</button>

View File

@@ -12,6 +12,7 @@ public partial class UserRow
[Parameter] public UserDto User { get; set; } = new();
[Parameter] public List<RoleDto> Roles { get; set; } = [];
[Parameter] public bool CanEdit { get; set; } = true;
[Parameter] public bool CanDelete { get; set; } = true;
[Parameter] public bool IsEditing { get; set; } = false;
[Parameter] public EventCallback<UserDto> OnRemove { get; set; }
[Parameter] public EventCallback<UserDto> OnSubmit { get; set; }

View File

@@ -1,7 +1,7 @@
.row {
height: 64px;
display: grid;
grid-template-columns: 48px 1fr 1fr 1fr auto;
grid-template-columns: 48px 1fr 1fr 1fr 100px;
grid-gap: 8px;
padding: 0 8px;
background: var(--input-secondary);
@@ -9,25 +9,24 @@
border-radius: var(--big-radius);
}
.row > * {
align-content: center;
}
.row > * {
align-content: center;
max-width: 160px;
width: 100%;
}
.icon ::deep svg {
fill: var(--line);
}
.role {
min-width: 160px;
width: fit-content;
}
::deep .input-name,
::deep .input-name[disabled],
::deep .input-password,
::deep .input-password[disabled],
::deep .input-password::placeholder {
color: var(--white);
max-width: 160px;
width: 100%;
}
::deep .input-name,
@@ -61,12 +60,13 @@
flex-direction: row;
gap: 8px;
height:auto;
justify-content: end;
}
.buttons > * {
border: none;
outline: none;
margin: auto;
margin: auto 0;
height: 28px;
width: 28px;
background: none;

View File

@@ -1,7 +1,7 @@
@page "/Users"
@using GameIdeas.BlazorApp.Pages.Games.Header
@using GameIdeas.BlazorApp.Layouts
@using GameIdeas.BlazorApp.Pages.Users.Components
@using GameIdeas.BlazorApp.Shared.Components.Header
@using GameIdeas.BlazorApp.Shared.Components.Popup
@using GameIdeas.BlazorApp.Shared.Components.Popup.Components
@using GameIdeas.BlazorApp.Shared.Components.Search
@@ -13,13 +13,13 @@
<PageTitle>@ResourcesKey.GamesIdeas</PageTitle>
<GameHeader DisplayAdd="false">
<HeaderGameIdeas>
<div class="header-content">
<SearchInput Placeholder="@ResourcesKey.EnterUsername" @bind-Text="FilterParams.Name" @bind-Text:after=HandleFilterChanged />
<SelectSearch TItem="RoleDto" Placeholder="@ResourcesKey.Roles" @bind-Values="FilterParams.Roles" @bind-Values:after=HandleFilterChanged
Items="Roles.ToList()" GetLabel="@(role => role.Name)" Theme="SelectTheme.Filter" />
</div>
</GameHeader>
</HeaderGameIdeas>
<div class="container">
<UserRow User="UserAdd" Roles="Roles.ToList()" CanEdit="false" IsEditing="true" OnRemove="HandleResetUser" OnSubmit="HandleSubmitUser" Validator="@(new UserCreateValidator())" />
@@ -31,7 +31,7 @@
{
@foreach (var user in UserList.Users ?? [])
{
<UserRow User="user" Roles="Roles.ToList()" OnRemove="HandleOpenConfirmationPopup" OnSubmit="HandleUpdateUser" Validator="@(new UserUpdateValidator())" />
<UserRow User="user" Roles="Roles.ToList()" OnRemove="HandleOpenConfirmationPopup" OnSubmit="HandleUpdateUser" Validator="@(new UserUpdateValidator())" CanDelete=@(user.Id != currentUserId) />
}
}
else

View File

@@ -1,14 +1,19 @@
using GameIdeas.BlazorApp.Pages.Users.Filters;
using GameIdeas.BlazorApp.Pages.Users.Gateways;
using GameIdeas.BlazorApp.Shared.Components.Popup;
using GameIdeas.Shared.Constants;
using GameIdeas.Shared.Dto;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using System.Security.Claims;
namespace GameIdeas.BlazorApp.Pages.Users;
public partial class Users
{
[Inject] private IUserGateway UserGateway { get; set; } = default!;
[Inject] private AuthenticationStateProvider StateProvider { get; set; } = default!;
[Inject] private NavigationManager NavigationManager { get; set; } = default!;
private Popup? Popup;
private bool IsLoading = false;
@@ -18,9 +23,19 @@ public partial class Users
private int CurrentPage = 1;
private UserDto UserAdd = new();
private UserDto? UserDelete;
private string? currentUserId;
protected override async Task OnInitializedAsync()
{
var authState = await StateProvider.GetAuthenticationStateAsync();
currentUserId = authState.User.FindFirstValue(ClaimTypes.Sid);
if (authState.User.FindFirstValue(ClaimTypes.Role) != GlobalConstants.ADMINISTRATOR || string.IsNullOrEmpty(currentUserId))
{
NavigationManager.NavigateTo("/Unauthorized");
return;
}
await FetchData();
await base.OnInitializedAsync();
}

View File

@@ -1,6 +1,6 @@
.header-content {
margin: 0 auto;
display: flex;
flex-direction: row;
gap: 8px;
}