e65527f316
Three fixes: 1. Config Checkpoints submenu replaced with a proper dialog. Lists checkpoints with timestamp/size/filename, has a "Take Checkpoint Now" button, and a "Roll Back" button that becomes enabled when a row is selected. The previous click-a-menu-entry-immediate-restore flow was too easy to fire by accident. 2. New CheckpointScheduler BackgroundService creates a checkpoint at midnight every day. Combined with the existing auto-on-save snapshots, this guarantees a daily rollback point even if the config wasn't edited that day. A new "create-checkpoint" admin op plus AdminPipeServer.CreateCheckpoint helper does the actual file copy; both manual (via the dialog) and the scheduler use it. 3. Installer: drop the post-install "Launch Webhook Server" wizard step. It tried to launch the GUI un-elevated, which fails because the GUI's manifest is requireAdministrator. The Start Menu shortcut handles elevation correctly, so the user can launch from there. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
57 lines
1.6 KiB
C#
57 lines
1.6 KiB
C#
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
using WebhookServer.Gui.Services;
|
|
using WebhookServer.Gui.ViewModels;
|
|
|
|
namespace WebhookServer.Gui;
|
|
|
|
public partial class MainWindow : Window
|
|
{
|
|
private readonly TrayIcon _tray;
|
|
private readonly MainViewModel _vm;
|
|
|
|
public MainWindow()
|
|
{
|
|
InitializeComponent();
|
|
_vm = new MainViewModel(new AdminPipeClient());
|
|
DataContext = _vm;
|
|
|
|
_tray = new TrayIcon(
|
|
resolveMainWindow: () => Application.Current.MainWindow,
|
|
restartServiceAsync: async () => await new AdminPipeClient().RestartListenerAsync());
|
|
|
|
Loaded += async (_, _) => await _vm.RefreshCommand.ExecuteAsync(null);
|
|
StateChanged += OnStateChanged;
|
|
Closed += (_, _) => _tray.Dispose();
|
|
}
|
|
|
|
private void OnStateChanged(object? sender, EventArgs e)
|
|
{
|
|
// Minimize-to-tray: hide the window when the user minimizes; restoring is
|
|
// via the tray icon's double-click or context menu.
|
|
if (WindowState == WindowState.Minimized)
|
|
{
|
|
Hide();
|
|
ShowInTaskbar = false;
|
|
}
|
|
else
|
|
{
|
|
ShowInTaskbar = true;
|
|
}
|
|
}
|
|
|
|
private void OnLogTailChanged(object sender, TextChangedEventArgs e)
|
|
{
|
|
if (DataContext is MainViewModel vm && vm.AutoScrollLogs && sender is TextBox box)
|
|
box.ScrollToEnd();
|
|
}
|
|
|
|
private void OnRowDoubleClick(object sender, MouseButtonEventArgs e)
|
|
{
|
|
if (DataContext is MainViewModel vm && vm.EditEndpointCommand.CanExecute(null))
|
|
vm.EditEndpointCommand.Execute(null);
|
|
}
|
|
|
|
}
|