Skip to content

Commit

Permalink
Fixes #1355
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdriscoll committed Dec 10, 2019
1 parent dc058ea commit ced212e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
7 changes: 5 additions & 2 deletions src/UniversalDashboard/Cmdlets/RemoveElementCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand All @@ -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();
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/UniversalDashboard/Server/DashboardHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ public static async Task AddElement(this IHubContext<DashboardHub> hub, string
await hub.Clients.Client(clientId).SendAsync("addElement", parentComponentId, element);
}

public static async Task RemoveElement(this IHubContext<DashboardHub> hub, string clientId, string componentId)
public static async Task RemoveElement(this IHubContext<DashboardHub> 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<DashboardHub> hub, string componentId)
public static async Task RemoveElement(this IHubContext<DashboardHub> 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<DashboardHub> hub, string clientId, string componentId)
Expand Down
5 changes: 3 additions & 2 deletions src/client/src/app/ud-dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
});

Expand Down

0 comments on commit ced212e

Please sign in to comment.