aggiunto componente per gestione files (Bozza x file dei messaggi)

This commit is contained in:
zaccaria.majid
2023-05-29 12:40:08 +02:00
parent c9ee7a02fc
commit acff028e5f
2 changed files with 116 additions and 0 deletions
@@ -0,0 +1,45 @@
<button class="btn btn-info" @onclick="()=>refreshVoc()">VOCABULARY REFRESH</button>
<input @bind-value="@defaultPath" />
@*@if (vocLemmas != null)
{
@foreach (var item in vocLemmas)
{
@foreach (var k in item.Value)
{
@*<div>@($"{k.Key} --> {k.Value}")</div>
@if(vocLemmasTEMP != null)
{
}
}
}
}*@
@if (showList)
{
@if (vocLemmas2Dict != null && vocLemmasTEMP2Dict != null)
{
@foreach (var item in vocLemmasTEMP2Dict)
{
@if (!vocLemmas2Dict.ContainsKey(item.Key))
{
<div class="row">
<div class="col-12 text-success">@($"{item.Key} --> {vocLemmasTEMP2Dict[item.Key]}")</div>
</div>
}
else if (item.Value != vocLemmas2Dict[item.Key])
{
<div class="row">
<div class="col-6 text-danger text-decoration-line-through">@($"{item.Key} --> {vocLemmas2Dict[item.Key]}")</div>
<div class="col-6 text-success">@($"{item.Key} --> {item.Value}")</div>
</div>
}
}
}
}
@@ -0,0 +1,71 @@
using Microsoft.AspNetCore.Components;
using Microsoft.CodeAnalysis.VisualBasic.Syntax;
using WebDoorCreator.Data.DbModels;
using WebDoorCreator.Data.Services;
namespace WebDoorCreator.UI.Components.FilesMan
{
public partial class FilesRefresh
{
[Inject]
protected WebDoorCreatorService WDCService { get; set; } = null!;
[Parameter]
public string lang { get; set; } = "";
protected Dictionary<string, Dictionary<string, string>>? vocLemmas { get; set; } = null;
protected Dictionary<string, string> vocLemmas2Dict { get; set; } = new Dictionary<string, string>();
protected Dictionary<string, Dictionary<string, string>>? vocLemmasTEMP { get; set; } = null;
protected Dictionary<string, string> vocLemmasTEMP2Dict { get; set; } = new Dictionary<string, string>();
protected bool showList { get; set; } = false;
protected async override Task OnParametersSetAsync()
{
var rawVoc = await WDCService.VocLemmaGetAll();
if (rawVoc != null)
{
vocLemmas = rawVoc.Where(x => x.Key == lang).ToDictionary(x => x.Key, x => x.Value);
if(vocLemmas != null)
{
foreach(var kvp in vocLemmas)
{
foreach(var item in kvp.Value)
{
vocLemmas2Dict.Add(item.Key, item.Value);
}
}
}
}
}
protected async Task refreshVoc()
{
vocLemmasTEMP = null;
await Task.Delay(1);
list2Mod = await WDCService.VocLemmaInsertPrepare(@$"{defaultPath}");
if (list2Mod != null)
{
//bool ok = await WDCService.VocLemmaInsert();
var k = await WDCService.VocLemmaTEMPGetAll();
if (k != null)
{
vocLemmasTEMP = k.Where(x => x.Key == lang).ToDictionary(x => x.Key, x => x.Value);
if (vocLemmasTEMP != null)
{
foreach (var kvp in vocLemmasTEMP)
{
foreach (var item in kvp.Value)
{
vocLemmasTEMP2Dict.Add(item.Key, item.Value);
}
}
}
}
}
showList = true;
}
List<VocabularyTempModel> list2Mod = new List<VocabularyTempModel>();
protected string defaultPath { get; set; } = "";
}
}