Ok visualizzazione giornaliera orizzontale...

This commit is contained in:
Samuele Locatelli
2021-12-10 19:22:02 +01:00
parent dc96cf8d4e
commit b390d84ee4
4 changed files with 154 additions and 74 deletions
+3 -67
View File
@@ -1,5 +1,4 @@
@using CORE.Data.DTO
<div class="d-flex justify-content-between">
<div class="p-1" style="width: 3em;">
@@ -31,16 +30,15 @@
{
<i>NO data</i>
}
else if (DayDTO != null && DayDTO.ListRA != null)
else if (@DayDTO != null && @DayDTO.ListRA != null)
{
<div class="d-flex justify-content-around text-center border border-dark border-top-0 border-left-0 border-right-0">
@foreach (var item in DayDTO.ListRA)
@foreach (var item in ListRegAtt())
{
<RegAtt CurrData="item" Periodo="periodo"></RegAtt>
}
</div>
}
@*<Test></Test>*@
}
</div>
<div class="py-2 px-1 small text-right" style="width: 5.5em;">
@@ -58,66 +56,4 @@
</div>
@code {
[Parameter]
public DailyDataDTO? DayDTO { get; set; }
[Parameter]
public int StartHour { get; set; }
[Parameter]
public int EndHour { get; set; }
[Parameter]
public bool IsTitle { get; set; } = false;
private bool noData
{
get => DayDTO == null || DayDTO.ListRA == null || DayDTO.ListRA.Count == 0;
}
private string TotLav
{
get
{
TimeSpan tSpan = TimeSpan.Zero;
double answ = 0;
if (DayDTO != null && DayDTO.TimbrExpl != null && DayDTO.TimbrExpl.HLav != null)
{
answ = (double)DayDTO.TimbrExpl.HLav;
tSpan = TimeSpan.FromHours(answ);
}
return $"{tSpan.Hours}h {tSpan.Minutes}'";
}
}
private string TotComm
{
get
{
TimeSpan tSpan = TimeSpan.Zero;
double answ = 0;
if (DayDTO != null && DayDTO.ListRA != null)
{
answ = (double)DayDTO.ListRA.Sum(x => x.OreTot);
tSpan = TimeSpan.FromHours(answ);
}
return $"{tSpan.Hours}h {tSpan.Minutes}'";
}
}
private int periodo
{
get
{
int answ=1;
if (DayDTO != null)
{
answ = EndHour - StartHour;
}
return answ;
}
}
}
+125
View File
@@ -0,0 +1,125 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using System.Net.Http;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.Web.Virtualization;
using Microsoft.JSInterop;
using GPW.CORE.UI;
using GPW.CORE.UI.Shared;
using GPW.CORE.Data.DTO;
namespace GPW.CORE.UI.Components
{
public partial class DayHoriz
{
[Parameter]
public DailyDataDTO? DayDTO { get; set; }
[Parameter]
public int StartHour { get; set; }
[Parameter]
public int EndHour { get; set; }
[Parameter]
public bool IsTitle { get; set; } = false;
private bool noData { get => DayDTO == null || DayDTO.ListRA == null || DayDTO.ListRA.Count == 0; }
private string TotLav
{
get
{
TimeSpan tSpan = TimeSpan.Zero;
double answ = 0;
if (DayDTO != null && DayDTO.TimbrExpl != null && DayDTO.TimbrExpl.HLav != null)
{
answ = (double)DayDTO.TimbrExpl.HLav;
tSpan = TimeSpan.FromHours(answ);
}
return $"{tSpan.Hours}h {tSpan.Minutes}'";
}
}
private string TotComm
{
get
{
TimeSpan tSpan = TimeSpan.Zero;
double answ = 0;
if (DayDTO != null && DayDTO.ListRA != null)
{
answ = (double)DayDTO.ListRA.Sum(x => x.OreTot);
tSpan = TimeSpan.FromHours(answ);
}
return $"{tSpan.Hours}h {tSpan.Minutes}'";
}
}
private int periodo
{
get
{
int answ = 1;
if (DayDTO != null)
{
answ = EndHour - StartHour;
}
return answ;
}
}
private List<CORE.Data.DbModels.RegAttivitaModel> ListRegAtt()
{
// init
DateTime currHour = DayDTO.DtRif.AddHours(StartHour);
DateTime lastHour = DayDTO.DtRif.AddHours(EndHour);
List<CORE.Data.DbModels.RegAttivitaModel> result = new List<CORE.Data.DbModels.RegAttivitaModel>();
// ciclo partendo dal primo evento ed aggiungendo eventuali periodi in testa / coda / intermedi
foreach (var item in DayDTO.ListRA)
{
// se evento > ora corrente --> aggiungo vuoto...
if (item.Inizio > currHour)
{
CORE.Data.DbModels.RegAttivitaModel? newItem = new CORE.Data.DbModels.RegAttivitaModel()
{
Inizio = currHour,
IdxFase = 0,
Descrizione="-",
Fine =item.Inizio,
OreTot=(decimal)item.Inizio.Subtract(currHour).TotalHours
};
result.Add(newItem);
}
// ...altrimenti parto con lui...
result.Add(item);
currHour = item.Fine;
}
// se non sono in fondo --> aggiungo!
if (currHour < lastHour)
{
CORE.Data.DbModels.RegAttivitaModel? newItem = new CORE.Data.DbModels.RegAttivitaModel()
{
Inizio = currHour,
IdxFase = 0,
Descrizione = "-",
Fine = lastHour,
OreTot = (decimal)lastHour.Subtract(currHour).TotalHours
};
result.Add(newItem);
}
return result;
}
}
}
+24 -4
View File
@@ -1,9 +1,19 @@
@using CORE.Data.DbModels
<div class="px-1 py-0 small border flex-fill" style="width: @widthPerc">
<div>@CurrData.Inizio</div>
<div>@CurrData.Fine</div>
<div class="px-1 py-0 small flex-fill @blockCss" style="width: @widthPerc">
<div class="d-flex">
@if (@CurrData.IdxFase > 0)
{
<div class="px-1">
<b>@widthPerc</b>
</div>
<div class="px-1">
<div>@CurrData.Inizio.ToString("HH:mm")</div>
<div>@CurrData.Fine.ToString("HH:mm")</div>
</div>
}
</div>
</div>
@@ -22,9 +32,19 @@
string answ = "1%";
if (CurrData != null)
{
answ = $"{CurrData.OreTot/Periodo:P0}";
answ = $"{CurrData.OreTot / Periodo:P0}";
}
return answ;
}
}
private string blockCss
{
get
{
string answ = CurrData.IdxFase == 0 ? "" : "table-info border border-info rounded";
return answ;
}
}
}
+2 -3
View File
@@ -61,7 +61,7 @@
</div>
<div class="row">
@*<div class="row">
<div class="col-12 text-center">
<table class="table table-sm table-striped table-responsive-sm">
<thead>
@@ -88,13 +88,12 @@
<DayAgendaDetail Ora="@i" CurrDay="DayOfWeek.Friday"></DayAgendaDetail>
<DayAgendaDetail Ora="@i" CurrDay="DayOfWeek.Saturday"></DayAgendaDetail>
<DayAgendaDetail Ora="@i" CurrDay="DayOfWeek.Sunday"></DayAgendaDetail>
@*<td style="width: 13.8%;"><DayAgendaDetail></DayAgendaDetail></td>*@
</tr>
}
</tbody>
</table>
</div>
</div>
</div>*@
}
<div class="small">