Correct bunch of issues #36
@@ -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>
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
<PageTitle>@ResourcesKey.GamesIdeas</PageTitle>
|
||||
|
||||
<HeaderGameIdeas 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
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.header-content {
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user