Expand settings UI to manage systems, containers, and certificate paths.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,160 @@
|
||||
namespace ZA.CoreService.ESBCertificateManager.Setup;
|
||||
|
||||
public sealed class AddSonicSystemForm : Form
|
||||
{
|
||||
private readonly SetupCoordinator _coordinator;
|
||||
private readonly TextBox _txtName;
|
||||
private readonly TextBox _txtHost;
|
||||
private readonly TextBox _txtPort;
|
||||
private readonly TextBox _txtDomain;
|
||||
private readonly ComboBox _cmbProtocol;
|
||||
private readonly Button _btnSave;
|
||||
private bool _running;
|
||||
|
||||
public int? CreatedSonicConnectionId { get; private set; }
|
||||
|
||||
public AddSonicSystemForm(SetupCoordinator coordinator)
|
||||
{
|
||||
_coordinator = coordinator;
|
||||
|
||||
Text = "Sonic-System hinzufügen";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
FormBorderStyle = FormBorderStyle.FixedDialog;
|
||||
MaximizeBox = false;
|
||||
MinimizeBox = false;
|
||||
ShowInTaskbar = false;
|
||||
ClientSize = new Size(520, 430);
|
||||
BackColor = SettingsUi.Background;
|
||||
ForeColor = SettingsUi.Text;
|
||||
Font = new Font("Segoe UI", 10f);
|
||||
|
||||
Label title = new()
|
||||
{
|
||||
Text = "Neues Sonic-System",
|
||||
Location = new Point(28, 22),
|
||||
AutoSize = true,
|
||||
Font = new Font("Segoe UI Semibold", 18f, FontStyle.Bold),
|
||||
ForeColor = SettingsUi.Text
|
||||
};
|
||||
|
||||
Label subtitle = new()
|
||||
{
|
||||
Text =
|
||||
$"Umgebung {_coordinator.Settings.EnvironmentCode} · " +
|
||||
"Management-Verbindung für Container-Neustarts",
|
||||
Location = new Point(30, 58),
|
||||
AutoSize = true,
|
||||
ForeColor = SettingsUi.Muted
|
||||
};
|
||||
|
||||
Panel card = SettingsUi.CreateCard();
|
||||
card.Location = new Point(28, 95);
|
||||
card.Size = new Size(464, 250);
|
||||
card.Paint += SettingsUi.PaintCardBorder;
|
||||
|
||||
_txtName = SettingsUi.CreateTextBox();
|
||||
_txtHost = SettingsUi.CreateTextBox();
|
||||
_txtPort = SettingsUi.CreateTextBox();
|
||||
_txtDomain = SettingsUi.CreateTextBox();
|
||||
_cmbProtocol = SettingsUi.CreateComboBox();
|
||||
_cmbProtocol.Items.AddRange(["tcp", "ssl"]);
|
||||
_cmbProtocol.SelectedIndex = 0;
|
||||
_txtPort.Text = "13070";
|
||||
|
||||
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.Location = new Point(292, 365);
|
||||
_btnSave.Size = new Size(200, 40);
|
||||
_btnSave.Click += async (_, _) => await SaveAsync();
|
||||
|
||||
Button cancel = SettingsUi.CreateGhostButton("Abbrechen");
|
||||
cancel.Location = new Point(170, 365);
|
||||
cancel.Size = new Size(110, 40);
|
||||
cancel.Click += (_, _) =>
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
};
|
||||
|
||||
Controls.Add(title);
|
||||
Controls.Add(subtitle);
|
||||
Controls.Add(card);
|
||||
Controls.Add(cancel);
|
||||
Controls.Add(_btnSave);
|
||||
AcceptButton = _btnSave;
|
||||
CancelButton = cancel;
|
||||
}
|
||||
|
||||
private async Task SaveAsync()
|
||||
{
|
||||
if (_running)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!int.TryParse(_txtPort.Text.Trim(), out int port))
|
||||
{
|
||||
MessageBox.Show(
|
||||
this,
|
||||
"Bitte einen gültigen Port eingeben.",
|
||||
"Sonic-System",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
_running = true;
|
||||
_btnSave.Enabled = false;
|
||||
Cursor = Cursors.WaitCursor;
|
||||
|
||||
try
|
||||
{
|
||||
CreatedSonicConnectionId =
|
||||
await _coordinator.AddSonicConnectionAsync(
|
||||
_txtName.Text,
|
||||
_txtHost.Text,
|
||||
port,
|
||||
_txtDomain.Text,
|
||||
_cmbProtocol.SelectedItem?.ToString() ?? "tcp");
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(
|
||||
this,
|
||||
ex.Message,
|
||||
"Sonic-System",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_running = false;
|
||||
_btnSave.Enabled = true;
|
||||
Cursor = Cursors.Default;
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddField(
|
||||
Control parent,
|
||||
string label,
|
||||
Control input,
|
||||
int x,
|
||||
int y,
|
||||
int width)
|
||||
{
|
||||
Label fieldLabel = SettingsUi.CreateFieldLabel(label);
|
||||
fieldLabel.Location = new Point(x, y);
|
||||
input.Location = new Point(x, y + 22);
|
||||
input.Width = width;
|
||||
parent.Controls.Add(fieldLabel);
|
||||
parent.Controls.Add(input);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user