move SheepIt settings to global settings
This commit is contained in:
@@ -3289,7 +3289,7 @@ Additional data:
|
||||
"codeblockId": "dd28b84b-a5e4-4327-b24f-d7c408f8acfa"
|
||||
}
|
||||
```
|
||||
Status: **loading**
|
||||
Status: **completed**
|
||||
|
||||
|
||||
</details>
|
||||
@@ -3297,3 +3297,110 @@ Status: **loading**
|
||||
|
||||
---
|
||||
|
||||
<tool-use data-tool-type="unknown" data-tool-name="edit_file_v2">
|
||||
<details>
|
||||
<summary>Tool use: **edit_file_v2**</summary>
|
||||
|
||||
|
||||
Parameters:
|
||||
|
||||
```json
|
||||
{
|
||||
"relativeWorkspacePath": "Views/WorkerEditWindow.axaml.cs"
|
||||
}
|
||||
```
|
||||
Additional data:
|
||||
|
||||
```json
|
||||
{
|
||||
"codeblockId": "1ece3095-7d84-48f1-b0c9-cd1778aa04dc"
|
||||
}
|
||||
```
|
||||
Status: **completed**
|
||||
|
||||
|
||||
</details>
|
||||
</tool-use>
|
||||
|
||||
---
|
||||
|
||||
<tool-use data-tool-type="unknown" data-tool-name="edit_file_v2">
|
||||
<details>
|
||||
<summary>Tool use: **edit_file_v2**</summary>
|
||||
|
||||
|
||||
Parameters:
|
||||
|
||||
```json
|
||||
{
|
||||
"relativeWorkspacePath": "Views/WorkerEditWindow.axaml.cs"
|
||||
}
|
||||
```
|
||||
Additional data:
|
||||
|
||||
```json
|
||||
{
|
||||
"codeblockId": "bd962585-1075-46d3-86e1-3ff33f1d67ed"
|
||||
}
|
||||
```
|
||||
Status: **completed**
|
||||
|
||||
|
||||
</details>
|
||||
</tool-use>
|
||||
|
||||
---
|
||||
|
||||
|
||||
Fixed the same issue in `WorkerEditWindow`. Verifying the build:
|
||||
|
||||
|
||||
---
|
||||
|
||||
<tool-use data-tool-type="shell" data-tool-name="run_terminal_command_v2">
|
||||
<details><summary>Tool use: **run_terminal_command_v2** • Run command: dotnet build --no-restore 2>&1 | Select-Object -First 30</summary>
|
||||
|
||||
```bash
|
||||
dotnet build --no-restore 2>&1 | Select-Object -First 30
|
||||
```
|
||||
|
||||
```
|
||||
UnifiedFarmLauncher -> C:\Users\Nathan\Desktop\UFL\bin\Debug\net8.0\UnifiedFarmLauncher.dll
|
||||
|
||||
Build succeeded.
|
||||
0 Warning(s)
|
||||
0 Error(s)
|
||||
|
||||
Time Elapsed 00:00:00.81
|
||||
|
||||
```
|
||||
</details>
|
||||
</tool-use>
|
||||
|
||||
---
|
||||
|
||||
|
||||
Fixed the same issue in `WorkerEditWindow`. It was accessing named controls directly (like `OkButton`, `CancelButton`, etc.) as fields, which caused a `NullReferenceException` and closed the window.
|
||||
|
||||
**Changes made:**
|
||||
- Updated `SetupEventHandlers()` to use `FindControl<T>()` for all button references
|
||||
- Updated `RemoveDriveButton_Click` and `RemovePathButton_Click` to use `FindControl<T>()` for the ListBox controls
|
||||
|
||||
The build succeeded. When you click "Add Worker", the dialog should open and stay open instead of closing immediately. Try it again.
|
||||
|
||||
---
|
||||
|
||||
_**User**_
|
||||
|
||||
This is cool. Flamenco and SheepIt should have universal settings, not per-worker; I don't want to put in user and RenderKey on a per-worker basis.
|
||||
|
||||
---
|
||||
|
||||
_**Agent (model default, mode Agent)**_
|
||||
|
||||
|
||||
Reviewing the current structure to move Flamenco and SheepIt credentials to global settings:
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -11,6 +11,12 @@ namespace UnifiedFarmLauncher.Models
|
||||
"https://www.sheepit-renderfarm.com/media/applet/client-latest.php",
|
||||
"https://www.sheepit-renderfarm.com/media/applet/client-latest.jar"
|
||||
};
|
||||
|
||||
[JsonPropertyName("sheepItUsername")]
|
||||
public string SheepItUsername { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("sheepItRenderKey")]
|
||||
public string SheepItRenderKey { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,12 +8,6 @@ namespace UnifiedFarmLauncher.Models
|
||||
{
|
||||
[JsonPropertyName("gpu")]
|
||||
public string Gpu { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("username")]
|
||||
public string Username { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("renderKey")]
|
||||
public string RenderKey { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class FlamencoConfig
|
||||
|
||||
@@ -89,9 +89,10 @@ $attachPath = Join-Path $dataRoot 'attach-helper.ps1'
|
||||
|
||||
var config = _configService.Load();
|
||||
var sheepIt = worker.WorkerTypes.SheepIt;
|
||||
var safeKey = sheepIt.RenderKey.Replace("'", "''");
|
||||
var safeUser = sheepIt.Username.Replace("'", "''");
|
||||
var urls = config.GlobalSettings.SheepItJarUrls;
|
||||
var globalSettings = config.GlobalSettings;
|
||||
var safeKey = globalSettings.SheepItRenderKey.Replace("'", "''");
|
||||
var safeUser = globalSettings.SheepItUsername.Replace("'", "''");
|
||||
var urls = globalSettings.SheepItJarUrls;
|
||||
var urlLiteral = "@(" + string.Join(", ", Array.ConvertAll(urls.ToArray(), url => $"'{url}'")) + ")";
|
||||
|
||||
return $@"
|
||||
|
||||
45
ViewModels/GlobalSettingsViewModel.cs
Normal file
45
ViewModels/GlobalSettingsViewModel.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using UnifiedFarmLauncher.Models;
|
||||
using UnifiedFarmLauncher.Services;
|
||||
|
||||
namespace UnifiedFarmLauncher.ViewModels
|
||||
{
|
||||
public class GlobalSettingsViewModel : ViewModelBase
|
||||
{
|
||||
private readonly ConfigService _configService;
|
||||
private string _sheepItUsername = string.Empty;
|
||||
private string _sheepItRenderKey = string.Empty;
|
||||
|
||||
public GlobalSettingsViewModel(ConfigService configService)
|
||||
{
|
||||
_configService = configService;
|
||||
LoadSettings();
|
||||
}
|
||||
|
||||
public string SheepItUsername
|
||||
{
|
||||
get => _sheepItUsername;
|
||||
set => SetAndRaise(ref _sheepItUsername, value);
|
||||
}
|
||||
|
||||
public string SheepItRenderKey
|
||||
{
|
||||
get => _sheepItRenderKey;
|
||||
set => SetAndRaise(ref _sheepItRenderKey, value);
|
||||
}
|
||||
|
||||
private void LoadSettings()
|
||||
{
|
||||
var config = _configService.Load();
|
||||
SheepItUsername = config.GlobalSettings.SheepItUsername;
|
||||
SheepItRenderKey = config.GlobalSettings.SheepItRenderKey;
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
var config = _configService.Load();
|
||||
config.GlobalSettings.SheepItUsername = SheepItUsername;
|
||||
config.GlobalSettings.SheepItRenderKey = SheepItRenderKey;
|
||||
_configService.Save(config);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,6 @@ namespace UnifiedFarmLauncher.ViewModels
|
||||
private int _sshPort = 22;
|
||||
private string _sshArgs = string.Empty;
|
||||
private string _sheepItGpu = "OPTIX_0";
|
||||
private string _sheepItUsername = string.Empty;
|
||||
private string _sheepItRenderKey = string.Empty;
|
||||
private string _flamencoWorkerPath = string.Empty;
|
||||
private bool _hasSheepIt;
|
||||
private bool _hasFlamenco;
|
||||
@@ -93,18 +91,6 @@ namespace UnifiedFarmLauncher.ViewModels
|
||||
set => SetAndRaise(ref _sheepItGpu, value);
|
||||
}
|
||||
|
||||
public string SheepItUsername
|
||||
{
|
||||
get => _sheepItUsername;
|
||||
set => SetAndRaise(ref _sheepItUsername, value);
|
||||
}
|
||||
|
||||
public string SheepItRenderKey
|
||||
{
|
||||
get => _sheepItRenderKey;
|
||||
set => SetAndRaise(ref _sheepItRenderKey, value);
|
||||
}
|
||||
|
||||
public string FlamencoWorkerPath
|
||||
{
|
||||
get => _flamencoWorkerPath;
|
||||
@@ -127,8 +113,6 @@ namespace UnifiedFarmLauncher.ViewModels
|
||||
{
|
||||
HasSheepIt = true;
|
||||
SheepItGpu = worker.WorkerTypes.SheepIt.Gpu;
|
||||
SheepItUsername = worker.WorkerTypes.SheepIt.Username;
|
||||
SheepItRenderKey = worker.WorkerTypes.SheepIt.RenderKey;
|
||||
}
|
||||
|
||||
if (worker.WorkerTypes.Flamenco != null)
|
||||
@@ -168,9 +152,7 @@ namespace UnifiedFarmLauncher.ViewModels
|
||||
{
|
||||
worker.WorkerTypes.SheepIt = new SheepItConfig
|
||||
{
|
||||
Gpu = SheepItGpu,
|
||||
Username = SheepItUsername,
|
||||
RenderKey = SheepItRenderKey
|
||||
Gpu = SheepItGpu
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
29
Views/GlobalSettingsWindow.axaml
Normal file
29
Views/GlobalSettingsWindow.axaml
Normal file
@@ -0,0 +1,29 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:UnifiedFarmLauncher.ViewModels"
|
||||
x:Class="UnifiedFarmLauncher.Views.GlobalSettingsWindow"
|
||||
x:DataType="vm:GlobalSettingsViewModel"
|
||||
Title="Global Settings"
|
||||
Width="500" Height="300"
|
||||
MinWidth="400" MinHeight="250">
|
||||
<Grid RowDefinitions="Auto,*,Auto" Margin="10">
|
||||
<!-- Settings Content -->
|
||||
<TabControl Grid.Row="1" Margin="0,10">
|
||||
<TabItem Header="SheepIt">
|
||||
<StackPanel Margin="10" Spacing="10">
|
||||
<TextBlock Text="Username:"/>
|
||||
<TextBox Name="SheepItUsernameTextBox" Text="{Binding SheepItUsername}"/>
|
||||
|
||||
<TextBlock Text="Render Key:" Margin="0,10,0,0"/>
|
||||
<TextBox Name="SheepItRenderKeyTextBox" Text="{Binding SheepItRenderKey}" PasswordChar="*"/>
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
||||
<!-- Buttons -->
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="2" Spacing="10" Margin="0,10,0,0">
|
||||
<Button Name="OkButton" Content="OK" Width="80" IsDefault="True"/>
|
||||
<Button Name="CancelButton" Content="Cancel" Width="80" IsCancel="True"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
61
Views/GlobalSettingsWindow.axaml.cs
Normal file
61
Views/GlobalSettingsWindow.axaml.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using UnifiedFarmLauncher.Services;
|
||||
using UnifiedFarmLauncher.ViewModels;
|
||||
|
||||
namespace UnifiedFarmLauncher.Views
|
||||
{
|
||||
public partial class GlobalSettingsWindow : Window
|
||||
{
|
||||
private readonly GlobalSettingsViewModel _viewModel;
|
||||
private bool _result;
|
||||
|
||||
public GlobalSettingsWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
var configService = new ConfigService();
|
||||
_viewModel = new GlobalSettingsViewModel(configService);
|
||||
DataContext = _viewModel;
|
||||
SetupEventHandlers();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
Avalonia.Markup.Xaml.AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
private void SetupEventHandlers()
|
||||
{
|
||||
this.FindControl<Button>("OkButton")!.Click += OkButton_Click;
|
||||
this.FindControl<Button>("CancelButton")!.Click += CancelButton_Click;
|
||||
}
|
||||
|
||||
private void OkButton_Click(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_viewModel.Save();
|
||||
_result = true;
|
||||
Close();
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
// Could show error message here
|
||||
System.Diagnostics.Debug.WriteLine($"Failed to save global settings: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void CancelButton_Click(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
_result = false;
|
||||
Close();
|
||||
}
|
||||
|
||||
public async Task<bool> ShowDialogAsync(Window parent)
|
||||
{
|
||||
await base.ShowDialog(parent);
|
||||
return _result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,8 @@
|
||||
<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>
|
||||
|
||||
<!-- Worker Type Filter -->
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace UnifiedFarmLauncher.Views
|
||||
this.FindControl<Button>("StartWorkerButton")!.Click += StartWorkerButton_Click;
|
||||
this.FindControl<Button>("StopWorkerButton")!.Click += StopWorkerButton_Click;
|
||||
this.FindControl<Button>("AttachWorkerButton")!.Click += AttachWorkerButton_Click;
|
||||
this.FindControl<Button>("SettingsButton")!.Click += SettingsButton_Click;
|
||||
this.FindControl<TabControl>("WorkerTypeTabs")!.SelectionChanged += WorkerTypeTabs_SelectionChanged;
|
||||
this.FindControl<DataGrid>("WorkersGrid")!.SelectionChanged += WorkersGrid_SelectionChanged;
|
||||
}
|
||||
@@ -199,6 +200,12 @@ namespace UnifiedFarmLauncher.Views
|
||||
}
|
||||
}
|
||||
|
||||
private async void SettingsButton_Click(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var dialog = new GlobalSettingsWindow();
|
||||
await dialog.ShowDialogAsync(this);
|
||||
}
|
||||
|
||||
private void WorkersGrid_SelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (DataContext is MainWindowViewModel vm)
|
||||
|
||||
@@ -42,11 +42,11 @@
|
||||
</ComboBox.Items>
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock Text="Username:" IsVisible="{Binding HasSheepIt}" Margin="0,10,0,0"/>
|
||||
<TextBox Name="SheepItUsernameTextBox" Text="{Binding SheepItUsername}" IsVisible="{Binding HasSheepIt}"/>
|
||||
|
||||
<TextBlock Text="Render Key:" IsVisible="{Binding HasSheepIt}" Margin="0,10,0,0"/>
|
||||
<TextBox Name="SheepItRenderKeyTextBox" Text="{Binding SheepItRenderKey}" IsVisible="{Binding HasSheepIt}" PasswordChar="*"/>
|
||||
<TextBlock Text="Note: Username and Render Key are configured in Global Settings."
|
||||
IsVisible="{Binding HasSheepIt}"
|
||||
Margin="0,10,0,0"
|
||||
Foreground="Gray"
|
||||
TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user