Aggiunta paginazione utenti
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
@page "/UserAdmin"
|
||||
|
||||
@using GWMS.UI.Pages
|
||||
@using GWMS.UI.Components
|
||||
|
||||
@if (ShowPopup)
|
||||
{
|
||||
@@ -168,6 +169,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<div class="card-footer p-1">
|
||||
<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" totalCount="totalCount" showLoading="isLoading" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -27,6 +27,11 @@ namespace GWMS.UI.Pages
|
||||
/// </summary>
|
||||
private IdentityUser objUser = new IdentityUser();
|
||||
|
||||
/// <summary>
|
||||
/// Collezione utenti
|
||||
/// </summary>
|
||||
private List<IdentityUser> RawList = new List<IdentityUser>();
|
||||
|
||||
/// <summary>
|
||||
/// Elenco ROLES da mostrare in dropdown durante editing (1 solo? usare DB?!?)
|
||||
/// </summary>
|
||||
@@ -55,6 +60,10 @@ namespace GWMS.UI.Pages
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private int _currPage { get; set; } = 1;
|
||||
|
||||
private int _numRecord { get; set; } = 10;
|
||||
|
||||
[CascadingParameter]
|
||||
private Task<AuthenticationState> authenticationStateTask { get; set; }
|
||||
|
||||
@@ -78,6 +87,36 @@ namespace GWMS.UI.Pages
|
||||
/// </summary>
|
||||
private string CurrentUserRole { get; set; } = "User";
|
||||
|
||||
private int currPage
|
||||
{
|
||||
get => _currPage;
|
||||
set
|
||||
{
|
||||
if (_currPage != value)
|
||||
{
|
||||
_currPage = value;
|
||||
var pUpd = Task.Run(async () => await ReloadData());
|
||||
pUpd.Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool isLoading { get; set; } = false;
|
||||
|
||||
private int numRecord
|
||||
{
|
||||
get => _numRecord;
|
||||
set
|
||||
{
|
||||
if (_numRecord != value)
|
||||
{
|
||||
_numRecord = value;
|
||||
var pUpd = Task.Run(async () => await ReloadData());
|
||||
pUpd.Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Protected Properties
|
||||
@@ -97,6 +136,19 @@ namespace GWMS.UI.Pages
|
||||
[Inject]
|
||||
protected IJSRuntime JSRuntime { get; set; }
|
||||
|
||||
protected int totalCount
|
||||
{
|
||||
get
|
||||
{
|
||||
int answ = 0;
|
||||
if (RawList != null)
|
||||
{
|
||||
answ = RawList.Count;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Private Methods
|
||||
@@ -220,6 +272,13 @@ namespace GWMS.UI.Pages
|
||||
ShowPopup = true;
|
||||
}
|
||||
|
||||
private async Task ReloadData()
|
||||
{
|
||||
isLoading = true;
|
||||
await GetUsers();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
private async Task SaveUser()
|
||||
{
|
||||
try
|
||||
@@ -353,6 +412,16 @@ namespace GWMS.UI.Pages
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected void ForceReload(int newNum)
|
||||
{
|
||||
numRecord = newNum;
|
||||
}
|
||||
|
||||
protected void ForceReloadPage(int newNum)
|
||||
{
|
||||
currPage = newNum;
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
AppMService.ShowSearch = true;
|
||||
@@ -386,7 +455,8 @@ namespace GWMS.UI.Pages
|
||||
// Collection to hold users
|
||||
UsersList = new List<UserData>();
|
||||
// get users from _UserManager
|
||||
var user = _UserManager.Users.Select(x => new IdentityUser
|
||||
RawList = _UserManager.Users.ToList();
|
||||
var user = RawList.Skip(numRecord * (currPage - 1)).Take(numRecord).Select(x => new IdentityUser
|
||||
{
|
||||
Id = x.Id,
|
||||
UserName = x.UserName,
|
||||
|
||||
Reference in New Issue
Block a user