* 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:
d11n
2022-04-12 09:55:10 +02:00
committed by GitHub
parent d58803a058
commit 7ec978fcdb
41 changed files with 2037 additions and 115 deletions

View File

@@ -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);
}