feat: single setup, mass-pass progress, per-server homes, Desktop shares its library (owner review 5, v1.1.0) (#68)
CI / Build and test (push) Successful in 11m36s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 12s
Release / Build, test and publish (push) Successful in 14m56s
CI / PostgreSQL 16 integration (push) Successful in 10m11s
CI / PostgreSQL 17 integration (push) Successful in 10m15s
CI / Docker image (push) Successful in 45s
Release / Server image (push) Successful in 4m55s
CI / Build and test (push) Successful in 11m36s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 12s
Release / Build, test and publish (push) Successful in 14m56s
CI / PostgreSQL 16 integration (push) Successful in 10m11s
CI / PostgreSQL 17 integration (push) Successful in 10m15s
CI / Docker image (push) Successful in 45s
Release / Server image (push) Successful in 4m55s
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #68.
This commit is contained in:
1 parent
988068ee8e
commit
20d64af4a4
793 files changed
+23882
-2096
No files matched your search
@@ -299,14 +299,20 @@
|
||||
<ItemsControl ItemsSource="{Binding Recent}" Focusable="False">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type ar:MaintenanceRow}">
|
||||
<Grid Height="28">
|
||||
<Grid MinHeight="28">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" MinWidth="90" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="{Binding DateText}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" />
|
||||
<TextBlock Grid.Column="1" Text="{Binding Text}" Margin="12,0" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" ToolTip="{Binding Text}" />
|
||||
<!-- A running line says what its job does now under it, muted (owner review 5, #65); a paused one where it stopped. -->
|
||||
<StackPanel Grid.Column="1" Margin="12,0" VerticalAlignment="Center">
|
||||
<TextBlock Text="{Binding Text}" TextTrimming="CharacterEllipsis" ToolTip="{Binding Text}" />
|
||||
<TextBlock Text="{Binding Detail}" FontSize="{StaticResource Size.Chip}" Foreground="{DynamicResource Brush.TextMuted}" TextTrimming="CharacterEllipsis"
|
||||
Typography.NumeralAlignment="Tabular" ToolTip="{Binding DetailToolTip}" Margin="0,0,0,3"
|
||||
Visibility="{Binding HasDetail, Converter={StaticResource BoolToVisibility}}" />
|
||||
</StackPanel>
|
||||
<!-- The outcome in its state's colour and glyph (Archive.html: accent while running, green when done). -->
|
||||
<ui:StatusGlyph Grid.Column="2" Kind="{Binding StateKind}" Text="{Binding StateText}" FontSize="12" VerticalAlignment="Center"
|
||||
Typography.NumeralAlignment="Tabular" ToolTip="{Binding StateToolTip}" />
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace Chronos.App.Sections;
|
||||
public sealed class ArchiveViewModel : SectionViewModel
|
||||
{
|
||||
private const int RecentCount = 6;
|
||||
private static readonly TimeSpan RecentInterval = TimeSpan.FromMilliseconds(500);
|
||||
private const int PageSize = 1000;
|
||||
private static readonly TimeSpan ReloadDelay = TimeSpan.FromSeconds(2);
|
||||
|
||||
@@ -72,6 +73,13 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
private IReadOnlyList<ChartItem> _formats = [];
|
||||
private IReadOnlyList<HealthLineViewModel> _health = [];
|
||||
private IReadOnlyList<MaintenanceRow> _recent = [];
|
||||
|
||||
/// <summary>The jobs behind <see cref="Recent"/>, their running ones' latest progress, and the ids whose progress counts here.</summary>
|
||||
private IReadOnlyList<Job> _recentJobs = [];
|
||||
private readonly Dictionary<Guid, JobProgressInfo> _recentLive = [];
|
||||
private readonly System.Collections.Concurrent.ConcurrentDictionary<Guid, JobProgressInfo> _recentPending = new();
|
||||
private HashSet<Guid> _recentRunning = [];
|
||||
private CoalescingThrottle? _recentThrottle;
|
||||
private IReadOnlyList<DuplicateRowViewModel>? _duplicates;
|
||||
private IReadOnlyList<OrphanRowViewModel>? _orphans;
|
||||
private bool _findingDuplicates;
|
||||
@@ -524,7 +532,12 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
{
|
||||
_reloadDelay.Stop();
|
||||
_search?.Cancel();
|
||||
if (_jobEvents && Services.Jobs is { } jobs) jobs.JobChanged -= OnJobChanged;
|
||||
if (_jobEvents && Services.Jobs is { } jobs)
|
||||
{
|
||||
jobs.JobChanged -= OnJobChanged;
|
||||
jobs.Progress -= OnProgress;
|
||||
}
|
||||
_recentThrottle?.Dispose();
|
||||
_waitingReorganize = null;
|
||||
_dialog?.Dispose();
|
||||
base.Dispose();
|
||||
@@ -663,6 +676,10 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
foreach (var kind in MaintenanceReports.MaintenanceKinds)
|
||||
jobs.AddRange((await db.Jobs.ListAsync(null, kind, RecentCount)).Items.Where(j => j.TargetIds.Contains(archive.Id)));
|
||||
if (!IsShowing(archive)) return;
|
||||
_recentJobs = jobs;
|
||||
_recentLive.Clear();
|
||||
_recentPending.Clear();
|
||||
Volatile.Write(ref _recentRunning, [.. jobs.Where(j => j.State == JobState.Running).Select(j => j.Id)]);
|
||||
Recent = MaintenanceReports.Recent(jobs, RecentCount);
|
||||
var scan = jobs.Where(j => j.Kind == JobKind.Scan && j is { State: JobState.Done, Finished: not null, Started: not null })
|
||||
.MaxBy(j => j.Finished);
|
||||
@@ -675,15 +692,59 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
{
|
||||
if (_jobEvents || Services.Jobs is not { } jobs) return;
|
||||
jobs.JobChanged += OnJobChanged;
|
||||
// A running Recent line follows its job (owner review 5, #65), at most twice a second.
|
||||
_recentThrottle = new CoalescingThrottle(RecentInterval, SynchronizationContext.Current, FlushRecent);
|
||||
jobs.Progress += OnProgress;
|
||||
_jobEvents = true;
|
||||
}
|
||||
|
||||
/// <summary>Progress of a running job of "Recent maintenance" (any thread): kept until the next flush.</summary>
|
||||
private void OnProgress(JobProgressInfo progress)
|
||||
{
|
||||
if (!Volatile.Read(ref _recentRunning).Contains(progress.JobId)) return;
|
||||
_recentPending[progress.JobId] = progress;
|
||||
_recentThrottle?.Signal();
|
||||
}
|
||||
|
||||
/// <summary>A maintenance job changed state: its Recent line shows it, and its progress counts while it runs (UI thread).</summary>
|
||||
private void TrackRecent(Job job)
|
||||
{
|
||||
if (_archive is not { } archive || !_loaded) return;
|
||||
var jobs = MaintenanceReports.Track(_recentJobs, job, archive.Id);
|
||||
if (ReferenceEquals(jobs, _recentJobs)) return;
|
||||
_recentJobs = jobs;
|
||||
var running = new HashSet<Guid>(Volatile.Read(ref _recentRunning));
|
||||
if (job.State == JobState.Running) running.Add(job.Id);
|
||||
else
|
||||
{
|
||||
running.Remove(job.Id);
|
||||
_recentLive.Remove(job.Id);
|
||||
}
|
||||
Volatile.Write(ref _recentRunning, running);
|
||||
Recent = MaintenanceReports.Recent(_recentJobs, RecentCount, _recentLive);
|
||||
}
|
||||
|
||||
/// <summary>The running Recent lines with their latest progress (UI thread).</summary>
|
||||
private void FlushRecent()
|
||||
{
|
||||
var changed = false;
|
||||
foreach (var id in _recentPending.Keys)
|
||||
{
|
||||
if (!_recentPending.TryRemove(id, out var progress) || !_recentRunning.Contains(id)) continue;
|
||||
_recentLive[id] = progress;
|
||||
changed = true;
|
||||
}
|
||||
if (changed) Recent = MaintenanceReports.Recent(_recentJobs, RecentCount, _recentLive);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A finished job on this archive or its sequences changes the figures: read them again once the jobs settle (a
|
||||
/// burst of analyses after an import reloads once). Jobs of other archives are none of this screen's business.
|
||||
/// A maintenance job of this archive queued, started, paused or ended: its Recent line follows it, live while it runs
|
||||
/// (owner review 5, #65). A finished job on this archive or its sequences changes the figures: read them again once the
|
||||
/// jobs settle (a burst of analyses after an import reloads once). Jobs of other archives are none of this screen's business.
|
||||
/// </summary>
|
||||
private void OnJobChanged(Job job)
|
||||
{
|
||||
if (MaintenanceReports.MaintenanceKinds.Contains(job.Kind)) System.Windows.Application.Current?.Dispatcher.BeginInvoke(() => TrackRecent(job));
|
||||
if (job.State is not (JobState.Done or JobState.Failed)) return;
|
||||
if (job.Kind is not (JobKind.Scan or JobKind.Rebuild or JobKind.Verify or JobKind.Maintenance or JobKind.Import or JobKind.Proxies or JobKind.Thumbs
|
||||
or JobKind.LightAnalyse or JobKind.DeepAnalyse or JobKind.Move or JobKind.Convert)) return;
|
||||
|
||||
@@ -989,7 +989,20 @@ public sealed class ImportViewModel : SectionViewModel
|
||||
/// <summary>What the signed-in user may still store on the server; null without a quota.</summary>
|
||||
private long? ServerSpace() => Services.Server.User is { QuotaBytes: > 0 } user ? System.Math.Max(0, user.QuotaBytes - user.UsedBytes) : null;
|
||||
|
||||
private string ServerStagingRoot => Path.Combine(CacheStore.Folder(Services.Environment, Services.Settings), "server-import");
|
||||
/// <summary>
|
||||
/// Where an import to the server is staged before it is uploaded: the signed-in server's own folder of the cache
|
||||
/// (<c>servers\<id>\import</c>, owner review 5); signed out, the cache's former shared folder.
|
||||
/// </summary>
|
||||
private string ServerStagingRoot
|
||||
{
|
||||
get
|
||||
{
|
||||
var cache = CacheStore.Folder(Services.Environment, Services.Settings);
|
||||
return Services.Sync.Server is { } server
|
||||
? Path.Combine(CacheStore.ServerFolder(cache, server, Services.Sync.Identity), Chronos.Core.IO.HomeFolders.Import)
|
||||
: Path.Combine(cache, Chronos.Data.Homes.HomeLayoutMigration.LegacyServerImport);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task PlanAsync()
|
||||
{
|
||||
|
||||
@@ -187,13 +187,20 @@
|
||||
ui:ButtonIcon.Glyph="{StaticResource Icon.ChevronRight}" Command="{Binding ToggleLogCommand}"
|
||||
ToolTip="{Binding ToggleToolTip}" AutomationProperties.Name="{Binding ToggleName}" />
|
||||
<TextBlock Grid.Column="1" Style="{StaticResource Text.Muted}" Text="{Binding Kind}" Margin="10,0,0,0" ToolTip="{Binding Kind}" />
|
||||
<!-- A job a schedule queued carries the "Scheduled" pill after its target, which gives way first. -->
|
||||
<!-- A job a schedule queued carries the "Scheduled" pill after its target, which gives way first. A running job's
|
||||
status line (what it does now; where a paused one stopped) sits under the target inside the 38 px row, muted, and is
|
||||
never announced (DECISIONS row 158). -->
|
||||
<DockPanel Grid.Column="2" Margin="10,0,0,0">
|
||||
<Border DockPanel.Dock="Right" Style="{StaticResource Pill.Auto}" Height="20" Padding="7,0" Margin="8,0,0,0" VerticalAlignment="Center"
|
||||
ToolTip="{l:Loc Tooltips.Jobs.Scheduled}" Visibility="{Binding IsScheduled, Converter={StaticResource BoolToVisibility}}">
|
||||
<TextBlock Text="{l:Loc Jobs.Scheduled}" FontSize="{StaticResource Size.Chip}" Foreground="{DynamicResource Brush.Accent}" VerticalAlignment="Center" />
|
||||
</Border>
|
||||
<TextBlock Style="{StaticResource Text.Cell}" Text="{Binding Target}" ToolTip="{Binding Target}" />
|
||||
<StackPanel VerticalAlignment="Center">
|
||||
<TextBlock Style="{StaticResource Text.Cell}" Text="{Binding Target}" ToolTip="{Binding Target}" />
|
||||
<TextBlock x:Name="Status" Style="{StaticResource Text.Cell}" Text="{Binding StatusText}" ToolTip="{Binding StatusToolTip}"
|
||||
FontSize="{StaticResource Size.Chip}" Foreground="{DynamicResource Brush.TextMuted}"
|
||||
Visibility="{Binding HasStatus, Converter={StaticResource BoolToVisibility}}" />
|
||||
</StackPanel>
|
||||
</DockPanel>
|
||||
<Grid Grid.Column="3" Margin="10,0,0,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
|
||||
@@ -457,7 +457,8 @@ public sealed class JobsViewModel : SectionViewModel
|
||||
private void UpdateShell()
|
||||
{
|
||||
if (_model.Current is { } current)
|
||||
Shell.SetJob(JobText.Bar(current), current.Fraction ?? 0, indeterminate: current.Fraction is null, name: JobText.Name(current.Job));
|
||||
Shell.SetJob(JobText.Bar(current), current.Fraction ?? 0, indeterminate: current.Fraction is null, name: JobText.Name(current.Job),
|
||||
toolTip: JobText.BarToolTip(current));
|
||||
else
|
||||
Shell.SetJob(null, 0);
|
||||
// The status strip and the Running chip count the same jobs: running or paused (Jobs.html). The rail badge adds the
|
||||
|
||||
@@ -189,7 +189,7 @@ public sealed class SequencePickerViewModel : LocalizedViewModel
|
||||
{
|
||||
var generation = _generation;
|
||||
foreach (var item in WorkspaceItems.Where(i => change.ProjectId is { } id ? i.ProjectId == id
|
||||
: i.Entry.IsServerHome && string.Equals(i.Entry.Home.Server, change.Server, StringComparison.OrdinalIgnoreCase)).ToList())
|
||||
: i.Entry.IsServerHome && Shell.Services.Workspace.SameServer(i.Entry.Home.Server, change.Server)).ToList())
|
||||
{
|
||||
if (generation != _generation) return;
|
||||
try
|
||||
|
||||
@@ -643,7 +643,8 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
{
|
||||
workspace.Remember(row.Id, entry.ProjectId);
|
||||
workspace.RecordOpened(entry.ProjectId);
|
||||
return (new WorkspaceSequenceSource(workspace.Sync, entry.ProjectId, db, decoder, services.Engine), row.DisplayTitle);
|
||||
return (new WorkspaceSequenceSource(workspace.SyncOf(entry.ProjectId), entry.ProjectId, db, decoder, services.Engine,
|
||||
hold: workspace.HoldInEditor(entry.ProjectId)), row.DisplayTitle);
|
||||
}
|
||||
var projectId = entry?.ProjectId ?? request?.ProjectId;
|
||||
string? newName = null;
|
||||
@@ -748,9 +749,10 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
// Its analyses and renders travel on a connection of the signed-in session, when that is the project's server:
|
||||
// made again whenever the sign-in changes, so a project opened signed out renders once signed in.
|
||||
var server = entry.Home.Server;
|
||||
var editorHome = new WorkspaceServerHome(() => string.Equals(sync.Server, server, StringComparison.OrdinalIgnoreCase) ? sync.ConnectEditor() : null,
|
||||
var editorHome = new WorkspaceServerHome(() => sync.Identity.Same(sync.Server, server) ? sync.ConnectEditor() : null,
|
||||
() => sync.Session);
|
||||
return new ServerOpen((new WorkspaceSequenceSource(workspace.Sync, entry.ProjectId, db, decoder, services.Engine, editorHome), entry.SequenceTitle));
|
||||
return new ServerOpen((new WorkspaceSequenceSource(workspace.SyncOf(entry.ProjectId), entry.ProjectId, db, decoder, services.Engine, editorHome,
|
||||
workspace.HoldInEditor(entry.ProjectId)), entry.SequenceTitle));
|
||||
}
|
||||
// An account that may not edit checks nothing out: it is shown with proxies, read-only, as on an older server.
|
||||
if (!sync.Policy.CanEdit || sync.ServerHome(remoteId) is not { } home) return null;
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
xmlns:l="clr-namespace:Chronos.Ui.Localization;assembly=Chronos.Ui"
|
||||
xmlns:infra="clr-namespace:Chronos.App.Infrastructure"
|
||||
xmlns:shell="clr-namespace:Chronos.App.Shell"
|
||||
xmlns:srv="clr-namespace:Chronos.App.Server">
|
||||
xmlns:srv="clr-namespace:Chronos.App.Server"
|
||||
xmlns:sec="clr-namespace:Chronos.App.Sections">
|
||||
<UserControl.Resources>
|
||||
<Style x:Key="Text.RowLabel" TargetType="TextBlock" BasedOn="{StaticResource Text.Label}">
|
||||
<Setter Property="MinWidth" Value="60" />
|
||||
@@ -42,14 +43,90 @@
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
|
||||
<!-- Server.html: the connection panel, then the sync table. The render-node status panel is not built (see the decisions). -->
|
||||
<!-- Server.html: this PC's shared library, the connection panel, the server's jobs while any run or wait paused, then the sync
|
||||
table. The render-node status panel is not built (see the decisions). -->
|
||||
<Grid Margin="20,16,20,12">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Border Style="{StaticResource Border.Panel}" Padding="16,14">
|
||||
<!-- This library (owner review 5, #67): sharing state, addresses with Copy, ports, fingerprint, temporary admin password,
|
||||
clients and the admin panel; off, one row and Sharing settings. -->
|
||||
<Border Style="{StaticResource Border.Panel}" Padding="16,12" DataContext="{Binding SharePanel}">
|
||||
<StackPanel>
|
||||
<DockPanel>
|
||||
<TextBlock Style="{StaticResource Text.RowLabel}" Text="{l:Loc Server.Share.Title}" FontWeight="SemiBold" VerticalAlignment="Center" />
|
||||
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Compact}" Content="{l:Loc Server.Share.AdminPanel}" Command="{Binding AdminPanelCommand}"
|
||||
ToolTip="{l:Loc Tooltips.Server.Share.AdminPanel}" Visibility="{Binding IsOn, Converter={StaticResource BoolToVisibility}}" />
|
||||
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Compact}" Content="{l:Loc Server.Share.Settings}" Command="{Binding SettingsCommand}"
|
||||
ToolTip="{l:Loc Tooltips.Server.Share.Settings}" Visibility="{Binding IsNotShared, Converter={StaticResource BoolToVisibility}}" />
|
||||
<WrapPanel VerticalAlignment="Center">
|
||||
<ui:StatusGlyph Kind="{Binding StatusKind}" Text="{Binding StateText}" FontSize="13" VerticalAlignment="Center" ToolTip="{l:Loc Tooltips.Server.Share.State}"
|
||||
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding StateText}" />
|
||||
<Button Style="{StaticResource Button.Compact}" Content="{l:Loc Server.Share.Restart}" Command="{Binding RestartCommand}" ToolTip="{l:Loc Tooltips.Server.Share.Restart}"
|
||||
Margin="12,0,0,0" Visibility="{Binding HasFailed, Converter={StaticResource BoolToVisibility}}" />
|
||||
</WrapPanel>
|
||||
</DockPanel>
|
||||
<ui:StatusGlyph Kind="Error" Text="{Binding Reason}" FontSize="12" Margin="0,8,0,0" HorizontalAlignment="Left"
|
||||
Visibility="{Binding Reason, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
|
||||
<ui:StatusGlyph Kind="Warning" Text="{l:Loc Server.Share.LegacyService}" FontSize="12" Margin="0,8,0,0" HorizontalAlignment="Left"
|
||||
ToolTip="{l:Loc Tooltips.Server.Share.LegacyService}" Visibility="{Binding HasLegacyService, Converter={StaticResource BoolToVisibility}}" />
|
||||
<Grid Margin="0,10,0,0" Visibility="{Binding IsOn, Converter={StaticResource BoolToVisibility}}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Style="{StaticResource Text.RowLabel}" Text="{l:Loc Server.Share.Addresses}" Margin="0,4,10,0" VerticalAlignment="Top" />
|
||||
<ItemsControl Grid.Column="1" ItemsSource="{Binding Addresses}" ItemsPanel="{StaticResource Panel.Wrap}" Focusable="False">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type sec:ShareAddressRow}">
|
||||
<StackPanel Orientation="Horizontal" Margin="0,0,18,4">
|
||||
<TextBlock Text="{Binding Address}" FlowDirection="LeftToRight" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" />
|
||||
<Button Style="{StaticResource Button.Compact}" Content="{l:Loc Server.Share.Copy}" Command="{Binding CopyCommand}" CommandParameter="{Binding Address}"
|
||||
ToolTip="{l:Loc Tooltips.Server.Share.Copy}" AutomationProperties.Name="{Binding Address}" Margin="8,0,0,0" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
<TextBlock Grid.Row="1" Style="{StaticResource Text.RowLabel}" Text="{l:Loc Server.Share.Ports}" Margin="0,6,10,0" />
|
||||
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding PortsText}" Margin="0,6,0,0" Typography.NumeralAlignment="Tabular" ToolTip="{l:Loc Tooltips.Server.Share.Ports}" />
|
||||
<TextBlock Grid.Row="2" Style="{StaticResource Text.RowLabel}" Text="{l:Loc Server.Share.Fingerprint}" Margin="0,10,10,0" VerticalAlignment="Center" />
|
||||
<StackPanel Grid.Row="2" Grid.Column="1" Orientation="Horizontal" Margin="0,6,0,0">
|
||||
<TextBlock Text="{Binding Fingerprint}" FontFamily="{DynamicResource Font.Mono}" FontSize="12" VerticalAlignment="Center" TextTrimming="CharacterEllipsis"
|
||||
ToolTip="{l:Loc Tooltips.Server.Share.Fingerprint}" />
|
||||
<Button Style="{StaticResource Button.Compact}" Content="{l:Loc Server.Share.Copy}" Command="{Binding CopyFingerprintCommand}"
|
||||
ToolTip="{l:Loc Tooltips.Server.Share.CopyFingerprint}" Margin="8,0,0,0" />
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Row="3" Style="{StaticResource Text.RowLabel}" Text="{l:Loc Server.Share.AdminPassword}" Margin="0,10,10,0" VerticalAlignment="Center"
|
||||
Visibility="{Binding HasAdminPassword, Converter={StaticResource BoolToVisibility}}" />
|
||||
<StackPanel Grid.Row="3" Grid.Column="1" Orientation="Horizontal" Margin="0,6,0,0" Visibility="{Binding HasAdminPassword, Converter={StaticResource BoolToVisibility}}">
|
||||
<TextBlock Text="{Binding PasswordText}" FontFamily="{DynamicResource Font.Mono}" FontSize="12" VerticalAlignment="Center" FlowDirection="LeftToRight"
|
||||
ToolTip="{l:Loc Tooltips.Server.Share.AdminPassword}" />
|
||||
<Button Style="{StaticResource Button.Compact}" Content="{Binding ShowPasswordText}" Command="{Binding ShowPasswordCommand}" ToolTip="{l:Loc Tooltips.Server.Share.Show}"
|
||||
Margin="8,0,0,0" />
|
||||
<Button Style="{StaticResource Button.Compact}" Content="{l:Loc Server.Share.Copy}" Command="{Binding CopyPasswordCommand}"
|
||||
ToolTip="{l:Loc Tooltips.Server.Share.CopyPassword}" Margin="8,0,0,0" />
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Row="4" Style="{StaticResource Text.RowLabel}" Text="{l:Loc Server.Share.Clients}" Margin="0,10,10,0" VerticalAlignment="Top" />
|
||||
<StackPanel Grid.Row="4" Grid.Column="1" Margin="0,10,0,0" ToolTip="{l:Loc Tooltips.Server.Share.Clients}">
|
||||
<TextBlock Text="{Binding ClientsText}" Foreground="{DynamicResource Brush.TextMuted}" />
|
||||
<ItemsControl ItemsSource="{Binding Clients}" Focusable="False" Visibility="{Binding HasClients, Converter={StaticResource BoolToVisibility}}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Row="1" Style="{StaticResource Border.Panel}" Padding="16,14" Margin="0,14,0,0">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
@@ -166,8 +243,11 @@
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- The server's running and paused jobs, live, while there are any (owner review 5, #65). -->
|
||||
<srv:ServerJobsView Grid.Row="2" Margin="0,14,0,0" DataContext="{Binding Jobs}" Visibility="{Binding HasRows, Converter={StaticResource BoolToVisibility}}" />
|
||||
|
||||
<!-- Sequences of this PC and of the server: chips, search, Upload all local; table; footer. -->
|
||||
<Border Grid.Row="1" Style="{StaticResource Border.Panel}" Margin="0,14,0,0" DataContext="{Binding Sync}">
|
||||
<Border Grid.Row="3" Style="{StaticResource Border.Panel}" Margin="0,14,0,0" DataContext="{Binding Sync}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
|
||||
@@ -14,7 +14,8 @@ namespace Chronos.App.Sections;
|
||||
/// <summary>
|
||||
/// Server (BRIEF §12.7, Server.html): address with LAN-discovered servers, connect with trust-on-first-use and login,
|
||||
/// status (name, version, latency, certificate), account and quota, sign out, the options of this PC (render node,
|
||||
/// proxies kept offline, automatic project sync, uploads paused on metered networks) and the sync table (<see cref="Sync"/>).
|
||||
/// proxies kept offline, automatic project sync, uploads paused on metered networks), the server's running and paused jobs
|
||||
/// (<see cref="Jobs"/>) and the sync table (<see cref="Sync"/>).
|
||||
/// The rail badge counts the settings conflicts waiting for a choice.
|
||||
/// </summary>
|
||||
public sealed class ServerViewModel : SectionViewModel
|
||||
@@ -41,11 +42,23 @@ public sealed class ServerViewModel : SectionViewModel
|
||||
Sync = new SyncTableViewModel(shell);
|
||||
_conflicts = Sync.Chips.Single(c => c.Filter == SyncFilter.Conflicts);
|
||||
_conflicts.PropertyChanged += OnConflictsChanged;
|
||||
Jobs = new ServerJobsViewModel(() => ServerJobsViewModel.AccountOf(Session), () => JobsConnection(Session), SynchronizationContext.Current,
|
||||
(title, message) => Shell.Notify(title, message, isError: true));
|
||||
SharePanel = new SharePanelViewModel(shell);
|
||||
}
|
||||
|
||||
/// <summary>Sequences of this PC and of the server, where they stand and what can be done.</summary>
|
||||
public SyncTableViewModel Sync { get; }
|
||||
|
||||
/// <summary>The server's running and paused jobs, live (owner review 5, #65).</summary>
|
||||
public ServerJobsViewModel Jobs { get; }
|
||||
|
||||
/// <summary>Opens the job list's connection for a session; the screenshots put the sample server's jobs here.</summary>
|
||||
internal Func<ServerSession, IServerJobsApi?> JobsConnection { get; set; } = ServerJobsViewModel.ConnectionOf;
|
||||
|
||||
/// <summary>This PC's library shared to the LAN (owner review 5, #67).</summary>
|
||||
public SharePanelViewModel SharePanel { get; }
|
||||
|
||||
public ShellViewModel Shell { get; }
|
||||
|
||||
private ServerSession Session => _session ?? Shell.Services.Server;
|
||||
@@ -212,6 +225,7 @@ public sealed class ServerViewModel : SectionViewModel
|
||||
if (!Shell.Services.Environment.IsCapture) _session.StartDiscovery();
|
||||
Shell.Settings.Encoders.CollectionChanged += OnEncodersChanged;
|
||||
Sync.Attach();
|
||||
Jobs.Refresh();
|
||||
await _session.RestoreAsync();
|
||||
if (_session.Flow.Error is not ConnectError.None and var error && !_session.IsConnected) ErrorText = ServerSession.ErrorText(error, _session.Flow.Address);
|
||||
}
|
||||
@@ -222,6 +236,8 @@ public sealed class ServerViewModel : SectionViewModel
|
||||
if (_session is not null) _session.PropertyChanged -= OnSessionChanged;
|
||||
Shell.Settings.Encoders.CollectionChanged -= OnEncodersChanged;
|
||||
Sync.Dispose();
|
||||
Jobs.Dispose();
|
||||
SharePanel.Dispose();
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
@@ -278,6 +294,7 @@ public sealed class ServerViewModel : SectionViewModel
|
||||
{
|
||||
OnAllPropertiesChanged();
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
Jobs.Refresh();
|
||||
}
|
||||
|
||||
/// <summary>The <see cref="Core.Model.UserRole"/> name of a server role, or null for a role this build does not know.</summary>
|
||||
|
||||
@@ -563,6 +563,28 @@
|
||||
Visibility="{Binding WorkspaceRows.HasUsageText, Converter={StaticResource BoolToVisibility}}" />
|
||||
</StackPanel>
|
||||
</HeaderedContentControl>
|
||||
<!-- Each home keeps its projects in its own folder of the workspace (owner review 5): this PC's archive, then each server. -->
|
||||
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Workspace.Homes}" ToolTip="{l:Loc Tooltips.Settings.Workspace.Homes}"
|
||||
Visibility="{Binding HasHomeFolderRows, Converter={StaticResource BoolToVisibility}}">
|
||||
<ItemsControl ItemsSource="{Binding HomeFolderRows}" Focusable="False">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type st:HomeFolderRow}">
|
||||
<Grid Height="36">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="160" />
|
||||
<ColumnDefinition Width="*" MinWidth="160" MaxWidth="360" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Style="{StaticResource Text.Cell}" Text="{Binding Name}" ToolTip="{Binding ToolTip}" />
|
||||
<TextBlock Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding Path}" ToolTip="{Binding ToolTip}" Foreground="{DynamicResource Brush.TextMuted}"
|
||||
FlowDirection="LeftToRight" HorizontalAlignment="Left" Margin="10,0,0,0" />
|
||||
<Button Grid.Column="2" Style="{StaticResource Button.Row}" Content="{l:Loc Common.Open}" Command="{Binding OpenCommand}"
|
||||
ToolTip="{l:Loc Tooltips.Settings.Workspace.OpenHome}" AutomationProperties.Name="{Binding Name}" Margin="10,0,0,0" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</HeaderedContentControl>
|
||||
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Workspace.SizeLimit}">
|
||||
<ComboBox Width="170" HorizontalAlignment="Left" ItemsSource="{Binding WorkspaceRows.SizeLimitChoices}" SelectedItem="{Binding WorkspaceRows.SelectedSizeLimit}"
|
||||
DisplayMemberPath="Label" ToolTip="{Binding WorkspaceRows.SizeLimitToolTip}" AutomationProperties.Name="{l:Loc Settings.Workspace.SizeLimit}" />
|
||||
@@ -613,6 +635,47 @@
|
||||
|
||||
<!-- ================= Server ================= -->
|
||||
<StackPanel Style="{StaticResource Page}" Visibility="{Binding Page, Converter={x:Static shell:EqualsToVisibilityConverter.Instance}, ConverterParameter=Server}">
|
||||
<!-- Sharing (owner review 5, #67): this PC's library served to the LAN while Chronos runs. -->
|
||||
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Server.Share}">
|
||||
<CheckBox Content="{l:Loc Settings.Server.ShareLibrary}" IsChecked="{Binding ShareRows.Enabled}" ToolTip="{l:Loc Tooltips.Settings.ShareLibrary}" Margin="0,4,0,0" />
|
||||
</HeaderedContentControl>
|
||||
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Server.ShareName}">
|
||||
<TextBox Style="{StaticResource TextBox.Setting}" Text="{Binding ShareRows.Name.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
|
||||
shell:EditBehavior.Field="{Binding ShareRows.Name}" ToolTip="{Binding ShareRows.Name.ToolTip}" ui:Field.Placeholder="{Binding ShareRows.PcName}"
|
||||
AutomationProperties.Name="{l:Loc Settings.Server.ShareName}" />
|
||||
</HeaderedContentControl>
|
||||
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Server.HttpsPort}">
|
||||
<TextBox Style="{StaticResource TextBox.SettingNumber}" Text="{Binding ShareRows.HttpsPort.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
|
||||
shell:EditBehavior.Field="{Binding ShareRows.HttpsPort}" ToolTip="{Binding ShareRows.HttpsPort.ToolTip}" AutomationProperties.Name="{l:Loc Settings.Server.HttpsPort}" />
|
||||
</HeaderedContentControl>
|
||||
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Server.HttpPort}">
|
||||
<TextBox Style="{StaticResource TextBox.SettingNumber}" Text="{Binding ShareRows.HttpPort.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
|
||||
shell:EditBehavior.Field="{Binding ShareRows.HttpPort}" ToolTip="{Binding ShareRows.HttpPort.ToolTip}" AutomationProperties.Name="{l:Loc Settings.Server.HttpPort}" />
|
||||
</HeaderedContentControl>
|
||||
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Server.PublicHttpsPort}">
|
||||
<TextBox Style="{StaticResource TextBox.SettingNumber}" Text="{Binding ShareRows.PublicHttpsPort.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
|
||||
shell:EditBehavior.Field="{Binding ShareRows.PublicHttpsPort}" ToolTip="{Binding ShareRows.PublicHttpsPort.ToolTip}"
|
||||
AutomationProperties.Name="{l:Loc Settings.Server.PublicHttpsPort}" />
|
||||
</HeaderedContentControl>
|
||||
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Server.PublicHttpPort}">
|
||||
<TextBox Style="{StaticResource TextBox.SettingNumber}" Text="{Binding ShareRows.PublicHttpPort.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
|
||||
shell:EditBehavior.Field="{Binding ShareRows.PublicHttpPort}" ToolTip="{Binding ShareRows.PublicHttpPort.ToolTip}"
|
||||
AutomationProperties.Name="{l:Loc Settings.Server.PublicHttpPort}" />
|
||||
</HeaderedContentControl>
|
||||
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Server.Discovery}">
|
||||
<CheckBox Content="{l:Loc Settings.Server.Announce}" IsChecked="{Binding ShareRows.Discovery}" ToolTip="{l:Loc Tooltips.Settings.Discovery}" Margin="0,4,0,0" />
|
||||
</HeaderedContentControl>
|
||||
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Server.ShareFolder}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" MinWidth="160" MaxWidth="360" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox Style="{StaticResource TextBox.Path}" IsReadOnly="True" Text="{Binding ShareRows.Folder, Mode=OneWay}" ToolTip="{l:Loc Tooltips.Settings.ShareFolder}"
|
||||
AutomationProperties.Name="{l:Loc Settings.Server.ShareFolder}" />
|
||||
<Button Grid.Column="1" Content="{l:Loc Common.Open}" Command="{Binding ShareRows.OpenFolderCommand}" ToolTip="{l:Loc Tooltips.Settings.OpenShareFolder}" Margin="10,0,0,0" />
|
||||
</Grid>
|
||||
</HeaderedContentControl>
|
||||
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Server.Default}">
|
||||
<TextBox Style="{StaticResource TextBox.Setting}" Text="{Binding DefaultServer.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
|
||||
shell:EditBehavior.Field="{Binding DefaultServer}" ToolTip="{Binding DefaultServer.ToolTip}" ui:Field.Placeholder="{l:Loc Server.AddressPlaceholder}"
|
||||
@@ -648,6 +711,62 @@
|
||||
</ItemsControl>
|
||||
</Grid>
|
||||
</HeaderedContentControl>
|
||||
<!-- The servers this PC signed in to (owner review 5): id, whether signed in now, the archive of their originals and their share of the cache. -->
|
||||
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Server.Known}" ToolTip="{l:Loc Tooltips.Settings.Server.Known}"
|
||||
Visibility="{Binding HasKnownServers, Converter={StaticResource BoolToVisibility}}">
|
||||
<ItemsControl ItemsSource="{Binding KnownServers}" Focusable="False">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type st:KnownServerRow}">
|
||||
<StackPanel Margin="0,0,0,8">
|
||||
<Grid Height="36">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" MinWidth="120" />
|
||||
<ColumnDefinition Width="170" />
|
||||
<ColumnDefinition Width="90" />
|
||||
<ColumnDefinition Width="90" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Style="{StaticResource Text.Cell}" Text="{Binding Name}" ToolTip="{Binding Name}" HorizontalAlignment="Left" />
|
||||
<TextBlock Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding Address}" ToolTip="{Binding Address}" FlowDirection="LeftToRight"
|
||||
HorizontalAlignment="Left" Margin="10,0,0,0" />
|
||||
<TextBlock Grid.Column="2" Style="{StaticResource Text.Cell}" Text="{Binding ShortId}" ToolTip="{Binding IdToolTip}" FontFamily="{StaticResource Font.Mono}"
|
||||
FontSize="12" FlowDirection="LeftToRight" HorizontalAlignment="Left" Margin="10,0,0,0"
|
||||
AutomationProperties.Name="{l:Loc Settings.Server.ServerId}" />
|
||||
<TextBlock Grid.Column="3" Style="{StaticResource Text.Cell}" Text="{Binding StateText}" ToolTip="{Binding StateToolTip}"
|
||||
Foreground="{DynamicResource Brush.TextMuted}" Margin="10,0,0,0" />
|
||||
</Grid>
|
||||
<Grid Height="32">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="140" />
|
||||
<ColumnDefinition Width="*" MinWidth="160" MaxWidth="360" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Style="{StaticResource Text.Cell}" Text="{l:Loc Settings.Server.Originals}" ToolTip="{l:Loc Tooltips.Settings.Server.Originals}"
|
||||
Foreground="{DynamicResource Brush.TextMuted}" />
|
||||
<TextBlock Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding OriginalsPath}" ToolTip="{l:Loc Tooltips.Settings.Server.Originals}"
|
||||
FlowDirection="LeftToRight" HorizontalAlignment="Left" Margin="10,0,0,0" />
|
||||
<Button Grid.Column="2" Style="{StaticResource Button.Row}" Content="{l:Loc Common.Open}" Command="{Binding OpenOriginalsCommand}"
|
||||
ToolTip="{l:Loc Tooltips.Settings.Server.OpenOriginals}" ToolTipService.ShowOnDisabled="True"
|
||||
AutomationProperties.Name="{l:Loc Settings.Server.Originals}" Margin="10,0,0,0" />
|
||||
</Grid>
|
||||
<Grid Height="32">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="140" />
|
||||
<ColumnDefinition Width="*" MinWidth="160" MaxWidth="360" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Style="{StaticResource Text.Cell}" Text="{l:Loc Settings.Server.Cache}" ToolTip="{l:Loc Tooltips.Settings.Server.Cache}"
|
||||
Foreground="{DynamicResource Brush.TextMuted}" />
|
||||
<TextBlock Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding CachePath}" ToolTip="{l:Loc Tooltips.Settings.Server.Cache}"
|
||||
FlowDirection="LeftToRight" HorizontalAlignment="Left" Margin="10,0,0,0" />
|
||||
<Button Grid.Column="2" Style="{StaticResource Button.Row}" Content="{l:Loc Common.Open}" Command="{Binding OpenCacheCommand}"
|
||||
ToolTip="{l:Loc Tooltips.Settings.Server.OpenCache}" ToolTipService.ShowOnDisabled="True"
|
||||
AutomationProperties.Name="{l:Loc Settings.Server.Cache}" Margin="10,0,0,0" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</HeaderedContentControl>
|
||||
</StackPanel>
|
||||
|
||||
<!-- ================= Updates ================= -->
|
||||
|
||||
@@ -90,8 +90,9 @@ public sealed class SettingsViewModel : SectionViewModel
|
||||
new(SettingsPage.Storage, ["Settings.Storage.Folder", "Settings.Storage.Thumbnails", "Settings.Storage.Limit"]),
|
||||
new(SettingsPage.Workspace, ["Settings.Workspace.Folder", "Settings.Workspace.Move", "Settings.Workspace.SizeLimit", "Settings.Workspace.DefaultMedia",
|
||||
"Settings.Workspace.Sync", "Settings.Workspace.AfterSave", "Settings.Workspace.VersionOnRender", "Settings.Workspace.SaveBeforeRender",
|
||||
"Settings.Workspace.Kept", "Settings.Workspace.CleanAfter", "Settings.Workspace.OpenProject", "Settings.Workspace.Trash"]),
|
||||
new(SettingsPage.Server, ["Settings.Server.Default", "Settings.Server.RenderNode", "Settings.Server.Certificates"]),
|
||||
"Settings.Workspace.Kept", "Settings.Workspace.CleanAfter", "Settings.Workspace.OpenProject", "Settings.Workspace.Trash", "Settings.Workspace.Homes"]),
|
||||
new(SettingsPage.Server, ["Settings.Server.Share", "Settings.Server.ShareName", "Settings.Server.HttpsPort", "Settings.Server.HttpPort",
|
||||
"Settings.Server.PublicHttpsPort", "Settings.Server.PublicHttpPort", "Settings.Server.Discovery", "Settings.Server.ShareFolder", "Settings.Server.Default", "Settings.Server.RenderNode", "Settings.Server.Certificates", "Settings.Server.Known"]),
|
||||
new(SettingsPage.Updates, ["Settings.General.CheckOnStart", "Settings.Updates.Latest", "About.Update.Check", "About.Releases"]),
|
||||
new(SettingsPage.Advanced, ["Settings.Advanced.DataFolder", "Settings.Advanced.Logs", "Settings.Advanced.LogLevel", "Settings.Advanced.KeepLogs",
|
||||
"Settings.Advanced.FileSize", "Settings.Advanced.LogsTotal", "Settings.Advanced.Rotation", "Settings.Advanced.Diagnostics",
|
||||
@@ -177,6 +178,9 @@ public sealed class SettingsViewModel : SectionViewModel
|
||||
// Saving applies them to the log files (App.SaveSettings).
|
||||
Logs = new LogSettingsRows(_s, Save);
|
||||
|
||||
// ---- Server › Sharing (owner review 5, #67); saving applies it to the share (AppServices.SaveSettings). ----
|
||||
ShareRows = new ShareSettingsRows(_s, Save, Shell.Services.Environment.ShareDirectory, Shell.Services.Environment.PcName);
|
||||
|
||||
// ---- Workspace ----
|
||||
WorkspaceRows = new WorkspaceSettingsRows(_s, Save, () => AppEnvironment.Shown(Shell.Services.Workspace.Root), OpenWorkspaceFolder, ChangeWorkspaceFolderAsync,
|
||||
WorkspaceSettingsServices.For(Shell.Services.Workspace, Shell.Services.Dialogs, (title, message, isError) => Shell.Notify(title, message, isError: isError),
|
||||
@@ -272,7 +276,12 @@ public sealed class SettingsViewModel : SectionViewModel
|
||||
if (value == SettingsPage.Rendering && Encoders.Count == 0 && !_isDetecting) _ = DetectEncodersAsync();
|
||||
if (value == SettingsPage.Formats && Formats.Count == 0 && !_isDetectingFormats) _ = DetectFormatsAsync(refresh: false);
|
||||
if (value == SettingsPage.Storage) _ = UpdateCacheUsageAsync();
|
||||
if (value == SettingsPage.Workspace) _ = WorkspaceRows.MeasureAsync();
|
||||
if (value == SettingsPage.Workspace)
|
||||
{
|
||||
_ = WorkspaceRows.MeasureAsync();
|
||||
_ = LoadHomeFoldersAsync();
|
||||
}
|
||||
if (value == SettingsPage.Server) _ = LoadKnownServersAsync();
|
||||
if (value == SettingsPage.Advanced) LoadBackups();
|
||||
}
|
||||
}
|
||||
@@ -741,7 +750,7 @@ public sealed class SettingsViewModel : SectionViewModel
|
||||
{
|
||||
try
|
||||
{
|
||||
ShellActions.Reveal(Shell.Services.Workspace.Store.Root);
|
||||
ShellActions.Reveal(Shell.Services.Workspace.Homes.Root);
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException)
|
||||
{
|
||||
@@ -793,6 +802,16 @@ public sealed class SettingsViewModel : SectionViewModel
|
||||
|
||||
public bool HasCertificates => Certificates.Count > 0;
|
||||
|
||||
/// <summary>Settings › Server › Known servers (owner review 5, #66): the servers this PC signed in to, with their folders.</summary>
|
||||
public ObservableCollection<KnownServerRow> KnownServers { get; } = [];
|
||||
|
||||
public bool HasKnownServers => KnownServers.Count > 0;
|
||||
|
||||
/// <summary>Settings › Workspace › Home folders (owner review 5, #66): where each home keeps its projects.</summary>
|
||||
public ObservableCollection<HomeFolderRow> HomeFolderRows { get; } = [];
|
||||
|
||||
public bool HasHomeFolderRows => HomeFolderRows.Count > 0;
|
||||
|
||||
// ---------------- Updates ----------------
|
||||
|
||||
public bool CheckForUpdates
|
||||
@@ -816,6 +835,9 @@ public sealed class SettingsViewModel : SectionViewModel
|
||||
/// <summary>Level, retention, size limits and rotation of the log files, and the diagnostics bundle's share of each.</summary>
|
||||
public LogSettingsRows Logs { get; }
|
||||
|
||||
/// <summary>Settings › Server › Sharing: this PC's library shared to the LAN (owner review 5, #67).</summary>
|
||||
public ShareSettingsRows ShareRows { get; }
|
||||
|
||||
public ICommand OpenDataFolderCommand { get; }
|
||||
public ICommand OpenLogsCommand { get; }
|
||||
public ICommand ExportDiagnosticsCommand { get; }
|
||||
@@ -897,6 +919,8 @@ public sealed class SettingsViewModel : SectionViewModel
|
||||
Shell.Notify(Loc.L("Settings.Advanced.RestoreFailed"), Loc.L("Errors.Backup.Deferred"), isError: true);
|
||||
break;
|
||||
}
|
||||
NotifyHomeLayout();
|
||||
Shell.Services.Sync.IdentityClash += (name, was) => Shell.Notify(Loc.L("Shell.Homes.Clash"), Loc.L("Errors.Homes.Clash", name, was), isError: true);
|
||||
// BRIEF §6.2: a portable copy in a folder OneDrive synchronises keeps its data in this user's folder instead, and
|
||||
// leaves the data it kept beside it before where it is. Only a user folder that is itself synchronised is unsafe.
|
||||
var environment = Shell.Services.Environment;
|
||||
@@ -1559,6 +1583,27 @@ public sealed class SettingsViewModel : SectionViewModel
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// How the sorting of the folders into homes went at start (owner review 5, #66): sorted, with Open on the workspace;
|
||||
/// pending, when projects in use or a workspace being moved wait for the next start; or failed, with Open on the logs.
|
||||
/// </summary>
|
||||
private void NotifyHomeLayout()
|
||||
{
|
||||
var services = Shell.Services;
|
||||
if (services.HomeLayoutError is { } error)
|
||||
{
|
||||
Shell.Notify(Loc.L("Shell.Homes.Pending"), Loc.L("Errors.Homes.Failed", error.Message), Loc.L("Settings.Advanced.Logs"),
|
||||
Loc.L("Tooltips.Shell.Homes.Logs"), () => ShellActions.Reveal(services.Environment.LogDirectory), isError: true);
|
||||
return;
|
||||
}
|
||||
if (services.HomeLayout is not { } result) return;
|
||||
if (result.Deferred is not null || result.InUse > 0)
|
||||
Shell.Notify(Loc.L("Shell.Homes.Pending"), Loc.L("Shell.Homes.PendingText"));
|
||||
else if (result.ProjectsMoved > 0)
|
||||
Shell.Notify(Loc.L("Shell.Homes.Sorted"), Loc.Plural("Shell.Homes.Moved", result.ProjectsMoved), Loc.L("Common.Open"),
|
||||
Loc.L("Tooltips.Settings.OpenWorkspace"), OpenWorkspaceFolder);
|
||||
}
|
||||
|
||||
private void CancelRestore()
|
||||
{
|
||||
try
|
||||
@@ -1629,6 +1674,7 @@ public sealed class SettingsViewModel : SectionViewModel
|
||||
break;
|
||||
case SettingsPage.Server:
|
||||
_s.RenderNodeOptIn = defaults.RenderNodeOptIn;
|
||||
ShareRows.Reset();
|
||||
break;
|
||||
case SettingsPage.Updates:
|
||||
_s.CheckForUpdates = defaults.CheckForUpdates;
|
||||
@@ -1736,6 +1782,7 @@ public sealed class SettingsViewModel : SectionViewModel
|
||||
foreach (var row in JobPriorities) row.Refresh();
|
||||
Logs.Refresh();
|
||||
WorkspaceRows.Refresh();
|
||||
ShareRows.Refresh();
|
||||
UpdatePreview();
|
||||
LoadCertificates();
|
||||
OnAllPropertiesChanged();
|
||||
@@ -1781,6 +1828,57 @@ public sealed class SettingsViewModel : SectionViewModel
|
||||
Shell.Notify(Loc.L("Settings.Import.Done"));
|
||||
}
|
||||
|
||||
/// <summary>The home folders of the workspace as they are now (read off the UI thread; none while the workspace cannot be read).</summary>
|
||||
private async Task LoadHomeFoldersAsync()
|
||||
{
|
||||
var workspace = Shell.Services.Workspace;
|
||||
if (!workspace.IsEnabled) return;
|
||||
var known = _s.KnownServers.ToList();
|
||||
IReadOnlyList<HomeFolderRow> rows;
|
||||
try
|
||||
{
|
||||
rows = await Task.Run(() => HomeFolderRow.Of(workspace.Homes, known, RevealFolder));
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException)
|
||||
{
|
||||
Log.Info("settings", $"The home folders of the workspace could not be read: {ex.Message}");
|
||||
rows = [];
|
||||
}
|
||||
HomeFolderRows.Clear();
|
||||
foreach (var row in rows) HomeFolderRows.Add(row);
|
||||
OnPropertyChanged(nameof(HasHomeFolderRows));
|
||||
}
|
||||
|
||||
/// <summary>The known servers, most recently seen first, with the archive of their originals and their share of the cache.</summary>
|
||||
private async Task LoadKnownServersAsync()
|
||||
{
|
||||
var services = Shell.Services;
|
||||
IReadOnlyList<Archive> archives = services.Database is { } db ? await db.Archives.ListAsync() : [];
|
||||
var cache = CacheStore.Folder(services.Environment, services.Settings);
|
||||
var signedIn = services.Sync.Server;
|
||||
KnownServers.Clear();
|
||||
foreach (var server in _s.KnownServers.Where(k => k.Id != Guid.Empty).OrderByDescending(k => k.LastSeen))
|
||||
{
|
||||
var key = HomeFolders.IdKey(server.Id);
|
||||
var originals = server.OriginalsArchiveId is { } id ? archives.FirstOrDefault(a => a.Id == id)?.RootPath : null;
|
||||
KnownServers.Add(new KnownServerRow(server, services.Sync.Identity.Same(signedIn, key), originals,
|
||||
CacheStore.ServerFolder(cache, key, services.Sync.Identity), RevealFolder));
|
||||
}
|
||||
OnPropertyChanged(nameof(HasKnownServers));
|
||||
}
|
||||
|
||||
private void RevealFolder(string folder)
|
||||
{
|
||||
try
|
||||
{
|
||||
ShellActions.Reveal(folder);
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
Shell.ReportError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadCertificates()
|
||||
{
|
||||
Certificates.Clear();
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
using Chronos.App.Infrastructure;
|
||||
using Chronos.App.Server;
|
||||
using Chronos.App.Settings;
|
||||
using Chronos.App.Shell;
|
||||
using Chronos.Core.Diagnostics;
|
||||
using Chronos.Core.Windows.Services;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Ui.Controls;
|
||||
using Chronos.Ui.Mvvm;
|
||||
|
||||
namespace Chronos.App.Sections;
|
||||
|
||||
/// <summary>An address of the shared library with its Copy button.</summary>
|
||||
public sealed record ShareAddressRow(string Address, ICommand CopyCommand);
|
||||
|
||||
/// <summary>
|
||||
/// Server › This library (owner review 5, #67): whether this PC shares its library, why not when it could not start
|
||||
/// (with Restart), the addresses with Copy, the ports, the certificate's fingerprint with Copy, the first administrator's
|
||||
/// temporary password while it exists (Show, Copy), the clients of the last minutes and the admin panel. Off, one row and
|
||||
/// Sharing settings. Follows <see cref="LibraryShare"/> on the UI thread; the clients are read again every few seconds. A
|
||||
/// warning row shows while the 1.0 Windows Server's service is installed, read at the start and at each change of state.
|
||||
/// </summary>
|
||||
public sealed class SharePanelViewModel : LocalizedViewModel
|
||||
{
|
||||
private static readonly TimeSpan RefreshInterval = TimeSpan.FromSeconds(10);
|
||||
|
||||
private readonly ShellViewModel _shell;
|
||||
private readonly LibraryShare _share;
|
||||
private readonly DispatcherTimer? _timer;
|
||||
private readonly Func<bool> _legacyService;
|
||||
private bool _showPassword;
|
||||
private bool _hasLegacyService;
|
||||
|
||||
/// <param name="shell">The shell whose shared library the panel shows.</param>
|
||||
/// <param name="legacyService">Whether the 1.0 Windows Server is installed; the Service Control Manager by default (never during screenshots).</param>
|
||||
public SharePanelViewModel(ShellViewModel shell, Func<bool>? legacyService = null)
|
||||
{
|
||||
_shell = shell;
|
||||
_share = shell.Services.Share;
|
||||
_legacyService = legacyService ?? (shell.Services.Environment.IsCapture ? () => false : () => ServiceProbe.IsInstalled(ServiceProbe.LegacyServer));
|
||||
_hasLegacyService = _legacyService();
|
||||
_share.PropertyChanged += OnShareChanged;
|
||||
CopyCommand = new RelayCommand(p => Copy(p as string));
|
||||
CopyFingerprintCommand = new RelayCommand(() => Copy(_share.Fingerprint), () => _share.Fingerprint is not null);
|
||||
ShowPasswordCommand = new RelayCommand(() =>
|
||||
{
|
||||
_showPassword = !_showPassword;
|
||||
OnPropertyChanged(nameof(PasswordText));
|
||||
OnPropertyChanged(nameof(ShowPasswordText));
|
||||
}, () => _share.AdminPassword is not null);
|
||||
CopyPasswordCommand = new RelayCommand(() => Copy(_share.AdminPassword), () => _share.AdminPassword is not null);
|
||||
AdminPanelCommand = new RelayCommand(() => ShellActions.OpenUrl($"https://localhost:{_share.HttpsPort}/admin"), () => _share.IsOn && _share.HttpsPort > 0);
|
||||
RestartCommand = new RelayCommand(() => _ = RestartAsync(), () => _share.State is ShareState.Failed);
|
||||
SettingsCommand = new RelayCommand(() =>
|
||||
{
|
||||
_shell.Settings.Page = SettingsPage.Server;
|
||||
_shell.Navigate(SectionKey.Settings);
|
||||
});
|
||||
if (Application.Current is not null && !shell.Services.Environment.IsCapture)
|
||||
{
|
||||
_timer = new DispatcherTimer(DispatcherPriority.Background) { Interval = RefreshInterval };
|
||||
_timer.Tick += (_, _) =>
|
||||
{
|
||||
if (_share.IsOn) _ = RefreshAsync();
|
||||
};
|
||||
_timer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand CopyCommand { get; }
|
||||
public ICommand CopyFingerprintCommand { get; }
|
||||
public ICommand ShowPasswordCommand { get; }
|
||||
public ICommand CopyPasswordCommand { get; }
|
||||
public ICommand AdminPanelCommand { get; }
|
||||
public ICommand RestartCommand { get; }
|
||||
public ICommand SettingsCommand { get; }
|
||||
|
||||
/// <summary>Sharing is on in the settings, whether it runs or not: the details show.</summary>
|
||||
public bool IsShared => _share.State is not ShareState.Off;
|
||||
|
||||
public bool IsNotShared => !IsShared;
|
||||
|
||||
public bool IsOn => _share.IsOn;
|
||||
|
||||
public bool HasFailed => _share.State is ShareState.Failed;
|
||||
|
||||
public StatusKind StatusKind => _share.State switch
|
||||
{
|
||||
ShareState.On => StatusKind.Online,
|
||||
ShareState.Starting => StatusKind.Running,
|
||||
ShareState.Failed => StatusKind.Error,
|
||||
_ => StatusKind.Offline,
|
||||
};
|
||||
|
||||
public string StateText => Loc.L("Server.Share.State." + _share.State);
|
||||
|
||||
public string? Reason => _share.Reason;
|
||||
|
||||
public IReadOnlyList<ShareAddressRow> Addresses => [.. _share.Addresses.Select(a => new ShareAddressRow(a, CopyCommand))];
|
||||
|
||||
public string? PortsText => _share.IsOn ? Loc.L("Server.Share.PortsValue", _share.HttpsPort, _share.HttpPort) : null;
|
||||
|
||||
public string? Fingerprint => _share.Fingerprint is { } fingerprint ? Formatting.LeftToRight(fingerprint) : null;
|
||||
|
||||
public bool HasAdminPassword => _share.AdminPassword is not null;
|
||||
|
||||
/// <summary>The temporary password, masked until Show.</summary>
|
||||
public string? PasswordText => _share.AdminPassword is not { } password ? null : _showPassword ? password : new string('•', 12);
|
||||
|
||||
public string ShowPasswordText => Loc.L(_showPassword ? "Server.Share.Hide" : "Server.Share.Show");
|
||||
|
||||
/// <summary>"anna · Chronos Uploader · 192.168.1.20", the latest first.</summary>
|
||||
public IReadOnlyList<string> Clients => [.. _share.Clients.Select(c => Loc.L("Server.Share.ClientRow", c.User, c.Program, c.Address).TrimEnd(' ', '·'))];
|
||||
|
||||
public bool HasClients => _share.Clients.Count > 0;
|
||||
|
||||
/// <summary>The 1.0 Windows Server's service is installed: it may hold the same ports, and the setup can remove it.</summary>
|
||||
public bool HasLegacyService => _hasLegacyService;
|
||||
|
||||
public string ClientsText => HasClients ? Loc.Plural("Server.Share.ClientCount", _share.Clients.Count) : Loc.L("Server.Share.NoClients");
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
_timer?.Stop();
|
||||
_share.PropertyChanged -= OnShareChanged;
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
private async Task RestartAsync()
|
||||
{
|
||||
await _share.RestartAsync();
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
}
|
||||
|
||||
private async Task RefreshAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
await _share.RefreshAsync();
|
||||
}
|
||||
catch (Exception ex) when (ex is InvalidOperationException or ObjectDisposedException)
|
||||
{
|
||||
Log.Warning("share", "The clients of the shared library could not be read", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static void Copy(string? text)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text)) return;
|
||||
try
|
||||
{
|
||||
Clipboard.SetText(text);
|
||||
}
|
||||
catch (ExternalException ex)
|
||||
{
|
||||
// Another program holds the clipboard: nothing was copied, as the next try may.
|
||||
Log.Warning("share", "The clipboard is busy", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnShareChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (Application.Current?.Dispatcher is { } dispatcher && !dispatcher.CheckAccess())
|
||||
{
|
||||
dispatcher.BeginInvoke(Changed);
|
||||
return;
|
||||
}
|
||||
Changed();
|
||||
}
|
||||
|
||||
private void Changed()
|
||||
{
|
||||
if (!_share.IsOn) _showPassword = false;
|
||||
_hasLegacyService = _legacyService();
|
||||
OnAllPropertiesChanged();
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
}
|
||||
}
|
||||
@@ -551,7 +551,7 @@ public sealed class VideosViewModel : SectionViewModel, Chronos.App.Editor.IVide
|
||||
var workspace = services.Workspace;
|
||||
if (!workspace.IsAvailable || !Directory.Exists(workspace.Root)) return [];
|
||||
var projects = await workspace.ListAsync(cancellationToken);
|
||||
return await Task.Run(() => VideoSources.ReadWorkspace(workspace.Store, projects), cancellationToken);
|
||||
return await Task.Run(() => VideoSources.ReadWorkspace(workspace.Homes, projects), cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>The signed-in session's server, its capability and the account's rights.</summary>
|
||||
|
||||
Reference in new issue
Block a user