mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 14:04:26 +01:00
Dashboard (#3530)
* Add dashboard and chart basics * More widgets * Make widgets responsive * Layout dashboard * Prepare ExplorerClient * Switch to Chartist * Dynamic data for store numbers and recent transactions tiles * Dynamic data for recent invoices tile * Improvements * Plug NBXPlorer DB * Properly filter by code * Reorder cheat mode button * AJAX update for graph data * Fix create invoice button * Retry connection on transient issues * App Top Items stats * Design updates * App Sales stats * Add points for weekly histogram, set last point to current balance Co-authored-by: nicolas.dorier <nicolas.dorier@gmail.com>
This commit is contained in:
@@ -134,31 +134,44 @@ namespace BTCPayServer.Controllers
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public StoreData CurrentStore
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.HttpContext.GetStoreData();
|
||||
}
|
||||
}
|
||||
|
||||
public StoreData CurrentStore => HttpContext.GetStoreData();
|
||||
|
||||
[HttpGet("{storeId}")]
|
||||
public IActionResult Dashboard()
|
||||
public async Task<IActionResult> Dashboard()
|
||||
{
|
||||
var store = CurrentStore;
|
||||
var storeBlob = store.GetStoreBlob();
|
||||
|
||||
AddPaymentMethods(store, storeBlob,
|
||||
out var derivationSchemes, out var lightningNodes);
|
||||
|
||||
|
||||
var walletEnabled = derivationSchemes.Any(scheme => !string.IsNullOrEmpty(scheme.Value) && scheme.Enabled);
|
||||
var lightningEnabled = lightningNodes.Any(ln => !string.IsNullOrEmpty(ln.Address) && ln.Enabled);
|
||||
var vm = new StoreDashboardViewModel
|
||||
{
|
||||
WalletEnabled = derivationSchemes.Any(scheme => !string.IsNullOrEmpty(scheme.Value) && scheme.Enabled),
|
||||
LightningEnabled = lightningNodes.Any(ln => !string.IsNullOrEmpty(ln.Address) && ln.Enabled),
|
||||
WalletEnabled = walletEnabled,
|
||||
LightningEnabled = lightningEnabled,
|
||||
StoreId = CurrentStore.Id,
|
||||
StoreName = CurrentStore.StoreName
|
||||
StoreName = CurrentStore.StoreName,
|
||||
IsSetUp = walletEnabled || lightningEnabled
|
||||
};
|
||||
|
||||
// Widget data
|
||||
if (vm.WalletEnabled || vm.LightningEnabled)
|
||||
{
|
||||
var userId = GetUserId();
|
||||
var apps = await _appService.GetAllApps(userId, false, store.Id);
|
||||
vm.Apps = apps
|
||||
.Where(a => a.AppType == AppType.Crowdfund.ToString())
|
||||
.Select(a =>
|
||||
{
|
||||
var appData = _appService.GetAppDataIfOwner(userId, a.Id, AppType.Crowdfund).Result;
|
||||
appData.StoreData = store;
|
||||
return appData;
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
return View("Dashboard", vm);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user