mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 14:22:40 +01:00
81 lines
4.2 KiB
Text
81 lines
4.2 KiB
Text
@using BTCPayServer.Abstractions.Extensions
|
|
@using BTCPayServer.Abstractions.Contracts
|
|
@using BTCPayServer.Client
|
|
@using BTCPayServer.Components.MainLogo
|
|
@using BTCPayServer.Services
|
|
@using BTCPayServer.Views.Stores
|
|
@inject BTCPayServerEnvironment Env
|
|
@inject IFileService FileService
|
|
@model BTCPayServer.Components.StoreSelector.StoreSelectorViewModel
|
|
@functions {
|
|
@* ReSharper disable once CSharpWarnings::CS1998 *@
|
|
#pragma warning disable 1998
|
|
private async Task LogoContent()
|
|
{
|
|
<vc:main-logo />
|
|
@if (Env.NetworkType != NBitcoin.ChainName.Mainnet)
|
|
{
|
|
var type = Env.NetworkType.ToString();
|
|
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>
|
|
}
|
|
}
|
|
private static string StoreName(string title)
|
|
{
|
|
return string.IsNullOrEmpty(title) ? "Unnamed Store" : title;
|
|
}
|
|
#pragma warning restore 1998
|
|
}
|
|
@if (Model.CurrentStoreId == null)
|
|
{
|
|
<a asp-controller="UIHome" asp-action="Index" id="StoreSelectorHome" class="navbar-brand py-2">@{await LogoContent();}</a>
|
|
}
|
|
else
|
|
{
|
|
<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>
|
|
<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>
|
|
}
|
|
@if (Model.Options.Any() || Model.ArchivedCount > 0)
|
|
{
|
|
<div id="StoreSelector">
|
|
<div id="StoreSelectorDropdown" class="dropdown only-for-js">
|
|
<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">
|
|
@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"/>
|
|
}
|
|
<span>@(Model.CurrentStoreId == null ? "Select Store" : Model.CurrentDisplayName)</span>
|
|
<vc:icon symbol="caret-down"/>
|
|
</button>
|
|
<ul id="StoreSelectorMenu" class="dropdown-menu" aria-labelledby="StoreSelectorToggle">
|
|
@foreach (var option in Model.Options)
|
|
{
|
|
<li>
|
|
@if (option.IsOwner)
|
|
{
|
|
<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>
|
|
}
|
|
else
|
|
{
|
|
<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>
|
|
}
|
|
</li>
|
|
}
|
|
@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>
|
|
}
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
}
|