From 5d807d08757809db71b917b45ded2312a7da88a4 Mon Sep 17 00:00:00 2001 From: Kevin Jump Date: Sun, 10 Mar 2024 17:19:25 +0000 Subject: [PATCH] Adds UI to the report to make it eaiser to spot sources. (#598) --- uSync.BackOffice/BackOfficeConstants.cs | 5 ++++ uSync.BackOffice/Services/SyncFileService.cs | 1 + .../SyncHandlers/SyncHandlerRoot.cs | 25 ++++++++++++++++--- .../App_Plugins/uSync/changedialog.html | 6 +++++ .../uSync/components/usync.reportview.html | 8 +++--- .../App_Plugins/uSync/usync.css | 25 ++++++++++++++++++- 6 files changed, 61 insertions(+), 9 deletions(-) diff --git a/uSync.BackOffice/BackOfficeConstants.cs b/uSync.BackOffice/BackOfficeConstants.cs index 55ca14fc..27835631 100644 --- a/uSync.BackOffice/BackOfficeConstants.cs +++ b/uSync.BackOffice/BackOfficeConstants.cs @@ -29,6 +29,11 @@ public static class Package /// public const string ReleaseSuffix = ""; + /// + /// folder we say things are in when we have merged them. + /// + public const string MergedFolderName = "Combined"; + /// /// ordering of the handler items (what gets done when) /// diff --git a/uSync.BackOffice/Services/SyncFileService.cs b/uSync.BackOffice/Services/SyncFileService.cs index 7d17677d..846ef6e4 100644 --- a/uSync.BackOffice/Services/SyncFileService.cs +++ b/uSync.BackOffice/Services/SyncFileService.cs @@ -506,6 +506,7 @@ public IEnumerable MergeFolders(string[] folders, string extens { // merge these files. item.Value.SetNode(trackerBase.MergeFiles(elements[item.Key].Node, item.Value.Node)); + item.Value.FileName = $"{uSyncConstants.MergedFolderName}/{Path.GetFileName(item.Value.FileName)}"; } elements[item.Key] = item.Value; diff --git a/uSync.BackOffice/SyncHandlers/SyncHandlerRoot.cs b/uSync.BackOffice/SyncHandlers/SyncHandlerRoot.cs index 4a146e56..c4805c84 100644 --- a/uSync.BackOffice/SyncHandlers/SyncHandlerRoot.cs +++ b/uSync.BackOffice/SyncHandlers/SyncHandlerRoot.cs @@ -285,7 +285,8 @@ public IEnumerable ImportAll(string[] folders, HandlerSettings conf options.Callbacks?.Update?.Invoke($"Importing {Path.GetFileNameWithoutExtension(item.Path)}", count, total); - var result = ImportElement(item.Node, item.Path, config, options); + var result = ImportElement(item.Node, item.FileName, config, options).ToList(); + foreach (var attempt in result) { if (attempt.Success) @@ -516,11 +517,13 @@ virtual public IEnumerable ImportElement(XElement node, string file .AsEnumerableOfOne(); } + var shortFilename = Path.GetFileNameWithoutExtension(filename); + if (_mutexService.FireItemStartingEvent(new uSyncImportingItemNotification(node, (ISyncHandler)this))) { // blocked return uSyncActionHelper - .ReportAction(ChangeType.NoChange, node.GetAlias(), node.GetPath(), GetNameFromFileOrNode(filename, node), node.GetKey(), this.Alias, "Change stopped by delegate event") + .ReportAction(ChangeType.NoChange, node.GetAlias(), node.GetPath(), GetNameFromFileOrNode(shortFilename, node), node.GetKey(), this.Alias, "Change stopped by delegate event") .AsEnumerableOfOne(); } @@ -532,7 +535,7 @@ virtual public IEnumerable ImportElement(XElement node, string file // get the item. var attempt = DeserializeItem(node, serializerOptions); - var action = uSyncActionHelper.SetAction(attempt, GetNameFromFileOrNode(filename, node), node.GetKey(), this.Alias, IsTwoPass); + var action = uSyncActionHelper.SetAction(attempt, GetNameFromFileOrNode(shortFilename, node), node.GetKey(), this.Alias, IsTwoPass); // add item if we have it. if (attempt.Item != null) action.Item = attempt.Item; @@ -540,6 +543,8 @@ virtual public IEnumerable ImportElement(XElement node, string file // add details if we have them if (attempt.Details != null && attempt.Details.Any()) action.Details = attempt.Details; + action.Path = GetRootFolder(filename.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)); + // this might not be the place to do this because, two pass items are imported at another point too. _mutexService.FireItemCompletedEvent(new uSyncImportedItemNotification(node, attempt.Change)); @@ -553,7 +558,19 @@ virtual public IEnumerable ImportElement(XElement node, string file $"{this.Alias} Import Fail: {ex.Message}", new Exception(ex.Message)) .AsEnumerableOfOne(); } + } + + private string GetRootFolder(string path) + { + if (path.StartsWith(uSyncConstants.MergedFolderName)) + return Path.GetDirectoryName(path); + foreach(var folder in this.uSyncConfig.GetFolders()) + { + if (path.Contains(folder) is true) return Path.GetFileName(folder.TrimEnd('/')); + } + + return path; } @@ -1361,7 +1378,7 @@ public IEnumerable ReportElement(XElement node, string filename, Ha var action = uSyncActionHelper .ReportAction(change.Change, node.GetAlias(), node.GetPath(), GetNameFromFileOrNode(filename, node), node.GetKey(), this.Alias, ""); - + action.Path = GetRootFolder(filename.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)); action.Message = ""; diff --git a/uSync.Backoffice.Assets/App_Plugins/uSync/changedialog.html b/uSync.Backoffice.Assets/App_Plugins/uSync/changedialog.html index e12eeac2..28587827 100644 --- a/uSync.Backoffice.Assets/App_Plugins/uSync/changedialog.html +++ b/uSync.Backoffice.Assets/App_Plugins/uSync/changedialog.html @@ -20,6 +20,12 @@ +
+ Update file from the {{vm.item.path}} folder. +
+
+ Update is the result of combining two or more files from disk. +
diff --git a/uSync.Backoffice.Assets/App_Plugins/uSync/components/usync.reportview.html b/uSync.Backoffice.Assets/App_Plugins/uSync/components/usync.reportview.html index b93976a7..a44a3eab 100644 --- a/uSync.Backoffice.Assets/App_Plugins/uSync/components/usync.reportview.html +++ b/uSync.Backoffice.Assets/App_Plugins/uSync/components/usync.reportview.html @@ -51,11 +51,11 @@
{{result._typename}}
+
+ {{result.path}} +
-
- {{result.name}} -
> {{result.itemType.substring(1)}}{{result.path}}
-
+ {{result.name}}
{{result.change}} diff --git a/uSync.Backoffice.Assets/App_Plugins/uSync/usync.css b/uSync.Backoffice.Assets/App_Plugins/uSync/usync.css index 607e6c58..2274e903 100644 --- a/uSync.Backoffice.Assets/App_Plugins/uSync/usync.css +++ b/uSync.Backoffice.Assets/App_Plugins/uSync/usync.css @@ -633,4 +633,27 @@ ul.usync-action-list { .usync-summary-expand.active .icon { transform: rotateX(180deg); -} \ No newline at end of file +} + +.usync-path-source-summary { + margin: 5px 0; + font-style: italic; + border: 1px solid #eee; + border-left: 4px solid #ddd; + padding: 5px 10px; +} + +.usync-path-name { + padding: 3px 5px; + border-radius: 4px; +} + + .usync-path-name.Combined { + background-color: #FF7043; + color: white; + } + + .usync-path-name.Root { + background-color: #27b171; + color: white; + }