Skip to content

Commit

Permalink
Merge pull request #451 from serverlessworkflow/fix-dashboard-task-na…
Browse files Browse the repository at this point in the history
…vigation

Improved task hierarchy navigation using a "tree view" in the Dashboard
  • Loading branch information
cdavernas authored Oct 31, 2024
2 parents bb98d91 + 6a7de2f commit 60ed01d
Show file tree
Hide file tree
Showing 20 changed files with 69 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<NeutralLanguage>en</NeutralLanguage>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>alpha5.1</VersionSuffix>
<VersionSuffix>alpha5.2</VersionSuffix>
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
<FileVersion>$(VersionPrefix)</FileVersion>
<Authors>The Synapse Authors</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<NeutralLanguage>en</NeutralLanguage>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>alpha5.1</VersionSuffix>
<VersionSuffix>alpha5.2</VersionSuffix>
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
<FileVersion>$(VersionPrefix)</FileVersion>
<Authors>The Synapse Authors</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<NeutralLanguage>en</NeutralLanguage>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>alpha5.1</VersionSuffix>
<VersionSuffix>alpha5.2</VersionSuffix>
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
<FileVersion>$(VersionPrefix)</FileVersion>
<Authors>The Synapse Authors</Authors>
Expand Down
2 changes: 1 addition & 1 deletion src/api/Synapse.Api.Http/Synapse.Api.Http.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<OutputType>Library</OutputType>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>alpha5.1</VersionSuffix>
<VersionSuffix>alpha5.2</VersionSuffix>
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
<FileVersion>$(VersionPrefix)</FileVersion>
<Authors>The Synapse Authors</Authors>
Expand Down
2 changes: 1 addition & 1 deletion src/api/Synapse.Api.Server/Synapse.Api.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<NeutralLanguage>en</NeutralLanguage>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>alpha5.1</VersionSuffix>
<VersionSuffix>alpha5.2</VersionSuffix>
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
<FileVersion>$(VersionPrefix)</FileVersion>
<Authors>The Synapse Authors</Authors>
Expand Down
2 changes: 1 addition & 1 deletion src/cli/Synapse.Cli/Synapse.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<NeutralLanguage>en</NeutralLanguage>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>alpha5.1</VersionSuffix>
<VersionSuffix>alpha5.2</VersionSuffix>
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
<FileVersion>$(VersionPrefix)</FileVersion>
<Authors>The Synapse Authors</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<NeutralLanguage>en</NeutralLanguage>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>alpha5.1</VersionSuffix>
<VersionSuffix>alpha5.2</VersionSuffix>
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
<FileVersion>$(VersionPrefix)</FileVersion>
<Authors>The Synapse Authors</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<NeutralLanguage>en</NeutralLanguage>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>alpha5.1</VersionSuffix>
<VersionSuffix>alpha5.2</VersionSuffix>
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
<FileVersion>$(VersionPrefix)</FileVersion>
<Authors>The Synapse Authors</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<NeutralLanguage>en</NeutralLanguage>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>alpha5.1</VersionSuffix>
<VersionSuffix>alpha5.2</VersionSuffix>
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
<FileVersion>$(VersionPrefix)</FileVersion>
<Authors>The Synapse Authors</Authors>
Expand Down
2 changes: 1 addition & 1 deletion src/core/Synapse.Core/Synapse.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<NeutralLanguage>en</NeutralLanguage>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>alpha5.1</VersionSuffix>
<VersionSuffix>alpha5.2</VersionSuffix>
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
<FileVersion>$(VersionPrefix)</FileVersion>
<Authors>The Synapse Authors</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<NeutralLanguage>en</NeutralLanguage>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>alpha5.1</VersionSuffix>
<VersionSuffix>alpha5.2</VersionSuffix>
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
<FileVersion>$(VersionPrefix)</FileVersion>
<Authors>The Synapse Authors</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,32 +71,6 @@
<DocumentDetails Label='Output' Reference="@TaskInstance.OutputReference" />
}
</div>
<h6 class="pt-3">Executed Tasks</h6>
@if (SubTasks == null || SubTasks.Count() == 0)
{
@("-")
}
else
{
<table class="table table-hover">
<thead>
<tr>
<th>Name</th>
<th class="text-center">Status</th>
<th class="text-center">Start Time</th>
<th class="text-center">End Time</th>
<th class="text-center">Duration</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var task in SubTasks)
{
<TaskInstanceRow TaskInstance="@task" Tasks="@Tasks"/>
}
</tbody>
</table>
}
<h6 class="pt-3">Runs</h6>
@if (TaskInstance.Runs == null || TaskInstance.Runs.Count == 0)
{
Expand Down Expand Up @@ -163,13 +137,4 @@

@code {
[Parameter] public TaskInstance? TaskInstance { get; set; }
[Parameter] public IEnumerable<TaskInstance>? Tasks { get; set; }

IEnumerable<TaskInstance> SubTasks
{
get
{
return TaskInstance == null ? [] : (this.Tasks ?? []).Where(t => t.ParentId == TaskInstance.Id);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@

@if (TaskInstance != null) {
<tr @onclick="async _ => await OnToggleRow()" class="cursor-pointer">
<td>
@if (HasChildren) {
@for(var i = 0; i<Depth; i++)
{
<span class="ps-2"></span>
}
<span @onclick="ToggleChildrenVisibility" @onclick:stopPropagation="true">
<Icon Name="showChildren ? IconName.Dash : IconName.Plus" Class="cursor-pointer" />
</span>
}
</td>
<td>@TaskInstance.Reference</td>
<td class="text-center"><span class="badge rounded-pill badge rounded-pill border @TaskInstance.Status.GetColorClass()">@(TaskInstance.Status ?? TaskInstanceStatus.Pending)</span></td>
<td class="text-center">@(TaskInstance.StartedAt?.RelativeFormat() ?? "-")</td>
Expand All @@ -38,7 +49,7 @@
<tr>
<td colspan="999">
<Collapse @ref="collapse">
<TaskInstanceDetails TaskInstance="@TaskInstance" Tasks="@Tasks" />
<TaskInstanceDetails TaskInstance="@TaskInstance" />
</Collapse>
</td>
</tr>
Expand All @@ -47,9 +58,12 @@

@code {
[Parameter] public TaskInstance? TaskInstance { get; set; }
[Parameter] public IEnumerable<TaskInstance>? Tasks { get; set; }
[Parameter] public bool HasChildren { get; set; }
[Parameter] public EventCallback<( string, int )> OnToggleChildrenClick { get; set; }
[Parameter] public int Depth { get; set; }
bool isOpen = false;
Collapse? collapse;
bool showChildren = false;

async Task OnToggleRow()
{
Expand All @@ -62,4 +76,13 @@
}
StateHasChanged();
}

async Task ToggleChildrenVisibility()
{
showChildren = !showChildren;
if (OnToggleChildrenClick.HasDelegate && TaskInstance != null)
{
await OnToggleChildrenClick.InvokeAsync((TaskInstance.Id, Depth ));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<table class="table table-hover">
<thead>
<tr>
<th></th>
<th>Name</th>
<th class="text-center">Status</th>
<th class="text-center">Start Time</th>
Expand All @@ -86,9 +87,9 @@
</tr>
</thead>
<tbody>
@foreach (var task in workflowInstance.Status.Tasks.Where(task => string.IsNullOrWhiteSpace(task.ParentId)) )
@foreach (var task in workflowInstance.Status.Tasks.Where(task => string.IsNullOrWhiteSpace(task.ParentId) || expandedTasks.ContainsKey(task.ParentId)) )
{
<TaskInstanceRow TaskInstance="@task" Tasks="@workflowInstance.Status.Tasks" />
<TaskInstanceRow TaskInstance="@task" Depth="string.IsNullOrWhiteSpace(task.ParentId) ? 0 : (expandedTasks[task.ParentId] + 1)" HasChildren="workflowInstance.Status.Tasks.Any(t => t.ParentId == task.Id)" OnToggleChildrenClick="ToggleChildrenTask" />
}
</tbody>
</table>
Expand Down Expand Up @@ -186,6 +187,7 @@
@code {
private WorkflowInstance? workflowInstance;
[Parameter] public WorkflowInstance? WorkflowInstance { get; set; }
private Dictionary<string, int> expandedTasks = new();

protected override void OnParametersSet()
{
Expand All @@ -204,4 +206,27 @@
shouldRender = false;
return true;
}

protected void CloseChildrenTask(string taskId)
{
if (expandedTasks.ContainsKey(taskId))
{
expandedTasks.Remove(taskId);
}
foreach (var child in workflowInstance?.Status?.Tasks?.Where(task => task.ParentId == taskId) ?? [])
{
CloseChildrenTask(child.Id);
}
}

protected void ToggleChildrenTask((string, int) e)
{
(string taskId, int depth) = e;
if (expandedTasks.ContainsKey(taskId))
{
CloseChildrenTask(taskId);
}
else expandedTasks.Add(taskId, depth);
shouldRender = true;
}
}
2 changes: 1 addition & 1 deletion src/operator/Synapse.Operator/Synapse.Operator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<NeutralLanguage>en</NeutralLanguage>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>alpha5.1</VersionSuffix>
<VersionSuffix>alpha5.2</VersionSuffix>
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
<FileVersion>$(VersionPrefix)</FileVersion>
<Authors>The Synapse Authors</Authors>
Expand Down
2 changes: 1 addition & 1 deletion src/runner/Synapse.Runner/Synapse.Runner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<NeutralLanguage>en</NeutralLanguage>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>alpha5.1</VersionSuffix>
<VersionSuffix>alpha5.2</VersionSuffix>
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
<FileVersion>$(VersionPrefix)</FileVersion>
<Authors>The Synapse Authors</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<NeutralLanguage>en</NeutralLanguage>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>alpha5.1</VersionSuffix>
<VersionSuffix>alpha5.2</VersionSuffix>
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
<FileVersion>$(VersionPrefix)</FileVersion>
<Authors>The Synapse Authors</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<NeutralLanguage>en</NeutralLanguage>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>alpha5.1</VersionSuffix>
<VersionSuffix>alpha5.2</VersionSuffix>
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
<FileVersion>$(VersionPrefix)</FileVersion>
<Authors>The Synapse Authors</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<NeutralLanguage>en</NeutralLanguage>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>alpha5.1</VersionSuffix>
<VersionSuffix>alpha5.2</VersionSuffix>
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
<FileVersion>$(VersionPrefix)</FileVersion>
<Authors>The Synapse Authors</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<NeutralLanguage>en</NeutralLanguage>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>alpha5.1</VersionSuffix>
<VersionSuffix>alpha5.2</VersionSuffix>
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
<FileVersion>$(VersionPrefix)</FileVersion>
<Authors>The Synapse Authors</Authors>
Expand Down

0 comments on commit 60ed01d

Please sign in to comment.