-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
104 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
@page "/oauth2/clients/{ClientId}/edit" | ||
@using Ory.Hydra.Client.Model | ||
@attribute [StreamRendering] | ||
@attribute [RenderModeInteractiveServer] | ||
@inject ICustomTranslator Translator | ||
@inject ILogger<Home> Logger | ||
@inject NavigationManager Navigation | ||
|
||
<PageTitle>Edit Client</PageTitle> | ||
|
||
<h1 class="title">Edit Client</h1> | ||
@if (_isLoading) | ||
{ | ||
// is loading | ||
<p>Loading data...</p> | ||
} | ||
else | ||
{ | ||
<form @onsubmit="SubmitForm"> | ||
<div class="field"> | ||
<label class="label"> | ||
Client Name | ||
<div class="control"> | ||
<input type="text" class="input" value="@_client?.ClientName" | ||
@onchange="args => AddPatch(new HydraJsonPatch())"/> | ||
</div> | ||
</label> | ||
</div> | ||
<div class="field"> | ||
<label class="label"> | ||
Client Secret | ||
<div class="control"> | ||
<input type="text" class="input" value="@_client?.ClientSecret" | ||
@onchange="args => AddPatch(new HydraJsonPatch())"/> | ||
</div> | ||
</label> | ||
</div> | ||
<div class="message is-warning p-2 @(string.IsNullOrWhiteSpace(_errorMessage) ? "is-hidden" : "")"> | ||
@_errorMessage | ||
</div> | ||
<div class="mt-5"> | ||
<div class="buttons"> | ||
<a class="button" href="oauth2/clients/@ClientId"> | ||
Cancel | ||
</a> | ||
<button type="submit" class="button is-success"> | ||
Save | ||
</button> | ||
</div> | ||
</div> | ||
</form> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Microsoft.AspNetCore.Components; | ||
using Ory.Hydra.Client.Model; | ||
using Ory.Kratos.Client.Client; | ||
using OryAdmin.Services; | ||
|
||
namespace OryAdmin.Components.Pages.OAuth2.Clients; | ||
|
||
public partial class Edit | ||
{ | ||
private HydraOAuth2Client? _client; | ||
private string? _errorMessage; | ||
private bool _isLoading = true; | ||
|
||
[Parameter] | ||
public required string ClientId { get; set; } | ||
|
||
private readonly List<HydraJsonPatch> _patches = new(); | ||
|
||
[Inject] private ApiService ApiService { get; set; } = default!; | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
_client = await ApiService.HydraOAuth2.GetOAuth2ClientAsync(ClientId); | ||
_isLoading = false; | ||
} | ||
|
||
private async Task SubmitForm() | ||
{ | ||
try | ||
{ | ||
_ = await ApiService.HydraOAuth2.PatchOAuth2ClientAsync(ClientId, _patches); | ||
} | ||
catch (ApiException exception) | ||
{ | ||
_errorMessage = exception.Message; | ||
return; | ||
} | ||
|
||
Navigation.NavigateTo("oauth2/clients"); | ||
} | ||
|
||
private void AddPatch(HydraJsonPatch patch) | ||
{ | ||
_patches.Add(patch); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters