Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/Models/SimulateConfigModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace GeneralUpdate.Tools.Models;

public record PlatformItem(int Value, string DisplayName) { public override string ToString() => DisplayName; }
public record AppTypeItem(int Value, string DisplayName) { public override string ToString() => DisplayName; }

/// <summary>
/// Configuration for the simulate-update module.
/// </summary>
Expand All @@ -19,11 +22,11 @@ public partial class SimulateConfigModel : ObservableObject
/// <summary>The target version the patch upgrades to.</summary>
[ObservableProperty] private string _targetVersion = "2.0.0.0";

/// <summary>Platform selector (1=Windows, 2=Linux).</summary>
[ObservableProperty] private int _platform = 1;
/// <summary>Platform selector.</summary>
[ObservableProperty] private PlatformItem _platform = new(1, "Windows");

/// <summary>AppType sent to the server (1=ClientApp, 2=UpgradeApp).</summary>
[ObservableProperty] private int _appType = 1;
/// <summary>AppType selector.</summary>
[ObservableProperty] private AppTypeItem _appType = new(1, "ClientApp");

/// <summary>Application secret key for the update API.</summary>
[ObservableProperty] private string _appSecretKey = "dfeb5833-975e-4afb-88f1-6278ee9aeff6";
Expand Down
4 changes: 2 additions & 2 deletions src/Services/ReportGeneratorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public async Task<string> GenerateAsync(
sb.AppendLine("|-------|-------|");
sb.AppendLine($"| Patch | {EscapeMd(config.PatchFilePath)} |");
sb.AppendLine($"| App Directory | {EscapeMd(config.AppDirectory)} |");
sb.AppendLine($"| Platform | {config.Platform} |");
sb.AppendLine($"| AppType | {config.AppType} |");
sb.AppendLine($"| Platform | {config.Platform.DisplayName} |");
sb.AppendLine($"| AppType | {config.AppType.DisplayName} |");
sb.AppendLine($"| Version | {config.CurrentVersion} → {config.TargetVersion} |");
sb.AppendLine($"| Server Port | {config.ServerPort} |");
sb.AppendLine($"| Simulation Time | {DateTime.Now:yyyy-MM-dd HH:mm:ss} |");
Expand Down
2 changes: 1 addition & 1 deletion src/Services/SimulationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public async Task<SimulationResult> RunAsync(

var hash = ComputeQuickHash(patchDest);
LocalUpdateServerFiles.Register(patchName, patchDest);
_server.Updates.Add((config.CurrentVersion, config.TargetVersion, hash, patchDest, config.AppType));
_server.Updates.Add((config.CurrentVersion, config.TargetVersion, hash, patchDest, config.AppType.Value));

await _server.StartAsync(config.ServerPort);
Log($" Server running on {_server.BaseUrl}", progress);
Expand Down
3 changes: 0 additions & 3 deletions src/ViewModels/SimulateViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,3 @@ async Task StartSimulation()

void L(string msg) => Log.Add($"[{DateTime.Now:HH:mm:ss}] {msg}");
}

public record PlatformItem(int Value, string DisplayName) { public override string ToString() => DisplayName; }
public record AppTypeItem(int Value, string DisplayName) { public override string ToString() => DisplayName; }
22 changes: 11 additions & 11 deletions src/Views/SimulateView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
<StackPanel Spacing="10">
<TextBlock Text="Test Target" FontSize="14" FontWeight="SemiBold"/>
<Grid ColumnDefinitions="Auto,*,Auto">
<TextBlock Grid.Column="0" Text="Old App Dir" VerticalAlignment="Center" Width="100"/>
<TextBlock Grid.Column="0" Text="Old App Dir" VerticalAlignment="Center" Width="110"/>
<TextBox Grid.Column="1" Text="{Binding Config.AppDirectory}" IsReadOnly="True" Margin="8,0"/>
<Button Grid.Column="2" Content="📁 Select" Command="{Binding SelectAppDirCommand}" MinWidth="80"/>
</Grid>
<Grid ColumnDefinitions="Auto,*,Auto">
<TextBlock Grid.Column="0" Text="Patch Package" VerticalAlignment="Center" Width="100"/>
<TextBlock Grid.Column="0" Text="Patch Package" VerticalAlignment="Center" Width="110"/>
<TextBox Grid.Column="1" Text="{Binding Config.PatchFilePath}" IsReadOnly="True" Margin="8,0"/>
<Button Grid.Column="2" Content="📁 Select" Command="{Binding SelectPatchCommand}" MinWidth="80"/>
</Grid>
Expand All @@ -38,18 +38,18 @@
<Grid ColumnDefinitions="Auto,*,Auto,*">
<TextBlock Grid.Column="0" Text="Platform" VerticalAlignment="Center"/>
<ComboBox Grid.Column="1" ItemsSource="{Binding Platforms}"
SelectedItem="{Binding Config.Platform}" Margin="8,0,16,0"/>
SelectedItem="{Binding Config.Platform}" Margin="8,0,16,0"
SelectedIndex="0"/>
<TextBlock Grid.Column="2" Text="AppType" VerticalAlignment="Center"/>
<ComboBox Grid.Column="3" ItemsSource="{Binding AppTypes}"
SelectedItem="{Binding Config.AppType}" Margin="8,0"/>
SelectedItem="{Binding Config.AppType}" Margin="8,0"
SelectedIndex="0"/>
</Grid>
<Grid ColumnDefinitions="Auto,*">
<Grid ColumnDefinitions="Auto,*,Auto,*">
<TextBlock Grid.Column="0" Text="AppSecret" VerticalAlignment="Center"/>
<TextBox Grid.Column="1" Text="{Binding Config.AppSecretKey}" Margin="8,0"/>
</Grid>
<Grid ColumnDefinitions="Auto,*">
<TextBlock Grid.Column="0" Text="Product ID" VerticalAlignment="Center"/>
<TextBox Grid.Column="1" Text="{Binding Config.ProductId}" Margin="8,0"/>
<TextBox Grid.Column="1" Text="{Binding Config.AppSecretKey}" Margin="8,0,16,0"/>
<TextBlock Grid.Column="2" Text="Product ID" VerticalAlignment="Center"/>
<TextBox Grid.Column="3" Text="{Binding Config.ProductId}" Margin="8,0"/>
</Grid>
</StackPanel>
</Border>
Expand All @@ -59,7 +59,7 @@
<StackPanel Spacing="10">
<TextBlock Text="Output" FontSize="14" FontWeight="SemiBold"/>
<Grid ColumnDefinitions="Auto,*,Auto">
<TextBlock Grid.Column="0" Text="Simulate Dir" VerticalAlignment="Center" Width="100"/>
<TextBlock Grid.Column="0" Text="Simulate Dir" VerticalAlignment="Center" Width="110"/>
<TextBox Grid.Column="1" Text="{Binding Config.OutputDirectory}" IsReadOnly="True" Margin="8,0"/>
<Button Grid.Column="2" Content="📁 Select" Command="{Binding SelectOutputDirCommand}" MinWidth="80"/>
</Grid>
Expand Down
Loading