Files
Samuele Locatelli 71fc5a81d4 SPEC:
- fix gestione permessi x nagMan + check buttons
2025-04-16 17:44:34 +02:00

88 lines
2.9 KiB
Plaintext

@page "/force-reset"
@using MP.AppAuth.Services
@using MP.SPEC.Data
<div class="d-flex justify-content-around">
<div class="col-12 col-md-10 col-lg-8 col-xl-6 ">
<div class="card shadow mt-5">
<div class="card-header">
<img class="img-fluid" src="./images/LogoMapoFull.png" />
</div>
<div class="card-body">
<ProgressDisplay RefreshInterval="50" Title="@title" MaxVal="100" CurrVal="@currVal" NextVal="@nextVal" ExpTimeMSec="@expTimeMsec" DisplaySize="ProgressDisplay.ModalSize.Medium"></ProgressDisplay>
<LoadingData DisplaySize="LoadingData.CtrlSize.Large" Title="Cleaning Up cache..." DisplayMode="LoadingData.SpinMode.Growl"></LoadingData>
</div>
</div>
</div>
</div>
@code {
[Inject]
protected NavigationManager NavMan { get; set; } = null!;
[Inject]
protected MsgServiceSpec MsgServ { get; set; } = null!;
[Inject]
protected MpDataService MDService { get; set; } = null!;
[Inject]
protected AuthenticationStateProvider AuthStateProv { get; set; } = null!;
[Inject]
protected AppAuthService AAService { get; set; } = null!;
private int currVal = 0;
private int nextVal = 0;
private int expTimeMsec = 10;
private int bDelay = 150;
private string title = "...";
/// <summary>
/// Esecuzione task di reset...
/// </summary>
/// <returns></returns>
protected override async Task OnInitializedAsync()
{
title = "Reset and Reload Data";
currVal = 0;
nextVal = 10;
await InvokeAsync(StateHasChanged);
await Task.Delay(bDelay);
title = "UserDataReload...";
currVal = 50;
nextVal = 80;
await ForceReload();
await InvokeAsync(StateHasChanged);
await Task.Delay(2 * bDelay);
title = "Reload!";
currVal = 80;
nextVal = 100;
await InvokeAsync(StateHasChanged);
await Task.Delay(bDelay);
// rimando a pagina corrente
NavMan.NavigateTo("Index", true);
}
private async Task ForceReload()
{
var authState = await AuthStateProv.GetAuthenticationStateAsync();
var user = authState.User;
if (user.Identity != null && user.Identity.IsAuthenticated)
{
string userName = $"{user.Identity.Name}";
// salvo username in msgService
var userData = userName.Split(@"\");
if (userData.Length > 1)
{
MsgServ.DomainName = userData[0];
MsgServ.UserName = userData[1];
// recupero diritti e salvo...
var UserRightList = await AAService.DirittiGetByUser(MsgServ.UserName);
if (UserRightList != null)
{
MsgServ.UserRight = UserRightList.Select(x => x.Funzione).ToList();
}
}
}
}
}