Fix gRPC types

This commit is contained in:
Sipke Schoorstra 2020-12-11 20:42:04 +01:00
parent 7fad97a952
commit 0369869910
45 changed files with 491 additions and 89 deletions

View file

@ -8,7 +8,7 @@ namespace Elsa.Client.Services
public interface IWorkflowRegistryApi
{
[Get("/v1/workflow-registry/{id}/{versionOptions}")]
Task<WorkflowBlueprint> GetByIdAsync(string id, VersionOptions versionOptions, CancellationToken cancellationToken = default);
Task<WorkflowBlueprint?> GetByIdAsync(string id, VersionOptions versionOptions, CancellationToken cancellationToken = default);
[Get("/v1/workflow-registry")]
Task<PagedList<WorkflowBlueprint>> ListAsync(int? page = default, int? pageSize = default, VersionOptions? versionOptions = default, CancellationToken cancellationToken = default);

View file

@ -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)

View file

@ -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<Uri>("Elsa:HostUrl"));
if (Program.RuntimeModel == BlazorRuntimeModel.Server)
services.AddServerSideBlazor(options =>

View file

@ -6,5 +6,8 @@
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
"AllowedHosts": "*",
"Elsa": {
"HostUrl": "https://localhost:11000"
}
}

View file

@ -14,6 +14,7 @@ namespace ElsaDashboard.Application.WebAssembly
var builder = WebAssemblyHostBuilder.CreateDefault(args);
var services = builder.Services;
//builder.RootComponents.Add<App>("#app");
services.AddScoped(sp => new HttpClient {BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)});
services.AddElsaDashboardUI();
services.AddElsaDashboardBackend();

View file

@ -2,7 +2,19 @@
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<PackageVersion>1.0.0</PackageVersion>
<LangVersion>latest</LangVersion>
<Authors>Elsa Contributors</Authors>
<Description>
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.
</Description>
<Copyright>2020</Copyright>
<PackageProjectUrl>https://github.com/elsa-workflows/elsa-core</PackageProjectUrl>
<RepositoryUrl>https://github.com/elsa-workflows/elsa-core</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<PackageTags>elsa, workflows, dashboard, asp.net core, blazor</PackageTags>
<PackageIcon>icon.png</PackageIcon>
<Nullable>enable</Nullable>
</PropertyGroup>
@ -25,4 +37,11 @@
<ProjectReference Include="..\ElsaDashboard.Shared\ElsaDashboard.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="icon.png">
<Pack>True</Pack>
<PackagePath />
</None>
</ItemGroup>
</Project>

View file

@ -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

View file

@ -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);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

View file

@ -2,20 +2,40 @@
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<PackageVersion>1.0.0</PackageVersion>
<LangVersion>latest</LangVersion>
<Authors>Elsa Contributors</Authors>
<Description>
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.
</Description>
<Copyright>2020</Copyright>
<PackageProjectUrl>https://github.com/elsa-workflows/elsa-core</PackageProjectUrl>
<RepositoryUrl>https://github.com/elsa-workflows/elsa-core</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<PackageTags>elsa, workflows, dashboard, asp.net core, grpc</PackageTags>
<PackageIcon>icon.png</PackageIcon>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ElsaDashboard.Shared\ElsaDashboard.Shared.csproj" />
<ProjectReference Include="..\ElsaDashboard.Shared\ElsaDashboard.Shared.csproj"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Grpc.AspNetCore.Server" Version="2.33.1" />
<PackageReference Include="Grpc.AspNetCore.Web" Version="2.33.1" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="NodaTime.Serialization.Protobuf" Version="2.0.0" />
<PackageReference Include="protobuf-net.Grpc.AspNetCore" Version="1.0.136" />
<PackageReference Include="protobuf-net.NodaTime" Version="3.0.73" />
<PackageReference Include="Grpc.AspNetCore.Server" Version="2.33.1"/>
<PackageReference Include="Grpc.AspNetCore.Web" Version="2.33.1"/>
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0"/>
<PackageReference Include="NodaTime.Serialization.Protobuf" Version="2.0.0"/>
<PackageReference Include="protobuf-net.Grpc.AspNetCore" Version="1.0.136"/>
<PackageReference Include="protobuf-net.NodaTime" Version="3.0.73"/>
</ItemGroup>
<ItemGroup>
<None Update="icon.png">
<Pack>True</Pack>
<PackagePath/>
</None>
</ItemGroup>
</Project>

View file

@ -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;

View file

