mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-02-20 13:44:30 +01:00
cleans up api key list view
This commit is contained in:
committed by
Andrew Camilleri
parent
609fd131eb
commit
a2a49636e0
@@ -1,92 +1,87 @@
|
||||
@namespace BTCPayServer.Client
|
||||
@model BTCPayServer.Controllers.ManageController.ApiKeysViewModel
|
||||
@{
|
||||
ViewData.SetActivePageAndTitle(ManageNavPages.APIKeys, "Manage your API Keys");
|
||||
ViewData.SetActivePageAndTitle(ManageNavPages.APIKeys, "API Keys");
|
||||
}
|
||||
<h2 class="mb-4">@ViewData["Title"]</h2>
|
||||
|
||||
<p>
|
||||
The <a asp-controller="Home" asp-action="SwaggerDocs" target="_blank">BTCPay Server Greenfield API</a> offers programmatic access to your instance. You can manage your BTCPay
|
||||
Server (e.g. stores, invoices, users) as well as automate workflows and integrations (see <a href="https://docs.btcpayserver.org/Development/GreenFieldExample/" rel="noreferrer noopener">use case examples</a>).
|
||||
For that you need the API keys, which can be generated here. Find more information in the <a href="@Url.Action("SwaggerDocs", "Home")#section/Authentication" target="_blank" rel="noreferrer noopener">API authentication docs</a>.
|
||||
</p>
|
||||
<table class="table table-lg">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Label</th>
|
||||
<th class="w-125px">Key</th>
|
||||
<th>Permissions</th>
|
||||
<th class="text-end">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@{
|
||||
var index = 0;
|
||||
}
|
||||
@foreach (var keyData in Model.ApiKeyDatas)
|
||||
{
|
||||
<tr>
|
||||
<td>@keyData.Label</td>
|
||||
<td>
|
||||
<code class="hide-when-js">@keyData.Id</code>
|
||||
<button class="btn btn-sm btn-outline-primary only-for-js" data-reveal-btn>Click to reveal</button>
|
||||
<div hidden>
|
||||
<code data-api-key>@keyData.Id</code>
|
||||
<button class="btn btn-sm btn-outline-primary mt-2" data-clipboard-confirm>
|
||||
Copy to clipboard
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
@{
|
||||
var permissions = keyData.GetBlob().Permissions;
|
||||
}
|
||||
@if (!permissions.Any())
|
||||
{
|
||||
<span class="text-warning">No permissions</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<ul>
|
||||
@foreach (var permission in Permission.ToPermissions(permissions).Select(c => c.ToString()).Distinct().ToArray())
|
||||
{
|
||||
<li>
|
||||
<code class="text-break">@permission</code>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<a asp-action="DeleteAPIKey" asp-route-id="@keyData.Id" asp-controller="Manage" data-bs-toggle="modal" data-bs-target="#ConfirmModal" data-description="Any application using the API key <strong>@(keyData.Label ?? keyData.Id)<strong> will immediately lose access." data-confirm-input="DELETE">Delete</a>
|
||||
<span>-</span>
|
||||
<button type="button" class="btn btn-link only-for-js p-0" data-qr="@index">Show QR</button>
|
||||
</td>
|
||||
</tr>
|
||||
index++;
|
||||
}
|
||||
@if (!Model.ApiKeyDatas.Any())
|
||||
{
|
||||
<tr>
|
||||
<td colspan="4" class="text-center h5 py-2">
|
||||
No API keys
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<a class="btn btn-primary" asp-action="AddApiKey" id="AddApiKey">
|
||||
<span class="fa fa-plus"></span>
|
||||
Generate new key
|
||||
</a>
|
||||
@if (Model.ApiKeyDatas.Any())
|
||||
{
|
||||
<table class="table table-lg">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Label</th>
|
||||
<th class="w-125px">Key</th>
|
||||
<th>Permissions</th>
|
||||
<th class="text-end">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@{
|
||||
var index = 0;
|
||||
}
|
||||
@foreach (var keyData in Model.ApiKeyDatas)
|
||||
{
|
||||
<tr>
|
||||
<td>@keyData.Label</td>
|
||||
<td>
|
||||
<code class="hide-when-js">@keyData.Id</code>
|
||||
<a class="only-for-js" data-reveal-btn>Click to reveal</a>
|
||||
<div hidden>
|
||||
<code data-api-key>@keyData.Id</code>
|
||||
<a class="mt-2" data-clipboard-confirm>
|
||||
Copy to clipboard
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
@{
|
||||
var permissions = keyData.GetBlob().Permissions;
|
||||
}
|
||||
@if (!permissions.Any())
|
||||
{
|
||||
<span class="text-warning">No permissions</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<ul>
|
||||
@foreach (var permission in Permission.ToPermissions(permissions).Select(c => c.ToString()).Distinct().ToArray())
|
||||
{
|
||||
<li>
|
||||
<code class="text-break">@permission</code>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<a asp-action="DeleteAPIKey" asp-route-id="@keyData.Id" asp-controller="Manage" data-bs-toggle="modal" data-bs-target="#ConfirmModal" data-description="Any application using the API key <strong>@(keyData.Label ?? keyData.Id)<strong> will immediately lose access." data-confirm-input="DELETE">Delete</a>
|
||||
<span>-</span>
|
||||
<button type="button" class="btn btn-link only-for-js p-0" data-qr="@index">Show QR</button>
|
||||
</td>
|
||||
</tr>
|
||||
index++;
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
|
||||
<partial name="_Confirm" model="@(new ConfirmModel("Delete API key", "Any application using the API key will immediately lose access.", "Delete"))" />
|
||||
|
||||
<partial name="ShowQR"/>
|
||||
<partial name="ShowQR" />
|
||||
|
||||
@section PageHeadContent {
|
||||
<link href="~/vendor/vue-qrcode-reader/vue-qrcode-reader.css" rel="stylesheet" asp-append-version="true"/>
|
||||
<link href="~/vendor/vue-qrcode-reader/vue-qrcode-reader.css" rel="stylesheet" asp-append-version="true" />
|
||||
}
|
||||
|
||||
@section PageFootContent {
|
||||
<bundle name="wwwroot/bundles/camera-bundle.min.js"></bundle>
|
||||
<script>
|
||||
@@ -105,7 +100,7 @@
|
||||
$clipboardBtn.click(window.copyToClipboard);
|
||||
})();
|
||||
});
|
||||
|
||||
|
||||
var apiKeys = @Safe.Json(Model.ApiKeyDatas.Select(data => new
|
||||
{
|
||||
ApiKey = data.Id,
|
||||
@@ -121,5 +116,4 @@
|
||||
});
|
||||
});
|
||||
</script>
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user