feat: add GrpcNodeAAddress/GrpcNodeBAddress to Site entity, CLI, and UI
This commit is contained in:
@@ -53,6 +53,8 @@ public static class SiteCommands
|
|||||||
var descOption = new Option<string?>("--description") { Description = "Site description" };
|
var descOption = new Option<string?>("--description") { Description = "Site description" };
|
||||||
var nodeAOption = new Option<string?>("--node-a-address") { Description = "Akka address for Node A" };
|
var nodeAOption = new Option<string?>("--node-a-address") { Description = "Akka address for Node A" };
|
||||||
var nodeBOption = new Option<string?>("--node-b-address") { Description = "Akka address for Node B" };
|
var nodeBOption = new Option<string?>("--node-b-address") { Description = "Akka address for Node B" };
|
||||||
|
var grpcNodeAOption = new Option<string?>("--grpc-node-a-address") { Description = "gRPC address for Node A" };
|
||||||
|
var grpcNodeBOption = new Option<string?>("--grpc-node-b-address") { Description = "gRPC address for Node B" };
|
||||||
|
|
||||||
var cmd = new Command("create") { Description = "Create a new site" };
|
var cmd = new Command("create") { Description = "Create a new site" };
|
||||||
cmd.Add(nameOption);
|
cmd.Add(nameOption);
|
||||||
@@ -60,6 +62,8 @@ public static class SiteCommands
|
|||||||
cmd.Add(descOption);
|
cmd.Add(descOption);
|
||||||
cmd.Add(nodeAOption);
|
cmd.Add(nodeAOption);
|
||||||
cmd.Add(nodeBOption);
|
cmd.Add(nodeBOption);
|
||||||
|
cmd.Add(grpcNodeAOption);
|
||||||
|
cmd.Add(grpcNodeBOption);
|
||||||
cmd.SetAction(async (ParseResult result) =>
|
cmd.SetAction(async (ParseResult result) =>
|
||||||
{
|
{
|
||||||
var name = result.GetValue(nameOption)!;
|
var name = result.GetValue(nameOption)!;
|
||||||
@@ -67,9 +71,11 @@ public static class SiteCommands
|
|||||||
var desc = result.GetValue(descOption);
|
var desc = result.GetValue(descOption);
|
||||||
var nodeA = result.GetValue(nodeAOption);
|
var nodeA = result.GetValue(nodeAOption);
|
||||||
var nodeB = result.GetValue(nodeBOption);
|
var nodeB = result.GetValue(nodeBOption);
|
||||||
|
var grpcNodeA = result.GetValue(grpcNodeAOption);
|
||||||
|
var grpcNodeB = result.GetValue(grpcNodeBOption);
|
||||||
return await CommandHelpers.ExecuteCommandAsync(
|
return await CommandHelpers.ExecuteCommandAsync(
|
||||||
result, urlOption, formatOption, usernameOption, passwordOption,
|
result, urlOption, formatOption, usernameOption, passwordOption,
|
||||||
new CreateSiteCommand(name, identifier, desc, nodeA, nodeB));
|
new CreateSiteCommand(name, identifier, desc, nodeA, nodeB, grpcNodeA, grpcNodeB));
|
||||||
});
|
});
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
@@ -81,6 +87,8 @@ public static class SiteCommands
|
|||||||
var descOption = new Option<string?>("--description") { Description = "Site description" };
|
var descOption = new Option<string?>("--description") { Description = "Site description" };
|
||||||
var nodeAOption = new Option<string?>("--node-a-address") { Description = "Akka address for Node A" };
|
var nodeAOption = new Option<string?>("--node-a-address") { Description = "Akka address for Node A" };
|
||||||
var nodeBOption = new Option<string?>("--node-b-address") { Description = "Akka address for Node B" };
|
var nodeBOption = new Option<string?>("--node-b-address") { Description = "Akka address for Node B" };
|
||||||
|
var grpcNodeAOption = new Option<string?>("--grpc-node-a-address") { Description = "gRPC address for Node A" };
|
||||||
|
var grpcNodeBOption = new Option<string?>("--grpc-node-b-address") { Description = "gRPC address for Node B" };
|
||||||
|
|
||||||
var cmd = new Command("update") { Description = "Update an existing site" };
|
var cmd = new Command("update") { Description = "Update an existing site" };
|
||||||
cmd.Add(idOption);
|
cmd.Add(idOption);
|
||||||
@@ -88,6 +96,8 @@ public static class SiteCommands
|
|||||||
cmd.Add(descOption);
|
cmd.Add(descOption);
|
||||||
cmd.Add(nodeAOption);
|
cmd.Add(nodeAOption);
|
||||||
cmd.Add(nodeBOption);
|
cmd.Add(nodeBOption);
|
||||||
|
cmd.Add(grpcNodeAOption);
|
||||||
|
cmd.Add(grpcNodeBOption);
|
||||||
cmd.SetAction(async (ParseResult result) =>
|
cmd.SetAction(async (ParseResult result) =>
|
||||||
{
|
{
|
||||||
var id = result.GetValue(idOption);
|
var id = result.GetValue(idOption);
|
||||||
@@ -95,9 +105,11 @@ public static class SiteCommands
|
|||||||
var desc = result.GetValue(descOption);
|
var desc = result.GetValue(descOption);
|
||||||
var nodeA = result.GetValue(nodeAOption);
|
var nodeA = result.GetValue(nodeAOption);
|
||||||
var nodeB = result.GetValue(nodeBOption);
|
var nodeB = result.GetValue(nodeBOption);
|
||||||
|
var grpcNodeA = result.GetValue(grpcNodeAOption);
|
||||||
|
var grpcNodeB = result.GetValue(grpcNodeBOption);
|
||||||
return await CommandHelpers.ExecuteCommandAsync(
|
return await CommandHelpers.ExecuteCommandAsync(
|
||||||
result, urlOption, formatOption, usernameOption, passwordOption,
|
result, urlOption, formatOption, usernameOption, passwordOption,
|
||||||
new UpdateSiteCommand(id, name, desc, nodeA, nodeB));
|
new UpdateSiteCommand(id, name, desc, nodeA, nodeB, grpcNodeA, grpcNodeB));
|
||||||
});
|
});
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,18 @@
|
|||||||
placeholder="akka.tcp://scadalink@host:port/user/site-communication" />
|
placeholder="akka.tcp://scadalink@host:port/user/site-communication" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row g-2 align-items-end mt-1">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="form-label small">gRPC Node A Address</label>
|
||||||
|
<input type="text" class="form-control form-control-sm" @bind="_formGrpcNodeAAddress"
|
||||||
|
placeholder="http://host:8083" />
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="form-label small">gRPC Node B Address (optional)</label>
|
||||||
|
<input type="text" class="form-control form-control-sm" @bind="_formGrpcNodeBAddress"
|
||||||
|
placeholder="http://host:8083" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@if (_formError != null)
|
@if (_formError != null)
|
||||||
{
|
{
|
||||||
<div class="text-danger small mt-1">@_formError</div>
|
<div class="text-danger small mt-1">@_formError</div>
|
||||||
@@ -92,6 +104,8 @@
|
|||||||
<th>Description</th>
|
<th>Description</th>
|
||||||
<th>Node A</th>
|
<th>Node A</th>
|
||||||
<th>Node B</th>
|
<th>Node B</th>
|
||||||
|
<th>gRPC Node A</th>
|
||||||
|
<th>gRPC Node B</th>
|
||||||
<th>Data Connections</th>
|
<th>Data Connections</th>
|
||||||
<th style="width: 260px;">Actions</th>
|
<th style="width: 260px;">Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -100,7 +114,7 @@
|
|||||||
@if (_sites.Count == 0)
|
@if (_sites.Count == 0)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="8" class="text-muted text-center">No sites configured.</td>
|
<td colspan="10" class="text-muted text-center">No sites configured.</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
@foreach (var site in _sites)
|
@foreach (var site in _sites)
|
||||||
@@ -112,6 +126,8 @@
|
|||||||
<td class="text-muted small">@(site.Description ?? "—")</td>
|
<td class="text-muted small">@(site.Description ?? "—")</td>
|
||||||
<td class="small text-truncate" style="max-width: 200px;" title="@site.NodeAAddress">@(site.NodeAAddress ?? "—")</td>
|
<td class="small text-truncate" style="max-width: 200px;" title="@site.NodeAAddress">@(site.NodeAAddress ?? "—")</td>
|
||||||
<td class="small text-truncate" style="max-width: 200px;" title="@site.NodeBAddress">@(site.NodeBAddress ?? "—")</td>
|
<td class="small text-truncate" style="max-width: 200px;" title="@site.NodeBAddress">@(site.NodeBAddress ?? "—")</td>
|
||||||
|
<td class="small text-truncate" style="max-width: 200px;" title="@site.GrpcNodeAAddress">@(site.GrpcNodeAAddress ?? "—")</td>
|
||||||
|
<td class="small text-truncate" style="max-width: 200px;" title="@site.GrpcNodeBAddress">@(site.GrpcNodeBAddress ?? "—")</td>
|
||||||
<td>
|
<td>
|
||||||
@{
|
@{
|
||||||
var conns = _siteConnections.GetValueOrDefault(site.Id);
|
var conns = _siteConnections.GetValueOrDefault(site.Id);
|
||||||
@@ -163,6 +179,8 @@
|
|||||||
private string? _formDescription;
|
private string? _formDescription;
|
||||||
private string? _formNodeAAddress;
|
private string? _formNodeAAddress;
|
||||||
private string? _formNodeBAddress;
|
private string? _formNodeBAddress;
|
||||||
|
private string? _formGrpcNodeAAddress;
|
||||||
|
private string? _formGrpcNodeBAddress;
|
||||||
private string? _formError;
|
private string? _formError;
|
||||||
|
|
||||||
private bool _deploying;
|
private bool _deploying;
|
||||||
@@ -207,6 +225,8 @@
|
|||||||
_formDescription = null;
|
_formDescription = null;
|
||||||
_formNodeAAddress = null;
|
_formNodeAAddress = null;
|
||||||
_formNodeBAddress = null;
|
_formNodeBAddress = null;
|
||||||
|
_formGrpcNodeAAddress = null;
|
||||||
|
_formGrpcNodeBAddress = null;
|
||||||
_formError = null;
|
_formError = null;
|
||||||
_showForm = true;
|
_showForm = true;
|
||||||
}
|
}
|
||||||
@@ -219,6 +239,8 @@
|
|||||||
_formDescription = site.Description;
|
_formDescription = site.Description;
|
||||||
_formNodeAAddress = site.NodeAAddress;
|
_formNodeAAddress = site.NodeAAddress;
|
||||||
_formNodeBAddress = site.NodeBAddress;
|
_formNodeBAddress = site.NodeBAddress;
|
||||||
|
_formGrpcNodeAAddress = site.GrpcNodeAAddress;
|
||||||
|
_formGrpcNodeBAddress = site.GrpcNodeBAddress;
|
||||||
_formError = null;
|
_formError = null;
|
||||||
_showForm = true;
|
_showForm = true;
|
||||||
}
|
}
|
||||||
@@ -248,6 +270,8 @@
|
|||||||
_editingSite.Description = _formDescription?.Trim();
|
_editingSite.Description = _formDescription?.Trim();
|
||||||
_editingSite.NodeAAddress = _formNodeAAddress?.Trim();
|
_editingSite.NodeAAddress = _formNodeAAddress?.Trim();
|
||||||
_editingSite.NodeBAddress = _formNodeBAddress?.Trim();
|
_editingSite.NodeBAddress = _formNodeBAddress?.Trim();
|
||||||
|
_editingSite.GrpcNodeAAddress = _formGrpcNodeAAddress?.Trim();
|
||||||
|
_editingSite.GrpcNodeBAddress = _formGrpcNodeBAddress?.Trim();
|
||||||
await SiteRepository.UpdateSiteAsync(_editingSite);
|
await SiteRepository.UpdateSiteAsync(_editingSite);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -261,7 +285,9 @@
|
|||||||
{
|
{
|
||||||
Description = _formDescription?.Trim(),
|
Description = _formDescription?.Trim(),
|
||||||
NodeAAddress = _formNodeAAddress?.Trim(),
|
NodeAAddress = _formNodeAAddress?.Trim(),
|
||||||
NodeBAddress = _formNodeBAddress?.Trim()
|
NodeBAddress = _formNodeBAddress?.Trim(),
|
||||||
|
GrpcNodeAAddress = _formGrpcNodeAAddress?.Trim(),
|
||||||
|
GrpcNodeBAddress = _formGrpcNodeBAddress?.Trim()
|
||||||
};
|
};
|
||||||
await SiteRepository.AddSiteAsync(site);
|
await SiteRepository.AddSiteAsync(site);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ public class Site
|
|||||||
public string? Description { get; set; }
|
public string? Description { get; set; }
|
||||||
public string? NodeAAddress { get; set; }
|
public string? NodeAAddress { get; set; }
|
||||||
public string? NodeBAddress { get; set; }
|
public string? NodeBAddress { get; set; }
|
||||||
|
public string? GrpcNodeAAddress { get; set; }
|
||||||
|
public string? GrpcNodeBAddress { get; set; }
|
||||||
|
|
||||||
public Site(string name, string siteIdentifier)
|
public Site(string name, string siteIdentifier)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ namespace ScadaLink.Commons.Messages.Management;
|
|||||||
|
|
||||||
public record ListSitesCommand;
|
public record ListSitesCommand;
|
||||||
public record GetSiteCommand(int SiteId);
|
public record GetSiteCommand(int SiteId);
|
||||||
public record CreateSiteCommand(string Name, string SiteIdentifier, string? Description, string? NodeAAddress = null, string? NodeBAddress = null);
|
public record CreateSiteCommand(string Name, string SiteIdentifier, string? Description, string? NodeAAddress = null, string? NodeBAddress = null, string? GrpcNodeAAddress = null, string? GrpcNodeBAddress = null);
|
||||||
public record UpdateSiteCommand(int SiteId, string Name, string? Description, string? NodeAAddress = null, string? NodeBAddress = null);
|
public record UpdateSiteCommand(int SiteId, string Name, string? Description, string? NodeAAddress = null, string? NodeBAddress = null, string? GrpcNodeAAddress = null, string? GrpcNodeBAddress = null);
|
||||||
public record DeleteSiteCommand(int SiteId);
|
public record DeleteSiteCommand(int SiteId);
|
||||||
public record ListAreasCommand(int SiteId);
|
public record ListAreasCommand(int SiteId);
|
||||||
public record CreateAreaCommand(int SiteId, string Name, int? ParentAreaId);
|
public record CreateAreaCommand(int SiteId, string Name, int? ParentAreaId);
|
||||||
|
|||||||
@@ -596,7 +596,9 @@ public class ManagementActor : ReceiveActor
|
|||||||
{
|
{
|
||||||
Description = cmd.Description,
|
Description = cmd.Description,
|
||||||
NodeAAddress = cmd.NodeAAddress,
|
NodeAAddress = cmd.NodeAAddress,
|
||||||
NodeBAddress = cmd.NodeBAddress
|
NodeBAddress = cmd.NodeBAddress,
|
||||||
|
GrpcNodeAAddress = cmd.GrpcNodeAAddress,
|
||||||
|
GrpcNodeBAddress = cmd.GrpcNodeBAddress
|
||||||
};
|
};
|
||||||
await repo.AddSiteAsync(site);
|
await repo.AddSiteAsync(site);
|
||||||
await repo.SaveChangesAsync();
|
await repo.SaveChangesAsync();
|
||||||
@@ -615,6 +617,8 @@ public class ManagementActor : ReceiveActor
|
|||||||
site.Description = cmd.Description;
|
site.Description = cmd.Description;
|
||||||
site.NodeAAddress = cmd.NodeAAddress;
|
site.NodeAAddress = cmd.NodeAAddress;
|
||||||
site.NodeBAddress = cmd.NodeBAddress;
|
site.NodeBAddress = cmd.NodeBAddress;
|
||||||
|
site.GrpcNodeAAddress = cmd.GrpcNodeAAddress;
|
||||||
|
site.GrpcNodeBAddress = cmd.GrpcNodeBAddress;
|
||||||
await repo.UpdateSiteAsync(site);
|
await repo.UpdateSiteAsync(site);
|
||||||
await repo.SaveChangesAsync();
|
await repo.SaveChangesAsync();
|
||||||
var commService = sp.GetService<CommunicationService>();
|
var commService = sp.GetService<CommunicationService>();
|
||||||
|
|||||||
Reference in New Issue
Block a user