-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Dashboard): Added the WorkflowDiagram component (WIP)
Signed-off-by: Charles d'Avernas <[email protected]>
- Loading branch information
Showing
44 changed files
with
1,507 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/core/Synapse.Core/Extensions/WorkflowDefinitionExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright © 2024-Present The Synapse Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"), | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace Synapse; | ||
|
||
/// <summary> | ||
/// Defines extensions for <see cref="WorkflowDefinition"/>s | ||
/// </summary> | ||
public static class WorkflowDefinitionExtensions | ||
{ | ||
|
||
/// <summary> | ||
/// Gets the task, if any, that should be executed after the specified one | ||
/// </summary> | ||
/// <param name="workflow">The <see cref="WorkflowDefinition"/> that defines the specified <see cref="TaskDefinition"/></param> | ||
/// <param name="afterTask">The name/definition mapping of the <see cref="TaskDefinition"/> to get the following <see cref="TaskDefinition"/> of</param> | ||
/// <param name="parentReference">A reference to the component that defines the next <see cref="TaskDefinition"/></param> | ||
/// <returns>A name/definition mapping of the next <see cref="TaskDefinition"/>, if any</returns> | ||
public static KeyValuePair<string, TaskDefinition>? GetNextTask(this WorkflowDefinition workflow, KeyValuePair<string, TaskDefinition> afterTask, string parentReference) | ||
{ | ||
ArgumentNullException.ThrowIfNull(workflow); | ||
ArgumentException.ThrowIfNullOrWhiteSpace(parentReference); | ||
var taskMap = workflow.GetComponent<IDictionary<string, TaskDefinition>>(parentReference) ?? throw new NullReferenceException($"Failed to find the component at '{parentReference}'"); | ||
var taskIndex = taskMap.Keys.ToList().IndexOf(afterTask.Key); | ||
var nextIndex = taskIndex < 0 ? -1 : taskIndex + 1; | ||
if (nextIndex < 0 || nextIndex >= taskMap.Count) return null; | ||
return taskMap.ElementAt(nextIndex); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/dashboard/Synapse.Dashboard/Components/WorkflowDetails/WorkflowDetails.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@namespace Synapse.Dashboard.Components | ||
|
||
<WorkflowDiagram WorkflowDefinition="Workflow.Spec.Versions.GetLatest()" Orientation="WorkflowDiagramOrientation.TopToBottom" /> | ||
|
||
@code{ | ||
|
||
[Parameter] public Workflow Workflow { get; set; } = null!; | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
src/dashboard/Synapse.Dashboard/Components/WorkflowDiagram/CallTaskNodeViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright © 2024-Present The Synapse Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"), | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using ServerlessWorkflow.Sdk.Models.Tasks; | ||
|
||
namespace Synapse.Dashboard.Components; | ||
|
||
/// <summary> | ||
/// Represents a call task node view model | ||
/// </summary> | ||
public class CallTaskNodeViewModel | ||
: LabeledWorkflowNodeViewModel | ||
{ | ||
|
||
/// <summary> | ||
/// Initializes a new <see cref="CallTaskNodeViewModel"/> | ||
/// </summary> | ||
public CallTaskNodeViewModel(KeyValuePair<string, CallTaskDefinition> task) | ||
: base(task.Key, "call-task-node", null, Neuroglia.Blazor.Dagre.Constants.NodeHeight * 1.5, Neuroglia.Blazor.Dagre.Constants.NodeHeight * 1.5) | ||
{ | ||
|
||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
src/dashboard/Synapse.Dashboard/Components/WorkflowDiagram/CompositeTaskNodeViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright © 2024-Present The Synapse Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"), | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using ServerlessWorkflow.Sdk.Models.Tasks; | ||
|
||
namespace Synapse.Dashboard.Components; | ||
|
||
/// <summary> | ||
/// Represents a composite task node view model | ||
/// </summary> | ||
public class CompositeTaskNodeViewModel | ||
: LabeledWorkflowNodeViewModel | ||
{ | ||
|
||
/// <summary> | ||
/// Initializes a new <see cref="CompositeTaskNodeViewModel"/> | ||
/// </summary> | ||
public CompositeTaskNodeViewModel(KeyValuePair<string, CompositeTaskDefinition> task) | ||
: base(task.Key, "composite-task-node", null, Neuroglia.Blazor.Dagre.Constants.NodeHeight * 1.5, Neuroglia.Blazor.Dagre.Constants.NodeHeight * 1.5) | ||
{ | ||
|
||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
src/dashboard/Synapse.Dashboard/Components/WorkflowDiagram/EmitTaskNodeViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright © 2024-Present The Synapse Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"), | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using Neuroglia.Blazor.Dagre; | ||
using ServerlessWorkflow.Sdk.Models.Tasks; | ||
|
||
namespace Synapse.Dashboard.Components; | ||
|
||
/// <summary> | ||
/// Represents an emit task node view model | ||
/// </summary> | ||
public class EmitTaskNodeViewModel | ||
: LabeledWorkflowNodeViewModel | ||
{ | ||
|
||
/// <summary> | ||
/// Initializes a new <see cref="EmitTaskNodeViewModel"/> | ||
/// </summary> | ||
public EmitTaskNodeViewModel(KeyValuePair<string, EmitTaskDefinition> task) | ||
: base(task.Key, "emit-task-node", null, Constants.NodeHeight * 1.5, Constants.NodeHeight * 1.5) | ||
{ | ||
|
||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
src/dashboard/Synapse.Dashboard/Components/WorkflowDiagram/EndNodeViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright © 2024-Present The Synapse Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"), | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using Neuroglia.Blazor.Dagre; | ||
|
||
namespace Synapse.Dashboard.Components; | ||
|
||
/// <summary> | ||
/// Represents the object that holds the data required to render the view of a workflow's end node | ||
/// </summary> | ||
public class EndNodeViewModel() | ||
: WorkflowNodeViewModel(string.Empty, "end-node", NodeShape.Circle, WorkflowGraphBuilder.StartEndNodeRadius, WorkflowGraphBuilder.StartEndNodeRadius) | ||
{ | ||
|
||
|
||
|
||
} |
34 changes: 34 additions & 0 deletions
34
src/dashboard/Synapse.Dashboard/Components/WorkflowDiagram/ExtensionTaskNodeViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright © 2024-Present The Synapse Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"), | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using ServerlessWorkflow.Sdk.Models.Tasks; | ||
|
||
namespace Synapse.Dashboard.Components; | ||
|
||
/// <summary> | ||
/// Represents a extension task node view model | ||
/// </summary> | ||
public class ExtensionTaskNodeViewModel | ||
: LabeledWorkflowNodeViewModel | ||
{ | ||
|
||
/// <summary> | ||
/// Initializes a new <see cref="ExtensionTaskNodeViewModel"/> | ||
/// </summary> | ||
public ExtensionTaskNodeViewModel(KeyValuePair<string, ExtensionTaskDefinition> task) | ||
: base(task.Key, "composite-task-node", null, Neuroglia.Blazor.Dagre.Constants.NodeHeight * 1.5, Neuroglia.Blazor.Dagre.Constants.NodeHeight * 1.5) | ||
{ | ||
|
||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
src/dashboard/Synapse.Dashboard/Components/WorkflowDiagram/ForTaskNodeViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright © 2024-Present The Synapse Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"), | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using Neuroglia.Blazor.Dagre; | ||
using ServerlessWorkflow.Sdk.Models.Tasks; | ||
|
||
namespace Synapse.Dashboard.Components; | ||
|
||
/// <summary> | ||
/// Represents a for task node view model | ||
/// </summary> | ||
public class ForTaskNodeViewModel | ||
: LabeledWorkflowNodeViewModel | ||
{ | ||
|
||
/// <summary> | ||
/// Initializes a new <see cref="ForTaskNodeViewModel"/> | ||
/// </summary> | ||
public ForTaskNodeViewModel(KeyValuePair<string, ForTaskDefinition> task) | ||
: base(task.Key, "for-task-node", null, Constants.NodeHeight * 1.5, Constants.NodeHeight * 1.5) | ||
{ | ||
|
||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
src/dashboard/Synapse.Dashboard/Components/WorkflowDiagram/IWorkflowNodeViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright © 2024-Present The Synapse Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"), | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using Synapse.Resources; | ||
|
||
namespace Synapse.Dashboard.Components; | ||
|
||
/// <summary> | ||
/// Defines the fundamentals of a workflow node | ||
/// </summary> | ||
public interface IWorkflowNodeViewModel | ||
{ | ||
|
||
/// <summary> | ||
/// Gets/Sets the number of active <see cref="WorkflowInstance"/>s for which the task described by the node is operative | ||
/// </summary> | ||
int OperativeInstancesCount { get; set; } | ||
|
||
/// <summary> | ||
/// Gets/Sets the number of active faulted <see cref="WorkflowInstance"/>s for which the task described by the node is faulted | ||
/// </summary> | ||
int FaultedInstancesCount { get; set; } | ||
|
||
/// <summary> | ||
/// Resets the operative and faulted instances counts | ||
/// </summary> | ||
void ResetInstancesCount(); | ||
|
||
} |
Oops, something went wrong.