mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-03 17:36:59 +01:00
Refactor nav pages, add page to see users of the server
This commit is contained in:
parent
6240abbb7b
commit
eb9f669224
26 changed files with 176 additions and 63 deletions
34
BTCPayServer/Controllers/ServerController.cs
Normal file
34
BTCPayServer/Controllers/ServerController.cs
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
using BTCPayServer.Models;
|
||||||
|
using BTCPayServer.Models.ServerViewModels;
|
||||||
|
using Microsoft.AspNetCore.Identity;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BTCPayServer.Controllers
|
||||||
|
{
|
||||||
|
public class ServerController : Controller
|
||||||
|
{
|
||||||
|
private UserManager<ApplicationUser> _UserManager;
|
||||||
|
|
||||||
|
public ServerController(UserManager<ApplicationUser> userManager)
|
||||||
|
{
|
||||||
|
_UserManager = userManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Route("server/users")]
|
||||||
|
public IActionResult ListUsers()
|
||||||
|
{
|
||||||
|
var users = new UsersViewModel();
|
||||||
|
users.Users
|
||||||
|
= _UserManager.Users.Select(u => new UsersViewModel.UserViewModel()
|
||||||
|
{
|
||||||
|
Name = u.UserName,
|
||||||
|
Email = u.Email
|
||||||
|
}).ToList();
|
||||||
|
return View(users);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
33
BTCPayServer/Models/ServerViewModels/UsersViewModel.cs
Normal file
33
BTCPayServer/Models/ServerViewModels/UsersViewModel.cs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BTCPayServer.Models.ServerViewModels
|
||||||
|
{
|
||||||
|
public class UsersViewModel
|
||||||
|
{
|
||||||
|
public class UserViewModel
|
||||||
|
{
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
public string Email
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string StatusMessage
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UserViewModel> Users
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
} = new List<UserViewModel>();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -12,8 +12,10 @@
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Disabling 2FA does not change the keys used in authenticator apps. If you wish to change the key
|
Disabling 2FA does not change the keys used in authenticator apps. If you wish to change the key
|
||||||
used in an authenticator app you should <a asp-action="ResetAuthenticatorWarning">reset your
|
used in an authenticator app you should <a asp-action="ResetAuthenticatorWarning">
|
||||||
authenticator keys.</a>
|
reset your
|
||||||
|
authenticator keys.
|
||||||
|
</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
@{
|
|
||||||
Layout = "/Views/Shared/_Layout.cshtml";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
<section>
|
|
||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-12 text-center">
|
|
||||||
<h2 class="section-heading">Manage your account</h2>
|
|
||||||
<hr class="primary">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-3">
|
|
||||||
@await Html.PartialAsync("_ManageNav")
|
|
||||||
</div>
|
|
||||||
<div class="col-md-9">
|
|
||||||
@RenderBody()
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
@section Scripts {
|
|
||||||
@RenderSection("Scripts", required: false)
|
|
||||||
}
|
|
||||||
|
|
4
BTCPayServer/Views/Manage/_ViewStart.cshtml
Normal file
4
BTCPayServer/Views/Manage/_ViewStart.cshtml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
@{
|
||||||
|
Layout = "../Shared/_NavLayout.cshtml";
|
||||||
|
ViewBag.MainTitle = "Manage your account";
|
||||||
|
}
|
28
BTCPayServer/Views/Server/ListUsers.cshtml
Normal file
28
BTCPayServer/Views/Server/ListUsers.cshtml
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
@model UsersViewModel
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Users";
|
||||||
|
ViewData.AddActivePage(ServerNavPages.Users);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
<h4>@ViewData["Title"]</h4>
|
||||||
|
@Html.Partial("_StatusMessage", Model.StatusMessage)
|
||||||
|
|
||||||
|
|
||||||
|
<table class="table">
|
||||||
|
<thead class="thead-inverse">
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Email</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach(var user in Model.Users)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>@user.Name</td>
|
||||||
|
<td>@user.Email</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
30
BTCPayServer/Views/Server/ServerNavPages.cs
Normal file
30
BTCPayServer/Views/Server/ServerNavPages.cs
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
|
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||||
|
|
||||||
|
namespace BTCPayServer.Views.Server
|
||||||
|
{
|
||||||
|
public static class ServerNavPages
|
||||||
|
{
|
||||||
|
public static string ActivePageKey => "ActivePage";
|
||||||
|
public static string Index => "Index";
|
||||||
|
|
||||||
|
|
||||||
|
public static string Users => "Users";
|
||||||
|
|
||||||
|
public static string UsersNavClass(ViewContext viewContext) => PageNavClass(viewContext, Users);
|
||||||
|
|
||||||
|
public static string IndexNavClass(ViewContext viewContext) => PageNavClass(viewContext, Index);
|
||||||
|
|
||||||
|
public static string PageNavClass(ViewContext viewContext, string page)
|
||||||
|
{
|
||||||
|
var activePage = viewContext.ViewData["ActivePage"] as string;
|
||||||
|
return string.Equals(activePage, page, StringComparison.OrdinalIgnoreCase) ? "active" : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddActivePage(this ViewDataDictionary viewData, string activePage) => viewData[ActivePageKey] = activePage;
|
||||||
|
}
|
||||||
|
}
|
6
BTCPayServer/Views/Server/_Nav.cshtml
Normal file
6
BTCPayServer/Views/Server/_Nav.cshtml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
@using BTCPayServer.Views.Server
|
||||||
|
|
||||||
|
<ul class="nav nav-pills nav-stacked">
|
||||||
|
<li class="@ServerNavPages.UsersNavClass(ViewContext)"><a asp-action="Users">Users</a></li>
|
||||||
|
</ul>
|
||||||
|
|
2
BTCPayServer/Views/Server/_ViewImports.cshtml
Normal file
2
BTCPayServer/Views/Server/_ViewImports.cshtml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
@using BTCPayServer.Views.Server
|
||||||
|
@using BTCPayServer.Models.ServerViewModels
|
4
BTCPayServer/Views/Server/_ViewStart.cshtml
Normal file
4
BTCPayServer/Views/Server/_ViewStart.cshtml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
@{
|
||||||
|
Layout = "../Shared/_NavLayout.cshtml";
|
||||||
|
ViewBag.MainTitle = "Server settings";
|
||||||
|
}
|
|
@ -53,7 +53,7 @@
|
||||||
{
|
{
|
||||||
@if(User.IsInRole(Roles.ServerAdmin))
|
@if(User.IsInRole(Roles.ServerAdmin))
|
||||||
{
|
{
|
||||||
<li class="nav-item"><a asp-area="" asp-controller="Server" asp-action="Settings" class="nav-link js-scroll-trigger">Server settings</a></li>
|
<li class="nav-item"><a asp-area="" asp-controller="Server" asp-action="ListUsers" class="nav-link js-scroll-trigger">Server settings</a></li>
|
||||||
}
|
}
|
||||||
<li class="nav-item"><a asp-area="" asp-controller="Stores" asp-action="ListStores" class="nav-link js-scroll-trigger">Stores</a></li>
|
<li class="nav-item"><a asp-area="" asp-controller="Stores" asp-action="ListStores" class="nav-link js-scroll-trigger">Stores</a></li>
|
||||||
<li class="nav-item"><a asp-area="" asp-controller="Invoice" asp-action="ListInvoices" class="nav-link js-scroll-trigger">Invoices</a></li>
|
<li class="nav-item"><a asp-area="" asp-controller="Invoice" asp-action="ListInvoices" class="nav-link js-scroll-trigger">Invoices</a></li>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12 text-center">
|
<div class="col-lg-12 text-center">
|
||||||
<h2 class="section-heading">Manage your store</h2>
|
<h2 class="section-heading">@ViewData["MainTitle"]</h2>
|
||||||
<hr class="primary">
|
<hr class="primary">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
<div>
|
<div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
@await Html.PartialAsync("_StoreNav")
|
@await Html.PartialAsync("_Nav")
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
@RenderBody()
|
@RenderBody()
|
|
@ -1,6 +1,5 @@
|
||||||
@model BTCPayServer.Models.StoreViewModels.CreateStoreViewModel
|
@model BTCPayServer.Models.StoreViewModels.CreateStoreViewModel
|
||||||
@{
|
@{
|
||||||
Layout = "/Views/Shared/_Layout.cshtml";
|
|
||||||
ViewData["Title"] = "Create a new store";
|
ViewData["Title"] = "Create a new store";
|
||||||
}
|
}
|
||||||
<section>
|
<section>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
@model CreateTokenViewModel
|
@model CreateTokenViewModel
|
||||||
@{
|
@{
|
||||||
|
Layout = "../Shared/_NavLayout.cshtml";
|
||||||
ViewData["Title"] = "Create a new token";
|
ViewData["Title"] = "Create a new token";
|
||||||
ViewData.AddActivePage(StoreNavPages.Tokens);
|
ViewData.AddActivePage(StoreNavPages.Tokens);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
@model StoresViewModel
|
@model StoresViewModel
|
||||||
@{
|
@{
|
||||||
Layout = "/Views/Shared/_Layout.cshtml";
|
|
||||||
ViewData["Title"] = "Stores";
|
ViewData["Title"] = "Stores";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
@model TokensViewModel
|
@model TokensViewModel
|
||||||
@{
|
@{
|
||||||
|
Layout = "../Shared/_NavLayout.cshtml";
|
||||||
ViewData["Title"] = "Access Tokens";
|
ViewData["Title"] = "Access Tokens";
|
||||||
ViewData.AddActivePage(StoreNavPages.Tokens);
|
ViewData.AddActivePage(StoreNavPages.Tokens);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
@model PairingModel
|
@model PairingModel
|
||||||
@{
|
@{
|
||||||
Layout = "/Views/Shared/_Layout.cshtml";
|
|
||||||
ViewData["Title"] = "Pairing permission";
|
ViewData["Title"] = "Pairing permission";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
@model StoreViewModel
|
@model StoreViewModel
|
||||||
@{
|
@{
|
||||||
|
Layout = "../Shared/_NavLayout.cshtml";
|
||||||
ViewData["Title"] = "Profile";
|
ViewData["Title"] = "Profile";
|
||||||
ViewData.AddActivePage(BTCPayServer.Views.Stores.StoreNavPages.Index);
|
ViewData.AddActivePage(BTCPayServer.Views.Stores.StoreNavPages.Index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
@using BTCPayServer.Views.Stores
|
@using BTCPayServer.Views.Stores
|
||||||
@inject SignInManager<ApplicationUser> SignInManager
|
@inject SignInManager<ApplicationUser> SignInManager
|
||||||
@{
|
|
||||||
var hasExternalLogins = (await SignInManager.GetExternalAuthenticationSchemesAsync()).Any();
|
|
||||||
}
|
|
||||||
|
|
||||||
<ul class="nav nav-pills nav-stacked">
|
<ul class="nav nav-pills nav-stacked">
|
||||||
<li class="@StoreNavPages.IndexNavClass(ViewContext)"><a asp-action="UpdateStore">Information</a></li>
|
<li class="@StoreNavPages.IndexNavClass(ViewContext)"><a asp-action="UpdateStore">Information</a></li>
|
3
BTCPayServer/Views/Stores/_ViewStart.cshtml
Normal file
3
BTCPayServer/Views/Stores/_ViewStart.cshtml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
@{
|
||||||
|
ViewBag.MainTitle = "Manage store";
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue