Owner review 1, phase 3a (docs/requests/2026-10-15-owner-review-1.md, R1). The desktop rail is 200 px wide, so the section names fit in every language, and collapses to 48 px of icons with its ≡ button or Ctrl+B. Collapsed, each icon's tooltip names its section before saying what it is for, while screen readers keep the name and the description. The choice is written to the settings file the moment it changes (nothing else restarts) and survives Settings › Reset all and Import; Ctrl+B waits behind the first-run dialog like Ctrl+1…6, and a held key toggles once. The admin panel's sidebar is 256 px and collapses to icons the same way, with its own ≡ button or Ctrl+B (on the physical key where the layout's B types no Latin letter, so Cyrillic, Greek, Hebrew and Arabic layouts work). The choice is kept in the browser, for the page when the browser refuses storage, and the tables fit their columns again after each toggle. At 900 px and below it stays the top bar and Ctrl+B stays the browser's. The wider rail leaves 49-72 px less for every screen at the 1200 px minimum. Six adversarial review rounds found what that cut, and in every shipped language no action is cut off now: the Jobs columns share their width (Target and Progress give way first, Kind/Where/State capped on wide windows), the editor's preview tools take a second line, a server job's Cancel has its own header column, the Archive tree keeps a year's label, the Import rows and result, the certificates and cache rows and the frame table fit. Headers, titles and cells that may be shortened end in an ellipsis and show their text in their tooltip; state tooltips start with the state, and their explanations were reworded not to repeat it (a queued job "waits for its turn", jobs running one at a time). The crop-result tool sits beside Crop mask, disabled with its reason while the mask is off. Tests check these rows in all 38 languages at 1200 px; the App test program now shuts WPF down in order, so its exit no longer crashes after every test passed. Phase 3 lands as two commits: R7 (the Edit section) edits the same shell files and follows. Also updates BRIEF (12.1, 14.8, 24), DECISIONS, CHANGELOG, STATUS, the request file, DESIGN and the mockups; every new or reworded string is in all 38 languages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
150 lines
6.1 KiB
C#
150 lines
6.1 KiB
C#
using System.Windows.Input;
|
|
using Titano.App.Infrastructure;
|
|
using Titano.App.Sections;
|
|
using Titano.Core.Localization;
|
|
using Titano.Core.Model;
|
|
using Titano.Ui.Controls;
|
|
using Titano.Ui.Mvvm;
|
|
|
|
namespace Titano.App.Jobs;
|
|
|
|
/// <summary>A row action: label, tooltip, the name screen readers hear (label and row) and command (26-px row buttons, DESIGN §4 tables).</summary>
|
|
public sealed record JobAction(string Text, string ToolTip, string AccessibleName, ICommand Command);
|
|
|
|
/// <summary>One row of the Jobs table (Jobs.html): kind, target, progress, speed, left, where, state, actions, log.</summary>
|
|
public sealed class JobRowViewModel : ObservableObject
|
|
{
|
|
private readonly JobActions _actions;
|
|
private JobEntry _entry;
|
|
private int _queuePosition;
|
|
private bool _isExpanded;
|
|
private string? _logTail;
|
|
|
|
internal JobRowViewModel(JobEntry entry, int queuePosition, JobActions actions)
|
|
{
|
|
_entry = entry;
|
|
_queuePosition = queuePosition;
|
|
_actions = actions;
|
|
ToggleLogCommand = new RelayCommand(() => IsExpanded = !IsExpanded);
|
|
}
|
|
|
|
public JobEntry Entry => _entry;
|
|
public Guid Id => _entry.Id;
|
|
public Job Job => _entry.Job;
|
|
|
|
public string Kind => JobText.Kind(_entry.Job.Kind);
|
|
|
|
public string Target => _entry.Job.TargetLabel ?? string.Empty;
|
|
|
|
/// <summary>"Render · Harbour sunset → 4K HEVC": the row's name for screen readers.</summary>
|
|
public string AccessibleName => JobText.Name(_entry.Job);
|
|
|
|
/// <summary>Progress 0…1 (0 while unknown).</summary>
|
|
public double Progress => _entry.State == JobState.Done ? 1 : _entry.Fraction ?? 0;
|
|
|
|
/// <summary>"62 %", "—" while queued or unknown.</summary>
|
|
public string PercentText => _entry.State == JobState.Done ? Formatting.Percent(1) : _entry.Fraction is { } f && _entry.State != JobState.Queued ? Formatting.Percent(f) : "—";
|
|
|
|
public string SpeedText => _entry.State is JobState.Running or JobState.Done ? Blank(JobText.Speed(_entry.Job.Kind, _entry.ItemsPerSecond)) : "—";
|
|
|
|
public string LeftText => Blank(JobText.Left(_entry, _queuePosition));
|
|
|
|
public string WhereText => _entry.State == JobState.Queued ? Loc.L("Jobs.Where.ThisPc") : Blank(JobText.Where(_entry.Job.NodeId, _actions.WorkerId));
|
|
|
|
public string StateText => JobText.State(_entry);
|
|
|
|
/// <summary>"Render · Harbour sunset: done · 3:00": what a screen reader announces when the state changes (not progress).</summary>
|
|
public string StateAnnouncement => Loc.L("Jobs.Row.State", AccessibleName, StateText);
|
|
|
|
/// <summary>Glyph and colour of the state (paired with the word, never colour alone).</summary>
|
|
public StatusKind StateKind => _entry.State switch
|
|
{
|
|
JobState.Running => StatusKind.Running,
|
|
JobState.Queued => StatusKind.Queued,
|
|
JobState.Paused => StatusKind.Paused,
|
|
JobState.Done => StatusKind.Done,
|
|
JobState.Failed => StatusKind.Failed,
|
|
_ => StatusKind.Offline,
|
|
};
|
|
|
|
/// <summary>
|
|
/// The state as the cell shows it (whole: the narrow column cuts longer states at the minimum window), then the error of
|
|
/// a failed job or what the state means (worded not to repeat the state).
|
|
/// </summary>
|
|
public string StateToolTip => string.Join(Loc.Separator, StateText,
|
|
_entry.Job.Error is { Length: > 0 } error ? error : Loc.L("Tooltips.Jobs.State." + _entry.State));
|
|
|
|
/// <summary>Muted text for rows that are not doing anything (queued, history), as in the mockup.</summary>
|
|
public bool IsDimmed => _entry.State is JobState.Queued or JobState.Done or JobState.Cancelled;
|
|
|
|
public bool IsFailed => _entry.State == JobState.Failed;
|
|
public bool IsDone => _entry.State == JobState.Done;
|
|
|
|
public IReadOnlyList<JobAction> Actions => _actions.For(_entry);
|
|
|
|
public ICommand ToggleLogCommand { get; }
|
|
|
|
public bool IsExpanded
|
|
{
|
|
get => _isExpanded;
|
|
set
|
|
{
|
|
if (!Set(ref _isExpanded, value)) return;
|
|
OnPropertyChanged(nameof(ToggleToolTip));
|
|
OnPropertyChanged(nameof(ToggleName));
|
|
if (value) _ = _actions.LoadLogAsync(this);
|
|
}
|
|
}
|
|
|
|
public string ToggleToolTip => Loc.L(_isExpanded ? "Tooltips.Jobs.HideLog" : "Tooltips.Jobs.ShowLog");
|
|
|
|
/// <summary>"Show log: Render · Harbour sunset": the expander names its row.</summary>
|
|
public string ToggleName => Loc.L("Jobs.ActionFor", Loc.L(_isExpanded ? "Jobs.Log.Hide" : "Jobs.Log.Show"), AccessibleName);
|
|
|
|
/// <summary>The last lines of the job log, plus the live message while it runs.</summary>
|
|
public string LogText
|
|
{
|
|
get
|
|
{
|
|
var tail = _logTail ?? _entry.Job.LogTail ?? string.Empty;
|
|
if (_entry.State == JobState.Running && _entry.Message is { Length: > 0 } message && !tail.EndsWith(message, StringComparison.Ordinal))
|
|
tail = tail.Length == 0 ? message : tail + "\n" + message;
|
|
return tail.Length == 0 ? Loc.L("Jobs.Log.Empty") : tail;
|
|
}
|
|
}
|
|
|
|
internal void SetLog(string? logTail)
|
|
{
|
|
_logTail = logTail;
|
|
OnPropertyChanged(nameof(LogText));
|
|
}
|
|
|
|
/// <summary>Refreshes the row from the model; returns true when it changed position-relevant data.</summary>
|
|
internal void Update(JobEntry entry, int queuePosition)
|
|
{
|
|
var stateChanged = entry.State != _entry.State;
|
|
_entry = entry;
|
|
_queuePosition = queuePosition;
|
|
if (stateChanged)
|
|
{
|
|
_logTail = null;
|
|
OnAllPropertiesChanged();
|
|
if (_isExpanded) _ = _actions.LoadLogAsync(this);
|
|
return;
|
|
}
|
|
OnPropertyChanged(nameof(Progress));
|
|
OnPropertyChanged(nameof(PercentText));
|
|
OnPropertyChanged(nameof(SpeedText));
|
|
OnPropertyChanged(nameof(LeftText));
|
|
OnPropertyChanged(nameof(WhereText));
|
|
OnPropertyChanged(nameof(StateText));
|
|
OnPropertyChanged(nameof(StateToolTip));
|
|
OnPropertyChanged(nameof(StateAnnouncement));
|
|
if (_isExpanded) OnPropertyChanged(nameof(LogText));
|
|
}
|
|
|
|
internal void Refresh() => OnAllPropertiesChanged();
|
|
|
|
private static string Blank(string text) => text.Length == 0 ? "—" : text;
|
|
}
|