90 lines
2.6 KiB
Plaintext
90 lines
2.6 KiB
Plaintext
@inherits LayoutComponentBase
|
|
|
|
<PageTitle>MP-MON</PageTitle>
|
|
|
|
<div class="page">
|
|
<main>
|
|
<div class="top-row px-4 justify-content-between">
|
|
<CmpHeader @rendermode="InteractiveWebAssembly"></CmpHeader>
|
|
</div>
|
|
|
|
<article class="content px-4">
|
|
@Body
|
|
</article>
|
|
<div class="fixed-bottom bottom-row px-2">
|
|
<CmpFooter @rendermode="InteractiveWebAssembly" version="@version" slowRefreshSec="@slowRefreshSec"></CmpFooter>
|
|
</div>
|
|
</main>
|
|
</div>
|
|
|
|
<div id="blazor-error-ui">
|
|
An unhandled error has occurred.
|
|
<a href="" class="reload">Reload</a>
|
|
<a class="dismiss">🗙</a>
|
|
</div>
|
|
@code {
|
|
|
|
[Inject]
|
|
protected NavigationManager NavMan { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected MonDataFeeder MMDataService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected IConfiguration config { get; set; } = null!;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
var currAssembly = typeof(Program).Assembly.GetName();
|
|
version = currAssembly.Version != null ? currAssembly.Version : new Version();
|
|
// sistemo config
|
|
CurrConfig = await MMDataService.ConfigGetAll();
|
|
|
|
#if DEBUG
|
|
slowRefreshSec = 20;
|
|
#else
|
|
getConfValInt("pageRefreshSec", ref slowRefreshSec);
|
|
#endif
|
|
|
|
// controllo URL x riscrivere se non fosse /MP/MON finale...
|
|
string baseUrl = config.GetValue<string>("ServerConf:BaseAppPath") ?? "/MP/MON/";
|
|
string wrongEnd = baseUrl.Substring(0, baseUrl.Length - 1);
|
|
string currUrl = NavMan.Uri;
|
|
if (currUrl.EndsWith(wrongEnd))
|
|
{
|
|
NavMan.NavigateTo(baseUrl, true);
|
|
}
|
|
base.OnInitialized();
|
|
}
|
|
|
|
|
|
private List<ConfigModel>? CurrConfig = null;
|
|
|
|
/// <summary>
|
|
/// Recupera il valore e se trovato aggiorna
|
|
/// </summary>
|
|
/// <param name="chiave">Valore da cercare</param>
|
|
/// <param name="varObj">Int in cui salvare il valore se trovato</param>
|
|
/// <returns></returns>
|
|
protected bool getConfValInt(string chiave, ref int varObj)
|
|
{
|
|
bool answ = false;
|
|
if (CurrConfig != null && CurrConfig.Count > 0)
|
|
{
|
|
// sistemo i parametri opzionali...
|
|
ConfigModel? risultato = CurrConfig.FirstOrDefault(x => x.Chiave == chiave);
|
|
if (risultato != null)
|
|
{
|
|
answ = int.TryParse(risultato.Valore, out varObj);
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
private int slowRefreshSec = 20;
|
|
|
|
/// <summary>
|
|
/// Versione applicativo ada passare al controllo footer
|
|
/// </summary>
|
|
private Version version = null!;
|
|
} |