273 lines
14 KiB
Plaintext
273 lines
14 KiB
Plaintext
@page "/UserAdmin"
|
|
|
|
@if (ShowPopup)
|
|
{
|
|
<div class="modal" tabindex="-1" style="display:block" role="dialog">
|
|
<div class="modal-dialog modal-lg">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<div class="d-flex justify-content-between w-100">
|
|
<div class="px-1">
|
|
<h3 class="modal-title">Edit User</h3>
|
|
</div>
|
|
<div class="px-1 ">
|
|
<button class="btn btn-outline-info" @onclick="() => ToggleCodeDetails()">@btnShowDetails</button>
|
|
<!-- Button to close the popup -->
|
|
<button type="button" class="btn btn-outline-dark btn-sm" @onclick="ClosePopup">
|
|
<i class="fa-solid fa-xmark"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- Edit form for the current user -->
|
|
<div class="modal-body">
|
|
<div class="row">
|
|
<div class="col-6">
|
|
@if (objUser.Id != "")
|
|
{
|
|
<p>@objUser.Id</p>
|
|
}
|
|
<div class="input-group mb-3">
|
|
<span class="input-group-text"><i class="far fa-envelope"></i></span>
|
|
<input class="form-control" type="text" placeholder="Email" @bind="objUser.Email" />
|
|
<div class="input-group-text">
|
|
<input class="form-control2" type="checkbox" title="Email Confirmed" @bind="objUser.EmailConfirmed" />
|
|
</div>
|
|
</div>
|
|
@*<PasswordBox Password="@(objUser.PasswordHash)"></PasswordBox>*@
|
|
<div class="input-group mb-3">
|
|
<span class="input-group-text"><i class="fas fa-key"></i></span>
|
|
<input class="form-control" type="password" placeholder="Password" @bind="objUser.PasswordHash" />
|
|
</div>
|
|
<div class="input-group mb-3">
|
|
<AuthorizeView Roles="SuperAdmin, DcaAdmin, CompAdmin">
|
|
<Authorized>
|
|
<span class="input-group-text"><i class="fas fa-user-tag"></i></span>
|
|
<select class="form-select" @bind="@CurrentUserRole">
|
|
@foreach (var option in RolesList)
|
|
{
|
|
<option value="@option">
|
|
@option
|
|
</option>
|
|
}
|
|
</select>
|
|
</Authorized>
|
|
</AuthorizeView>
|
|
</div>
|
|
|
|
<div class="input-group mb-3">
|
|
<span class="input-group-text"><i class="fas fa-tag"></i></span>
|
|
<select class="form-select" @bind="@CurrentUserClaimType">
|
|
@foreach (var option in ClaimsList)
|
|
{
|
|
<option value="@option">
|
|
@option
|
|
</option>
|
|
}
|
|
</select>
|
|
<select class="form-select" @bind="@CurrentUserClaimVal">
|
|
<option value="0">--- Selezionare ---</option>
|
|
@foreach (var option in ClaimValList)
|
|
{
|
|
<option value="@option.Key">
|
|
@option.Value
|
|
</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
<span style="color:red">@strError</span>
|
|
<hr />
|
|
<div class="row">
|
|
<div class="col-6 d-grid">
|
|
<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="fa-solid fa-xmark"></i> Close</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-6 text-right">
|
|
@if (objUser.Id != "" && showCodeDetails)
|
|
{
|
|
<div class="img-fluid">
|
|
<QrCodeDisplay rawCode="@qrCodeVal" Height="400" Width="400"></QrCodeDisplay>
|
|
</div>
|
|
<CopyToClipboard Text="@qrCodeVal" AddSlash="true"></CopyToClipboard>
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
@if (isLoading)
|
|
{
|
|
<LoadingData></LoadingData>
|
|
}
|
|
else
|
|
{
|
|
<div class="cardShadow py-1">
|
|
<div class="card-header">
|
|
<div class="d-flex justify-content-between">
|
|
<div>
|
|
<h3>User Administration</h3>
|
|
</div>
|
|
<div class="d-flex justify-content-between gap-3 mb-1">
|
|
<div class="input-group" title="Search">
|
|
<span class="input-group-text"><i class="fa-solid fa-magnifying-glass"></i></span>
|
|
<input class="form-control" placeholder="Search" @bind="@searchVal">
|
|
<button class="input-group-text" @onclick="resetSearch"><i class="fa-solid fa-xmark"></i></button>
|
|
</div>
|
|
<div class="input-group">
|
|
<AuthorizeView Roles="SuperAdmin, DcaAdmin, CompAdmin">
|
|
<Authorized>
|
|
<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>
|
|
@foreach (var option in RolesList)
|
|
{
|
|
<option value="@option">
|
|
@option
|
|
</option>
|
|
}
|
|
</select>
|
|
</Authorized>
|
|
</AuthorizeView>
|
|
</div>
|
|
<div class="input-group">
|
|
<AuthorizeView Roles="SuperAdmin, DcaAdmin, CompAdmin">
|
|
<Authorized>
|
|
<span class="input-group-text"><i class="fa-solid fa-building"></i></span>
|
|
@if (@context.User.IsInRole("SuperAdmin") || @context.User.IsInRole("DcaAdmin"))
|
|
{
|
|
<select class="form-select" @bind="@FiltCompany">
|
|
<option value="0">--- ALL COMPANIES ---</option>
|
|
@foreach (var option in CompanyList)
|
|
{
|
|
<option value="@option.CompanyId">
|
|
@option.CompanyName
|
|
</option>
|
|
}
|
|
</select>
|
|
}
|
|
else
|
|
{
|
|
<select class="form-select" @bind="@FiltCompany" disabled>
|
|
@foreach (var option in CompanyList)
|
|
{
|
|
<option value="@option.CompanyId">
|
|
@option.CompanyName
|
|
</option>
|
|
}
|
|
</select>
|
|
}
|
|
</Authorized>
|
|
</AuthorizeView>
|
|
</div>
|
|
<div>
|
|
<AuthorizeView Roles="SuperAdmin">
|
|
<Authorized>
|
|
<button class="btn btn-success btn-block text-nowrap" @onclick="AddNewUser">Add NEW User <i class="fa-solid fa-user-plus"></i></button>
|
|
</Authorized>
|
|
</AuthorizeView>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="card-body px-1">
|
|
<table class="table table-sm table-striped table-responsive-md">
|
|
<thead>
|
|
<tr>
|
|
<th></th>
|
|
<AuthorizeView Roles="SuperAdmin">
|
|
<Authorized>
|
|
<th>Id</th>
|
|
</Authorized>
|
|
</AuthorizeView>
|
|
<th>User / Email</th>
|
|
<th>Role</th>
|
|
<th>Rights</th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var user in UsersList)
|
|
{
|
|
<tr class="@userCss(user.isInactive)">
|
|
<td>
|
|
@if (!ShowPopup)
|
|
{
|
|
<button class="btn btn-sm btn-primary" @onclick="(() => EditUser(user.Identity))" title="Edit">
|
|
<i class="fas fa-pen"></i>
|
|
</button>
|
|
}
|
|
else
|
|
{
|
|
<button class="btn btn-sm btn-secondary disabled" title="Edit">
|
|
<i class="fas fa-pen"></i>
|
|
</button>
|
|
}
|
|
</td>
|
|
<AuthorizeView Roles="SuperAdmin">
|
|
<Authorized>
|
|
<td>@user.Identity.Id.Substring(0, 8)...</td>
|
|
</Authorized>
|
|
</AuthorizeView>
|
|
<td>
|
|
@if (user.Identity.EmailConfirmed)
|
|
{
|
|
<span class="badge rounded-pill bg-success" title="Email validata"><span class="oi oi-check" aria-hidden="true"></span></span>
|
|
}
|
|
else
|
|
{
|
|
<span class="badge rounded-pill bg-danger" title="Email NON ancora validata!"><span class="oi oi-check" aria-hidden="true"></span></span>
|
|
}
|
|
@user.Identity.Email
|
|
</td>
|
|
<td>
|
|
@ShowRoles(user.Roles)
|
|
</td>
|
|
<td>
|
|
@ShowClaims(user.Claims)
|
|
</td>
|
|
<td>
|
|
@if (!ShowPopup)
|
|
{
|
|
if (user.isInactive)
|
|
{
|
|
<button class="btn btn-sm btn-success" @onclick="(() => EnableUser(user.Identity))" title="Enable User">
|
|
<i class="fas fa-check"></i>
|
|
</button>
|
|
<AuthorizeView Roles="SuperAdmin">
|
|
<Authorized>
|
|
<button class="btn btn-sm btn-danger" @onclick="(() => DeleteUser(user.Identity))" title="Delete">
|
|
<i class="fas fa-trash"></i>
|
|
</button>
|
|
</Authorized>
|
|
</AuthorizeView>
|
|
}
|
|
else
|
|
{
|
|
<button class="btn btn-sm btn-warning" @onclick="(() => DisableUser(user.Identity))" title="Disable User">
|
|
<i class="fas fa-trash"></i>
|
|
</button>
|
|
}
|
|
}
|
|
else
|
|
{
|
|
<button class="btn btn-sm btn-secondary disabled" title="Delete">
|
|
<i class="fas fa-trash"></i>
|
|
</button>
|
|
}
|
|
</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="card-footer p-1">
|
|
<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" totalCount="totalCount" showLoading="isLoading" />
|
|
</div>
|
|
</div>
|
|
} |