Files
Chronos/src/Chronos.App/Sections/JobsView.xaml.cs
T
Alby96andClaude Opus 5.5 af9eeaab9b
CI / Build and test (push) Successful in 7m0s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 13m28s
CI / PostgreSQL 16 integration (push) Successful in 5m52s
CI / PostgreSQL 17 integration (push) Successful in 4m50s
CI / Docker image (push) Successful in 1m4s
Release / Server image (push) Successful in 1m35s
feat: owner review 2 phase 2: scheduled jobs and log settings (#10)
- Jobs > Scheduled on the desktop and the admin panel. Every timer that queued work is now a visible system schedule: archive scan, upload clean-up, index backup, job-history and audit clean-ups, desktop housekeeping. New actions: verify, thumbnails, proxies, analysis, maintenance, backup, clean-ups, reports.
- The scheduler: migration 0007, in-house recurrence, compare-and-set claim, catch-up, scan at start.
- Log settings: levels, retention, size parts, total limit, daily or hourly rotation, audit retention, diagnostics share; the server writes Debug/Trace to its files again; logging never fails a job.

Upgrade: CHRONOS_LOG_LEVEL set in an existing container locks both levels; migration 0007 is one-way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
2026-10-27 11:19:26 +01:00

76 lines
2.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
using Chronos.App.Jobs;
namespace Chronos.App.Sections;
public partial class JobsView : UserControl
{
private JobsViewModel? _model;
private IInputElement? _beforeDialog;
public JobsView()
{
InitializeComponent();
DataContextChanged += OnDataContextChanged;
}
/// <summary>Loads older history when the list scrolls near its end.</summary>
private void OnScrollChanged(object sender, ScrollChangedEventArgs e)
{
if (DataContext is not JobsViewModel vm || e.ExtentHeight <= 0) return;
if (e.VerticalOffset + e.ViewportHeight >= e.ExtentHeight - Math.Max(e.ViewportHeight, 200)) _ = vm.LoadMoreAsync();
}
private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (_model is not null)
{
_model.RowRevealRequested -= OnRevealRequested;
_model.Schedules.PropertyChanged -= OnSchedulesChanged;
}
_model = e.NewValue as JobsViewModel;
if (_model is not null)
{
_model.RowRevealRequested += OnRevealRequested;
_model.Schedules.PropertyChanged += OnSchedulesChanged;
}
}
/// <summary>A job shown from Jobs › Scheduled: its row comes into view (the list is visible again by then) and takes the keyboard.</summary>
private void OnRevealRequested(JobRowViewModel row) =>
Dispatcher.BeginInvoke(DispatcherPriority.Loaded, () =>
{
JobList.ScrollIntoView(row);
JobList.UpdateLayout();
if (JobList.ItemContainerGenerator.ContainerFromItem(row) is ListBoxItem item) item.MoveFocus(new TraversalRequest(FocusNavigationDirection.First));
});
/// <summary>
/// The schedule editor takes the keyboard when it opens (its first field); when it closes, the keyboard goes back to the
/// control that opened it while that can still take it.
/// </summary>
private void OnSchedulesChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName != nameof(SchedulesViewModel.Editor) || _model is not { } model) return;
if (model.Schedules.Editor is not null)
{
if (!IsVisible) return;
_beforeDialog ??= Keyboard.FocusedElement is Visual focused && IsAncestorOf(focused) ? Keyboard.FocusedElement : null;
Dispatcher.BeginInvoke(DispatcherPriority.Input, () => DialogHost.MoveFocus(new TraversalRequest(FocusNavigationDirection.First)));
return;
}
var back = _beforeDialog;
_beforeDialog = null;
if (!IsVisible) return;
Dispatcher.BeginInvoke(DispatcherPriority.Input, () =>
{
if (back is UIElement { IsVisible: true, IsEnabled: true, Focusable: true } element) element.Focus();
});
}
}