PROG:
- fix display size - fix display status - review modulo DiffView
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.FileData
|
||||
{
|
||||
public class MeasureUtils
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
public static readonly string[] SizeSuffixes = { "b", "Kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb" };
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Calcola dimensione file automaticamwente secondo dimensione
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="decimalPlaces"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentOutOfRangeException"></exception>
|
||||
public static string SizeSuffix(Int64 value, int decimalPlaces = 1)
|
||||
{
|
||||
if (decimalPlaces < 0) { throw new ArgumentOutOfRangeException("decimalPlaces"); }
|
||||
if (value < 0) { return "-" + SizeSuffix(-value, decimalPlaces); }
|
||||
if (value == 0) { return string.Format("{0:n" + decimalPlaces + "} bytes", 0); }
|
||||
|
||||
// mag is 0 for bytes, 1 for KB, 2, for MB, etc.
|
||||
int mag = (int)Math.Log(value, 1024);
|
||||
|
||||
// 1L << (mag * 10) == 2 ^ (10 * mag) [i.e. the number of bytes in the unit
|
||||
// corresponding to mag]
|
||||
decimal adjustedSize = (decimal)value / (1L << (mag * 10));
|
||||
|
||||
// make adjustment when the value is large enough that it would round up to 1000 or more
|
||||
if (Math.Round(adjustedSize, decimalPlaces) >= 1000)
|
||||
{
|
||||
mag += 1;
|
||||
adjustedSize /= 1024;
|
||||
}
|
||||
|
||||
return string.Format("{0:n" + decimalPlaces + "} {1}",
|
||||
adjustedSize,
|
||||
SizeSuffixes[mag]);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -31,119 +31,13 @@
|
||||
<div class="row" style=" height: @(pHeight)em; overflow-y: scroll;">
|
||||
<div class="col-6 table-primary">
|
||||
<div class="border border-primary p-2 bg-light">
|
||||
<p style="max-width: 70em;">@((MarkupString)oldResult)</p>
|
||||
<p style="max-width: 70em;">@((MarkupString)StrFix(oldResult))</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 table-warning">
|
||||
<div class="border border-warning p-2 bg-light">
|
||||
<p style="max-width: 70em;">@((MarkupString)newResult)</p>
|
||||
<p style="max-width: 70em;">@((MarkupString)StrFix(newResult))</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
string sepDest = "<br />";
|
||||
|
||||
protected int pHeight = 25;
|
||||
|
||||
protected string oldResult = "";
|
||||
protected string newResult = "";
|
||||
|
||||
protected string _oldText = "";
|
||||
protected string _newText = "";
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<int> diffDone { get; set; }
|
||||
|
||||
protected int numChanges { get; set; } = 0;
|
||||
|
||||
[Parameter]
|
||||
public string oldText
|
||||
{
|
||||
get
|
||||
{
|
||||
return _oldText;
|
||||
}
|
||||
set
|
||||
{
|
||||
_oldText = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected string oldTextFix
|
||||
{
|
||||
get
|
||||
{
|
||||
return _oldText.Replace(" ", " ").Replace(Environment.NewLine, sepDest).Replace("\n", sepDest).Replace("\r", sepDest);
|
||||
}
|
||||
}
|
||||
|
||||
protected string newTextFix
|
||||
{
|
||||
get
|
||||
{
|
||||
return _newText.Replace(" ", " ").Replace(Environment.NewLine, sepDest).Replace("\n", sepDest).Replace("\r", sepDest);
|
||||
}
|
||||
}
|
||||
[Parameter]
|
||||
public string newText
|
||||
{
|
||||
get
|
||||
{
|
||||
return _newText;
|
||||
}
|
||||
set
|
||||
{
|
||||
_newText = value;
|
||||
ReloadData();
|
||||
}
|
||||
}
|
||||
protected void ReloadData()
|
||||
{
|
||||
numChanges = 0;
|
||||
// calcolo diff
|
||||
diff_match_patch dmp = new diff_match_patch();
|
||||
List<Diff> diff = dmp.diff_main(oldTextFix, newTextFix);
|
||||
dmp.diff_cleanupSemantic(diff);
|
||||
|
||||
// predispongo la stringa secondo l'elenco dei diff....
|
||||
StringBuilder sbNew = new StringBuilder();
|
||||
StringBuilder sbOld = new StringBuilder();
|
||||
foreach (var item in diff)
|
||||
{
|
||||
switch (item.operation)
|
||||
{
|
||||
case Operation.DELETE:
|
||||
sbOld.Append($"<span class=\"border border-success table-success\">{item.text}</span>");
|
||||
numChanges++;
|
||||
break;
|
||||
case Operation.INSERT:
|
||||
sbNew.Append($"<span class=\"border border-danger table-danger\">{item.text}</span>");
|
||||
numChanges++;
|
||||
break;
|
||||
case Operation.EQUAL:
|
||||
sbNew.Append($"<span class=\"text-dark\">{item.text}</span>");
|
||||
sbOld.Append($"<span class=\"text-dark\">{item.text}</span>");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
newResult = sbNew.ToString().Trim();
|
||||
oldResult = sbOld.ToString().Trim();
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
await diffDone.InvokeAsync(numChanges);
|
||||
});
|
||||
pUpd.Wait();
|
||||
}
|
||||
|
||||
protected override Task OnInitializedAsync()
|
||||
{
|
||||
ReloadData();
|
||||
return base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
using DiffMatchPatch;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Prog.Components
|
||||
{
|
||||
public partial class DiffView
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<int> diffDone { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string newText
|
||||
{
|
||||
get => _newText;
|
||||
set => _newText = value;
|
||||
}
|
||||
|
||||
[Parameter]
|
||||
public string oldText
|
||||
{
|
||||
get => _oldText;
|
||||
set => _oldText = value;
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected string _newText = "";
|
||||
|
||||
protected string _oldText = "";
|
||||
|
||||
protected string newResult = "";
|
||||
|
||||
protected string oldResult = "";
|
||||
|
||||
protected int pHeight = 25;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected int numChanges { get; set; } = 0;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected override Task OnInitializedAsync()
|
||||
{
|
||||
ReloadData();
|
||||
return base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
ReloadData();
|
||||
}
|
||||
|
||||
protected void ReloadData()
|
||||
{
|
||||
numChanges = 0;
|
||||
// calcolo diff
|
||||
diff_match_patch dmp = new diff_match_patch();
|
||||
List<Diff> diff = dmp.diff_main(oldText, newText);
|
||||
//List<Diff> diff = dmp.diff_main(oldTextFix, newTextFix);
|
||||
dmp.diff_cleanupSemantic(diff);
|
||||
|
||||
// predispongo la stringa secondo l'elenco dei diff....
|
||||
StringBuilder sbNew = new StringBuilder();
|
||||
StringBuilder sbOld = new StringBuilder();
|
||||
foreach (var item in diff)
|
||||
{
|
||||
switch (item.operation)
|
||||
{
|
||||
case Operation.DELETE:
|
||||
sbOld.Append($"<span class=\"border border-success table-success\">{item.text}</span>");
|
||||
numChanges++;
|
||||
break;
|
||||
|
||||
case Operation.INSERT:
|
||||
sbNew.Append($"<span class=\"border border-danger table-danger\">{item.text}</span>");
|
||||
numChanges++;
|
||||
break;
|
||||
|
||||
case Operation.EQUAL:
|
||||
sbNew.Append($"<span class=\"text-dark\">{item.text}</span>");
|
||||
sbOld.Append($"<span class=\"text-dark\">{item.text}</span>");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
newResult = sbNew.ToString().Trim();
|
||||
oldResult = sbOld.ToString().Trim();
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
await diffDone.InvokeAsync(numChanges);
|
||||
});
|
||||
pUpd.Wait();
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private string sepDest = "<br />";
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private string StrFix(string origVal)
|
||||
{
|
||||
return origVal.Replace(" ", " ").Replace(Environment.NewLine, sepDest).Replace("\n", sepDest).Replace("\r", sepDest);
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -11,10 +11,10 @@
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<button type="button" class="btn btn-primary btn-lg w-100" value="Cancel" @onclick="RejectChange">Mantieni Archivio <i class="fas fa-arrow-right"></i></button>
|
||||
<button type="button" class="btn btn-primary w-100" value="Cancel" @onclick="RejectChange">Mantieni Archivio <i class="fas fa-arrow-right"></i></button>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<button type="button" class="btn btn-warning btn-lg w-100" value="Cancel" @onclick="ApproveChange"><i class="fas fa-arrow-left"></i> Accetta Modifiche</button>
|
||||
<button type="button" class="btn btn-warning w-100" value="Cancel" @onclick="ApproveChange"><i class="fas fa-arrow-left"></i> Accetta Modifiche</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -23,7 +23,7 @@
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<button type="button" class="btn btn-success btn-lg w-100" value="" @onclick="ExportArchive">Sostituisci da Archivio <i class="fas fa-file-download"></i></button>
|
||||
<button type="button" class="btn btn-success w-100" value="" @onclick="ExportArchive">Sostituisci da Archivio <i class="fas fa-file-download"></i></button>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
</div>
|
||||
@@ -33,11 +33,11 @@
|
||||
<div class="col-2">
|
||||
</div>
|
||||
<div class="col-2 text-end">
|
||||
<button type="button" class="btn btn-light btn-lg w-100" value="Cancel" @onclick="cancelUpdate" title="Chiudi">Chiudi <i class="fas fa-window-close"></i></button>
|
||||
<button type="button" class="btn btn-light w-100" value="Cancel" @onclick="cancelUpdate" title="Chiudi">Chiudi <i class="fas fa-xmark"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body small py-1">
|
||||
<MP.Prog.Components.DiffView oldText="@_currItem.FileStringContent" newText="@(CurrFileContent(_currItem.Path))"></MP.Prog.Components.DiffView>
|
||||
<DiffView oldText="@_currItem.FileStringContent" newText="@(CurrFileContent(_currItem.Path))"></DiffView>
|
||||
</div>
|
||||
</div>
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>MP.Prog</RootNamespace>
|
||||
<Version>6.16.2410.2120</Version>
|
||||
<Version>6.16.2410.2210</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -150,7 +150,7 @@
|
||||
<div>@record.Rev</div>
|
||||
</td>
|
||||
<td>
|
||||
<div>@((((double)record.Size) / 1024).ToString("N2")) k</div>
|
||||
@CalcSize(record.Size)
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<span title="@record.DiskStatus | Ultimo controllo: @record.LastCheck.ToString("yyyy.MM.dd HH:mm:ss")">
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using MP.FileData;
|
||||
using MP.FileData.DatabaseModels;
|
||||
using MP.Prog.Data;
|
||||
using NLog;
|
||||
@@ -293,26 +294,26 @@ namespace MP.Prog.Pages
|
||||
return answ;
|
||||
}
|
||||
|
||||
private string cssStatusByCod(FileData.FileState currStatus)
|
||||
private string cssStatusByCod(FileState currStatus)
|
||||
{
|
||||
string answ = "badge";
|
||||
switch (currStatus)
|
||||
{
|
||||
case FileData.FileState.Changed:
|
||||
answ += " badge-warning";
|
||||
case FileState.Changed:
|
||||
answ += " text-bg-warning";
|
||||
break;
|
||||
|
||||
case FileData.FileState.Deleted:
|
||||
answ += " badge-danger";
|
||||
case FileState.Deleted:
|
||||
answ += " text-bg-danger";
|
||||
break;
|
||||
|
||||
case FileData.FileState.Ok:
|
||||
answ += " badge-success";
|
||||
case FileState.Ok:
|
||||
answ += " text-bg-success";
|
||||
break;
|
||||
|
||||
case FileData.FileState.ND:
|
||||
case FileState.ND:
|
||||
default:
|
||||
answ += " badge-light";
|
||||
answ += " text-bg-light";
|
||||
break;
|
||||
}
|
||||
return answ;
|
||||
@@ -366,6 +367,16 @@ namespace MP.Prog.Pages
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce size calcolata
|
||||
/// </summary>
|
||||
/// <param name="origSize"></param>
|
||||
/// <returns></returns>
|
||||
protected string CalcSize(long origSize)
|
||||
{
|
||||
return MeasureUtils.SizeSuffix(origSize, 1);
|
||||
}
|
||||
|
||||
protected async Task FilterTag(string searchVal)
|
||||
{
|
||||
SelTag = searchVal;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo gestione Programmi MAPO</i>
|
||||
<h4>Versione: 6.16.2410.2120</h4>
|
||||
<h4>Versione: 6.16.2410.2210</h4>
|
||||
<br />
|
||||
Note di rilascio:
|
||||
<ul>
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.16.2410.2120
|
||||
6.16.2410.2210
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>6.16.2410.2120</version>
|
||||
<version>6.16.2410.2210</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/MP.Prog.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user