2022-10-17 12:16:29 +02:00
|
|
|
@using Microsoft.AspNetCore.Mvc.TagHelpers
|
|
|
|
@using BTCPayServer.Abstractions.Extensions
|
|
|
|
@using BTCPayServer.Abstractions.TagHelpers
|
|
|
|
@using BTCPayServer.Abstractions.Contracts
|
|
|
|
@inject BTCPayServer.Services.BTCPayServerEnvironment Env
|
|
|
|
@inject SignInManager<ApplicationUser> SignInManager
|
|
|
|
@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()
|
|
|
|
{
|
|
|
|
var logoSrc = $"{ViewContext.HttpContext.Request.PathBase}/img/logo.svg";
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" role="img" alt="BTCPay Server" class="logo"><use href="@logoSrc#small" class="logo-small" /><use href="@logoSrc#large" class="logo-large" /></svg>
|
2022-10-17 12:16:29 +02:00
|
|
|
@if (Env.NetworkType != NBitcoin.ChainName.Mainnet)
|
2022-01-18 02:20:59 +01:00
|
|
|
{
|
2022-10-17 12:16:29 +02:00
|
|
|
<span class="badge bg-warning ms-1 ms-sm-0" style="font-size:10px;">@Env.NetworkType.ToString()</span>
|
2022-01-18 02:20:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
private string StoreName(string title)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
<a href="~/" class="navbar-brand py-2 js-scroll-trigger">@{await LogoContent();}</a>
|
|
|
|
}
|
|
|
|
else if (Model.CurrentStoreIsOwner)
|
|
|
|
{
|
|
|
|
<a asp-controller="UIStores" asp-action="Dashboard" asp-route-storeId="@Model.CurrentStoreId" class="navbar-brand py-2 js-scroll-trigger">@{await LogoContent();}</a>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<a asp-controller="UIInvoice" asp-action="ListInvoices" asp-route-storeId="@Model.CurrentStoreId" class="navbar-brand py-2 js-scroll-trigger">@{await LogoContent();}</a>
|
|
|
|
}
|
|
|
|
|
2021-12-11 04:32:23 +01:00
|
|
|
<div id="StoreSelector">
|
2022-01-13 09:08:15 +01:00
|
|
|
@if (Model.Options.Count > 0)
|
|
|
|
{
|
|
|
|
<div id="StoreSelectorDropdown" class="dropdown only-for-js">
|
2022-01-24 18:07:52 -08:00
|
|
|
<button id="StoreSelectorToggle" class="btn btn-secondary dropdown-toggle rounded-pill px-3 @(Model.CurrentStoreId == null ? "text-secondary" : "")" 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>
|
|
|
|
}
|
|
|
|
<li><hr class="dropdown-divider"></li>
|
2022-01-07 12:32:00 +09:00
|
|
|
<li><a asp-controller="UIUserStores" asp-action="CreateStore" class="dropdown-item" id="StoreSelectorCreate">Create Store</a></li>
|
2022-01-13 09:08:15 +01:00
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
}
|
2022-10-17 12:16:29 +02:00
|
|
|
else if (SignInManager.IsSignedIn(User))
|
2022-01-13 09:08:15 +01:00
|
|
|
{
|
2022-01-07 12:32:00 +09:00
|
|
|
<a asp-controller="UIUserStores" asp-action="CreateStore" class="btn btn-primary w-100 rounded-pill" id="StoreSelectorCreate">Create Store</a>
|
2022-01-13 09:08:15 +01:00
|
|
|
}
|
2021-12-11 04:32:23 +01:00
|
|
|
</div>
|