From ced212e88d837637f69b88ab8e098a90c3f12faa Mon Sep 17 00:00:00 2001 From: Adam Driscoll Date: Tue, 10 Dec 2019 09:50:09 -0700 Subject: [PATCH] Fixes #1355 --- src/UniversalDashboard/Cmdlets/RemoveElementCommand.cs | 7 +++++-- src/UniversalDashboard/Server/DashboardHub.cs | 8 ++++---- src/client/src/app/ud-dashboard.jsx | 5 +++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/UniversalDashboard/Cmdlets/RemoveElementCommand.cs b/src/UniversalDashboard/Cmdlets/RemoveElementCommand.cs index f8ac4270..000b8317 100644 --- a/src/UniversalDashboard/Cmdlets/RemoveElementCommand.cs +++ b/src/UniversalDashboard/Cmdlets/RemoveElementCommand.cs @@ -15,6 +15,9 @@ public class RemoveElementCommand : PSCmdlet [Parameter(Mandatory = true)] public string Id { get; set; } + [Parameter()] + public string ParentId { get; set; } + [Parameter] public SwitchParameter Broadcast { get; set; } @@ -24,12 +27,12 @@ protected override void EndProcessing() if (Broadcast) { - hub.RemoveElement(Id).Wait(); + hub.RemoveElement(Id, ParentId).Wait(); } else { var connectionId = this.GetVariableValue("ConnectionId") as string; - hub.RemoveElement(Id).Wait(); + hub.RemoveElement(Id, ParentId).Wait(); } } } diff --git a/src/UniversalDashboard/Server/DashboardHub.cs b/src/UniversalDashboard/Server/DashboardHub.cs index 9f7fe6fc..33483652 100644 --- a/src/UniversalDashboard/Server/DashboardHub.cs +++ b/src/UniversalDashboard/Server/DashboardHub.cs @@ -84,14 +84,14 @@ public static async Task AddElement(this IHubContext hub, string await hub.Clients.Client(clientId).SendAsync("addElement", parentComponentId, element); } - public static async Task RemoveElement(this IHubContext hub, string clientId, string componentId) + public static async Task RemoveElement(this IHubContext hub, string clientId, string componentId, string parentId) { - await hub.Clients.Client(clientId).SendAsync("removeElement", componentId); + await hub.Clients.Client(clientId).SendAsync("removeElement", componentId, parentId); } - public static async Task RemoveElement(this IHubContext hub, string componentId) + public static async Task RemoveElement(this IHubContext hub, string componentId, string parentId) { - await hub.Clients.All.SendAsync("removeElement", componentId); + await hub.Clients.All.SendAsync("removeElement", componentId, parentId); } public static async Task ClearElement(this IHubContext hub, string clientId, string componentId) diff --git a/src/client/src/app/ud-dashboard.jsx b/src/client/src/app/ud-dashboard.jsx index 66e0b9dd..60172fd0 100644 --- a/src/client/src/app/ud-dashboard.jsx +++ b/src/client/src/app/ud-dashboard.jsx @@ -77,10 +77,11 @@ export default class UdDashboard extends React.Component { }); }); - connection.on('removeElement', (componentId) => { + connection.on('removeElement', (componentId, parentId) => { PubSub.publish(componentId, { type: "removeElement", - componentId: componentId + componentId: componentId, + parentId: parentId }); });