2022-10-17 12:16:29 +02:00
|
|
|
@using BTCPayServer.Abstractions.Extensions
|
|
|
|
@using BTCPayServer.Abstractions.Contracts
|
2023-05-26 16:49:32 +02:00
|
|
|
@using BTCPayServer.Client
|
2023-09-11 02:59:17 +02:00
|
|
|
@using BTCPayServer.Components.MainLogo
|
2022-11-14 14:29:23 +01:00
|
|
|
@using BTCPayServer.Services
|
2023-09-11 02:59:17 +02:00
|
|
|
@using BTCPayServer.Views.Stores
|
2022-11-14 14:29:23 +01:00
|
|
|
@inject BTCPayServerEnvironment Env
|
2022-10-17 12:16:29 +02:00
|
|
|
@inject IFileService FileService
|
2021-12-11 04:32:23 +01:00
|
|
|
@model BTCPayServer.Components.StoreSelector.StoreSelectorViewModel
|
2022-01-18 02:20:59 +01:00
|
|
|
@functions {
|
|
|
|
@* ReSharper disable once CSharpWarnings::CS1998 *@
|
2022-06-28 17:38:59 +09:00
|
|
|
#pragma warning disable 1998
|
2022-01-18 02:20:59 +01:00
|
|
|
private async Task LogoContent()
|
|
|
|
{
|
2022-11-14 14:29:23 +01:00
|
|
|
<vc:main-logo />
|
2022-10-17 12:16:29 +02:00
|
|
|
@if (Env.NetworkType != NBitcoin.ChainName.Mainnet)
|
2022-01-18 02:20:59 +01:00
|
|
|
{
|
2022-11-14 14:29:23 +01:00
|
|
|
var type = Env.NetworkType.ToString();
|
2023-01-19 10:08:34 +01:00
|
|
|
var displayType = type.Replace("Testnet", "TN").Replace("Regtest", "RT").Replace("Signet", "SN");
|
|
|
|
<small class="badge bg-warning rounded-pill ms-1 ms-sm-0" title="@type">@displayType</small>
|
2022-01-18 02:20:59 +01:00
|
|
|
}
|
|
|
|
}
|
2022-11-14 14:29:23 +01:00
|
|
|
private static string StoreName(string title)
|
2022-01-18 02:20:59 +01:00
|
|
|
{
|
|
|
|
return string.IsNullOrEmpty(title) ? "Unnamed Store" : title;
|
|
|
|
}
|
2022-06-28 17:38:59 +09:00
|
|
|
#pragma warning restore 1998
|
2022-01-18 02:20:59 +01:00
|
|
|
}
|
|
|
|
@if (Model.CurrentStoreId == null)
|
|
|
|
{
|
2022-11-14 14:29:23 +01:00
|
|
|
<a asp-controller="UIHome" asp-action="Index" id="StoreSelectorHome" class="navbar-brand py-2">@{await LogoContent();}</a>
|
2022-01-18 02:20:59 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-05-26 16:49:32 +02:00
|
|
|
<a asp-controller="UIStores" asp-action="Dashboard" permission="@Policies.CanModifyStoreSettings" asp-route-storeId="@Model.CurrentStoreId" id="StoreSelectorHome" class="navbar-brand py-2">@{await LogoContent();}</a>
|
2023-05-30 10:59:03 +02:00
|
|
|
<a asp-controller="UIInvoice" asp-action="ListInvoices" not-permission="@Policies.CanModifyStoreSettings" asp-route-storeId="@Model.CurrentStoreId" id="StoreSelectorHome" class="navbar-brand py-2">@{await LogoContent();}</a>
|
2022-01-18 02:20:59 +01:00
|
|
|
}
|
2023-09-11 02:59:17 +02:00
|
|
|
@if (Model.Options.Any() || Model.ArchivedCount > 0)
|
2023-05-10 11:18:29 +02:00
|
|
|
{
|
|
|
|
<div id="StoreSelector">
|
2022-01-13 09:08:15 +01:00
|
|
|
<div id="StoreSelectorDropdown" class="dropdown only-for-js">
|
2022-12-05 08:47:51 +01:00
|
|
|
<button id="StoreSelectorToggle" class="btn btn-secondary dropdown-toggle rounded-pill px-3 @(Model.CurrentStoreId == null ? "empty-state" : "")" type="button" data-bs-toggle="dropdown" aria-expanded="false">
|
2022-10-17 12:16:29 +02:00
|
|
|
@if (!string.IsNullOrEmpty(Model.CurrentStoreLogoFileId))
|
|
|
|
{
|
|
|
|
<img class="logo" src="@(await FileService.GetFileUrl(Context.Request.GetAbsoluteRootUri(), Model.CurrentStoreLogoFileId))" alt="@Model.CurrentDisplayName" />
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<vc:icon symbol="store"/>
|
|
|
|
}
|
2022-01-24 18:07:52 -08:00
|
|
|
<span>@(Model.CurrentStoreId == null ? "Select Store" : Model.CurrentDisplayName)</span>
|
|
|
|
<vc:icon symbol="caret-down"/>
|
|
|
|
</button>
|
2022-01-13 09:08:15 +01:00
|
|
|
<ul id="StoreSelectorMenu" class="dropdown-menu" aria-labelledby="StoreSelectorToggle">
|
|
|
|
@foreach (var option in Model.Options)
|
|
|
|
{
|
|
|
|
<li>
|
2022-04-12 09:55:10 +02:00
|
|
|
@if (option.IsOwner)
|
2022-01-13 09:08:15 +01:00
|
|
|
{
|
2022-01-18 02:20:59 +01:00
|
|
|
<a asp-controller="UIStores" asp-action="Dashboard" asp-route-storeId="@option.Value" class="dropdown-item@(option.Selected ? " active" : "")" id="StoreSelectorMenuItem-@option.Value">@StoreName(option.Text)</a>
|
2022-01-13 09:08:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-18 02:20:59 +01:00
|
|
|
<a asp-controller="UIInvoice" asp-action="ListInvoices" asp-route-storeId="@option.Value" class="dropdown-item@(option.Selected ? " active" : "")" id="StoreSelectorMenuItem-@option.Value">@StoreName(option.Text)</a>
|
2022-01-13 09:08:15 +01:00
|
|
|
}
|
|
|
|
</li>
|
|
|
|
}
|
2023-09-11 02:59:17 +02:00
|
|
|
@if (Model.Options.Any())
|
|
|
|
{
|
|
|
|
<li><hr class="dropdown-divider"></li>
|
|
|
|
}
|
|
|
|
<li><a asp-controller="UIUserStores" asp-action="CreateStore" class="dropdown-item @ViewData.IsActivePage(StoreNavPages.Create)" id="StoreSelectorCreate">Create Store</a></li>
|
|
|
|
@if (Model.ArchivedCount > 0)
|
|
|
|
{
|
|
|
|
<li><hr class="dropdown-divider"></li>
|
|
|
|
<li><a asp-controller="UIUserStores" asp-action="ListStores" asp-route-archived="true" class="dropdown-item @ViewData.IsActivePage(StoreNavPages.Index)" id="StoreSelectorArchived">@Model.ArchivedCount Archived Store@(Model.ArchivedCount == 1 ? "" : "s")</a></li>
|
|
|
|
}
|
2022-01-13 09:08:15 +01:00
|
|
|
</ul>
|
|
|
|
</div>
|
2023-05-10 11:18:29 +02:00
|
|
|
</div>
|
|
|
|
}
|