Owner review 2, R10 on the desktop: every timer that queued work out of sight is now a visible, editable schedule of this PC. - DesktopScheduleHost implements IScheduleHost: the PC's time zone, the archive at Settings › Archive's folder (refreshed from archive.json, none while it is offline), and three system schedules: archive-scan (every:<ScanIntervalMinutes>m, seeded once from the old setting, no catch-up), index-backup (every day with catch-up, replacing DatabaseBackups.RunDailyAsync) and housekeeping (daily 04:00 with catch-up: job history 90 days and the new cache-trim step). - AppServices starts the Scheduler after the engine, once the archive was reopened; an unplugged archive is looked for every minute and the scheduler woken when it is back. The rescan loop and the daily backup loop are gone; ApplyJobSettings wakes the scheduler. - CacheStore.Trim brings the cache to Settings › Storage › Cache limit, oldest files first, skipping files in use and the proxies, render-node and server-import folders; CacheTrimStep runs it as a clean-up step. - Jobs gets a Queue | Scheduled segmented control. Scheduled lists the schedules (switch, name, action, when, next run, last result) with Run now, Edit, Reset (system) or Delete (user's, confirmed), the selected schedule's last runs with Show in queue, and an in-window editor that checks every field with the scheduler's limits. Jobs a schedule queued carry a "Scheduled" pill; the history line follows the housekeeping's job-history days. - JobNotices: a scheduled background run raises a toast only when it fails (upkeep stays silent). - Settings › Archive › Rescan every is removed; ScanIntervalMinutes stays only as the seed. Strings in en and it; the others are retranslated. - The capture shows jobs-scheduled and jobs-schedule-editor on a stopped scheduler clock with sample schedules. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit e25d812feb3f417cb9251c748c29e8035fd9b03c)
143 lines
11 KiB
XML
143 lines
11 KiB
XML
<UserControl x:Class="Chronos.App.Sections.SchedulesView"
|
||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||
xmlns:ui="clr-namespace:Chronos.Ui.Controls;assembly=Chronos.Ui"
|
||
xmlns:l="clr-namespace:Chronos.Ui.Localization;assembly=Chronos.Ui"
|
||
xmlns:infra="clr-namespace:Chronos.App.Infrastructure"
|
||
xmlns:j="clr-namespace:Chronos.App.Jobs">
|
||
<!-- Jobs › Scheduled (owner review 2, R10): the schedules of this PC, and the last runs of the selected one. -->
|
||
<UserControl.Resources>
|
||
<Style x:Key="Text.Muted" TargetType="TextBlock" BasedOn="{StaticResource Text.Cell}">
|
||
<Setter Property="Foreground" Value="{DynamicResource Brush.TextMuted}" />
|
||
</Style>
|
||
<!-- A schedule row: selecting it shows its last runs; it reads as its name, action and recurrence, its last result as its status. -->
|
||
<Style x:Key="ListBoxItem.Schedule" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.Row}">
|
||
<Setter Property="Padding" Value="0" />
|
||
<Setter Property="FocusVisualStyle" Value="{StaticResource Focus.Inset}" />
|
||
<Setter Property="AutomationProperties.Name" Value="{Binding AccessibleName}" />
|
||
<Setter Property="AutomationProperties.ItemStatus" Value="{Binding LastText}" />
|
||
</Style>
|
||
<Style x:Key="ListBoxItem.Run" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.PlainRow}">
|
||
<Setter Property="AutomationProperties.Name" Value="{Binding AccessibleName}" />
|
||
</Style>
|
||
</UserControl.Resources>
|
||
|
||
<Grid Margin="20,0,20,12">
|
||
<Grid.RowDefinitions>
|
||
<RowDefinition Height="*" MinHeight="150" />
|
||
<RowDefinition Height="Auto" />
|
||
</Grid.RowDefinitions>
|
||
|
||
<Border Style="{StaticResource Border.Panel}" Visibility="{Binding HasRows, Converter={StaticResource BoolToVisibility}}">
|
||
<!-- Header and rows share their columns: the same 14 px padding, the actions column sized by its widest row, the scroll-bar gutter kept. -->
|
||
<Grid Grid.IsSharedSizeScope="True">
|
||
<Grid.RowDefinitions>
|
||
<RowDefinition Height="Auto" />
|
||
<RowDefinition Height="*" />
|
||
</Grid.RowDefinitions>
|
||
<Border BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="0,0,0,1" Padding="14,8,24,8">
|
||
<Grid>
|
||
<Grid.ColumnDefinitions>
|
||
<ColumnDefinition Width="56" />
|
||
<ColumnDefinition Width="1.2*" MinWidth="120" />
|
||
<ColumnDefinition Width="0.9*" MinWidth="100" MaxWidth="190" />
|
||
<ColumnDefinition Width="1.1*" MinWidth="120" MaxWidth="240" />
|
||
<ColumnDefinition Width="0.8*" MinWidth="110" MaxWidth="170" />
|
||
<ColumnDefinition Width="0.8*" MinWidth="110" MaxWidth="180" />
|
||
<ColumnDefinition Width="Auto" MinWidth="200" SharedSizeGroup="ScheduleActions" />
|
||
</Grid.ColumnDefinitions>
|
||
<TextBlock Style="{StaticResource Text.Header}" Text="{l:Loc Jobs.Schedule.Column.On}" ToolTip="{l:Loc Jobs.Schedule.Column.On}" />
|
||
<TextBlock Grid.Column="1" Style="{StaticResource Text.Header}" Text="{l:Loc Jobs.Schedule.Column.Name}" Margin="10,0,0,0" ToolTip="{l:Loc Jobs.Schedule.Column.Name}" />
|
||
<TextBlock Grid.Column="2" Style="{StaticResource Text.Header}" Text="{l:Loc Jobs.Schedule.Column.Action}" Margin="10,0,0,0" ToolTip="{l:Loc Jobs.Schedule.Column.Action}" />
|
||
<TextBlock Grid.Column="3" Style="{StaticResource Text.Header}" Text="{l:Loc Jobs.Schedule.Column.When}" Margin="10,0,0,0" ToolTip="{l:Loc Jobs.Schedule.Column.When}" />
|
||
<TextBlock Grid.Column="4" Style="{StaticResource Text.Header}" Text="{l:Loc Jobs.Schedule.Column.Next}" Margin="10,0,0,0" ToolTip="{l:Loc Jobs.Schedule.Column.Next}" />
|
||
<TextBlock Grid.Column="5" Style="{StaticResource Text.Header}" Text="{l:Loc Jobs.Schedule.Column.Last}" Margin="10,0,0,0" ToolTip="{l:Loc Jobs.Schedule.Column.Last}" />
|
||
</Grid>
|
||
</Border>
|
||
|
||
<!-- Rows: the arrow keys move the selection; Tab walks the switch and the buttons of each row. -->
|
||
<ListBox x:Name="ScheduleList" Grid.Row="1" ItemsSource="{Binding Rows}" SelectedItem="{Binding Selected}" ItemContainerStyle="{StaticResource ListBoxItem.Schedule}"
|
||
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Visible" KeyboardNavigation.TabNavigation="Continue"
|
||
AutomationProperties.Name="{l:Loc Jobs.Tab.Scheduled}">
|
||
<ListBox.ItemTemplate>
|
||
<DataTemplate DataType="{x:Type j:ScheduleRowViewModel}">
|
||
<Grid Height="38" Margin="14,0">
|
||
<Grid.ColumnDefinitions>
|
||
<ColumnDefinition Width="56" />
|
||
<ColumnDefinition Width="1.2*" MinWidth="120" />
|
||
<ColumnDefinition Width="0.9*" MinWidth="100" MaxWidth="190" />
|
||
<ColumnDefinition Width="1.1*" MinWidth="120" MaxWidth="240" />
|
||
<ColumnDefinition Width="0.8*" MinWidth="110" MaxWidth="170" />
|
||
<ColumnDefinition Width="0.8*" MinWidth="110" MaxWidth="180" />
|
||
<ColumnDefinition Width="Auto" MinWidth="200" SharedSizeGroup="ScheduleActions" />
|
||
</Grid.ColumnDefinitions>
|
||
<CheckBox Style="{StaticResource CheckBox.Switch}" IsChecked="{Binding IsEnabled}" ToolTip="{Binding EnabledToolTip}" VerticalAlignment="Center"
|
||
HorizontalAlignment="Left" AutomationProperties.Name="{Binding EnabledName}" />
|
||
<TextBlock Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding Name}" ToolTip="{Binding NameToolTip}" Margin="10,0,0,0" />
|
||
<TextBlock Grid.Column="2" Style="{StaticResource Text.Muted}" Text="{Binding ActionText}" ToolTip="{Binding ActionToolTip}" Margin="10,0,0,0" />
|
||
<TextBlock Grid.Column="3" Style="{StaticResource Text.Cell}" Text="{Binding WhenText}" ToolTip="{Binding WhenToolTip}" Margin="10,0,0,0" />
|
||
<TextBlock Grid.Column="4" Style="{StaticResource Text.Muted}" Text="{Binding NextText}" ToolTip="{Binding NextToolTip}" Margin="10,0,0,0" />
|
||
<!-- A new result is announced with its schedule. -->
|
||
<ui:StatusGlyph Grid.Column="5" Kind="{Binding LastKind}" Text="{Binding LastText}" ToolTip="{Binding LastToolTip}" FontSize="13" VerticalAlignment="Center"
|
||
Margin="10,0,0,0" AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding LastText}" />
|
||
<StackPanel Grid.Column="6" Orientation="Horizontal" VerticalAlignment="Center" Margin="10,0,0,0">
|
||
<Button Style="{StaticResource Button.Row}" Content="{l:Loc Jobs.Schedule.RunNow}" Command="{Binding RunNowCommand}" ToolTip="{Binding RunNowToolTip}"
|
||
ToolTipService.ShowOnDisabled="True" AutomationProperties.Name="{Binding RunNowName}" />
|
||
<Button Style="{StaticResource Button.Row}" Content="{l:Loc Jobs.Schedule.Edit}" Command="{Binding EditCommand}" ToolTip="{l:Loc Tooltips.Jobs.Schedule.Edit}"
|
||
AutomationProperties.Name="{Binding EditName}" />
|
||
<Button Style="{StaticResource Button.Row}" Content="{l:Loc Jobs.Schedule.Reset}" Command="{Binding ResetCommand}" ToolTip="{l:Loc Tooltips.Jobs.Schedule.Reset}"
|
||
AutomationProperties.Name="{Binding ResetName}" Visibility="{Binding IsSystem, Converter={StaticResource BoolToVisibility}}" />
|
||
<Button Style="{StaticResource Button.Row}" Content="{l:Loc Jobs.Schedule.Delete}" Command="{Binding DeleteCommand}" ToolTip="{l:Loc Tooltips.Jobs.Schedule.Delete}"
|
||
AutomationProperties.Name="{Binding DeleteName}"
|
||
Visibility="{Binding IsSystem, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
|
||
</StackPanel>
|
||
</Grid>
|
||
</DataTemplate>
|
||
</ListBox.ItemTemplate>
|
||
</ListBox>
|
||
</Grid>
|
||
</Border>
|
||
|
||
<!-- The selected schedule's last runs: Show in queue opens the job's row in the Queue tab. -->
|
||
<Border Grid.Row="1" Style="{StaticResource Border.Panel}" Margin="0,12,0,0" MaxHeight="260" Visibility="{Binding HasSelection, Converter={StaticResource BoolToVisibility}}">
|
||
<Grid>
|
||
<Grid.RowDefinitions>
|
||
<RowDefinition Height="Auto" />
|
||
<RowDefinition Height="*" />
|
||
</Grid.RowDefinitions>
|
||
<Border BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="0,0,0,1" Padding="14,8">
|
||
<TextBlock Text="{Binding RunsHeading}" Style="{StaticResource Text.PanelTitle}" FontSize="13" TextTrimming="CharacterEllipsis" ToolTip="{l:Loc Tooltips.Jobs.Schedule.Runs}" />
|
||
</Border>
|
||
<ListBox Grid.Row="1" ItemsSource="{Binding Runs}" ItemContainerStyle="{StaticResource ListBoxItem.Run}" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||
KeyboardNavigation.TabNavigation="Continue" AutomationProperties.Name="{Binding RunsHeading}"
|
||
Visibility="{Binding HasRuns, Converter={StaticResource BoolToVisibility}}">
|
||
<ListBox.ItemTemplate>
|
||
<DataTemplate DataType="{x:Type j:ScheduleRunViewModel}">
|
||
<Grid Height="34" Margin="14,0">
|
||
<Grid.ColumnDefinitions>
|
||
<ColumnDefinition Width="0.6*" MinWidth="110" MaxWidth="170" />
|
||
<ColumnDefinition Width="0.7*" MinWidth="90" MaxWidth="150" />
|
||
<ColumnDefinition Width="1.4*" MinWidth="120" />
|
||
<ColumnDefinition Width="0.8*" MinWidth="110" MaxWidth="190" />
|
||
<ColumnDefinition Width="Auto" />
|
||
</Grid.ColumnDefinitions>
|
||
<TextBlock Style="{StaticResource Text.Muted}" Text="{Binding WhenText}" ToolTip="{l:Loc Tooltips.Jobs.Schedule.RunWhen}" />
|
||
<TextBlock Grid.Column="1" Style="{StaticResource Text.Muted}" Text="{Binding Kind}" ToolTip="{Binding Kind}" Margin="10,0,0,0" />
|
||
<TextBlock Grid.Column="2" Style="{StaticResource Text.Cell}" Text="{Binding Target}" ToolTip="{Binding Target}" Margin="10,0,0,0" />
|
||
<ui:StatusGlyph Grid.Column="3" Kind="{Binding StateKind}" Text="{Binding StateText}" ToolTip="{Binding StateToolTip}" FontSize="13" VerticalAlignment="Center"
|
||
Margin="10,0,0,0" />
|
||
<Button Grid.Column="4" Style="{StaticResource Button.Row}" Content="{l:Loc Jobs.Schedule.ShowJob}" Command="{Binding ShowCommand}"
|
||
ToolTip="{l:Loc Tooltips.Jobs.Schedule.ShowJob}" AutomationProperties.Name="{Binding ShowName}" VerticalAlignment="Center" Margin="10,0,0,0" />
|
||
</Grid>
|
||
</DataTemplate>
|
||
</ListBox.ItemTemplate>
|
||
</ListBox>
|
||
<TextBlock Grid.Row="1" Text="{l:Loc Jobs.Schedule.NoRuns}" Foreground="{DynamicResource Brush.TextMuted}" Margin="14,10"
|
||
Visibility="{Binding IsRunsEmpty, Converter={StaticResource BoolToVisibility}}" />
|
||
</Grid>
|
||
</Border>
|
||
|
||
<ui:EmptyState Grid.RowSpan="2" Message="{l:Loc Jobs.Schedule.NotRunning}" Visibility="{Binding IsUnavailable, Converter={StaticResource BoolToVisibility}}" />
|
||
</Grid>
|
||
</UserControl>
|