From 630f3816745066c3dd263baf6769cb9077fbf642 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 7 Sep 2021 19:17:32 +0200 Subject: [PATCH] COmpletato comportamento editing accetta/rifiuta --- MP.FileData/Controllers/FileController.cs | 9 ++-- MP.FileData/DatabaseModels/FileModel.cs | 2 +- MP.FileData/Enum.cs | 2 +- MP.Prog/Components/DiffView.razor | 64 +++++++++++++++++------ MP.Prog/Components/FileEditor.razor | 58 ++------------------ MP.Prog/Components/FileEditor.razor.cs | 28 ++++++---- MP.Prog/Data/SelectData.cs | 2 +- MP.Prog/Pages/Archive.razor | 16 ++---- MP.Prog/Pages/Archive.razor.cs | 10 +++- MP.Prog/wwwroot/css/site.css | 3 ++ MP.Prog/wwwroot/css/site.less | 4 ++ MP.Prog/wwwroot/css/site.min.css | 2 +- 12 files changed, 98 insertions(+), 102 deletions(-) diff --git a/MP.FileData/Controllers/FileController.cs b/MP.FileData/Controllers/FileController.cs index 0b992f02..84b7a312 100644 --- a/MP.FileData/Controllers/FileController.cs +++ b/MP.FileData/Controllers/FileController.cs @@ -243,7 +243,7 @@ namespace MP.FileData.Controllers .DbSetProgFile .Include(m => m.Macchina) .Include(a => a.Articolo) - .Where(x => (x.IdxMacchina == IdxMacchina || IdxMacchina == "0") && (x.Active == OnlyActive || !OnlyActive) && (!OnlyMod || x.DiskStatus != FileState.Unchanged) && (x.Name.Contains(SearchVal) || string.IsNullOrEmpty(SearchVal))) + .Where(x => (x.IdxMacchina == IdxMacchina || IdxMacchina == "0") && (x.Active == OnlyActive || !OnlyActive) && (!OnlyMod || x.DiskStatus != FileState.Ok) && (x.Name.Contains(SearchVal) || string.IsNullOrEmpty(SearchVal))) .OrderByDescending(x => x.LastMod) .ToList(); } @@ -271,7 +271,7 @@ namespace MP.FileData.Controllers { Active = true, CodArticolo = "ND", - DiskStatus = FileState.Unchanged, + DiskStatus = FileState.Ok, IdxMacchina = idxMacchina, LastCheck = adesso, LastMod = o.LastWriteTime, @@ -318,7 +318,7 @@ namespace MP.FileData.Controllers // archivio vecchio file currFile.Active = false; - currFile.DiskStatus = FileState.Unchanged; + currFile.DiskStatus = FileState.Ok; localDbCtx.Entry(currFile).State = EntityState.Modified; // salvo DB localDbCtx.SaveChanges(); @@ -340,8 +340,9 @@ namespace MP.FileData.Controllers var newFileInfo = new FileInfo(currFile.Path); // aggiorno stato del file a unchanged e data mod ad ora... - currFile.DiskStatus = FileState.Unchanged; + currFile.DiskStatus = FileState.Ok; currFile.LastMod = newFileInfo.LastWriteTime; + localDbCtx.Entry(currFile).State = EntityState.Modified; // salvo DB localDbCtx.SaveChanges(); diff --git a/MP.FileData/DatabaseModels/FileModel.cs b/MP.FileData/DatabaseModels/FileModel.cs index 32f645ab..af9953b5 100644 --- a/MP.FileData/DatabaseModels/FileModel.cs +++ b/MP.FileData/DatabaseModels/FileModel.cs @@ -31,7 +31,7 @@ namespace MP.FileData.DatabaseModels public string Path { get; set; } = ""; public string MimeType { get; set; } = ""; public string MD5 { get; set; } = ""; - public FileState DiskStatus { get; set; } = FileState.Unchanged; + public FileState DiskStatus { get; set; } = FileState.Ok; public DateTime LastCheck { get; set; } = DateTime.Now.AddYears(-1); public byte[] FileContent { get; set; } diff --git a/MP.FileData/Enum.cs b/MP.FileData/Enum.cs index c4104772..5163fd93 100644 --- a/MP.FileData/Enum.cs +++ b/MP.FileData/Enum.cs @@ -14,6 +14,6 @@ namespace MP.FileData ND = 0, Changed, Deleted, - Unchanged + Ok } } \ No newline at end of file diff --git a/MP.Prog/Components/DiffView.razor b/MP.Prog/Components/DiffView.razor index a3c2c59a..845fc93e 100644 --- a/MP.Prog/Components/DiffView.razor +++ b/MP.Prog/Components/DiffView.razor @@ -3,38 +3,66 @@ @using DiffMatchPatch
-
-

Archiviato

-
- @((MarkupString)oldResult) -
-
-
+
-
-

Attuale

+
+

Archivio

-
- @numChanges modifiche +
+
+
+
-
-
-

@((MarkupString)newResult)">

+ @if (numChanges > 0) + { +
+
+
+

Attuale

+
+
+
+
+ @numChanges modifiche +
+
+
+ } +
+
+
+
+

@((MarkupString)oldResult)

+
+
+ @if (numChanges > 0) + { +
+
+

@((MarkupString)newResult)

+
+
+ }
@code { string sepDest = "
"; + protected int pHeight = 25; + protected string oldResult = ""; protected string newResult = ""; protected string _oldText = ""; protected string _newText = ""; - protected int numChanges = 0; + [Parameter] + public EventCallback diffDone { get; set; } + + protected int numChanges { get; set; } = 0; [Parameter] public string oldText @@ -46,7 +74,6 @@ set { _oldText = value; - ReloadData(); } } @@ -111,6 +138,11 @@ newResult = sbNew.ToString().Trim(); oldResult = sbOld.ToString().Trim(); + var pUpd = Task.Run(async () => + { + await diffDone.InvokeAsync(numChanges); + }); + pUpd.Wait(); } protected override Task OnInitializedAsync() diff --git a/MP.Prog/Components/FileEditor.razor b/MP.Prog/Components/FileEditor.razor index bff5eda2..067157fa 100644 --- a/MP.Prog/Components/FileEditor.razor +++ b/MP.Prog/Components/FileEditor.razor @@ -5,7 +5,7 @@
Dettaglio modifiche
- @if (_currItem.DiskStatus != FileData.FileState.Unchanged) + @if (_currItem.DiskStatus != FileData.FileState.Ok) {
@@ -18,64 +18,14 @@ }
+ @numDiff
-
- @* - -
-
-
-
- - - -
- -
-
-
- - - -
- -
-
- - -
-
- -
-
-
*@ - -
- -
-
- \ No newline at end of file diff --git a/MP.Prog/Components/FileEditor.razor.cs b/MP.Prog/Components/FileEditor.razor.cs index 414afd65..d600311a 100644 --- a/MP.Prog/Components/FileEditor.razor.cs +++ b/MP.Prog/Components/FileEditor.razor.cs @@ -12,12 +12,16 @@ namespace MP.Prog.Components { public partial class FileEditor : ComponentBase { + #region Protected Fields + + protected int numDiff = 0; + + #endregion Protected Fields + #region Public Fields public FileModel _currItem = new FileModel(); - public int pHeight = 20; - #endregion Public Fields #region Protected Properties @@ -129,6 +133,17 @@ namespace MP.Prog.Components #endregion Private Methods + #region Protected Methods + + protected void diffDoneHandler(int numChanges) + { +#if false + numDiff = numChanges; +#endif + } + + #endregion Protected Methods + #region Public Methods public string CurrFileContent(string fullPath) @@ -142,14 +157,5 @@ namespace MP.Prog.Components } #endregion Public Methods - - //protected override async Task OnInitializedAsync() - //{ - // await ReloadAllData(); - //} - - //protected async Task ReloadAllData() - //{ - //} } } \ No newline at end of file diff --git a/MP.Prog/Data/SelectData.cs b/MP.Prog/Data/SelectData.cs index 5c2cb00c..62f2a68b 100644 --- a/MP.Prog/Data/SelectData.cs +++ b/MP.Prog/Data/SelectData.cs @@ -13,7 +13,7 @@ namespace MP.Prog.Data public DateTime DateEnd { get; set; } = DateTime.Now.AddMinutes(1); public DateTime DateStart { get; set; } = DateTime.Now.AddDays(-7); public string IdxMacchina { get; set; } = ""; - public bool OnlyActive { get; set; } = false; + public bool OnlyActive { get; set; } = true; public bool OnlyMod { get; set; } = false; #endregion Public Properties diff --git a/MP.Prog/Pages/Archive.razor b/MP.Prog/Pages/Archive.razor index efa91e4d..31c0b83f 100644 --- a/MP.Prog/Pages/Archive.razor +++ b/MP.Prog/Pages/Archive.razor @@ -99,7 +99,7 @@ { - @if (currRecord == null) + @if (currRecord == null && record.Active) {