feat(ui): complete Avalonia UI port with 7 main pages, tool settings & top MenuBar
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
namespace ClawdDotNet.Desktop.ViewModels;
|
||||
|
||||
public sealed record AddServiceResultData(
|
||||
string ServiceName,
|
||||
string ServiceType,
|
||||
int ServicePort,
|
||||
string ServiceDescription
|
||||
);
|
||||
|
||||
public sealed partial class AddServiceViewModel : ViewModelBase
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string _serviceName = "";
|
||||
|
||||
[ObservableProperty]
|
||||
private string _serviceType = "HTTP";
|
||||
|
||||
[ObservableProperty]
|
||||
private int _servicePort = 8080;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _serviceDescription = "";
|
||||
|
||||
[ObservableProperty]
|
||||
private string _statusMessage = "";
|
||||
|
||||
public List<string> AvailableServiceTypes { get; } = ["HTTP", "TCP", "gRPC", "WebSocket", "Custom"];
|
||||
|
||||
public AddServiceResultData? Result { get; private set; }
|
||||
|
||||
public event Action? CloseRequested;
|
||||
|
||||
[RelayCommand]
|
||||
private void Confirm()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(ServiceName))
|
||||
{
|
||||
StatusMessage = "Bitte einen Dienstnamen eingeben.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (ServicePort <= 0 || ServicePort > 65535)
|
||||
{
|
||||
StatusMessage = "Gültigen Port zwischen 1 und 65535 eingeben.";
|
||||
return;
|
||||
}
|
||||
|
||||
Result = new AddServiceResultData(
|
||||
ServiceName.Trim(),
|
||||
ServiceType,
|
||||
ServicePort,
|
||||
ServiceDescription.Trim()
|
||||
);
|
||||
|
||||
CloseRequested?.Invoke();
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void Cancel()
|
||||
{
|
||||
Result = null;
|
||||
CloseRequested?.Invoke();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user