Rimozione
This commit is contained in:
@ -17,7 +17,7 @@
|
|||||||
<link href="/libs/Fontawesome/css/all.min.css" rel="stylesheet" />
|
<link href="/libs/Fontawesome/css/all.min.css" rel="stylesheet" />
|
||||||
<link href="/libs/Fontawesome/css/regular.min.css" rel="stylesheet" />
|
<link href="/libs/Fontawesome/css/regular.min.css" rel="stylesheet" />
|
||||||
<link rel="icon" type="image/png" href="favicon.png" />
|
<link rel="icon" type="image/png" href="favicon.png" />
|
||||||
<RadzenTheme Theme="material" @rendermode="InteractiveServer" />
|
<RadzenTheme Theme="material" />
|
||||||
<HeadOutlet />
|
<HeadOutlet />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
@using Microsoft.AspNetCore.Authentication
|
@using Microsoft.AspNetCore.Authentication
|
||||||
@inherits LayoutComponentBase
|
@inherits LayoutComponentBase
|
||||||
|
<RadzenComponents @rendermode="InteractiveAuto" />
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<!-- NAV MENU MANAGEMENT -->
|
<!-- NAV MENU MANAGEMENT -->
|
||||||
<header class="navbar navbar-expand-md d-print-none" >
|
<header class="navbar navbar-expand-md d-print-none" >
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
@rendermode InteractiveServer
|
@rendermode InteractiveServer
|
||||||
|
|
||||||
@inject DialogService DialogService
|
@inject AuthenticationStateProvider auth
|
||||||
|
|
||||||
<PageTitle>Utenti</PageTitle>
|
<PageTitle>Utenti</PageTitle>
|
||||||
|
|
||||||
@ -40,8 +40,6 @@
|
|||||||
<Template Context="user">
|
<Template Context="user">
|
||||||
<RadzenButton Icon="edit" ButtonStyle="ButtonStyle.Light" Variant="Variant.Flat" Size="ButtonSize.Medium" class="rz-my-1 rz-ms-1" Click="@(args => EditRow(user))" @onclick:stopPropagation="true" />
|
<RadzenButton Icon="edit" ButtonStyle="ButtonStyle.Light" Variant="Variant.Flat" Size="ButtonSize.Medium" class="rz-my-1 rz-ms-1" Click="@(args => EditRow(user))" @onclick:stopPropagation="true" />
|
||||||
<RadzenButton Icon="delete" ButtonStyle="ButtonStyle.Danger" Variant="Variant.Flat" Size="ButtonSize.Medium" Shade="Shade.Lighter" class="rz-my-1 rz-ms-1" Click="@(args => DeleteRow(user))" @onclick:stopPropagation="true" />
|
<RadzenButton Icon="delete" ButtonStyle="ButtonStyle.Danger" Variant="Variant.Flat" Size="ButtonSize.Medium" Shade="Shade.Lighter" class="rz-my-1 rz-ms-1" Click="@(args => DeleteRow(user))" @onclick:stopPropagation="true" />
|
||||||
<RadzenButton Text="Confirm dialog with markup" ButtonStyle="ButtonStyle.Secondary"
|
|
||||||
Click=@(args => DialogService.Confirm(GetMessage(), "MyTitle", new ConfirmOptions() { OkButtonText = "Yes", CancelButtonText = "No" })) />
|
|
||||||
</Template>
|
</Template>
|
||||||
</RadzenDataGridColumn>
|
</RadzenDataGridColumn>
|
||||||
</Columns>
|
</Columns>
|
||||||
@ -72,29 +70,12 @@
|
|||||||
|
|
||||||
private async Task DeleteRow(Utente user)
|
private async Task DeleteRow(Utente user)
|
||||||
{
|
{
|
||||||
var confirmationResult = await this.DialogService.Confirm("Are you sure?", "Dialog Title", new ConfirmOptions { OkButtonText = "Yes", CancelButtonText = "No" });
|
var ok = await _dialogService.Confirm($"Vuoi davvero eliminare l'utente {user.ToString()}?", "Conferma eliminazione", new ConfirmOptions { OkButtonText = "Sì", CancelButtonText = "No", Width = "400px" });
|
||||||
if (confirmationResult == true)
|
|
||||||
{
|
|
||||||
//Delete logic for id
|
|
||||||
}
|
|
||||||
// var ok = await dialog.Confirm($"Vuoi davvero eliminare l'utente {user.ToString()}?", "Conferma eliminazione", new ConfirmOptions { OkButtonText = "Sì", CancelButtonText = "No", Width = "400px" });
|
|
||||||
|
|
||||||
// if (ok == true)
|
if (ok == true)
|
||||||
// {
|
|
||||||
// // qui fai l’eliminazione vera
|
|
||||||
// //ASP
|
|
||||||
// // se serve:
|
|
||||||
// await InvokeAsync(StateHasChanged);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
RenderFragment GetMessage()
|
|
||||||
{
|
{
|
||||||
return __builder =>
|
await _managerService.UtenteService.Elimina(user.Id, await MembershipUtils.GetUserId(auth));
|
||||||
{
|
utenti = await _managerService.UtenteService.RicercaQueryable(x => x.Eliminato == false);
|
||||||
<text>
|
}
|
||||||
Are <b>you</b> sure?
|
|
||||||
</text>
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,9 @@
|
|||||||
|
|
||||||
@using Radzen
|
@using Radzen
|
||||||
@using Radzen.Blazor
|
@using Radzen.Blazor
|
||||||
|
@using StandManager.Utils
|
||||||
|
|
||||||
@inject IManagerService _managerService
|
@inject IManagerService _managerService
|
||||||
|
|
||||||
|
@inject DialogService _dialogService
|
||||||
@inject NavigationManager _navManager
|
@inject NavigationManager _navManager
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
using Microsoft.AspNetCore.Components.WebAssembly.Server;
|
||||||
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Radzen;
|
using Radzen;
|
||||||
@ -14,7 +15,8 @@ var builder = WebApplication.CreateBuilder(args);
|
|||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddRazorComponents()
|
builder.Services.AddRazorComponents()
|
||||||
.AddInteractiveServerComponents();
|
.AddInteractiveServerComponents()
|
||||||
|
.AddInteractiveWebAssemblyComponents();
|
||||||
|
|
||||||
builder.Services.AddCascadingAuthenticationState();
|
builder.Services.AddCascadingAuthenticationState();
|
||||||
|
|
||||||
@ -90,7 +92,8 @@ app.UseAuthorization();
|
|||||||
app.UseAntiforgery();
|
app.UseAntiforgery();
|
||||||
|
|
||||||
app.MapRazorComponents<App>()
|
app.MapRazorComponents<App>()
|
||||||
.AddInteractiveServerRenderMode();
|
.AddInteractiveServerRenderMode()
|
||||||
|
.AddInteractiveWebAssemblyRenderMode();
|
||||||
|
|
||||||
app.Use(async (context, func) =>
|
app.Use(async (context, func) =>
|
||||||
{
|
{
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.22" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.22" />
|
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.22" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.22" />
|
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.22" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.11">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.11">
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
namespace StandManager.Utils;
|
using Microsoft.AspNetCore.Components.Authorization;
|
||||||
|
|
||||||
|
namespace StandManager.Utils;
|
||||||
|
|
||||||
public class LayoutState
|
public class LayoutState
|
||||||
{
|
{
|
||||||
@ -12,3 +14,14 @@ public class LayoutState
|
|||||||
OnChanged?.Invoke();
|
OnChanged?.Invoke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class MembershipUtils
|
||||||
|
{
|
||||||
|
public static async Task<Guid> GetUserId(AuthenticationStateProvider auth)
|
||||||
|
{
|
||||||
|
var state = await auth.GetAuthenticationStateAsync();
|
||||||
|
var idClaim = state.User.FindFirst("UserId")?.Value;
|
||||||
|
|
||||||
|
return Guid.Parse(idClaim ?? Guid.Empty.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user