btcpayserver/BTCPayServer/Components/AppTopItems/Default.cshtml
d11n 6d3e1bb40a
Dashboard: Add Point Of Sale data (#3897)
* Dashboard: Add Point Of Sale data

Closes #3675.

* LNURL: Add POS redirect URL

* POS: Fix invoices link

* Fix integration tests

* Simplify data aggregation

* Improve chart display
2022-06-28 14:05:02 +09:00

55 lines
2 KiB
Text

@using BTCPayServer.Services.Apps
@model BTCPayServer.Components.AppTopItems.AppTopItemsViewModel
@{
var action = $"Update{Model.App.AppType}";
var label = Model.App.AppType == nameof(AppType.Crowdfund) ? "contribution" : "sale";
}
<div id="AppTopItems-@Model.App.Id" class="widget app-top-items">
<header class="mb-3">
<h3>Top @(Model.App.AppType == nameof(AppType.Crowdfund) ? "Perks" : "Items")</h3>
<a asp-controller="UIApps" asp-action="@action" asp-route-appId="@Model.App.Id">View All</a>
</header>
@if (Model.Entries.Any())
{
<div class="ct-chart mb-3"></div>
<script>
(function () {
const id = @Safe.Json($"AppTopItems-{Model.App.Id}");
const series = @Safe.Json(Model.Entries.Select(i => i.SalesCount));
new Chartist.Bar(`#${id} .ct-chart`, { series }, {
distributeSeries: true,
horizontalBars: true,
showLabel: false,
stackBars: true,
axisY: {
offset: 0
}
});
})();
</script>
<div class="app-items">
@for (var i = 0; i < Model.Entries.Count; i++)
{
var entry = Model.Entries[i];
<div class="app-item ct-series-@i">
<span class="app-item-name">
<span class="app-item-point ct-point"></span>
@entry.Title
</span>
<span class="app-item-value">
<span class="text-muted">@entry.SalesCount @($"{label}{(entry.SalesCount == 1 ? "" : "s")}"),</span>
@entry.TotalFormatted
</span>
</div>
}
</div>
}
else
{
<p class="text-secondary mt-3">
No @($"{label}s") have been made yet.
</p>
}
</div>