Skip to content

Commit

Permalink
fix(Dashboard): fixed try task representation in the graph
Browse files Browse the repository at this point in the history
- added delete button in the instances list

Signed-off-by: Jean-Baptiste Bianchi <[email protected]>
  • Loading branch information
JBBianchi committed Aug 14, 2024
1 parent c1f582e commit 12d8991
Show file tree
Hide file tree
Showing 26 changed files with 299 additions and 115 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.9" />
<PackageReference Include="Neuroglia.Security.AspNetCore" Version="4.12.9" />
<PackageReference Include="Neuroglia.Mediation.AspNetCore" Version="4.12.10" />
<PackageReference Include="Neuroglia.Security.AspNetCore" Version="4.12.10" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.7.0" />
</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.9" />
<PackageReference Include="Neuroglia.Data.Infrastructure.Redis" Version="4.12.9" />
<PackageReference Include="Neuroglia.Data.Infrastructure.ResourceOriented.Redis" Version="4.12.9" />
<PackageReference Include="Neuroglia.Mediation" Version="4.12.9" />
<PackageReference Include="Neuroglia.Plugins" Version="4.12.9" />
<PackageReference Include="Neuroglia.Data.Expressions.Abstractions" Version="4.12.10" />
<PackageReference Include="Neuroglia.Data.Infrastructure.Redis" Version="4.12.10" />
<PackageReference Include="Neuroglia.Data.Infrastructure.ResourceOriented.Redis" Version="4.12.10" />
<PackageReference Include="Neuroglia.Mediation" Version="4.12.10" />
<PackageReference Include="Neuroglia.Plugins" Version="4.12.10" />
<PackageReference Include="ServerlessWorkflow.Sdk.IO" Version="1.0.0-alpha2.8" />
</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.9" />
<PackageReference Include="Neuroglia.Eventing.CloudEvents" Version="4.12.9" />
<PackageReference Include="Neuroglia.Data.Infrastructure.ResourceOriented" Version="4.12.10" />
<PackageReference Include="Neuroglia.Eventing.CloudEvents" Version="4.12.10" />
<PackageReference Include="Semver" Version="2.3.0" />
<PackageReference Include="ServerlessWorkflow.Sdk" Version="1.0.0-alpha2.8" />
</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.7" />
<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.9" />
<PackageReference Include="Neuroglia.Data.Expressions.JQ" Version="4.12.9" />
<PackageReference Include="Neuroglia.Eventing.CloudEvents.AspNetCore" Version="4.12.9" />
<PackageReference Include="Neuroglia.Mediation.AspNetCore" Version="4.12.9" />
<PackageReference Include="Neuroglia.Eventing.CloudEvents.Infrastructure" Version="4.12.9" />
<PackageReference Include="Neuroglia.Security.AspNetCore" Version="4.12.9" />
<PackageReference Include="Neuroglia.Data.Expressions.JavaScript" Version="4.12.10" />
<PackageReference Include="Neuroglia.Data.Expressions.JQ" Version="4.12.10" />
<PackageReference Include="Neuroglia.Eventing.CloudEvents.AspNetCore" Version="4.12.10" />
<PackageReference Include="Neuroglia.Mediation.AspNetCore" Version="4.12.10" />
<PackageReference Include="Neuroglia.Eventing.CloudEvents.Infrastructure" Version="4.12.10" />
<PackageReference Include="Neuroglia.Security.AspNetCore" Version="4.12.10" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.7.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.7.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,11 @@ public void SetLabel(string label)
/// <param name="reference">The new <see cref="DocumentDetailsState.Reference"/> value</param>
public void SetReference(string? reference)
{
var documentJson = this.Get(state => state.DocumentJson);
this.Reduce(state => state with
{
Reference = reference,
DocumentJson = string.Empty,
DocumentJson = reference != null ? string.Empty : documentJson,
Loaded = false,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
<div class="details task-instance-details p-3">
<h6>Details</h6>
<div class="row mb-3">
<div class="col-md-12 col-lg-4">
<div class="col-md-12 col-lg-4 text-truncate" title="@TaskInstance.Name">
<div class="label">Name</div>
@TaskInstance.Name
</div>
<div class="col-md-12 col-lg-4">
<div class="col-md-12 col-lg-4 text-truncate" title="@TaskInstance.Reference">
<div class="label">Reference</div>
@TaskInstance.Reference
</div>
Expand Down
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.

namespace Synapse.Dashboard.Components;

/// <summary>
/// Represents a catch node view model
/// </summary>
public class CatchDoNodeViewModel
: WorkflowClusterViewModel
{
/// <summary>
/// Initializes a new <see cref="CatchDoNodeViewModel"/>
/// </summary>
/// <param name="taskReference">The node task reference</param>
/// <param name="name">The node name</param>
/// <param name="content">The node content</param>
public CatchDoNodeViewModel(string taskReference, string name, string content)
: base(taskReference, new() { Label = name + " - Catch", CssClass = "catch-node" })
{
Content = content;
Symbol = "catch-symbol";
Type = "CATCH";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ namespace Synapse.Dashboard.Components;
/// Represents a catch node view model
/// </summary>
public class CatchNodeViewModel
: WorkflowClusterViewModel
: WorkflowNodeViewModel
{
/// <summary>
/// Initializes a new <see cref="TryTaskNodeViewModel"/>
/// Initializes a new <see cref="CatchNodeViewModel"/>
/// </summary>
/// <param name="taskReference">The node task reference</param>
/// <param name="name">The node name</param>
public CatchNodeViewModel(string taskReference, string name)
: base(taskReference, new() { Label = name, CssClass = "catch-node" })
/// <param name="content">The node content</param>
public CatchNodeViewModel(string taskReference, string name, string content)
: base(taskReference, new() { Label = name + " - Catch", CssClass = "catch-node" })
{
Content = content;
Symbol = "catch-symbol";
Type = "CATCH";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
c 0 -@((Node.RadiusX / 2).ToInvariantString()) @((Node.RadiusX / 2).ToInvariantString()) -@(Node.RadiusX.ToInvariantString()) @(Node.RadiusX.ToInvariantString()) -@(Node.RadiusX.ToInvariantString())
h @((bounds.Width - (Node.RadiusX * 2)).ToInvariantString())
c @((Node.RadiusX / 2).ToInvariantString()) 0 @(Node.RadiusX.ToInvariantString()) @((Node.RadiusY / 2).ToInvariantString()) @(Node.RadiusX.ToInvariantString()) @(Node.RadiusY.ToInvariantString())
v @Constants.ClusterHeight
v @(Constants.ClusterHeight + 10)
h -@(bounds.Width.ToInvariantString())
z"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
(0 - bounds.Height / 4).ToInvariantString() :
!WorkflowNode.IsCluster ?
(0 - _symbolSize / 2).ToInvariantString() :
(0 - (bounds.Height + _symbolSize - Constants.ClusterHeight) / 2).ToInvariantString();
(0 - (bounds.Height + _symbolSize - (Constants.ClusterHeight+10)) / 2).ToInvariantString();

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

<g class="@(WorkflowNode.IsCluster ? "cluster" : "node") @(!string.IsNullOrWhiteSpace(Node.Shape) ? "shape-" + Node.Shape : "shape-rectangle") @Node.CssClass" transform="translate(@((Node.X).ToInvariantString()), @((Node.Y).ToInvariantString()))">
<g id="@Node.Id" class="@(WorkflowNode.IsCluster ? "cluster" : "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 Down
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.

namespace Synapse.Dashboard.Components;

/// <summary>
/// Represents a catch node view model
/// </summary>
public class TryNodeViewModel
: WorkflowClusterViewModel
{
/// <summary>
/// Initializes a new <see cref="TryNodeViewModel"/>
/// </summary>
/// <param name="taskReference">The node task reference</param>
/// <param name="name">The node name</param>
/// <param name="content">The node content</param>
public TryNodeViewModel(string taskReference, string name, string content)
: base(taskReference, new() { Label = name + " - Try", CssClass = "try-node" })
{
Content = content;
Symbol = "try-symbol";
Type = "TRY";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public class TryTaskNodeViewModel
/// <param name="name">The node name</param>
/// <param name="content">The node content</param>
public TryTaskNodeViewModel(string taskReference, string name, string content)
: base(taskReference, new() { Label = name, CssClass = "try-task-node" })
: base(taskReference, new() { Label = name, CssClass = "try-catch-task-node" })
{
Content = content;
Symbol = "try-symbol";
Type = "TRY";
Type = "TRY..CATCH";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

@if (TaskInstance != null) {
<tr @onclick="async _ => await OnToggleRow()" class="cursor-pointer">
<td>@TaskInstance.Name</td>
<td>@TaskInstance.Reference</td>
<td class="text-center"><span class="badge rounded-pill badge rounded-pill border [email protected]() [email protected]()">@(TaskInstance.Status ?? TaskInstanceStatus.Pending)</span></td>
<td class="text-center">@(TaskInstance.StartedAt?.DateTime.RelativeFormat() ?? "-")</td>
<td class="text-center">@(TaskInstance.EndedAt?.DateTime.RelativeFormat() ?? "-")</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
<div class="details workflow-instance-details p-3">
<h6>Details</h6>
<div class="row mb-3">
<div class="col-md-12 col-lg-4">
<div class="col-md-12 col-lg-4 text-truncate" title="@workflowInstance.GetName()">
<div class="label">Name</div>
@workflowInstance.GetName()
</div>
<div class="col-md-12 col-lg-4">
<div class="col-md-12 col-lg-4 text-truncate" title="@workflowInstance.GetNamespace()">
<div class="label">Namespace</div>
@workflowInstance.GetNamespace()
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<tr>
@foreach (var column in columns)
{
if(Columns.Count() == 0 || Columns.Contains(column))
if ((Columns.Count() == 0 && column != "Delete") || Columns.Contains(column))
{
<th class="sticky-header text-@GetColumnAlignment(column)">@(column != "Action" ? column : "")</th>
}
Expand All @@ -65,7 +65,7 @@
<tr @onclick="async _ => await OnShowClickedAsync(instance)" class="cursor-pointer @(ActiveRow == instance.GetName() ? "table-active" : "")">
@foreach (var column in columns)
{
if (Columns.Count() == 0 || Columns.Contains(column))
if ((Columns.Count() == 0 && column != "Delete") || Columns.Contains(column))
{
<td class="text-@GetColumnAlignment(column)">
@switch(column)
Expand Down Expand Up @@ -113,6 +113,9 @@
</ul>
</div>
break;
case "Delete":
<a class="dropdown-item text-danger" href="#" @onclick="async _ => await OnDeleteClickedAsync(instance)" @onclick:preventDefault="true" @onclick:stopPropagation="true"><Icon Name="IconName.Trash" /></a>
break;
default:
break;
}
Expand Down Expand Up @@ -154,7 +157,8 @@
"End Time",
"Duration",
"Operator",
"Actions"
"Actions",
"Delete"
];

/// <summary>
Expand Down
11 changes: 11 additions & 0 deletions src/dashboard/Synapse.Dashboard/Pages/Workflows/Details/Store.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using Neuroglia.Data.Infrastructure.ResourceOriented;
using ServerlessWorkflow.Sdk.Models;
using Synapse.Api.Client.Services;
using Synapse.Resources;
Expand Down Expand Up @@ -351,6 +352,16 @@ public async Task CreateInstanceAsync(string input)
}
await this.Modal!.HideAsync();
}

/// <summary>
/// Delete the provided <see cref="WorkflowInstance"/>
/// </summary>
/// <param name="workflowInstance">The workflow instance to delete</param>
/// <returns></returns>
public async Task DeleteWorkflowInstanceAsync(WorkflowInstance workflowInstance)
{
await this.ApiClient.ManageNamespaced<WorkflowInstance>().DeleteAsync(workflowInstance.GetName(), workflowInstance.GetNamespace()!).ConfigureAwait(false);
}
#endregion

/// <inheritdoc/>
Expand Down
29 changes: 27 additions & 2 deletions src/dashboard/Synapse.Dashboard/Pages/Workflows/Details/View.razor
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
Columns="columns"
OnSearchInput="OnSearchInput"
OnShowDetails="OnShowInstanceDetails"
/>
OnDelete="OnDeleteWorkflowInstanceAsync" />
<Button Outline="true" Color="ButtonColor.Primary" @onclick="async _ => await Store.OnShowCreateInstanceAsync()" class="w-100 mt-3">
<Icon Name="IconName.Plus"/>
</Button>
Expand Down Expand Up @@ -99,6 +99,8 @@

<Modal @ref="Store.Modal" IsVerticallyCentered="true" />

<ConfirmDialog @ref="Dialog" />

@code
{

Expand All @@ -114,7 +116,8 @@
"Namespace",
"Status",
"Start Time",
"End Time"
"End Time",
"Delete"
];

[Parameter] public new string? Namespace { get; set; }
Expand Down Expand Up @@ -204,6 +207,28 @@
</select>
};

/// <summary>
/// Handles the deletion of the targeted <see cref="WorkflowInstance"/>
/// </summary>
/// <param name="instance">The <see cref="WorkflowInstance"/> to delete</param>
protected async Task OnDeleteWorkflowInstanceAsync(WorkflowInstance instance)
{
if (this.Dialog == null) return;
var confirmation = await this.Dialog.ShowAsync(
title: $"Are you sure you want to delete '{instance.Metadata.Name}'?",
message1: $"The workflow instance will be permanently deleted. Are you sure you want to proceed ?",
confirmDialogOptions: new ConfirmDialogOptions()
{
YesButtonColor = ButtonColor.Danger,
YesButtonText = "Delete",
NoButtonText = "Abort",
IsVerticallyCentered = true
}
);
if (!confirmation) return;
await this.Store.DeleteWorkflowInstanceAsync(instance);
}

void OnCreateWorkflowVersion() => this.NavigationManager.NavigateTo($"/workflows/new/{ns}/{name}");

void OnShowInstanceDetails(WorkflowInstance instance) => NavigationManager.NavigateTo($"/workflows/details/{Namespace}/{Name}/{version}/{instance.GetName()}");
Expand Down
Loading

0 comments on commit 12d8991

Please sign in to comment.