Skip to content

Commit

Permalink
fix(Dashboard): Refactored edge drawing in the graph
Browse files Browse the repository at this point in the history
Signed-off-by: Jean-Baptiste Bianchi <[email protected]>
  • Loading branch information
JBBianchi committed Jul 31, 2024
1 parent 747453d commit 7c628de
Show file tree
Hide file tree
Showing 31 changed files with 248 additions and 200 deletions.
4 changes: 2 additions & 2 deletions src/api/Synapse.Api.Http/Synapse.Api.Http.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Neuroglia.Mediation.AspNetCore" Version="4.12.5" />
<PackageReference Include="Neuroglia.Security.AspNetCore" Version="4.12.5" />
<PackageReference Include="Neuroglia.Mediation.AspNetCore" Version="4.12.6" />
<PackageReference Include="Neuroglia.Security.AspNetCore" Version="4.12.6" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.6.2" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

<ItemGroup>
<PackageReference Include="IdentityModel" Version="7.0.0" />
<PackageReference Include="Neuroglia.Data.Expressions.Abstractions" Version="4.12.5" />
<PackageReference Include="Neuroglia.Data.Infrastructure.Redis" Version="4.12.5" />
<PackageReference Include="Neuroglia.Data.Infrastructure.ResourceOriented.Redis" Version="4.12.5" />
<PackageReference Include="Neuroglia.Mediation" Version="4.12.5" />
<PackageReference Include="Neuroglia.Plugins" Version="4.12.5" />
<PackageReference Include="Neuroglia.Data.Expressions.Abstractions" Version="4.12.6" />
<PackageReference Include="Neuroglia.Data.Infrastructure.Redis" Version="4.12.6" />
<PackageReference Include="Neuroglia.Data.Infrastructure.ResourceOriented.Redis" Version="4.12.6" />
<PackageReference Include="Neuroglia.Mediation" Version="4.12.6" />
<PackageReference Include="Neuroglia.Plugins" Version="4.12.6" />
<PackageReference Include="ServerlessWorkflow.Sdk.IO" Version="1.0.0-alpha2.5" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions src/core/Synapse.Core/Synapse.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Neuroglia.Data.Infrastructure.ResourceOriented" Version="4.12.5" />
<PackageReference Include="Neuroglia.Eventing.CloudEvents" Version="4.12.5" />
<PackageReference Include="Neuroglia.Data.Infrastructure.ResourceOriented" Version="4.12.6" />
<PackageReference Include="Neuroglia.Eventing.CloudEvents" Version="4.12.6" />
<PackageReference Include="Semver" Version="2.3.0" />
<PackageReference Include="ServerlessWorkflow.Sdk" Version="1.0.0-alpha2.5" />
</ItemGroup>
Expand Down
12 changes: 6 additions & 6 deletions src/correlator/Synapse.Correlator/Synapse.Correlator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
<PackageReference Include="Microsoft.Extensions.Configuration.KeyPerFile" Version="8.0.6" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
<PackageReference Include="Neuroglia.Data.Expressions.JavaScript" Version="4.12.5" />
<PackageReference Include="Neuroglia.Data.Expressions.JQ" Version="4.12.5" />
<PackageReference Include="Neuroglia.Eventing.CloudEvents.AspNetCore" Version="4.12.5" />
<PackageReference Include="Neuroglia.Mediation.AspNetCore" Version="4.12.5" />
<PackageReference Include="Neuroglia.Eventing.CloudEvents.Infrastructure" Version="4.12.5" />
<PackageReference Include="Neuroglia.Security.AspNetCore" Version="4.12.5" />
<PackageReference Include="Neuroglia.Data.Expressions.JavaScript" Version="4.12.6" />
<PackageReference Include="Neuroglia.Data.Expressions.JQ" Version="4.12.6" />
<PackageReference Include="Neuroglia.Eventing.CloudEvents.AspNetCore" Version="4.12.6" />
<PackageReference Include="Neuroglia.Mediation.AspNetCore" Version="4.12.6" />
<PackageReference Include="Neuroglia.Eventing.CloudEvents.Infrastructure" Version="4.12.6" />
<PackageReference Include="Neuroglia.Security.AspNetCore" Version="4.12.6" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.6.2" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.6.2" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ public class CallTaskNodeViewModel
/// <summary>
/// Initializes a new <see cref="CallTaskNodeViewModel"/>
/// </summary>
/// <param name="taskReference">The node task reference</param>
/// <param name="name">The node name</param>
/// <param name="content">The node content</param>
/// <param name="callType">The type of call</param>
public CallTaskNodeViewModel(string name, string content, string callType = "")
: base(new() { Label = name, CssClass = "call-task-node" })
public CallTaskNodeViewModel(string taskReference, string name, string content, string callType = "")
: base(taskReference, new() { Label = name, CssClass = "call-task-node" })
{
Content = content;
Symbol = !string.IsNullOrEmpty(callType) ? $"{callType.ToLower()}-symbol" : "call-symbol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ public class DoTaskNodeViewModel
/// <summary>
/// Initializes a new <see cref="DoTaskNodeViewModel"/>
/// </summary>
/// <param name="taskReference">The node task reference</param>
/// <param name="name">The node name</param>
/// <param name="content">The node content</param>
public DoTaskNodeViewModel(string name, string content)
: base(new() { Label = name, CssClass = "do-task-node" })
public DoTaskNodeViewModel(string taskReference, string name, string content)
: base(taskReference, new() { Label = name, CssClass = "do-task-node" })
{
Content = content;
Symbol = "do-symbol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ public class EmitTaskNodeViewModel
/// <summary>
/// Initializes a new <see cref="EmitTaskNodeViewModel"/>
/// </summary>
/// <param name="taskReference">The node task reference</param>
/// <param name="name">The node name</param>
/// <param name="content">The node content</param>
public EmitTaskNodeViewModel(string name, string content)
: base(new() { Label = name, CssClass = "emit-task-node" })
public EmitTaskNodeViewModel(string taskReference, string name, string content)
: base(taskReference, new() { Label = name, CssClass = "emit-task-node" })
{
Content = content;
Symbol = "emit-symbol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ namespace Synapse.Dashboard.Components;
/// Represents the object that holds the data required to render the view of a workflow's end node
/// </summary>
public class EndNodeViewModel()
: WorkflowNodeViewModel(new() { CssClass = "end-node", Shape = NodeShape.Circle, Width = WorkflowGraphBuilder.StartEndNodeRadius, Height = WorkflowGraphBuilder.StartEndNodeRadius })
: WorkflowNodeViewModel("end-node", new() { CssClass = "end-node", Shape = NodeShape.Circle, Width = WorkflowGraphBuilder.StartEndNodeRadius, Height = WorkflowGraphBuilder.StartEndNodeRadius })
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ public class ExtensionTaskNodeViewModel
/// <summary>
/// Initializes a new <see cref="ExtensionTaskNodeViewModel"/>
/// </summary>
/// <param name="taskReference">The node task reference</param>
/// <param name="name">The node name</param>
public ExtensionTaskNodeViewModel(string name)
: base(new() { Label = name, CssClass = "extension-task-node" })
public ExtensionTaskNodeViewModel(string taskReference, string name)
: base(taskReference, new() { Label = name, CssClass = "extension-task-node" })
{
Symbol = "extension-symbol";
Type = "EXTENSION";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ public class ForTaskNodeViewModel
/// <summary>
/// Initializes a new <see cref="ForTaskNodeViewModel"/>
/// </summary>
/// <param name="taskReference">The node task reference</param>
/// <param name="name">The node name</param>
/// <param name="content">The node content</param>
public ForTaskNodeViewModel(string name, string content)
: base(new() { Label = name, CssClass = "for-task-node" })
public ForTaskNodeViewModel(string taskReference, string name, string content)
: base(taskReference, new() { Label = name, CssClass = "for-task-node" })
{
Content = content;
Symbol = "for-symbol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ public class ListenTaskNodeViewModel
/// <summary>
/// Initializes a new <see cref="ListenTaskNodeViewModel"/>
/// </summary>
/// <param name="taskReference">The node task reference</param>
/// <param name="name">The node name</param>
/// <param name="content">The node content</param>
public ListenTaskNodeViewModel(string name, string content)
: base(new() { Label = name, CssClass = "listen-task-node" })
public ListenTaskNodeViewModel(string taskReference, string name, string content)
: base(taskReference, new() { Label = name, CssClass = "listen-task-node" })
{
Content = content;
Symbol = "listen-symbol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class NodeViewModelConfig
/// <summary>
/// Gets/sets parent node id
/// </summary>
public Guid? ParentId { get; set; }
public string? ParentId { get; set; }

/// <summary>
/// Gets/sets the shape the node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ public class RaiseTaskNodeViewModel
/// <summary>
/// Initializes a new <see cref="RaiseTaskNodeViewModel"/>
/// </summary>
/// <param name="taskReference">The node task reference</param>
/// <param name="name">The node name</param>
/// <param name="content">The node content</param>
public RaiseTaskNodeViewModel(string name, string content)
: base(new() { Label = name, CssClass = "raise-task-node" })
public RaiseTaskNodeViewModel(string taskReference, string name, string content)
: base(taskReference, new() { Label = name, CssClass = "raise-task-node" })
{
Content = content;
Symbol = "raise-symbol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ public class RunTaskNodeViewModel
/// <summary>
/// Initializes a new <see cref="RunTaskNodeViewModel"/>
/// </summary>
/// <param name="taskReference">The node task reference</param>
/// <param name="name">The node name</param>
/// <param name="content">The node content</param>
/// <param name="runType">The type of run</param>
public RunTaskNodeViewModel(string name, string content, string runType = "")
: base(new() { Label = name, CssClass = "run-task-node" })
public RunTaskNodeViewModel(string taskReference, string name, string content, string runType = "")
: base(taskReference, new() { Label = name, CssClass = "run-task-node" })
{
Content = content;
Symbol = !string.IsNullOrEmpty(runType) ? $"{runType.ToLower()}-symbol" : "run-symbol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ public class SetTaskNodeViewModel
/// <summary>
/// Initializes a new <see cref="SetTaskNodeViewModel"/>
/// </summary>
/// <param name="taskReference">The node task reference</param>
/// <param name="name">The node name</param>
/// <param name="content">The node content</param>
public SetTaskNodeViewModel(string name, string content)
: base(new() { Label = name, CssClass = "set-task-node" })
public SetTaskNodeViewModel(string taskReference, string name, string content)
: base(taskReference, new() { Label = name, CssClass = "set-task-node" })
{
Content = content;
Symbol = "set-symbol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Synapse.Dashboard.Components;
/// Represents the object that holds the data required to render the view of a workflow's start node
/// </summary>
public class StartNodeViewModel(bool hasSuccessor = false)
: WorkflowNodeViewModel(new() { CssClass = "start-node", Shape = NodeShape.Circle, Width = WorkflowGraphBuilder.StartEndNodeRadius, Height = WorkflowGraphBuilder.StartEndNodeRadius })
: WorkflowNodeViewModel("start-node", new() { CssClass = "start-node", Shape = NodeShape.Circle, Width = WorkflowGraphBuilder.StartEndNodeRadius, Height = WorkflowGraphBuilder.StartEndNodeRadius })
{

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ public class SwitchTaskNodeViewModel
/// <summary>
/// Initializes a new <see cref="SwitchTaskNodeViewModel"/>
/// </summary>
/// <param name="taskReference">The node task reference</param>
/// <param name="name">The node name</param>
/// <param name="content">The node content</param>
public SwitchTaskNodeViewModel(string name, string content)
: base(new() { Label = name, CssClass = "switch-task-node" })
public SwitchTaskNodeViewModel(string taskReference, string name, string content)
: base(taskReference, new() { Label = name, CssClass = "switch-task-node" })
{
Content = content;
Symbol = "switch-symbol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ public class TaskNodeViewModel
/// <summary>
/// Initializes a new <see cref="TaskNodeViewModel"/>
/// </summary>
/// <param name="taskReference">The node task reference</param>
/// <param name="name">The name of the <see cref="TaskDefinition"/> the <see cref="TaskNodeViewModel"/> represents</param>
/// <param name="definition">The <see cref="TaskDefinition"/> the <see cref="TaskNodeViewModel"/> represents</param>
/// <param name="isFirst">Indicates whether or not the task to create the <see cref="TaskNodeViewModel"/> for is the first task of the workflow it belongs to</param>
public TaskNodeViewModel(string name, TaskDefinition definition, bool isFirst = false)
public TaskNodeViewModel(string taskReference, string name, TaskDefinition definition, bool isFirst = false)
: base(null, name)
{
this.Id = taskReference;
this.Name = name;
this.Definition = definition;
this.IsFirst = isFirst;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ else if (!string.IsNullOrWhiteSpace(Node.Label) )

@code {

IBoundingBox bbox => Node.BBox!;
string x => bbox.X.ToInvariantString() ?? string.Empty;
string y => bbox.Y.ToInvariantString() ?? string.Empty;
string width => bbox.Width.ToInvariantString() ?? string.Empty;
string height => bbox.Height.ToInvariantString() ?? Neuroglia.Blazor.Dagre.Constants.LabelHeight.ToInvariantString();
BoundingBox bounds => Node.Bounds!;
string x => bounds.X.ToInvariantString() ?? string.Empty;
string y => bounds.Y.ToInvariantString() ?? string.Empty;
string width => bounds.Width.ToInvariantString() ?? string.Empty;
string height => bounds.Height.ToInvariantString() ?? Neuroglia.Blazor.Dagre.Constants.LabelHeight.ToInvariantString();

[CascadingParameter(Name = "Node")] public INodeViewModel Node { get; set; } = null!;
[CascadingParameter(Name = "LabelTemplate")] public RenderFragment? LabelTemplate { get; set; } = null!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@
<g class="shape">
@if (Node.Shape == NodeShape.Circle)
{
<Circle BBox="bbox" />
<Circle Bounds="bounds" />
}
else if (Node.Shape == NodeShape.Ellipse)
{
<Ellipse BBox="bbox" />
<Ellipse Bounds="bounds" />
}
else if (Node.Shape == SynapseNodeShape.Cartouche)
{
<rect class="node-rectangle" x="@(bbox.X.ToInvariantString())"
y="@(bbox.Y.ToInvariantString())"
width="@(bbox.Width.ToInvariantString())"
height="@(bbox.Height.ToInvariantString())"
rx="@((Node.RadiusX ?? 0).ToInvariantString())"
ry="@((Node.RadiusY ?? 0).ToInvariantString())" />
<path class="node-cartouche" d="m @((bbox.X).ToInvariantString()) @((bbox.Y + (Node.RadiusX ?? 0)).ToInvariantString()) c 0 -@(((Node.RadiusX ?? 0) / 2).ToInvariantString()) @(((Node.RadiusX ?? 0) / 2).ToInvariantString()) -@((Node.RadiusX ?? 0).ToInvariantString()) @((Node.RadiusX ?? 0).ToInvariantString()) -@((Node.RadiusX ?? 0).ToInvariantString()) h @(((bbox.Width / 8) - 1).ToInvariantString()) v @((bbox.Height).ToInvariantString()) h -@(((bbox.Width / 8) - 1).ToInvariantString()) c -@(((Node.RadiusX ?? 0) / 2).ToInvariantString()) 0 -@((Node.RadiusX ?? 0).ToInvariantString()) -@(((Node.RadiusX ?? 0) / 2).ToInvariantString()) -@((Node.RadiusX ?? 0).ToInvariantString()) -@((Node.RadiusX ?? 0).ToInvariantString()) z" />
<rect class="node-rectangle" x="@(bounds.X.ToInvariantString())"
y="@(bounds.Y.ToInvariantString())"
width="@(bounds.Width.ToInvariantString())"
height="@(bounds.Height.ToInvariantString())"
rx="@((Node.RadiusX).ToInvariantString())"
ry="@((Node.RadiusY).ToInvariantString())" />
<path class="node-cartouche" d="m @((bounds.X).ToInvariantString()) @((bounds.Y + (Node.RadiusX)).ToInvariantString()) c 0 -@(((Node.RadiusX) / 2).ToInvariantString()) @(((Node.RadiusX) / 2).ToInvariantString()) -@((Node.RadiusX).ToInvariantString()) @((Node.RadiusX).ToInvariantString()) -@((Node.RadiusX).ToInvariantString()) h @(((bounds.Width / 8) - 1).ToInvariantString()) v @((bounds.Height).ToInvariantString()) h -@(((bounds.Width / 8) - 1).ToInvariantString()) c -@(((Node.RadiusX) / 2).ToInvariantString()) 0 -@((Node.RadiusX).ToInvariantString()) -@(((Node.RadiusX) / 2).ToInvariantString()) -@((Node.RadiusX).ToInvariantString()) -@((Node.RadiusX).ToInvariantString()) z" />
}
else
{
<Rectangle BBox="bbox" RadiusX="Node.RadiusX" RadiusY="Node.RadiusY" />
<Rectangle Bounds="bounds" RadiusX="Node.RadiusX" RadiusY="Node.RadiusY" />
}
</g>

@code {

IBoundingBox bbox => Node.BBox!;
BoundingBox bounds => Node.Bounds!;
[CascadingParameter(Name = "Node")] public INodeViewModel Node { get; set; } = null!;

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
@code {

Double _symbolSize = 30;
IBoundingBox bbox => Node.BBox!;
BoundingBox bounds => Node.Bounds!;
string? width => Node.Shape != SynapseNodeShape.Cartouche ?
(bbox.Width / 2).ToInvariantString() :
(bounds.Width / 2).ToInvariantString() :
_symbolSize.ToInvariantString();
string? height => Node.Shape != SynapseNodeShape.Cartouche ?
(bbox.Height / 2).ToInvariantString() :
(bounds.Height / 2).ToInvariantString() :
_symbolSize.ToInvariantString();
string? x => Node.Shape != SynapseNodeShape.Cartouche ?
(0 - bbox.Width / 4).ToInvariantString() :
(0 - (bbox.Width - _symbolSize) / 2).ToInvariantString();
(0 - bounds.Width / 4).ToInvariantString() :
(0 - (bounds.Width - _symbolSize) / 2).ToInvariantString();
string? y => Node.Shape != SynapseNodeShape.Cartouche ?
(0 - bbox.Height / 4).ToInvariantString() :
(0 - bounds.Height / 4).ToInvariantString() :
(0 - _symbolSize / 2).ToInvariantString();

[CascadingParameter(Name = "Node")] public INodeViewModel Node { get; set; } = null!;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@namespace Synapse.Dashboard
@inherits NodeTemplate

<g class="node @(!string.IsNullOrWhiteSpace(Node.Shape) ? "shape-" + Node.Shape : "shape-rectangle") @Node.CssClass" transform="translate(@((Node.X ?? 0).ToInvariantString()), @((Node.Y ?? 0).ToInvariantString()))">
<g class="node @(!string.IsNullOrWhiteSpace(Node.Shape) ? "shape-" + Node.Shape : "shape-rectangle") @Node.CssClass" transform="translate(@((Node.X).ToInvariantString()), @((Node.Y).ToInvariantString()))">
<CascadingValue Name="Node" Value="Node">
<NodeShapeTemplate />
<CascadingValue Name="LabelTemplate" Value="LabelTemplate">
Expand All @@ -24,15 +24,15 @@

@code {
protected virtual IWorkflowNodeViewModel WorkflowNode => (IWorkflowNodeViewModel)this.Node;
IBoundingBox bbox => Node.BBox!;
BoundingBox bounds => Node.Bounds!;

RenderFragment? LabelTemplate => !string.IsNullOrWhiteSpace(WorkflowNode.Type) || !string.IsNullOrWhiteSpace(WorkflowNode.Content) ? (__builder) =>
{
<g class="label">
<foreignObject x="@(bbox.X.ToInvariantString())"
y="@(bbox.Y.ToInvariantString())"
width="@(bbox.Width.ToInvariantString())"
height="@(bbox.Height.ToInvariantString())">
<foreignObject x="@(bounds.X.ToInvariantString())"
y="@(bounds.Y.ToInvariantString())"
width="@(bounds.Width.ToInvariantString())"
height="@(bounds.Height.ToInvariantString())">
<div class="label-content">
<h3>
@if (!string.IsNullOrWhiteSpace(Node.Label))
Expand Down
Loading

0 comments on commit 7c628de

Please sign in to comment.