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

@@ -9,17 +9,36 @@
MinWidth="800" MinHeight="600">
<Grid RowDefinitions="Auto,Auto,*,Auto">
<!-- Toolbar -->
<StackPanel Orientation="Horizontal" Margin="5" Grid.Row="0">
<Button Name="AddWorkerButton" Content="Add Worker" Margin="5" Width="120"/>
<Button Name="EditWorkerButton" Content="Edit Worker" Margin="5" Width="120"/>
<Button Name="DeleteWorkerButton" Content="Delete Worker" Margin="5" Width="120"/>
<Separator Margin="10,0"/>
<Button Name="StartWorkerButton" Content="Start" Margin="5" Width="80"/>
<Button Name="StopWorkerButton" Content="Stop" Margin="5" Width="80"/>
<Button Name="AttachWorkerButton" Content="Attach" Margin="5" Width="80"/>
<Separator Margin="10,0"/>
<Button Name="SettingsButton" Content="Settings" Margin="5" Width="80"/>
</StackPanel>
<Grid Grid.Row="0" Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Grid.Column="0">
<Button Name="AddWorkerButton" Content="Add Worker" Margin="5" Width="120"/>
<Button Name="EditWorkerButton" Content="Edit Worker" Margin="5" Width="120"/>
<Button Name="DeleteWorkerButton" Content="Delete Worker" Margin="5" Width="120"/>
<Separator Margin="10,0"/>
<Button Name="StartWorkerButton" Content="Start" Margin="5" Width="80"/>
<Button Name="StopWorkerButton" Content="Stop" Margin="5" Width="80"/>
<Button Name="AttachWorkerButton" Content="Attach" Margin="5" Width="80"/>
<Separator Margin="10,0"/>
<Button Name="SettingsButton" Content="Settings" Margin="5" Width="80"/>
</StackPanel>
<!-- Operation Mode Toggle Button -->
<Button Name="OperationModeToggleButton" Grid.Column="1"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Margin="5"
Padding="10,5"
MinWidth="120">
<StackPanel Orientation="Horizontal" Spacing="5">
<TextBlock Text="{Binding OperationModeIcon}" FontSize="16" VerticalAlignment="Center"/>
<TextBlock Text="{Binding OperationModeDisplayName}"
VerticalAlignment="Center" FontWeight="Bold"/>
</StackPanel>
</Button>
</Grid>
<!-- Worker Type Filter -->
<TabControl Name="WorkerTypeTabs" Grid.Row="1" Margin="5,0">

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;