2020-03-02 16:50:28 +01:00
|
|
|
@using BTCPayServer.Client
|
2020-02-24 14:36:15 +01:00
|
|
|
@using BTCPayServer.Controllers
|
2020-03-27 13:13:40 +09:00
|
|
|
@using BTCPayServer.Security.GreenField
|
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");
|
|
|
|
}
|
|
|
|
|
|
|
|
<h4>@ViewData["Title"]</h4>
|
2020-03-23 14:17:17 +01:00
|
|
|
<partial name="_StatusMessage"/>
|
2020-03-20 19:39:02 +09:00
|
|
|
<p>
|
2020-02-24 14:36:15 +01:00
|
|
|
Generate a new api key to use BTCPay through its API.
|
|
|
|
</p>
|
2020-02-25 14:43:53 +01:00
|
|
|
|
2020-10-16 22:30:53 +02:00
|
|
|
<form method="post" asp-action="AddApiKey">
|
|
|
|
<div asp-validation-summary="All" class="text-danger"></div>
|
2020-03-19 19:11:15 +09:00
|
|
|
|
2020-10-16 22:30:53 +02:00
|
|
|
<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>
|
|
|
|
|
|
|
|
<h5 class="mt-5 mb-3">Permissions</h5>
|
|
|
|
<div class="list-group mb-4">
|
|
|
|
@for (int i = 0; i < Model.PermissionValues.Count; i++)
|
|
|
|
{
|
2020-12-08 15:20:59 +09:00
|
|
|
@if (Model.PermissionValues[i].Forbidden)
|
2020-03-12 14:59:24 +01:00
|
|
|
{
|
2020-12-08 15:20:59 +09:00
|
|
|
<input type="hidden" asp-for="PermissionValues[i].Value" value="false" />
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<input type="hidden" asp-for="PermissionValues[i].Permission" />
|
2020-10-16 22:30:53 +02:00
|
|
|
@if (Policies.IsStorePolicy(Model.PermissionValues[i].Permission))
|
2020-03-19 19:11:15 +09:00
|
|
|
{
|
2020-12-08 15:20:59 +09:00
|
|
|
<input type="hidden" asp-for="PermissionValues[i].StoreMode" value="@Model.PermissionValues[i].StoreMode" />
|
2020-10-16 22:30:53 +02:00
|
|
|
@if (Model.PermissionValues[i].StoreMode == ManageController.AddApiKeyViewModel.ApiKeyStoreMode.AllStores)
|
2020-02-24 14:36:15 +01:00
|
|
|
{
|
2020-10-16 22:30:53 +02:00
|
|
|
<div class="list-group-item form-group py-3">
|
|
|
|
<div class="form-check">
|
2020-12-08 15:20:59 +09:00
|
|
|
<input id="@Model.PermissionValues[i].Permission" type="checkbox" asp-for="PermissionValues[i].Value" class="form-check-input ml-n4" />
|
2020-10-16 22:30:53 +02:00
|
|
|
<label for="@Model.PermissionValues[i].Permission" class="h5 form-check-label mr-2 mb-1">@Model.PermissionValues[i].Title</label>
|
|
|
|
<button type="submit" class="btn btn-link p-0 mb-1" name="command" value="@($"{Model.PermissionValues[i].Permission}:change-store-mode")">Select specific stores</button>
|
|
|
|
<span asp-validation-for="PermissionValues[i].Value" class="text-danger"></span>
|
2020-03-23 14:17:17 +01:00
|
|
|
<span class="form-text text-muted">@Model.PermissionValues[i].Description</span>
|
|
|
|
</div>
|
2020-10-16 22:30:53 +02:00
|
|
|
</div>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<div class="list-group-item py-3" style="padding-left:2.5rem;">
|
|
|
|
<h5 class="mb-1">@Model.PermissionValues[i].Title</h5>
|
|
|
|
<span class="form-text text-muted my-2">@Model.PermissionValues[i].Description</span>
|
|
|
|
<button type="submit" class="btn btn-link p-0 mb-1" name="command" value="@($"{Model.PermissionValues[i].Permission}:change-store-mode")">Give permission to all stores instead</button>
|
|
|
|
|
2020-03-23 14:17:17 +01:00
|
|
|
@if (!Model.Stores.Any())
|
|
|
|
{
|
2020-10-16 22:30:53 +02:00
|
|
|
<p class="text-warning">
|
2020-03-23 14:17:17 +01:00
|
|
|
You currently have no stores configured.
|
2020-10-16 22:30:53 +02:00
|
|
|
</p>
|
2020-03-23 14:17:17 +01:00
|
|
|
}
|
|
|
|
@for (var index = 0; index < Model.PermissionValues[i].SpecificStores.Count; index++)
|
|
|
|
{
|
2020-10-16 22:30:53 +02:00
|
|
|
<div class="input-group my-3">
|
|
|
|
@if (Model.PermissionValues[i].SpecificStores[index] == null)
|
|
|
|
{
|
|
|
|
<select asp-for="PermissionValues[i].SpecificStores[index]" class="form-control" asp-items="@(new SelectList(Model.Stores.Where(data => !Model.PermissionValues[i].SpecificStores.Contains(data.Id)), nameof(StoreData.Id), nameof(StoreData.StoreName)))"></select>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var store = Model.Stores.SingleOrDefault(data => data.Id == Model.PermissionValues[i].SpecificStores[index]);
|
|
|
|
<select asp-for="PermissionValues[i].SpecificStores[index]" class="form-control" asp-items="@(new SelectList(new[] {store}, nameof(StoreData.Id), nameof(StoreData.StoreName), store.Id))"></select>
|
|
|
|
}
|
|
|
|
<span asp-validation-for="PermissionValues[i].SpecificStores[index]" class="text-danger"></span>
|
|
|
|
<div class="input-group-append">
|
|
|
|
<button type="submit" title="Remove Store Permission" name="command" value="@($"{Model.PermissionValues[i].Permission}:remove-store:{index}")" class="btn btn-danger">
|
|
|
|
Remove
|
|
|
|
</button>
|
2020-03-23 14:17:17 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
@if (Model.PermissionValues[i].SpecificStores.Count < Model.Stores.Length)
|
|
|
|
{
|
2020-10-16 22:30:53 +02:00
|
|
|
<div class="mt-3 mb-2">
|
|
|
|
<button type="submit" name="command" value="@($"{Model.PermissionValues[i].Permission}:add-store")" class="btn btn-secondary">Add another store</button>
|
2020-03-23 14:17:17 +01:00
|
|
|
</div>
|
|
|
|
}
|
|
|
|
</div>
|
2020-02-24 14:36:15 +01:00
|
|
|
}
|
2020-03-23 14:17:17 +01:00
|
|
|
}
|
2020-10-16 22:30:53 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
<div class="list-group-item form-group py-3">
|
|
|
|
<div class="form-check">
|
2020-12-08 15:20:59 +09:00
|
|
|
<input id="@Model.PermissionValues[i].Permission" type="checkbox" asp-for="PermissionValues[i].Value" class="form-check-input ml-n4" />
|
2020-10-16 22:30:53 +02:00
|
|
|
<label for="@Model.PermissionValues[i].Permission" class="h5 form-check-label mr-2 mb-1">@Model.PermissionValues[i].Title</label>
|
|
|
|
<span asp-validation-for="PermissionValues[i].Value" class="text-danger"></span>
|
|
|
|
<span class="form-text text-muted">@Model.PermissionValues[i].Description</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
}
|
2020-02-24 14:36:15 +01:00
|
|
|
}
|
2020-10-16 22:30:53 +02:00
|
|
|
}
|
2020-02-24 14:36:15 +01:00
|
|
|
</div>
|
2020-10-16 22:30:53 +02:00
|
|
|
|
|
|
|
<button type="submit" class="btn btn-primary" id="Generate">Generate API Key</button>
|
|
|
|
</form>
|
2020-02-24 14:36:15 +01:00
|
|
|
|
|
|
|
@section Scripts {
|
|
|
|
@await Html.PartialAsync("_ValidationScriptsPartial")
|
|
|
|
|
|
|
|
<style>
|
2020-03-20 19:39:02 +09:00
|
|
|
.remove-btn {
|
2020-02-24 14:36:15 +01:00
|
|
|
font-size: 1.5rem;
|
|
|
|
border-radius: 0;
|
|
|
|
}
|
2020-03-20 19:39:02 +09:00
|
|
|
|
|
|
|
.remove-btn:hover {
|
|
|
|
background-color: #CCCCCC;
|
|
|
|
}
|
2020-02-24 14:36:15 +01:00
|
|
|
</style>
|
|
|
|
}
|