Skip to content

Commit

Permalink
display interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
abarz722 committed Mar 19, 2024
1 parent 6b70ef2 commit ca73457
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 4 deletions.
2 changes: 2 additions & 0 deletions roles/database/files/sql/idempotent/fworch-texts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,8 @@ INSERT INTO txt VALUES ('provided_interfaces', 'German', 'Bereitgestellte Schni
INSERT INTO txt VALUES ('provided_interfaces', 'English', 'Provided Interfaces');
INSERT INTO txt VALUES ('remove_interface', 'German', 'Schnittstelle entfernen');
INSERT INTO txt VALUES ('remove_interface', 'English', 'Remove Interface');
INSERT INTO txt VALUES ('display_interface', 'German', 'Schnittstelle darstellen');
INSERT INTO txt VALUES ('display_interface', 'English', 'Display Interface');
INSERT INTO txt VALUES ('use', 'German', 'Benutzen');
INSERT INTO txt VALUES ('use', 'English', 'Use');
INSERT INTO txt VALUES ('services_group', 'German', 'Dienstgruppe');
Expand Down
21 changes: 18 additions & 3 deletions roles/ui/files/FWO.UI/Pages/NetworkModelling/EditConn.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,18 @@
}
<div style="margin-left: @($"{(ConnHandler.ReadOnly ? 0 : sidebarLeftWidth) + 10}px");">
<h3>@(ConnHandler.ActConn.IsInterface ? userConfig.GetText("interface") : (ConnHandler.ActConn.IsCommonService ? userConfig.GetText("common_service") : userConfig.GetText("connection")))</h3>
@if(ConnHandler.ActConn.UsedInterfaceId != null)
@if(ConnHandler.ActConn.UsedInterfaceId != null && !PopupMode)
{
<label class="col-sm-12">@(userConfig.GetText("used_interface")): @ConnHandler.InterfaceName</label>
<div class="col-sm-12 me-auto">
<div class="d-flex flex-row">
<label class="">@(userConfig.GetText("used_interface")): </label>
<h5 class="ml-13">@ConnHandler.InterfaceName</h5>
<button type="button" class="btn btn-sm btn-primary ml-13" @onclick="async () =>
{await ConnHandler.DisplaySelectedInterface(await ConnHandler.GetUsedInterface(ConnHandler.ActConn) ?? new());
await ConnHandlerChanged.InvokeAsync(ConnHandler);}">
@(ConnHandler.DisplayButton("display_interface", Icons.Display))</button>
</div>
</div>
}
<div class="col-sm-11 border rounded m-2 p-2">
<div class="form-group row me-auto">
Expand Down Expand Up @@ -235,7 +244,9 @@
}
</div>
<div class="ml-13 btn-group">
@if(ConnHandler.ReadOnly)
@if(PopupMode)
{}
else if(ConnHandler.ReadOnly)
{
<button type="button" class="btn btn-sm btn-primary" @onclick="Cancel">@(userConfig.GetText("ok"))</button>
}
Expand All @@ -260,6 +271,7 @@
<InProgress Display="workInProgress"/>
<EditServiceGroup @bind-Display="ConnHandler.EditSvcGrpMode" @bind-SvcGroupHandler="ConnHandler.SvcGrpHandler" AddMode="false"/>
<EditAppRole @bind-Display="ConnHandler.EditAppRoleMode" @bind-AppRoleHandler="ConnHandler.AppRoleHandler" AddMode="false"/>
<EditConnPopup @bind-Display="ConnHandler.DisplaySelectedInterfaceMode" ConnHandler="ConnHandler.IntConnHandler"/>
}

@code
Expand All @@ -282,6 +294,9 @@
[Parameter]
public Func<bool> ClosingAction { get; set; } = DefaultInit.DoNothingSync;

[Parameter]
public bool PopupMode { get; set; } = false;