@ -15,13 +15,13 @@ namespace ElsaDashboard.Backend.Rpc
_elsaClient = elsaClient;
}
public async Task<PagedList<WorkflowDefinition>> ListAsync(int? page, int? pageSize, VersionOptions? versionOptions, CallContext context) =>
await _elsaClient.WorkflowDefinitions.ListAsync(page, pageSize, versionOptions, context.CancellationToken);
public async Task<PagedList<WorkflowDefinition>> ListAsync(ListWorkflowDefinitionsRequest request, CallContext context = default) =>
await _elsaClient.WorkflowDefinitions.ListAsync(request.Page, request.PageSize, request.VersionOptions, context.CancellationToken);
public async Task<WorkflowDefinition> GetById(string workflowDefinitionId, VersionOptions versionOptions, CallContext context = default) =>
await _elsaClient.WorkflowDefinitions.GetByIdAsync(workflowDefinitionId, versionOptions, context.CancellationToken);
public async Task<WorkflowDefinition> GetByIdAsync(GetWorkflowDefinitionByIdRequest request, CallContext context = default) =>
await _elsaClient.WorkflowDefinitions.GetByIdAsync(request.WorkflowDefinitionId, request.VersionOptions ?? VersionOptions.Published, context.CancellationToken);
public Task<WorkflowDefinition> GetByVersionIdAsync(string workflowDefinitionVersionId, CallContext context) => _elsaClient.WorkflowDefinitions.GetByVersionIdAsync(workflowDefinitionVersionId, context.CancellationToken);
public Task<WorkflowDefinition> GetByVersionIdAsync(GetWorkflowDefinitionByVersionIdRequest request, CallContext context) => _elsaClient.WorkflowDefinitions.GetByVersionIdAsync(request.WorkflowDefinitionVersionId, context.CancellationToken);
public async Task<WorkflowDefinition> SaveAsync(SaveWorkflowDefinitionRequest request, CallContext context) => await _elsaClient.WorkflowDefinitions.SaveAsync(request, context.CancellationToken);
}
}

View file

@ -10,8 +10,8 @@ namespace ElsaDashboard.Backend.Rpc
{
private readonly IElsaClient _elsaClient;
public WorkflowInstanceService(IElsaClient elsaClient) => _elsaClient = elsaClient;
public Task<PagedList<WorkflowInstance>> ListAsync(int page = 0, int pageSize = 50, CallContext context = default) => _elsaClient.WorkflowInstances.ListAsync(page, pageSize, context.CancellationToken);
public Task<WorkflowInstance?> 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<PagedList<WorkflowInstance>> ListAsync(ListWorkflowInstancesRequest request, CallContext context = default) => _elsaClient.WorkflowInstances.ListAsync(request.Page, request.PageSize, context.CancellationToken);
public Task<WorkflowInstance?> 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);
}
}

View file

@ -11,9 +11,9 @@ namespace ElsaDashboard.Backend.Rpc
private readonly IElsaClient _elsaClient;
public WorkflowRegistryService(IElsaClient elsaClient) => _elsaClient = elsaClient;
public Task<PagedList<WorkflowBlueprint>> ListAsync(int? page = default, int? pageSize = default, VersionOptions? versionOptions = default, CallContext context = default) =>
_elsaClient.WorkflowRegistry.ListAsync(page, pageSize, versionOptions, context.CancellationToken);
public Task<PagedList<WorkflowBlueprint>> ListAsync(ListWorkflowBlueprintsRequest request, CallContext context = default) =>
_elsaClient.WorkflowRegistry.ListAsync(request.Page, request.PageSize, request.VersionOptions, context.CancellationToken);
public Task<WorkflowBlueprint> GetById(string id, VersionOptions versionOptions, CallContext context = default) => _elsaClient.WorkflowRegistry.GetByIdAsync(id, versionOptions, context.CancellationToken);
public Task<WorkflowBlueprint?> GetById(GetWorkflowBlueprintByIdRequest request, CallContext context = default) => _elsaClient.WorkflowRegistry.GetByIdAsync(request.Id, request.VersionOptions, context.CancellationToken);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

View file

