feat(app): server sync table, conflict resolution, sync options and Library sync glyphs

SyncHost runs the sync agent of the signed-in session and gives transfer jobs
their connection; the Server screen lists every sequence of this PC and of the
server with its state and actions (upload, download originals, open with
proxies, keep mine / take server / save both, pause, resume), filter chips,
search, Upload all local and the comparison footer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-02 22:53:24 +00:00
1 parent c02d1867d0
commit 25653c052b
16 files changed
+1072 -10

No files matched your search

+3
View File
@@ -61,8 +61,11 @@
<data name="Library.Sort.Title" xml:space="preserve"><value>Title</value></data>
<data name="Library.Status.Analysed" xml:space="preserve"><value>Analysed</value></data>
<data name="Library.Status.Analysing" xml:space="preserve"><value>Analysing</value></data>
<data name="Library.Status.Conflict" xml:space="preserve"><value>Conflict</value></data>
<data name="Library.Status.LocalAhead" xml:space="preserve"><value>Newer here</value></data>
<data name="Library.Status.Proxies" xml:space="preserve"><value>Proxies</value></data>
<data name="Library.Status.Remote" xml:space="preserve"><value>Remote</value></data>
<data name="Library.Status.ServerAhead" xml:space="preserve"><value>Newer on server</value></data>
<data name="Library.Status.Synced" xml:space="preserve"><value>Synced</value></data>
<data name="Library.View" xml:space="preserve"><value>View</value></data>
<data name="Library.View.Grid" xml:space="preserve"><value>Grid</value></data>
+55
View File
@@ -5,12 +5,19 @@
<resheader name="reader"><value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value></resheader>
<resheader name="writer"><value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value></resheader>
<data name="Server.AddressPlaceholder" xml:space="preserve"><value>nas.local:8443</value><comment>invariant</comment></data>
<data name="Server.AutoSync" xml:space="preserve"><value>Sync projects automatically</value></data>
<data name="Server.Certificate" xml:space="preserve"><value>Certificate</value></data>
<data name="Server.Certificate.Forget" xml:space="preserve"><value>Forget</value></data>
<data name="Server.Certificate.Keep" xml:space="preserve"><value>Keep</value></data>
<data name="Server.Certificate.Message" xml:space="preserve"><value>Titano trusts this certificate for this server. Forgetting it disconnects, and the next connection asks again.</value><comment>long</comment></data>
<data name="Server.Certificate.Title" xml:space="preserve"><value>Server certificate</value></data>
<data name="Server.Certificate.Trusted" xml:space="preserve"><value>TLS {0} trusted {1}</value></data>
<data name="Server.Conflict.Cancel" xml:space="preserve"><value>Cancel</value></data>
<data name="Server.Conflict.Difference" xml:space="preserve"><value>{0}: {1} here, {2} on the server</value><comment>long; {0} setting path, {1} value on this PC, {2} value on the server</comment></data>
<data name="Server.Conflict.KeepMine.Message" xml:space="preserve"><value>The server copy of {0} will be replaced by this PC's settings.</value><comment>long; {0} sequence title</comment></data>
<data name="Server.Conflict.KeepMine.Title" xml:space="preserve"><value>Keep this PC's settings?</value></data>
<data name="Server.Conflict.TakeServer.Message" xml:space="preserve"><value>This PC's settings of {0} will be replaced by the server copy.</value><comment>long; {0} sequence title</comment></data>
<data name="Server.Conflict.TakeServer.Title" xml:space="preserve"><value>Take the server's settings?</value></data>
<data name="Server.Connect" xml:space="preserve"><value>Connect</value></data>
<data name="Server.Disconnect" xml:space="preserve"><value>Disconnect</value></data>
<data name="Server.Empty" xml:space="preserve"><value>Not connected to a server</value></data>
@@ -71,6 +78,7 @@
<data name="Server.Error.WrongPassword" xml:space="preserve"><value>The current password is wrong.</value><comment>long</comment></data>
<data name="Server.Error.WrongUploadKind" xml:space="preserve"><value>This upload belongs to a render job.</value><comment>long</comment></data>
<data name="Server.Found" xml:space="preserve"><value>Servers found</value></data>
<data name="Server.KeepProxies" xml:space="preserve"><value>Keep proxies offline</value></data>
<data name="Server.Label.Account" xml:space="preserve"><value>Account</value></data>
<data name="Server.Label.Server" xml:space="preserve"><value>Server</value></data>
<data name="Server.Label.Status" xml:space="preserve"><value>Status</value></data>
@@ -93,6 +101,53 @@
<data name="Server.Status.Connecting" xml:space="preserve"><value>Connecting…</value></data>
<data name="Server.Status.Disconnected" xml:space="preserve"><value>Disconnected</value></data>
<data name="Server.Status.NotConnected" xml:space="preserve"><value>Not connected</value></data>
<data name="Server.Sync.Action.DownloadOriginals" xml:space="preserve"><value>Download originals</value></data>
<data name="Server.Sync.Action.KeepMine" xml:space="preserve"><value>Keep mine</value></data>
<data name="Server.Sync.Action.OpenWithProxies" xml:space="preserve"><value>Open with proxies</value></data>
<data name="Server.Sync.Action.Pause" xml:space="preserve"><value>Pause</value></data>
<data name="Server.Sync.Action.Resume" xml:space="preserve"><value>Resume</value></data>
<data name="Server.Sync.Action.SaveBoth" xml:space="preserve"><value>Save both</value></data>
<data name="Server.Sync.Action.SyncSettings" xml:space="preserve"><value>Sync settings</value></data>
<data name="Server.Sync.Action.TakeServer" xml:space="preserve"><value>Take server</value></data>
<data name="Server.Sync.Action.Upload" xml:space="preserve"><value>Upload</value></data>
<data name="Server.Sync.Archive.one" xml:space="preserve"><value>Server archive {1} · {0} sequence</value><comment>long; {0} sequence count, {1} archive size</comment></data>
<data name="Server.Sync.Archive.other" xml:space="preserve"><value>Server archive {1} · {0} sequences</value><comment>long; {0} sequence count, {1} archive size</comment></data>
<data name="Server.Sync.ChangedAgain" xml:space="preserve"><value>The server copy changed again; compare and choose again.</value><comment>long</comment></data>
<data name="Server.Sync.Column.Local" xml:space="preserve"><value>This PC</value></data>
<data name="Server.Sync.Column.Sequence" xml:space="preserve"><value>Sequence</value></data>
<data name="Server.Sync.Column.Server" xml:space="preserve"><value>Server</value></data>
<data name="Server.Sync.Column.State" xml:space="preserve"><value>State</value></data>
<data name="Server.Sync.Empty" xml:space="preserve"><value>Nothing to compare yet</value></data>
<data name="Server.Sync.Exports.one" xml:space="preserve"><value>{0} export</value><comment>{0} count</comment></data>
<data name="Server.Sync.Exports.other" xml:space="preserve"><value>{0} exports</value><comment>{0} count</comment></data>
<data name="Server.Sync.Filter.All" xml:space="preserve"><value>All · {0}</value><comment>{0} count</comment></data>
<data name="Server.Sync.Filter.Conflicts" xml:space="preserve"><value>Conflicts · {0}</value><comment>{0} count</comment></data>
<data name="Server.Sync.Filter.LocalOnly" xml:space="preserve"><value>Local only · {0}</value><comment>{0} count</comment></data>
<data name="Server.Sync.Filter.Remote" xml:space="preserve"><value>Remote · {0}</value><comment>{0} count</comment></data>
<data name="Server.Sync.Last" xml:space="preserve"><value>Last sync {0} · manifest diff {1} s</value><comment>long; {0} time of day, {1} seconds</comment></data>
<data name="Server.Sync.NoMatch" xml:space="preserve"><value>No sequence matches</value></data>
<data name="Server.Sync.None" xml:space="preserve"><value>—</value><comment>invariant</comment></data>
<data name="Server.Sync.OpenAdmin" xml:space="preserve"><value>Open admin panel</value></data>
<data name="Server.Sync.Originals" xml:space="preserve"><value>originals</value></data>
<data name="Server.Sync.Proxies" xml:space="preserve"><value>proxies</value></data>
<data name="Server.Sync.Queued.one" xml:space="preserve"><value>{0} upload queued</value><comment>{0} count</comment></data>
<data name="Server.Sync.Queued.other" xml:space="preserve"><value>{0} uploads queued</value><comment>{0} count</comment></data>
<data name="Server.Sync.Received" xml:space="preserve"><value>{0} received</value><comment>{0} percent</comment></data>
<data name="Server.Sync.Retrying" xml:space="preserve"><value>Not compared · retrying</value></data>
<data name="Server.Sync.Search" xml:space="preserve"><value>Search</value></data>
<data name="Server.Sync.State.Conflict" xml:space="preserve"><value>settings differ</value></data>
<data name="Server.Sync.State.Downloading" xml:space="preserve"><value>downloading</value></data>
<data name="Server.Sync.State.InSync" xml:space="preserve"><value>in sync</value></data>
<data name="Server.Sync.State.LocalAhead" xml:space="preserve"><value>newer here</value></data>
<data name="Server.Sync.State.LocalOnly" xml:space="preserve"><value>local only</value></data>
<data name="Server.Sync.State.Paused" xml:space="preserve"><value>paused</value></data>
<data name="Server.Sync.State.ProxiesOnly" xml:space="preserve"><value>proxies only</value></data>
<data name="Server.Sync.State.RemoteOnly" xml:space="preserve"><value>remote</value></data>
<data name="Server.Sync.State.ServerAhead" xml:space="preserve"><value>newer on server</value></data>
<data name="Server.Sync.State.Uploading" xml:space="preserve"><value>uploading</value></data>
<data name="Server.Sync.State.Waiting" xml:space="preserve"><value>waiting</value></data>
<data name="Server.Sync.Title" xml:space="preserve"><value>Sequences</value></data>
<data name="Server.Sync.UploadAll" xml:space="preserve"><value>Upload all local</value></data>
<data name="Server.Trust.Accept" xml:space="preserve"><value>Trust</value></data>
<data name="Server.Trust.Cancel" xml:space="preserve"><value>Cancel</value></data>
<data name="Server.Trust.Message" xml:space="preserve"><value>{0} uses a certificate Titano does not know yet. Compare the fingerprint with the one in the server's admin panel before you trust it.</value><comment>long</comment></data>
+37
View File
@@ -74,13 +74,16 @@
<data name="Tooltips.Library.Status" xml:space="preserve"><value>Filter by analysis, proxies, verification or warnings</value></data>
<data name="Tooltips.Library.Status.Analysed" xml:space="preserve"><value>Analysed: exposure, flicker and motion are measured</value></data>
<data name="Tooltips.Library.Status.Analysing" xml:space="preserve"><value>An analysis job is running on this sequence</value></data>
<data name="Tooltips.Library.Status.Conflict" xml:space="preserve"><value>Settings changed here and on the server; choose on the Server screen</value></data>
<data name="Tooltips.Library.Status.Errors" xml:space="preserve"><value>Some frames are missing or unreadable; open the sequence for details</value></data>
<data name="Tooltips.Library.Status.LocalAhead" xml:space="preserve"><value>This PC has originals or settings the server does not have yet</value></data>
<data name="Tooltips.Library.Status.NoProxies" xml:space="preserve"><value>No proxies yet; editing reads the originals</value></data>
<data name="Tooltips.Library.Status.NotAnalysed" xml:space="preserve"><value>Not analysed yet</value></data>
<data name="Tooltips.Library.Status.Proxies" xml:space="preserve"><value>JPEG proxies built for fast editing</value></data>
<data name="Tooltips.Library.Status.Remote" xml:space="preserve"><value>Lives on the server; this PC has proxies at most</value></data>
<data name="Tooltips.Library.Status.Rendered.one" xml:space="preserve"><value>Rendered once</value></data>
<data name="Tooltips.Library.Status.Rendered.other" xml:space="preserve"><value>Rendered {0:N0} times</value></data>
<data name="Tooltips.Library.Status.ServerAhead" xml:space="preserve"><value>The server has originals or settings this PC does not have yet</value></data>
<data name="Tooltips.Library.Status.Synced" xml:space="preserve"><value>The same on this PC and on the server</value></data>
<data name="Tooltips.Library.Status.Warnings.one" xml:space="preserve"><value>{0:N0} warning; open the sequence for details</value></data>
<data name="Tooltips.Library.Status.Warnings.other" xml:space="preserve"><value>{0:N0} warnings; open the sequence for details</value></data>
@@ -97,14 +100,18 @@
<data name="Tooltips.Nav.Server" xml:space="preserve"><value>Connection, sync and render node · Ctrl+6</value></data>
<data name="Tooltips.Nav.Settings" xml:space="preserve"><value>Preferences of this PC · Ctrl+,</value></data>
<data name="Tooltips.Server.Address" xml:space="preserve"><value>Address of the Titano Server; https is assumed · Enter connects</value></data>
<data name="Tooltips.Server.AutoSync" xml:space="preserve"><value>Send and take project settings as they change; settings changed on both sides wait for your choice in the table below</value></data>
<data name="Tooltips.Server.Certificate" xml:space="preserve"><value>Show the full fingerprint, or forget the trust</value></data>
<data name="Tooltips.Server.CertificateTrusted" xml:space="preserve"><value>Fingerprint trusted on first use; a change blocks the connection and asks you again</value></data>
<data name="Tooltips.Server.Conflict.Cancel" xml:space="preserve"><value>Close without changing either copy</value></data>
<data name="Tooltips.Server.Conflict.Detail" xml:space="preserve"><value>The settings that differ: this PC's value, then the server's</value></data>
<data name="Tooltips.Server.Connect" xml:space="preserve"><value>Identify the server, confirm a new certificate, then sign in · Enter</value></data>
<data name="Tooltips.Server.Disconnect" xml:space="preserve"><value>Close the session and work with the local archive only; you stay signed in</value></data>
<data name="Tooltips.Server.DontTrust" xml:space="preserve"><value>Do not connect; nothing is sent to this server</value></data>
<data name="Tooltips.Server.Fingerprint" xml:space="preserve"><value>SHA-256 fingerprint of the server certificate</value></data>
<data name="Tooltips.Server.ForgetTrust" xml:space="preserve"><value>Forget this certificate; the next connection asks again</value></data>
<data name="Tooltips.Server.Found" xml:space="preserve"><value>Servers found on this network and used before</value></data>
<data name="Tooltips.Server.KeepProxies" xml:space="preserve"><value>Keep JPEG proxies of every server sequence on this PC to edit without the originals; uses space in the cache folder</value></data>
<data name="Tooltips.Server.KeepTrust" xml:space="preserve"><value>Keep trusting this certificate</value></data>
<data name="Tooltips.Server.LoginCancel" xml:space="preserve"><value>Close without signing in · Esc</value></data>
<data name="Tooltips.Server.LoginPassword" xml:space="preserve"><value>Sent only to this server; Titano keeps a session token, never the password</value></data>
@@ -118,6 +125,36 @@
<data name="Tooltips.Server.SignIn" xml:space="preserve"><value>Sign in; the token is stored encrypted for this Windows user · Enter</value></data>
<data name="Tooltips.Server.SignOut" xml:space="preserve"><value>Sign out; the token is removed from this PC</value></data>
<data name="Tooltips.Server.Status" xml:space="preserve"><value>Connection to the server</value></data>
<data name="Tooltips.Server.Sync.Archive" xml:space="preserve"><value>Size and sequences of the server archive</value></data>
<data name="Tooltips.Server.Sync.DownloadOriginals" xml:space="preserve"><value>Fetch the originals to this PC, verified by hash ({0})</value><comment>{0} size</comment></data>
<data name="Tooltips.Server.Sync.Filter.All" xml:space="preserve"><value>All sequences on this PC and on the server</value></data>
<data name="Tooltips.Server.Sync.Filter.Conflicts" xml:space="preserve"><value>Settings differ between this PC and the server</value></data>
<data name="Tooltips.Server.Sync.Filter.LocalOnly" xml:space="preserve"><value>Only on this PC</value></data>
<data name="Tooltips.Server.Sync.Filter.Remote" xml:space="preserve"><value>Only on the server</value></data>
<data name="Tooltips.Server.Sync.KeepMine" xml:space="preserve"><value>Overwrite the server copy with this PC's settings</value></data>
<data name="Tooltips.Server.Sync.LastSync" xml:space="preserve"><value>When this PC last compared every sequence with the server, and how long it took</value></data>
<data name="Tooltips.Server.Sync.OpenAdmin" xml:space="preserve"><value>Open the web admin in your browser (admins only)</value></data>
<data name="Tooltips.Server.Sync.OpenWithProxies" xml:space="preserve"><value>Open the editor on the proxies; the render runs on the server</value></data>
<data name="Tooltips.Server.Sync.Pause" xml:space="preserve"><value>Pause this transfer; it resumes where it stopped</value></data>
<data name="Tooltips.Server.Sync.Resume" xml:space="preserve"><value>Resume this transfer where it stopped</value></data>
<data name="Tooltips.Server.Sync.Retrying" xml:space="preserve"><value>The last comparison failed: {0}. It is retried automatically.</value><comment>{0} reason</comment></data>
<data name="Tooltips.Server.Sync.SaveBoth" xml:space="preserve"><value>Take the server copy and keep this PC's settings as a dated copy of the project</value></data>
<data name="Tooltips.Server.Sync.Search" xml:space="preserve"><value>Filter the table by sequence title</value></data>
<data name="Tooltips.Server.Sync.State.Conflict" xml:space="preserve"><value>Settings changed both here and on the server; choose which to keep</value></data>
<data name="Tooltips.Server.Sync.State.Downloading" xml:space="preserve"><value>Originals or proxies are arriving from the server</value></data>
<data name="Tooltips.Server.Sync.State.InSync" xml:space="preserve"><value>Same originals and settings on this PC and on the server</value></data>
<data name="Tooltips.Server.Sync.State.LocalAhead" xml:space="preserve"><value>This PC has originals or settings the server does not have yet</value></data>
<data name="Tooltips.Server.Sync.State.LocalOnly" xml:space="preserve"><value>Only on this PC; upload it to keep it on the server too</value></data>
<data name="Tooltips.Server.Sync.State.Paused" xml:space="preserve"><value>The transfer is paused; resume it to continue</value></data>
<data name="Tooltips.Server.Sync.State.ProxiesOnly" xml:space="preserve"><value>On the server; this PC keeps its proxies for editing</value></data>
<data name="Tooltips.Server.Sync.State.RemoteOnly" xml:space="preserve"><value>Only on the server</value></data>
<data name="Tooltips.Server.Sync.State.ServerAhead" xml:space="preserve"><value>The server has originals or settings this PC does not have yet</value></data>
<data name="Tooltips.Server.Sync.State.Uploading" xml:space="preserve"><value>Originals are being sent to the server</value></data>
<data name="Tooltips.Server.Sync.State.Waiting" xml:space="preserve"><value>The transfer waits for its turn in the job queue</value></data>
<data name="Tooltips.Server.Sync.SyncSettings" xml:space="preserve"><value>Send or take the settings changed on one side</value></data>
<data name="Tooltips.Server.Sync.TakeServer" xml:space="preserve"><value>Replace this PC's settings with the server copy</value></data>
<data name="Tooltips.Server.Sync.Upload" xml:space="preserve"><value>Copy originals and settings to the server ({0})</value><comment>{0} size</comment></data>
<data name="Tooltips.Server.Sync.UploadAll" xml:space="preserve"><value>Send every local-only sequence to the server ({0} sequences, {1})</value><comment>{0} count, {1} size</comment></data>
<data name="Tooltips.Server.Trust" xml:space="preserve"><value>Trust this certificate for this server and continue to sign in</value></data>
<data name="Tooltips.Server.UseFound" xml:space="preserve"><value>Use this address</value></data>
<data name="Tooltips.Settings.Adapter" xml:space="preserve"><value>Graphics adapter and Media Foundation encoders found</value></data>
+3
View File
@@ -61,8 +61,11 @@
<data name="Library.Sort.Title" xml:space="preserve"><value>Titolo</value></data>
<data name="Library.Status.Analysed" xml:space="preserve"><value>Analizzata</value></data>
<data name="Library.Status.Analysing" xml:space="preserve"><value>In analisi</value></data>
<data name="Library.Status.Conflict" xml:space="preserve"><value>Conflitto</value></data>
<data name="Library.Status.LocalAhead" xml:space="preserve"><value>Più recente qui</value></data>
<data name="Library.Status.Proxies" xml:space="preserve"><value>Proxy</value></data>
<data name="Library.Status.Remote" xml:space="preserve"><value>Remota</value></data>
<data name="Library.Status.ServerAhead" xml:space="preserve"><value>Più recente sul server</value></data>
<data name="Library.Status.Synced" xml:space="preserve"><value>Sincronizzata</value></data>
<data name="Library.View" xml:space="preserve"><value>Vista</value></data>
<data name="Library.View.Grid" xml:space="preserve"><value>Griglia</value></data>
+54
View File
@@ -4,12 +4,19 @@
<resheader name="version"><value>2.0</value></resheader>
<resheader name="reader"><value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value></resheader>
<resheader name="writer"><value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value></resheader>
<data name="Server.AutoSync" xml:space="preserve"><value>Sincronia automatica progetti</value></data>
<data name="Server.Certificate" xml:space="preserve"><value>Certificato</value></data>
<data name="Server.Certificate.Forget" xml:space="preserve"><value>Dimentica</value></data>
<data name="Server.Certificate.Keep" xml:space="preserve"><value>Mantieni</value></data>
<data name="Server.Certificate.Message" xml:space="preserve"><value>Titano considera attendibile questo certificato per questo server. Se lo dimentichi la connessione si chiude e la prossima volta te lo chiederà di nuovo.</value></data>
<data name="Server.Certificate.Title" xml:space="preserve"><value>Certificato del server</value></data>
<data name="Server.Certificate.Trusted" xml:space="preserve"><value>TLS {0} attendibile dal {1}</value></data>
<data name="Server.Conflict.Cancel" xml:space="preserve"><value>Annulla</value></data>
<data name="Server.Conflict.Difference" xml:space="preserve"><value>{0}: {1} qui, {2} sul server</value></data>
<data name="Server.Conflict.KeepMine.Message" xml:space="preserve"><value>La copia sul server di {0} sarà sostituita dalle impostazioni di questo PC.</value></data>
<data name="Server.Conflict.KeepMine.Title" xml:space="preserve"><value>Tenere le impostazioni di questo PC?</value></data>
<data name="Server.Conflict.TakeServer.Message" xml:space="preserve"><value>Le impostazioni di {0} su questo PC saranno sostituite dalla copia del server.</value></data>
<data name="Server.Conflict.TakeServer.Title" xml:space="preserve"><value>Usare le impostazioni del server?</value></data>
<data name="Server.Connect" xml:space="preserve"><value>Connetti</value></data>
<data name="Server.Disconnect" xml:space="preserve"><value>Disconnetti</value></data>
<data name="Server.Empty" xml:space="preserve"><value>Non connesso a un server</value></data>
@@ -70,6 +77,7 @@
<data name="Server.Error.WrongPassword" xml:space="preserve"><value>La password attuale è errata.</value></data>
<data name="Server.Error.WrongUploadKind" xml:space="preserve"><value>Questo caricamento appartiene a un job di rendering.</value></data>
<data name="Server.Found" xml:space="preserve"><value>Server trovati</value></data>
<data name="Server.KeepProxies" xml:space="preserve"><value>Proxy disponibili offline</value></data>
<data name="Server.Label.Account" xml:space="preserve"><value>Account</value></data>
<data name="Server.Label.Server" xml:space="preserve"><value>Server</value></data>
<data name="Server.Label.Status" xml:space="preserve"><value>Stato</value></data>
@@ -92,6 +100,52 @@
<data name="Server.Status.Connecting" xml:space="preserve"><value>Connessione…</value></data>
<data name="Server.Status.Disconnected" xml:space="preserve"><value>Disconnesso</value></data>
<data name="Server.Status.NotConnected" xml:space="preserve"><value>Non connesso</value></data>
<data name="Server.Sync.Action.DownloadOriginals" xml:space="preserve"><value>Scarica originali</value></data>
<data name="Server.Sync.Action.KeepMine" xml:space="preserve"><value>Tieni le mie</value></data>
<data name="Server.Sync.Action.OpenWithProxies" xml:space="preserve"><value>Apri con i proxy</value></data>
<data name="Server.Sync.Action.Pause" xml:space="preserve"><value>Pausa</value></data>
<data name="Server.Sync.Action.Resume" xml:space="preserve"><value>Riprendi</value></data>
<data name="Server.Sync.Action.SaveBoth" xml:space="preserve"><value>Salva entrambe</value></data>
<data name="Server.Sync.Action.SyncSettings" xml:space="preserve"><value>Sincronizza</value></data>
<data name="Server.Sync.Action.TakeServer" xml:space="preserve"><value>Usa il server</value></data>
<data name="Server.Sync.Action.Upload" xml:space="preserve"><value>Carica</value></data>
<data name="Server.Sync.Archive.one" xml:space="preserve"><value>Archivio del server {1} · {0} sequenza</value></data>
<data name="Server.Sync.Archive.other" xml:space="preserve"><value>Archivio del server {1} · {0} sequenze</value></data>
<data name="Server.Sync.ChangedAgain" xml:space="preserve"><value>La copia sul server è cambiata di nuovo; confronta e scegli di nuovo.</value></data>
<data name="Server.Sync.Column.Local" xml:space="preserve"><value>Questo PC</value></data>
<data name="Server.Sync.Column.Sequence" xml:space="preserve"><value>Sequenza</value></data>
<data name="Server.Sync.Column.Server" xml:space="preserve"><value>Server</value></data>
<data name="Server.Sync.Column.State" xml:space="preserve"><value>Stato</value></data>
<data name="Server.Sync.Empty" xml:space="preserve"><value>Ancora nulla da confrontare</value></data>
<data name="Server.Sync.Exports.one" xml:space="preserve"><value>{0} esportazione</value></data>
<data name="Server.Sync.Exports.other" xml:space="preserve"><value>{0} esportazioni</value></data>
<data name="Server.Sync.Filter.All" xml:space="preserve"><value>Tutte · {0}</value></data>
<data name="Server.Sync.Filter.Conflicts" xml:space="preserve"><value>Conflitti · {0}</value></data>
<data name="Server.Sync.Filter.LocalOnly" xml:space="preserve"><value>Solo locali · {0}</value></data>
<data name="Server.Sync.Filter.Remote" xml:space="preserve"><value>Sul server · {0}</value></data>
<data name="Server.Sync.Last" xml:space="preserve"><value>Ultima sincronia {0} · confronto {1} s</value></data>
<data name="Server.Sync.NoMatch" xml:space="preserve"><value>Nessuna sequenza corrisponde</value></data>
<data name="Server.Sync.OpenAdmin" xml:space="preserve"><value>Apri pannello admin</value></data>
<data name="Server.Sync.Originals" xml:space="preserve"><value>originali</value></data>
<data name="Server.Sync.Proxies" xml:space="preserve"><value>proxy</value></data>
<data name="Server.Sync.Queued.one" xml:space="preserve"><value>{0} caricamento in coda</value></data>
<data name="Server.Sync.Queued.other" xml:space="preserve"><value>{0} caricamenti in coda</value></data>
<data name="Server.Sync.Received" xml:space="preserve"><value>{0} ricevuto</value></data>
<data name="Server.Sync.Retrying" xml:space="preserve"><value>Confronto non riuscito · riprovo</value></data>
<data name="Server.Sync.Search" xml:space="preserve"><value>Cerca</value></data>
<data name="Server.Sync.State.Conflict" xml:space="preserve"><value>impostazioni diverse</value></data>
<data name="Server.Sync.State.Downloading" xml:space="preserve"><value>in scaricamento</value></data>
<data name="Server.Sync.State.InSync" xml:space="preserve"><value>sincronizzata</value></data>
<data name="Server.Sync.State.LocalAhead" xml:space="preserve"><value>più recente qui</value></data>
<data name="Server.Sync.State.LocalOnly" xml:space="preserve"><value>solo locale</value></data>
<data name="Server.Sync.State.Paused" xml:space="preserve"><value>in pausa</value></data>
<data name="Server.Sync.State.ProxiesOnly" xml:space="preserve"><value>solo proxy</value></data>
<data name="Server.Sync.State.RemoteOnly" xml:space="preserve"><value>sul server</value></data>
<data name="Server.Sync.State.ServerAhead" xml:space="preserve"><value>più recente sul server</value></data>
<data name="Server.Sync.State.Uploading" xml:space="preserve"><value>in caricamento</value></data>
<data name="Server.Sync.State.Waiting" xml:space="preserve"><value>in attesa</value></data>
<data name="Server.Sync.Title" xml:space="preserve"><value>Sequenze</value></data>
<data name="Server.Sync.UploadAll" xml:space="preserve"><value>Carica tutte le locali</value></data>
<data name="Server.Trust.Accept" xml:space="preserve"><value>Considera attendibile</value></data>
<data name="Server.Trust.Cancel" xml:space="preserve"><value>Annulla</value></data>
<data name="Server.Trust.Message" xml:space="preserve"><value>{0} usa un certificato che Titano non conosce ancora. Confronta l'impronta con quella del pannello di amministrazione del server prima di considerarlo attendibile.</value></data>
+37
View File
@@ -74,13 +74,16 @@
<data name="Tooltips.Library.Status" xml:space="preserve"><value>Filtra per analisi, proxy, verifica o avvisi</value></data>
<data name="Tooltips.Library.Status.Analysed" xml:space="preserve"><value>Analizzata: esposizione, flicker e movimento sono misurati</value></data>
<data name="Tooltips.Library.Status.Analysing" xml:space="preserve"><value>Un'attività di analisi è in corso su questa sequenza</value></data>
<data name="Tooltips.Library.Status.Conflict" xml:space="preserve"><value>Impostazioni cambiate qui e sul server; scegli nella schermata Server</value></data>
<data name="Tooltips.Library.Status.Errors" xml:space="preserve"><value>Alcuni fotogrammi mancano o sono illeggibili; apri la sequenza per i dettagli</value></data>
<data name="Tooltips.Library.Status.LocalAhead" xml:space="preserve"><value>Questo PC ha originali o impostazioni che il server non ha ancora</value></data>
<data name="Tooltips.Library.Status.NoProxies" xml:space="preserve"><value>Ancora nessun proxy; la modifica legge gli originali</value></data>
<data name="Tooltips.Library.Status.NotAnalysed" xml:space="preserve"><value>Non ancora analizzata</value></data>
<data name="Tooltips.Library.Status.Proxies" xml:space="preserve"><value>Proxy JPEG pronti per una modifica veloce</value></data>
<data name="Tooltips.Library.Status.Remote" xml:space="preserve"><value>Si trova sul server; questo PC ne ha al massimo i proxy</value></data>
<data name="Tooltips.Library.Status.Rendered.one" xml:space="preserve"><value>Esportata una volta</value></data>
<data name="Tooltips.Library.Status.Rendered.other" xml:space="preserve"><value>Esportata {0:N0} volte</value></data>
<data name="Tooltips.Library.Status.ServerAhead" xml:space="preserve"><value>Il server ha originali o impostazioni che questo PC non ha ancora</value></data>
<data name="Tooltips.Library.Status.Synced" xml:space="preserve"><value>Uguale su questo PC e sul server</value></data>
<data name="Tooltips.Library.Status.Warnings.one" xml:space="preserve"><value>{0:N0} avviso; apri la sequenza per i dettagli</value></data>
<data name="Tooltips.Library.Status.Warnings.other" xml:space="preserve"><value>{0:N0} avvisi; apri la sequenza per i dettagli</value></data>
@@ -97,14 +100,18 @@
<data name="Tooltips.Nav.Server" xml:space="preserve"><value>Connessione, sincronizzazione e nodo di rendering · Ctrl+6</value></data>
<data name="Tooltips.Nav.Settings" xml:space="preserve"><value>Preferenze di questo PC · Ctrl+,</value></data>
<data name="Tooltips.Server.Address" xml:space="preserve"><value>Indirizzo del Titano Server; si presume https · Invio per connettersi</value></data>
<data name="Tooltips.Server.AutoSync" xml:space="preserve"><value>Invia e ricevi le impostazioni dei progetti quando cambiano; quelle cambiate da entrambe le parti attendono la tua scelta nella tabella sotto</value></data>
<data name="Tooltips.Server.Certificate" xml:space="preserve"><value>Mostra l'impronta completa o revoca la fiducia</value></data>
<data name="Tooltips.Server.CertificateTrusted" xml:space="preserve"><value>Impronta accettata al primo utilizzo; se cambia, la connessione si blocca e te lo chiede di nuovo</value></data>
<data name="Tooltips.Server.Conflict.Cancel" xml:space="preserve"><value>Chiudi senza modificare nessuna delle due copie</value></data>
<data name="Tooltips.Server.Conflict.Detail" xml:space="preserve"><value>Le impostazioni diverse: il valore di questo PC, poi quello del server</value></data>
<data name="Tooltips.Server.Connect" xml:space="preserve"><value>Identifica il server, conferma un certificato nuovo e poi accedi · Invio</value></data>
<data name="Tooltips.Server.Disconnect" xml:space="preserve"><value>Chiude la sessione e lavora solo con l'archivio locale; l'accesso resta salvato</value></data>
<data name="Tooltips.Server.DontTrust" xml:space="preserve"><value>Non connetterti; a questo server non viene inviato nulla</value></data>
<data name="Tooltips.Server.Fingerprint" xml:space="preserve"><value>Impronta SHA-256 del certificato del server</value></data>
<data name="Tooltips.Server.ForgetTrust" xml:space="preserve"><value>Dimentica questo certificato; alla prossima connessione verrà chiesto di nuovo</value></data>
<data name="Tooltips.Server.Found" xml:space="preserve"><value>Server trovati in questa rete e usati in precedenza</value></data>
<data name="Tooltips.Server.KeepProxies" xml:space="preserve"><value>Tieni su questo PC i proxy JPEG di ogni sequenza del server per lavorare senza gli originali; usa spazio nella cartella cache</value></data>
<data name="Tooltips.Server.KeepTrust" xml:space="preserve"><value>Continua a considerare attendibile questo certificato</value></data>
<data name="Tooltips.Server.LoginCancel" xml:space="preserve"><value>Chiude senza accedere · Esc</value></data>
<data name="Tooltips.Server.LoginPassword" xml:space="preserve"><value>Inviata solo a questo server; Titano conserva un token di sessione, mai la password</value></data>
@@ -118,6 +125,36 @@
<data name="Tooltips.Server.SignIn" xml:space="preserve"><value>Accedi; il token viene salvato cifrato per questo utente di Windows · Invio</value></data>
<data name="Tooltips.Server.SignOut" xml:space="preserve"><value>Esci; il token viene rimosso da questo PC</value></data>
<data name="Tooltips.Server.Status" xml:space="preserve"><value>Connessione al server</value></data>
<data name="Tooltips.Server.Sync.Archive" xml:space="preserve"><value>Dimensione e sequenze dell'archivio del server</value></data>
<data name="Tooltips.Server.Sync.DownloadOriginals" xml:space="preserve"><value>Scarica gli originali su questo PC, verificati con l'hash ({0})</value></data>
<data name="Tooltips.Server.Sync.Filter.All" xml:space="preserve"><value>Tutte le sequenze di questo PC e del server</value></data>
<data name="Tooltips.Server.Sync.Filter.Conflicts" xml:space="preserve"><value>Le impostazioni differiscono tra questo PC e il server</value></data>
<data name="Tooltips.Server.Sync.Filter.LocalOnly" xml:space="preserve"><value>Solo su questo PC</value></data>
<data name="Tooltips.Server.Sync.Filter.Remote" xml:space="preserve"><value>Solo sul server</value></data>
<data name="Tooltips.Server.Sync.KeepMine" xml:space="preserve"><value>Sovrascrivi la copia del server con le impostazioni di questo PC</value></data>
<data name="Tooltips.Server.Sync.LastSync" xml:space="preserve"><value>Quando questo PC ha confrontato per l'ultima volta tutte le sequenze con il server, e quanto ha impiegato</value></data>
<data name="Tooltips.Server.Sync.OpenAdmin" xml:space="preserve"><value>Apri l'amministrazione web nel browser (solo amministratori)</value></data>
<data name="Tooltips.Server.Sync.OpenWithProxies" xml:space="preserve"><value>Apri l'editor sui proxy; il rendering avviene sul server</value></data>
<data name="Tooltips.Server.Sync.Pause" xml:space="preserve"><value>Metti in pausa questo trasferimento; riprende da dove si è fermato</value></data>
<data name="Tooltips.Server.Sync.Resume" xml:space="preserve"><value>Riprendi questo trasferimento da dove si è fermato</value></data>
<data name="Tooltips.Server.Sync.Retrying" xml:space="preserve"><value>L'ultimo confronto non è riuscito: {0}. Viene ripetuto automaticamente.</value></data>
<data name="Tooltips.Server.Sync.SaveBoth" xml:space="preserve"><value>Usa la copia del server e conserva le impostazioni di questo PC come copia datata del progetto</value></data>
<data name="Tooltips.Server.Sync.Search" xml:space="preserve"><value>Filtra la tabella per titolo della sequenza</value></data>
<data name="Tooltips.Server.Sync.State.Conflict" xml:space="preserve"><value>Le impostazioni sono cambiate sia qui sia sul server; scegli quali tenere</value></data>
<data name="Tooltips.Server.Sync.State.Downloading" xml:space="preserve"><value>Originali o proxy in arrivo dal server</value></data>
<data name="Tooltips.Server.Sync.State.InSync" xml:space="preserve"><value>Stessi originali e impostazioni su questo PC e sul server</value></data>
<data name="Tooltips.Server.Sync.State.LocalAhead" xml:space="preserve"><value>Questo PC ha originali o impostazioni che il server non ha ancora</value></data>
<data name="Tooltips.Server.Sync.State.LocalOnly" xml:space="preserve"><value>Solo su questo PC; caricala per averla anche sul server</value></data>
<data name="Tooltips.Server.Sync.State.Paused" xml:space="preserve"><value>Il trasferimento è in pausa; riprendilo per continuare</value></data>
<data name="Tooltips.Server.Sync.State.ProxiesOnly" xml:space="preserve"><value>Sul server; questo PC ne conserva i proxy per modificarla</value></data>
<data name="Tooltips.Server.Sync.State.RemoteOnly" xml:space="preserve"><value>Solo sul server</value></data>
<data name="Tooltips.Server.Sync.State.ServerAhead" xml:space="preserve"><value>Il server ha originali o impostazioni che questo PC non ha ancora</value></data>
<data name="Tooltips.Server.Sync.State.Uploading" xml:space="preserve"><value>Originali in invio al server</value></data>
<data name="Tooltips.Server.Sync.State.Waiting" xml:space="preserve"><value>Il trasferimento attende il suo turno nella coda delle attività</value></data>
<data name="Tooltips.Server.Sync.SyncSettings" xml:space="preserve"><value>Invia o ricevi le impostazioni cambiate da una sola parte</value></data>
<data name="Tooltips.Server.Sync.TakeServer" xml:space="preserve"><value>Sostituisci le impostazioni di questo PC con la copia del server</value></data>
<data name="Tooltips.Server.Sync.Upload" xml:space="preserve"><value>Copia originali e impostazioni sul server ({0})</value></data>
<data name="Tooltips.Server.Sync.UploadAll" xml:space="preserve"><value>Invia al server ogni sequenza solo locale ({0} sequenze, {1})</value></data>
<data name="Tooltips.Server.Trust" xml:space="preserve"><value>Considera attendibile questo certificato per questo server e prosegui con l'accesso</value></data>
<data name="Tooltips.Server.UseFound" xml:space="preserve"><value>Usa questo indirizzo</value></data>
<data name="Tooltips.Settings.Adapter" xml:space="preserve"><value>Scheda grafica ed encoder Media Foundation trovati</value></data>
+18 -3
View File
@@ -29,7 +29,7 @@ namespace Titano.App.Infrastructure;
/// archive engine (WIC first, then managed decoders), the analysis and render engine (the same decoders; Media
/// Foundation, then managed encoders), the one <see cref="JobEngine"/> of this PC with the handlers of
/// <see cref="CreateJobHandlers"/>, thumbnails, the server session, the render node, the encoder inventory and the
/// update check. Started after the window shows, stopped when the app exits. The last archive is reopened at start and
/// update check, and the sync with the signed-in server (<see cref="SyncHost"/>). Started after the window shows, stopped when the app exits. The last archive is reopened at start and
/// rescanned every <see cref="ScanInterval"/> (BRIEF §7: polling, no file-system watchers). The render node runs while
/// the user offers this PC (<see cref="AppSettings.RenderNodeOptIn"/>) and a server session is open.
/// </summary>
@@ -52,6 +52,7 @@ public sealed class AppServices : IAsyncDisposable
SaveSettingsAction = saveSettings;
Dialogs = dialogs;
ArchiveSetup = new EngineArchiveSetup(this);
Sync = new SyncHost(this);
Server = new ServerSession(settings, saveSettings, new TitanoServerApiFactory(), new DpapiTokenProtector());
Encoders = new MediaFoundationInventory();
CheckForUpdateAsync = ct => UpdateCheck.FetchAsync(Http.Value, ProductLinks.LatestReleaseApi, VersionText, ct);
@@ -81,9 +82,13 @@ public sealed class AppServices : IAsyncDisposable
_server = value;
_server.PropertyChanged += OnServerChanged;
UpdateRenderNode();
Sync.Update();
}
}
/// <summary>Sync with the signed-in server: engine, job connection, background comparison.</summary>
public SyncHost Sync { get; }
public IEncoderInventory Encoders { get; set; }
/// <summary>Latest public release (GitHub Releases API of the releases repository, BRIEF §18).</summary>
@@ -111,7 +116,10 @@ public sealed class AppServices : IAsyncDisposable
/// <summary>The job handlers of this PC's engine — the single registration list; a kind without a handler stays
/// queued (it is never claimed here).</summary>
public static IReadOnlyList<IJobHandler> CreateJobHandlers(AppServices services) =>
[.. services.Archives?.CreateJobHandlers() ?? [], .. services.Processing?.CreateJobHandlers() ?? []];
[
.. services.Archives?.CreateJobHandlers() ?? [], .. services.Processing?.CreateJobHandlers() ?? [],
.. services.Sync.Service?.CreateJobHandlers(services.Sync) ?? [],
];
/// <summary>Queues a scan of <paramref name="archive"/> unless one is already waiting or running.</summary>
public async Task QueueScanAsync(Archive archive, bool full, CancellationToken ct = default)
@@ -174,6 +182,7 @@ public sealed class AppServices : IAsyncDisposable
_server.PropertyChanged -= OnServerChanged;
await _nodeSwitch;
await StopRenderNodeAsync();
await Sync.DisposeAsync();
(Jobs as IDisposable)?.Dispose();
if (Engine is not null) await Engine.DisposeAsync();
Thumbnails?.Dispose();
@@ -209,6 +218,7 @@ public sealed class AppServices : IAsyncDisposable
var archive = new ArchiveServiceOptions { Decoder = DecoderFactory.CreateClient(new WicDecoderProvider()) };
Archives = new ArchiveService(database, archive);
Processing = new ProcessingService(database, ProcessingOptions(archive));
Sync.Open(database, Archives, archive);
var handlers = CreateJobHandlers(this);
var kinds = handlers.Select(h => h.Kind).Distinct().ToArray();
Engine = new JobEngine(database, handlers, new JobEngineOptions { WorkerId = WorkerId, Kinds = kinds });
@@ -218,6 +228,7 @@ public sealed class AppServices : IAsyncDisposable
Jobs = new EngineJobQueue(database, Engine, started);
Log.Info("jobs", started ? $"Job engine started with {Engine.Options.Workers} worker(s) for {string.Join(", ", kinds)}" : "No job handlers registered; jobs stay queued");
UpdateRenderNode();
Sync.Update();
}
/// <summary>Media Foundation (hardware first, software H.264) then managed encoders; frames spill into the cache folder
@@ -235,7 +246,11 @@ public sealed class AppServices : IAsyncDisposable
},
};
private void OnServerChanged(object? sender, PropertyChangedEventArgs e) => UpdateRenderNode();
private void OnServerChanged(object? sender, PropertyChangedEventArgs e)
{
UpdateRenderNode();
Sync.Update();
}
/// <summary>Waits for the previous switch, then runs the node for the current session, or stops it.</summary>
private async Task SwitchRenderNodeAsync(Task previous)
@@ -111,6 +111,12 @@ public sealed class AppSettings
/// <summary>Let the server send render jobs to this PC (BRIEF §14.7).</summary>
public bool RenderNodeOptIn { get; set; }
/// <summary>Keep the proxies of every server sequence without local originals in the cache (BRIEF §12.7).</summary>
public bool KeepProxiesOffline { get; set; }
/// <summary>Send and take project settings changed on one side without asking (Server.html).</summary>
public bool SyncSettingsAutomatically { get; set; } = true;
// ---- Jobs ----
/// <summary>"Clear done": finished jobs older than this are hidden from the Jobs list (they stay in the history).</summary>
public DateTimeOffset? JobsClearedAt { get; set; }
+11 -2
View File
@@ -147,6 +147,16 @@ public sealed class SequenceItem : ObservableObject
OnPropertyChanged(nameof(PrimaryStatus));
}
/// <summary>Where a local copy stands against the server (the sync engine writes the state); null while it is only here.</summary>
public static CardStatus? SyncStatus(SyncState state) => state switch
{
SyncState.InSync => new CardStatus(StatusKind.Synced, Loc.L("Library.Status.Synced"), Loc.L("Tooltips.Library.Status.Synced")),
SyncState.LocalAhead => new CardStatus(StatusKind.Synced, Loc.L("Library.Status.LocalAhead"), Loc.L("Tooltips.Library.Status.LocalAhead")),
SyncState.ServerAhead => new CardStatus(StatusKind.Remote, Loc.L("Library.Status.ServerAhead"), Loc.L("Tooltips.Library.Status.ServerAhead")),
SyncState.Conflict => new CardStatus(StatusKind.Warning, Loc.L("Library.Status.Conflict"), Loc.L("Tooltips.Library.Status.Conflict")),
_ => null,
};
/// <summary>Card status row: analysed, proxies, renders, sync, warnings (Main.html).</summary>
public static IReadOnlyList<CardStatus> BuildStatuses(Sequence s, bool analysing)
{
@@ -168,8 +178,7 @@ public sealed class SequenceItem : ObservableObject
if (s.RenderedCount > 0)
list.Add(new CardStatus(StatusKind.Rendered, Formatting.Count(s.RenderedCount), Loc.Plural("Tooltips.Library.Status.Rendered", s.RenderedCount)));
if (s.SyncState == SyncState.InSync)
list.Add(new CardStatus(StatusKind.Synced, Loc.L("Library.Status.Synced"), Loc.L("Tooltips.Library.Status.Synced")));
if (SyncStatus(s.SyncState) is { } sync) list.Add(sync);
if ((s.Status & SequenceStatus.HasErrors) != 0)
list.Add(new CardStatus(StatusKind.Error, Formatting.Count(Math.Max(1, s.WarningCount)), Loc.L("Tooltips.Library.Status.Errors")));
else if (s.WarningCount > 0 || (s.Status & SequenceStatus.HasWarnings) != 0)
+1 -1
View File
@@ -497,7 +497,7 @@ public sealed class LibraryViewModel : SectionViewModel
{
if (await _db.Sequences.GetAsync(item.Id) is { } fresh) item.Update(fresh);
}
if (job.Kind is JobKind.Scan or JobKind.Rebuild or JobKind.Import or JobKind.Adopt or JobKind.Move or JobKind.UploadCommit) await RefreshAsync();
if (job.Kind is JobKind.Scan or JobKind.Rebuild or JobKind.Import or JobKind.Adopt or JobKind.Move or JobKind.UploadCommit or JobKind.Download) await RefreshAsync();
}
catch (DatabaseException ex)
{
+107 -1
View File
@@ -15,9 +15,12 @@
<Setter Property="Margin" Value="8,0" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<ItemsPanelTemplate x:Key="Panel.Row">
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</UserControl.Resources>
<!-- Server.html: the connection panel; the render-node panel (right) and the sync table (below) join later. -->
<!-- Server.html: the connection panel, then the sync table; the render-node panel joins the connection panel. -->
<Grid Margin="20,16,20,12">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
@@ -112,9 +115,112 @@
<Border Grid.Row="3" Grid.ColumnSpan="2" Margin="0,14,0,0" Padding="0,10,0,0" BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="0,1,0,0">
<WrapPanel>
<CheckBox Content="{l:Loc Server.RenderNode}" IsChecked="{Binding RenderNodeOptIn}" ToolTip="{l:Loc Tooltips.Server.RenderNode}" Margin="0,0,22,0" />
<CheckBox Content="{l:Loc Server.KeepProxies}" IsChecked="{Binding KeepProxiesOffline}" ToolTip="{l:Loc Tooltips.Server.KeepProxies}" Margin="0,0,22,0" />
<CheckBox Content="{l:Loc Server.AutoSync}" IsChecked="{Binding SyncSettingsAutomatically}" ToolTip="{l:Loc Tooltips.Server.AutoSync}" Margin="0,0,22,0" />
</WrapPanel>
</Border>
</Grid>
</Border>
<!-- 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}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<DockPanel Margin="14,10" LastChildFill="False">
<TextBlock Text="{l:Loc Server.Sync.Title}" FontWeight="SemiBold" VerticalAlignment="Center" Margin="0,0,10,0" />
<Button DockPanel.Dock="Right" Content="{l:Loc Server.Sync.UploadAll}" Command="{Binding UploadAllCommand}" ToolTip="{Binding UploadAllToolTip}"
Height="30" Margin="10,0,0,0" />
<TextBox DockPanel.Dock="Right" Width="200" Height="30" Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}" ui:Field.Glyph="{StaticResource Icon.Search}"
ui:Field.Placeholder="{l:Loc Server.Sync.Search}" ToolTip="{l:Loc Tooltips.Server.Sync.Search}" AutomationProperties.Name="{l:Loc Server.Sync.Search}" />
<ItemsControl ItemsSource="{Binding Chips}" ItemsPanel="{StaticResource Panel.Row}" Focusable="False" VerticalAlignment="Center">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type srv:SyncFilterChip}">
<Button x:Name="Chip" Style="{StaticResource Button.Chip}" Content="{Binding Text}" Tag="{Binding IsSelected}" Command="{Binding SelectCommand}"
ToolTip="{Binding ToolTip}" Height="28" FontSize="12" Margin="0,0,10,0" Typography.NumeralAlignment="Tabular" />
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding NeedsAttention}" Value="True">
<Setter TargetName="Chip" Property="BorderBrush" Value="{DynamicResource Brush.Warning}" />
<Setter TargetName="Chip" Property="Foreground" Value="{DynamicResource Brush.Warning}" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DockPanel>
<!-- Header; the rows repeat its columns (Server.html: 1.6fr 150px 150px 150px 1.4fr, here stars with minimums). -->
<Border Grid.Row="1" BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="0,1,0,1" Padding="14,8">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.4*" MinWidth="140" />
<ColumnDefinition Width="*" MinWidth="110" />
<ColumnDefinition Width="*" MinWidth="110" />
<ColumnDefinition Width="*" MinWidth="120" />
<ColumnDefinition Width="1.6*" MinWidth="330" />
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource Text.Header}" Text="{l:Loc Server.Sync.Column.Sequence}" />
<TextBlock Grid.Column="1" Style="{StaticResource Text.Header}" Text="{l:Loc Server.Sync.Column.Local}" Margin="10,0,0,0" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.Header}" Text="{l:Loc Server.Sync.Column.Server}" Margin="10,0,0,0" />
<TextBlock Grid.Column="3" Style="{StaticResource Text.Header}" Text="{l:Loc Server.Sync.Column.State}" Margin="10,0,0,0" />
</Grid>
</Border>
<!-- Rows (virtualised): this PC, the server, the state and the actions that apply. -->
<ListBox Grid.Row="2" ItemsSource="{Binding Rows}" ItemContainerStyle="{StaticResource ListBoxItem.PlainRow}"
VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling" VirtualizingPanel.ScrollUnit="Pixel"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" AutomationProperties.Name="{l:Loc Server.Sync.Title}"
Visibility="{Binding HasRows, Converter={StaticResource BoolToVisibility}}">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type srv:SyncRow}">
<Grid Height="40" Background="Transparent" Margin="14,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.4*" MinWidth="140" />
<ColumnDefinition Width="*" MinWidth="110" />
<ColumnDefinition Width="*" MinWidth="110" />
<ColumnDefinition Width="*" MinWidth="120" />
<ColumnDefinition Width="1.6*" MinWidth="330" />
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource Text.Cell}" Text="{Binding Title}" ToolTip="{Binding Title}" />
<TextBlock Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding LocalText}" Margin="10,0,0,0" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.Cell}" Text="{Binding ServerText}" 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" />
<ItemsControl Grid.Column="4" ItemsSource="{Binding Actions}" ItemsPanel="{StaticResource Panel.Row}" Focusable="False"
VerticalAlignment="Center" Margin="10,0,0,0">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type srv:SyncRowAction}">
<Button Style="{StaticResource Button.Row}" Content="{Binding Text}" Command="{Binding Command}" ToolTip="{Binding ToolTip}" FontSize="12" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<ui:EmptyState Grid.Row="2" Message="{Binding EmptyText}" Visibility="{Binding EmptyText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
<!-- Footer: last comparison · server archive · retry state · admin panel. -->
<Border Grid.Row="3" BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="0,1,0,0" Padding="14,8">
<DockPanel LastChildFill="False" TextElement.FontSize="12">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Link}" Content="{l:Loc Server.Sync.OpenAdmin}" Command="{Binding OpenAdminCommand}"
ToolTip="{l:Loc Tooltips.Server.Sync.OpenAdmin}" Visibility="{Binding CanOpenAdmin, Converter={StaticResource BoolToVisibility}}" />
<TextBlock Text="{Binding LastSyncText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="0,0,16,0" VerticalAlignment="Center"
Typography.NumeralAlignment="Tabular" ToolTip="{l:Loc Tooltips.Server.Sync.LastSync}"
Visibility="{Binding LastSyncText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
<TextBlock Text="{Binding ArchiveText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="0,0,16,0" VerticalAlignment="Center"
Typography.NumeralAlignment="Tabular" ToolTip="{l:Loc Tooltips.Server.Sync.Archive}"
Visibility="{Binding ArchiveText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
<ui:StatusGlyph Kind="Warning" Text="{Binding ErrorText}" ToolTip="{Binding ErrorToolTip}" FontSize="12" VerticalAlignment="Center"
Visibility="{Binding ErrorText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
</DockPanel>
</Border>
</Grid>
</Border>
</Grid>
</UserControl>
+32 -3
View File
@@ -10,9 +10,9 @@ using Titano.Ui.Mvvm;
namespace Titano.App.Sections;
/// <summary>
/// Server, connection part (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, and
/// the render-node opt-in. The sync table and render-node panel join this screen later.
/// 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) and the sync table (<see cref="Sync"/>).
/// </summary>
public sealed class ServerViewModel : SectionViewModel
{
@@ -34,8 +34,12 @@ public sealed class ServerViewModel : SectionViewModel
else if (p is string text) Address = text;
});
CertificateCommand = new RelayCommand(ShowCertificate, () => Fingerprint is not null);
Sync = new SyncTableViewModel(shell);
}
/// <summary>Sequences of this PC and of the server, where they stand and what can be done.</summary>
public SyncTableViewModel Sync { get; }
public ShellViewModel Shell { get; }
private ServerSession Session => _session ?? Shell.Services.Server;
@@ -134,6 +138,20 @@ public sealed class ServerViewModel : SectionViewModel
}
}
/// <summary>Keep the proxies of every server sequence without local originals on this PC.</summary>
public bool KeepProxiesOffline
{
get => Shell.Services.Settings.KeepProxiesOffline;
set => SetSyncOption(value, Shell.Services.Settings.KeepProxiesOffline, v => Shell.Services.Settings.KeepProxiesOffline = v);
}
/// <summary>Send and take project settings changed on one side without asking.</summary>
public bool SyncSettingsAutomatically
{
get => Shell.Services.Settings.SyncSettingsAutomatically;
set => SetSyncOption(value, Shell.Services.Settings.SyncSettingsAutomatically, v => Shell.Services.Settings.SyncSettingsAutomatically = v);
}
/// <summary>Re-reads values another screen changed (Settings › Server).</summary>
public void Refresh() => OnPropertyChanged(nameof(RenderNodeOptIn));
@@ -149,6 +167,7 @@ public sealed class ServerViewModel : SectionViewModel
if (Address.Length == 0 && Session.Discovered.Count > 0) Address = Session.Discovered[0].Address;
};
if (!Shell.Services.Environment.IsCapture) _session.StartDiscovery();
Sync.Attach();
await _session.RestoreAsync();
if (_session.Flow.Error is not ConnectError.None and var error && !_session.IsConnected) ErrorText = ServerSession.ErrorText(error);
}
@@ -156,9 +175,19 @@ public sealed class ServerViewModel : SectionViewModel
public override void Dispose()
{
if (_session is not null) _session.PropertyChanged -= OnSessionChanged;
Sync.Dispose();
base.Dispose();
}
private void SetSyncOption(bool value, bool current, Action<bool> store, [System.Runtime.CompilerServices.CallerMemberName] string? name = null)
{
if (value == current) return;
store(value);
Shell.Services.SaveSettings();
Shell.Services.Sync.RequestRefresh();
OnPropertyChanged(name);
}
private async Task ConnectAsync()
{
ErrorText = null;
+137
View File
@@ -0,0 +1,137 @@
using System.IO;
using Titano.App.Infrastructure;
using Titano.Core.Diagnostics;
using Titano.Core.Model;
using Titano.Data;
using Titano.Data.Sync;
using Titano.Protocol.Client;
namespace Titano.App.Server;
/// <summary>Makes the sync connection of a signed-in session.</summary>
public delegate ISyncRemote SyncRemoteFactory(Uri address, string token, IReadOnlyCollection<string> trustedFingerprints);
/// <summary>
/// This PC's sync with the signed-in server (BRIEF §4.4, §14.5): the <see cref="SyncService"/> of the index, the
/// connection of upload and download jobs (<see cref="ISyncConnector"/>) and a <see cref="SyncAgent"/> that keeps the
/// table current while a session is open, started and stopped in order as the session changes. Options come from
/// <see cref="AppSettings.SyncSettingsAutomatically"/> and <see cref="AppSettings.KeepProxiesOffline"/>.
/// </summary>
public sealed class SyncHost(AppServices services) : ISyncConnector, IAsyncDisposable
{
/// <summary>How long a job resumed at start waits for the saved session to be restored.</summary>
private static readonly TimeSpan RestoreWait = TimeSpan.FromSeconds(30);
private Task _switch = Task.CompletedTask;
private Credentials? _credentials;
private (SyncAgent Agent, ISyncRemote Remote, Credentials Credentials)? _running;
/// <summary>Connections over <see cref="TitanoClient"/>; screenshots substitute a fake server.</summary>
public SyncRemoteFactory RemoteFactory { get; set; } = (address, token, trusted) =>
new TitanoSyncRemote(new TitanoClient(address, new CertificatePinning(trusted), $"Titano ({Environment.MachineName})") { Token = token }, ownsClient: true);
/// <summary>The engine; null until the index is open.</summary>
public SyncService? Service { get; private set; }
/// <summary>The background comparison of the signed-in server; null while signed out.</summary>
public SyncAgent? Agent => _running?.Agent;
/// <summary>The agent's connection, for the table's own calls (conflict resolution); null while signed out.</summary>
public ISyncRemote? Remote => _running?.Remote;
/// <summary>Key of the signed-in server (<see cref="SyncService.ServerKey"/>); null while signed out.</summary>
public string? Server => Volatile.Read(ref _credentials) is { } c ? SyncService.ServerKey(c.Address) : null;
public SyncPolicy Policy => new(services.Settings.SyncSettingsAutomatically, services.Settings.KeepProxiesOffline);
/// <summary>The agent started, stopped or compared, or the table of the signed-in server changed (any thread).</summary>
public event Action? Changed;
/// <summary>Creates the engine over the open index; the proxy cache lives in the client's cache folder.</summary>
public SyncService Open(TitanoDatabase database, Titano.Data.Archiving.ArchiveService archives, Titano.Data.Archiving.ArchiveServiceOptions options)
{
var cache = CacheStore.Folder(services.Environment, services.Settings);
Service = new SyncService(database, archives, new SyncOptions { Archive = options, ProxyCacheDirectory = Path.Combine(cache, "proxies") });
Service.Changed += server =>
{
if (server == Server) Changed?.Invoke();
};
return Service;
}
/// <summary>Follows the server session (UI thread): starts the agent for a new sign-in, stops it on sign-out.</summary>
public void Update()
{
var session = services.Server;
Credentials? wanted = session.IsConnected && session.Flow is { Address: { } address, Token: { } token }
? new Credentials(address, token, session.Fingerprints)
: null;
Volatile.Write(ref _credentials, wanted);
_switch = SwitchAsync(_switch, wanted);
}
/// <summary>Compares again soon (an option changed, an edit on this PC).</summary>
public void RequestRefresh() => Agent?.RequestRefresh();
/// <summary>The archive downloaded originals go to when a sequence has no local copy: the one this PC works with.</summary>
public async Task<Archive?> CurrentArchiveAsync(CancellationToken ct = default)
{
if (services.Database is not { } db) return null;
var archives = await db.Archives.ListAsync(ct);
if (services.Settings.LastArchivePath is { Length: > 0 } root)
{
var full = Path.GetFullPath(root).TrimEnd(Path.DirectorySeparatorChar);
if (archives.FirstOrDefault(a => string.Equals(Path.GetFullPath(a.RootPath).TrimEnd(Path.DirectorySeparatorChar), full, StringComparison.OrdinalIgnoreCase))
is { } current) return current;
}
return archives.Count == 1 ? archives[0] : null;
}
public async ValueTask<ISyncRemote?> ConnectAsync(string server, CancellationToken cancellationToken)
{
// A job resumed at start runs before the saved session is restored: give the restore a moment.
var until = DateTime.UtcNow + RestoreWait;
while (Volatile.Read(ref _credentials) is null && services.Settings.ProtectedToken is not null && DateTime.UtcNow < until)
await Task.Delay(500, cancellationToken);
if (Volatile.Read(ref _credentials) is not { } c || SyncService.ServerKey(c.Address) != server) return null;
CacheStore.Prepare(CacheStore.Folder(services.Environment, services.Settings));
return RemoteFactory(c.Address, c.Token, c.Fingerprints);
}
public async ValueTask DisposeAsync()
{
Volatile.Write(ref _credentials, null);
await _switch;
await StopAsync();
}
private async Task SwitchAsync(Task previous, Credentials? wanted)
{
await previous;
if (_running is { } running && wanted is { } same && running.Credentials.Address == same.Address && running.Credentials.Token == same.Token) return;
await StopAsync();
if (wanted is not { } start || Service is not { } service)
{
Changed?.Invoke();
return;
}
var remote = RemoteFactory(start.Address, start.Token, start.Fingerprints);
var agent = new SyncAgent(service, remote, () => Policy, services.Engine);
agent.Changed += () => Changed?.Invoke();
agent.Start();
_running = (agent, remote, start);
Log.Info("sync", $"Comparing with {remote.Server}");
Changed?.Invoke();
}
private async Task StopAsync()
{
if (_running is not { } running) return;
_running = null;
await running.Agent.DisposeAsync();
running.Remote.Dispose();
Changed?.Invoke();
}
private sealed record Credentials(Uri Address, string Token, IReadOnlyCollection<string> Fingerprints);
}
+58
View File
@@ -0,0 +1,58 @@
using System.Windows.Input;
using Titano.App.Infrastructure;
using Titano.Core.Localization;
using Titano.Data.Sync;
using Titano.Ui.Controls;
using Titano.Ui.Mvvm;
namespace Titano.App.Server;
/// <summary>A row button: "Upload", "Keep mine", …</summary>
public sealed record SyncRowAction(SyncAction Action, string Text, string ToolTip, ICommand Command);
/// <summary>One row of the sync table (Server.html): sequence, this PC, server, state and the actions that apply.</summary>
public sealed class SyncRow : ObservableObject
{
private readonly Func<SyncRow, SyncAction, Task> _act;
private SyncEntry _entry;
private SyncRights _rights;
public SyncRow(SyncEntry entry, SyncRights rights, Func<SyncRow, SyncAction, Task> act)
{
_entry = entry;
_rights = rights;
_act = act;
Actions = BuildActions();
}
public SyncEntry Entry => _entry;
public Guid Id => _entry.Id;
public string Title => _entry.Title;
public string LocalText => SyncText.Local(_entry);
public string ServerText => SyncText.Server(_entry);
public StatusKind StateKind => SyncText.State(_entry).Kind;
public string StateText => SyncText.State(_entry).Text;
public string StateToolTip => SyncText.State(_entry).ToolTip;
public IReadOnlyList<SyncRowAction> Actions { get; private set; }
/// <summary>Takes a fresher comparison of the same sequence.</summary>
public void Update(SyncEntry entry, SyncRights rights)
{
_entry = entry;
_rights = rights;
Actions = BuildActions();
OnAllPropertiesChanged();
}
private List<SyncRowAction> BuildActions() =>
[
.. SyncText.Actions(_entry, _rights).Select(action => new SyncRowAction(action, Loc.L("Server.Sync.Action." + action), ToolTip(action),
new AsyncRelayCommand(() => _act(this, action)))),
];
private string ToolTip(SyncAction action) => action switch
{
SyncAction.Upload or SyncAction.DownloadOriginals => Loc.L("Tooltips.Server.Sync." + action, Formatting.Bytes(SyncText.Size(_entry, action))),
_ => Loc.L("Tooltips.Server.Sync." + action),
};
}
+366
View File
@@ -0,0 +1,366 @@
using System.Collections.Concurrent;
using System.Collections.ObjectModel;
using System.Net;
using System.Windows.Input;
using System.Windows.Threading;
using Titano.App.Infrastructure;
using Titano.App.Shell;
using Titano.Core.Diagnostics;
using Titano.Core.Localization;
using Titano.Core.Model;
using Titano.Data.Jobs;
using Titano.Data.Sync;
using Titano.Protocol.Client;
using Titano.Ui.Mvvm;
namespace Titano.App.Server;
/// <summary>A filter chip of the sync table: "Conflicts · 1".</summary>
public sealed class SyncFilterChip(SyncFilter filter, Action<SyncFilter> select) : ObservableObject
{
private int _count;
private bool _isSelected;
public SyncFilter Filter { get; } = filter;
public string Text => Loc.L("Server.Sync.Filter." + Filter, Formatting.Count(_count));
public string ToolTip => Loc.L("Tooltips.Server.Sync.Filter." + Filter);
public ICommand SelectCommand { get; } = new RelayCommand(() => select(filter));
/// <summary>Conflicts waiting for a choice: the chip is drawn in the warning colour.</summary>
public bool NeedsAttention => Filter == SyncFilter.Conflicts && _count > 0;
public bool IsSelected
{
get => _isSelected;
set => Set(ref _isSelected, value);
}
public int Count
{
get => _count;
set
{
if (!Set(ref _count, value)) return;
OnPropertyChanged(nameof(Text));
OnPropertyChanged(nameof(NeedsAttention));
}
}
}
/// <summary>
/// The sync table of the Server screen (BRIEF §12.7, Server.html): every sequence of this PC and of the signed-in
/// server with what each side holds, where it stands and what can be done (upload, download originals, open with
/// proxies, settle a settings conflict, pause or resume a transfer), filter chips, search, "Upload all local" and the
/// footer (last comparison, server archive, admin panel). Reloads when the sync engine reports a change; transfer
/// progress is applied at most a few times a second. Runs on the UI thread.
/// </summary>
public sealed class SyncTableViewModel : ObservableObject, IDisposable
{
private readonly ShellViewModel _shell;
private readonly IReadOnlyList<SyncFilterChip> _chips;
private readonly HashSet<Guid> _openWhenCached = [];
private readonly ConcurrentDictionary<Guid, JobProgressInfo> _progress = new();
private readonly SemaphoreSlim _reloading = new(1, 1);
private IReadOnlyList<SyncEntry> _entries = [];
private SyncFilter _filter = SyncFilter.All;
private string _search = string.Empty;
private int _progressQueued;
private int _reloadQueued;
private bool _attached;
public SyncTableViewModel(ShellViewModel shell)
{
_shell = shell;
_chips = [.. Enum.GetValues<SyncFilter>().Select(f => new SyncFilterChip(f, Select) { IsSelected = f == SyncFilter.All })];
UploadAllCommand = new AsyncRelayCommand(UploadAllAsync, () => Rights.CanUpload && LocalOnly.Any());
OpenAdminCommand = new RelayCommand(() =>
{
if (Host.Server is { } server) ShellActions.OpenUrl(server + "/admin");
});
}
public ObservableCollection<SyncRow> Rows { get; } = [];
public IReadOnlyList<SyncFilterChip> Chips => _chips;
public ICommand UploadAllCommand { get; }
public ICommand OpenAdminCommand { get; }
public string SearchText
{
get => _search;
set
{
if (Set(ref _search, value ?? string.Empty)) ApplyFilter();
}
}
/// <summary>Signed in: the table compares this PC with that server.</summary>
public bool IsActive => Host.Server is not null;
public bool HasRows => Rows.Count > 0;
/// <summary>"Not connected to a server", "Nothing to compare yet" or "No sequence matches"; null when rows show.</summary>
public string? EmptyText => HasRows ? null
: !IsActive ? Loc.L("Server.Empty")
: _entries.Count == 0 ? Loc.L("Server.Sync.Empty")
: Loc.L("Server.Sync.NoMatch");
public string UploadAllToolTip => Loc.L("Tooltips.Server.Sync.UploadAll", Formatting.Count(LocalOnly.Count()), Formatting.Bytes(LocalOnly.Sum(e => e.Local!.TotalBytes)));
/// <summary>"Last sync 10:15 · manifest diff 0.4 s"; null before the first comparison.</summary>
public string? LastSyncText => Host.Agent?.Snapshot is { } s
? Loc.L("Server.Sync.Last", Formatting.TimeOfDay(s.RefreshedAt), s.Duration.TotalSeconds.ToString("0.0", Loc.Culture))
: null;
/// <summary>"Server archive 9.4 TB · 412 sequences".</summary>
public string? ArchiveText => Host.Agent?.Snapshot is { } s ? Loc.Plural("Server.Sync.Archive", s.ServerSequences, Formatting.Bytes(s.ServerBytes)) : null;
/// <summary>The last comparison failed (it is retried with growing pauses); null when it worked.</summary>
public string? ErrorText => Host.Agent?.LastError is not null ? Loc.L("Server.Sync.Retrying") : null;
public string? ErrorToolTip => Host.Agent?.LastError is { } error ? Loc.L("Tooltips.Server.Sync.Retrying", error.Message) : null;
/// <summary>The server's web admin (it admits administrators only).</summary>
public bool CanOpenAdmin => IsActive;
private SyncHost Host => _shell.Services.Sync;
private SyncRights Rights => _shell.Services.Server.User is { } user ? SyncRights.Of(user.Permissions) : default;
private IEnumerable<SyncEntry> LocalOnly => _entries.Where(e => e.Status == SyncStatus.LocalOnly);
/// <summary>Starts following the sync engine and the transfer jobs.</summary>
public void Attach()
{
if (_attached) return;
_attached = true;
Host.Changed += OnChanged;
if (_shell.Services.Jobs is { } jobs)
{
jobs.JobChanged += OnJobChanged;
jobs.Progress += OnProgress;
}
_ = ReloadAsync();
}
/// <summary>Reads the table again; concurrent requests collapse into one more pass.</summary>
public async Task ReloadAsync()
{
Interlocked.Exchange(ref _reloadQueued, 1);
if (!await _reloading.WaitAsync(0)) return;
try
{
while (Interlocked.Exchange(ref _reloadQueued, 0) == 1)
{
_entries = Host is { Service: { } service, Server: { } server } ? await service.ListAsync(server, CancellationToken.None) : [];
Refresh();
}
}
catch (Exception ex) when (ex is Data.DatabaseException or InvalidOperationException)
{
Log.Warning("sync", "The sync table could not be read", ex);
}
finally
{
_reloading.Release();
}
}
public void Dispose()
{
if (!_attached) return;
Host.Changed -= OnChanged;
if (_shell.Services.Jobs is { } jobs)
{
jobs.JobChanged -= OnJobChanged;
jobs.Progress -= OnProgress;
}
}
private void Select(SyncFilter filter)
{
_filter = filter;
foreach (var chip in _chips) chip.IsSelected = chip.Filter == filter;
ApplyFilter();
}
/// <summary>Counts, rows, footer and the Library's sync glyphs after a reload.</summary>
private void Refresh()
{
foreach (var chip in _chips) chip.Count = _entries.Count(e => SyncText.Matches(e, chip.Filter, string.Empty));
ApplyFilter();
UpdateLibrary();
OpenCachedProxies();
OnPropertyChanged(nameof(IsActive));
OnPropertyChanged(nameof(UploadAllToolTip));
OnPropertyChanged(nameof(LastSyncText));
OnPropertyChanged(nameof(ArchiveText));
OnPropertyChanged(nameof(ErrorText));
OnPropertyChanged(nameof(ErrorToolTip));
OnPropertyChanged(nameof(CanOpenAdmin));
CommandManager.InvalidateRequerySuggested();
}
/// <summary>Updates the rows in place (scroll position and recycled containers survive), adding and removing as needed.</summary>
private void ApplyFilter()
{
var rights = Rights;
var wanted = _entries.Where(e => SyncText.Matches(e, _filter, _search.Trim())).ToList();
var byId = Rows.ToDictionary(r => r.Id);
for (var i = 0; i < wanted.Count; i++)
{
var entry = wanted[i];
if (byId.Remove(entry.Id, out var row))
{
row.Update(entry, rights);
var at = Rows.IndexOf(row);
if (at != i) Rows.Move(at, i);
}
else
{
Rows.Insert(i, new SyncRow(entry, rights, ActAsync));
}
}
while (Rows.Count > wanted.Count) Rows.RemoveAt(Rows.Count - 1);
OnPropertyChanged(nameof(HasRows));
OnPropertyChanged(nameof(EmptyText));
}
/// <summary>The Library shows each local copy's sync state: rows it has loaded take the fresh state.</summary>
private void UpdateLibrary()
{
var locals = _entries.Where(e => e.Local is not null).ToDictionary(e => e.Local!.Id, e => e.Local!);
foreach (var item in _shell.Library.Items)
{
if (locals.TryGetValue(item.Id, out var fresh) && fresh.SyncState != item.Sequence.SyncState) item.Update(fresh);
}
}
/// <summary>"Open with proxies" waits for the proxy download; the editor opens once it is in the cache.</summary>
private void OpenCachedProxies()
{
foreach (var entry in _entries)
{
if (entry.Status == SyncStatus.ProxiesOnly && _openWhenCached.Remove(entry.Id)) _shell.OpenSequence(entry.Id);
}
}
private async Task ActAsync(SyncRow row, SyncAction action)
{
if (Host is not { Service: { } service, Server: { } server } || _shell.Services.Engine is not { } engine) return;
var entry = row.Entry;
switch (action)
{
case SyncAction.Upload:
await service.EnqueueUploadAsync(engine, server, entry.Local!);
break;
case SyncAction.DownloadOriginals:
if ((entry.Local?.ArchiveId ?? (await Host.CurrentArchiveAsync())?.Id) is not { } archive)
{
_shell.Notify(Loc.L("Errors.Sync.NoArchive"));
return;
}
await service.EnqueueDownloadAsync(engine, server, entry.Id, entry.Title, SyncDownloadMode.Originals, archive);
break;
case SyncAction.OpenWithProxies when entry.Status == SyncStatus.ProxiesOnly && service.OpenRemote(server, entry.Id) is not null:
_shell.OpenSequence(entry.Id);
return;
case SyncAction.OpenWithProxies:
_openWhenCached.Add(entry.Id);
await service.EnqueueDownloadAsync(engine, server, entry.Id, entry.Title, SyncDownloadMode.Proxies, null);
break;
case SyncAction.Pause:
await _shell.Services.Jobs!.PauseAsync(entry.Transfer!.Id);
break;
case SyncAction.Resume:
await _shell.Services.Jobs!.ResumeAsync(entry.Transfer!.Id);
break;
case SyncAction.SyncSettings when Host.Remote is { } remote:
await service.SyncSettingsAsync(remote, entry.Id, CancellationToken.None);
break;
case SyncAction.KeepMine or SyncAction.TakeServer or SyncAction.SaveBoth when Host.Remote is { } remote:
await ResolveAsync(service, remote, entry, action);
break;
}
await ReloadAsync();
}
/// <summary>Settles a conflict; overwriting one side is confirmed first with the settings that differ (the dry run).</summary>
private async Task ResolveAsync(SyncService service, ISyncRemote remote, SyncEntry entry, SyncAction action)
{
var resolution = action switch
{
SyncAction.KeepMine => SyncResolution.KeepMine,
SyncAction.TakeServer => SyncResolution.TakeServer,
_ => SyncResolution.SaveBoth,
};
if (resolution != SyncResolution.SaveBoth && !_shell.Services.Dialogs.Confirm(new ConfirmRequest
{
Heading = Loc.L("Server.Conflict." + action + ".Title"),
Message = Loc.L("Server.Conflict." + action + ".Message", entry.Title),
Detail = SyncText.Conflict(entry),
DetailToolTip = Loc.L("Tooltips.Server.Conflict.Detail"),
SafeText = Loc.L("Server.Conflict.Cancel"),
SafeToolTip = Loc.L("Tooltips.Server.Conflict.Cancel"),
ActionText = Loc.L("Server.Sync.Action." + action),
ActionToolTip = Loc.L("Tooltips.Server.Sync." + action),
IsDestructive = true,
})) return;
try
{
await service.ResolveAsync(remote, entry.Id, resolution, CancellationToken.None);
}
catch (TitanoApiException ex) when (ex.Status == HttpStatusCode.Conflict)
{
// The server copy changed again meanwhile: compare again and let the user choose on fresh content.
_shell.Notify(Loc.L("Server.Sync.ChangedAgain"));
await service.RefreshSequencesAsync(remote, [entry.Id], Host.Policy, CancellationToken.None);
}
}
private async Task UploadAllAsync()
{
if (Host is not { Service: { } service, Server: { } server } || _shell.Services.Engine is not { } engine) return;
var queued = 0;
foreach (var entry in LocalOnly.ToList())
{
await service.EnqueueUploadAsync(engine, server, entry.Local!);
queued++;
}
_shell.Notify(Loc.Plural("Server.Sync.Queued", queued));
await ReloadAsync();
}
private void OnChanged() => Dispatch(() => _ = ReloadAsync());
private void OnJobChanged(Job job)
{
if (job.Kind is not (JobKind.UploadCommit or JobKind.Download)) return;
_progress.TryRemove(job.Id, out _);
OnChanged();
}
/// <summary>Transfer progress ("46 % received") without reading the table again, at most a few times a second.</summary>
private void OnProgress(JobProgressInfo info)
{
if (info.Kind is not (JobKind.UploadCommit or JobKind.Download)) return;
_progress[info.JobId] = info;
if (Interlocked.Exchange(ref _progressQueued, 1) == 1) return;
System.Windows.Application.Current?.Dispatcher.BeginInvoke(DispatcherPriority.Background, async () =>
{
await Task.Delay(250);
Interlocked.Exchange(ref _progressQueued, 0);
var rights = Rights;
foreach (var row in Rows)
{
if (row.Entry.Transfer is { } job && _progress.TryGetValue(job.Id, out var p))
row.Update(row.Entry with { Transfer = job with { ProgressDone = p.Done, ProgressTotal = p.Total } }, rights);
}
});
}
private static void Dispatch(Action action)
{
if (System.Windows.Application.Current?.Dispatcher is not { } dispatcher || dispatcher.CheckAccess()) action();
else dispatcher.BeginInvoke(action);
}
}
+147
View File
@@ -0,0 +1,147 @@
using Titano.App.Infrastructure;
using Titano.Core.Localization;
using Titano.Core.Model;
using Titano.Data.Sync;
using Titano.Ui.Controls;
namespace Titano.App.Server;
/// <summary>Filter chips of the sync table (Server.html).</summary>
public enum SyncFilter
{
All,
LocalOnly,
Remote,
Conflicts,
}
/// <summary>What a row of the sync table offers.</summary>
public enum SyncAction
{
Upload,
OpenWithProxies,
DownloadOriginals,
SyncSettings,
KeepMine,
TakeServer,
SaveBoth,
Pause,
Resume,
}
/// <summary>What the signed-in account may do (server permission bits).</summary>
/// <param name="CanUpload">Send originals and settings.</param>
/// <param name="CanFetchOriginals">Download originals (editors and render nodes).</param>
public readonly record struct SyncRights(bool CanUpload, bool CanFetchOriginals)
{
public static SyncRights Of(long permissions) => new(
(permissions & (long)Permissions.Upload) != 0 && (permissions & (long)Permissions.Edit) != 0,
(permissions & (long)(Permissions.Edit | Permissions.RenderNode)) != 0);
}
/// <summary>The words, glyphs and actions of the sync table (BRIEF §12.7): plain functions of a <see cref="SyncEntry"/>.</summary>
public static class SyncText
{
/// <summary>"originals · proxies", "proxies" (cached server proxies) or "—".</summary>
public static string Local(SyncEntry entry)
{
if (entry.HasLocalOriginals)
return (entry.Local!.Status & SequenceStatus.ProxiesBuilt) != 0 ? Join(Loc.L("Server.Sync.Originals"), Loc.L("Server.Sync.Proxies")) : Loc.L("Server.Sync.Originals");
return entry.Link is { ProxiesCached: > 0 } ? Loc.L("Server.Sync.Proxies") : Loc.L("Server.Sync.None");
}
/// <summary>"originals · proxies · 3 exports", "46 % received" while uploading, or "—".</summary>
public static string Server(SyncEntry entry)
{
if (entry.Transfer is { Kind: JobKind.UploadCommit, State: JobState.Running, ProgressTotal: > 0 } upload)
return Loc.L("Server.Sync.Received", Formatting.Percent((double)upload.ProgressDone / upload.ProgressTotal));
if (entry.Link is not { } link) return Loc.L("Server.Sync.None");
var parts = new List<string>(3) { Loc.L("Server.Sync.Originals") };
if (link.ServerHasProxies) parts.Add(Loc.L("Server.Sync.Proxies"));
if (link.RenderCount > 0) parts.Add(Loc.Plural("Server.Sync.Exports", link.RenderCount));
return Join([.. parts]);
}
/// <summary>The State column: glyph kind, word and tooltip (never colour alone).</summary>
public static (StatusKind Kind, string Text, string ToolTip) State(SyncEntry entry)
{
if (entry.Transfer is { } job)
{
var upload = job.Kind == JobKind.UploadCommit;
return job.State switch
{
JobState.Paused => (StatusKind.Paused, Loc.L("Server.Sync.State.Paused"), Loc.L("Tooltips.Server.Sync.State.Paused")),
JobState.Queued => (StatusKind.Queued, Loc.L("Server.Sync.State.Waiting"), Loc.L("Tooltips.Server.Sync.State.Waiting")),
_ => (StatusKind.Running, Loc.L(upload ? "Server.Sync.State.Uploading" : "Server.Sync.State.Downloading"),
Loc.L(upload ? "Tooltips.Server.Sync.State.Uploading" : "Tooltips.Server.Sync.State.Downloading")),
};
}
return entry.Status switch
{
SyncStatus.InSync => (StatusKind.Done, Loc.L("Server.Sync.State.InSync"), Loc.L("Tooltips.Server.Sync.State.InSync")),
SyncStatus.LocalOnly => (StatusKind.Offline, Loc.L("Server.Sync.State.LocalOnly"), Loc.L("Tooltips.Server.Sync.State.LocalOnly")),
SyncStatus.RemoteOnly => (StatusKind.Remote, Loc.L("Server.Sync.State.RemoteOnly"), Loc.L("Tooltips.Server.Sync.State.RemoteOnly")),
SyncStatus.ProxiesOnly => (StatusKind.Remote, Loc.L("Server.Sync.State.ProxiesOnly"), Loc.L("Tooltips.Server.Sync.State.ProxiesOnly")),
SyncStatus.LocalAhead => (StatusKind.Synced, Loc.L("Server.Sync.State.LocalAhead"), Loc.L("Tooltips.Server.Sync.State.LocalAhead")),
SyncStatus.ServerAhead => (StatusKind.Remote, Loc.L("Server.Sync.State.ServerAhead"), Loc.L("Tooltips.Server.Sync.State.ServerAhead")),
_ => (StatusKind.Warning, Loc.L("Server.Sync.State.Conflict"), Conflict(entry)),
};
}
/// <summary>"exposure.deflickerWindow.manual: 41 here, 33 on the server" for each setting that differs (at most three).</summary>
public static string Conflict(SyncEntry entry)
{
var differences = entry.Link?.ConflictSettingsJson is { } theirs ? SyncRules.Differences(entry.Local?.SettingsJson, theirs) : [];
if (differences.Count == 0) return Loc.L("Tooltips.Server.Sync.State.Conflict");
return string.Join("\n", differences.Select(d => Loc.L("Server.Conflict.Difference", d.Path, d.Mine ?? Loc.L("Server.Sync.None"), d.Theirs ?? Loc.L("Server.Sync.None"))));
}
/// <summary>The row's buttons, in the order the mockup shows them.</summary>
public static IReadOnlyList<SyncAction> Actions(SyncEntry entry, SyncRights rights)
{
if (entry.Transfer is { } job) return job.State == JobState.Paused ? [SyncAction.Resume] : [SyncAction.Pause];
var actions = new List<SyncAction>(3);
switch (entry.Status)
{
case SyncStatus.LocalOnly when rights.CanUpload:
actions.Add(SyncAction.Upload);
break;
case SyncStatus.RemoteOnly or SyncStatus.ProxiesOnly:
actions.Add(SyncAction.OpenWithProxies);
if (rights.CanFetchOriginals) actions.Add(SyncAction.DownloadOriginals);
break;
case SyncStatus.LocalAhead when entry.Link is { MissingRemote: > 0 }:
if (rights.CanUpload) actions.Add(SyncAction.Upload);
break;
case SyncStatus.ServerAhead when entry.Link is { MissingLocal: > 0 }:
if (rights.CanFetchOriginals) actions.Add(SyncAction.DownloadOriginals);
break;
case SyncStatus.LocalAhead or SyncStatus.ServerAhead:
actions.Add(SyncAction.SyncSettings);
break;
case SyncStatus.Conflict:
actions.AddRange([SyncAction.KeepMine, SyncAction.TakeServer, SyncAction.SaveBoth]);
break;
}
return actions;
}
/// <summary>The bytes an upload or download of the row moves (for the tooltips).</summary>
public static long Size(SyncEntry entry, SyncAction action) => action switch
{
SyncAction.Upload => entry.Local?.TotalBytes ?? 0,
SyncAction.DownloadOriginals => entry.Link?.TotalBytes ?? 0,
_ => 0,
};
public static bool Matches(SyncEntry entry, SyncFilter filter, string search) =>
(filter switch
{
SyncFilter.LocalOnly => entry.Status == SyncStatus.LocalOnly,
SyncFilter.Remote => entry.Status is SyncStatus.RemoteOnly or SyncStatus.ProxiesOnly,
SyncFilter.Conflicts => entry.Status == SyncStatus.Conflict,
_ => true,
}) && (search.Length == 0 || entry.Title.Contains(search, StringComparison.CurrentCultureIgnoreCase));
private static string Join(params string[] parts) => string.Join(" · ", parts);
}