7b0b9c7365
Solution + 23 src projects + 26 test projects renamed; folders, csproj, namespaces, and ScadaLinkDbContext/ScadaBridgeDbContext class updated. ActorSystem "scadalink" → "scadabridge", Akka seed-node URLs migrated. SQL roles/logins, LDAP domains, CLI command name, and CLI config dir (~/.scadalink → ~/.scadabridge) also renamed. Build green; 5 Host.Tests fail awaiting SQL login rename in next commit. Pre-existing StaleTagMonitor timing flakes unchanged. Rename script committed at tools/rename-to-scadabridge.sh.
177 lines
6.9 KiB
Plaintext
177 lines
6.9 KiB
Plaintext
@page "/admin/sites/create"
|
|
@page "/admin/sites/{Id:int}/edit"
|
|
@using ZB.MOM.WW.ScadaBridge.Security
|
|
@using ZB.MOM.WW.ScadaBridge.Commons.Entities.Sites
|
|
@using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories
|
|
@using ZB.MOM.WW.ScadaBridge.Communication
|
|
@attribute [Authorize(Policy = AuthorizationPolicies.RequireAdmin)]
|
|
@inject ISiteRepository SiteRepository
|
|
@inject CommunicationService CommunicationService
|
|
@inject NavigationManager NavigationManager
|
|
|
|
<div class="container-fluid mt-3">
|
|
<div class="mb-3">
|
|
<button class="btn btn-outline-secondary btn-sm" @onclick="GoBack">
|
|
← Back
|
|
</button>
|
|
</div>
|
|
|
|
<ToastNotification @ref="_toast" />
|
|
|
|
<div class="card mb-3">
|
|
<div class="card-body">
|
|
<div class="d-flex justify-content-between align-items-start">
|
|
<h6 class="card-title">@(IsEditMode ? "Edit Site" : "Add Site")</h6>
|
|
@* Bundle D (#23 M7-T12) drill-in: deep-link into the central Audit
|
|
Log pre-filtered to this site's events. AuditEvent.SourceSiteId
|
|
stores the SiteIdentifier (string), so we pass that through. *@
|
|
@if (IsEditMode && !string.IsNullOrWhiteSpace(_formIdentifier))
|
|
{
|
|
<a class="btn btn-outline-secondary btn-sm"
|
|
href="/audit/log?site=@Uri.EscapeDataString(_formIdentifier)"
|
|
data-test="audit-link">
|
|
Recent audit activity
|
|
</a>
|
|
}
|
|
</div>
|
|
<div class="mb-2">
|
|
<label class="form-label small">Identifier</label>
|
|
<input type="text" class="form-control form-control-sm" @bind="_formIdentifier"
|
|
disabled="@IsEditMode" />
|
|
</div>
|
|
<div class="mb-2">
|
|
<label class="form-label small">Name</label>
|
|
<input type="text" class="form-control form-control-sm" @bind="_formName" />
|
|
</div>
|
|
<div class="mb-3">
|
|
<label class="form-label small">Description</label>
|
|
<input type="text" class="form-control form-control-sm" @bind="_formDescription" />
|
|
</div>
|
|
|
|
<h6 class="text-muted border-bottom pb-1">Node A</h6>
|
|
<div class="mb-2">
|
|
<label class="form-label small">Akka Address</label>
|
|
<input type="text" class="form-control form-control-sm" @bind="_formNodeAAddress"
|
|
placeholder="akka.tcp://scadabridge@host:port/user/site-communication" />
|
|
</div>
|
|
<div class="mb-3">
|
|
<label class="form-label small">gRPC Address</label>
|
|
<input type="text" class="form-control form-control-sm" @bind="_formGrpcNodeAAddress"
|
|
placeholder="http://host:8083" />
|
|
</div>
|
|
|
|
<h6 class="text-muted border-bottom pb-1">Node B</h6>
|
|
<div class="mb-2">
|
|
<label class="form-label small">Akka Address</label>
|
|
<input type="text" class="form-control form-control-sm" @bind="_formNodeBAddress"
|
|
placeholder="akka.tcp://scadabridge@host:port/user/site-communication" />
|
|
</div>
|
|
<div class="mb-3">
|
|
<label class="form-label small">gRPC Address</label>
|
|
<input type="text" class="form-control form-control-sm" @bind="_formGrpcNodeBAddress"
|
|
placeholder="http://host:8083" />
|
|
</div>
|
|
|
|
@if (_formError != null)
|
|
{
|
|
<div class="text-danger small mt-2">@_formError</div>
|
|
}
|
|
<div class="mt-3">
|
|
<button class="btn btn-success btn-sm me-1" @onclick="SaveSite">Save</button>
|
|
<button class="btn btn-outline-secondary btn-sm" @onclick="GoBack">Cancel</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
@code {
|
|
[Parameter] public int? Id { get; set; }
|
|
|
|
private bool IsEditMode => Id.HasValue;
|
|
|
|
private Site? _editingSite;
|
|
private string _formName = string.Empty;
|
|
private string _formIdentifier = string.Empty;
|
|
private string? _formDescription;
|
|
private string? _formNodeAAddress;
|
|
private string? _formNodeBAddress;
|
|
private string? _formGrpcNodeAAddress;
|
|
private string? _formGrpcNodeBAddress;
|
|
private string? _formError;
|
|
|
|
private ToastNotification _toast = default!;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
if (Id.HasValue)
|
|
{
|
|
_editingSite = await SiteRepository.GetSiteByIdAsync(Id.Value);
|
|
if (_editingSite != null)
|
|
{
|
|
_formName = _editingSite.Name;
|
|
_formIdentifier = _editingSite.SiteIdentifier;
|
|
_formDescription = _editingSite.Description;
|
|
_formNodeAAddress = _editingSite.NodeAAddress;
|
|
_formNodeBAddress = _editingSite.NodeBAddress;
|
|
_formGrpcNodeAAddress = _editingSite.GrpcNodeAAddress;
|
|
_formGrpcNodeBAddress = _editingSite.GrpcNodeBAddress;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void GoBack()
|
|
{
|
|
NavigationManager.NavigateTo("/admin/sites");
|
|
}
|
|
|
|
private async Task SaveSite()
|
|
{
|
|
_formError = null;
|
|
|
|
if (string.IsNullOrWhiteSpace(_formName))
|
|
{
|
|
_formError = "Name is required.";
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
if (_editingSite != null)
|
|
{
|
|
_editingSite.Name = _formName.Trim();
|
|
_editingSite.Description = _formDescription?.Trim();
|
|
_editingSite.NodeAAddress = _formNodeAAddress?.Trim();
|
|
_editingSite.NodeBAddress = _formNodeBAddress?.Trim();
|
|
_editingSite.GrpcNodeAAddress = _formGrpcNodeAAddress?.Trim();
|
|
_editingSite.GrpcNodeBAddress = _formGrpcNodeBAddress?.Trim();
|
|
await SiteRepository.UpdateSiteAsync(_editingSite);
|
|
}
|
|
else
|
|
{
|
|
if (string.IsNullOrWhiteSpace(_formIdentifier))
|
|
{
|
|
_formError = "Identifier is required.";
|
|
return;
|
|
}
|
|
var site = new Site(_formName.Trim(), _formIdentifier.Trim())
|
|
{
|
|
Description = _formDescription?.Trim(),
|
|
NodeAAddress = _formNodeAAddress?.Trim(),
|
|
NodeBAddress = _formNodeBAddress?.Trim(),
|
|
GrpcNodeAAddress = _formGrpcNodeAAddress?.Trim(),
|
|
GrpcNodeBAddress = _formGrpcNodeBAddress?.Trim()
|
|
};
|
|
await SiteRepository.AddSiteAsync(site);
|
|
}
|
|
|
|
await SiteRepository.SaveChangesAsync();
|
|
CommunicationService.RefreshSiteAddresses();
|
|
NavigationManager.NavigateTo("/admin/sites");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_formError = $"Save failed: {ex.Message}";
|
|
}
|
|
}
|
|
}
|