sheepit/flamenco toggle

This commit is contained in:
Nathan
2025-12-17 16:46:35 -07:00
parent 0460865ebc
commit 553758c378
7 changed files with 16425 additions and 44 deletions

View File

@@ -40,8 +40,18 @@ namespace UnifiedFarmLauncher.Views
this.FindControl<Button>("StopWorkerButton")!.Click += StopWorkerButton_Click;
this.FindControl<Button>("AttachWorkerButton")!.Click += AttachWorkerButton_Click;
this.FindControl<Button>("SettingsButton")!.Click += SettingsButton_Click;
this.FindControl<Button>("OperationModeToggleButton")!.Click += OperationModeToggleButton_Click;
this.FindControl<TabControl>("WorkerTypeTabs")!.SelectionChanged += WorkerTypeTabs_SelectionChanged;
this.FindControl<DataGrid>("WorkersGrid")!.SelectionChanged += WorkersGrid_SelectionChanged;
}
private void OperationModeToggleButton_Click(object? sender, RoutedEventArgs e)
{
if (DataContext is MainWindowViewModel vm)
{
vm.OperationMode = vm.OperationMode == "sheepit" ? "flamenco" : "sheepit";
}
}
private async void AddWorkerButton_Click(object? sender, RoutedEventArgs e)
@@ -88,16 +98,22 @@ namespace UnifiedFarmLauncher.Views
{
try
{
string? workerType = null;
if (worker.WorkerTypes.SheepIt != null)
workerType = "sheepit";
else if (worker.WorkerTypes.Flamenco != null)
workerType = "flamenco";
var vm = (MainWindowViewModel)DataContext!;
string? workerType = vm.OperationMode;
if (workerType == null)
// Verify the worker supports the selected operation mode
if (workerType == "sheepit" && worker.WorkerTypes.SheepIt == null)
{
var box = MessageBoxManager.GetMessageBoxStandard("Error",
"Worker has no configured worker type.",
$"Worker '{worker.Name}' does not have SheepIt configured.",
ButtonEnum.Ok, MsBox.Avalonia.Enums.Icon.Error);
await box.ShowAsync();
return;
}
if (workerType == "flamenco" && worker.WorkerTypes.Flamenco == null)
{
var box = MessageBoxManager.GetMessageBoxStandard("Error",
$"Worker '{worker.Name}' does not have Flamenco configured.",
ButtonEnum.Ok, MsBox.Avalonia.Enums.Icon.Error);
await box.ShowAsync();
return;
@@ -105,10 +121,10 @@ namespace UnifiedFarmLauncher.Views
await _controllerService.StartWorkerAsync(worker, workerType);
var successBox = MessageBoxManager.GetMessageBoxStandard("Start Worker",
$"Worker '{worker.Name}' started successfully.",
$"Worker '{worker.Name}' ({vm.OperationModeDisplayName}) started successfully.",
ButtonEnum.Ok, MsBox.Avalonia.Enums.Icon.Success);
await successBox.ShowAsync();
((MainWindowViewModel)DataContext!).RefreshWorkers();
vm.RefreshWorkers();
}
catch (System.Exception ex)
{
@@ -126,16 +142,22 @@ namespace UnifiedFarmLauncher.Views
{
try
{
string? workerType = null;
if (worker.WorkerTypes.SheepIt != null)
workerType = "sheepit";
else if (worker.WorkerTypes.Flamenco != null)
workerType = "flamenco";
var vm = (MainWindowViewModel)DataContext!;
string workerType = vm.OperationMode;
if (workerType == null)
// Verify the worker supports the selected operation mode
if (workerType == "sheepit" && worker.WorkerTypes.SheepIt == null)
{
var box = MessageBoxManager.GetMessageBoxStandard("Error",
"Worker has no configured worker type.",
$"Worker '{worker.Name}' does not have SheepIt configured.",
ButtonEnum.Ok, MsBox.Avalonia.Enums.Icon.Error);
await box.ShowAsync();
return;
}
if (workerType == "flamenco" && worker.WorkerTypes.Flamenco == null)
{
var box = MessageBoxManager.GetMessageBoxStandard("Error",
$"Worker '{worker.Name}' does not have Flamenco configured.",
ButtonEnum.Ok, MsBox.Avalonia.Enums.Icon.Error);
await box.ShowAsync();
return;
@@ -143,7 +165,7 @@ namespace UnifiedFarmLauncher.Views
await _controllerService.StopWorkerAsync(worker, workerType);
var successBox = MessageBoxManager.GetMessageBoxStandard("Stop Worker",
$"Stop command sent to worker '{worker.Name}'.",
$"Stop command sent to worker '{worker.Name}' ({vm.OperationModeDisplayName}).",
ButtonEnum.Ok, MsBox.Avalonia.Enums.Icon.Info);
await successBox.ShowAsync();
}
@@ -163,16 +185,22 @@ namespace UnifiedFarmLauncher.Views
{
try
{
string? workerType = null;
if (worker.WorkerTypes.SheepIt != null)
workerType = "sheepit";
else if (worker.WorkerTypes.Flamenco != null)
workerType = "flamenco";
var vm = (MainWindowViewModel)DataContext!;
string workerType = vm.OperationMode;
if (workerType == null)
// Verify the worker supports the selected operation mode
if (workerType == "sheepit" && worker.WorkerTypes.SheepIt == null)
{
var box = MessageBoxManager.GetMessageBoxStandard("Error",
"Worker has no configured worker type.",
$"Worker '{worker.Name}' does not have SheepIt configured.",
ButtonEnum.Ok, MsBox.Avalonia.Enums.Icon.Error);
await box.ShowAsync();
return;
}
if (workerType == "flamenco" && worker.WorkerTypes.Flamenco == null)
{
var box = MessageBoxManager.GetMessageBoxStandard("Error",
$"Worker '{worker.Name}' does not have Flamenco configured.",
ButtonEnum.Ok, MsBox.Avalonia.Enums.Icon.Error);
await box.ShowAsync();
return;