Fix surrogate serialization and UI updates
This commit is contained in:
parent
af73545b90
commit
f3c7fe6bbd
|
|
@ -6,7 +6,7 @@ namespace ElsaDashboard.Application.Server
|
|||
{
|
||||
public class Program
|
||||
{
|
||||
public static BlazorRuntimeModel RuntimeModel => BlazorRuntimeModel.Browser;
|
||||
public static BlazorRuntimeModel RuntimeModel => BlazorRuntimeModel.Server;
|
||||
public static RenderMode RenderMode => RuntimeModel == BlazorRuntimeModel.Server ? RenderMode.ServerPrerendered : RenderMode.WebAssemblyPrerendered;
|
||||
|
||||
public static void Main(string[] args)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
using ElsaDashboard.Application.Models;
|
||||
|
||||
namespace ElsaDashboard.Application.Shared
|
||||
{
|
||||
public class WorkflowModelChangedEventArgs : EventArgs
|
||||
{
|
||||
public WorkflowModel WorkflowModel { get; }
|
||||
|
||||
public WorkflowModelChangedEventArgs(WorkflowModel workflowModel)
|
||||
{
|
||||
WorkflowModel = workflowModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,4 +14,4 @@
|
|||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<WorkflowDesigner Model="WorkflowModel" />
|
||||
<WorkflowDesigner Model="WorkflowModel" WorkflowChanged="@OnWorkflowChanged" />
|
||||
|
|
@ -4,6 +4,8 @@ using System.Linq;
|
|||
using System.Threading.Tasks;
|
||||
using Elsa.Client.Models;
|
||||
using ElsaDashboard.Application.Models;
|
||||
using ElsaDashboard.Application.Services;
|
||||
using ElsaDashboard.Application.Shared;
|
||||
using ElsaDashboard.Shared.Rpc;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
|
|
@ -16,6 +18,7 @@ namespace ElsaDashboard.Application.Pages
|
|||
[Inject] private IActivityService ActivityService { get; set; } = default!;
|
||||
private IDictionary<string, ActivityDescriptor> ActivityDescriptors { get; set; } = default!;
|
||||
private WorkflowModel WorkflowModel { get; set; } = WorkflowModel.Blank();
|
||||
private BackgroundWorker BackgroundWorker { get; } = new();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
|
|
@ -30,6 +33,8 @@ namespace ElsaDashboard.Application.Pages
|
|||
{
|
||||
WorkflowModel = WorkflowModel.Blank();
|
||||
}
|
||||
|
||||
InvokeAsync(() => BackgroundWorker.StartAsync());
|
||||
}
|
||||
|
||||
private WorkflowModel CreateWorkflowModel(WorkflowDefinition workflowDefinition)
|
||||
|
|
@ -52,5 +57,16 @@ namespace ElsaDashboard.Application.Pages
|
|||
var descriptor = ActivityDescriptors[activityDefinition.Type];
|
||||
return new ActivityModel(activityDefinition.ActivityId, activityDefinition.Type, descriptor.Outcomes);
|
||||
}
|
||||
|
||||
private async ValueTask SaveWorkflowAsync()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private async Task OnWorkflowChanged(WorkflowModelChangedEventArgs e)
|
||||
{
|
||||
WorkflowModel = e.WorkflowModel;
|
||||
await BackgroundWorker.ScheduleTask(SaveWorkflowAsync);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -18,32 +18,22 @@ namespace ElsaDashboard.Application.Shared
|
|||
{
|
||||
partial class WorkflowDesigner : IAsyncDisposable
|
||||
{
|
||||
private static Action<ConnectionModel> _connectionCreatedAction = default!;
|
||||
private static Func<ConnectionModel, Task> _connectionCreatedAction = default!;
|
||||
|
||||
[Parameter] public WorkflowModel Model { private get; set; } = WorkflowModel.Blank();
|
||||
[Parameter] public EventCallback<WorkflowModelChangedEventArgs> WorkflowChanged { get; set; }
|
||||
[Inject] private IJSRuntime JS { get; set; } = default!;
|
||||
[Inject] private IFlyoutPanelService FlyoutPanelService { get; set; } = default!;
|
||||
private IJSObjectReference _designerModule = default!;
|
||||
private bool _connectionsChanged = true;
|
||||
private EventCallbackFactory EventCallbackFactory { get; } = new();
|
||||
private BackgroundWorker BackgroundWorker { get; } = new();
|
||||
|
||||
[JSInvokableAttribute("InvokeConnectionCreated")]
|
||||
public static void InvokeConnectionCreated(ConnectionModel connection) => _connectionCreatedAction(connection);
|
||||
public static Task InvokeConnectionCreated(ConnectionModel connection) => _connectionCreatedAction(connection);
|
||||
|
||||
|
||||
int _currentCount = 0;
|
||||
|
||||
void IncrementCount()
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
_currentCount++;
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_connectionCreatedAction = OnConnectionCreated;
|
||||
|
||||
InvokeAsync(() => BackgroundWorker.StartAsync());
|
||||
_connectionCreatedAction = OnConnectionCreatedAsync;
|
||||
}
|
||||
|
||||
protected override void OnParametersSet()
|
||||
|
|
@ -69,12 +59,8 @@ namespace ElsaDashboard.Application.Shared
|
|||
{
|
||||
Model = model;
|
||||
ConnectionsHasChanged();
|
||||
await BackgroundWorker.ScheduleTask(SaveWorkflowAsync);
|
||||
}
|
||||
|
||||
private async ValueTask SaveWorkflowAsync()
|
||||
{
|
||||
|
||||
await WorkflowChanged.InvokeAsync(new WorkflowModelChangedEventArgs(Model));
|
||||
}
|
||||
|
||||
private IEnumerable<ActivityModel> GetRootActivities() => Model.GetChildActivities(null);
|
||||
|
|
@ -224,11 +210,9 @@ namespace ElsaDashboard.Application.Shared
|
|||
model = model.AddConnection(connection);
|
||||
}
|
||||
}
|
||||
|
||||
Model = model;
|
||||
|
||||
await UpdateModelAsync(model);
|
||||
await FlyoutPanelService.HideAsync();
|
||||
ConnectionsHasChanged();
|
||||
await BackgroundWorker.ScheduleTask(() => Console.WriteLine("TEST"));
|
||||
}
|
||||
|
||||
private void ConnectionsHasChanged()
|
||||
|
|
@ -255,10 +239,9 @@ namespace ElsaDashboard.Application.Shared
|
|||
await FlyoutPanelService.ShowAsync<ActivityEditor>("Timer Properties");
|
||||
}
|
||||
|
||||
private void OnConnectionCreated(ConnectionModel connection)
|
||||
private async Task OnConnectionCreatedAsync(ConnectionModel connection)
|
||||
{
|
||||
Model = Model.AddConnection(connection);
|
||||
ConnectionsHasChanged();
|
||||
await UpdateModelAsync(Model.AddConnection(connection));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -16,6 +16,10 @@ namespace ElsaDashboard.Shared.Rpc
|
|||
[ProtoContract]
|
||||
public record ListWorkflowDefinitionsRequest
|
||||
{
|
||||
public ListWorkflowDefinitionsRequest()
|
||||
{
|
||||
}
|
||||
|
||||
public ListWorkflowDefinitionsRequest(int? page = default, int? pageSize = default, VersionOptions? versionOptions = default)
|
||||
{
|
||||
Page = page;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,10 @@ namespace ElsaDashboard.Shared.Surrogates
|
|||
SerializerSettings = new JsonSerializerSettings().ConfigureForNodaTime(DateTimeZoneProviders.Tzdb);
|
||||
}
|
||||
|
||||
public ActivityPropertyDescriptorSurrogate()
|
||||
{
|
||||
}
|
||||
|
||||
public ActivityPropertyDescriptorSurrogate(ActivityPropertyDescriptor value)
|
||||
{
|
||||
Name = value.Name;
|
||||
|
|
|
|||
Loading…
Reference in a new issue