diff --git a/src/dashboards/blazor/ElsaDashboard.Application.Server/Program.cs b/src/dashboards/blazor/ElsaDashboard.Application.Server/Program.cs
index dbc88da5a..97975b8c0 100644
--- a/src/dashboards/blazor/ElsaDashboard.Application.Server/Program.cs
+++ b/src/dashboards/blazor/ElsaDashboard.Application.Server/Program.cs
@@ -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)
diff --git a/src/dashboards/blazor/ElsaDashboard.Application/Models/WorkflowModelChangedEventArgs.cs b/src/dashboards/blazor/ElsaDashboard.Application/Models/WorkflowModelChangedEventArgs.cs
new file mode 100644
index 000000000..38ff9d47f
--- /dev/null
+++ b/src/dashboards/blazor/ElsaDashboard.Application/Models/WorkflowModelChangedEventArgs.cs
@@ -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;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/dashboards/blazor/ElsaDashboard.Application/Pages/Designer.razor b/src/dashboards/blazor/ElsaDashboard.Application/Pages/Designer.razor
index 10e967850..24a665706 100644
--- a/src/dashboards/blazor/ElsaDashboard.Application/Pages/Designer.razor
+++ b/src/dashboards/blazor/ElsaDashboard.Application/Pages/Designer.razor
@@ -14,4 +14,4 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/src/dashboards/blazor/ElsaDashboard.Application/Pages/Designer.razor.cs b/src/dashboards/blazor/ElsaDashboard.Application/Pages/Designer.razor.cs
index e51a26993..fbfa9cd88 100644
--- a/src/dashboards/blazor/ElsaDashboard.Application/Pages/Designer.razor.cs
+++ b/src/dashboards/blazor/ElsaDashboard.Application/Pages/Designer.razor.cs
@@ -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 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);
+ }
}
}
\ No newline at end of file
diff --git a/src/dashboards/blazor/ElsaDashboard.Application/Shared/WorkflowDesigner.razor.cs b/src/dashboards/blazor/ElsaDashboard.Application/Shared/WorkflowDesigner.razor.cs
index a58c9b29a..7bdd3e7f5 100644
--- a/src/dashboards/blazor/ElsaDashboard.Application/Shared/WorkflowDesigner.razor.cs
+++ b/src/dashboards/blazor/ElsaDashboard.Application/Shared/WorkflowDesigner.razor.cs
@@ -18,32 +18,22 @@ namespace ElsaDashboard.Application.Shared
{
partial class WorkflowDesigner : IAsyncDisposable
{
- private static Action _connectionCreatedAction = default!;
+ private static Func _connectionCreatedAction = default!;
[Parameter] public WorkflowModel Model { private get; set; } = WorkflowModel.Blank();
+ [Parameter] public EventCallback 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 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("Timer Properties");
}
- private void OnConnectionCreated(ConnectionModel connection)
+ private async Task OnConnectionCreatedAsync(ConnectionModel connection)
{
- Model = Model.AddConnection(connection);
- ConnectionsHasChanged();
+ await UpdateModelAsync(Model.AddConnection(connection));
}
}
}
\ No newline at end of file
diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/IWorkflowDefinitionService.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/IWorkflowDefinitionService.cs
index 36752a026..d81a9e3ca 100644
--- a/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/IWorkflowDefinitionService.cs
+++ b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/IWorkflowDefinitionService.cs
@@ -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;
diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Surrogates/ActivityPropertyDescriptorSurrogate.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Surrogates/ActivityPropertyDescriptorSurrogate.cs
index 69caf0029..7a1fad0d5 100644
--- a/src/dashboards/blazor/ElsaDashboard.Shared/Surrogates/ActivityPropertyDescriptorSurrogate.cs
+++ b/src/dashboards/blazor/ElsaDashboard.Shared/Surrogates/ActivityPropertyDescriptorSurrogate.cs
@@ -17,6 +17,10 @@ namespace ElsaDashboard.Shared.Surrogates
SerializerSettings = new JsonSerializerSettings().ConfigureForNodaTime(DateTimeZoneProviders.Tzdb);
}
+ public ActivityPropertyDescriptorSurrogate()
+ {
+ }
+
public ActivityPropertyDescriptorSurrogate(ActivityPropertyDescriptor value)
{
Name = value.Name;