@ -2,19 +2,39 @@
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<PackageVersion>1.0.0</PackageVersion>
<LangVersion>latest</LangVersion>
<Authors>Elsa Contributors</Authors>
<Description>
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.
</Description>
<Copyright>2020</Copyright>
<PackageProjectUrl>https://github.com/elsa-workflows/elsa-core</PackageProjectUrl>
<RepositoryUrl>https://github.com/elsa-workflows/elsa-core</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<PackageTags>elsa, workflows, dashboard, asp.net core, grpc</PackageTags>
<PackageIcon>icon.png</PackageIcon>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Api.CommonProtos" Version="2.2.0" />
<PackageReference Include="Grpc.Net.Client" Version="2.33.1" />
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.33.1" />
<PackageReference Include="protobuf-net" Version="3.0.62" />
<PackageReference Include="protobuf-net.Grpc" Version="1.0.136" />
<PackageReference Include="Grpc.Net.Client" Version="2.34.0" />
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.34.0" />
<PackageReference Include="protobuf-net" Version="3.0.73" />
<PackageReference Include="protobuf-net.Grpc" Version="1.0.140" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\clients\Elsa.Client\Elsa.Client.csproj" />
<ProjectReference Include="..\..\..\clients\Elsa.Client\Elsa.Client.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="icon.png">
<Pack>True</Pack>
<PackagePath />
</None>
</ItemGroup>
</Project>

View file

@ -0,0 +1,13 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=rpc_005Cworkflowdefinition/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=rpc_005Cworkflowdefinitionservice/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=rpc_005Cworkflowdefinitionservice_005Cextensions/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=rpc_005Cworkflowdefinitionservice_005Cmodels/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=rpc_005Cworkflowdefinitionservice_005Cservices/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=rpc_005Cworkflowdefinition_005Cextensions/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=rpc_005Cworkflowdefinition_005Cmodels/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=rpc_005Cworkflowdefinition_005Cservices/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=rpc_005Cworkflowregistry/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=rpc_005Cworkflowregistry_005Cextensions/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=rpc_005Cworkflowregistry_005Cmodels/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=rpc_005Cworkflowregistry_005Cservices/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View file

@ -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<IEnumerable<ActivityInfo>> GetActivitiesAsync(CallContext context = default);
}
}

View file

@ -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<PagedList<WorkflowDefinition>> ListAsync(int? page = default, int? pageSize = default, VersionOptions? versionOptions = default, CallContext context = default);
Task<WorkflowDefinition> GetById(string workflowDefinitionId, VersionOptions versionOptions, CallContext context = default);
Task<WorkflowDefinition> GetByVersionIdAsync(string workflowDefinitionVersionId, CallContext context = default);
Task<WorkflowDefinition> SaveAsync(SaveWorkflowDefinitionRequest request, CallContext context = default);
}
}

View file

@ -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<PagedList<WorkflowInstance>> ListAsync(int page = 0, int pageSize = 50, CallContext context = default);
Task<WorkflowInstance?> GetByIdAsync(string id, CallContext context = default);
Task DeleteAsync(string id, CallContext context = default);
}
}

View file

@ -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<PagedList<WorkflowBlueprint>> ListAsync(int? page = default, int? pageSize = default, VersionOptions? versionOptions = default, CallContext context = default);
Task<WorkflowBlueprint> GetById(string id, VersionOptions versionOptions, CallContext context = default);
}
}

View file

@ -0,0 +1,17 @@
using System.Threading.Tasks;
using Elsa.Client.Models;
namespace ElsaDashboard.Shared.Rpc
{
public static class WorkflowDefinitionServiceExtensions
{
public static async Task<PagedList<WorkflowDefinition>> 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<WorkflowDefinition> GetByIdAsync(this IWorkflowDefinitionService service, string workflowDefinitionId, VersionOptions? versionOptions = default) =>
await service.GetByIdAsync(new GetWorkflowDefinitionByIdRequest(workflowDefinitionId, versionOptions));
public static async Task<WorkflowDefinition> GetByVersionIdAsync(this IWorkflowDefinitionService service, string workflowDefinitionVersionId) =>
await service.GetByVersionIdAsync(new GetWorkflowDefinitionByVersionIdRequest(workflowDefinitionVersionId));
}
}

View file

@ -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; }
}
}

View file

@ -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; }
}
}

View file

@ -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; }
}
}

View file

@ -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<PagedList<WorkflowDefinition>> ListAsync(ListWorkflowDefinitionsRequest request, CallContext context = default);
[Operation]
Task<WorkflowDefinition> GetByIdAsync(GetWorkflowDefinitionByIdRequest request, CallContext context = default);
[Operation]
Task<WorkflowDefinition> GetByVersionIdAsync(GetWorkflowDefinitionByVersionIdRequest request, CallContext context = default);
[Operation]
Task<WorkflowDefinition> SaveAsync(SaveWorkflowDefinitionRequest request, CallContext context = default);
}
}

View file

