9e243493fb
Applies the family-wide admin-UI cleanup playbook to the Central UI so the Blazor surfaces stop diverging from the shared kit: buttons are grouped rather than individually sized, long cell values are contained instead of widening tables, and hard-coded colours give way to theme tokens. The headline fix is that MainLayout passed Accent="#2f5fd0" to ThemeShell, which the kit emits as an inline style on the shell root. Being a descendant of <html>, it beat the [data-bs-theme="dark"] override for the entire app, so the dark accent had never rendered. Declaring --accent in site.css :root instead lets both schemes resolve; light is unchanged because the value already matched the kit's light default. Theme pins to 0.4.1, which upstreams the local .btn sizing block verbatim, so that block is deleted here rather than duplicated. Verified byte-identical before removal; the repo now declares no --bs-btn-* anywhere. NOT purely cosmetic, contrary to the sweep's stated scope: four detail-modal surfaces (NotificationReport, ConfigurationAuditLog, ParkedMessages, SiteCallsReport) were additionally refactored from holding the selected record to holding its id and re-resolving from the current page each render, with the resolve doubling as the visibility gate. A background refresh that drops the row now closes the modal instead of showing a stale snapshot. This is a behaviour change and is called out rather than buried: a full-suite run turned up one intermittent CentralUI failure, CloseButton_DismissesModal, whose stack (GetRequiredEventBindingEntry during DispatchEventAsync) indicates the handler was disposed between render and click — a window the previous field-held record made structurally impossible. Treat the modal lifecycle here as unreviewed. Build 0/0; suite green apart from that one intermittent failure.
122 lines
4.4 KiB
Plaintext
122 lines
4.4 KiB
Plaintext
@page "/design/db-connections/create"
|
|
@page "/design/db-connections/{Id:int}/edit"
|
|
@using ZB.MOM.WW.ScadaBridge.Security
|
|
@using ZB.MOM.WW.ScadaBridge.Commons.Entities.ExternalSystems
|
|
@using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories
|
|
@attribute [Authorize(Policy = AuthorizationPolicies.RequireDesign)]
|
|
@inject IExternalSystemRepository ExternalSystemRepository
|
|
@inject NavigationManager NavigationManager
|
|
|
|
<div class="container-fluid mt-3">
|
|
<button class="btn btn-outline-secondary btn-sm mb-2" @onclick="GoBack">← Back</button>
|
|
|
|
<h4 class="mb-3">@(Id.HasValue ? "Edit Database Connection" : "Add Database Connection")</h4>
|
|
|
|
@if (_loading)
|
|
{
|
|
<LoadingSpinner IsLoading="true" />
|
|
}
|
|
else
|
|
{
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="mb-3">
|
|
<label class="form-label">Name</label>
|
|
<input type="text" class="form-control" @bind="_name" />
|
|
</div>
|
|
<div class="mb-3">
|
|
<label class="form-label">Connection String</label>
|
|
<input type="text" class="form-control" @bind="_connectionString" />
|
|
<div class="form-text">Treat as sensitive — visible to admins only.</div>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label class="form-label">Max Retries</label>
|
|
<input type="number" class="form-control" @bind="_maxRetries" min="0" />
|
|
</div>
|
|
<div class="mb-3">
|
|
<label class="form-label">Retry Delay (seconds)</label>
|
|
<input type="number" class="form-control" @bind="_retryDelaySeconds" min="0" />
|
|
</div>
|
|
|
|
@if (_formError != null)
|
|
{
|
|
<div class="text-danger small mb-2">@_formError</div>
|
|
}
|
|
|
|
<div class="btn-group" role="group">
|
|
<button class="btn btn-success" @onclick="Save">Save</button>
|
|
<button class="btn btn-outline-secondary" @onclick="GoBack">Cancel</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
</div>
|
|
|
|
@code {
|
|
[Parameter] public int? Id { get; set; }
|
|
|
|
private bool _loading = true;
|
|
private string _name = "", _connectionString = "";
|
|
private int _maxRetries = 3;
|
|
private int _retryDelaySeconds = 5;
|
|
private string? _formError;
|
|
|
|
private DatabaseConnectionDefinition? _existing;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
if (Id.HasValue)
|
|
{
|
|
try
|
|
{
|
|
_existing = await ExternalSystemRepository.GetDatabaseConnectionByIdAsync(Id.Value);
|
|
if (_existing != null)
|
|
{
|
|
_name = _existing.Name;
|
|
_connectionString = _existing.ConnectionString;
|
|
_maxRetries = _existing.MaxRetries;
|
|
_retryDelaySeconds = (int)_existing.RetryDelay.TotalSeconds;
|
|
}
|
|
}
|
|
catch (Exception ex) { _formError = ex.Message; }
|
|
}
|
|
_loading = false;
|
|
}
|
|
|
|
private async Task Save()
|
|
{
|
|
_formError = null;
|
|
if (string.IsNullOrWhiteSpace(_name) || string.IsNullOrWhiteSpace(_connectionString))
|
|
{
|
|
_formError = "Name and connection string required.";
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
if (_existing != null)
|
|
{
|
|
_existing.Name = _name.Trim();
|
|
_existing.ConnectionString = _connectionString.Trim();
|
|
_existing.MaxRetries = _maxRetries;
|
|
_existing.RetryDelay = TimeSpan.FromSeconds(_retryDelaySeconds);
|
|
await ExternalSystemRepository.UpdateDatabaseConnectionAsync(_existing);
|
|
}
|
|
else
|
|
{
|
|
var dc = new DatabaseConnectionDefinition(_name.Trim(), _connectionString.Trim())
|
|
{
|
|
MaxRetries = _maxRetries,
|
|
RetryDelay = TimeSpan.FromSeconds(_retryDelaySeconds)
|
|
};
|
|
await ExternalSystemRepository.AddDatabaseConnectionAsync(dc);
|
|
}
|
|
await ExternalSystemRepository.SaveChangesAsync();
|
|
NavigationManager.NavigateTo("/design/external-systems");
|
|
}
|
|
catch (Exception ex) { _formError = ex.Message; }
|
|
}
|
|
|
|
private void GoBack() => NavigationManager.NavigateTo("/design/external-systems");
|
|
}
|