OK edit ruoli con refresh (2 check redis cache...)

This commit is contained in:
Samuele Locatelli
2023-05-27 10:52:42 +02:00
parent 89a810ee77
commit 5029d6ef21
3 changed files with 59 additions and 45 deletions
+21
View File
@@ -304,6 +304,27 @@ namespace WebDoorCreator.UI.Data
return dataResult;
}
/// <summary>
/// Effettua reset dati utente...
/// </summary>
/// <param name="resetAll">Indica reset completo (anche dati elenco di base)</param>
/// <returns></returns>
public async Task<bool> ResetUserDataCache(bool resetAll)
{
bool fatto = false;
RedisValue pattern = new RedisValue($"{Constants.rKeyUsersAll}");
if (resetAll)
{
fatto = await ExecFlushRedisPattern(pattern);
}
// ora resetto il resto
pattern = new RedisValue($"{Constants.rKeyUsersDataId}:*");
fatto = fatto && await ExecFlushRedisPattern(pattern);
pattern = new RedisValue($"{Constants.rKeyUsersDataSearch}:*");
fatto = fatto && await ExecFlushRedisPattern(pattern);
return fatto;
}
#endregion Public Methods
#region Protected Methods
+11 -11
View File
@@ -8,8 +8,8 @@
<div class="modal-header">
<h3 class="modal-title">Edit User</h3>
<!-- Button to close the popup -->
<button type="button" class="close" @onclick="ClosePopup">
<span aria-hidden="true">X</span>
<button type="button" class="btn btn-primary btn-sm" @onclick="ClosePopup">
<i class="fa-solid fa-xmark"></i>
</button>
</div>
<!-- Edit form for the current user -->
@@ -33,7 +33,7 @@
</div>
<div class="input-group mb-3">
<span class="input-group-text"><i class="fas fa-user-tag"></i></span>
<select class="form-control" @bind="@CurrentUserRole">
<select class="form-select" @bind="@CurrentUserRole">
@foreach (var option in RolesList)
{
<option value="@option">
@@ -45,7 +45,7 @@
<div class="input-group mb-3">
<span class="input-group-text"><i class="fas fa-tag"></i></span>
<select class="form-control" @bind="@CurrentUserClaimType">
<select class="form-select" @bind="@CurrentUserClaimType">
@foreach (var option in ClaimsList)
{
<option value="@option">
@@ -53,7 +53,7 @@
</option>
}
</select>
<select class="form-control" @bind="@CurrentUserClaimVal">
<select class="form-select" @bind="@CurrentUserClaimVal">
<option value="0">--- Selezionare ---</option>
@foreach (var option in ClaimValList)
{
@@ -70,7 +70,7 @@
<button class="btn btn-block btn-success" @onclick="SaveUser" title="Save"><i class="fas fa-check"></i> Save</button>
</div>
<div class="col-6 d-grid">
<button class="btn btn-block btn-primary" @onclick="ClosePopup"><i class="far fa-window-close"></i> Close</button>
<button class="btn btn-block btn-primary" @onclick="ClosePopup"><i class="fa-solid fa-xmark"></i> Close</button>
</div>
</div>
</div>
@@ -100,8 +100,8 @@ else
<div>
<h3>User Administration</h3>
</div>
<div class="d-flex justify-content-between gap-3">
<div class="input-group mb-1">
<div class="d-flex justify-content-between gap-3 mb-1">
<div class="input-group">
<span class="input-group-text"><i class="fas fa-user-tag"></i></span>
<select class="form-select" @bind="@FiltUserRole">
<option value="0">--- ALL ROLES ---</option>
@@ -114,7 +114,7 @@ else
</select>
@*<span class="input-group-text">ROLES</span>*@
</div>
<div class="input-group mb-1">
<div class="input-group">
<span class="input-group-text"><i class="fa-solid fa-building"></i></span>
<select class="form-select" @bind="@FiltCompany">
<option value="0">--- ALL COMPANIES ---</option>
@@ -146,8 +146,8 @@ else
<th></th>
<th>Id</th>
<th>User / Email</th>
<th>Ruolo</th>
<th>Permessi</th>
<th>Role</th>
<th>Rights</th>
<th></th>
</tr>
</thead>
+27 -34
View File
@@ -159,7 +159,6 @@ namespace WebDoorCreator.UI.Pages
public string ShowClaims(List<System.Security.Claims.Claim> ClaimList)
{
//string answ = string.Join(",", ClaimList);
string answ = string.Join(",", ConvertClaim(ClaimList));
return answ;
}
@@ -212,11 +211,6 @@ namespace WebDoorCreator.UI.Pages
#endregion Protected Properties
#if false
protected List<GWMS.Data.DatabaseModels.SupplierModel>? suppList { get; set; } = null;
protected List<GWMS.Data.DatabaseModels.TransporterModel>? transpList { get; set; } = null;
#endif
#region Protected Methods
protected void ForceReload(int newNum)
@@ -258,10 +252,6 @@ namespace WebDoorCreator.UI.Pages
private string qrCodeVal = "";
/// <summary>
/// Collezione utenti
/// </summary>
private List<IdentityUser> RawList = new List<IdentityUser>();
/// <summary>
/// Elenco ROLES da mostrare in dropdown durante editing (1 solo? usare DB?!?)
@@ -281,7 +271,7 @@ namespace WebDoorCreator.UI.Pages
/// <summary>
/// Collezione utenti
/// </summary>
/// </summary> filtrati/mostrati
private List<UserData> UsersList = new List<UserData>();
#endregion Private Fields
@@ -292,10 +282,8 @@ namespace WebDoorCreator.UI.Pages
private int _currPage { get; set; } = 1;
private string _filtUserRole { get; set; } = "0";
private string _filtCompanyId { get; set; } = "0";
private string _filtUserRole { get; set; } = "0";
private int _numRecord { get; set; } = 10;
[CascadingParameter]
@@ -350,25 +338,6 @@ namespace WebDoorCreator.UI.Pages
}
}
/// <summary>
/// Gestione filtraggio RUOLI utente
/// </summary>
private string FiltUserRole
{
get
{
return _filtUserRole;
}
set
{
if (_filtUserRole != value)
{
_filtUserRole = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
/// <summary>
/// Gestione filtraggio COMPANY
/// </summary>
@@ -389,6 +358,26 @@ namespace WebDoorCreator.UI.Pages
}
}
/// <summary>
/// Gestione filtraggio RUOLI utente
/// </summary>
private string FiltUserRole
{
get
{
return _filtUserRole;
}
set
{
if (_filtUserRole != value)
{
_filtUserRole = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private bool isLoading { get; set; } = false;
private int numRecord
@@ -482,6 +471,8 @@ namespace WebDoorCreator.UI.Pages
{
// Delete the user
await _UserManager.DeleteAsync(user);
// reset cache!
await WDCUsrServ.ResetUserDataCache(true);
}
// Refresh Users
await ReloadData();
@@ -497,7 +488,7 @@ namespace WebDoorCreator.UI.Pages
#if false
// Get the user
var user = await _UserManager.FindByIdAsync(objUser.Id);
var user = await _UserManager.FindByIdAsync(objUser.Id);
#endif
if (user != null)
{
@@ -732,6 +723,8 @@ namespace WebDoorCreator.UI.Pages
}
// Close the Popup
ShowPopup = false;
// reset cache!
await WDCUsrServ.ResetUserDataCache(true);
// Refresh page
await ReloadData();
}