@ -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<PagedList<WorkflowInstance>> ListAsync(this IWorkflowInstanceService service, int page = 0, int pageSize = 50) => service.ListAsync(new ListWorkflowInstancesRequest(page, pageSize));
public static Task<WorkflowInstance?> 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));
}
}

View file

@ -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; }
}
}

View file

@ -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; }
}
}

View file

@ -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;
}
}

View file

@ -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<PagedList<WorkflowInstance>> ListAsync(ListWorkflowInstancesRequest request, CallContext context = default);
[Operation]
Task<WorkflowInstance?> GetByIdAsync(GetWorkflowInstanceByIdRequest request, CallContext context = default);
[Operation]
Task DeleteAsync(DeleteWorkflowInstanceRequest request, CallContext context = default);
}
}

View file

@ -0,0 +1,13 @@
using System.Threading.Tasks;
using Elsa.Client.Models;
namespace ElsaDashboard.Shared.Rpc
{
public static class WorkflowRegistryServiceExtensions
{
public static Task<PagedList<WorkflowBlueprint>> ListAsync(this IWorkflowRegistryService service, int? page = default, int? pageSize = default, VersionOptions? versionOptions = default) =>
service.ListAsync(new ListWorkflowBlueprintsRequest(page, pageSize, versionOptions));
public static Task<WorkflowBlueprint?> GetById(this IWorkflowRegistryService service, string id, VersionOptions versionOptions) => service.GetById(new GetWorkflowBlueprintByIdRequest(id, versionOptions));
}
}

View file

@ -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; }
}
}

View file

@ -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; }
}
}

View file

@ -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<PagedList<WorkflowBlueprint>> ListAsync(ListWorkflowBlueprintsRequest request, CallContext context = default);
[Operation]
Task<WorkflowBlueprint?> GetById(GetWorkflowBlueprintByIdRequest request, CallContext context = default);
}
}

View file

@ -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)
};
/// <summary>

View file

@ -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<WorkflowBlueprint>(json, SerializerSettings)!;
private static string Serialize(WorkflowBlueprint value) => JsonConvert.SerializeObject(value, SerializerSettings)!;
}
}

View file

@ -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<WorkflowDefinition>(json, SerializerSettings)!;
private static string Serialize(WorkflowDefinition value) => JsonConvert.SerializeObject(value, SerializerSettings)!;
}
}

View file

@ -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);

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

View file

@ -2,15 +2,37 @@
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<PackageVersion>1.0.0</PackageVersion>
<LangVersion>latest</LangVersion>
<Authors>Elsa Contributors</Authors>
<Description>
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.
</Description>
<Copyright>2020</Copyright>
<PackageProjectUrl>https://github.com/elsa-workflows/elsa-core</PackageProjectUrl>
<RepositoryUrl>https://github.com/elsa-workflows/elsa-core</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<PackageTags>elsa, workflows, dashboard, asp.net core, blazo, webassemblyr</PackageTags>
<PackageIcon>icon.png</PackageIcon>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Grpc.Net.Client.Web" Version="2.33.1" />
<PackageReference Include="Microsoft.AspNetCore.Components" Version="5.0.0" />
<PackageReference Include="protobuf-net.NodaTime" Version="3.0.73" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ElsaDashboard.Shared\ElsaDashboard.Shared.csproj" />
<ProjectReference Include="..\ElsaDashboard.Shared\ElsaDashboard.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="icon.png">
<Pack>True</Pack>
<PackagePath />
</None>
</ItemGroup>
</Project>

View file

@ -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<NavigationManager>();
var backendUrl = "https://localhost:53451"; //navigationManager.BaseUri;
var navigationManager = sp.GetRequiredService<NavigationManager>();
var backendUrl = navigationManager.BaseUri;
var httpClient = new HttpClient(new GrpcWebHandler(GrpcWebMode.GrpcWeb, new HttpClientHandler()));
//var tokenManager = sp.GetRequiredService<ITokenManager>();

View file

@ -13,7 +13,9 @@ namespace ElsaDashboard.WebAssembly.Extensions
RuntimeTypeModel.Default.AddNodaTime();
return services
.AddGrpcClient<IActivityService>()
.AddGrpcClient<IWorkflowDefinitionService>();
.AddGrpcClient<IWorkflowDefinitionService>()
.AddGrpcClient<IWorkflowInstanceService>()
.AddGrpcClient<IWorkflowRegistryService>();
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

View file

@ -18,10 +18,6 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<!-- <ItemGroup>-->
<!-- <FrameworkReference Include="Microsoft.AspNetCore.App" />-->
<!-- </ItemGroup>-->
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />