web-proxy rewrite
This commit is contained in:
parent
26c741ad03
commit
283fa1abc2
10 changed files with 63 additions and 134 deletions
|
|
@ -1,6 +1,6 @@
|
|||
using Insight.Domain.Interfaces;
|
||||
using Insight.Domain.Messages;
|
||||
using Insight.Domain.Messages.Web;
|
||||
using Insight.Domain.Messages.Agent;
|
||||
using Vaitr.Bus;
|
||||
|
||||
namespace Insight.Web.Network.Handlers;
|
||||
|
|
@ -16,7 +16,7 @@ public class ConsoleHandler : IMessageHandler<WebSession>
|
|||
|
||||
public async ValueTask HandleAsync<TMessage>(WebSession sender, TMessage message, CancellationToken cancellationToken) where TMessage : IMessage
|
||||
{
|
||||
if (message is ConsoleQueryProxy consoleQuery)
|
||||
if (message is Proxy<ConsoleQuery> consoleQuery)
|
||||
{
|
||||
await _bus.PublishAsync(consoleQuery, cancellationToken);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,17 +6,17 @@
|
|||
{
|
||||
<MudGrid>
|
||||
<MudItem xs="12" sm="12" md="12" lg="12">
|
||||
<MudTextField T="string" Label="Query" Variant="Variant.Outlined" @bind-Text="_model.ConsoleQuery.Query" Lines="20" />
|
||||
<MudTextField T="string" Label="Query" Variant="Variant.Outlined" @bind-Text="_model.Request.Query" Lines="20" />
|
||||
</MudItem>
|
||||
|
||||
<MudItem xs="12" sm="12" md="12" lg="12">
|
||||
@if (_model.ConsoleQuery.HadErrors is false)
|
||||
@if (_model.Response.HadErrors is false)
|
||||
{
|
||||
<MudTextField T="string" Label="Data" Variant="Variant.Outlined" @bind-Text="_model.ConsoleQuery.Data" Lines="20" />
|
||||
<MudTextField T="string" Label="Data" Variant="Variant.Outlined" @bind-Text="_model.Response.Data" Lines="20" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudTextField T="string" Label="Errors" Variant="Variant.Outlined" @bind-Text="_model.ConsoleQuery.Errors" Lines="20" />
|
||||
<MudTextField T="string" Label="Errors" Variant="Variant.Outlined" @bind-Text="_model.Response.Errors" Lines="20" />
|
||||
}
|
||||
</MudItem>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
using Insight.Domain.Messages;
|
||||
using Insight.Domain.Messages.Web;
|
||||
using Insight.Domain.Messages.Agent;
|
||||
using Insight.Infrastructure;
|
||||
using Insight.Infrastructure.Entities;
|
||||
using Insight.Web.Constants;
|
||||
|
|
@ -33,7 +33,7 @@ public partial class Index
|
|||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_subscriptions.Add(Bus.SubscribeAsync<ConsoleQueryProxy>(OnQueryResultAsync, p => p.Id == _id));
|
||||
_subscriptions.Add(Bus.SubscribeAsync<Proxy<ConsoleQuery>>(OnQueryResultAsync, p => p.RequestId == _id));
|
||||
}
|
||||
|
||||
private async Task LoadDataAsync()
|
||||
|
|
@ -75,15 +75,15 @@ public partial class Index
|
|||
|
||||
private async Task SubmitAsync()
|
||||
{
|
||||
if (_model.ConsoleQuery.Query is null || WebPool.Any() is false) return;
|
||||
if (_model.Request.Query is null || WebPool.Any() is false) return;
|
||||
|
||||
try
|
||||
{
|
||||
await WebPool.First().Value.SendAsync(new ConsoleQueryProxyRequest
|
||||
await WebPool.First().Value.SendAsync(new Proxy<ConsoleQueryRequest>
|
||||
{
|
||||
Id = _id,
|
||||
RequestId = _id,
|
||||
HostId = HostId,
|
||||
Query = _model.ConsoleQuery.Query
|
||||
Message = _model.Request
|
||||
}, default);
|
||||
|
||||
Notification.Information(Snackbar, "Sent Query Command");
|
||||
|
|
@ -94,17 +94,18 @@ public partial class Index
|
|||
}
|
||||
}
|
||||
|
||||
private async ValueTask OnQueryResultAsync(ConsoleQueryProxy query, CancellationToken cancellationToken)
|
||||
private async ValueTask OnQueryResultAsync(Proxy<ConsoleQuery> proxy, CancellationToken cancellationToken)
|
||||
{
|
||||
_model.ConsoleQuery.HadErrors = query.HadErrors;
|
||||
_model.ConsoleQuery.Data = query.Data;
|
||||
_model.ConsoleQuery.Errors = query.Errors;
|
||||
_model.Response.HadErrors = proxy.Message.HadErrors;
|
||||
_model.Response.Data = proxy.Message?.Data;
|
||||
_model.Response.Errors = proxy.Message?.Errors;
|
||||
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private class IndexViewModel
|
||||
{
|
||||
public readonly ConsoleQueryProxy ConsoleQuery = new();
|
||||
public readonly ConsoleQueryRequest Request = new();
|
||||
public readonly ConsoleQuery Response = new();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue