mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-20 02:28:31 +01:00
657423207b
* Dashboard: Load Lightning balance async, display default currency * Simplify approach, improve views and scripts * Async tiles Async tiles * Add period for app sales * Fix missing keypad view sales * Fix after rebase * Fix awaited call * Fix build Co-authored-by: Nicolas Dorier <nicolas.dorier@gmail.com>
60 lines
1.8 KiB
C#
60 lines
1.8 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using BTCPayServer.Components.AppSales;
|
|
using BTCPayServer.Components.AppTopItems;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace BTCPayServer.Controllers
|
|
{
|
|
public partial class UIAppsController
|
|
{
|
|
[HttpGet("{appId}/dashboard/app-top-items")]
|
|
public IActionResult AppTopItems(string appId)
|
|
{
|
|
var app = HttpContext.GetAppData();
|
|
if (app == null)
|
|
return NotFound();
|
|
|
|
app.StoreData = GetCurrentStore();
|
|
|
|
var vm = new AppTopItemsViewModel { App = app };
|
|
return ViewComponent("AppTopItems", new { vm });
|
|
}
|
|
|
|
[HttpGet("{appId}/dashboard/app-sales")]
|
|
public IActionResult AppSales(string appId)
|
|
{
|
|
var app = HttpContext.GetAppData();
|
|
if (app == null)
|
|
return NotFound();
|
|
|
|
app.StoreData = GetCurrentStore();
|
|
|
|
var vm = new AppSalesViewModel { App = app };
|
|
return ViewComponent("AppSales", new { vm });
|
|
}
|
|
|
|
[HttpGet("{appId}/dashboard/app-sales/{period}")]
|
|
public async Task<IActionResult> AppSales(string appId, AppSalesPeriod period)
|
|
{
|
|
var app = HttpContext.GetAppData();
|
|
if (app == null)
|
|
return NotFound();
|
|
|
|
app.StoreData = GetCurrentStore();
|
|
|
|
var days = period switch
|
|
{
|
|
AppSalesPeriod.Week => 7,
|
|
AppSalesPeriod.Month => 30,
|
|
_ => throw new ArgumentException($"AppSalesPeriod {period} does not exist.")
|
|
};
|
|
var stats = await _appService.GetSalesStats(app, days);
|
|
|
|
return stats == null
|
|
? NotFound()
|
|
: Json(stats);
|
|
}
|
|
}
|
|
}
|