feat: single setup, mass-pass progress, per-server homes, Desktop shares its library (owner review 5, v1.1.0) #68
No files matched your search
@@ -1193,4 +1193,57 @@
|
||||
<data name="Admin.Videos.Sequence.Clear.Tip" xml:space="preserve"><value>Show the videos of every sequence; the other filters stay</value></data>
|
||||
<data name="Admin.Settings.VideosPath" xml:space="preserve"><value>Videos folder</value></data>
|
||||
<data name="Admin.Settings.VideosPath.Tip" xml:space="preserve"><value>Where Copy to folder puts videos (the /videos volume in Docker); empty turns copying off</value></data>
|
||||
<data name="Admin.Job.Step.List" xml:space="preserve"><value>Listing folders</value></data>
|
||||
<data name="Admin.Job.Step.Check" xml:space="preserve"><value>Checking</value></data>
|
||||
<data name="Admin.Job.Step.Index" xml:space="preserve"><value>Indexing</value></data>
|
||||
<data name="Admin.Job.Step.Index.Count" xml:space="preserve"><value>Indexing photo {0} of {1}</value></data>
|
||||
<data name="Admin.Job.Step.Verify" xml:space="preserve"><value>Verifying</value></data>
|
||||
<data name="Admin.Job.Step.Verify.Count" xml:space="preserve"><value>Verifying photo {0} of {1}</value></data>
|
||||
<data name="Admin.Job.Step.Thumbs" xml:space="preserve"><value>Drawing thumbnails</value></data>
|
||||
<data name="Admin.Job.Step.Thumbs.Count" xml:space="preserve"><value>Thumbnail {0} of {1}</value></data>
|
||||
<data name="Admin.Job.Step.Proxies" xml:space="preserve"><value>Making proxies</value></data>
|
||||
<data name="Admin.Job.Step.Proxies.Count" xml:space="preserve"><value>Proxy {0} of {1}</value></data>
|
||||
<data name="Admin.Job.Step.Analyse" xml:space="preserve"><value>Analysing</value></data>
|
||||
<data name="Admin.Job.Step.Analyse.Count" xml:space="preserve"><value>Analysing photo {0} of {1}</value></data>
|
||||
<data name="Admin.Job.Step.Convert" xml:space="preserve"><value>Converting</value></data>
|
||||
<data name="Admin.Job.Step.Convert.Count" xml:space="preserve"><value>Converting photo {0} of {1}</value></data>
|
||||
<data name="Admin.Job.Step.Replace" xml:space="preserve"><value>Replacing photos</value></data>
|
||||
<data name="Admin.Job.Step.Replace.Count" xml:space="preserve"><value>Replacing photo {0} of {1}</value></data>
|
||||
<data name="Admin.Job.Step.Reorganize" xml:space="preserve"><value>Reorganizing</value></data>
|
||||
<data name="Admin.Job.Step.CopyPhoto" xml:space="preserve"><value>Copying photos</value></data>
|
||||
<data name="Admin.Job.Step.CopyPhoto.Count" xml:space="preserve"><value>Copying photo {0} of {1}</value></data>
|
||||
<data name="Admin.Job.Step.CopyProxy" xml:space="preserve"><value>Copying proxies</value></data>
|
||||
<data name="Admin.Job.Step.CopyProxy.Count" xml:space="preserve"><value>Copying proxy {0} of {1}</value></data>
|
||||
<data name="Admin.Job.Step.CopyOriginal" xml:space="preserve"><value>Copying originals</value></data>
|
||||
<data name="Admin.Job.Step.CopyOriginal.Count" xml:space="preserve"><value>Copying original {0} of {1}</value></data>
|
||||
<data name="Admin.Job.Step.CopyVideo" xml:space="preserve"><value>Copying video</value></data>
|
||||
<data name="Admin.Job.Step.Encode" xml:space="preserve"><value>Encoding</value></data>
|
||||
<data name="Admin.Job.Step.Encode.Count" xml:space="preserve"><value>Encoding frame {0} of {1}</value></data>
|
||||
<data name="Admin.Job.Step.Upload" xml:space="preserve"><value>Uploading</value></data>
|
||||
<data name="Admin.Job.Step.Upload.Count" xml:space="preserve"><value>Uploading photo {0} of {1}</value></data>
|
||||
<data name="Admin.Job.Step.Download" xml:space="preserve"><value>Downloading</value></data>
|
||||
<data name="Admin.Job.Step.Download.Count" xml:space="preserve"><value>Downloading photo {0} of {1}</value></data>
|
||||
<data name="Admin.Job.Step.Erase" xml:space="preserve"><value>Erasing</value></data>
|
||||
<data name="Admin.Job.Step.Backup" xml:space="preserve"><value>Copying the index</value></data>
|
||||
<data name="Admin.Job.Step.Cleanup" xml:space="preserve"><value>Cleaning up</value></data>
|
||||
<data name="Admin.Job.Step.Maintenance" xml:space="preserve"><value>Maintenance</value></data>
|
||||
<data name="Admin.Job.Step.FollowUps" xml:space="preserve"><value>Queueing follow-ups</value></data>
|
||||
<data name="Admin.Job.Step.Process" xml:space="preserve"><value>Processing</value></data>
|
||||
<data name="Admin.Job.Step.Process.Count" xml:space="preserve"><value>Processing photo {0} of {1}</value></data>
|
||||
<data name="Admin.Job.Maintenance.Step.Leases" xml:space="preserve"><value>Clearing stale leases</value></data>
|
||||
<data name="Admin.Job.Maintenance.Step.Temp" xml:space="preserve"><value>Removing temporary files</value></data>
|
||||
<data name="Admin.Job.Maintenance.Step.Packs" xml:space="preserve"><value>Compacting thumbnails</value></data>
|
||||
<data name="Admin.Job.Maintenance.Step.Duplicates" xml:space="preserve"><value>Flagging duplicates</value></data>
|
||||
<data name="Admin.Job.Maintenance.Step.Vacuum" xml:space="preserve"><value>Compacting the index</value></data>
|
||||
<data name="Admin.Job.Part.Sequence" xml:space="preserve"><value>sequence {0} of {1}</value></data>
|
||||
<data name="Admin.Job.Part.Folder" xml:space="preserve"><value>folder {0} of {1}</value></data>
|
||||
<data name="Admin.Job.Part.Render" xml:space="preserve"><value>video {0} of {1}</value></data>
|
||||
<data name="Admin.Job.Part.Entry" xml:space="preserve"><value>entry {0} of {1}</value></data>
|
||||
<data name="Admin.Job.Part.Step" xml:space="preserve"><value>step {0} of {1}</value></data>
|
||||
<data name="Admin.Job.Detail.Count" xml:space="preserve"><value>{0} of {1}</value></data>
|
||||
<data name="Admin.Job.Detail.StoppedAt" xml:space="preserve"><value>Stopped at {0}</value></data>
|
||||
<data name="Admin.Job.Speed.Fps" xml:space="preserve"><value>{0} fps</value></data>
|
||||
<data name="Admin.Job.Speed.PerSecond" xml:space="preserve"><value>{0}/s</value></data>
|
||||
<data name="Admin.Job.Speed.Bytes" xml:space="preserve"><value>{0}/s</value></data>
|
||||
<data name="Admin.Job.Left" xml:space="preserve"><value>{0} left</value></data>
|
||||
</root>
|
||||
@@ -207,4 +207,53 @@
|
||||
<data name="Jobs.Log.WorkspaceSkip.NoMedia" xml:space="preserve"><value>no media to remove</value></data>
|
||||
<data name="Jobs.Log.WorkspaceSkip.JustCopied" xml:space="preserve"><value>just copied</value></data>
|
||||
<data name="Jobs.Kind.VideoCopy" xml:space="preserve"><value>Copy videos</value></data>
|
||||
<data name="Jobs.Step.List" xml:space="preserve"><value>Listing folders</value></data>
|
||||
<data name="Jobs.Step.Check" xml:space="preserve"><value>Checking</value></data>
|
||||
<data name="Jobs.Step.Index" xml:space="preserve"><value>Indexing</value></data>
|
||||
<data name="Jobs.Step.Index.Count" xml:space="preserve"><value>Indexing photo {0} of {1}</value></data>
|
||||
<data name="Jobs.Step.Verify" xml:space="preserve"><value>Verifying</value></data>
|
||||
<data name="Jobs.Step.Verify.Count" xml:space="preserve"><value>Verifying photo {0} of {1}</value></data>
|
||||
<data name="Jobs.Step.Thumbs" xml:space="preserve"><value>Drawing thumbnails</value></data>
|
||||
<data name="Jobs.Step.Thumbs.Count" xml:space="preserve"><value>Thumbnail {0} of {1}</value></data>
|
||||
<data name="Jobs.Step.Proxies" xml:space="preserve"><value>Making proxies</value></data>
|
||||
<data name="Jobs.Step.Proxies.Count" xml:space="preserve"><value>Proxy {0} of {1}</value></data>
|
||||
<data name="Jobs.Step.Analyse" xml:space="preserve"><value>Analysing</value></data>
|
||||
<data name="Jobs.Step.Analyse.Count" xml:space="preserve"><value>Analysing photo {0} of {1}</value></data>
|
||||
<data name="Jobs.Step.Convert" xml:space="preserve"><value>Converting</value></data>
|
||||
<data name="Jobs.Step.Convert.Count" xml:space="preserve"><value>Converting photo {0} of {1}</value></data>
|
||||
<data name="Jobs.Step.Replace" xml:space="preserve"><value>Replacing photos</value></data>
|
||||
<data name="Jobs.Step.Replace.Count" xml:space="preserve"><value>Replacing photo {0} of {1}</value></data>
|
||||
<data name="Jobs.Step.Reorganize" xml:space="preserve"><value>Reorganizing</value></data>
|
||||
<data name="Jobs.Step.CopyPhoto" xml:space="preserve"><value>Copying photos</value></data>
|
||||
<data name="Jobs.Step.CopyPhoto.Count" xml:space="preserve"><value>Copying photo {0} of {1}</value></data>
|
||||
<data name="Jobs.Step.CopyProxy" xml:space="preserve"><value>Copying proxies</value></data>
|
||||
<data name="Jobs.Step.CopyProxy.Count" xml:space="preserve"><value>Copying proxy {0} of {1}</value></data>
|
||||
<data name="Jobs.Step.CopyOriginal" xml:space="preserve"><value>Copying originals</value></data>
|
||||
<data name="Jobs.Step.CopyOriginal.Count" xml:space="preserve"><value>Copying original {0} of {1}</value></data>
|
||||
<data name="Jobs.Step.CopyVideo" xml:space="preserve"><value>Copying video</value></data>
|
||||
<data name="Jobs.Step.Encode" xml:space="preserve"><value>Encoding</value></data>
|
||||
<data name="Jobs.Step.Encode.Count" xml:space="preserve"><value>Encoding frame {0} of {1}</value></data>
|
||||
<data name="Jobs.Step.Upload" xml:space="preserve"><value>Uploading</value></data>
|
||||
<data name="Jobs.Step.Upload.Count" xml:space="preserve"><value>Uploading photo {0} of {1}</value></data>
|
||||
<data name="Jobs.Step.Download" xml:space="preserve"><value>Downloading</value></data>
|
||||
<data name="Jobs.Step.Download.Count" xml:space="preserve"><value>Downloading photo {0} of {1}</value></data>
|
||||
<data name="Jobs.Step.Erase" xml:space="preserve"><value>Erasing</value></data>
|
||||
<data name="Jobs.Step.Backup" xml:space="preserve"><value>Copying the index</value></data>
|
||||
<data name="Jobs.Step.Cleanup" xml:space="preserve"><value>Cleaning up</value></data>
|
||||
<data name="Jobs.Step.Maintenance" xml:space="preserve"><value>Maintenance</value></data>
|
||||
<data name="Jobs.Step.FollowUps" xml:space="preserve"><value>Queueing follow-ups</value></data>
|
||||
<data name="Jobs.Step.Process" xml:space="preserve"><value>Processing</value></data>
|
||||
<data name="Jobs.Step.Process.Count" xml:space="preserve"><value>Processing photo {0} of {1}</value></data>
|
||||
<data name="Jobs.Maintenance.Step.Leases" xml:space="preserve"><value>Clearing stale leases</value></data>
|
||||
<data name="Jobs.Maintenance.Step.Temp" xml:space="preserve"><value>Removing temporary files</value></data>
|
||||
<data name="Jobs.Maintenance.Step.Packs" xml:space="preserve"><value>Compacting thumbnails</value></data>
|
||||
<data name="Jobs.Maintenance.Step.Duplicates" xml:space="preserve"><value>Flagging duplicates</value></data>
|
||||
<data name="Jobs.Maintenance.Step.Vacuum" xml:space="preserve"><value>Compacting the index</value></data>
|
||||
<data name="Jobs.Part.Sequence" xml:space="preserve"><value>sequence {0} of {1}</value></data>
|
||||
<data name="Jobs.Part.Folder" xml:space="preserve"><value>folder {0} of {1}</value></data>
|
||||
<data name="Jobs.Part.Render" xml:space="preserve"><value>video {0} of {1}</value></data>
|
||||
<data name="Jobs.Part.Entry" xml:space="preserve"><value>entry {0} of {1}</value></data>
|
||||
<data name="Jobs.Part.Step" xml:space="preserve"><value>step {0} of {1}</value></data>
|
||||
<data name="Jobs.Detail.Count" xml:space="preserve"><value>{0} of {1}</value></data>
|
||||
<data name="Jobs.Detail.StoppedAt" xml:space="preserve"><value>Stopped at {0}</value></data>
|
||||
</root>
|
||||
@@ -129,6 +129,8 @@
|
||||
<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.Jobs.NotChanged" xml:space="preserve"><value>Job not changed</value></data>
|
||||
<data name="Server.Jobs.Title" xml:space="preserve"><value>Server jobs</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>
|
||||
|
||||
@@ -692,6 +692,8 @@
|
||||
<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.Jobs" xml:space="preserve"><value>What runs or waits paused on the server now; pause, resume or cancel any of them</value></data>
|
||||
<data name="Tooltips.Server.Jobs.ReadOnly" xml:space="preserve"><value>What runs or waits paused on the server now; only an account that manages the archive can pause or cancel them</value></data>
|
||||
<data name="Tooltips.Server.KeepProxies" xml:space="preserve"><value>Keep the proxies of the server sequences you opened with proxies up to date on this PC, to edit without the originals; uses space in the cache folder</value><comment>long</comment></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>
|
||||
|
||||
@@ -1185,4 +1185,57 @@
|
||||
<data name="Admin.Videos.Sequence.Clear.Tip" xml:space="preserve"><value>Mostra i video di tutte le sequenze; gli altri filtri restano</value></data>
|
||||
<data name="Admin.Settings.VideosPath" xml:space="preserve"><value>Cartella video</value></data>
|
||||
<data name="Admin.Settings.VideosPath.Tip" xml:space="preserve"><value>Dove Copia in cartella mette i video (il volume /videos in Docker); vuota disattiva la copia</value></data>
|
||||
<data name="Admin.Job.Step.List" xml:space="preserve"><value>Elenco cartelle</value></data>
|
||||
<data name="Admin.Job.Step.Check" xml:space="preserve"><value>Controllo</value></data>
|
||||
<data name="Admin.Job.Step.Index" xml:space="preserve"><value>Indicizzazione</value></data>
|
||||
<data name="Admin.Job.Step.Index.Count" xml:space="preserve"><value>Indicizzazione foto {0} di {1}</value></data>
|
||||
<data name="Admin.Job.Step.Verify" xml:space="preserve"><value>Verifica</value></data>
|
||||
<data name="Admin.Job.Step.Verify.Count" xml:space="preserve"><value>Verifica foto {0} di {1}</value></data>
|
||||
<data name="Admin.Job.Step.Thumbs" xml:space="preserve"><value>Creazione miniature</value></data>
|
||||
<data name="Admin.Job.Step.Thumbs.Count" xml:space="preserve"><value>Miniatura {0} di {1}</value></data>
|
||||
<data name="Admin.Job.Step.Proxies" xml:space="preserve"><value>Creazione proxy</value></data>
|
||||
<data name="Admin.Job.Step.Proxies.Count" xml:space="preserve"><value>Proxy {0} di {1}</value></data>
|
||||
<data name="Admin.Job.Step.Analyse" xml:space="preserve"><value>Analisi</value></data>
|
||||
<data name="Admin.Job.Step.Analyse.Count" xml:space="preserve"><value>Analisi foto {0} di {1}</value></data>
|
||||
<data name="Admin.Job.Step.Convert" xml:space="preserve"><value>Conversione</value></data>
|
||||
<data name="Admin.Job.Step.Convert.Count" xml:space="preserve"><value>Conversione foto {0} di {1}</value></data>
|
||||
<data name="Admin.Job.Step.Replace" xml:space="preserve"><value>Sostituzione foto</value></data>
|
||||
<data name="Admin.Job.Step.Replace.Count" xml:space="preserve"><value>Sostituzione foto {0} di {1}</value></data>
|
||||
<data name="Admin.Job.Step.Reorganize" xml:space="preserve"><value>Riorganizzazione</value></data>
|
||||
<data name="Admin.Job.Step.CopyPhoto" xml:space="preserve"><value>Copia foto</value></data>
|
||||
<data name="Admin.Job.Step.CopyPhoto.Count" xml:space="preserve"><value>Copia foto {0} di {1}</value></data>
|
||||
<data name="Admin.Job.Step.CopyProxy" xml:space="preserve"><value>Copia proxy</value></data>
|
||||
<data name="Admin.Job.Step.CopyProxy.Count" xml:space="preserve"><value>Copia proxy {0} di {1}</value></data>
|
||||
<data name="Admin.Job.Step.CopyOriginal" xml:space="preserve"><value>Copia originali</value></data>
|
||||
<data name="Admin.Job.Step.CopyOriginal.Count" xml:space="preserve"><value>Copia originale {0} di {1}</value></data>
|
||||
<data name="Admin.Job.Step.CopyVideo" xml:space="preserve"><value>Copia video</value></data>
|
||||
<data name="Admin.Job.Step.Encode" xml:space="preserve"><value>Codifica</value></data>
|
||||
<data name="Admin.Job.Step.Encode.Count" xml:space="preserve"><value>Codifica fotogramma {0} di {1}</value></data>
|
||||
<data name="Admin.Job.Step.Upload" xml:space="preserve"><value>Invio</value></data>
|
||||
<data name="Admin.Job.Step.Upload.Count" xml:space="preserve"><value>Invio foto {0} di {1}</value></data>
|
||||
<data name="Admin.Job.Step.Download" xml:space="preserve"><value>Download</value></data>
|
||||
<data name="Admin.Job.Step.Download.Count" xml:space="preserve"><value>Download foto {0} di {1}</value></data>
|
||||
<data name="Admin.Job.Step.Erase" xml:space="preserve"><value>Eliminazione</value></data>
|
||||
<data name="Admin.Job.Step.Backup" xml:space="preserve"><value>Copia dell'indice</value></data>
|
||||
<data name="Admin.Job.Step.Cleanup" xml:space="preserve"><value>Pulizia</value></data>
|
||||
<data name="Admin.Job.Step.Maintenance" xml:space="preserve"><value>Manutenzione</value></data>
|
||||
<data name="Admin.Job.Step.FollowUps" xml:space="preserve"><value>Accodamento seguiti</value></data>
|
||||
<data name="Admin.Job.Step.Process" xml:space="preserve"><value>Elaborazione</value></data>
|
||||
<data name="Admin.Job.Step.Process.Count" xml:space="preserve"><value>Elaborazione foto {0} di {1}</value></data>
|
||||
<data name="Admin.Job.Maintenance.Step.Leases" xml:space="preserve"><value>Pulizia lease scaduti</value></data>
|
||||
<data name="Admin.Job.Maintenance.Step.Temp" xml:space="preserve"><value>Rimozione file temporanei</value></data>
|
||||
<data name="Admin.Job.Maintenance.Step.Packs" xml:space="preserve"><value>Compattazione miniature</value></data>
|
||||
<data name="Admin.Job.Maintenance.Step.Duplicates" xml:space="preserve"><value>Marcatura duplicati</value></data>
|
||||
<data name="Admin.Job.Maintenance.Step.Vacuum" xml:space="preserve"><value>Compattazione indice</value></data>
|
||||
<data name="Admin.Job.Part.Sequence" xml:space="preserve"><value>sequenza {0} di {1}</value></data>
|
||||
<data name="Admin.Job.Part.Folder" xml:space="preserve"><value>cartella {0} di {1}</value></data>
|
||||
<data name="Admin.Job.Part.Render" xml:space="preserve"><value>video {0} di {1}</value></data>
|
||||
<data name="Admin.Job.Part.Entry" xml:space="preserve"><value>voce {0} di {1}</value></data>
|
||||
<data name="Admin.Job.Part.Step" xml:space="preserve"><value>passo {0} di {1}</value></data>
|
||||
<data name="Admin.Job.Detail.Count" xml:space="preserve"><value>{0} di {1}</value></data>
|
||||
<data name="Admin.Job.Detail.StoppedAt" xml:space="preserve"><value>Fermo a {0}</value></data>
|
||||
<data name="Admin.Job.Speed.Fps" xml:space="preserve"><value>{0} fps</value></data>
|
||||
<data name="Admin.Job.Speed.PerSecond" xml:space="preserve"><value>{0}/s</value></data>
|
||||
<data name="Admin.Job.Speed.Bytes" xml:space="preserve"><value>{0}/s</value></data>
|
||||
<data name="Admin.Job.Left" xml:space="preserve"><value>{0} rimanenti</value></data>
|
||||
</root>
|
||||
@@ -205,4 +205,53 @@
|
||||
<data name="Jobs.Log.WorkspaceSkip.NoMedia" xml:space="preserve"><value>nessun media da rimuovere</value></data>
|
||||
<data name="Jobs.Log.WorkspaceSkip.JustCopied" xml:space="preserve"><value>appena copiato</value></data>
|
||||
<data name="Jobs.Kind.VideoCopy" xml:space="preserve"><value>Copia video</value></data>
|
||||
<data name="Jobs.Step.List" xml:space="preserve"><value>Elenco cartelle</value></data>
|
||||
<data name="Jobs.Step.Check" xml:space="preserve"><value>Controllo</value></data>
|
||||
<data name="Jobs.Step.Index" xml:space="preserve"><value>Indicizzazione</value></data>
|
||||
<data name="Jobs.Step.Index.Count" xml:space="preserve"><value>Indicizzazione foto {0} di {1}</value></data>
|
||||
<data name="Jobs.Step.Verify" xml:space="preserve"><value>Verifica</value></data>
|
||||
<data name="Jobs.Step.Verify.Count" xml:space="preserve"><value>Verifica foto {0} di {1}</value></data>
|
||||
<data name="Jobs.Step.Thumbs" xml:space="preserve"><value>Creazione miniature</value></data>
|
||||
<data name="Jobs.Step.Thumbs.Count" xml:space="preserve"><value>Miniatura {0} di {1}</value></data>
|
||||
<data name="Jobs.Step.Proxies" xml:space="preserve"><value>Creazione proxy</value></data>
|
||||
<data name="Jobs.Step.Proxies.Count" xml:space="preserve"><value>Proxy {0} di {1}</value></data>
|
||||
<data name="Jobs.Step.Analyse" xml:space="preserve"><value>Analisi</value></data>
|
||||
<data name="Jobs.Step.Analyse.Count" xml:space="preserve"><value>Analisi foto {0} di {1}</value></data>
|
||||
<data name="Jobs.Step.Convert" xml:space="preserve"><value>Conversione</value></data>
|
||||
<data name="Jobs.Step.Convert.Count" xml:space="preserve"><value>Conversione foto {0} di {1}</value></data>
|
||||
<data name="Jobs.Step.Replace" xml:space="preserve"><value>Sostituzione foto</value></data>
|
||||
<data name="Jobs.Step.Replace.Count" xml:space="preserve"><value>Sostituzione foto {0} di {1}</value></data>
|
||||
<data name="Jobs.Step.Reorganize" xml:space="preserve"><value>Riorganizzazione</value></data>
|
||||
<data name="Jobs.Step.CopyPhoto" xml:space="preserve"><value>Copia foto</value></data>
|
||||
<data name="Jobs.Step.CopyPhoto.Count" xml:space="preserve"><value>Copia foto {0} di {1}</value></data>
|
||||
<data name="Jobs.Step.CopyProxy" xml:space="preserve"><value>Copia proxy</value></data>
|
||||
<data name="Jobs.Step.CopyProxy.Count" xml:space="preserve"><value>Copia proxy {0} di {1}</value></data>
|
||||
<data name="Jobs.Step.CopyOriginal" xml:space="preserve"><value>Copia originali</value></data>
|
||||
<data name="Jobs.Step.CopyOriginal.Count" xml:space="preserve"><value>Copia originale {0} di {1}</value></data>
|
||||
<data name="Jobs.Step.CopyVideo" xml:space="preserve"><value>Copia video</value></data>
|
||||
<data name="Jobs.Step.Encode" xml:space="preserve"><value>Codifica</value></data>
|
||||
<data name="Jobs.Step.Encode.Count" xml:space="preserve"><value>Codifica fotogramma {0} di {1}</value></data>
|
||||
<data name="Jobs.Step.Upload" xml:space="preserve"><value>Invio</value></data>
|
||||
<data name="Jobs.Step.Upload.Count" xml:space="preserve"><value>Invio foto {0} di {1}</value></data>
|
||||
<data name="Jobs.Step.Download" xml:space="preserve"><value>Download</value></data>
|
||||
<data name="Jobs.Step.Download.Count" xml:space="preserve"><value>Download foto {0} di {1}</value></data>
|
||||
<data name="Jobs.Step.Erase" xml:space="preserve"><value>Eliminazione</value></data>
|
||||
<data name="Jobs.Step.Backup" xml:space="preserve"><value>Copia dell'indice</value></data>
|
||||
<data name="Jobs.Step.Cleanup" xml:space="preserve"><value>Pulizia</value></data>
|
||||
<data name="Jobs.Step.Maintenance" xml:space="preserve"><value>Manutenzione</value></data>
|
||||
<data name="Jobs.Step.FollowUps" xml:space="preserve"><value>Accodamento seguiti</value></data>
|
||||
<data name="Jobs.Step.Process" xml:space="preserve"><value>Elaborazione</value></data>
|
||||
<data name="Jobs.Step.Process.Count" xml:space="preserve"><value>Elaborazione foto {0} di {1}</value></data>
|
||||
<data name="Jobs.Maintenance.Step.Leases" xml:space="preserve"><value>Pulizia lease scaduti</value></data>
|
||||
<data name="Jobs.Maintenance.Step.Temp" xml:space="preserve"><value>Rimozione file temporanei</value></data>
|
||||
<data name="Jobs.Maintenance.Step.Packs" xml:space="preserve"><value>Compattazione miniature</value></data>
|
||||
<data name="Jobs.Maintenance.Step.Duplicates" xml:space="preserve"><value>Marcatura duplicati</value></data>
|
||||
<data name="Jobs.Maintenance.Step.Vacuum" xml:space="preserve"><value>Compattazione indice</value></data>
|
||||
<data name="Jobs.Part.Sequence" xml:space="preserve"><value>sequenza {0} di {1}</value></data>
|
||||
<data name="Jobs.Part.Folder" xml:space="preserve"><value>cartella {0} di {1}</value></data>
|
||||
<data name="Jobs.Part.Render" xml:space="preserve"><value>video {0} di {1}</value></data>
|
||||
<data name="Jobs.Part.Entry" xml:space="preserve"><value>voce {0} di {1}</value></data>
|
||||
<data name="Jobs.Part.Step" xml:space="preserve"><value>passo {0} di {1}</value></data>
|
||||
<data name="Jobs.Detail.Count" xml:space="preserve"><value>{0} di {1}</value></data>
|
||||
<data name="Jobs.Detail.StoppedAt" xml:space="preserve"><value>Fermo a {0}</value></data>
|
||||
</root>
|
||||
@@ -127,6 +127,8 @@
|
||||
<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.Jobs.NotChanged" xml:space="preserve"><value>Lavoro non modificato</value></data>
|
||||
<data name="Server.Jobs.Title" xml:space="preserve"><value>Lavori del server</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>
|
||||
|
||||
@@ -762,6 +762,8 @@
|
||||
<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.Jobs" xml:space="preserve"><value>Ciò che il server esegue o tiene in pausa ora; metti in pausa, riprendi o annulla qualsiasi lavoro</value></data>
|
||||
<data name="Tooltips.Server.Jobs.ReadOnly" xml:space="preserve"><value>Ciò che il server esegue o tiene in pausa ora; solo un account che gestisce l'archivio può metterli in pausa o annullarli</value></data>
|
||||
<data name="Tooltips.Server.KeepProxies" xml:space="preserve"><value>Mantieni aggiornati su questo PC i proxy delle sequenze del server aperte con i proxy, 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>
|
||||
|
||||
@@ -3,6 +3,7 @@ using Chronos.App.Jobs;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Data.Archiving;
|
||||
using Chronos.Data.Jobs;
|
||||
using Chronos.Data.Repositories;
|
||||
using Chronos.Ui.Controls;
|
||||
|
||||
@@ -30,9 +31,15 @@ public enum OrphanKind
|
||||
/// <summary>One line of the orphans report and the target of its fix.</summary>
|
||||
public sealed record OrphanRow(OrphanKind Kind, string Title, string Detail, Guid? SequenceId);
|
||||
|
||||
/// <summary>A line of "Recent maintenance": date, operation and outcome.</summary>
|
||||
public sealed record MaintenanceRow(Guid JobId, string DateText, string Text, string StateText, JobState State)
|
||||
/// <summary>
|
||||
/// A line of "Recent maintenance": date, operation and outcome; <paramref name="Detail"/>, the muted second line of a running
|
||||
/// job (what it does now) or of a paused or failed one (where it stopped), owner review 5, #65; empty otherwise, with
|
||||
/// <paramref name="DetailToolTip"/> the line whole plus the speed and time left.
|
||||
/// </summary>
|
||||
public sealed record MaintenanceRow(Guid JobId, string DateText, string Text, string StateText, JobState State, string Detail = "", string DetailToolTip = "")
|
||||
{
|
||||
public bool HasDetail => Detail.Length > 0;
|
||||
|
||||
/// <summary>The outcome's glyph and colour, as on the Jobs screen (paired with the word, never colour alone).</summary>
|
||||
public StatusKind StateKind => State switch
|
||||
{
|
||||
@@ -102,18 +109,23 @@ public static class MaintenanceReports
|
||||
return rows;
|
||||
}
|
||||
|
||||
public static IReadOnlyList<MaintenanceRow> Recent(IEnumerable<Job> jobs, int count) =>
|
||||
/// <summary>
|
||||
/// The latest <paramref name="count"/> jobs as "Recent maintenance" lines; a running one shows its percentage and what it
|
||||
/// does now from its <paramref name="live"/> progress when there is some (owner review 5, #65), else from its stored snapshot.
|
||||
/// </summary>
|
||||
public static IReadOnlyList<MaintenanceRow> Recent(IEnumerable<Job> jobs, int count, IReadOnlyDictionary<Guid, JobProgressInfo>? live = null) =>
|
||||
[
|
||||
.. jobs.OrderByDescending(j => j.Finished ?? j.Started ?? j.Created).Take(count).Select(j =>
|
||||
{
|
||||
var when = j.Finished ?? j.Started ?? j.Created;
|
||||
var text = string.IsNullOrWhiteSpace(j.TargetLabel) ? JobText.Kind(j.Kind) : Loc.L("Archive.Recent.Line", JobText.Kind(j.Kind), j.TargetLabel);
|
||||
var entry = new JobEntry(j) { Live = j.State == JobState.Running ? live?.GetValueOrDefault(j.Id) : null };
|
||||
var state = j.State switch
|
||||
{
|
||||
JobState.Running when j.ProgressTotal > 0 => Formatting.Percent(j.ProgressDone / (double)j.ProgressTotal),
|
||||
JobState.Running when entry.Fraction is { } fraction => Formatting.Percent(fraction),
|
||||
_ => Loc.L("Jobs.State." + j.State),
|
||||
};
|
||||
return new MaintenanceRow(j.Id, Formatting.Date(when), text, state, j.State);
|
||||
return new MaintenanceRow(j.Id, Formatting.Date(when), text, state, j.State, JobText.RowStatus(entry), JobText.RowStatusToolTip(entry));
|
||||
}),
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using Chronos.Core.Model;
|
||||
|
||||
namespace Chronos.App.DesignTime;
|
||||
|
||||
/// <summary>
|
||||
/// What the sample's running and paused jobs do now (owner review 5, #65), for the design view, the screenshots and the
|
||||
/// visual tests: a pass over many photos says which photo of which sequence; a job of another kind, or one that is queued or
|
||||
/// finished, is left as it is.
|
||||
/// </summary>
|
||||
public static class SampleJobDetails
|
||||
{
|
||||
/// <summary><paramref name="job"/> with the sample detail of its kind while it runs or is paused; unchanged otherwise.</summary>
|
||||
public static Job Apply(Job job)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(job);
|
||||
if (job.State is not (JobState.Running or JobState.Paused) || job.Detail is not null) return job;
|
||||
var title = string.IsNullOrWhiteSpace(job.TargetLabel) ? null : job.TargetLabel;
|
||||
JobDetail? detail = job.Kind switch
|
||||
{
|
||||
JobKind.Scan or JobKind.Rebuild => new JobDetail(JobStep.Index, "2024/2024-09-27 Harbour sunset", 1_240, 3_600, 12, 340, JobPartUnit.Folder),
|
||||
JobKind.Verify => new JobDetail(JobStep.Verify, "Harbour sunset", 812, 2_400, 3, 41, JobPartUnit.Sequence),
|
||||
JobKind.Thumbs => new JobDetail(JobStep.Thumbs, title, 1_240, 3_600, 2, 7, JobPartUnit.Sequence),
|
||||
JobKind.Proxies => new JobDetail(JobStep.Proxies, title, 1_240, 3_600, 2, 7, JobPartUnit.Sequence),
|
||||
JobKind.LightAnalyse => new JobDetail(JobStep.Analyse, title, Part: 120, Parts: 4_812, PartUnit: JobPartUnit.Sequence),
|
||||
JobKind.DeepAnalyse => new JobDetail(JobStep.Analyse, title, job.ProgressDone, job.ProgressTotal),
|
||||
JobKind.Render or JobKind.WorkspaceRender => new JobDetail(JobStep.Encode, null, job.ProgressDone, job.ProgressTotal),
|
||||
JobKind.Convert => new JobDetail(JobStep.Convert, title, 412, 1_200, 4, 9, JobPartUnit.Sequence),
|
||||
JobKind.Import => new JobDetail(JobStep.CopyPhoto, "IMG_4812.CR3", 1_240, 4_812),
|
||||
JobKind.UploadCommit => new JobDetail(JobStep.Upload, title, job.ProgressDone, job.ProgressTotal),
|
||||
JobKind.Download => new JobDetail(JobStep.Download, title, job.ProgressDone, job.ProgressTotal),
|
||||
JobKind.Maintenance => new JobDetail(JobStep.Maintenance, "packs", Part: 3, Parts: 5, PartUnit: JobPartUnit.Step),
|
||||
_ => null,
|
||||
};
|
||||
return detail is null ? job : job with { Detail = detail };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using Chronos.App.Server;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Data.Jobs;
|
||||
using Chronos.Protocol;
|
||||
|
||||
namespace Chronos.App.DesignTime;
|
||||
|
||||
/// <summary>
|
||||
/// The sample server's jobs for the Server section's job list (owner review 5, #65), for the screenshots: empty until
|
||||
/// <see cref="Fill"/>, then a verification and a thumbnail pass running with what each does now, and a proxy pass paused.
|
||||
/// Pause, resume and cancel change the list; no event ever comes. Thread-safe; disposing it does nothing, so it can be reused.
|
||||
/// </summary>
|
||||
public sealed class SampleServerJobs : IServerJobsApi
|
||||
{
|
||||
private readonly Lock _gate = new();
|
||||
private List<JobDto> _jobs = [];
|
||||
|
||||
/// <summary>The sample's running and paused jobs.</summary>
|
||||
public void Fill()
|
||||
{
|
||||
var now = SampleData.Now;
|
||||
lock (_gate)
|
||||
{
|
||||
_jobs =
|
||||
[
|
||||
Job(JobKind.Verify, "Harbour sunset", JobState.Running, 812, 2_400, 38.5, 41, now.AddMinutes(-6),
|
||||
new JobDetail(JobStep.Verify, "Harbour sunset", 812, 2_400, 3, 41, JobPartUnit.Sequence)),
|
||||
Job(JobKind.Thumbs, "Sunrise over Superga", JobState.Running, 1_240, 3_600, 52.0, 45, now.AddMinutes(-3),
|
||||
new JobDetail(JobStep.Thumbs, "Sunrise over Superga", 1_240, 3_600, 2, 7, JobPartUnit.Sequence)),
|
||||
Job(JobKind.Proxies, "Alpine lake, winter", JobState.Paused, 300, 1_800, null, null, now.AddMinutes(-40),
|
||||
new JobDetail(JobStep.Proxies, "Alpine lake, winter", 300, 1_800, 1, 2, JobPartUnit.Sequence)),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Nothing runs on the server again.</summary>
|
||||
public void Clear()
|
||||
{
|
||||
lock (_gate) _jobs = [];
|
||||
}
|
||||
|
||||
public Task<Page<JobDto>> ListJobsAsync(string state, string? cursor, CancellationToken cancellationToken)
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
var items = _jobs.Where(j => j.State == state).ToList();
|
||||
return Task.FromResult(new Page<JobDto>(items, null, items.Count));
|
||||
}
|
||||
}
|
||||
|
||||
public Task<JobDto> GetJobAsync(Guid id, CancellationToken cancellationToken)
|
||||
{
|
||||
lock (_gate) return Task.FromResult(_jobs.Single(j => j.Id == id));
|
||||
}
|
||||
|
||||
public Task<JobDto> PauseJobAsync(Guid id, CancellationToken cancellationToken) => SetState(id, JobState.Paused);
|
||||
|
||||
public Task<JobDto> ResumeJobAsync(Guid id, CancellationToken cancellationToken) => SetState(id, JobState.Running);
|
||||
|
||||
public Task<JobDto> CancelJobAsync(Guid id, CancellationToken cancellationToken) => SetState(id, JobState.Cancelled);
|
||||
|
||||
public async IAsyncEnumerable<ServerEvent> EventsAsync([EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
{
|
||||
await Task.Delay(Timeout.Infinite, cancellationToken).ConfigureAwait(false);
|
||||
yield break;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
private Task<JobDto> SetState(Guid id, JobState state)
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
var index = _jobs.FindIndex(j => j.Id == id);
|
||||
var job = _jobs[index] with { State = JobWire.State(state) };
|
||||
if (state is JobState.Running or JobState.Paused) _jobs[index] = job;
|
||||
else _jobs.RemoveAt(index);
|
||||
return Task.FromResult(job);
|
||||
}
|
||||
}
|
||||
|
||||
private static JobDto Job(JobKind kind, string target, JobState state, long done, long total, double? rate, double? eta, DateTimeOffset started,
|
||||
JobDetail detail) =>
|
||||
new(Guid.NewGuid(), JobWire.Kind(kind), [Guid.NewGuid()], target, JobWire.State(state), JobWire.Priority(JobPriority.Background), done, total,
|
||||
rate, eta, null, null, 1, null, started, started, null, null, JobWire.Detail(detail));
|
||||
}
|
||||
@@ -44,7 +44,10 @@ public static class EditorText
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>"Render running on Studio NAS · 1,240 / 3,600 · 11.3 fps · 3 min left"; "Render waiting on Studio NAS".</summary>
|
||||
/// <summary>
|
||||
/// "Render running on Studio NAS · 1,240 / 3,600 · 11.3 fps · 3 min left"; with what the job does now in place of the
|
||||
/// counter ("… · Encoding frame 1,240 of 3,600 · 11.3 fps · 3 min left", owner review 5, #65); "Render waiting on Studio NAS".
|
||||
/// </summary>
|
||||
public static string ServerJobDetail(Job job, string server)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(job);
|
||||
@@ -55,7 +58,8 @@ public static class EditorText
|
||||
_ => "Tooltips.Editor.ServerJob",
|
||||
};
|
||||
var parts = new List<string> { Loc.L(key, JobText.Kind(job.Kind), server) };
|
||||
if (JobText.Counter(job.ProgressDone, job.ProgressTotal) is { Length: > 0 } counter) parts.Add(counter);
|
||||
if (job.State == JobState.Running && JobText.Status(job.Detail) is { Length: > 0 } status) parts.Add(status);
|
||||
else if (JobText.Counter(job.Kind, job.ProgressDone, job.ProgressTotal) is { Length: > 0 } counter) parts.Add(counter);
|
||||
if (JobText.Speed(job.Kind, job.ItemsPerSecond) is { Length: > 0 } speed) parts.Add(speed);
|
||||
if (job.Eta is { } eta) parts.Add(Loc.L("Editor.ServerJob.Left", Formatting.Duration(eta)));
|
||||
return string.Join(Separator, parts);
|
||||
|
||||
@@ -180,6 +180,8 @@ internal sealed class ServerJobs : IAsyncDisposable
|
||||
ProgressTotal = progress.Total,
|
||||
ItemsPerSecond = progress.ItemsPerSecond,
|
||||
Eta = JobEta.FromSeconds(progress.EtaSeconds),
|
||||
// What it does now (owner review 5, #65); an older server sends none, and the last one stays.
|
||||
Detail = JobWire.FromDto(progress.Detail) ?? job.Detail,
|
||||
});
|
||||
break;
|
||||
case JobProgressEvent:
|
||||
|
||||
@@ -32,6 +32,12 @@ public sealed class JobEntry(Job job)
|
||||
public TimeSpan? Eta => Live?.Eta ?? Job.Eta;
|
||||
public string? Message => Live?.Message;
|
||||
|
||||
/// <summary>
|
||||
/// What the job does now (owner review 5, #65): the live detail while it runs, else the one stored with its last saved
|
||||
/// progress (where a paused or failed job stopped); null when its handler reports none.
|
||||
/// </summary>
|
||||
public JobDetail? Detail => Live?.Detail ?? Job.Detail;
|
||||
|
||||
/// <summary>0…1, or null while the total is unknown.</summary>
|
||||
public double? Fraction => Total > 0 ? Math.Clamp((double)Done / Total, 0, 1) : null;
|
||||
|
||||
|
||||
@@ -36,6 +36,17 @@ public sealed class JobRowViewModel : ObservableObject
|
||||
|
||||
public string Target => _entry.Job.TargetLabel ?? string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// What a running job does now, or where a paused or failed job stopped (owner review 5, #65), under the target; empty
|
||||
/// otherwise. Not announced: a screen reader hears state changes only (DECISIONS row 158).
|
||||
/// </summary>
|
||||
public string StatusText => JobText.RowStatus(_entry);
|
||||
|
||||
public bool HasStatus => StatusText.Length > 0;
|
||||
|
||||
/// <summary>The status line whole, then the speed and time left of a running job.</summary>
|
||||
public string StatusToolTip => JobText.RowStatusToolTip(_entry);
|
||||
|
||||
/// <summary>A schedule queued the job (owner review 2, R10): the row shows a "Scheduled" pill.</summary>
|
||||
public bool IsScheduled => _entry.Job.ScheduleId is not null;
|
||||
|
||||
@@ -136,6 +147,9 @@ public sealed class JobRowViewModel : ObservableObject
|
||||
return;
|
||||
}
|
||||
OnPropertyChanged(nameof(Progress));
|
||||
OnPropertyChanged(nameof(StatusText));
|
||||
OnPropertyChanged(nameof(HasStatus));
|
||||
OnPropertyChanged(nameof(StatusToolTip));
|
||||
OnPropertyChanged(nameof(PercentText));
|
||||
OnPropertyChanged(nameof(SpeedText));
|
||||
OnPropertyChanged(nameof(LeftText));
|
||||
|
||||
@@ -29,6 +29,141 @@ public static class JobText
|
||||
public static string Counter(long done, long total) =>
|
||||
total > 0 ? Loc.L("Jobs.Counter", Formatting.Count(done), Formatting.Count(total)) : string.Empty;
|
||||
|
||||
/// <summary>"1,240 / 3,600", or "52 GB / 1.1 TB" for a job that counts bytes; empty while the total is unknown.</summary>
|
||||
public static string Counter(JobKind kind, long done, long total) => total <= 0 ? string.Empty
|
||||
: CountsBytes(kind) ? Loc.L("Jobs.Counter", Formatting.Bytes(done), Formatting.Bytes(total))
|
||||
: Counter(done, total);
|
||||
|
||||
/// <summary>The longest status line the job bar shows (<see cref="Bar"/>); the item goes first, the full line is in the Jobs table.</summary>
|
||||
public const int BarStatusLength = 60;
|
||||
|
||||
/// <summary>
|
||||
/// What a job does now (owner review 5, #65), from its <paramref name="detail"/>: the step ("Verifying photo 812 of 2,400"),
|
||||
/// the item ("Harbour sunset", a folder kept left to right) and the part ("sequence 3 of 41"), each left out when empty;
|
||||
/// a clean-up or maintenance sub-step names itself in place of the step. A step this build does not know (a newer server)
|
||||
/// shows its counts only. Empty for no detail.
|
||||
/// </summary>
|
||||
public static string Status(JobDetail? detail) => Status(detail, int.MaxValue);
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="Status(JobDetail?)"/> in at most <paramref name="maxLength"/> characters: a longer line drops the item
|
||||
/// first, then is cut with an ellipsis.
|
||||
/// </summary>
|
||||
public static string Status(JobDetail? detail, int maxLength)
|
||||
{
|
||||
if (detail is null) return string.Empty;
|
||||
var (step, consumed) = StepPhrase(detail);
|
||||
var item = consumed ? null : ItemText(detail.Item);
|
||||
var part = PartPhrase(detail);
|
||||
var full = JoinParts(step, item, part);
|
||||
if (full.Length <= maxLength) return full;
|
||||
if (item is not null && JoinParts(step, null, part) is { Length: > 0 } shorter) full = shorter;
|
||||
return Cut(full, maxLength);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The status line of a Jobs row: what a running job does now; "Stopped at …" with where a paused or failed job stopped;
|
||||
/// empty for queued and finished jobs, and for a job whose handler reports no detail.
|
||||
/// </summary>
|
||||
public static string RowStatus(JobEntry entry)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(entry);
|
||||
return entry.State switch
|
||||
{
|
||||
JobState.Running => Status(entry.Detail),
|
||||
JobState.Paused or JobState.Failed when Status(entry.Job.Detail) is { Length: > 0 } status => Loc.L("Jobs.Detail.StoppedAt", status),
|
||||
_ => string.Empty,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>The tooltip of a row's status line: the line whole, then the speed and the time left while the job runs.</summary>
|
||||
public static string RowStatusToolTip(JobEntry entry)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(entry);
|
||||
var parts = new List<string>(3);
|
||||
if (RowStatus(entry) is { Length: > 0 } status) parts.Add(status);
|
||||
if (entry.State == JobState.Running)
|
||||
{
|
||||
if (Speed(entry.Job.Kind, entry.ItemsPerSecond) is { Length: > 0 } speed) parts.Add(speed);
|
||||
if (entry.Eta is { } eta) parts.Add(Loc.L("Jobs.Bar.Left", Formatting.Duration(eta)));
|
||||
}
|
||||
return string.Join(Loc.Separator, parts);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The step phrase, counted when the item is ("Verifying photo 812 of 2,400"), and whether it took the item's place (the
|
||||
/// named sub-step of a clean-up or maintenance).
|
||||
/// </summary>
|
||||
private static (string? Phrase, bool ConsumedItem) StepPhrase(JobDetail detail)
|
||||
{
|
||||
var counted = detail.ItemTotal > 0;
|
||||
var done = Formatting.Count(Math.Clamp(detail.ItemDone, 0, detail.ItemTotal));
|
||||
var total = Formatting.Count(detail.ItemTotal);
|
||||
var counts = counted ? Loc.L("Jobs.Detail.Count", done, total) : null;
|
||||
// A clean-up step ("job-history") and a maintenance step ("packs") name themselves.
|
||||
var named = detail.Step switch
|
||||
{
|
||||
JobStep.Cleanup => Known("Jobs.Schedule.Step." + Pascal(detail.Item)),
|
||||
JobStep.Maintenance => Known("Jobs.Maintenance.Step." + Pascal(detail.Item)),
|
||||
_ => null,
|
||||
};
|
||||
if (named is not null) return (JoinParts(Loc.L(named), counts, null), true);
|
||||
if (detail.Step == JobStep.None) return (counts, false);
|
||||
var key = "Jobs.Step." + detail.Step;
|
||||
// The item of a clean-up or maintenance step is a key, not data: one this build does not know is never shown.
|
||||
if (detail.Step is JobStep.Cleanup or JobStep.Maintenance) return (JoinParts(Known(key) is { } step ? Loc.L(step) : null, counts, null), true);
|
||||
if (counted && Known(key + ".Count") is { } countKey) return (Loc.L(countKey, done, total), false);
|
||||
if (Known(key) is null) return (counts, false);
|
||||
return (JoinParts(Loc.L(key), counts, null), false);
|
||||
}
|
||||
|
||||
/// <summary>"sequence 3 of 41" when the job has more than one part; null otherwise.</summary>
|
||||
private static string? PartPhrase(JobDetail detail)
|
||||
{
|
||||
if (detail.Parts <= 1) return null;
|
||||
var part = Formatting.Count(Math.Clamp(detail.Part, 0, detail.Parts));
|
||||
var parts = Formatting.Count(detail.Parts);
|
||||
return detail.PartUnit != JobPartUnit.None && Known("Jobs.Part." + detail.PartUnit) is { } key
|
||||
? Loc.L(key, part, parts)
|
||||
: Loc.L("Jobs.Detail.Count", part, parts);
|
||||
}
|
||||
|
||||
/// <summary>The item as data: a folder or a path kept left to right inside right-to-left text (DECISIONS row 218).</summary>
|
||||
private static string? ItemText(string? item)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(item)) return null;
|
||||
return item.Contains('/') || item.Contains('\\') ? Formatting.LeftToRight(item) : item;
|
||||
}
|
||||
|
||||
/// <summary>"job-history" → "JobHistory"; null for a key that is not one (data from a newer peer).</summary>
|
||||
private static string? Pascal(string? key)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key) || key.Length > 40 || !key.All(c => char.IsAsciiLetterOrDigit(c) || c is '-' or '_')) return null;
|
||||
return string.Concat(key.Split('-', '_', StringSplitOptions.RemoveEmptyEntries).Select(p => char.ToUpperInvariant(p[0]) + p[1..]));
|
||||
}
|
||||
|
||||
/// <summary>The key when the catalog has it (the step, unit or sub-step of a newer peer may have none); null otherwise.</summary>
|
||||
private static string? Known(string? key) => key is not null && !key.EndsWith('.') && Loc.Get(key, Loc.Culture) is not null ? key : null;
|
||||
|
||||
private static string JoinParts(string? a, string? b, string? c)
|
||||
{
|
||||
var pieces = new List<string>(3);
|
||||
if (!string.IsNullOrEmpty(a)) pieces.Add(a);
|
||||
if (!string.IsNullOrEmpty(b)) pieces.Add(b);
|
||||
if (!string.IsNullOrEmpty(c)) pieces.Add(c);
|
||||
return string.Join(Loc.Separator, pieces);
|
||||
}
|
||||
|
||||
/// <summary>Cuts <paramref name="text"/> to <paramref name="max"/> characters with an ellipsis, closing a left-to-right island it cut into.</summary>
|
||||
private static string Cut(string text, int max)
|
||||
{
|
||||
if (text.Length <= max) return text;
|
||||
var length = Math.Max(1, max - 1);
|
||||
if (char.IsHighSurrogate(text[length - 1])) length--;
|
||||
var cut = text[..length] + "…";
|
||||
return cut.Count(c => c == '') > cut.Count(c => c == '') ? cut + "" : cut;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The "Left" column: time left while running, "after n" while queued, the finish time of the history.
|
||||
/// </summary>
|
||||
@@ -71,13 +206,17 @@ public static class JobText
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Job bar line (DESIGN §4): "Render · Harbour sunset · 2,232 / 3,600 · 11.3 fps · 2 min left".
|
||||
/// Job bar line (DESIGN §4): "Render · Harbour sunset · 2,232 / 3,600 · 11.3 fps · 2 min left"; with a detail, what the
|
||||
/// job does now in place of the counter ("Scan · Archive 2024 · Indexing photo 1,240 of 3,600 · folder 12 of 340 · 41/s ·
|
||||
/// 3 min left", at most <see cref="BarStatusLength"/> characters of it); a job that counts bytes shows sizes.
|
||||
/// </summary>
|
||||
public static string Bar(JobEntry entry)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(entry);
|
||||
var parts = new List<string>(5) { Kind(entry.Job.Kind) };
|
||||
if (!string.IsNullOrWhiteSpace(entry.Job.TargetLabel)) parts.Add(entry.Job.TargetLabel!);
|
||||
if (Counter(entry.Done, entry.Total) is { Length: > 0 } counter) parts.Add(counter);
|
||||
if (Status(entry.Detail, BarStatusLength) is { Length: > 0 } status) parts.Add(status);
|
||||
else if (Counter(entry.Job.Kind, entry.Done, entry.Total) is { Length: > 0 } counter) parts.Add(counter);
|
||||
if (Speed(entry.Job.Kind, entry.ItemsPerSecond) is { Length: > 0 } speed) parts.Add(speed);
|
||||
if (entry.Eta is { } eta) parts.Add(Loc.L("Jobs.Bar.Left", Formatting.Duration(eta)));
|
||||
return string.Join(Loc.Separator, parts);
|
||||
|
||||
@@ -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,9 +692,33 @@ 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>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.
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -42,9 +42,10 @@
|
||||
</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: 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="*" />
|
||||
</Grid.RowDefinitions>
|
||||
@@ -166,8 +167,11 @@
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- The server's running and paused jobs, live, while there are any (owner review 5, #65). -->
|
||||
<srv:ServerJobsView Grid.Row="1" 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="2" 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,19 @@ 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));
|
||||
}
|
||||
|
||||
/// <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;
|
||||
|
||||
public ShellViewModel Shell { get; }
|
||||
|
||||
private ServerSession Session => _session ?? Shell.Services.Server;
|
||||
@@ -212,6 +221,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 +232,7 @@ public sealed class ServerViewModel : SectionViewModel
|
||||
if (_session is not null) _session.PropertyChanged -= OnSessionChanged;
|
||||
Shell.Settings.Encoders.CollectionChanged -= OnEncodersChanged;
|
||||
Sync.Dispose();
|
||||
Jobs.Dispose();
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
@@ -278,6 +289,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>
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
using Chronos.Protocol;
|
||||
using Chronos.Protocol.Client;
|
||||
|
||||
namespace Chronos.App.Server;
|
||||
|
||||
/// <summary>
|
||||
/// What the Server section's job list needs from the signed-in server (owner review 5, #65): its jobs by state, one job,
|
||||
/// pause, resume and cancel, and its events (<see cref="JobProgressEvent"/>, <see cref="JobStateEvent"/>). Owns its connection.
|
||||
/// </summary>
|
||||
public interface IServerJobsApi : IDisposable
|
||||
{
|
||||
/// <summary>A page of the server's jobs in <paramref name="state"/> (a wire name: running, paused…), newest first.</summary>
|
||||
Task<Page<JobDto>> ListJobsAsync(string state, string? cursor, CancellationToken cancellationToken);
|
||||
|
||||
Task<JobDto> GetJobAsync(Guid id, CancellationToken cancellationToken);
|
||||
|
||||
Task<JobDto> PauseJobAsync(Guid id, CancellationToken cancellationToken);
|
||||
|
||||
Task<JobDto> ResumeJobAsync(Guid id, CancellationToken cancellationToken);
|
||||
|
||||
Task<JobDto> CancelJobAsync(Guid id, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>Server events until cancelled or the socket closes.</summary>
|
||||
IAsyncEnumerable<ServerEvent> EventsAsync(CancellationToken cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary><see cref="IServerJobsApi"/> over a signed-in <see cref="ChronosClient"/>, which it owns.</summary>
|
||||
public sealed class ChronosServerJobsApi(ChronosClient client) : IServerJobsApi
|
||||
{
|
||||
public Task<Page<JobDto>> ListJobsAsync(string state, string? cursor, CancellationToken cancellationToken) =>
|
||||
client.ListJobsAsync(state, null, cursor, cancellationToken);
|
||||
|
||||
public Task<JobDto> GetJobAsync(Guid id, CancellationToken cancellationToken) => client.GetJobAsync(id, cancellationToken);
|
||||
|
||||
public Task<JobDto> PauseJobAsync(Guid id, CancellationToken cancellationToken) => client.PauseJobAsync(id, cancellationToken);
|
||||
|
||||
public Task<JobDto> ResumeJobAsync(Guid id, CancellationToken cancellationToken) => client.ResumeJobAsync(id, cancellationToken);
|
||||
|
||||
public Task<JobDto> CancelJobAsync(Guid id, CancellationToken cancellationToken) => client.CancelJobAsync(id, cancellationToken);
|
||||
|
||||
public IAsyncEnumerable<ServerEvent> EventsAsync(CancellationToken cancellationToken) => client.EventsAsync(cancellationToken);
|
||||
|
||||
public void Dispose() => client.Dispose();
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
<UserControl x:Class="Chronos.App.Server.ServerJobsView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ui="clr-namespace:Chronos.Ui.Controls;assembly=Chronos.Ui"
|
||||
xmlns:l="clr-namespace:Chronos.Ui.Localization;assembly=Chronos.Ui"
|
||||
xmlns:infra="clr-namespace:Chronos.App.Infrastructure"
|
||||
xmlns:j="clr-namespace:Chronos.App.Jobs"
|
||||
xmlns:srv="clr-namespace:Chronos.App.Server">
|
||||
<UserControl.Resources>
|
||||
<Style x:Key="Text.Muted" TargetType="TextBlock" BasedOn="{StaticResource Text.Cell}">
|
||||
<Setter Property="Foreground" Value="{DynamicResource Brush.TextMuted}" />
|
||||
</Style>
|
||||
<!-- Numbers stay right-aligned in both reading directions; speeds and times left read in the language's direction (as on Jobs). -->
|
||||
<Style x:Key="Text.MutedNumber" TargetType="TextBlock" BasedOn="{StaticResource Text.Muted}">
|
||||
<Setter Property="TextAlignment" Value="Right" />
|
||||
<Setter Property="FlowDirection" Value="LeftToRight" />
|
||||
</Style>
|
||||
<Style x:Key="Text.MutedEnd" TargetType="TextBlock" BasedOn="{StaticResource Text.Muted}">
|
||||
<Setter Property="TextAlignment" Value="Right" />
|
||||
</Style>
|
||||
<Style x:Key="Text.HeaderEnd" TargetType="TextBlock" BasedOn="{StaticResource Text.Header}">
|
||||
<Setter Property="TextAlignment" Value="Right" />
|
||||
</Style>
|
||||
<ItemsPanelTemplate x:Key="Panel.Row">
|
||||
<StackPanel Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
<!-- A row reads as its job and state; Tab goes to its buttons. -->
|
||||
<Style x:Key="ListBoxItem.ServerJob" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.PlainRow}">
|
||||
<Setter Property="AutomationProperties.Name" Value="{Binding AccessibleName}" />
|
||||
<Setter Property="AutomationProperties.ItemStatus" Value="{Binding StateText}" />
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
|
||||
<!-- The server's running and paused jobs (owner review 5, #65): the Jobs table's columns without Where; Pause, Resume and
|
||||
Cancel only for an account that manages the archive. At most four rows show; more scroll. -->
|
||||
<Border Style="{StaticResource Border.Panel}">
|
||||
<Grid Grid.IsSharedSizeScope="True">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Text="{l:Loc Server.Jobs.Title}" ToolTip="{Binding TitleToolTip}" FontWeight="SemiBold" Margin="14,10" HorizontalAlignment="Left" />
|
||||
|
||||
<Border Grid.Row="1" BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="0,1,0,1" Padding="14,8,24,8">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="0.7*" MinWidth="90" MaxWidth="140" />
|
||||
<ColumnDefinition Width="1.6*" MinWidth="120" />
|
||||
<ColumnDefinition Width="*" MinWidth="104" MaxWidth="240" />
|
||||
<ColumnDefinition Width="90" />
|
||||
<ColumnDefinition Width="80" />
|
||||
<ColumnDefinition Width="0.7*" MinWidth="116" MaxWidth="170" />
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="ServerJobActions" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Style="{StaticResource Text.Header}" Text="{l:Loc Jobs.Column.Kind}" ToolTip="{l:Loc Jobs.Column.Kind}" />
|
||||
<TextBlock Grid.Column="1" Style="{StaticResource Text.Header}" Text="{l:Loc Jobs.Column.Target}" Margin="10,0,0,0" ToolTip="{l:Loc Jobs.Column.Target}" />
|
||||
<TextBlock Grid.Column="2" Style="{StaticResource Text.Header}" Text="{l:Loc Jobs.Column.Progress}" Margin="10,0,0,0" ToolTip="{l:Loc Jobs.Column.Progress}" />
|
||||
<TextBlock Grid.Column="3" Style="{StaticResource Text.HeaderEnd}" Text="{l:Loc Jobs.Column.Speed}" Margin="10,0,0,0" ToolTip="{l:Loc Jobs.Column.Speed}" />
|
||||
<TextBlock Grid.Column="4" Style="{StaticResource Text.HeaderEnd}" Text="{l:Loc Jobs.Column.Left}" Margin="10,0,0,0" ToolTip="{l:Loc Jobs.Column.Left}" />
|
||||
<TextBlock Grid.Column="5" Style="{StaticResource Text.Header}" Text="{l:Loc Jobs.Column.State}" Margin="10,0,0,0" ToolTip="{l:Loc Jobs.Column.State}" />
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- Rows: running first, then paused. The status line under the target is never announced; a new state is. -->
|
||||
<ListBox x:Name="JobList" Grid.Row="2" ItemsSource="{Binding Rows}" ItemContainerStyle="{StaticResource ListBoxItem.ServerJob}" MaxHeight="160"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Visible" VirtualizingPanel.ScrollUnit="Pixel"
|
||||
KeyboardNavigation.TabNavigation="Continue" AutomationProperties.Name="{l:Loc Server.Jobs.Title}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type srv:ServerJobRowViewModel}">
|
||||
<Border Height="38" Background="Transparent" Padding="14,0">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="0.7*" MinWidth="90" MaxWidth="140" />
|
||||
<ColumnDefinition Width="1.6*" MinWidth="120" />
|
||||
<ColumnDefinition Width="*" MinWidth="104" MaxWidth="240" />
|
||||
<ColumnDefinition Width="90" />
|
||||
<ColumnDefinition Width="80" />
|
||||
<ColumnDefinition Width="0.7*" MinWidth="116" MaxWidth="170" />
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="ServerJobActions" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Style="{StaticResource Text.Muted}" Text="{Binding Kind}" ToolTip="{Binding Kind}" />
|
||||
<StackPanel Grid.Column="1" Margin="10,0,0,0" VerticalAlignment="Center">
|
||||
<TextBlock Style="{StaticResource Text.Cell}" Text="{Binding Target}" ToolTip="{Binding Target}" />
|
||||
<TextBlock x:Name="Status" Style="{StaticResource Text.Muted}" Text="{Binding StatusText}" ToolTip="{Binding StatusToolTip}"
|
||||
FontSize="{StaticResource Size.Chip}" Visibility="{Binding HasStatus, Converter={StaticResource BoolToVisibility}}" />
|
||||
</StackPanel>
|
||||
<Grid Grid.Column="2" Margin="10,0,0,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="44" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ProgressBar Maximum="1" Value="{Binding Progress, Mode=OneWay}" IsIndeterminate="{Binding IsIndeterminate, Mode=OneWay}" VerticalAlignment="Center"
|
||||
AutomationProperties.Name="{Binding AccessibleName}" />
|
||||
<TextBlock Grid.Column="1" Style="{StaticResource Text.MutedNumber}" Text="{Binding PercentText}" />
|
||||
</Grid>
|
||||
<TextBlock Grid.Column="3" Style="{StaticResource Text.MutedEnd}" Text="{Binding SpeedText}" Margin="10,0,0,0" />
|
||||
<TextBlock Grid.Column="4" Style="{StaticResource Text.MutedEnd}" Text="{Binding LeftText}" Margin="10,0,0,0" />
|
||||
<ui:StatusGlyph Grid.Column="5" Kind="{Binding StateKind}" Text="{Binding StateText}" ToolTip="{Binding StateToolTip}"
|
||||
FontSize="13" VerticalAlignment="Center" Margin="10,0,0,0"
|
||||
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding StateAnnouncement}" />
|
||||
<ItemsControl Grid.Column="6" ItemsSource="{Binding Actions}" ItemsPanel="{StaticResource Panel.Row}" Focusable="False"
|
||||
VerticalAlignment="Center" Margin="10,0,0,0">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type j:JobAction}">
|
||||
<Button Style="{StaticResource Button.Row}" Content="{Binding Text}" Command="{Binding Command}" ToolTip="{Binding ToolTip}"
|
||||
AutomationProperties.Name="{Binding AccessibleName}" />
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Grid>
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Chronos.App.Server;
|
||||
|
||||
/// <summary>The Server section's list of the server's running and paused jobs (<see cref="ServerJobsViewModel"/>).</summary>
|
||||
public partial class ServerJobsView : UserControl
|
||||
{
|
||||
public ServerJobsView() => InitializeComponent();
|
||||
}
|
||||
@@ -0,0 +1,491 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Net.Http;
|
||||
using System.Text.Json;
|
||||
using Chronos.App.Infrastructure;
|
||||
using Chronos.App.Jobs;
|
||||
using Chronos.Core.Diagnostics;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Data.Jobs;
|
||||
using Chronos.Protocol;
|
||||
using Chronos.Protocol.Client;
|
||||
using Chronos.Ui.Controls;
|
||||
using Chronos.Ui.Mvvm;
|
||||
|
||||
namespace Chronos.App.Server;
|
||||
|
||||
/// <summary>
|
||||
/// Who is signed in, as the Server section's job list sees it: <see cref="Key"/> names the session (a new sign-in is another
|
||||
/// list), <see cref="CanControl"/> whether the account may pause, resume and cancel any of the server's jobs.
|
||||
/// </summary>
|
||||
public sealed record ServerJobsAccount(string Key, bool CanControl);
|
||||
|
||||
/// <summary>
|
||||
/// The jobs running or paused on the signed-in server, live (owner review 5, #65 and the owner's answer to Q2): read from the
|
||||
/// server's jobs API, then followed through its events (<see cref="JobProgressEvent"/> with what each job does now,
|
||||
/// <see cref="JobStateEvent"/>), at most four updates a second, and read again whenever the event socket comes back after a
|
||||
/// loss (with a growing delay; nothing that fails on the way ends it). Queued jobs are the admin panel's (a busy server
|
||||
/// queues thumbnails by the thousand). Pause, Resume and Cancel are offered only to an account with the right to manage
|
||||
/// the archive, which the server requires to act on a job someone else started; otherwise the list is read-only. Empty and
|
||||
/// idle while signed out or without the right to read. UI thread, except where said.
|
||||
/// </summary>
|
||||
public sealed class ServerJobsViewModel : ObservableObject, IDisposable
|
||||
{
|
||||
private static readonly TimeSpan FlushInterval = TimeSpan.FromMilliseconds(250);
|
||||
private static readonly TimeSpan MinBackoff = TimeSpan.FromSeconds(2);
|
||||
private static readonly TimeSpan MaxBackoff = TimeSpan.FromMinutes(1);
|
||||
private static readonly string[] ListedStates = [JobWire.State(JobState.Running), JobWire.State(JobState.Paused)];
|
||||
|
||||
private readonly JobListModel _model = new();
|
||||
private readonly Updates _updates = new();
|
||||
private readonly Dictionary<Guid, ServerJobRowViewModel> _rows = [];
|
||||
private readonly Func<ServerJobsAccount?> _account;
|
||||
private readonly Func<IServerJobsApi?> _connect;
|
||||
private readonly Action<string, string>? _failed;
|
||||
private readonly CoalescingThrottle _throttle;
|
||||
private Watch? _watch;
|
||||
private bool _canControl;
|
||||
private bool _disposed;
|
||||
|
||||
/// <param name="account">The signed-in account; null while signed out or without the right to read the server's jobs.</param>
|
||||
/// <param name="connect">A connection for the signed-in session; null when there is none.</param>
|
||||
/// <param name="context">Where updates are applied (the UI); null applies them on a timer thread.</param>
|
||||
/// <param name="failed">Says that an action failed: a title and the reason.</param>
|
||||
public ServerJobsViewModel(Func<ServerJobsAccount?> account, Func<IServerJobsApi?> connect, SynchronizationContext? context, Action<string, string>? failed = null)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(account);
|
||||
ArgumentNullException.ThrowIfNull(connect);
|
||||
_account = account;
|
||||
_connect = connect;
|
||||
_failed = failed;
|
||||
_throttle = new CoalescingThrottle(FlushInterval, context, Flush);
|
||||
}
|
||||
|
||||
/// <summary>The account of <paramref name="session"/>: none while signed out or without the Read right; control with ManageArchive.</summary>
|
||||
public static ServerJobsAccount? AccountOf(ServerSession session)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(session);
|
||||
if (session.User is not { } user || session.Flow.Address is not { } address || session.Flow.Token is not { } token) return null;
|
||||
var permissions = (Permissions)user.Permissions;
|
||||
if (!permissions.HasFlag(Permissions.Read)) return null;
|
||||
return new ServerJobsAccount($"{ServerAddress.Display(address)}|{user.Id}|{token}", permissions.HasFlag(Permissions.ManageArchive));
|
||||
}
|
||||
|
||||
/// <summary>A connection over <see cref="ChronosClient"/> for <paramref name="session"/>, pinned to its trusted certificates; null while signed out.</summary>
|
||||
public static IServerJobsApi? ConnectionOf(ServerSession session)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(session);
|
||||
return session.IsConnected && session.Flow is { Address: { } address, Token: { } token }
|
||||
? new ChronosServerJobsApi(new ChronosClient(address, new CertificatePinning(session.Fingerprints), $"Chronos ({Environment.MachineName})") { Token = token })
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>Raised after the listener posted an update (any thread; tests wait on it).</summary>
|
||||
internal event Action? Posted;
|
||||
|
||||
/// <summary>The running jobs first (oldest start first), then the paused ones.</summary>
|
||||
public ObservableCollection<ServerJobRowViewModel> Rows { get; } = [];
|
||||
|
||||
/// <summary>The list shows: a session is followed and the server runs or holds something.</summary>
|
||||
public bool HasRows => Rows.Count > 0;
|
||||
|
||||
/// <summary>The account may pause, resume and cancel the server's jobs; without it the list is read-only.</summary>
|
||||
public bool CanControl => _canControl;
|
||||
|
||||
/// <summary>What the list shows, and whether the account can act on it.</summary>
|
||||
public string TitleToolTip => Loc.L(_canControl ? "Tooltips.Server.Jobs" : "Tooltips.Server.Jobs.ReadOnly");
|
||||
|
||||
/// <summary>A session is being followed.</summary>
|
||||
internal bool IsWatching => _watch is not null;
|
||||
|
||||
/// <summary>Follows the signed-in session, or stops when it ended or changed (call when the session changes).</summary>
|
||||
public void Refresh()
|
||||
{
|
||||
if (_disposed) return;
|
||||
var account = _account();
|
||||
if (account?.CanControl != _canControl)
|
||||
{
|
||||
_canControl = account?.CanControl ?? false;
|
||||
foreach (var row in _rows.Values) row.Refresh();
|
||||
OnPropertyChanged(nameof(CanControl));
|
||||
OnPropertyChanged(nameof(TitleToolTip));
|
||||
}
|
||||
if (_watch?.Key == account?.Key) return;
|
||||
Stop();
|
||||
if (account is not null && _connect() is { } api)
|
||||
{
|
||||
_watch = new Watch(account.Key, api, new CancellationTokenSource());
|
||||
var watch = _watch;
|
||||
watch.Listening = Task.Run(() => ListenAsync(watch), CancellationToken.None);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Reads the server's running and paused jobs again (a picture of the list as it is now).</summary>
|
||||
public async Task ReloadAsync()
|
||||
{
|
||||
if (_watch is not { } watch) return;
|
||||
await LoadAsync(watch.Api, watch.Stopping.Token);
|
||||
Flush();
|
||||
}
|
||||
|
||||
/// <summary>Applies what the listener collected since the last flush (UI thread).</summary>
|
||||
internal void Flush()
|
||||
{
|
||||
var (reset, jobs, removed, progress) = _updates.Drain();
|
||||
if (reset is not null)
|
||||
{
|
||||
var listed = reset.Select(j => j.Id).ToHashSet();
|
||||
foreach (var entry in _model.Ordered().Where(e => !listed.Contains(e.Id)).ToList()) _model.Remove(entry.Id);
|
||||
foreach (var job in reset) _model.Apply(job);
|
||||
}
|
||||
foreach (var job in jobs)
|
||||
{
|
||||
if (IsListed(job.State)) _model.Apply(job);
|
||||
else _model.Remove(job.Id);
|
||||
}
|
||||
foreach (var id in removed) _model.Remove(id);
|
||||
foreach (var p in progress) _model.Apply(p);
|
||||
SyncRows();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_disposed) return;
|
||||
_disposed = true;
|
||||
Stop();
|
||||
_throttle.Dispose();
|
||||
}
|
||||
|
||||
private static bool IsListed(JobState state) => state is JobState.Running or JobState.Paused;
|
||||
|
||||
private void Stop()
|
||||
{
|
||||
if (Interlocked.Exchange(ref _watch, null) is not { } watch) return;
|
||||
watch.Stopping.Cancel();
|
||||
// The listener disposes its connection once it has stopped.
|
||||
_updates.Reset([]);
|
||||
Flush();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lists the jobs, then follows the events until stopped; after a loss, waits with a growing delay and lists again
|
||||
/// (events missed meanwhile are in that list). Nothing that fails on the way ends it. Disposes the connection at the end.
|
||||
/// </summary>
|
||||
private async Task ListenAsync(Watch watch)
|
||||
{
|
||||
var ct = watch.Stopping.Token;
|
||||
var failures = 0;
|
||||
try
|
||||
{
|
||||
while (!ct.IsCancellationRequested)
|
||||
{
|
||||
try
|
||||
{
|
||||
await LoadAsync(watch.Api, ct).ConfigureAwait(false);
|
||||
await foreach (var e in watch.Api.EventsAsync(ct).ConfigureAwait(false))
|
||||
{
|
||||
failures = 0;
|
||||
await OnEventAsync(watch.Api, e, ct).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
if (ct.IsCancellationRequested) return;
|
||||
Log.Info("server", $"Jobs of the server lost: {ex.Message}");
|
||||
}
|
||||
var delay = Math.Min(MaxBackoff.Ticks, MinBackoff.Ticks << Math.Min(failures++, 10));
|
||||
await Task.Delay(TimeSpan.FromTicks(delay), ct).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException) when (ct.IsCancellationRequested)
|
||||
{
|
||||
}
|
||||
finally
|
||||
{
|
||||
watch.Api.Dispose();
|
||||
watch.Stopping.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Every running and paused job of the server, all pages (any thread).</summary>
|
||||
private async Task LoadAsync(IServerJobsApi api, CancellationToken ct)
|
||||
{
|
||||
var jobs = new List<Job>();
|
||||
foreach (var state in ListedStates)
|
||||
{
|
||||
string? cursor = null;
|
||||
do
|
||||
{
|
||||
var page = await api.ListJobsAsync(state, cursor, ct).ConfigureAwait(false);
|
||||
jobs.AddRange(page.Items.Select(JobWire.FromDto).OfType<Job>().Where(j => IsListed(j.State)));
|
||||
cursor = page.NextCursor;
|
||||
}
|
||||
while (cursor is not null);
|
||||
}
|
||||
_updates.Reset(jobs);
|
||||
Signal();
|
||||
}
|
||||
|
||||
private async Task OnEventAsync(IServerJobsApi api, ServerEvent e, CancellationToken ct)
|
||||
{
|
||||
switch (e)
|
||||
{
|
||||
case JobProgressEvent p:
|
||||
// Kind and target come from the listed job; what matters here is the count, the pace and the detail.
|
||||
_updates.Post(new JobProgressInfo(p.JobId, default, null, p.Done, p.Total, p.ItemsPerSecond, JobEta.FromSeconds(p.EtaSeconds), null,
|
||||
JobWire.FromDto(p.Detail)));
|
||||
Signal();
|
||||
break;
|
||||
case JobStateEvent s when JobWire.TryParseState(s.State, out var state) && IsListed(state):
|
||||
await FetchAsync(api, s.JobId, ct).ConfigureAwait(false);
|
||||
break;
|
||||
case JobStateEvent s:
|
||||
// Queued again, finished or of a state this build does not know: it leaves the list.
|
||||
_updates.Remove(s.JobId);
|
||||
Signal();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task FetchAsync(IServerJobsApi api, Guid jobId, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (JobWire.FromDto(await api.GetJobAsync(jobId, ct).ConfigureAwait(false)) is { } job) _updates.Post(job);
|
||||
else _updates.Remove(jobId);
|
||||
Signal();
|
||||
}
|
||||
catch (Exception ex) when (ex is ChronosApiException or HttpRequestException or JsonException
|
||||
|| (ex is OperationCanceledException && !ct.IsCancellationRequested))
|
||||
{
|
||||
Log.Info("server", $"Job {jobId} of the server could not be read: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void Signal()
|
||||
{
|
||||
_throttle.Signal();
|
||||
Posted?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>Pauses, resumes or cancels a job on the server; what the server answers shows at once (UI thread).</summary>
|
||||
internal async Task ActAsync(Guid jobId, Func<IServerJobsApi, Guid, CancellationToken, Task<JobDto>> action)
|
||||
{
|
||||
if (_watch is not { } watch || !_canControl) return;
|
||||
try
|
||||
{
|
||||
var dto = await action(watch.Api, jobId, watch.Stopping.Token);
|
||||
if (JobWire.FromDto(dto) is { } job) _updates.Post(job);
|
||||
else _updates.Remove(jobId);
|
||||
Flush();
|
||||
}
|
||||
catch (Exception ex) when (ex is ChronosApiException or HttpRequestException or JsonException or OperationCanceledException or ObjectDisposedException)
|
||||
{
|
||||
if (watch.Stopping.IsCancellationRequested) return;
|
||||
Log.Info("server", $"Job {jobId} of the server not changed: {ex.Message}");
|
||||
// The server words its refusal in this PC's language (Accept-Language); anything else is a lost connection.
|
||||
_failed?.Invoke(Loc.L("Server.Jobs.NotChanged"),
|
||||
ex is ChronosApiException { Error.Message: { Length: > 0 } reason } ? reason : Loc.L("Server.Error.Unreachable"));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Brings <see cref="Rows"/> to the model's order with moves.</summary>
|
||||
private void SyncRows()
|
||||
{
|
||||
var ordered = _model.Ordered();
|
||||
var wanted = ordered.Select(e => e.Id).ToHashSet();
|
||||
for (var i = Rows.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (wanted.Contains(Rows[i].Id)) continue;
|
||||
_rows.Remove(Rows[i].Id);
|
||||
Rows.RemoveAt(i);
|
||||
}
|
||||
for (var i = 0; i < ordered.Count; i++)
|
||||
{
|
||||
var entry = ordered[i];
|
||||
if (!_rows.TryGetValue(entry.Id, out var row))
|
||||
{
|
||||
row = new ServerJobRowViewModel(entry, this);
|
||||
_rows[entry.Id] = row;
|
||||
}
|
||||
else
|
||||
{
|
||||
row.Update(entry);
|
||||
}
|
||||
if (i < Rows.Count && ReferenceEquals(Rows[i], row)) continue;
|
||||
var existing = Rows.IndexOf(row);
|
||||
if (existing >= 0) Rows.Move(existing, i);
|
||||
else Rows.Insert(i, row);
|
||||
}
|
||||
OnPropertyChanged(nameof(HasRows));
|
||||
}
|
||||
|
||||
/// <summary>The session followed: its key, its connection and what stops its listener.</summary>
|
||||
private sealed class Watch(string key, IServerJobsApi api, CancellationTokenSource stopping)
|
||||
{
|
||||
public string Key { get; } = key;
|
||||
public IServerJobsApi Api { get; } = api;
|
||||
public CancellationTokenSource Stopping { get; } = stopping;
|
||||
public Task? Listening { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// What the listener collected for the next flush (thread-safe): a new list, which drops everything collected before it;
|
||||
/// then per job its newest snapshot or its removal, and its newest progress.
|
||||
/// </summary>
|
||||
private sealed class Updates
|
||||
{
|
||||
private readonly Lock _gate = new();
|
||||
private IReadOnlyList<Job>? _reset;
|
||||
private Dictionary<Guid, Job> _jobs = [];
|
||||
private HashSet<Guid> _removed = [];
|
||||
private Dictionary<Guid, JobProgressInfo> _progress = [];
|
||||
|
||||
public void Reset(IReadOnlyList<Job> jobs)
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
_reset = jobs;
|
||||
_jobs = [];
|
||||
_removed = [];
|
||||
_progress = [];
|
||||
}
|
||||
}
|
||||
|
||||
public void Post(Job job)
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
_jobs[job.Id] = job;
|
||||
_removed.Remove(job.Id);
|
||||
_progress.Remove(job.Id);
|
||||
}
|
||||
}
|
||||
|
||||
public void Remove(Guid id)
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
_jobs.Remove(id);
|
||||
_progress.Remove(id);
|
||||
_removed.Add(id);
|
||||
}
|
||||
}
|
||||
|
||||
public void Post(JobProgressInfo progress)
|
||||
{
|
||||
lock (_gate) _progress[progress.JobId] = progress;
|
||||
}
|
||||
|
||||
public (IReadOnlyList<Job>? Reset, IReadOnlyCollection<Job> Jobs, IReadOnlyCollection<Guid> Removed, IReadOnlyCollection<JobProgressInfo> Progress) Drain()
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
var drained = (_reset, (IReadOnlyCollection<Job>)_jobs.Values, (IReadOnlyCollection<Guid>)_removed, (IReadOnlyCollection<JobProgressInfo>)_progress.Values);
|
||||
_reset = null;
|
||||
_jobs = [];
|
||||
_removed = [];
|
||||
_progress = [];
|
||||
return drained;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// One job of the server as the Server section lists it: kind, target with what it does now (or where a paused one stopped),
|
||||
/// progress, speed, time left, state, and Pause / Resume / Cancel when the account may.
|
||||
/// </summary>
|
||||
public sealed class ServerJobRowViewModel : ObservableObject
|
||||
{
|
||||
private readonly ServerJobsViewModel _owner;
|
||||
private JobEntry _entry;
|
||||
|
||||
internal ServerJobRowViewModel(JobEntry entry, ServerJobsViewModel owner)
|
||||
{
|
||||
_entry = entry;
|
||||
_owner = owner;
|
||||
}
|
||||
|
||||
public Guid Id => _entry.Id;
|
||||
|
||||
public JobEntry Entry => _entry;
|
||||
|
||||
public string Kind => JobText.Kind(_entry.Job.Kind);
|
||||
|
||||
public string Target => _entry.Job.TargetLabel ?? string.Empty;
|
||||
|
||||
/// <summary>"Verify · Harbour sunset": the row's name for screen readers.</summary>
|
||||
public string AccessibleName => JobText.Name(_entry.Job);
|
||||
|
||||
/// <summary>What it does now ("Verifying photo 812 of 2,400 · Harbour sunset · sequence 3 of 41"), or "Stopped at …".</summary>
|
||||
public string StatusText => JobText.RowStatus(_entry);
|
||||
|
||||
public bool HasStatus => StatusText.Length > 0;
|
||||
|
||||
public string StatusToolTip => JobText.RowStatusToolTip(_entry);
|
||||
|
||||
public double Progress => _entry.Fraction ?? 0;
|
||||
|
||||
public bool IsIndeterminate => _entry.State == JobState.Running && _entry.Fraction is null;
|
||||
|
||||
public string PercentText => _entry.Fraction is { } f ? Formatting.Percent(f) : "—";
|
||||
|
||||
public string SpeedText => _entry.State == JobState.Running ? Blank(JobText.Speed(_entry.Job.Kind, _entry.ItemsPerSecond)) : "—";
|
||||
|
||||
public string LeftText => Blank(JobText.Left(_entry, 0));
|
||||
|
||||
public string StateText => JobText.State(_entry);
|
||||
|
||||
public StatusKind StateKind => _entry.State == JobState.Paused ? StatusKind.Paused : StatusKind.Running;
|
||||
|
||||
public string StateToolTip => string.Join(Loc.Separator, StateText, Loc.L("Tooltips.Jobs.State." + _entry.State));
|
||||
|
||||
/// <summary>"Verify · Harbour sunset: running": what a screen reader announces when the state changes (not progress).</summary>
|
||||
public string StateAnnouncement => Loc.L("Jobs.Row.State", AccessibleName, StateText);
|
||||
|
||||
/// <summary>Pause and Cancel while it runs, Resume and Cancel while paused; none for a read-only account.</summary>
|
||||
public IReadOnlyList<JobAction> Actions
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_owner.CanControl) return [];
|
||||
var id = _entry.Id;
|
||||
return _entry.State == JobState.Paused
|
||||
? [Action("Jobs.Action.Resume", "Tooltips.Jobs.Resume", (api, job, ct) => api.ResumeJobAsync(job, ct)),
|
||||
Action("Jobs.Action.Cancel", "Tooltips.Jobs.Cancel", (api, job, ct) => api.CancelJobAsync(job, ct))]
|
||||
: [Action("Jobs.Action.Pause", "Tooltips.Jobs.Pause", (api, job, ct) => api.PauseJobAsync(job, ct)),
|
||||
Action("Jobs.Action.Cancel", "Tooltips.Jobs.Cancel", (api, job, ct) => api.CancelJobAsync(job, ct))];
|
||||
|
||||
JobAction Action(string textKey, string toolTipKey, Func<IServerJobsApi, Guid, CancellationToken, Task<JobDto>> run)
|
||||
{
|
||||
var text = Loc.L(textKey);
|
||||
return new JobAction(text, Loc.L(toolTipKey), Loc.L("Jobs.ActionFor", text, AccessibleName),
|
||||
new AsyncRelayCommand(() => _owner.ActAsync(id, run)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void Update(JobEntry entry)
|
||||
{
|
||||
var stateChanged = entry.State != _entry.State;
|
||||
_entry = entry;
|
||||
if (stateChanged)
|
||||
{
|
||||
OnAllPropertiesChanged();
|
||||
return;
|
||||
}
|
||||
OnPropertyChanged(nameof(StatusText));
|
||||
OnPropertyChanged(nameof(HasStatus));
|
||||
OnPropertyChanged(nameof(StatusToolTip));
|
||||
OnPropertyChanged(nameof(Progress));
|
||||
OnPropertyChanged(nameof(IsIndeterminate));
|
||||
OnPropertyChanged(nameof(PercentText));
|
||||
OnPropertyChanged(nameof(SpeedText));
|
||||
OnPropertyChanged(nameof(LeftText));
|
||||
}
|
||||
|
||||
internal void Refresh() => OnAllPropertiesChanged();
|
||||
|
||||
private static string Blank(string text) => text.Length == 0 ? "—" : text;
|
||||
}
|
||||
@@ -2,6 +2,7 @@ using System.Globalization;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
using Chronos.App.Infrastructure;
|
||||
using Chronos.App.Jobs;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Data.Projects;
|
||||
@@ -143,8 +144,10 @@ public static class SyncText
|
||||
{
|
||||
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")),
|
||||
// What the transfer does now (owner review 5, #65: "Uploading photo 812 of 2,400") follows in the tooltip.
|
||||
_ => (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")),
|
||||
Join([Loc.L(upload ? "Tooltips.Server.Sync.State.Uploading" : "Tooltips.Server.Sync.State.Downloading"),
|
||||
.. JobText.Status(job.Detail) is { Length: > 0 } status ? [status] : Array.Empty<string>()])),
|
||||
};
|
||||
}
|
||||
if (entry.Link?.Error is { } error) return (StatusKind.Warning, Loc.L("Server.Sync.State.Failed"), Loc.L("Tooltips.Server.Sync.State.Failed", error));
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
|
||||
<!-- Job bar (DESIGN §4): current job, progress, time left, pause; "Ready" when idle, hidden when idle in the editor.
|
||||
Screen readers hear which job starts and when the queue empties, not its progress ticks. -->
|
||||
<ui:JobBar x:Name="JobBar" Text="{Binding JobText}" Progress="{Binding JobProgress}" IsActive="{Binding IsJobActive}" IsIndeterminate="{Binding IsJobIndeterminate}"
|
||||
<ui:JobBar x:Name="JobBar" Text="{Binding JobText}" ToolTip="{Binding JobText}" Progress="{Binding JobProgress}" IsActive="{Binding IsJobActive}" IsIndeterminate="{Binding IsJobIndeterminate}"
|
||||
StopCommand="{Binding StopJobCommand}" StopToolTip="{l:Loc Tooltips.Shell.PauseJob}" StopName="{l:Loc Shell.JobBar.Pause}" ActionGlyph="{StaticResource Icon.Pause}"
|
||||
Visibility="{Binding IsJobBarVisible, Converter={StaticResource BoolToVisibility}}"
|
||||
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding JobAnnouncement}" />
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Chronos.App.Shell;
|
||||
/// <summary>
|
||||
/// <c>Chronos.exe --capture <dir></c>: renders every client screen at 1440×900 in the dark and light themes to
|
||||
/// <c><screen>-<theme>.png</c> from <see cref="SampleData"/> (first run on an empty index, then a populated
|
||||
/// one, then the Videos section, then the sync table with transfers, a conflict and its confirmation, then the sequence editor on an archive
|
||||
/// one, then the Videos section, then the sync table with transfers, a conflict and its confirmation, then the server's jobs, then the sequence editor on an archive
|
||||
/// sequence and on a server sequence with proxies, its server job and a read-only account), plus the Library, the
|
||||
/// editor's Exposure tab and the import plan in Arabic (<c>*-rtl-dark.png</c>, right to left), for visual review,
|
||||
/// the pixel diff against <c>tests/visual/baselines</c> and phase reports (BRIEF §20.2), then exits. The pictures are
|
||||
@@ -53,6 +53,10 @@ public static class ScreenCapture
|
||||
window.ShowInTaskbar = false;
|
||||
window.Show();
|
||||
|
||||
// The Server section's job list reads the sample server's jobs, none until its own scene.
|
||||
var serverJobs = new SampleServerJobs();
|
||||
shell.Server.JobsConnection = _ => serverJobs;
|
||||
|
||||
// First run: empty index, nothing connected, the welcome dialog over the empty Library.
|
||||
await sample.OpenEmptyAsync();
|
||||
await shell.StartAsync();
|
||||
@@ -164,6 +168,19 @@ public static class ScreenCapture
|
||||
SelectSyncFilter(shell, SyncFilter.All);
|
||||
}
|
||||
|
||||
// The server's jobs running and paused above the sync table, with what each does now (owner review 5, #65); the
|
||||
// sample account is an editor, so the list is read-only.
|
||||
serverJobs.Fill();
|
||||
await shell.Server.Jobs.ReloadAsync();
|
||||
foreach (var theme in Themes)
|
||||
{
|
||||
ThemeManager.Apply(theme);
|
||||
shell.Navigate(SectionKey.Server);
|
||||
written += await SaveAsync(window, directory, "server-jobs", theme);
|
||||
}
|
||||
serverJobs.Clear();
|
||||
await shell.Server.Jobs.ReloadAsync();
|
||||
|
||||
written += await CaptureEditorAsync(window, shell, sample, directory);
|
||||
written += await CaptureRemoteEditorAsync(window, shell, sample, directory);
|
||||
Log.Info("capture", $"{written} screenshot(s) written to {Path.GetFullPath(directory)}");
|
||||
|
||||
@@ -185,6 +185,10 @@ svg.chart .label { fill: var(--text-muted); }
|
||||
.progress-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
|
||||
.progress-cell svg.bar { flex: 1 1 0; min-width: 16px; }
|
||||
.progress-cell span { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
/* A job's target with what it does now under it, inside the 52 px row (owner review 5, #65). */
|
||||
.target-cell { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
|
||||
.target-cell > span { display: block; }
|
||||
.progress-detail { font-size: 12px; line-height: 16px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
|
||||
|
||||
/* Tables: ARIA rows laid out as subgrids of one grid, so every column fits its widest cell; 52 px rows in the admin. */
|
||||
.table { display: grid; column-gap: 12px; min-width: 0; }
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
// Job and node labels shared by the dashboard and the Jobs page.
|
||||
import { t, has } from "./i18n.js";
|
||||
import { escapeHtml, attr, bar } from "./ui.js";
|
||||
import { escapeHtml, attr, bar, formatNumber, formatBytes, formatDuration } from "./ui.js";
|
||||
|
||||
const CODECS = { h264: "H.264", hevc: "HEVC", av1: "AV1" };
|
||||
// The kinds whose pace is frames per second and those whose counts are bytes, as on the desktop (JobText).
|
||||
const FRAME_KINDS = new Set(["render", "proxies", "thumbs", "deep-analyse", "workspace-render"]);
|
||||
const BYTE_KINDS = new Set(["verify", "import"]);
|
||||
/** The longest status line a row shows; the whole line is its tooltip. */
|
||||
const STATUS_LENGTH = 90;
|
||||
/** Hardware encoder families as users know them, recognised in the Media Foundation encoder names. */
|
||||
const VENDORS = [[/nvidia|nvenc/i, "NVENC"], [/intel|quick ?sync|qsv/i, "QSV"], [/amd|radeon|amf/i, "AMF"]];
|
||||
|
||||
@@ -33,6 +38,99 @@ export function progressCell(job) {
|
||||
return `<div class="progress-cell">${bar(fraction)}<span class="num">${Math.floor(fraction * 100)} %</span></div>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* What a job does now (owner review 5, #65), from its detail: the step ("Verifying photo 812 of 2,400"), the item and the
|
||||
* part ("sequence 3 of 41"), each left out when empty; a clean-up or maintenance sub-step names itself in place of the
|
||||
* step; a step this panel does not know shows its counts only. Empty without a detail.
|
||||
*/
|
||||
export function statusText(detail) {
|
||||
if (!detail) return "";
|
||||
const counted = detail.itemTotal > 0;
|
||||
const done = formatNumber(Math.min(Math.max(detail.itemDone, 0), detail.itemTotal));
|
||||
const total = formatNumber(detail.itemTotal);
|
||||
const counts = counted ? t("Admin.Job.Detail.Count", done, total) : "";
|
||||
const named = detail.step === "cleanup" ? known(`Admin.Schedules.Step.${pascal(detail.item ?? "")}`)
|
||||
: detail.step === "maintenance" ? known(`Admin.Job.Maintenance.Step.${pascal(detail.item ?? "")}`) : null;
|
||||
let step;
|
||||
let item = detail.item ?? "";
|
||||
if (named) {
|
||||
step = join(t(named), counts);
|
||||
item = "";
|
||||
} else if (detail.step === "cleanup" || detail.step === "maintenance") {
|
||||
// The item of these steps is a key, not data: one this panel does not know is never shown.
|
||||
const key = `Admin.Job.Step.${pascal(detail.step)}`;
|
||||
step = join(known(key) ? t(key) : "", counts);
|
||||
item = "";
|
||||
} else if (!detail.step || detail.step === "none") {
|
||||
step = counts;
|
||||
} else {
|
||||
const key = `Admin.Job.Step.${pascal(detail.step)}`;
|
||||
step = counted && known(`${key}.Count`) ? t(`${key}.Count`, done, total) : known(key) ? join(t(key), counts) : counts;
|
||||
}
|
||||
let part = "";
|
||||
if (detail.parts > 1) {
|
||||
const unit = detail.partUnit ? known(`Admin.Job.Part.${pascal(detail.partUnit)}`) : null;
|
||||
const at = formatNumber(Math.min(Math.max(detail.part, 0), detail.parts));
|
||||
part = t(unit ?? "Admin.Job.Detail.Count", at, formatNumber(detail.parts));
|
||||
}
|
||||
return join(step, item, part);
|
||||
}
|
||||
|
||||
/** The status line of a row: what a running job does now, "Stopped at …" for a paused or failed one, empty otherwise. */
|
||||
export function rowStatus(job) {
|
||||
const status = statusText(job.detail);
|
||||
if (!status) return "";
|
||||
if (job.state === "running") return status;
|
||||
return job.state === "paused" || job.state === "failed" ? t("Admin.Job.Detail.StoppedAt", status) : "";
|
||||
}
|
||||
|
||||
/** "11.3 fps", "57 MB/s" or "41/s"; empty when unknown. */
|
||||
export function speedText(kind, rate) {
|
||||
if (!(rate > 0)) return "";
|
||||
if (BYTE_KINDS.has(kind)) return t("Admin.Job.Speed.Bytes", formatBytes(rate));
|
||||
const value = formatNumber(Math.round(rate * 10) / 10);
|
||||
return t(FRAME_KINDS.has(kind) ? "Admin.Job.Speed.Fps" : "Admin.Job.Speed.PerSecond", value);
|
||||
}
|
||||
|
||||
/** "3 min left"; empty when unknown. */
|
||||
export function leftText(seconds) {
|
||||
return seconds > 0 ? t("Admin.Job.Left", formatDuration(seconds)) : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* The target cell's content: the target, and under it the status line (muted, cut to fit; its tooltip the whole line,
|
||||
* then the speed and time left of a running job). Items are data and read in their own direction.
|
||||
*/
|
||||
export function targetCell(job) {
|
||||
const target = job.targetLabel ?? "";
|
||||
return `<span class="ellipsis" dir="auto" title="${attr(target)}">${escapeHtml(target)}</span>${statusLine(job)}`;
|
||||
}
|
||||
|
||||
/** The muted status line of a job's target cell; empty when it says nothing. */
|
||||
export function statusLine(job) {
|
||||
const status = rowStatus(job);
|
||||
if (!status) return "";
|
||||
const tip = job.state === "running" ? join(status, speedText(job.kind, job.itemsPerSecond), leftText(job.etaSeconds)) : status;
|
||||
const shown = status.length > STATUS_LENGTH ? `${status.slice(0, STATUS_LENGTH - 1)}…` : status;
|
||||
return `<span class="progress-detail" dir="auto" title="${attr(tip)}">${escapeHtml(shown)}</span>`;
|
||||
}
|
||||
|
||||
/** Redraws the status line of a row already drawn (a progress event), leaving the rest of the row as it is. */
|
||||
export function updateStatus(row, job) {
|
||||
const cell = row?.querySelector(".target-cell");
|
||||
if (!cell) return;
|
||||
cell.querySelector(".progress-detail")?.remove();
|
||||
cell.insertAdjacentHTML("beforeend", statusLine(job));
|
||||
}
|
||||
|
||||
function known(key) {
|
||||
return has(key) ? key : null;
|
||||
}
|
||||
|
||||
function join(...pieces) {
|
||||
return pieces.filter((p) => p).join(" · ");
|
||||
}
|
||||
|
||||
export function stateCell(state) {
|
||||
const glyph = { running: "◐", queued: "○", paused: "❚❚", done: "●", failed: "✕", cancelled: "○" }[state] ?? "";
|
||||
return `<span class="state ${attr(state)}"><span aria-hidden="true">${glyph}</span> ${escapeHtml(stateLabel(state))}</span>`;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Dashboard (mockup Admin.html, BRIEF §14.8): storage, archive, jobs, render nodes, charts, activity, active jobs.
|
||||
import { t, plural, applyStrings, culture } from "../i18n.js";
|
||||
import { escapeHtml, attr, formatBytes, formatNumber, formatTime, formatDuration, bar, storageTip, writeVolumeLine, columns, toast, errorText, emptyState, redraw, fitColumns, PROXY_WARNING } from "../ui.js";
|
||||
import { kindLabel, nodeLabel, progressCell, stateCell, stateLabel, encoders } from "../jobs.js";
|
||||
import { kindLabel, nodeLabel, progressCell, stateCell, stateLabel, encoders, targetCell, updateStatus } from "../jobs.js";
|
||||
import { activityText } from "../audit.js";
|
||||
|
||||
const SCAN_BUTTON = `<button class="btn small" data-scan data-i18n="Admin.Archive.Scan" data-i18n-title="Admin.Archive.Scan.Tip"></button>`;
|
||||
@@ -23,6 +23,8 @@ function archiveProblemChip(problem) {
|
||||
|
||||
export async function render(root, { api, setMeta, actions, onEvent }) {
|
||||
let timer = null;
|
||||
// The active jobs drawn, by id, so a progress event updates the bar and the status line in place.
|
||||
let activeJobs = new Map();
|
||||
const refresh = () => {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(load, 1500);
|
||||
@@ -53,6 +55,7 @@ export async function render(root, { api, setMeta, actions, onEvent }) {
|
||||
const uploads = lastThirtyDays(d.uploads);
|
||||
const totalUploads = uploads.reduce((s, u) => s + u.value, 0);
|
||||
const peak = Math.max(0, ...uploads.map((u) => u.value));
|
||||
activeJobs = new Map(d.activeJobs.map((j) => [j.id, j]));
|
||||
|
||||
root.innerHTML = `
|
||||
<div class="tiles">
|
||||
@@ -111,7 +114,7 @@ export async function render(root, { api, setMeta, actions, onEvent }) {
|
||||
<div role="rowgroup">${d.activeJobs.map((j) => `
|
||||
<div class="row" role="row" data-key="${attr(j.id)}">
|
||||
<span class="ellipsis" role="cell">${escapeHtml(kindLabel(j.kind))}</span>
|
||||
<span class="ellipsis" role="cell" dir="auto" title="${attr(j.targetLabel ?? "")}">${escapeHtml(j.targetLabel ?? "")}</span>
|
||||
<span class="target-cell" role="cell">${targetCell(j)}</span>
|
||||
<span class="col-node ellipsis" role="cell" dir="auto">${escapeHtml(nodeLabel(j, d.nodes))}</span>
|
||||
<span class="progress" role="cell">${progressCell(j)}</span><span role="cell">${stateCell(j.state)}</span>
|
||||
<span class="row-actions" role="cell"><button class="btn small" data-cancel="${attr(j.id)}" data-i18n="${j.state === "queued" ? "Admin.Jobs.Remove" : "Admin.Jobs.Cancel"}"
|
||||
@@ -145,8 +148,16 @@ export async function render(root, { api, setMeta, actions, onEvent }) {
|
||||
|
||||
onEvent((e) => {
|
||||
if (e.type === "jobProgress") {
|
||||
const cell = root.querySelector(`[data-key="${CSS.escape(e.jobId)}"] .progress`);
|
||||
if (cell) cell.innerHTML = progressCell({ progressDone: e.done, progressTotal: e.total });
|
||||
const job = activeJobs.get(e.jobId) ?? { kind: "", state: "running" };
|
||||
job.progressDone = e.done;
|
||||
job.progressTotal = e.total;
|
||||
job.itemsPerSecond = e.itemsPerSecond;
|
||||
job.etaSeconds = e.etaSeconds;
|
||||
if (e.detail) job.detail = e.detail;
|
||||
const row = root.querySelector(`[data-key="${CSS.escape(e.jobId)}"]`);
|
||||
const cell = row?.querySelector(".progress");
|
||||
if (cell) cell.innerHTML = progressCell(job);
|
||||
updateStatus(row, job);
|
||||
} else {
|
||||
refresh();
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// schedules, its system ones included (schedules.js).
|
||||
import { t, plural, applyStrings } from "../i18n.js";
|
||||
import { escapeHtml, attr, formatTime, formatDateTime, toast, errorText, confirmDialog, emptyState, redraw, fitColumns, routeParams } from "../ui.js";
|
||||
import { kindLabel, nodeLabel, progressCell, stateCell, stateLabel, encoders, logText } from "../jobs.js";
|
||||
import { kindLabel, nodeLabel, progressCell, stateCell, stateLabel, encoders, logText, targetCell, updateStatus } from "../jobs.js";
|
||||
import { renderSchedules } from "../schedules.js";
|
||||
|
||||
const TABS = ["queue", "schedules"];
|
||||
@@ -125,7 +125,7 @@ async function renderQueue(root, { api, setMeta, onEvent }, focusJob) {
|
||||
<div class="row" role="row" data-key="${attr(j.id)}">
|
||||
<span class="name-cell" role="cell"><button class="link ellipsis" data-toggle="${attr(j.id)}" aria-expanded="${expanded.has(j.id)}" aria-controls="log-${attr(j.id)}" data-i18n-title="Admin.Jobs.Log.Tip">${escapeHtml(kindLabel(j.kind))}</button>${j.scheduleId
|
||||
? `<a class="pill" href="#/jobs?tab=schedules&schedule=${attr(j.scheduleId)}" data-i18n="Admin.Jobs.Scheduled" data-i18n-title="Admin.Jobs.Scheduled.Tip"></a>` : ""}</span>
|
||||
<span class="ellipsis" role="cell" dir="auto" title="${attr(j.targetLabel ?? "")}">${escapeHtml(j.targetLabel ?? "")}</span>
|
||||
<span class="target-cell" role="cell">${targetCell(j)}</span>
|
||||
<span class="col-node ellipsis" role="cell" dir="auto">${escapeHtml(nodeLabel(j, nodes))}</span>
|
||||
<span class="progress" role="cell">${progressCell(j)}</span>
|
||||
<span role="cell">${stateCell(j.state)}</span>
|
||||
@@ -231,8 +231,14 @@ async function renderQueue(root, { api, setMeta, onEvent }, focusJob) {
|
||||
if (job) {
|
||||
job.progressDone = e.done;
|
||||
job.progressTotal = e.total;
|
||||
const cell = root.querySelector(`[data-key="${CSS.escape(e.jobId)}"] .progress`);
|
||||
job.itemsPerSecond = e.itemsPerSecond;
|
||||
job.etaSeconds = e.etaSeconds;
|
||||
// An older server sends no detail: the line keeps what the list said.
|
||||
if (e.detail) job.detail = e.detail;
|
||||
const row = root.querySelector(`[data-key="${CSS.escape(e.jobId)}"]`);
|
||||
const cell = row?.querySelector(".progress");
|
||||
if (cell) cell.innerHTML = progressCell(job);
|
||||
updateStatus(row, job);
|
||||
}
|
||||
} else if (e.type === "jobState" || e.type === "nodeState") {
|
||||
clearTimeout(timer);
|
||||
|
||||
@@ -386,6 +386,35 @@ public sealed class RemoteSequenceSourceTests(TestContext context)
|
||||
Assert.True(api.Disposed, "closing the editor closes its connection");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TheServersJobSaysWhatItDoesNow()
|
||||
{
|
||||
Loc.SetCulture(System.Globalization.CultureInfo.GetCultureInfo("en"));
|
||||
var (source, api, _) = Open();
|
||||
await using (source)
|
||||
{
|
||||
await source.LoadAsync(context.Cancellation);
|
||||
var seen = new List<Job>();
|
||||
source.JobChanged += job =>
|
||||
{
|
||||
lock (seen) seen.Add(job);
|
||||
};
|
||||
var id = Guid.CreateVersion7();
|
||||
api.Jobs[id] = api.Job(id, "render", "running");
|
||||
api.Publish(new JobStateEvent(id, "running", null));
|
||||
await WaitAsync(() => Last(seen).Id == id);
|
||||
|
||||
// Owner review 5, #65: the progress event carries the step, and an older server's event without one keeps it.
|
||||
api.Publish(new JobProgressEvent(id, 40, 300, 11.3, 20, new JobDetailDto("encode", null, 40, 300)));
|
||||
await WaitAsync(() => Last(seen).ProgressDone == 40);
|
||||
Assert.Equal(new JobDetail(JobStep.Encode, null, 40, 300), Last(seen).Detail);
|
||||
Assert.Contains("Encoding frame 40 of 300", EditorText.ServerJobDetail(Last(seen), "Studio NAS"));
|
||||
api.Publish(new JobProgressEvent(id, 41, 300, 11.3, 19));
|
||||
await WaitAsync(() => Last(seen).ProgressDone == 41);
|
||||
Assert.Equal(JobStep.Encode, Last(seen).Detail?.Step);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ASequenceGoneFromTheServerReadsAsMissing()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
using System.Globalization;
|
||||
using Chronos.App.Infrastructure;
|
||||
using Chronos.App.Jobs;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Data.Jobs;
|
||||
using Chronos.Testing;
|
||||
|
||||
namespace Chronos.App.Tests.Jobs;
|
||||
|
||||
/// <summary>The status line of a running job (owner review 5, #65): what it does now, in the job bar, the Jobs table and the tooltips.</summary>
|
||||
public sealed class JobTextTests
|
||||
{
|
||||
private static readonly DateTimeOffset T0 = new(2026, 9, 28, 10, 0, 0, TimeSpan.Zero);
|
||||
|
||||
[Test]
|
||||
public void TheStatusLineSaysStepItemAndPart()
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
var verify = new JobDetail(JobStep.Verify, "Harbour sunset", 812, 2_400, 3, 41, JobPartUnit.Sequence);
|
||||
Assert.Equal("Verifying photo 812 of 2,400 · Harbour sunset · sequence 3 of 41", JobText.Status(verify));
|
||||
// Not counted: the step word alone; a single part is not said.
|
||||
Assert.Equal("Listing folders", JobText.Status(new JobDetail(JobStep.List)));
|
||||
Assert.Equal("Encoding frame 10 of 300", JobText.Status(new JobDetail(JobStep.Encode, null, 10, 300, 1, 1, JobPartUnit.Render)));
|
||||
// A part without a unit is counted plainly.
|
||||
Assert.Equal("Analysing · Lake · 120 of 4,812", JobText.Status(new JobDetail(JobStep.Analyse, "Lake", Part: 120, Parts: 4_812)));
|
||||
Assert.Equal(string.Empty, JobText.Status(null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EveryStepAndPartHasItsWordsInEnglishAndItalian()
|
||||
{
|
||||
foreach (var culture in new[] { "en", "it" })
|
||||
{
|
||||
var c = CultureInfo.GetCultureInfo(culture);
|
||||
foreach (var step in Enum.GetValues<JobStep>().Where(s => s != JobStep.None))
|
||||
Assert.True(Loc.Get("Jobs.Step." + step, c) is not null, $"{culture} {step}");
|
||||
foreach (var unit in Enum.GetValues<JobPartUnit>().Where(u => u != JobPartUnit.None))
|
||||
Assert.True(Loc.Get("Jobs.Part." + unit, c) is not null, $"{culture} {unit}");
|
||||
foreach (var sub in new[] { "Leases", "Temp", "Packs", "Duplicates", "Vacuum" })
|
||||
Assert.True(Loc.Get("Jobs.Maintenance.Step." + sub, c) is not null, $"{culture} {sub}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void SubStepsNameThemselvesAndUnknownOnesShowCountsOnly()
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
Assert.Equal("Compacting thumbnails · step 3 of 5", JobText.Status(new JobDetail(JobStep.Maintenance, "packs", Part: 3, Parts: 5, PartUnit: JobPartUnit.Step)));
|
||||
Assert.Equal("Job history", JobText.Status(new JobDetail(JobStep.Cleanup, "job-history")));
|
||||
// A sub-step key of a newer server is never shown as text.
|
||||
Assert.Equal("Maintenance · step 6 of 6", JobText.Status(new JobDetail(JobStep.Maintenance, "re-index", Part: 6, Parts: 6, PartUnit: JobPartUnit.Step)));
|
||||
// A step this build does not know (JobStep.None from the wire) shows its counts and item only.
|
||||
Assert.Equal("4 of 10 · Lake", JobText.Status(new JobDetail(JobStep.None, "Lake", 4, 10)));
|
||||
Assert.Equal(JobStep.None, JobWire.FromDto(new Chronos.Protocol.JobDetailDto("teleport", "Lake", 4, 10))!.Step);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FoldersStayLeftToRight()
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
var status = JobText.Status(new JobDetail(JobStep.Index, "2024/2024-09-27 Harbour", 1, 2));
|
||||
Assert.Contains(Formatting.LeftToRight("2024/2024-09-27 Harbour"), status);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ALongLineDropsTheItemFirstThenIsCut()
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
var detail = new JobDetail(JobStep.Verify, new string('x', 120), 812, 2_400, 3, 41, JobPartUnit.Sequence);
|
||||
Assert.Equal("Verifying photo 812 of 2,400 · sequence 3 of 41", JobText.Status(detail, JobText.BarStatusLength));
|
||||
var cut = JobText.Status(detail, 20);
|
||||
Assert.Equal(20, cut.Length);
|
||||
Assert.True(cut.EndsWith('…'));
|
||||
// A cut folder island is closed again.
|
||||
var folder = JobText.Status(new JobDetail(JobStep.Index, "2024/" + new string('y', 80)), 30);
|
||||
Assert.Equal(folder.Count(c => c == ''), folder.Count(c => c == ''));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TheBarSaysWhatTheJobDoesNow()
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
var job = Job(JobKind.Verify, JobState.Running, "Harbour sunset") with
|
||||
{
|
||||
Detail = new JobDetail(JobStep.Verify, "Harbour sunset", 812, 2_400, 3, 41, JobPartUnit.Sequence),
|
||||
};
|
||||
// The bar keeps 60 characters of the line: the item (already the target here) goes first.
|
||||
var entry = new JobEntry(job);
|
||||
Assert.Equal("Verify · Harbour sunset · Verifying photo 812 of 2,400 · sequence 3 of 41", JobText.Bar(entry));
|
||||
|
||||
// Without a detail the counter stays, in bytes for a byte job.
|
||||
var bytes = new JobEntry(Job(JobKind.Import, JobState.Running, "Card") with { ProgressDone = 2_000_000, ProgressTotal = 8_000_000 });
|
||||
Assert.Equal($"Import · Card · {Formatting.Bytes(2_000_000)} / {Formatting.Bytes(8_000_000)}", JobText.Bar(bytes));
|
||||
Assert.Equal("3 / 9", JobText.Counter(JobKind.Scan, 3, 9));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LiveDetailWinsAndStoppedJobsSayWhere()
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
var job = Job(JobKind.Thumbs, JobState.Running, "Lake") with { Detail = new JobDetail(JobStep.Thumbs, "Lake", 1, 10) };
|
||||
var entry = new JobEntry(job)
|
||||
{
|
||||
Live = new JobProgressInfo(job.Id, job.Kind, "Lake", 5, 10, 2.5, TimeSpan.FromMinutes(2), null, new JobDetail(JobStep.Thumbs, "Lake", 5, 10)),
|
||||
};
|
||||
Assert.Equal("Thumbnail 5 of 10 · Lake", JobText.RowStatus(entry));
|
||||
Assert.Equal("Thumbnail 5 of 10 · Lake · 2.5 fps · 2 min left", JobText.RowStatusToolTip(entry));
|
||||
|
||||
var paused = new JobEntry(job with { State = JobState.Paused });
|
||||
Assert.Equal("Stopped at Thumbnail 1 of 10 · Lake", JobText.RowStatus(paused));
|
||||
Assert.Equal(string.Empty, JobText.RowStatus(new JobEntry(job with { State = JobState.Queued })));
|
||||
Assert.Equal(string.Empty, JobText.RowStatus(new JobEntry(job with { State = JobState.Done })));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RecentMaintenanceFollowsLiveProgress()
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
var verify = Job(JobKind.Verify, JobState.Running, "ChronosArchive") with { ProgressDone = 10, ProgressTotal = 100 };
|
||||
var scan = Job(JobKind.Scan, JobState.Paused, "Archive") with { Detail = new JobDetail(JobStep.Index, null, 4, 9) };
|
||||
var live = new Dictionary<Guid, JobProgressInfo>
|
||||
{
|
||||
[verify.Id] = new(verify.Id, verify.Kind, null, 71, 100, null, null, null, new JobDetail(JobStep.Verify, "Harbour sunset", 3, 9)),
|
||||
// Progress of a job that is not running is not shown.
|
||||
[scan.Id] = new(scan.Id, scan.Kind, null, 99, 100, null, null, null, new JobDetail(JobStep.Index, null, 8, 9)),
|
||||
};
|
||||
var recent = Chronos.App.Archiving.MaintenanceReports.Recent([verify, scan], 5, live);
|
||||
var running = recent.Single(r => r.JobId == verify.Id);
|
||||
Assert.Equal("71 %", running.StateText);
|
||||
Assert.Equal("Verifying photo 3 of 9 · Harbour sunset", running.Detail);
|
||||
Assert.True(running.HasDetail);
|
||||
var paused = recent.Single(r => r.JobId == scan.Id);
|
||||
Assert.Equal("Stopped at Indexing photo 4 of 9", paused.Detail);
|
||||
// Without live progress the stored snapshot speaks.
|
||||
Assert.Equal("10 %", Chronos.App.Archiving.MaintenanceReports.Recent([verify], 5).Single().StateText);
|
||||
}
|
||||
|
||||
private static Job Job(JobKind kind, JobState state, string label) => new()
|
||||
{
|
||||
Id = Guid.CreateVersion7(),
|
||||
Kind = kind,
|
||||
State = state,
|
||||
TargetLabel = label,
|
||||
Created = T0,
|
||||
Started = state == JobState.Queued ? null : T0,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>The status line in Italian. It switches the process-wide UI language, so the class is serial.</summary>
|
||||
[Serial]
|
||||
public sealed class JobTextLanguageTests
|
||||
{
|
||||
[Test]
|
||||
public void ItalianWordsTheSameLine()
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("it"));
|
||||
try
|
||||
{
|
||||
var verify = new JobDetail(JobStep.Verify, "Tramonto", 812, 2_400, 3, 41, JobPartUnit.Sequence);
|
||||
Assert.Equal($"Verifica foto 812 di {Formatting.Count(2_400)} · Tramonto · sequenza 3 di 41", JobText.Status(verify));
|
||||
Assert.Equal("Elaborazione foto 5 di 9", JobText.Status(new JobDetail(JobStep.Process, null, 5, 9)));
|
||||
Assert.Equal("Fermo a Miniatura 1 di 10", Loc.L("Jobs.Detail.StoppedAt", JobText.Status(new JobDetail(JobStep.Thumbs, null, 1, 10))));
|
||||
}
|
||||
finally
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Channels;
|
||||
using Chronos.App.Server;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Data.Jobs;
|
||||
using Chronos.Protocol;
|
||||
using Chronos.Testing;
|
||||
|
||||
namespace Chronos.App.Tests.Jobs;
|
||||
|
||||
/// <summary>The Server section's list of the server's jobs (owner review 5, #65, the owner's answer to Q2).</summary>
|
||||
public sealed class ServerJobsListTests
|
||||
{
|
||||
private static readonly DateTimeOffset T0 = new(2026, 9, 28, 10, 0, 0, TimeSpan.Zero);
|
||||
|
||||
[Test]
|
||||
public async Task AReadOnlyAccountSeesRunningAndPausedJobsWithoutActions()
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
var api = new FakeJobsApi();
|
||||
var verify = api.Add("verify", "Harbour sunset", "running", new JobDetailDto("verify", "Harbour sunset", 812, 2_400, 3, 41, "sequence"));
|
||||
api.Add("proxies", "Lake", "paused", new JobDetailDto("proxies", "Lake", 300, 1_800));
|
||||
api.Add("thumbs", "Queued one", "queued");
|
||||
using var vm = new ServerJobsViewModel(() => new ServerJobsAccount("a", CanControl: false), () => api, new IdleContext());
|
||||
|
||||
await UpdatedAsync(vm, vm.Refresh);
|
||||
Assert.True(vm.IsWatching);
|
||||
Assert.False(vm.CanControl);
|
||||
Assert.Equal(Loc.L("Tooltips.Server.Jobs.ReadOnly"), vm.TitleToolTip);
|
||||
Assert.Equal(2, vm.Rows.Count);
|
||||
Assert.True(vm.HasRows);
|
||||
var running = vm.Rows[0];
|
||||
Assert.Equal(verify, running.Id);
|
||||
Assert.Equal("Verifying photo 812 of 2,400 · Harbour sunset · sequence 3 of 41", running.StatusText);
|
||||
Assert.Equal(StatusKindOf(JobState.Running), running.StateKind);
|
||||
Assert.Empty(running.Actions);
|
||||
Assert.Equal("Stopped at Proxy 300 of 1,800 · Lake", vm.Rows[1].StatusText);
|
||||
Assert.Empty(vm.Rows[1].Actions);
|
||||
// Without the right, nothing reaches the server.
|
||||
await vm.ActAsync(verify, (a, id, ct) => a.PauseJobAsync(id, ct));
|
||||
Assert.Equal(0, api.Actions);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ProgressEventsMoveTheLineAndAFinishedJobLeaves()
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
var api = new FakeJobsApi();
|
||||
var id = api.Add("verify", "Harbour sunset", "running", new JobDetailDto("verify", "Harbour sunset", 1, 2_400, 3, 41, "sequence"));
|
||||
using var vm = new ServerJobsViewModel(() => new ServerJobsAccount("a", false), () => api, new IdleContext());
|
||||
await UpdatedAsync(vm, vm.Refresh);
|
||||
|
||||
await UpdatedAsync(vm, () => api.Events.Writer.TryWrite(new JobProgressEvent(id, 900, 2_400, 52, 60,
|
||||
new JobDetailDto("verify", "Alpine lake", 20, 100, 4, 41, "sequence"))));
|
||||
var row = vm.Rows.Single();
|
||||
Assert.Equal("Verifying photo 20 of 100 · Alpine lake · sequence 4 of 41", row.StatusText);
|
||||
Assert.Equal(900d / 2_400, row.Progress);
|
||||
Assert.Equal("1 min", row.LeftText);
|
||||
|
||||
await UpdatedAsync(vm, () => api.Events.Writer.TryWrite(new JobStateEvent(id, "done", null)));
|
||||
Assert.Empty(vm.Rows);
|
||||
Assert.False(vm.HasRows);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AManagingAccountPausesResumesAndCancels()
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
var api = new FakeJobsApi();
|
||||
var id = api.Add("thumbs", "Lake", "running");
|
||||
using var vm = new ServerJobsViewModel(() => new ServerJobsAccount("a", CanControl: true), () => api, new IdleContext());
|
||||
await UpdatedAsync(vm, vm.Refresh);
|
||||
Assert.True(vm.CanControl);
|
||||
Assert.Equal(Loc.L("Tooltips.Server.Jobs"), vm.TitleToolTip);
|
||||
Assert.SequenceEqual(new[] { Loc.L("Jobs.Action.Pause"), Loc.L("Jobs.Action.Cancel") }, vm.Rows.Single().Actions.Select(a => a.Text));
|
||||
|
||||
await vm.ActAsync(id, (a, job, ct) => a.PauseJobAsync(job, ct));
|
||||
Assert.Equal(StatusKindOf(JobState.Paused), vm.Rows.Single().StateKind);
|
||||
Assert.SequenceEqual(new[] { Loc.L("Jobs.Action.Resume"), Loc.L("Jobs.Action.Cancel") }, vm.Rows.Single().Actions.Select(a => a.Text));
|
||||
|
||||
await vm.ActAsync(id, (a, job, ct) => a.CancelJobAsync(job, ct));
|
||||
Assert.Empty(vm.Rows);
|
||||
Assert.Equal(2, api.Actions);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ARefusedActionIsSaidAndTheListStays()
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
var api = new FakeJobsApi { Refuse = true };
|
||||
var id = api.Add("thumbs", "Lake", "running");
|
||||
string? said = null;
|
||||
using var vm = new ServerJobsViewModel(() => new ServerJobsAccount("a", true), () => api, new IdleContext(), (title, reason) => said = $"{title}: {reason}");
|
||||
await UpdatedAsync(vm, vm.Refresh);
|
||||
|
||||
await vm.ActAsync(id, (a, job, ct) => a.PauseJobAsync(job, ct));
|
||||
Assert.Equal($"{Loc.L("Server.Jobs.NotChanged")}: The job cannot do that in its current state.", said);
|
||||
Assert.Equal(StatusKindOf(JobState.Running), vm.Rows.Single().StateKind);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task SigningOutEmptiesTheListAndClosesTheConnection()
|
||||
{
|
||||
var api = new FakeJobsApi();
|
||||
api.Add("verify", "Harbour sunset", "running");
|
||||
ServerJobsAccount? account = new("a", false);
|
||||
using var vm = new ServerJobsViewModel(() => account, () => api, new IdleContext());
|
||||
await UpdatedAsync(vm, vm.Refresh);
|
||||
Assert.Equal(1, vm.Rows.Count);
|
||||
|
||||
account = null;
|
||||
vm.Refresh();
|
||||
Assert.False(vm.IsWatching);
|
||||
Assert.Empty(vm.Rows);
|
||||
await api.Disposed.Task.WaitAsync(TimeSpan.FromSeconds(10));
|
||||
|
||||
// Without an account nothing is opened.
|
||||
var opened = 0;
|
||||
using var signedOut = new ServerJobsViewModel(() => null, () => { opened++; return api; }, new IdleContext());
|
||||
signedOut.Refresh();
|
||||
Assert.Equal(0, opened);
|
||||
Assert.False(signedOut.HasRows);
|
||||
}
|
||||
|
||||
private static Chronos.Ui.Controls.StatusKind StatusKindOf(JobState state) =>
|
||||
state == JobState.Paused ? Chronos.Ui.Controls.StatusKind.Paused : Chronos.Ui.Controls.StatusKind.Running;
|
||||
|
||||
/// <summary>Runs <paramref name="act"/>, waits for the listener to post what follows, then applies it as the UI would.</summary>
|
||||
private static async Task UpdatedAsync(ServerJobsViewModel vm, Action act)
|
||||
{
|
||||
var posted = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
void OnPosted() => posted.TrySetResult();
|
||||
vm.Posted += OnPosted;
|
||||
try
|
||||
{
|
||||
act();
|
||||
await posted.Task.WaitAsync(TimeSpan.FromSeconds(10));
|
||||
}
|
||||
finally
|
||||
{
|
||||
vm.Posted -= OnPosted;
|
||||
}
|
||||
vm.Flush();
|
||||
}
|
||||
|
||||
/// <summary>A UI context that never runs what is posted to it: the test applies the updates itself.</summary>
|
||||
private sealed class IdleContext : SynchronizationContext
|
||||
{
|
||||
public override void Post(SendOrPostCallback d, object? state)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class FakeJobsApi : IServerJobsApi
|
||||
{
|
||||
private readonly List<JobDto> _jobs = [];
|
||||
|
||||
public Channel<ServerEvent> Events { get; } = Channel.CreateUnbounded<ServerEvent>();
|
||||
|
||||
public TaskCompletionSource Disposed { get; } = new(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
public bool Refuse { get; init; }
|
||||
|
||||
public int Actions { get; private set; }
|
||||
|
||||
public Guid Add(string kind, string target, string state, JobDetailDto? detail = null)
|
||||
{
|
||||
var id = Guid.CreateVersion7();
|
||||
lock (_jobs)
|
||||
{
|
||||
_jobs.Add(new JobDto(id, kind, [], target, state, "background", 10, 100, null, null, null, null, 1, null, T0, T0.AddMinutes(_jobs.Count), null, null,
|
||||
detail));
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public Task<Page<JobDto>> ListJobsAsync(string state, string? cursor, CancellationToken cancellationToken)
|
||||
{
|
||||
lock (_jobs)
|
||||
{
|
||||
var items = _jobs.Where(j => j.State == state).ToList();
|
||||
return Task.FromResult(new Page<JobDto>(items, null, items.Count));
|
||||
}
|
||||
}
|
||||
|
||||
public Task<JobDto> GetJobAsync(Guid id, CancellationToken cancellationToken)
|
||||
{
|
||||
lock (_jobs) return Task.FromResult(_jobs.Single(j => j.Id == id));
|
||||
}
|
||||
|
||||
public Task<JobDto> PauseJobAsync(Guid id, CancellationToken cancellationToken) => Set(id, "paused");
|
||||
|
||||
public Task<JobDto> ResumeJobAsync(Guid id, CancellationToken cancellationToken) => Set(id, "running");
|
||||
|
||||
public Task<JobDto> CancelJobAsync(Guid id, CancellationToken cancellationToken) => Set(id, "cancelled");
|
||||
|
||||
public async IAsyncEnumerable<ServerEvent> EventsAsync([EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
{
|
||||
await foreach (var e in Events.Reader.ReadAllAsync(cancellationToken)) yield return e;
|
||||
}
|
||||
|
||||
public void Dispose() => Disposed.TrySetResult();
|
||||
|
||||
private Task<JobDto> Set(Guid id, string state)
|
||||
{
|
||||
if (Refuse)
|
||||
throw new Chronos.Protocol.Client.ChronosApiException(System.Net.HttpStatusCode.Conflict,
|
||||
new ApiError("invalid_state", "The job cannot do that in its current state.", null));
|
||||
Actions++;
|
||||
lock (_jobs)
|
||||
{
|
||||
var index = _jobs.FindIndex(j => j.Id == id);
|
||||
var job = _jobs[index] with { State = state };
|
||||
_jobs[index] = job;
|
||||
return Task.FromResult(job);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Data.Jobs;
|
||||
using Chronos.Protocol;
|
||||
using Chronos.Testing;
|
||||
|
||||
namespace Chronos.Server.Tests.Hosting;
|
||||
|
||||
/// <summary>
|
||||
/// What a job does now in the admin panel (owner review 5, #65; <c>Admin/web/jobs.js</c>): the Jobs page and the dashboard
|
||||
/// draw the status line under the target and move it with every progress event, and every step, part and sub-step the
|
||||
/// server can send is worded in English and Italian.
|
||||
/// </summary>
|
||||
[Category("server")]
|
||||
public sealed class AdminJobDetailTests(TestContext context)
|
||||
{
|
||||
private static readonly string[] MaintenanceSteps = ["Leases", "Temp", "Packs", "Duplicates", "Vacuum"];
|
||||
|
||||
[Test]
|
||||
public async Task TheJobsPageAndTheDashboardShowTheStatusLine()
|
||||
{
|
||||
await using var server = await TestServer.StartAsync(context);
|
||||
var jobs = await server.Client.GetStringAsync("/admin/jobs.js");
|
||||
foreach (var helper in new[] { "statusText(detail)", "rowStatus(job)", "speedText(kind, rate)", "leftText(seconds)", "targetCell(job)", "statusLine(job)", "updateStatus(row, job)" })
|
||||
Assert.Contains($"export function {helper}", jobs);
|
||||
// Items are data: they read in their own direction, and the whole line is the tooltip.
|
||||
Assert.Contains(@"<span class=""progress-detail"" dir=""auto"" title=""${attr(tip)}"">", jobs);
|
||||
foreach (var page in new[] { "/admin/pages/jobs.js", "/admin/pages/dashboard.js" })
|
||||
{
|
||||
var text = await server.Client.GetStringAsync(page);
|
||||
Assert.Contains(@"<span class=""target-cell"" role=""cell"">${targetCell(j)}</span>", text);
|
||||
Assert.Contains("if (e.detail) job.detail = e.detail;", text);
|
||||
Assert.Contains("updateStatus(row, job);", text);
|
||||
Assert.True(!text.Contains(" style=", StringComparison.Ordinal), "inline style");
|
||||
}
|
||||
Assert.Contains(".progress-detail {", await server.Client.GetStringAsync("/admin/admin.css"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task EveryStepAndPartIsInEnglishAndItalian()
|
||||
{
|
||||
await using var server = await TestServer.StartAsync(context);
|
||||
var jobs = await server.Client.GetStringAsync("/admin/jobs.js");
|
||||
var en = Assert.NotNull(await server.Client.GetFromJsonAsync("/api/v1/i18n/en", ProtocolJson.Default.DictionaryStringString));
|
||||
var it = Assert.NotNull(await server.Client.GetFromJsonAsync("/api/v1/i18n/it", ProtocolJson.Default.DictionaryStringString));
|
||||
var keys = Regex.Matches(jobs, @"""(Admin\.[A-Za-z]+(?:\.[A-Za-z]+)*)""").Select(m => m.Groups[1].Value).ToList();
|
||||
Assert.Contains("Admin.Job.Detail.StoppedAt", keys);
|
||||
// The keys built from what the server sends.
|
||||
keys.AddRange(Enum.GetValues<JobStep>().Where(s => s != JobStep.None).Select(s => $"Admin.Job.Step.{s}"));
|
||||
keys.AddRange(Enum.GetValues<JobPartUnit>().Where(u => u != JobPartUnit.None).Select(u => $"Admin.Job.Part.{u}"));
|
||||
keys.AddRange(MaintenanceSteps.Select(s => $"Admin.Job.Maintenance.Step.{s}"));
|
||||
foreach (var key in keys.Distinct())
|
||||
Assert.True(en.ContainsKey(key) && it.ContainsKey(key), key);
|
||||
// The step and the unit keys are the wire names in PascalCase, as the panel builds them.
|
||||
Assert.Equal("copy-photo", JobWire.Step(JobStep.CopyPhoto));
|
||||
Assert.Equal("Copia foto {0} di {1}", it["Admin.Job.Step.CopyPhoto.Count"]);
|
||||
Assert.Equal("Verifying photo {0} of {1}", en["Admin.Job.Step.Verify.Count"]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user