124 lines
4.4 KiB
Plaintext
124 lines
4.4 KiB
Plaintext
@page "/UserAdmin"
|
|
|
|
@using GWMS.User.Pages
|
|
|
|
<AuthorizeView>
|
|
<Authorized>
|
|
<div class="row">
|
|
<div class="col-8 col-lg-9 col-xl-10">
|
|
<h3>User Administration</h3>
|
|
</div>
|
|
<div class="col-4 col-lg-3 col-xl-2 text-right">
|
|
@if (context.User.IsInRole("SuperAdmin"))
|
|
{
|
|
<button class="btn btn-success btn-block" @onclick="AddNewUser">Add User</button>
|
|
}
|
|
</div>
|
|
</div>
|
|
</Authorized>
|
|
<NotAuthorized>
|
|
<p>You're not loggged in.</p>
|
|
</NotAuthorized>
|
|
</AuthorizeView>
|
|
@if (ShowPopup)
|
|
{
|
|
<div class="modal" tabindex="-1" style="display:block" role="dialog">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<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>
|
|
</div>
|
|
<!-- Edit form for the current user -->
|
|
<div class="modal-body">
|
|
<!-- Only show Id if not a new user -->
|
|
@if (objUser.Id != "")
|
|
{
|
|
<p>@objUser.Id</p>
|
|
}
|
|
<!-- Only allow edit if a new user -->
|
|
@if (objUser.Id != "")
|
|
{
|
|
<p>@objUser.UserName</p>
|
|
}
|
|
else
|
|
{
|
|
<input class="form-control" type="text"
|
|
placeholder="UserName"
|
|
@bind="objUser.UserName" />
|
|
}
|
|
<input class="form-control" type="text"
|
|
placeholder="Email"
|
|
@bind="objUser.Email" />
|
|
<input class="form-control" type="password"
|
|
placeholder="Password"
|
|
@bind="objUser.PasswordHash" />
|
|
<select class="form-control"
|
|
@bind="@CurrentUserRole">
|
|
@foreach (var option in Options)
|
|
{
|
|
<option value="@option">
|
|
@option
|
|
</option>
|
|
}
|
|
</select>
|
|
<br /><br />
|
|
<!-- Button to save the user -->
|
|
<button class="btn btn-primary"
|
|
@onclick="SaveUser">
|
|
Save
|
|
</button>
|
|
<!-- Only show delete button if not a new record -->
|
|
@if (objUser.Id != "")
|
|
{
|
|
<!-- Button to delete the forecast -->
|
|
<button class="btn btn-danger"
|
|
@onclick="DeleteUser">
|
|
Delete
|
|
</button>
|
|
}
|
|
<br />
|
|
<span style="color:red">@strError</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
<table class="table table-striped table-responsive-sm">
|
|
<thead>
|
|
<tr>
|
|
<th>Id</th>
|
|
<th>User Name</th>
|
|
<th>Email</th>
|
|
<th>Ruolo</th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var user in ColUsers)
|
|
{
|
|
<tr>
|
|
<td>@user.Id.Substring(0, 15)...</td>
|
|
<td>@user.UserName</td>
|
|
<td><span class="badge badge-pill @checkSem(user.EmailConfirmed)" title="Email validata"><span class="oi oi-check" aria-hidden="true"></span></span> @user.Email</td>
|
|
<td>
|
|
@if (!ShowPopup)
|
|
{
|
|
@GetRole(user)
|
|
}
|
|
</td>
|
|
<td>
|
|
<!-- Edit the current forecast -->
|
|
<button class="btn btn-primary"
|
|
@onclick="(() => EditUser(user))">
|
|
Edit
|
|
</button>
|
|
</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table> |