Update Planner x autorefresh

This commit is contained in:
Samuele Locatelli
2022-01-21 11:07:11 +01:00
parent 6644d0dd20
commit 055a9d570b
3 changed files with 50 additions and 6 deletions
+3
View File
@@ -116,6 +116,9 @@ else if (ListTimbr != null)
<i class="fas fa-angle-double-right"></i>
<input @bind="endHour" style="width: 3em;" type="number" />
</div>
<div class="py-1 px-2">
<span>@lastRefresh.ToString("dddd dd.MM.yyyy HH:mm:ss")</span>
</div>
<div class="py-1 px-2">
@if (clonedRA != null)
{
+44 -2
View File
@@ -13,7 +13,7 @@ namespace GPW.CORE.UI.Pages
/// modale: vedere qui: https://gist.github.com/conficient/ba98d1662c659e170ec16650acea05c8
/// </summary>
//[Authorize(Roles = "SuperAdmin, Admin")]
public partial class Planner
public partial class Planner : IDisposable
{
#region Private Fields
@@ -298,6 +298,7 @@ namespace GPW.CORE.UI.Pages
await Task.Delay(100);
checkHourRange();
await Task.Delay(100);
lastRefresh = DateTime.Now;
isLoading = false;
}
@@ -339,10 +340,51 @@ namespace GPW.CORE.UI.Pages
DtRifTempRil = dataRif;
showTemp = true;
}
/// <summary>
/// TImer per refresh dati
/// </summary>
protected System.Timers.Timer timer;
protected DateTime lastRefresh = DateTime.Now;
protected override void OnInitialized()
{
// avvio un timer infinito x refresh pagina COMUNQUE ogni 60 sec anche non succedesse nulla...
timer = new System.Timers.Timer
{
Interval = 1000 * 60,
AutoReset = true,
Enabled = true
};
timer.Elapsed += async (s, ea) => await TryReload();
}
public void Dispose()
{
timer?.Dispose();
}
protected async Task TryReload()
{
await Task.Delay(1);
// effettuo reload SOLO SE no ho editing in corso...
if (!modeEdit)
{
await ReloadData();
await InvokeAsync(StateHasChanged);
}
}
protected bool modeEdit
{
get => (currRecord != null || ListTimbr != null || showTemp);
//get => (selPeriod || showTemp || currRecord != null || weekStatList != null || ListTimbr != null);
}
protected async Task ReloadPeriodo()
{
selPeriod = false;
showTemp=false;
showTemp = false;
weekStatList = null;
currRecord = null;
ListTimbr = null;
+3 -4
View File
@@ -8,11 +8,10 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="~/" />
@*<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />*@
<link rel="stylesheet" href="lib/bootstrap/css/bootstrap.min.css" />
<link href="css/site.css" rel="stylesheet" />
<link href="lib/font-awesome/css/all.css" rel="stylesheet" />
<link href="GPW.CORE.UI.styles.css" rel="stylesheet" />
<link rel="stylesheet"href="css/site.css" />
<link rel="stylesheet"href="lib/font-awesome/css/all.css" />
<link rel="stylesheet"href="GPW.CORE.UI.styles.css" />
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
</head>