Add edit and delete for systems, containers, and paths in settings.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
using ZA.CoreService.ESBCertificateManager.Models;
|
||||
|
||||
namespace ZA.CoreService.ESBCertificateManager.Setup;
|
||||
|
||||
public sealed class AddSonicSystemForm : Form
|
||||
{
|
||||
private readonly SetupCoordinator _coordinator;
|
||||
private readonly SonicSystemOption? _existing;
|
||||
private readonly TextBox _txtName;
|
||||
private readonly TextBox _txtHost;
|
||||
private readonly TextBox _txtPort;
|
||||
@@ -13,11 +16,18 @@ public sealed class AddSonicSystemForm : Form
|
||||
|
||||
public int? CreatedSonicConnectionId { get; private set; }
|
||||
|
||||
public AddSonicSystemForm(SetupCoordinator coordinator)
|
||||
public bool IsEditMode => _existing is not null;
|
||||
|
||||
public AddSonicSystemForm(
|
||||
SetupCoordinator coordinator,
|
||||
SonicSystemOption? existing = null)
|
||||
{
|
||||
_coordinator = coordinator;
|
||||
_existing = existing;
|
||||
|
||||
Text = "Sonic-System hinzufügen";
|
||||
Text = IsEditMode
|
||||
? "Sonic-System bearbeiten"
|
||||
: "Sonic-System hinzufügen";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
FormBorderStyle = FormBorderStyle.FixedDialog;
|
||||
MaximizeBox = false;
|
||||
@@ -30,7 +40,9 @@ public sealed class AddSonicSystemForm : Form
|
||||
|
||||
Label title = new()
|
||||
{
|
||||
Text = "Neues Sonic-System",
|
||||
Text = IsEditMode
|
||||
? "Sonic-System bearbeiten"
|
||||
: "Neues Sonic-System",
|
||||
Location = new Point(28, 22),
|
||||
AutoSize = true,
|
||||
Font = new Font("Segoe UI Semibold", 18f, FontStyle.Bold),
|
||||
@@ -61,13 +73,30 @@ public sealed class AddSonicSystemForm : Form
|
||||
_cmbProtocol.SelectedIndex = 0;
|
||||
_txtPort.Text = "13070";
|
||||
|
||||
if (_existing is not null)
|
||||
{
|
||||
_txtName.Text = _existing.ConnectionName;
|
||||
_txtHost.Text = _existing.ManagementHost;
|
||||
_txtPort.Text = _existing.ManagementPort.ToString();
|
||||
_txtDomain.Text = _existing.DomainName;
|
||||
|
||||
string protocol = _existing.ConnectionProtocol
|
||||
.Trim()
|
||||
.TrimEnd(':', '/')
|
||||
.ToLowerInvariant();
|
||||
|
||||
int protocolIndex = _cmbProtocol.Items.IndexOf(protocol);
|
||||
_cmbProtocol.SelectedIndex = protocolIndex >= 0 ? protocolIndex : 0;
|
||||
}
|
||||
|
||||
AddField(card, "Verbindungsname", _txtName, 18, 18, 420);
|
||||
AddField(card, "Management-Host", _txtHost, 18, 78, 280);
|
||||
AddField(card, "Port", _txtPort, 316, 78, 122);
|
||||
AddField(card, "Domain", _txtDomain, 18, 138, 420);
|
||||
AddField(card, "Protokoll", _cmbProtocol, 18, 198, 160);
|
||||
|
||||
_btnSave = SettingsUi.CreatePrimaryButton("System anlegen");
|
||||
_btnSave = SettingsUi.CreatePrimaryButton(
|
||||
IsEditMode ? "Änderungen speichern" : "System anlegen");
|
||||
_btnSave.Location = new Point(292, 365);
|
||||
_btnSave.Size = new Size(200, 40);
|
||||
_btnSave.Click += async (_, _) => await SaveAsync();
|
||||
@@ -114,13 +143,31 @@ public sealed class AddSonicSystemForm : Form
|
||||
|
||||
try
|
||||
{
|
||||
CreatedSonicConnectionId =
|
||||
await _coordinator.AddSonicConnectionAsync(
|
||||
string protocol =
|
||||
_cmbProtocol.SelectedItem?.ToString() ?? "tcp";
|
||||
|
||||
if (_existing is not null)
|
||||
{
|
||||
await _coordinator.UpdateSonicConnectionAsync(
|
||||
_existing.SonicConnectionId,
|
||||
_txtName.Text,
|
||||
_txtHost.Text,
|
||||
port,
|
||||
_txtDomain.Text,
|
||||
_cmbProtocol.SelectedItem?.ToString() ?? "tcp");
|
||||
protocol);
|
||||
|
||||
CreatedSonicConnectionId = _existing.SonicConnectionId;
|
||||
}
|
||||
else
|
||||
{
|
||||
CreatedSonicConnectionId =
|
||||
await _coordinator.AddSonicConnectionAsync(
|
||||
_txtName.Text,
|
||||
_txtHost.Text,
|
||||
port,
|
||||
_txtDomain.Text,
|
||||
protocol);
|
||||
}
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
|
||||
Reference in New Issue
Block a user