Update gestione risorse

This commit is contained in:
Samuele Locatelli
2025-10-30 18:32:17 +01:00
parent 00317a3c12
commit dfaf8f33ca
15 changed files with 289 additions and 27 deletions
@@ -1219,6 +1219,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
.Include(c => c.JobNav)
.Include(c => c.PhaseNav)
.Include(c => c.ResourceNav)
.Include(c => c.TagNav)
.ToListAsync();
}
catch (Exception exc)
@@ -1311,7 +1312,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
{
var currRec = dbCtx
.DbSetJobStep
.Where(x => x.JobStepID == upsRec.JobStepID && upsRec.JobStepID>0)
.Where(x => x.JobStepID == upsRec.JobStepID && upsRec.JobStepID > 0)
.FirstOrDefault();
// se trovato --> aggiorno
if (currRec != null)
@@ -1395,6 +1396,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
dbResult = await dbCtx
.DbSetJobTask
.Include(c => c.JobStepNav)
.Include(c => c.TagNav)
.ToListAsync();
}
catch (Exception exc)
@@ -2156,6 +2158,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
{
dbResult = await dbCtx
.DbSetResource
.Include(d => d.DriverNav)
.ToListAsync();
}
catch (Exception exc)
@@ -108,5 +108,14 @@ namespace EgwCoreLib.Lux.Data.DbModel.Task
/// Many-to-many with Tags
/// </summary>
public virtual ICollection<JobStepTagModel> TagNav { get; set; } = new List<JobStepTagModel>();
/// <summary>
/// Numero Tags compresi
/// </summary>
[NotMapped]
public int NumTags
{
get => TagNav?.Count ?? 0;
}
}
}
@@ -57,5 +57,14 @@ namespace EgwCoreLib.Lux.Data.DbModel.Task
{
get => JobStepNav?.Count ?? 0;
}
/// <summary>
/// Numero Tags compresi
/// </summary>
[NotMapped]
public int NumTags
{
get => TagNav?.Count ?? 0;
}
}
}
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>0.9.2510.3012</Version>
<Version>0.9.2510.3018</Version>
</PropertyGroup>
<ItemGroup>
@@ -95,6 +95,7 @@
<th>Fase</th>
<th>Risorsa</th>
<th>Descrizione</th>
<th>Tags</th>
<th>Resa</th>
<th>
<button class="btn btn-sm btn-success" @onclick="ToggleAdd"><i class="fa-solid fa-plus"></i></button>
@@ -148,6 +149,7 @@
<td>@item.PhaseNav.Name</td>
<td>@item.ResourceNav.Name</td>
<td>@item.Description</td>
<td class="text-center">@item.NumTags</td>
<td>@($"{item.ProductivityRate:P2}")</td>
<td>
@@ -62,7 +62,8 @@
{
<th>Ord.</th>
<th>Descrizione</th>
<th>Fasi</th>
<th class="text-center">Fasi</th>
<th class="text-center">Tags</th>
<th>
<button class="btn btn-sm btn-success" @onclick="ToggleAdd"><i class="fa-solid fa-plus"></i></button>
</th>
@@ -93,7 +94,8 @@
<button class="btn @cssBtnDown btn-sm fa-solid fa-caret-down" @onclick="() => MoveRec(item, false)"></button>
</td>
<td>@item.Description</td>
<td>@item.NumChild</td>
<td class="text-center">@item.NumChild</td>
<td class="text-center">@item.NumTags</td>
<td>
@if (item.Lock || item.NumChild > 0)
{
@@ -0,0 +1,47 @@
<div class="card shadow">
@* <div class="card-header">
Elenco <b>Risorse</b> configurate
</div> *@
<div class="card-body">
@if (isLoading || ListRecords == null)
{
<LoadingData></LoadingData>
}
else if (totalCount == 0)
{
<div class="alert alert-info text-center display-4">Nessun record trovato</div>
}
else
{
<table class="table table-sm table-striped">
<thead>
<tr>
<th class="text-center">
<button class="btn btn-sm btn-primary" title="Reset selezione" @onclick="DoReset"><i class="fa-solid fa-arrow-rotate-right"></i></button>
</th>
<th>Cod.</th>
<th>Nome</th>
<th>Driver</th>
<th class="text-center">
<button class="btn btn-sm btn-success" @onclick="ToggleAdd"><i class="fa-solid fa-plus"></i></button>
</th>
</tr>
</thead>
<tbody>
@foreach (var item in ListRecords)
{
<tr>
<td class="text-center">
<button class="btn btn-sm btn-primary" @onclick="() => DoSelect(item)"><i class="fa-solid fa-magnifying-glass"></i></button>
</td>
<td>@item.CodResource</td>
<td>@item.Name</td>
<td>@item.DriverNav.Name</td>
<td class="text-center">-</td>
</tr>
}
</tbody>
</table>
}
</div>
</div>
@@ -0,0 +1,136 @@
using EgwCoreLib.Lux.Data.DbModel.Cost;
using EgwCoreLib.Lux.Data.DbModel.Task;
using EgwCoreLib.Lux.Data.Services;
using Microsoft.AspNetCore.Components;
namespace Lux.UI.Components.Compo.JobTask
{
public partial class ResourcesMan
{
#region Public Properties
[Parameter]
public string CurrSearch { get; set; } = string.Empty;
#endregion Public Properties
#region Protected Fields
protected List<ResourceModel> AllRecords = new List<ResourceModel>();
protected List<ResourceModel> ListRecords = new List<ResourceModel>();
protected List<ResourceModel> SearchRecords = new List<ResourceModel>();
#endregion Protected Fields
#region Protected Properties
[Inject]
protected DataLayerServices DLService { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
/// <summary>
/// Reset selezione
/// </summary>
protected async void DoReset()
{
editRecord = null;
selRecord = null;
await ReloadBaseData();
ReloadData();
}
/// <summary>
/// Selezione articolo x display info
/// </summary>
/// <param name="curRec"></param>
protected void DoSelect(ResourceModel curRec)
{
selRecord = curRec;
}
protected override async Task OnInitializedAsync()
{
await ReloadBaseData();
ReloadData();
}
protected override void OnParametersSet()
{
ReloadData();
}
protected void ToggleAdd()
{
addVisible = !addVisible;
if (addVisible)
{
newRecord = new ResourceModel()
{
Name = $"Risorsa | {DateTime.Now:yyyy.MM.dd-HH.mm.ss}"
};
}
}
#endregion Protected Methods
#region Private Fields
private bool addVisible = false;
private int currPage = 1;
private ResourceModel? editRecord = null;
private bool isLoading = false;
private ResourceModel? newRecord = null;
private int numRecord = 10;
private ResourceModel? selRecord = null;
private int totalCount = 0;
#endregion Private Fields
#region Private Properties
private string mainCss
{
get => selRecord == null ? "col-6" : "col-4";
}
#endregion Private Properties
#region Private Methods
private async Task ReloadBaseData()
{
AllRecords = await DLService.ResourcesGetAllAsync();
}
private void ReloadData()
{
isLoading = true;
// se ho ricerca testuale faccio filtro ulteriore...
if (!string.IsNullOrEmpty(CurrSearch))
{
SearchRecords = AllRecords
.Where(x => x.Name.Contains(CurrSearch, StringComparison.InvariantCultureIgnoreCase))
.ToList();
}
else
{
SearchRecords = AllRecords;
}
totalCount = SearchRecords.Count;
// fix paginazione
ListRecords = SearchRecords
.OrderBy(x => x.CodResource)
.ThenBy(x => x.Name)
.Skip(numRecord * (currPage - 1))
.Take(numRecord)
.ToList();
isLoading = false;
}
#endregion Private Methods
}
}
+5
View File
@@ -39,6 +39,11 @@
<span class="fa-solid fa-book px-2 fs-4" aria-hidden="true"></span> <span class="@hideText">Articoli</span>
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="Resources">
<span class="fa-solid fa-location-dot px-2 fs-4" aria-hidden="true"></span> <span class="@hideText">Risorse</span>
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="JobRoute">
<span class="fa-solid fa-route px-2 fs-4" aria-hidden="true"></span> <span class="@hideText">Cicli</span>
+20 -20
View File
@@ -43,6 +43,9 @@ namespace Lux.UI.Components.Pages
private JobTaskModel? editRecord = null;
private bool isLoading = false;
private List<PhaseModel> ListPhases = new List<PhaseModel>();
private List<ResourceModel> ListResources = new List<ResourceModel>();
private List<JobStepModel>? ListStep = null;
private JobTaskModel? selRecord = null;
#endregion Private Fields
@@ -75,6 +78,23 @@ namespace Lux.UI.Components.Pages
isLoading = false;
}
/// <summary>
/// Reload dettagli ciclo
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
private async Task ReloadDetail(bool args)
{
if (selRecord != null)
{
ListStep = await DLService.JobStepGetAsync(selRecord.JobID);
}
else
{
ListStep = null;
}
}
/// <summary>
/// Salva ID sel e mostra dettagli JobTask
/// </summary>
@@ -94,26 +114,6 @@ namespace Lux.UI.Components.Pages
}
}
private List<JobStepModel>? ListStep = null;
private List<PhaseModel> ListPhases = new List<PhaseModel>();
private List<ResourceModel> ListResources = new List<ResourceModel>();
#endregion Private Methods
/// <summary>
/// Reload dettagli ciclo
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
private async Task ReloadDetail(bool args)
{
if (selRecord != null)
{
ListStep = await DLService.JobStepGetAsync(selRecord.JobID);
}
else
{
ListStep = null;
}
}
}
}
+23
View File
@@ -0,0 +1,23 @@
@page "/Resources"
<div class="card shadow">
<div class="card-header">
<div class=" d-flex justify-content-between">
<div class="px-0 fs-3">
<b>Risorse</b>
</div>
<div class="px-0 d-flex justify-content-between">
<div class="px-1">
<div class="input-group input-group-sm" title="ricerca">
<span class="input-group-text"><i class="fas fa-search"></i></span>
<input type="text" class="form-control" @bind="@searchVal">
<button class="btn btn-outline-secondary" @onclick="ResetSearch"><i class="fas fa-ban"></i></button>
</div>
</div>
</div>
</div>
</div>
<div class="card-body">
<ResourcesMan CurrSearch="@searchVal"></ResourcesMan>
</div>
</div>
@@ -0,0 +1,26 @@
using EgwCoreLib.Lux.Data.DbModel.Cost;
using EgwCoreLib.Lux.Data.DbModel.Task;
using EgwCoreLib.Lux.Data.Services;
using Lux.UI.Components.Compo.JobTask;
using Microsoft.AspNetCore.Components;
namespace Lux.UI.Components.Pages
{
public partial class Resources
{
#region Protected Methods
protected void ResetSearch()
{
searchVal = "";
}
#endregion Protected Methods
#region Private Properties
private string searchVal { get; set; } = string.Empty;
#endregion Private Properties
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>LUX - Web Windows MES</i>
<h4>Versione: 0.9.2510.3012</h4>
<h4>Versione: 0.9.2510.3018</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
0.9.2510.3012
0.9.2510.3018
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>0.9.2510.3012</version>
<version>0.9.2510.3018</version>
<url>http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html</changelog>
<mandatory>false</mandatory>