2020-03-02 16:50:28 +01:00
|
|
|
@using BTCPayServer.Client
|
2020-02-24 14:36:15 +01:00
|
|
|
@using BTCPayServer.Controllers
|
|
|
|
@using BTCPayServer.Security.APIKeys
|
2020-03-08 15:44:37 +01:00
|
|
|
@model ManageController.AddApiKeyViewModel
|
2020-02-24 14:36:15 +01:00
|
|
|
|
|
|
|
@{
|
|
|
|
ViewData.SetActivePageAndTitle(ManageNavPages.APIKeys, "Add API Key");
|
|
|
|
|
|
|
|
string GetDescription(string permission)
|
|
|
|
{
|
|
|
|
return APIKeyConstants.Permissions.PermissionDescriptions[permission].Description;
|
|
|
|
}
|
|
|
|
|
|
|
|
string GetTitle(string permission)
|
|
|
|
{
|
|
|
|
return APIKeyConstants.Permissions.PermissionDescriptions[permission].Description;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
<h4>@ViewData["Title"]</h4>
|
|
|
|
<partial name="_StatusMessage"/>
|
|
|
|
<p >
|
|
|
|
Generate a new api key to use BTCPay through its API.
|
|
|
|
</p>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-12">
|
|
|
|
<form method="post" asp-action="AddApiKey" class="list-group">
|
|
|
|
|
|
|
|
<input type="hidden" asp-for="StoreMode" value="@Model.StoreMode"/>
|
|
|
|
<div asp-validation-summary="All" class="text-danger"></div>
|
2020-02-25 14:43:53 +01:00
|
|
|
|
|
|
|
<div class="list-group-item ">
|
|
|
|
<div class="form-group">
|
|
|
|
<label asp-for="Label"></label>
|
|
|
|
<input asp-for="Label" class="form-control"/>
|
|
|
|
<span asp-validation-for="Label" class="text-danger"></span>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-02-24 14:36:15 +01:00
|
|
|
@if (Model.IsServerAdmin)
|
|
|
|
{
|
|
|
|
<div class="list-group-item form-group">
|
|
|
|
<input asp-for="ServerManagementPermission" class="form-check-inline"/>
|
2020-03-02 16:50:28 +01:00
|
|
|
<label asp-for="ServerManagementPermission" class="h5">@GetTitle(Permissions.ServerManagement)</label>
|
2020-02-24 14:36:15 +01:00
|
|
|
<span asp-validation-for="ServerManagementPermission" class="text-danger"></span>
|
2020-03-02 16:50:28 +01:00
|
|
|
<p>@GetDescription(Permissions.ServerManagement).</p>
|
2020-02-24 14:36:15 +01:00
|
|
|
</div>
|
|
|
|
}
|
2020-03-12 14:59:24 +01:00
|
|
|
|
|
|
|
@for (int i = 0; i < Model.PermissionValues.Count; i++)
|
|
|
|
{
|
|
|
|
<div class="list-group-item form-group">
|
|
|
|
<input type="hidden" asp-for="PermissionValues[i].Permission">
|
|
|
|
<input type="checkbox" asp-for="PermissionValues[i].Value" class="form-check-inline"/>
|
|
|
|
<label asp-for="PermissionValues[i].Value" class="h5">@GetTitle(Model.PermissionValues[i].Permission)</label>
|
|
|
|
<span asp-validation-for="PermissionValues[i].Value" class="text-danger"></span>
|
|
|
|
<p>@GetDescription(Model.PermissionValues[i].Permission).</p>
|
|
|
|
</div>
|
|
|
|
}
|
2020-02-24 14:36:15 +01:00
|
|
|
@if (Model.StoreMode == ManageController.AddApiKeyViewModel.ApiKeyStoreMode.AllStores)
|
|
|
|
{
|
|
|
|
<div class="list-group-item form-group">
|
|
|
|
@Html.CheckBoxFor(model => model.StoreManagementPermission, new Dictionary<string, string>() {{"class", "form-check-inline"}})
|
|
|
|
|
2020-03-02 16:50:28 +01:00
|
|
|
<label asp-for="StoreManagementPermission" class="h5">@GetTitle(Permissions.StoreManagement)</label>
|
2020-02-24 14:36:15 +01:00
|
|
|
<span asp-validation-for="StoreManagementPermission" class="text-danger"></span>
|
2020-03-02 16:50:28 +01:00
|
|
|
<p class="mb-0">@GetDescription(Permissions.StoreManagement).</p>
|
2020-02-24 14:36:15 +01:00
|
|
|
<button type="submit" class="btn btn-link" name="command" value="change-store-mode">Give permission to specific stores instead</button>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
else if (Model.StoreMode == ManageController.AddApiKeyViewModel.ApiKeyStoreMode.Specific)
|
|
|
|
{
|
|
|
|
<div class="list-group-item p-0 border-0 mb-2">
|
|
|
|
<li class="list-group-item ">
|
2020-03-02 16:50:28 +01:00
|
|
|
<h5 class="mb-1">@GetTitle(Permissions.StoreManagement + ":")</h5>
|
|
|
|
<p class="mb-0">@GetDescription(Permissions.StoreManagement + ":").</p>
|
2020-02-24 14:36:15 +01:00
|
|
|
<button type="submit" class="btn btn-link" name="command" value="change-store-mode">Give permission to all stores instead</button>
|
|
|
|
</li>
|
|
|
|
@if (!Model.Stores.Any())
|
|
|
|
{
|
|
|
|
<li class="list-group-item alert-warning">
|
|
|
|
You currently have no stores configured.
|
|
|
|
</li>
|
|
|
|
}
|
|
|
|
@for (var index = 0; index < Model.SpecificStores.Count; index++)
|
|
|
|
{
|
|
|
|
<div class="list-group-item transaction-output-form p-0 pl-lg-2">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-sm-12 col-md-12 col-lg-10 py-2 ">
|
|
|
|
<div class="form-group my-0">
|
|
|
|
@if (Model.SpecificStores[index] == null)
|
|
|
|
{
|
|
|
|
<select asp-for="SpecificStores[index]" class="form-control" asp-items="@(new SelectList(Model.Stores.Where(data => !Model.SpecificStores.Contains(data.Id)), nameof(StoreData.Id), nameof(StoreData.StoreName)))"></select>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var store = Model.Stores.SingleOrDefault(data => data.Id == Model.SpecificStores[index]);
|
|
|
|
<select asp-for="SpecificStores[index]" class="form-control" asp-items="@(new SelectList(new[] {store}, nameof(StoreData.Id), nameof(StoreData.StoreName), store.Id))"></select>
|
|
|
|
}
|
|
|
|
|
|
|
|
<span asp-validation-for="SpecificStores[index]" class="text-danger"></span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="col-sm-12 col-md-12 col-lg-2 pull-right">
|
|
|
|
<button type="submit" title="Remove Store Permission" name="command" value="@($"remove-store:{index}")"
|
|
|
|
class="d-block d-lg-none d-xl-none btn btn-danger mb-2 ml-2">
|
|
|
|
Remove
|
|
|
|
</button>
|
|
|
|
<button type="submit" title="Remove Store Permission" name="command" value="@($"remove-store:{index}")"
|
|
|
|
class="d-none d-lg-block remove-btn text-decoration-none h-100 align-middle btn text-danger btn-link fa fa-times rounded-0 pull-right">
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
@if (Model.SpecificStores.Count < Model.Stores.Length)
|
|
|
|
{
|
|
|
|
<div class="list-group-item">
|
|
|
|
<button type="submit" name="command" value="add-store" class="ml-1 btn btn-secondary">Add another store </button>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
<button type="submit" class="btn btn-primary" id="Generate">Generate API Key</button>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
@section Scripts {
|
|
|
|
@await Html.PartialAsync("_ValidationScriptsPartial")
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.remove-btn{
|
|
|
|
font-size: 1.5rem;
|
|
|
|
border-radius: 0;
|
|
|
|
}
|
|
|
|
.remove-btn:hover{
|
|
|
|
background-color: #CCCCCC;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
}
|