private ModellingDnDContainer Container { get; set; } = new();
private int sidebarInitWidth = GlobalConst.kSidebarLeftWidth + 300;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
@(ConnHandler.DisplayButton("remove", Icons.Delete))</button>
}
}

}
</div>
<br><br>
Expand Down Expand Up @@ -166,6 +165,10 @@
{ConnHandler.RequestRemovePreselectedInterface(selectedInterfaces[0]);
selectedInterfaces = new(); ConnHandlerChanged.InvokeAsync(ConnHandler);}">
@(ConnHandler.DisplayButton("remove", Icons.Delete))</button>
<button type="button" class="btn btn-sm btn-primary" @onclick="async () =>
{await ConnHandler.DisplaySelectedInterface(selectedInterfaces[0]);
await ConnHandlerChanged.InvokeAsync(ConnHandler);}">
@(ConnHandler.DisplayButton("display_interface", Icons.Display))</button>
}
</div>
<br>
Expand All @@ -189,6 +192,8 @@
Application="ConnHandler.Application" Refresh="ConnHandler.RefreshSelectedNwObjects"/>
<ConfirmDelete @bind-Display="ConnHandler.RemoveNwObjectMode" PerformAction="async () => await WrapAsync(ConnHandler.RemoveNwGrpObject)"
Title="@userConfig.GetText("remove_nw_object")" DeleteMessage="@ConnHandler.Message" AllowedRoles="@Roles.Modeller" Remove="true" Enabled="ConnHandler.IsOwner"/>
<EditConnPopup @bind-Display="ConnHandler.DisplaySelectedInterfaceMode" ConnHandler="ConnHandler.IntConnHandler"/>


@code
{
Expand Down
39 changes: 39 additions & 0 deletions roles/ui/files/FWO.UI/Pages/NetworkModelling/EditConnPopup.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@using FWO.Config.Api

@inject ApiConnection apiConnection
@inject UserConfig userConfig


<PopUp Title="@ConnHandler?.Application.Name" Show="@Display" Size=PopupSize.XLarge OnClose="Close">
<Body>
@if (Display)
{
<EditConn Display="true" ConnHandler="ConnHandler" PopupMode="true"/>
}
</Body>
<Footer>
<button type="button" class="btn btn-sm btn-primary" @onclick="Close">@(userConfig.GetText("ok"))</button>
</Footer>
</PopUp>


@code
{
[CascadingParameter]
Action<Exception?, string, string, bool> DisplayMessageInUi { get; set; } = DefaultInit.DoNothing;

[Parameter]
public bool Display { get; set; } = false;

[Parameter]
public EventCallback<bool> DisplayChanged { get; set; }

[Parameter]
public ModellingConnectionHandler ConnHandler { get; set; }

private void Close()
{
Display = false;
DisplayChanged.InvokeAsync(Display);
}
}
11 changes: 11 additions & 0 deletions roles/ui/files/FWO.UI/Services/ModellingConnectionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public class ModellingConnectionHandler : ModellingHandlerBase
public bool SearchNWObjectMode = false;
public bool RemoveNwObjectMode = false;
public bool RemovePreselectedInterfaceMode = false;
public bool DisplaySelectedInterfaceMode = false;
public ModellingConnectionHandler? IntConnHandler;

public List<ModellingAppServer> SrcAppServerToAdd { get; set; } = new();
public List<ModellingAppServer> SrcAppServerToDelete { get; set; } = new();
Expand Down Expand Up @@ -271,6 +273,14 @@ public async Task RemovePreselectedInterface()
}
}

public async Task DisplaySelectedInterface(ModellingConnection interf)
{
FwoOwner? app = allApps.FirstOrDefault(x => x.Id == interf.AppId);
IntConnHandler = new ModellingConnectionHandler(apiConnection, userConfig, app ?? new(), Connections, interf, false, true, DisplayMessageInUi, false);
await IntConnHandler.Init();
DisplaySelectedInterfaceMode = true;
}

public void AppServerToSource(List<ModellingAppServer> srcAppServers)
{
if(!SrcDropForbidden())
Expand Down Expand Up @@ -1095,6 +1105,7 @@ public void Close()
SearchNWObjectMode = false;
RemoveNwObjectMode = false;
RemovePreselectedInterfaceMode = false;
DisplaySelectedInterfaceMode = false;
AddAppRoleMode = false;
EditAppRoleMode = false;
DeleteAppRoleMode = false;
Expand Down
20 changes: 20 additions & 0 deletions roles/ui/files/FWO.UI/Services/ModellingHandlerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,26 @@ public async Task<string> ExtractUsedInterface(ModellingConnection conn)
return interfaceName;
}

public async Task<ModellingConnection?> GetUsedInterface(ModellingConnection conn)
{
try
{
if(conn.UsedInterfaceId != null)
{
List<ModellingConnection> interf = await apiConnection.SendQueryAsync<List<ModellingConnection>>(ModellingQueries.getInterfaceById, new {intId = conn.UsedInterfaceId});
if(interf.Count > 0)
{
return interf[0];
}
}
}
catch (Exception exception)
{
DisplayMessageInUi(exception, userConfig.GetText("fetch_data"), "", true);
}
return null;
}

protected async Task<bool> CheckAppServerInUse(ModellingAppServer appServer)
{
try
Expand Down

0 comments on commit ca73457

Please sign in to comment.