Skip to content

Commit 832b0ca

Browse files
[~] Fix new app servers not visible in LSB after creation CactuseSecurity#2973
1 parent 3ccb560 commit 832b0ca

File tree

4 files changed

+41
-4
lines changed

4 files changed

+41
-4
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
using FWO.Services.EventMediator.Interfaces;
2+
3+
namespace FWO.Services.EventMediator.Events;
4+
5+
public class EditAppServerSavedEvent : IEvent { }
6+

roles/lib/files/FWO.Services/ModellingConnectionHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public async Task ReInit()
173173
}
174174
}
175175

176-
private async Task RefreshObjects()
176+
public async Task RefreshObjects()
177177
{
178178
await RefreshPreselectedInterfaces();
179179
PreselectedInterfaces = ModellingConnectionWrapper.Resolve(await apiConnection.SendQueryAsync<List<ModellingConnectionWrapper>>(ModellingQueries.getSelectedConnections, new { appId = Application.Id })).ToList();

roles/ui/files/FWO.UI/Pages/NetworkModelling/EditAppServer.razor

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
@using System.Text.Json
1+
@using System.Text.Json
22
@using System.Net
3+
@using FWO.Services.EventMediator.Events
4+
@using FWO.Services.EventMediator.Interfaces
5+
@inject IEventMediator EventMediator
36

47
@attribute [Authorize(Roles = $"{Roles.Admin}, {Roles.Auditor}")]
58

@@ -47,7 +50,7 @@
4750
@if (!AppServerHandler.ReadOnly)
4851
{
4952
<button type="button" class="btn btn-sm btn-primary col-sm-3" data-toggle="@("tooltip")"
50-
title="@(userConfig.PureLine("C9017"))"@onclick="Lookup">@(userConfig.GetText("generate_name"))</button>
53+
title="@(userConfig.PureLine("C9017"))"@onclick="Lookup">@(userConfig.GetText("generate_name"))</button>
5154
}
5255
}
5356
else
@@ -106,6 +109,8 @@
106109
private bool firstTry = true;
107110
private bool workInProgress = false;
108111

112+
private readonly static EditAppServerSavedEvent OnEditAppServerSavedEvent = new();
113+
109114
protected override void OnInitialized()
110115
{
111116
try
@@ -171,6 +176,7 @@
171176
await AppServerHandlerChanged.InvokeAsync(AppServerHandler);
172177
Close();
173178
}
179+
EventMediator.Publish<EditAppServerSavedEvent>(OnEditAppServerSavedEvent);
174180
workInProgress = false;
175181
}
176182
catch (Exception exception)

roles/ui/files/FWO.UI/Pages/NetworkModelling/EditConnLeftSide.razor

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
@using FWO.Services.EventMediator.Events
2+
@using FWO.Services.EventMediator.Interfaces
13
@using FWO.Ui.Display
4+
@inject IEventMediator EventMediator
25

36
@inject UserConfig userConfig
47

@@ -15,7 +18,7 @@
1518
<h5>@(userConfig.GetText("network_objects"))</h5>
1619
<div class="form-group row">
1720
<div class="@ColWidthClass()">
18-
<DraggableList AllElements="ConnHandler.AvailableNwElems" @bind-SelectedElements="selectedNwElems"
21+
<DraggableList AllElements="AvailableNwElements" @bind-SelectedElements="selectedNwElems"
1922
HandleDragStart="HandleNwDragStart" Display="@DisplayNwObject" MaxHeight="25"/>
2023
</div>
2124
@if(!OverviewMode)
@@ -284,6 +287,13 @@
284287
}
285288
}
286289

290+
private List<KeyValuePair<int, long>> AvailableNwElements = [];
291+
292+
protected override async Task OnInitializedAsync()
293+
{
294+
EventMediator.Subscribe<EditAppServerSavedEvent>(new Action<EditAppServerSavedEvent>(async _ => await LoadNwElements(refresh: true)));
295+
await LoadNwElements();
296+
}
287297

288298
private string DisplayInterfaceWithIcon(ModellingConnection interf)
289299
{
@@ -684,4 +694,19 @@
684694
{
685695
return OverviewMode ? "col-sm-12" : "col-sm-10";
686696
}
697+
698+
private async Task LoadNwElements(bool refresh = false)
699+
{
700+
if(ConnHandler is null)
701+
{
702+
return;
703+
}
704+
705+
if (refresh)
706+
{
707+
await ConnHandler.RefreshObjects();
708+
}
709+
710+
AvailableNwElements = ConnHandler.AvailableNwElems;
711+
}
687712
}

0 commit comments

Comments
 (0)