- Completato modifiche x selezione ricetta
- Controller x download ricetta
This commit is contained in:
Samuele Locatelli
2023-04-04 16:17:39 +02:00
parent 1c1710f285
commit cd90e6871f
9 changed files with 110 additions and 59 deletions
+17 -9
View File
@@ -19,7 +19,7 @@ else
<th>
@if (currRecord != null)
{
<button @onclick="() => resetSel(false)" class="btn btn-primary btn-sm"><i class="bi bi-arrow-counterclockwise"></i></button>
<button @onclick="() => resetSel(true)" class="btn btn-primary btn-sm"><i class="bi bi-arrow-counterclockwise"></i></button>
}
</th>
<th>Cod</th>
@@ -131,13 +131,21 @@ else
<div class="small textConsensed"><b>T. Ciclo:</b> @record.Tcassegnato.ToString("N3")</div>
</td>
<td>
@if (@record.Attivabile)
<div>
@if (@record.Attivabile)
{
<i class="fa-regular fa-square-check text-success"></i>
}
else
{
<i class="fa-regular fa-square text-secondary"></i>
}
</div>
@if (!string.IsNullOrEmpty(record.Recipe))
{
<i class="fa-regular fa-square-check text-success"></i>
}
else
{
<i class="fa-regular fa-square text-secondary"></i>
<div>
<i class="fa-solid fa-flask"></i> <b>@record.Recipe</b>
</div>
}
</td>
<td>
@@ -160,10 +168,10 @@ else
<RecipeConfMan IdxPODL="@currRecord.IdxPromessa" RecipePath="@currRecipePath" CancelEvent="resetSel"></RecipeConfMan>
</div>
}
else if(showRecipeArch)
else if (showRecipeArch)
{
<div class="col-6 ps-0">
<RecipeArchMan IdxPODL="@currRecord.IdxPromessa" RecipeCode="@currRecord.Recipe" RecipeArchPath="@currRecipeArchPath" ReqCloseEvent="resetSel"></RecipeArchMan>
<RecipeArchMan IdxPODL="@currRecord.IdxPromessa" RecipeCode="@currRecord.Recipe" RecipeArchPath="@currRecipeArchPath" IdxMacc="@currRecord.IdxMacchina" ReqCloseEvent="resetSel"></RecipeArchMan>
</div>
}
}
+6 -14
View File
@@ -10,7 +10,7 @@ else
<div class="card-header">
<div class="d-flex justify-content-between">
<div>
<h4>Ricetta Assegnata</h4>
<h4>Assegnazione Ricetta <i class="fa-solid fa-flask"></i></h4>
</div>
<div class="text-danger">
@if (string.IsNullOrEmpty(RecipeCode))
@@ -25,23 +25,23 @@ else
<div class="card-body">
<div class="d-flex justify-content-between">
<div>
<button class="btn btn-primary" @onclick="() => showPreview()"><i class="fa-regular fa-eye"></i></button>
<a class="btn btn-primary" target="_blank" href="@($"api/RecipeArchive/GetFile?idxMacc={IdxMacc}&fileName={RecipeCode}")"><i class="fa-regular fa-eye"></i></a>
<b>@(string.IsNullOrEmpty(RecipeCode) ? "-- SELEZIONARE --" : RecipeCode)</b>
</div>
<div>
<button class="btn btn-sm btn-success" @onclick="showSelect" title="Selezione Ricetta"><i class="fa-solid fa-pen"></i> Sel</button>
<button class="btn btn-sm btn-success" @onclick="showSelect" title="Modifica Ricetta Assegnata"><i class="fa-solid fa-pen"></i> Modifica</button>
</div>
</div>
@if (showSearch)
{
<ul class="list-group small">
<ul class="list-group small mt-1">
<li class="list-group-item active">
<div class="d-flex justify-content-between">
<div>
search
Ricette disponibili
</div>
<div>
<input class="form-control" @bind="@searchVal" type="text" title="Filtro ricerca" placeholder="ricerca">
<input class="form-control form-control-sm text-end" @bind="@searchVal" type="text" title="Filtro ricerca" placeholder="ricerca">
</div>
</div>
</li>
@@ -72,14 +72,6 @@ else
</li>
</ul>
}
else if (showDetail)
{
<div class="row" style=" height: @(pHeight)em; overflow-y: scroll;">
<div class="col-12 table-primary">
@((MarkupString)rawRecipe)
</div>
</div>
}
</div>
</div>
}
+10 -30
View File
@@ -1,5 +1,7 @@
using Microsoft.AspNetCore.Components;
using MP.SPEC.Data;
using System.Text;
using System.Xml;
namespace MP.SPEC.Components
{
@@ -15,6 +17,8 @@ namespace MP.SPEC.Components
[Parameter]
public string RecipeCode { get; set; } = "";
[Parameter]
public string IdxMacc { get; set; } = "";
[Parameter]
public EventCallback<bool> ReqCloseEvent { get; set; }
@@ -24,12 +28,10 @@ namespace MP.SPEC.Components
#region Protected Fields
protected int _numShow = 10;
protected string _rawRecipe = "";
protected string _searchVal = "";
protected bool isLoading = false;
protected int numFound = 0;
protected int pHeight = 25;
protected bool showDetail = false;
protected bool showSearch = false;
#endregion Protected Fields
@@ -53,14 +55,7 @@ namespace MP.SPEC.Components
}
}
protected string rawRecipe
{
get
{
return _rawRecipe.Replace(Environment.NewLine, sepDest).Replace("\n", sepDest).Replace("\r", sepDest);
}
set => _rawRecipe = value;
}
protected string searchVal
{
@@ -87,23 +82,13 @@ namespace MP.SPEC.Components
protected override async Task OnParametersSetAsync()
{
await ReloadData();
if (!string.IsNullOrEmpty(RecipeArchPath) && !string.IsNullOrEmpty(RecipeCode) && !string.IsNullOrEmpty(IdxMacc))
{
await ReloadData();
}
}
protected async Task showPreview()
{
showDetail = !showDetail;
if (showDetail)
{
if (!string.IsNullOrEmpty(RecipeCode))
{
// leggo ricetta e carico...
string fullPath = Path.Combine(RecipeArchPath, RecipeCode);
rawRecipe = File.ReadAllText(fullPath);
}
}
await Task.Delay(1);
}
/// <summary>
/// Salvataggio ricetta in PODL corrente
@@ -117,10 +102,6 @@ namespace MP.SPEC.Components
{
RecipeCode = recipeName;
showSearch = false;
showDetail = true;
// leggo ricetta e carico...
string fullPath = Path.Combine(RecipeArchPath, recipeName);
rawRecipe = File.ReadAllText(fullPath);
}
}
@@ -130,7 +111,6 @@ namespace MP.SPEC.Components
private List<string> list2show = new List<string>();
private List<string> recipeList = new List<string>();
private string sepDest = "<br />";
#endregion Private Fields
@@ -0,0 +1,69 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using MP.Data.MgModels;
using MP.SPEC.Data;
using Newtonsoft.Json;
using NLog;
using System.Xml;
namespace MP.SPEC.Controllers
{
[Route("api/[controller]")]
[ApiController]
[AllowAnonymous]
public class RecipeArchiveController : ControllerBase
{
/// <summary>
/// Dataservice x accesso DB
/// </summary>
protected MpDataService DService { get; set; }
public RecipeArchiveController(IConfiguration configuration, MpDataService DataService)
{
Log.Info("Starting RecipeArchiveController");
_configuration = configuration;
DService = DataService;
Log.Info("Avviata classe RecipeArchiveController");
}
private static IConfiguration _configuration = null!;
private static Logger Log = LogManager.GetCurrentClassLogger();
[HttpGet("GetFile")]
public async Task<string> GetFile(string idxMacc, string fileName)
{
string answ = "";
string archPath = await DService.MacchineRecipeArchive(idxMacc);
if (!string.IsNullOrEmpty(archPath))
{
string fullPath = Path.Combine(archPath, fileName);
if (!string.IsNullOrEmpty(fullPath))
{
answ = System.IO.File.ReadAllText(fullPath);
}
}
return answ;
}
[HttpGet("GetByPODL")]
public async Task<string> GetByPODL(string idxMacc, int idxPODL)
{
string answ = "";
string archPath = await DService.MacchineRecipeArchive(idxMacc);
var podlData = await DService.POdlGetByKey(idxPODL);
if (podlData != null)
{
string fileName = podlData?.Recipe ?? "";
string fullPath = Path.Combine(archPath, fileName);
if (!string.IsNullOrEmpty(fullPath))
{
answ = System.IO.File.ReadAllText(fullPath);
}
}
return answ;
}
}
}
+4 -2
View File
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using MP.Data.MgModels;
@@ -11,6 +12,7 @@ namespace MP.SPEC.Controllers
{
[Route("api/[controller]")]
[ApiController]
[AllowAnonymous]
public class RecipeController : ControllerBase
{
/// <summary>
@@ -20,7 +22,7 @@ namespace MP.SPEC.Controllers
public RecipeController(IConfiguration configuration, MpDataService DataService)
{
Log.Info("Starting MpDataService INIT");
Log.Info("Starting RecipeController");
_configuration = configuration;
DService = DataService;
Log.Info("Avviata classe Recipe");
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.SPEC</RootNamespace>
<Version>6.16.2304.411</Version>
<Version>6.16.2304.416</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 6.16.2304.411</h4>
<h4>Versione: 6.16.2304.416</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
6.16.2304.411
6.16.2304.416
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2304.411</version>
<version>6.16.2304.416</version>
<url>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>