76 lines
2.4 KiB
Plaintext
76 lines
2.4 KiB
Plaintext
@using Newtonsoft.Json
|
|
@using Radzen.Blazor
|
|
@using Web.Operation.Services
|
|
|
|
@typeparam TRequest where TRequest : class, new()
|
|
@typeparam TResponse where TResponse : class, new()
|
|
|
|
@inject ProxyKMSService _proxyKmsService
|
|
|
|
<div>
|
|
<RadzenLabel Style="color: #bb86fc">@Title</RadzenLabel>
|
|
<div>
|
|
<div style="display:flex;">
|
|
<div style="width:50%; margin: 1rem;">
|
|
<div style="margin-bottom: 0.5rem; display:flex; justify-content:center; align-items:center; font-size: 1.6rem;">
|
|
<RadzenLabel>Request</RadzenLabel>
|
|
<RadzenLabel Style="margin-left: 2rem;">@($"[{Method}]")</RadzenLabel>
|
|
<RadzenTextBox Style="margin-left:1rem; width:100%;" @bind-Value="@Url"></RadzenTextBox>
|
|
<RadzenButton Style="margin-left: 2rem; width: 10rem;" Click="@OnClickSend">Send</RadzenButton>
|
|
</div>
|
|
<div>
|
|
<RadzenTextArea Style="width:100%; height: 20rem; font-size: 1.6rem;" @bind-Value="@Request"></RadzenTextArea>
|
|
</div>
|
|
</div>
|
|
<div style="width:50%; margin:1rem; font-size: 1.6rem;">
|
|
<div style="margin-bottom:0.5rem;">
|
|
<RadzenLabel>Response</RadzenLabel>
|
|
</div>
|
|
<div>
|
|
<RadzenTextArea Style="width:100%; height: 20rem; font-size: 1.6rem;" @bind-Value="@Response"></RadzenTextArea>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
@code {
|
|
[Parameter]
|
|
public string Title { get; set; }
|
|
|
|
[Parameter]
|
|
public string Method { get; set; }
|
|
|
|
[Parameter]
|
|
public string Url { get; set; }
|
|
|
|
|
|
public string Request{ get; set; }
|
|
|
|
public string Response{ get; set; }
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
var request = new TRequest();
|
|
Request = request.ToJson();
|
|
}
|
|
|
|
private async Task OnClickSend()
|
|
{
|
|
var req = JsonConvert.DeserializeObject<TRequest>(Request);
|
|
TResponse res = new TResponse();
|
|
|
|
if(Method.ToLower() == "post")
|
|
{
|
|
res = await _proxyKmsService.PostKms<TRequest, TResponse>($"{Url}", req);
|
|
}
|
|
else if(Method.ToLower() == "put")
|
|
{
|
|
res = await _proxyKmsService.PutKms<TRequest, TResponse>($"{Url}", req);
|
|
}
|
|
|
|
|
|
Response = res.ToJson();
|
|
}
|
|
}
|