diff --git a/src/clients/Elsa.Client/Services/IWorkflowRegistryApi.cs b/src/clients/Elsa.Client/Services/IWorkflowRegistryApi.cs index 3d96db389..18e6782ca 100644 --- a/src/clients/Elsa.Client/Services/IWorkflowRegistryApi.cs +++ b/src/clients/Elsa.Client/Services/IWorkflowRegistryApi.cs @@ -8,7 +8,7 @@ namespace Elsa.Client.Services public interface IWorkflowRegistryApi { [Get("/v1/workflow-registry/{id}/{versionOptions}")] - Task GetByIdAsync(string id, VersionOptions versionOptions, CancellationToken cancellationToken = default); + Task GetByIdAsync(string id, VersionOptions versionOptions, CancellationToken cancellationToken = default); [Get("/v1/workflow-registry")] Task> ListAsync(int? page = default, int? pageSize = default, VersionOptions? versionOptions = default, CancellationToken cancellationToken = default); diff --git a/src/dashboards/blazor/ElsaDashboard.Application.Server/Program.cs b/src/dashboards/blazor/ElsaDashboard.Application.Server/Program.cs index 97975b8c0..dbc88da5a 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.Server; + public static BlazorRuntimeModel RuntimeModel => BlazorRuntimeModel.Browser; 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.Server/Startup.cs b/src/dashboards/blazor/ElsaDashboard.Application.Server/Startup.cs index afcf670ac..a8282cbb1 100644 --- a/src/dashboards/blazor/ElsaDashboard.Application.Server/Startup.cs +++ b/src/dashboards/blazor/ElsaDashboard.Application.Server/Startup.cs @@ -23,7 +23,7 @@ namespace ElsaDashboard.Application.Server { services.AddRazorPages(); services.AddElsaDashboardUI(); - services.AddElsaDashboardBackend(options => options.ServerUrl = new Uri("https://localhost:11000")); + services.AddElsaDashboardBackend(options => options.ServerUrl = Configuration.GetValue("Elsa:HostUrl")); if (Program.RuntimeModel == BlazorRuntimeModel.Server) services.AddServerSideBlazor(options => diff --git a/src/dashboards/blazor/ElsaDashboard.Application.Server/appsettings.json b/src/dashboards/blazor/ElsaDashboard.Application.Server/appsettings.json index 4442d5117..cf8d27193 100644 --- a/src/dashboards/blazor/ElsaDashboard.Application.Server/appsettings.json +++ b/src/dashboards/blazor/ElsaDashboard.Application.Server/appsettings.json @@ -6,5 +6,8 @@ "Microsoft.Hosting.Lifetime": "Information" } }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "Elsa": { + "HostUrl": "https://localhost:11000" + } } diff --git a/src/dashboards/blazor/ElsaDashboard.Application.WebAssembly/Program.cs b/src/dashboards/blazor/ElsaDashboard.Application.WebAssembly/Program.cs index 4a85d44a8..592534779 100644 --- a/src/dashboards/blazor/ElsaDashboard.Application.WebAssembly/Program.cs +++ b/src/dashboards/blazor/ElsaDashboard.Application.WebAssembly/Program.cs @@ -14,6 +14,7 @@ namespace ElsaDashboard.Application.WebAssembly var builder = WebAssemblyHostBuilder.CreateDefault(args); var services = builder.Services; + //builder.RootComponents.Add("#app"); services.AddScoped(sp => new HttpClient {BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)}); services.AddElsaDashboardUI(); services.AddElsaDashboardBackend(); diff --git a/src/dashboards/blazor/ElsaDashboard.Application/ElsaDashboard.Application.csproj b/src/dashboards/blazor/ElsaDashboard.Application/ElsaDashboard.Application.csproj index ac96cca8d..f91b33e9e 100644 --- a/src/dashboards/blazor/ElsaDashboard.Application/ElsaDashboard.Application.csproj +++ b/src/dashboards/blazor/ElsaDashboard.Application/ElsaDashboard.Application.csproj @@ -2,7 +2,19 @@ net5.0 + 1.0.0 latest + Elsa Contributors + + Elsa is a set of workflow libraries and tools that enable lean and mean workflowing capabilities in any .NET Core application. + This package provides a dashboard application using Blazor. + + 2020 + https://github.com/elsa-workflows/elsa-core + https://github.com/elsa-workflows/elsa-core + GitHub + elsa, workflows, dashboard, asp.net core, blazor + icon.png enable @@ -25,4 +37,11 @@ + + + True + + + + diff --git a/src/dashboards/blazor/ElsaDashboard.Application/Pages/WorkflowDefinitions/Designer.razor.cs b/src/dashboards/blazor/ElsaDashboard.Application/Pages/WorkflowDefinitions/Designer.razor.cs index 9c2d7b115..a5dcfde5a 100644 --- a/src/dashboards/blazor/ElsaDashboard.Application/Pages/WorkflowDefinitions/Designer.razor.cs +++ b/src/dashboards/blazor/ElsaDashboard.Application/Pages/WorkflowDefinitions/Designer.razor.cs @@ -31,7 +31,7 @@ namespace ElsaDashboard.Application.Pages.WorkflowDefinitions { if (WorkflowDefinitionId != null) { - WorkflowDefinition = await WorkflowDefinitionService.GetById(WorkflowDefinitionId, VersionOptions.Latest); + WorkflowDefinition = await WorkflowDefinitionService.GetByIdAsync(WorkflowDefinitionId, VersionOptions.Latest); WorkflowModel = CreateWorkflowModel(WorkflowDefinition); } else diff --git a/src/dashboards/blazor/ElsaDashboard.Application/Pages/WorkflowRegistry/Viewer.razor.cs b/src/dashboards/blazor/ElsaDashboard.Application/Pages/WorkflowRegistry/Viewer.razor.cs index 1497acc53..c360adea3 100644 --- a/src/dashboards/blazor/ElsaDashboard.Application/Pages/WorkflowRegistry/Viewer.razor.cs +++ b/src/dashboards/blazor/ElsaDashboard.Application/Pages/WorkflowRegistry/Viewer.razor.cs @@ -25,7 +25,7 @@ namespace ElsaDashboard.Application.Pages.WorkflowRegistry protected override async Task OnParametersSetAsync() { - WorkflowBlueprint = await WorkflowRegistryService.GetById(WorkflowDefinitionId, VersionOptions.Latest); + WorkflowBlueprint = (await WorkflowRegistryService.GetById(WorkflowDefinitionId, VersionOptions.Latest))!; WorkflowModel = CreateWorkflowModel(WorkflowBlueprint); } diff --git a/src/dashboards/blazor/ElsaDashboard.Application/icon.png b/src/dashboards/blazor/ElsaDashboard.Application/icon.png new file mode 100644 index 000000000..28dbaafbf Binary files /dev/null and b/src/dashboards/blazor/ElsaDashboard.Application/icon.png differ diff --git a/src/dashboards/blazor/ElsaDashboard.Backend/ElsaDashboard.Backend.csproj b/src/dashboards/blazor/ElsaDashboard.Backend/ElsaDashboard.Backend.csproj index 8d9d0baeb..db13437ad 100644 --- a/src/dashboards/blazor/ElsaDashboard.Backend/ElsaDashboard.Backend.csproj +++ b/src/dashboards/blazor/ElsaDashboard.Backend/ElsaDashboard.Backend.csproj @@ -2,20 +2,40 @@ net5.0 + 1.0.0 + latest + Elsa Contributors + + Elsa is a set of workflow libraries and tools that enable lean and mean workflowing capabilities in any .NET Core application. + This package provides dashboard backend services exposed as gRPC endpoints. + + 2020 + https://github.com/elsa-workflows/elsa-core + https://github.com/elsa-workflows/elsa-core + GitHub + elsa, workflows, dashboard, asp.net core, grpc + icon.png enable - + - - - - - - + + + + + + + + + + + True + + diff --git a/src/dashboards/blazor/ElsaDashboard.Backend/Extensions/ServiceCollectionExtensions.cs b/src/dashboards/blazor/ElsaDashboard.Backend/Extensions/ServiceCollectionExtensions.cs index 1eb1ca0b0..2c19b4783 100644 --- a/src/dashboards/blazor/ElsaDashboard.Backend/Extensions/ServiceCollectionExtensions.cs +++ b/src/dashboards/blazor/ElsaDashboard.Backend/Extensions/ServiceCollectionExtensions.cs @@ -2,7 +2,6 @@ using System.IO.Compression; using Elsa.Client.Extensions; using Elsa.Client.Options; -using Elsa.Client.Services; using ElsaDashboard.Backend.Rpc; using ElsaDashboard.Shared.Rpc; using ElsaDashboard.Shared.Surrogates; diff --git a/src/dashboards/blazor/ElsaDashboard.Backend/Rpc/WorkflowDefinitionService.cs b/src/dashboards/blazor/ElsaDashboard.Backend/Rpc/WorkflowDefinitionService.cs index efa74202b..255a48584 100644 --- a/src/dashboards/blazor/ElsaDashboard.Backend/Rpc/WorkflowDefinitionService.cs +++ b/src/dashboards/blazor/ElsaDashboard.Backend/Rpc/WorkflowDefinitionService.cs @@ -15,13 +15,13 @@ namespace ElsaDashboard.Backend.Rpc _elsaClient = elsaClient; } - public async Task> ListAsync(int? page, int? pageSize, VersionOptions? versionOptions, CallContext context) => - await _elsaClient.WorkflowDefinitions.ListAsync(page, pageSize, versionOptions, context.CancellationToken); + public async Task> ListAsync(ListWorkflowDefinitionsRequest request, CallContext context = default) => + await _elsaClient.WorkflowDefinitions.ListAsync(request.Page, request.PageSize, request.VersionOptions, context.CancellationToken); - public async Task GetById(string workflowDefinitionId, VersionOptions versionOptions, CallContext context = default) => - await _elsaClient.WorkflowDefinitions.GetByIdAsync(workflowDefinitionId, versionOptions, context.CancellationToken); + public async Task GetByIdAsync(GetWorkflowDefinitionByIdRequest request, CallContext context = default) => + await _elsaClient.WorkflowDefinitions.GetByIdAsync(request.WorkflowDefinitionId, request.VersionOptions ?? VersionOptions.Published, context.CancellationToken); - public Task GetByVersionIdAsync(string workflowDefinitionVersionId, CallContext context) => _elsaClient.WorkflowDefinitions.GetByVersionIdAsync(workflowDefinitionVersionId, context.CancellationToken); + public Task GetByVersionIdAsync(GetWorkflowDefinitionByVersionIdRequest request, CallContext context) => _elsaClient.WorkflowDefinitions.GetByVersionIdAsync(request.WorkflowDefinitionVersionId, context.CancellationToken); public async Task SaveAsync(SaveWorkflowDefinitionRequest request, CallContext context) => await _elsaClient.WorkflowDefinitions.SaveAsync(request, context.CancellationToken); } } \ No newline at end of file diff --git a/src/dashboards/blazor/ElsaDashboard.Backend/Rpc/WorkflowInstanceService.cs b/src/dashboards/blazor/ElsaDashboard.Backend/Rpc/WorkflowInstanceService.cs index c2d744d54..b859b2ebf 100644 --- a/src/dashboards/blazor/ElsaDashboard.Backend/Rpc/WorkflowInstanceService.cs +++ b/src/dashboards/blazor/ElsaDashboard.Backend/Rpc/WorkflowInstanceService.cs @@ -10,8 +10,8 @@ namespace ElsaDashboard.Backend.Rpc { private readonly IElsaClient _elsaClient; public WorkflowInstanceService(IElsaClient elsaClient) => _elsaClient = elsaClient; - public Task> ListAsync(int page = 0, int pageSize = 50, CallContext context = default) => _elsaClient.WorkflowInstances.ListAsync(page, pageSize, context.CancellationToken); - public Task GetByIdAsync(string id, CallContext context = default) => _elsaClient.WorkflowInstances.GetByIdAsync(id, context.CancellationToken); - public Task DeleteAsync(string id, CallContext context = default) => _elsaClient.WorkflowInstances.DeleteAsync(id, context.CancellationToken); + public Task> ListAsync(ListWorkflowInstancesRequest request, CallContext context = default) => _elsaClient.WorkflowInstances.ListAsync(request.Page, request.PageSize, context.CancellationToken); + public Task GetByIdAsync(GetWorkflowInstanceByIdRequest request, CallContext context = default) => _elsaClient.WorkflowInstances.GetByIdAsync(request.WorkflowInstanceId, context.CancellationToken); + public Task DeleteAsync(DeleteWorkflowInstanceRequest request, CallContext context = default) => _elsaClient.WorkflowInstances.DeleteAsync(request.WorkflowInstanceId, context.CancellationToken); } } \ No newline at end of file diff --git a/src/dashboards/blazor/ElsaDashboard.Backend/Rpc/WorkflowRegistryService.cs b/src/dashboards/blazor/ElsaDashboard.Backend/Rpc/WorkflowRegistryService.cs index a22cc94f2..860522cdb 100644 --- a/src/dashboards/blazor/ElsaDashboard.Backend/Rpc/WorkflowRegistryService.cs +++ b/src/dashboards/blazor/ElsaDashboard.Backend/Rpc/WorkflowRegistryService.cs @@ -11,9 +11,9 @@ namespace ElsaDashboard.Backend.Rpc private readonly IElsaClient _elsaClient; public WorkflowRegistryService(IElsaClient elsaClient) => _elsaClient = elsaClient; - public Task> ListAsync(int? page = default, int? pageSize = default, VersionOptions? versionOptions = default, CallContext context = default) => - _elsaClient.WorkflowRegistry.ListAsync(page, pageSize, versionOptions, context.CancellationToken); + public Task> ListAsync(ListWorkflowBlueprintsRequest request, CallContext context = default) => + _elsaClient.WorkflowRegistry.ListAsync(request.Page, request.PageSize, request.VersionOptions, context.CancellationToken); - public Task GetById(string id, VersionOptions versionOptions, CallContext context = default) => _elsaClient.WorkflowRegistry.GetByIdAsync(id, versionOptions, context.CancellationToken); + public Task GetById(GetWorkflowBlueprintByIdRequest request, CallContext context = default) => _elsaClient.WorkflowRegistry.GetByIdAsync(request.Id, request.VersionOptions, context.CancellationToken); } } \ No newline at end of file diff --git a/src/dashboards/blazor/ElsaDashboard.Backend/icon.png b/src/dashboards/blazor/ElsaDashboard.Backend/icon.png new file mode 100644 index 000000000..28dbaafbf Binary files /dev/null and b/src/dashboards/blazor/ElsaDashboard.Backend/icon.png differ diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/ElsaDashboard.Shared.csproj b/src/dashboards/blazor/ElsaDashboard.Shared/ElsaDashboard.Shared.csproj index c0bc2c39e..f83f1f21f 100644 --- a/src/dashboards/blazor/ElsaDashboard.Shared/ElsaDashboard.Shared.csproj +++ b/src/dashboards/blazor/ElsaDashboard.Shared/ElsaDashboard.Shared.csproj @@ -2,19 +2,39 @@ net5.0 + 1.0.0 + latest + Elsa Contributors + + Elsa is a set of workflow libraries and tools that enable lean and mean workflowing capabilities in any .NET Core application. + This package provides gRPC endpoint abstractions shared by the Elsa.Dashboard.Backend and Elsa.Dashboard.WebAssembly packages. + + 2020 + https://github.com/elsa-workflows/elsa-core + https://github.com/elsa-workflows/elsa-core + GitHub + elsa, workflows, dashboard, asp.net core, grpc + icon.png enable - + - - - - + + + + - + - + + + + + + True + + diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/ElsaDashboard.Shared.csproj.DotSettings b/src/dashboards/blazor/ElsaDashboard.Shared/ElsaDashboard.Shared.csproj.DotSettings new file mode 100644 index 000000000..dad40ff58 --- /dev/null +++ b/src/dashboards/blazor/ElsaDashboard.Shared/ElsaDashboard.Shared.csproj.DotSettings @@ -0,0 +1,13 @@ + + True + True + True + True + True + True + True + True + True + True + True + True \ No newline at end of file diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/IActivityService.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/Activity/Services/IActivityService.cs similarity index 84% rename from src/dashboards/blazor/ElsaDashboard.Shared/Rpc/IActivityService.cs rename to src/dashboards/blazor/ElsaDashboard.Shared/Rpc/Activity/Services/IActivityService.cs index 8745161cf..aa3530413 100644 --- a/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/IActivityService.cs +++ b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/Activity/Services/IActivityService.cs @@ -4,11 +4,13 @@ using Elsa.Client.Models; using ProtoBuf.Grpc; using ProtoBuf.Grpc.Configuration; +// ReSharper disable once CheckNamespace namespace ElsaDashboard.Shared.Rpc { [Service] public interface IActivityService { + [Operation] Task> GetActivitiesAsync(CallContext context = default); } } \ 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 deleted file mode 100644 index 6f5ded84c..000000000 --- a/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/IWorkflowDefinitionService.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Threading.Tasks; -using Elsa.Client.Models; -using ProtoBuf.Grpc; -using ProtoBuf.Grpc.Configuration; - -namespace ElsaDashboard.Shared.Rpc -{ - [Service] - public interface IWorkflowDefinitionService - { - Task> ListAsync(int? page = default, int? pageSize = default, VersionOptions? versionOptions = default, CallContext context = default); - Task GetById(string workflowDefinitionId, VersionOptions versionOptions, CallContext context = default); - Task GetByVersionIdAsync(string workflowDefinitionVersionId, CallContext context = default); - Task SaveAsync(SaveWorkflowDefinitionRequest request, CallContext context = default); - } -} \ No newline at end of file diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/IWorkflowInstanceService.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/IWorkflowInstanceService.cs deleted file mode 100644 index 3fae085f6..000000000 --- a/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/IWorkflowInstanceService.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Threading.Tasks; -using Elsa.Client.Models; -using ProtoBuf.Grpc; -using ProtoBuf.Grpc.Configuration; - -namespace ElsaDashboard.Shared.Rpc -{ - [Service] - public interface IWorkflowInstanceService - { - Task> ListAsync(int page = 0, int pageSize = 50, CallContext context = default); - Task GetByIdAsync(string id, CallContext context = default); - Task DeleteAsync(string id, CallContext context = default); - } -} \ No newline at end of file diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/IWorkflowRegistryService.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/IWorkflowRegistryService.cs deleted file mode 100644 index dd547351d..000000000 --- a/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/IWorkflowRegistryService.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Threading.Tasks; -using Elsa.Client.Models; -using ProtoBuf.Grpc; -using ProtoBuf.Grpc.Configuration; - -namespace ElsaDashboard.Shared.Rpc -{ - [Service] - public interface IWorkflowRegistryService - { - Task> ListAsync(int? page = default, int? pageSize = default, VersionOptions? versionOptions = default, CallContext context = default); - Task GetById(string id, VersionOptions versionOptions, CallContext context = default); - } -} \ No newline at end of file diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowDefinition/Extensions/WorkflowDefinitionServiceExtensions.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowDefinition/Extensions/WorkflowDefinitionServiceExtensions.cs new file mode 100644 index 000000000..8ea5dd703 --- /dev/null +++ b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowDefinition/Extensions/WorkflowDefinitionServiceExtensions.cs @@ -0,0 +1,17 @@ +using System.Threading.Tasks; +using Elsa.Client.Models; + +namespace ElsaDashboard.Shared.Rpc +{ + public static class WorkflowDefinitionServiceExtensions + { + public static async Task> ListAsync(this IWorkflowDefinitionService service, int? page = default, int? pageSize = default, VersionOptions? versionOptions = default) => + await service.ListAsync(new ListWorkflowDefinitionsRequest(page, pageSize, versionOptions)); + + public static async Task GetByIdAsync(this IWorkflowDefinitionService service, string workflowDefinitionId, VersionOptions? versionOptions = default) => + await service.GetByIdAsync(new GetWorkflowDefinitionByIdRequest(workflowDefinitionId, versionOptions)); + + public static async Task GetByVersionIdAsync(this IWorkflowDefinitionService service, string workflowDefinitionVersionId) => + await service.GetByVersionIdAsync(new GetWorkflowDefinitionByVersionIdRequest(workflowDefinitionVersionId)); + } +} \ No newline at end of file diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowDefinition/Models/GetWorkflowDefinitionByIdRequest.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowDefinition/Models/GetWorkflowDefinitionByIdRequest.cs new file mode 100644 index 000000000..514759ff9 --- /dev/null +++ b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowDefinition/Models/GetWorkflowDefinitionByIdRequest.cs @@ -0,0 +1,22 @@ +using Elsa.Client.Models; +using ProtoBuf; + +namespace ElsaDashboard.Shared.Rpc +{ + [ProtoContract] + public class GetWorkflowDefinitionByIdRequest + { + public GetWorkflowDefinitionByIdRequest() + { + } + + public GetWorkflowDefinitionByIdRequest(string workflowDefinitionId, VersionOptions? versionOptions) + { + WorkflowDefinitionId = workflowDefinitionId; + VersionOptions = versionOptions; + } + + [ProtoMember(1)] public string WorkflowDefinitionId { get; set; } + [ProtoMember(2)] public VersionOptions? VersionOptions { get; set; } + } +} \ No newline at end of file diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowDefinition/Models/GetWorkflowDefinitionByVersionIdRequest.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowDefinition/Models/GetWorkflowDefinitionByVersionIdRequest.cs new file mode 100644 index 000000000..53cd2073a --- /dev/null +++ b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowDefinition/Models/GetWorkflowDefinitionByVersionIdRequest.cs @@ -0,0 +1,19 @@ +using ProtoBuf; + +namespace ElsaDashboard.Shared.Rpc +{ + [ProtoContract] + public class GetWorkflowDefinitionByVersionIdRequest + { + public GetWorkflowDefinitionByVersionIdRequest() + { + } + + public GetWorkflowDefinitionByVersionIdRequest(string workflowDefinitionVersionId) + { + WorkflowDefinitionVersionId = workflowDefinitionVersionId; + } + + [ProtoMember(1)] public string WorkflowDefinitionVersionId { get; set; } + } +} \ No newline at end of file diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowDefinition/Models/ListWorkflowDefinitionsRequest.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowDefinition/Models/ListWorkflowDefinitionsRequest.cs new file mode 100644 index 000000000..620662114 --- /dev/null +++ b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowDefinition/Models/ListWorkflowDefinitionsRequest.cs @@ -0,0 +1,24 @@ +using Elsa.Client.Models; +using ProtoBuf; + +namespace ElsaDashboard.Shared.Rpc +{ + [ProtoContract] + public class ListWorkflowDefinitionsRequest + { + public ListWorkflowDefinitionsRequest() + { + } + + public ListWorkflowDefinitionsRequest(int? page, int? pageSize, VersionOptions? versionOptions) + { + Page = page; + PageSize = pageSize; + VersionOptions = versionOptions; + } + + [ProtoMember(1)] public int? Page { get; set; } + [ProtoMember(2)] public int? PageSize { get; set; } + [ProtoMember(3)] public VersionOptions? VersionOptions { get; set; } + } +} \ No newline at end of file diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowDefinition/Services/IWorkflowDefinitionService.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowDefinition/Services/IWorkflowDefinitionService.cs new file mode 100644 index 000000000..a5ed6e623 --- /dev/null +++ b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowDefinition/Services/IWorkflowDefinitionService.cs @@ -0,0 +1,23 @@ +using System.Threading.Tasks; +using Elsa.Client.Models; +using ProtoBuf.Grpc; +using ProtoBuf.Grpc.Configuration; + +namespace ElsaDashboard.Shared.Rpc +{ + [Service] + public interface IWorkflowDefinitionService + { + [Operation] + Task> ListAsync(ListWorkflowDefinitionsRequest request, CallContext context = default); + + [Operation] + Task GetByIdAsync(GetWorkflowDefinitionByIdRequest request, CallContext context = default); + + [Operation] + Task GetByVersionIdAsync(GetWorkflowDefinitionByVersionIdRequest request, CallContext context = default); + + [Operation] + Task SaveAsync(SaveWorkflowDefinitionRequest request, CallContext context = default); + } +} \ No newline at end of file diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowInstance/Extensions/WorkflowInstanceServiceExtensions.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowInstance/Extensions/WorkflowInstanceServiceExtensions.cs new file mode 100644 index 000000000..9b1a7719f --- /dev/null +++ b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowInstance/Extensions/WorkflowInstanceServiceExtensions.cs @@ -0,0 +1,13 @@ +using System.Threading.Tasks; +using Elsa.Client.Models; + +// ReSharper disable once CheckNamespace +namespace ElsaDashboard.Shared.Rpc +{ + public static class WorkflowInstanceServiceExtensions + { + public static Task> ListAsync(this IWorkflowInstanceService service, int page = 0, int pageSize = 50) => service.ListAsync(new ListWorkflowInstancesRequest(page, pageSize)); + public static Task GetByIdAsync(this IWorkflowInstanceService service, string workflowInstanceId) => service.GetByIdAsync(new GetWorkflowInstanceByIdRequest(workflowInstanceId)); + public static Task DeleteAsync(this IWorkflowInstanceService service, string workflowInstanceId) => service.DeleteAsync(new DeleteWorkflowInstanceRequest(workflowInstanceId)); + } +} \ No newline at end of file diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowInstance/Models/DeleteWorkflowInstanceRequest.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowInstance/Models/DeleteWorkflowInstanceRequest.cs new file mode 100644 index 000000000..c081b2539 --- /dev/null +++ b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowInstance/Models/DeleteWorkflowInstanceRequest.cs @@ -0,0 +1,20 @@ +using ProtoBuf; + +// ReSharper disable once CheckNamespace +namespace ElsaDashboard.Shared.Rpc +{ + [ProtoContract] + public class DeleteWorkflowInstanceRequest + { + public DeleteWorkflowInstanceRequest() + { + } + + public DeleteWorkflowInstanceRequest(string workflowInstanceId) + { + WorkflowInstanceId = workflowInstanceId; + } + + [ProtoMember(1)] public string WorkflowInstanceId { get; set; } + } +} \ No newline at end of file diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowInstance/Models/GetWorkflowInstanceByIdRequest.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowInstance/Models/GetWorkflowInstanceByIdRequest.cs new file mode 100644 index 000000000..da0f34526 --- /dev/null +++ b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowInstance/Models/GetWorkflowInstanceByIdRequest.cs @@ -0,0 +1,20 @@ +using ProtoBuf; + +// ReSharper disable once CheckNamespace +namespace ElsaDashboard.Shared.Rpc +{ + [ProtoContract] + public class GetWorkflowInstanceByIdRequest + { + public GetWorkflowInstanceByIdRequest() + { + } + + public GetWorkflowInstanceByIdRequest(string workflowInstanceId) + { + WorkflowInstanceId = workflowInstanceId; + } + + [ProtoMember(1)] public string WorkflowInstanceId { get; set; } + } +} \ No newline at end of file diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowInstance/Models/ListWorkflowInstancesRequest.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowInstance/Models/ListWorkflowInstancesRequest.cs new file mode 100644 index 000000000..f1d27e0d1 --- /dev/null +++ b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowInstance/Models/ListWorkflowInstancesRequest.cs @@ -0,0 +1,22 @@ +using ProtoBuf; + +// ReSharper disable once CheckNamespace +namespace ElsaDashboard.Shared.Rpc +{ + [ProtoContract] + public class ListWorkflowInstancesRequest + { + public ListWorkflowInstancesRequest() + { + } + + public ListWorkflowInstancesRequest(int page, int pageSize = 50) + { + Page = page; + PageSize = pageSize; + } + + [ProtoMember(1)] public int Page { get; set; } + [ProtoMember(2)] public int PageSize { get; set; } = 50; + } +} \ No newline at end of file diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowInstance/Services/IWorkflowInstanceService.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowInstance/Services/IWorkflowInstanceService.cs new file mode 100644 index 000000000..308ee2c39 --- /dev/null +++ b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowInstance/Services/IWorkflowInstanceService.cs @@ -0,0 +1,21 @@ +using System.Threading.Tasks; +using Elsa.Client.Models; +using ProtoBuf.Grpc; +using ProtoBuf.Grpc.Configuration; + +// ReSharper disable once CheckNamespace +namespace ElsaDashboard.Shared.Rpc +{ + [Service] + public interface IWorkflowInstanceService + { + [Operation] + Task> ListAsync(ListWorkflowInstancesRequest request, CallContext context = default); + + [Operation] + Task GetByIdAsync(GetWorkflowInstanceByIdRequest request, CallContext context = default); + + [Operation] + Task DeleteAsync(DeleteWorkflowInstanceRequest request, CallContext context = default); + } +} \ No newline at end of file diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowRegistry/Extensions/WorkflowRegistryServiceExtensions.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowRegistry/Extensions/WorkflowRegistryServiceExtensions.cs new file mode 100644 index 000000000..671b0fcb4 --- /dev/null +++ b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowRegistry/Extensions/WorkflowRegistryServiceExtensions.cs @@ -0,0 +1,13 @@ +using System.Threading.Tasks; +using Elsa.Client.Models; + +namespace ElsaDashboard.Shared.Rpc +{ + public static class WorkflowRegistryServiceExtensions + { + public static Task> ListAsync(this IWorkflowRegistryService service, int? page = default, int? pageSize = default, VersionOptions? versionOptions = default) => + service.ListAsync(new ListWorkflowBlueprintsRequest(page, pageSize, versionOptions)); + + public static Task GetById(this IWorkflowRegistryService service, string id, VersionOptions versionOptions) => service.GetById(new GetWorkflowBlueprintByIdRequest(id, versionOptions)); + } +} \ No newline at end of file diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowRegistry/Models/GetWorkflowBlueprintByIdRequest.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowRegistry/Models/GetWorkflowBlueprintByIdRequest.cs new file mode 100644 index 000000000..7f2c0d1ba --- /dev/null +++ b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowRegistry/Models/GetWorkflowBlueprintByIdRequest.cs @@ -0,0 +1,22 @@ +using Elsa.Client.Models; +using ProtoBuf; + +namespace ElsaDashboard.Shared.Rpc +{ + [ProtoContract] + public class GetWorkflowBlueprintByIdRequest + { + public GetWorkflowBlueprintByIdRequest() + { + } + + public GetWorkflowBlueprintByIdRequest(string id, VersionOptions versionOptions) + { + Id = id; + VersionOptions = versionOptions; + } + + [ProtoMember(1)] public string Id { get; set; } = default!; + [ProtoMember(2)] public VersionOptions VersionOptions { get; set; } + } +} \ No newline at end of file diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowRegistry/Models/ListWorkflowBlueprintsRequest.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowRegistry/Models/ListWorkflowBlueprintsRequest.cs new file mode 100644 index 000000000..22be68429 --- /dev/null +++ b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowRegistry/Models/ListWorkflowBlueprintsRequest.cs @@ -0,0 +1,24 @@ +using Elsa.Client.Models; +using ProtoBuf; + +namespace ElsaDashboard.Shared.Rpc +{ + [ProtoContract] + public class ListWorkflowBlueprintsRequest + { + public ListWorkflowBlueprintsRequest() + { + } + + public ListWorkflowBlueprintsRequest(int? page, int? pageSize, VersionOptions? versionOptions) + { + Page = page; + PageSize = pageSize; + VersionOptions = versionOptions; + } + + [ProtoMember(1)] public int? Page { get; set; } + [ProtoMember(2)] public int? PageSize { get; set; } + [ProtoMember(3)] public VersionOptions? VersionOptions { get; set; } + } +} \ No newline at end of file diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowRegistry/Services/IWorkflowRegistryService.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowRegistry/Services/IWorkflowRegistryService.cs new file mode 100644 index 000000000..6a8933299 --- /dev/null +++ b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/WorkflowRegistry/Services/IWorkflowRegistryService.cs @@ -0,0 +1,17 @@ +using System.Threading.Tasks; +using Elsa.Client.Models; +using ProtoBuf.Grpc; +using ProtoBuf.Grpc.Configuration; + +namespace ElsaDashboard.Shared.Rpc +{ + [Service] + public interface IWorkflowRegistryService + { + [Operation] + Task> ListAsync(ListWorkflowBlueprintsRequest request, CallContext context = default); + + [Operation] + Task GetById(GetWorkflowBlueprintByIdRequest request, CallContext context = default); + } +} \ No newline at end of file diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Surrogates/RuntimeTypeModelExtensions.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Surrogates/RuntimeTypeModelExtensions.cs index 8187d3751..4192e7df5 100644 --- a/src/dashboards/blazor/ElsaDashboard.Shared/Surrogates/RuntimeTypeModelExtensions.cs +++ b/src/dashboards/blazor/ElsaDashboard.Shared/Surrogates/RuntimeTypeModelExtensions.cs @@ -14,7 +14,9 @@ namespace ElsaDashboard.Shared.Surrogates { [typeof(ActivityPropertyInfo)] = typeof(ActivityPropertyDescriptorSurrogate), [typeof(VersionOptions)] = typeof(VersionOptionsSurrogate), - [typeof(WorkflowInstance)] = typeof(WorkflowInstanceSurrogate) + [typeof(WorkflowInstance)] = typeof(WorkflowInstanceSurrogate), + [typeof(WorkflowDefinition)] = typeof(WorkflowDefinitionSurrogate), + [typeof(WorkflowBlueprint)] = typeof(WorkflowBlueprintSurrogate) }; /// diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Surrogates/WorkflowBlueprintSurrogate.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Surrogates/WorkflowBlueprintSurrogate.cs new file mode 100644 index 000000000..2bf2de8a6 --- /dev/null +++ b/src/dashboards/blazor/ElsaDashboard.Shared/Surrogates/WorkflowBlueprintSurrogate.cs @@ -0,0 +1,35 @@ +using Elsa.Client.Models; +using Newtonsoft.Json; +using NodaTime; +using NodaTime.Serialization.JsonNet; +using ProtoBuf; + +namespace ElsaDashboard.Shared.Surrogates +{ + [ProtoContract(IgnoreListHandling = true)] + public class WorkflowBlueprintSurrogate + { + private static readonly JsonSerializerSettings SerializerSettings; + + static WorkflowBlueprintSurrogate() + { + SerializerSettings = new JsonSerializerSettings + { + TypeNameHandling = TypeNameHandling.Auto + }.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb); + } + + public WorkflowBlueprintSurrogate(WorkflowBlueprint value) + { + Value = Serialize(value); + } + + [ProtoMember(1)] public string Value { get; } + + public static implicit operator WorkflowBlueprint(WorkflowBlueprintSurrogate surrogate) => Deserialize(surrogate.Value)!; + public static implicit operator WorkflowBlueprintSurrogate(WorkflowBlueprint source) => new(source); + + private static WorkflowBlueprint Deserialize(string json) => JsonConvert.DeserializeObject(json, SerializerSettings)!; + private static string Serialize(WorkflowBlueprint value) => JsonConvert.SerializeObject(value, SerializerSettings)!; + } +} \ No newline at end of file diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Surrogates/WorkflowDefinitionSurrogate.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Surrogates/WorkflowDefinitionSurrogate.cs new file mode 100644 index 000000000..54a241c97 --- /dev/null +++ b/src/dashboards/blazor/ElsaDashboard.Shared/Surrogates/WorkflowDefinitionSurrogate.cs @@ -0,0 +1,35 @@ +using Elsa.Client.Models; +using Newtonsoft.Json; +using NodaTime; +using NodaTime.Serialization.JsonNet; +using ProtoBuf; + +namespace ElsaDashboard.Shared.Surrogates +{ + [ProtoContract(IgnoreListHandling = true)] + public class WorkflowDefinitionSurrogate + { + private static readonly JsonSerializerSettings SerializerSettings; + + static WorkflowDefinitionSurrogate() + { + SerializerSettings = new JsonSerializerSettings + { + TypeNameHandling = TypeNameHandling.Auto + }.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb); + } + + public WorkflowDefinitionSurrogate(WorkflowDefinition value) + { + Value = Serialize(value); + } + + [ProtoMember(1)] public string Value { get; } + + public static implicit operator WorkflowDefinition(WorkflowDefinitionSurrogate surrogate) => Deserialize(surrogate.Value)!; + public static implicit operator WorkflowDefinitionSurrogate(WorkflowDefinition source) => new(source); + + private static WorkflowDefinition Deserialize(string json) => JsonConvert.DeserializeObject(json, SerializerSettings)!; + private static string Serialize(WorkflowDefinition value) => JsonConvert.SerializeObject(value, SerializerSettings)!; + } +} \ No newline at end of file diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Surrogates/WorkflowInstanceSurrogate.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Surrogates/WorkflowInstanceSurrogate.cs index 02975c555..4b1e3d805 100644 --- a/src/dashboards/blazor/ElsaDashboard.Shared/Surrogates/WorkflowInstanceSurrogate.cs +++ b/src/dashboards/blazor/ElsaDashboard.Shared/Surrogates/WorkflowInstanceSurrogate.cs @@ -10,7 +10,7 @@ namespace ElsaDashboard.Shared.Surrogates public class WorkflowInstanceSurrogate { private static readonly JsonSerializerSettings SerializerSettings; - + static WorkflowInstanceSurrogate() { SerializerSettings = new JsonSerializerSettings @@ -25,7 +25,7 @@ namespace ElsaDashboard.Shared.Surrogates } [ProtoMember(1)] public string Value { get; } - + public static implicit operator WorkflowInstance(WorkflowInstanceSurrogate surrogate) => Deserialize(surrogate.Value)!; public static implicit operator WorkflowInstanceSurrogate(WorkflowInstance source) => new(source); diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/icon.png b/src/dashboards/blazor/ElsaDashboard.Shared/icon.png new file mode 100644 index 000000000..28dbaafbf Binary files /dev/null and b/src/dashboards/blazor/ElsaDashboard.Shared/icon.png differ diff --git a/src/dashboards/blazor/ElsaDashboard.WebAssembly/ElsaDashboard.WebAssembly.csproj b/src/dashboards/blazor/ElsaDashboard.WebAssembly/ElsaDashboard.WebAssembly.csproj index 4511dd6b2..412b51d02 100644 --- a/src/dashboards/blazor/ElsaDashboard.WebAssembly/ElsaDashboard.WebAssembly.csproj +++ b/src/dashboards/blazor/ElsaDashboard.WebAssembly/ElsaDashboard.WebAssembly.csproj @@ -2,15 +2,37 @@ net5.0 + 1.0.0 + latest + Elsa Contributors + + Elsa is a set of workflow libraries and tools that enable lean and mean workflowing capabilities in any .NET Core application. + This package provides gRPC client implementations for use within the Blazor WebAssembly imlementation of the Elsa Dashboard. + + 2020 + https://github.com/elsa-workflows/elsa-core + https://github.com/elsa-workflows/elsa-core + GitHub + elsa, workflows, dashboard, asp.net core, blazo, webassemblyr + icon.png + enable + - + - + + + + + + True + + diff --git a/src/dashboards/blazor/ElsaDashboard.WebAssembly/Extensions/GrpcServicesServiceCollectionExtensions.cs b/src/dashboards/blazor/ElsaDashboard.WebAssembly/Extensions/GrpcServicesServiceCollectionExtensions.cs index 8c5c142af..c4723b3f6 100644 --- a/src/dashboards/blazor/ElsaDashboard.WebAssembly/Extensions/GrpcServicesServiceCollectionExtensions.cs +++ b/src/dashboards/blazor/ElsaDashboard.WebAssembly/Extensions/GrpcServicesServiceCollectionExtensions.cs @@ -3,6 +3,7 @@ using System.Net.Http; using Grpc.Core; using Grpc.Net.Client; using Grpc.Net.Client.Web; +using Microsoft.AspNetCore.Components; using Microsoft.Extensions.DependencyInjection; using ProtoBuf.Grpc.Client; @@ -15,8 +16,8 @@ namespace ElsaDashboard.WebAssembly.Extensions private static GrpcChannel CreateGrpcChannel(IServiceProvider sp) { - //var navigationManager = sp.GetRequiredService(); - var backendUrl = "https://localhost:53451"; //navigationManager.BaseUri; + var navigationManager = sp.GetRequiredService(); + var backendUrl = navigationManager.BaseUri; var httpClient = new HttpClient(new GrpcWebHandler(GrpcWebMode.GrpcWeb, new HttpClientHandler())); //var tokenManager = sp.GetRequiredService(); diff --git a/src/dashboards/blazor/ElsaDashboard.WebAssembly/Extensions/ServiceCollectionExtensions.cs b/src/dashboards/blazor/ElsaDashboard.WebAssembly/Extensions/ServiceCollectionExtensions.cs index fefb7348f..fe141a6de 100644 --- a/src/dashboards/blazor/ElsaDashboard.WebAssembly/Extensions/ServiceCollectionExtensions.cs +++ b/src/dashboards/blazor/ElsaDashboard.WebAssembly/Extensions/ServiceCollectionExtensions.cs @@ -13,7 +13,9 @@ namespace ElsaDashboard.WebAssembly.Extensions RuntimeTypeModel.Default.AddNodaTime(); return services .AddGrpcClient() - .AddGrpcClient(); + .AddGrpcClient() + .AddGrpcClient() + .AddGrpcClient(); } } } \ No newline at end of file diff --git a/src/dashboards/blazor/ElsaDashboard.WebAssembly/icon.png b/src/dashboards/blazor/ElsaDashboard.WebAssembly/icon.png new file mode 100644 index 000000000..28dbaafbf Binary files /dev/null and b/src/dashboards/blazor/ElsaDashboard.WebAssembly/icon.png differ diff --git a/src/server/Elsa.Server.Api/Elsa.Server.Api.csproj b/src/server/Elsa.Server.Api/Elsa.Server.Api.csproj index e87ab5361..316f6573b 100644 --- a/src/server/Elsa.Server.Api/Elsa.Server.Api.csproj +++ b/src/server/Elsa.Server.Api/Elsa.Server.Api.csproj @@ -18,10 +18,6 @@ enable - - - -