2022-07-04 04:03:16 +02:00
|
|
|
@using BTCPayServer.Components.StoreLightningBalance
|
2022-07-06 05:40:16 +02:00
|
|
|
@using BTCPayServer.Components.StoreLightningServices
|
2022-07-04 04:03:16 +02:00
|
|
|
@using BTCPayServer.Components.StoreNumbers
|
2022-07-06 05:40:16 +02:00
|
|
|
@using BTCPayServer.Components.StoreRecentInvoices
|
|
|
|
@using BTCPayServer.Components.StoreRecentTransactions
|
2022-07-04 04:03:16 +02:00
|
|
|
@using BTCPayServer.Components.StoreWalletBalance
|
2022-07-06 05:40:16 +02:00
|
|
|
@using BTCPayServer.Components.AppSales
|
|
|
|
@using BTCPayServer.Components.AppTopItems
|
2024-01-06 08:46:19 +01:00
|
|
|
@using BTCPayServer.Client
|
2023-03-17 03:56:32 +01:00
|
|
|
@model StoreDashboardViewModel
|
2022-01-13 09:08:15 +01:00
|
|
|
@{
|
2022-04-12 09:55:10 +02:00
|
|
|
ViewData.SetActivePage(StoreNavPages.Dashboard, Model.StoreName, Model.StoreId);
|
|
|
|
var store = ViewContext.HttpContext.GetStoreData();
|
2022-01-13 09:08:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
<partial name="_StatusMessage" />
|
|
|
|
|
2022-04-12 09:55:10 +02:00
|
|
|
<div class="d-flex align-items-center justify-content-between">
|
|
|
|
<h2 class="mb-0">@ViewData["Title"]</h2>
|
|
|
|
</div>
|
2022-01-13 09:08:15 +01:00
|
|
|
|
2022-04-12 09:55:10 +02:00
|
|
|
@if (Model.IsSetUp)
|
2022-01-13 09:08:15 +01:00
|
|
|
{
|
2022-04-12 09:55:10 +02:00
|
|
|
/* include chart library inline so that it instantly renders */
|
|
|
|
<link rel="stylesheet" href="~/vendor/chartist/chartist.css" asp-append-version="true">
|
2024-02-02 11:29:35 +01:00
|
|
|
<link rel="stylesheet" href="~/vendor/chartist/chartist-plugin-tooltip.css" asp-append-version="true">
|
2022-04-12 09:55:10 +02:00
|
|
|
<script src="~/vendor/chartist/chartist.min.js" asp-append-version="true"></script>
|
2024-02-02 11:29:35 +01:00
|
|
|
<script src="~/vendor/chartist/chartist-plugin-tooltip.js" asp-append-version="true"></script>
|
2022-07-04 04:03:16 +02:00
|
|
|
<script>
|
|
|
|
const DashboardUtils = {
|
|
|
|
toDefaultCurrency(amount, rate) {
|
|
|
|
return Math.round((amount * rate) * 100) / 100;
|
|
|
|
},
|
|
|
|
displayDefaultCurrency(amount, rate, currency, divisibility) {
|
|
|
|
const value = DashboardUtils.toDefaultCurrency(amount, rate);
|
|
|
|
const locale = currency === 'USD' ? 'en-US' : navigator.language;
|
2023-05-25 03:08:00 +02:00
|
|
|
const isSats = currency === 'SATS';
|
|
|
|
if (isSats) currency = 'BTC';
|
2022-07-04 04:03:16 +02:00
|
|
|
const opts = { currency, style: 'decimal', minimumFractionDigits: divisibility };
|
2023-05-25 03:08:00 +02:00
|
|
|
const val = new Intl.NumberFormat(locale, opts).format(value);
|
|
|
|
return isSats ? val.replace(/[\\.,]/g, ' ') : val;
|
2022-07-04 04:03:16 +02:00
|
|
|
},
|
|
|
|
async fetchRate(currencyPair) {
|
|
|
|
const storeId = @Safe.Json(Context.GetRouteValue("storeId"));
|
|
|
|
const pathBase = @Safe.Json(Context.Request.PathBase);
|
|
|
|
const response = await fetch(`${pathBase}/api/rates?storeId=${storeId}¤cyPairs=${currencyPair}`);
|
|
|
|
const json = await response.json();
|
|
|
|
const rate = json[0] && json[0].rate;
|
|
|
|
if (rate) return rate;
|
|
|
|
else console.warn(`Fetching rate for ${currencyPair} failed.`);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
2022-04-12 09:55:10 +02:00
|
|
|
<div id="Dashboard" class="mt-4">
|
2023-01-09 14:07:05 +01:00
|
|
|
<vc:ui-extension-point location="dashboard" model="@Model"/>
|
2022-04-12 09:55:10 +02:00
|
|
|
@if (Model.WalletEnabled)
|
|
|
|
{
|
|
|
|
<vc:store-wallet-balance store="@store"/>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<div class="widget setup-guide">
|
|
|
|
<header>
|
|
|
|
<h5 class="mb-4 text-muted">This store is ready to accept transactions, good job!</h5>
|
|
|
|
</header>
|
|
|
|
<div class="list-group" id="SetupGuide">
|
|
|
|
<div class="list-group-item d-flex align-items-center" id="SetupGuide-LightningDone">
|
|
|
|
<vc:icon symbol="done"/>
|
|
|
|
<div class="content">
|
|
|
|
<h5 class="mb-0 text-success">Set up a Lightning node</h5>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-07-06 05:40:16 +02:00
|
|
|
<a asp-controller="UIStores" asp-action="SetupWallet" asp-route-storeId="@Model.StoreId" asp-route-cryptoCode="@Model.CryptoCode" id="SetupGuide-Wallet" class="list-group-item list-group-item-action d-flex align-items-center">
|
2022-04-12 09:55:10 +02:00
|
|
|
<vc:icon symbol="new-wallet"/>
|
|
|
|
<div class="content">
|
|
|
|
<h5 class="mb-0">Set up a wallet</h5>
|
|
|
|
</div>
|
|
|
|
<vc:icon symbol="caret-right"/>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
}
|
2022-07-06 05:40:16 +02:00
|
|
|
<vc:store-numbers vm="@(new StoreNumbersViewModel { Store = store, CryptoCode = Model.CryptoCode, InitialRendering = true })"/>
|
2022-06-14 07:36:22 +02:00
|
|
|
@if (Model.LightningEnabled)
|
|
|
|
{
|
2022-07-06 05:40:16 +02:00
|
|
|
<vc:store-lightning-balance vm="@(new StoreLightningBalanceViewModel { Store = store, CryptoCode = Model.CryptoCode, InitialRendering = true })"/>
|
2024-01-06 08:46:19 +01:00
|
|
|
<vc:store-lightning-services vm="@(new StoreLightningServicesViewModel { Store = store, CryptoCode = Model.CryptoCode })" permission="@Policies.CanModifyServerSettings"/>
|
2022-06-14 07:36:22 +02:00
|
|
|
}
|
2022-04-12 09:55:10 +02:00
|
|
|
@if (Model.WalletEnabled)
|
|
|
|
{
|
2022-07-06 05:40:16 +02:00
|
|
|
<vc:store-recent-transactions vm="@(new StoreRecentTransactionsViewModel { Store = store, CryptoCode = Model.CryptoCode, InitialRendering = true })"/>
|
2022-04-12 09:55:10 +02:00
|
|
|
}
|
2022-07-06 05:40:16 +02:00
|
|
|
<vc:store-recent-invoices vm="@(new StoreRecentInvoicesViewModel { Store = store, CryptoCode = Model.CryptoCode, InitialRendering = true })"/>
|
2022-04-12 09:55:10 +02:00
|
|
|
@foreach (var app in Model.Apps)
|
|
|
|
{
|
2023-03-20 10:39:26 +09:00
|
|
|
<vc:app-sales app-id="@app.Id" app-type="@app.AppType" />
|
|
|
|
<vc:app-top-items app-id="@app.Id" app-type="@app.AppType" />
|
2022-04-12 09:55:10 +02:00
|
|
|
}
|
|
|
|
</div>
|
2022-01-13 09:08:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-12-12 21:45:41 +01:00
|
|
|
<p class="lead text-secondary mt-2">To start accepting payments, set up a wallet or a Lightning node.</p>
|
2022-04-12 09:55:10 +02:00
|
|
|
|
|
|
|
<div class="list-group" id="SetupGuide">
|
|
|
|
<div class="list-group-item d-flex align-items-center" id="SetupGuide-StoreDone">
|
2022-01-27 03:56:46 +01:00
|
|
|
<vc:icon symbol="done"/>
|
|
|
|
<div class="content">
|
2022-04-12 09:55:10 +02:00
|
|
|
<h5 class="mb-0 text-success">Create your store</h5>
|
2022-01-13 09:08:15 +01:00
|
|
|
</div>
|
2022-01-27 03:56:46 +01:00
|
|
|
</div>
|
2022-09-13 16:14:46 +02:00
|
|
|
@if (Model.Network is BTCPayNetwork)
|
2022-04-12 09:55:10 +02:00
|
|
|
{
|
2022-09-13 16:14:46 +02:00
|
|
|
|
|
|
|
@if (!Model.WalletEnabled)
|
|
|
|
{
|
|
|
|
<a asp-controller="UIStores" asp-action="SetupWallet" asp-route-storeId="@Model.StoreId" asp-route-cryptoCode="@Model.CryptoCode" id="SetupGuide-Wallet" class="list-group-item list-group-item-action d-flex align-items-center order-1">
|
|
|
|
<vc:icon symbol="new-wallet"/>
|
|
|
|
<div class="content">
|
|
|
|
<h5 class="mb-0">Set up a wallet</h5>
|
|
|
|
</div>
|
|
|
|
<vc:icon symbol="caret-right"/>
|
|
|
|
</a>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<div class="list-group-item d-flex align-items-center" id="SetupGuide-WalletDone">
|
|
|
|
<vc:icon symbol="done"/>
|
|
|
|
<div class="content">
|
|
|
|
<h5 class="mb-0 text-success">Set up a wallet</h5>
|
|
|
|
</div>
|
2022-04-12 09:55:10 +02:00
|
|
|
</div>
|
2022-09-13 16:14:46 +02:00
|
|
|
}
|
2022-04-12 09:55:10 +02:00
|
|
|
}
|
2022-07-06 18:38:51 -07:00
|
|
|
@if (Model.LightningSupported) {
|
|
|
|
if (!Model.LightningEnabled)
|
|
|
|
{
|
|
|
|
<a asp-controller="UIStores" asp-action="SetupLightningNode" asp-route-storeId="@Model.StoreId" asp-route-cryptoCode="@Model.CryptoCode" id="SetupGuide-Lightning" class="list-group-item list-group-item-action d-flex align-items-center order-1">
|
|
|
|
<vc:icon symbol="new-wallet"/>
|
|
|
|
<div class="content">
|
|
|
|
<h5 class="mb-0">Set up a Lightning node</h5>
|
|
|
|
</div>
|
|
|
|
<vc:icon symbol="caret-right"/>
|
|
|
|
</a>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<div class="list-group-item d-flex align-items-center" id="SetupGuide-LightningDone">
|
|
|
|
<vc:icon symbol="done"/>
|
|
|
|
<div class="content">
|
|
|
|
<h5 class="mb-0 text-success">Set up a Lightning node</h5>
|
|
|
|
</div>
|
2022-04-12 09:55:10 +02:00
|
|
|
</div>
|
2022-07-06 18:38:51 -07:00
|
|
|
}
|
2022-04-12 09:55:10 +02:00
|
|
|
}
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
|