mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-19 05:33:31 +01:00
Server Settings: Update Policies page (#4326)
Handles the multiple submit buttons on that page and closes #4319. Contains some UI unifications with other pages and also shows the block explorers without needing to toggle the section via JS.
This commit is contained in:
parent
eda0f7327e
commit
6194c156bd
@ -298,9 +298,9 @@ namespace BTCPayServer.Controllers
|
|||||||
[HttpPost("server/policies")]
|
[HttpPost("server/policies")]
|
||||||
public async Task<IActionResult> Policies([FromServices] BTCPayNetworkProvider btcPayNetworkProvider, PoliciesSettings settings, string command = "")
|
public async Task<IActionResult> Policies([FromServices] BTCPayNetworkProvider btcPayNetworkProvider, PoliciesSettings settings, string command = "")
|
||||||
{
|
{
|
||||||
|
|
||||||
ViewBag.UpdateUrlPresent = _Options.UpdateUrl != null;
|
ViewBag.UpdateUrlPresent = _Options.UpdateUrl != null;
|
||||||
ViewBag.AppsList = await GetAppSelectList();
|
ViewBag.AppsList = await GetAppSelectList();
|
||||||
|
|
||||||
if (command == "add-domain")
|
if (command == "add-domain")
|
||||||
{
|
{
|
||||||
ModelState.Clear();
|
ModelState.Clear();
|
||||||
|
@ -2,8 +2,10 @@
|
|||||||
@using BTCPayServer.Services.Mails;
|
@using BTCPayServer.Services.Mails;
|
||||||
@model BTCPayServer.Services.PoliciesSettings
|
@model BTCPayServer.Services.PoliciesSettings
|
||||||
@inject SettingsRepository _SettingsRepository
|
@inject SettingsRepository _SettingsRepository
|
||||||
|
@inject BTCPayNetworkProvider BTCPayNetworkProvider
|
||||||
@{
|
@{
|
||||||
ViewData.SetActivePage(ServerNavPages.Policies);
|
ViewData.SetActivePage(ServerNavPages.Policies);
|
||||||
|
var networks = BTCPayNetworkProvider.GetAll().ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
<h3 class="mb-4">@ViewData["Title"]</h3>
|
<h3 class="mb-4">@ViewData["Title"]</h3>
|
||||||
@ -13,7 +15,9 @@
|
|||||||
<div asp-validation-summary="All" class="text-danger"></div>
|
<div asp-validation-summary="All" class="text-danger"></div>
|
||||||
}
|
}
|
||||||
|
|
||||||
<form method="post">
|
<div class="row">
|
||||||
|
<div class="col-xl-8 col-xxl-constrain">
|
||||||
|
<form method="post" class="d-flex flex-column">
|
||||||
<div class="form-group mb-5">
|
<div class="form-group mb-5">
|
||||||
<h4 class="mb-3">Existing User Settings</h4>
|
<h4 class="mb-3">Existing User Settings</h4>
|
||||||
<div class="form-check my-3">
|
<div class="form-check my-3">
|
||||||
@ -119,23 +123,24 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h4 class="mb-3">Plugins</h4>
|
<h4 class="mb-3">Plugins</h4>
|
||||||
<div class="row">
|
|
||||||
<div class="col-12 col-lg-8">
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="PluginSource" class="form-label"></label>
|
<label asp-for="PluginSource" class="form-label"></label>
|
||||||
<input asp-for="PluginSource" placeholder="@PoliciesSettings.DefaultPluginSource" class="form-control"/>
|
<input asp-for="PluginSource" placeholder="@PoliciesSettings.DefaultPluginSource" class="form-control"/>
|
||||||
<span asp-validation-for="PluginSource" class="text-danger"></span>
|
<span asp-validation-for="PluginSource" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-check my-3">
|
<div class="form-check">
|
||||||
<input asp-for="PluginPreReleases" type="checkbox" class="form-check-input"/>
|
<input asp-for="PluginPreReleases" type="checkbox" class="form-check-input"/>
|
||||||
<label asp-for="PluginPreReleases" class="form-check-label"></label>
|
<label asp-for="PluginPreReleases" class="form-check-label"></label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
@* To handle the multiple submit buttons on this page: Give this button
|
||||||
|
a specific order to put it last, but keep it first in the markup *@
|
||||||
|
<div class="order-1">
|
||||||
|
<button id="SaveButton" type="submit" class="btn btn-primary" name="command" value="Save">Save</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h4 class="mb-3">Customization Settings</h4>
|
<h4 class="mt-5">Customization Settings</h4>
|
||||||
|
<div class="form-group mb-5">
|
||||||
<div class="form-group">
|
|
||||||
<label asp-for="RootAppId" class="form-label"></label>
|
<label asp-for="RootAppId" class="form-label"></label>
|
||||||
<select asp-for="RootAppId" asp-items="@(new SelectList(ViewBag.AppsList, nameof(SelectListItem.Value), nameof(SelectListItem.Text), Model.RootAppId))" class="form-select w-auto"></select>
|
<select asp-for="RootAppId" asp-items="@(new SelectList(ViewBag.AppsList, nameof(SelectListItem.Value), nameof(SelectListItem.Text), Model.RootAppId))" class="form-select w-auto"></select>
|
||||||
@if (!Model.DomainToAppMapping.Any())
|
@if (!Model.DomainToAppMapping.Any())
|
||||||
@ -146,18 +151,24 @@
|
|||||||
|
|
||||||
@if (Model.DomainToAppMapping.Any())
|
@if (Model.DomainToAppMapping.Any())
|
||||||
{
|
{
|
||||||
<h5 class="mt-5 mb-0">
|
<h5 class="d-flex align-items-center justify-content-between mt-5 gap-3">
|
||||||
Domain to app mapping
|
Domain to app mapping
|
||||||
<button id="AddDomainButton" type="submit" name="command" value="add-domain" class="btn btn-secondary btn-sm ms-2">Add domain mapping</button>
|
<button id="AddDomainButton" type="submit" name="command" value="add-domain" class="d-inline-block btn text-primary btn-link p-0">
|
||||||
|
<span class="fa fa-plus"></span>
|
||||||
|
Add domain mapping
|
||||||
|
</button>
|
||||||
</h5>
|
</h5>
|
||||||
<div class="list-group list-group-flush mb-2">
|
<div class="list-group list-group-flush mb-2">
|
||||||
@for (var index = 0; index < Model.DomainToAppMapping.Count; index++)
|
@for (var index = 0; index < Model.DomainToAppMapping.Count; index++)
|
||||||
{
|
{
|
||||||
<div class="list-group-item px-0 pt-3">
|
<div class="list-group-item px-0 pt-3">
|
||||||
<div class="row">
|
|
||||||
<div class="col-12 col-lg-8">
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
<div class="d-flex align-items-center justify-content-between">
|
||||||
<label asp-for="DomainToAppMapping[index].Domain" class="form-label"></label>
|
<label asp-for="DomainToAppMapping[index].Domain" class="form-label"></label>
|
||||||
|
<button type="submit" title="Remove domain mapping" name="command" value="@($"remove-domain:{index}")" class="d-inline-block ms-2 btn text-danger btn-link p-0 mb-2">
|
||||||
|
<span class="fa fa-times"></span> Remove Mapping
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<input asp-for="DomainToAppMapping[index].Domain" class="form-control"/>
|
<input asp-for="DomainToAppMapping[index].Domain" class="form-control"/>
|
||||||
<span asp-validation-for="DomainToAppMapping[index].Domain" class="text-danger"></span>
|
<span asp-validation-for="DomainToAppMapping[index].Domain" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
@ -170,32 +181,11 @@
|
|||||||
<span asp-validation-for="DomainToAppMapping[index].AppId" class="text-danger"></span>
|
<span asp-validation-for="DomainToAppMapping[index].AppId" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-lg-2 pull-right">
|
|
||||||
<button type="submit" title="Remove domain mapping" name="command" value="@($"remove-domain:{index}")"
|
|
||||||
class="d-block d-lg-none d-xl-none btn btn-danger mb-2">
|
|
||||||
Remove Destination
|
|
||||||
</button>
|
|
||||||
<button type="submit" title="Remove domain mapping" name="command" value="@($"remove-domain:{index}")"
|
|
||||||
class="d-none d-lg-block btn btn-outline-danger text-decoration-none h-100 align-middle border-0 fs-4">
|
|
||||||
<span class="fa fa-times"></span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
<button class="btn btn-link px-0" type="button" id="ExplorerLinksButton" data-bs-toggle="collapse" data-bs-target="#explorer-links" aria-expanded="false" aria-controls="explorer-links">
|
<h4>Block Explorers</h4>
|
||||||
Override the block explorers used
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<div class="collapse show collapse-on-js" id="explorer-links">
|
|
||||||
@inject BTCPayNetworkProvider BTCPayNetworkProvider
|
|
||||||
@{
|
|
||||||
var networks = BTCPayNetworkProvider.GetAll().ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
@for (var i = 0; i < networks.Count(); i++)
|
@for (var i = 0; i < networks.Count(); i++)
|
||||||
{
|
{
|
||||||
@ -206,8 +196,8 @@
|
|||||||
{
|
{
|
||||||
Model.BlockExplorerLinks.Add(new PoliciesSettings.BlockExplorerOverrideItem() {CryptoCode = network.CryptoCode, Link = network.BlockExplorerLinkDefault});
|
Model.BlockExplorerLinks.Add(new PoliciesSettings.BlockExplorerOverrideItem() {CryptoCode = network.CryptoCode, Link = network.BlockExplorerLinkDefault});
|
||||||
}
|
}
|
||||||
<div class="form-group m-0 py-4">
|
<div class="form-group">
|
||||||
<label class="form-label">@network.DisplayName (@network.CryptoCode)</label>
|
<label asp-for="BlockExplorerLinks[i].Link" class="form-label">@network.DisplayName (@network.CryptoCode)</label>
|
||||||
<input type="hidden" asp-for="BlockExplorerLinks[i].CryptoCode" value="@network.CryptoCode"/>
|
<input type="hidden" asp-for="BlockExplorerLinks[i].CryptoCode" value="@network.CryptoCode"/>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text" class="form-control" asp-for="BlockExplorerLinks[i].Link" value="@linkValue" rel="noreferrer noopener" data-default-link="@network.BlockExplorerLinkDefault"/>
|
<input type="text" class="form-control" asp-for="BlockExplorerLinks[i].Link" value="@linkValue" rel="noreferrer noopener" data-default-link="@network.BlockExplorerLinkDefault"/>
|
||||||
@ -217,11 +207,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button id="SaveButton" type="submit" class="btn btn-primary" name="command" value="Save">Save</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
@section PageFootContent {
|
@section PageFootContent {
|
||||||
<script>
|
<script>
|
||||||
|
Loading…
Reference in New Issue
Block a user