2023-01-22 03:08:12 +09:00
@using BTCPayServer.Abstractions.Models
2022-07-15 05:38:33 +02:00
@model UsersViewModel
2017-09-16 01:15:17 +09:00
@{
2021-12-16 11:17:02 +01:00
ViewData.SetActivePage(ServerNavPages.Users);
2021-03-29 22:32:44 -07:00
var nextUserEmailSortOrder = (string)ViewData["NextUserEmailSortOrder"];
2024-01-31 06:45:54 +01:00
var userEmailSortOrder = nextUserEmailSortOrder switch
2021-03-29 22:32:44 -07:00
{
2024-01-31 06:45:54 +01:00
"asc" => "desc",
"desc" => "asc",
_ => null
};
2021-03-29 22:32:44 -07:00
2024-05-20 01:57:46 +02:00
const string sortByDesc = "Sort by email descending...";
const string sortByAsc = "Sort by email ascending...";
2017-09-16 01:15:17 +09:00
}
2024-06-19 15:23:10 +02:00
<div class="sticky-header">
2024-07-25 22:46:02 +09:00
<h2 text-translate="true">@ViewData["Title"]</h2>
2024-07-25 15:23:28 +09:00
<a id="page-primary" asp-action="CreateUser" class="btn btn-primary" role="button">
2021-06-24 12:52:41 +02:00
Add User
</a>
2019-05-28 08:40:10 -04:00
</div>
2024-06-19 15:23:10 +02:00
<partial name="_StatusMessage" />
2022-04-05 04:34:56 -07:00
2024-01-31 06:45:54 +01:00
<form asp-action="ListUsers" asp-route-sortOrder="@(userEmailSortOrder)" style="max-width:640px" method="get">
<input asp-for="SearchTerm" class="form-control" placeholder="Search by email..." />
2022-04-05 04:34:56 -07:00
</form>
2022-01-23 21:03:56 -08:00
<div class="table-responsive">
<table class="table table-hover">
<thead>
2021-04-08 15:32:42 +02:00
<tr>
2022-01-23 21:03:56 -08:00
<th>
<a
asp-action="ListUsers"
asp-route-sortOrder="@(nextUserEmailSortOrder ?? "asc")"
class="text-nowrap"
title="@(nextUserEmailSortOrder == "desc" ? sortByAsc : sortByDesc)"
>
Email
2024-05-20 01:57:46 +02:00
<vc:icon symbol="actions-sort-alpha-@(userEmailSortOrder ?? nextUserEmailSortOrder ?? "desc")" />
2022-01-23 21:03:56 -08:00
</a>
</th>
2024-02-23 09:51:41 +01:00
<th>Stores</th>
2024-01-31 06:45:54 +01:00
<th>Created</th>
<th>Status</th>
<th class="actions-col"></th>
2024-02-23 09:51:41 +01:00
<th></th>
2021-04-08 15:32:42 +02:00
</tr>
2022-01-23 21:03:56 -08:00
</thead>
2024-01-31 06:45:54 +01:00
<tbody id="UsersList">
2022-01-23 21:03:56 -08:00
@foreach (var user in Model.Users)
{
2024-01-31 06:45:54 +01:00
var status = user switch
{
{ Disabled: true } => ("Disabled", "danger"),
{ Approved: false } => ("Pending Approval", "warning"),
{ EmailConfirmed: false } => ("Pending Email Verification", "warning"),
2024-09-12 05:31:57 +02:00
{ InvitationUrl: not null } => ("Pending Invitation", "warning"),
2024-01-31 06:45:54 +01:00
_ => ("Active", "success")
};
2024-02-23 09:51:41 +01:00
var detailsId = $"user_details_{user.Id}";
<tr id="user_@user.Id" class="user-overview-row mass-action-row">
<td>
<div class="d-flex align-items-center gap-2">
<span class="user-email">@user.Email</span>
@foreach (var role in user.Roles)
{
<span class="badge bg-info">@Model.Roles[role]</span>
}
</div>
2022-01-23 21:03:56 -08:00
</td>
2024-09-12 05:31:57 +02:00
<td class="@(user.Stores.Any() ? null : "text-muted")">@user.Stores.Count() Store@(user.Stores.Count() == 1 ? "" : "s")</td>
2022-01-23 21:03:56 -08:00
<td>@user.Created?.ToBrowserDate()</td>
2024-01-31 06:45:54 +01:00
<td>
<span class="user-status badge bg-@status.Item2">@status.Item1</span>
2022-01-23 21:03:56 -08:00
</td>
2024-01-31 06:45:54 +01:00
<td class="actions-col">
<div class="d-inline-flex align-items-center gap-3">
@if (user is { EmailConfirmed: false, Disabled: false }) {
<a asp-action="SendVerificationEmail" asp-route-userId="@user.Id" data-bs-toggle="modal" data-bs-target="#ConfirmModal" data-title="Send verification email" data-description="This will send a verification email to <strong>@Html.Encode(user.Email)</strong>." data-confirm="Send">Resend email</a>
}
2024-02-28 12:43:18 +01:00
@if (user is { Approved: false, Disabled: false })
2024-01-31 06:45:54 +01:00
{
<a asp-action="ApproveUser" asp-route-userId="@user.Id" asp-route-approved="true" data-bs-toggle="modal" data-bs-target="#ConfirmModal" data-title="Approve user" data-description="This will approve the user <strong>@Html.Encode(user.Email)</strong>." data-confirm="Approve">Approve</a>
}
2024-09-12 05:31:57 +02:00
<a asp-action="User" asp-route-userId="@user.Id" class="user-edit">Edit</a>
2024-02-28 12:43:18 +01:00
@if (status.Item2 != "warning")
2024-01-31 06:45:54 +01:00
{
<a asp-action="ToggleUser" asp-route-userId="@user.Id" asp-route-enable="@user.Disabled">@(user.Disabled ? "Enable" : "Disable")</a>
}
<a asp-action="DeleteUser" asp-route-userId="@user.Id">Remove</a>
</div>
2022-01-23 21:03:56 -08:00
</td>
2024-02-23 09:51:41 +01:00
<td class="text-end">
<div class="d-inline-flex align-items-center gap-2">
<button class="accordion-button collapsed only-for-js ms-0 d-inline-block" type="button" data-bs-toggle="collapse" data-bs-target="#@detailsId" aria-expanded="false" aria-controls="@detailsId">
<vc:icon symbol="caret-down" />
</button>
</div>
</td>
</tr>
<tr id="@detailsId" class="user-details-row collapse">
<td colspan="6" class="border-top-0">
2024-09-12 05:31:57 +02:00
@if (!string.IsNullOrEmpty(user.InvitationUrl))
{
<div class="payment-box m-0">
<div class="qr-container">
<vc:qr-code data="@user.InvitationUrl" />
</div>
<div class="input-group mt-3">
<div class="form-floating">
<vc:truncate-center text="@user.InvitationUrl" padding="15" elastic="true" classes="form-control-plaintext"/>
<label>Invitation URL</label>
</div>
</div>
</div>
}
else if (user.Stores.Any())
2024-02-23 09:51:41 +01:00
{
<ul class="mb-0 p-0">
@foreach (var store in user.Stores)
{
<li class="py-1 d-flex gap-2">
<a asp-controller="UIStores" asp-action="Index" asp-route-storeId="@store.StoreData.Id">@store.StoreData.StoreName</a>
<span class="badge bg-light">@store.StoreRoleId</span>
@if (store.StoreData.Archived)
{
<span class="badge bg-info">archived</span>
}
</li>
}
</ul>
}
else
{
2024-09-12 05:31:57 +02:00
<span class="text-secondary">No stores</span>
2024-02-23 09:51:41 +01:00
}
</td>
2022-01-23 21:03:56 -08:00
</tr>
}
</tbody>
</table>
</div>
2021-03-29 22:32:44 -07:00
2021-04-08 15:32:42 +02:00
<vc:pager view-model="Model"></vc:pager>
2022-05-26 21:36:47 -07:00
<partial name="_Confirm" model="@(new ConfirmModel("Send verification email", $"This will send a verification email to the user.", "Send"))" />