62 lines
1.8 KiB
Plaintext
62 lines
1.8 KiB
Plaintext
@page "/admin/api/{Id:int}"
|
|
|
|
@using System.Text.Json
|
|
@using MoonCore.Helpers
|
|
@using Moonlight.Shared.Http.Requests.Admin.ApiKeys
|
|
@using Moonlight.Shared.Http.Responses.Admin.ApiKeys
|
|
|
|
@inject HttpApiClient ApiClient
|
|
@inject NavigationManager Navigation
|
|
@inject ToastService ToastService
|
|
|
|
<LazyLoader Load="Load">
|
|
<PageHeader Title="Update API Key">
|
|
<a href="/admin/api" class="btn btn-secondary">
|
|
<i class="icon-chevron-left"></i>
|
|
Back
|
|
</a>
|
|
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
|
|
<i class="icon-check"></i>
|
|
Update
|
|
</WButton>
|
|
</PageHeader>
|
|
|
|
<div class="mt-5">
|
|
<HandleForm @ref="Form" Model="Request" OnValidSubmit="OnSubmit">
|
|
<div class="grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6">
|
|
<div class="sm:col-span-2">
|
|
<label class="block text-sm font-medium leading-6 text-base-content">Description</label>
|
|
<div class="mt-2">
|
|
<input @bind="Request.Description" type="text" autocomplete="off" class="input w-full">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</HandleForm>
|
|
</div>
|
|
</LazyLoader>
|
|
|
|
@code
|
|
{
|
|
[Parameter] public int Id { get; set; }
|
|
|
|
private HandleForm Form;
|
|
private UpdateApiKeyRequest Request;
|
|
|
|
private async Task Load(LazyLoader _)
|
|
{
|
|
var detail = await ApiClient.GetJson<ApiKeyResponse>($"api/admin/apikeys/{Id}");
|
|
|
|
Request = new()
|
|
{
|
|
Description = detail.Description
|
|
};
|
|
}
|
|
|
|
private async Task OnSubmit()
|
|
{
|
|
await ApiClient.Patch($"api/admin/apikeys/{Id}", Request);
|
|
|
|
await ToastService.Success("Successfully updated api key");
|
|
Navigation.NavigateTo("/admin/api");
|
|
}
|
|
} |