@page "/admin/api-keys/create"
@page "/admin/api-keys/{Id:int}/edit"
@using ScadaLink.Security
@using ScadaLink.Commons.Entities.InboundApi
@using ScadaLink.Commons.Interfaces.Repositories
@attribute [Authorize(Policy = AuthorizationPolicies.RequireAdmin)]
@inject IInboundApiRepository InboundApiRepository
@inject NavigationManager NavigationManager
@inject IJSRuntime JS
← Back
ยท
@if (_saved)
{
@:API Key Created
}
else if (IsEditMode)
{
@:Edit API Key
}
else
{
@:Add API Key
}
@* Bundle D (#23 M7-T12) drill-in: deep-link into the central Audit Log
pre-filtered to this API key's inbound calls. Inbound audit rows record
the key Name as Actor and live on the ApiInbound channel. *@
@if (IsEditMode && !string.IsNullOrWhiteSpace(_formName))
{
Recent audit activity
}
@if (_loading)
{
}
else if (_saved && _newlyCreatedKeyValue != null)
{
New API Key Created
@_newlyCreatedKeyValue
Copy
Save this key now. It will not be shown again in full.
Back to API Keys
}
else if (_errorMessage != null)
{
@_errorMessage
}
else
{
Name
@if (IsEditMode)
{
API Method Access
@if (_allMethods.Count == 0)
{
No API methods configured.
Create one to grant access.
}
else
{
@foreach (var method in _allMethods.OrderBy(m => m.Name))
{
var checkboxId = $"method-access-{method.Id}";
ToggleMethod(method.Id, (bool)e.Value!)" />
@method.Name
}
Callers using this key can invoke any checked method.
}
}
@if (_formError != null)
{
@_formError
}
Save
Cancel
}
@code {
[Parameter] public int? Id { get; set; }
private bool IsEditMode => _editingKey != null;
private ApiKey? _editingKey;
private string _formName = string.Empty;
private string? _formError;
private string? _errorMessage;
private string? _newlyCreatedKeyValue;
private bool _loading = true;
private bool _saved;
private List