1392b0e6d1
Il marchio e' corallo (#ec4c41), rosso profondo e bianco sporco: azzurro non ce n'e'. Nell'app invece era il colore piu' diffuso — lo stato "in corso", la voce attiva della barra, l'avatar, le righe scelte, il pannello di riepilogo — e non stava per niente: era solo il tono che si usa quando un colore serve e non si sa quale. Il ruolo "info" passa alla famiglia dell'ancora navy, cioe' allo stesso colore del testo forte: lo stato informativo smette di portarsi un colore proprio e i colori restano ai toni che significano qualcosa (verde inviato, ambra da completare, rosso da inviare) e all'accento. Il pannello di riepilogo dell'ispezione era l'unico blocco tinto dell'app e diventa bianco come ogni altro pannello: dentro, l'unico colore e' adesso la barra di avanzamento. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
148 lines
4.2 KiB
Plaintext
148 lines
4.2 KiB
Plaintext
@using System.Globalization
|
|
@using SteUp.Shared.Components.SingleElements
|
|
@using SteUp.Shared.Core.Interface.IntegryApi
|
|
@using SteUp.Shared.Core.Interface.System.Network
|
|
@inherits LayoutComponentBase
|
|
@implements IDisposable
|
|
@inject INetworkService NetworkService
|
|
@inject IIntegryApiService IntegryApiService
|
|
|
|
<MudThemeProvider Theme="_theme" IsDarkMode="false"/>
|
|
<MudPopoverProvider/>
|
|
@* NoHeader NON va messo qui: e' il valore predefinito di tutti i dialog e
|
|
sopprimerebbe il titolo dei MudMessageBox, che lo rendono nella testata.
|
|
Le schermate a tutto schermo (form scheda, scelta punto vendita) lo
|
|
chiedono gia' per conto loro nelle DialogOptions. *@
|
|
<MudDialogProvider CloseButton="false" BackdropClick="false"/>
|
|
<MudSnackbarProvider/>
|
|
|
|
<ConnectionState IsNetworkAvailable="IsNetworkAvailable" ServicesIsDown="ServicesIsDown" ShowWarning="ShowWarning"/>
|
|
|
|
<div class="app-shell">
|
|
@Body
|
|
</div>
|
|
|
|
<NavMenu/>
|
|
|
|
@code {
|
|
|
|
//Connection state
|
|
private bool _isNetworkAvailable;
|
|
private bool _servicesIsDown;
|
|
private bool _showWarning;
|
|
|
|
private DateTime _lastApiCheck = DateTime.MinValue;
|
|
private const int DelaySeconds = 90;
|
|
|
|
private CancellationTokenSource? _cts;
|
|
|
|
private bool ServicesIsDown
|
|
{
|
|
get => _servicesIsDown;
|
|
set
|
|
{
|
|
if (_servicesIsDown == value) return;
|
|
_servicesIsDown = value;
|
|
StateHasChanged();
|
|
}
|
|
}
|
|
|
|
private bool IsNetworkAvailable
|
|
{
|
|
get => _isNetworkAvailable;
|
|
set
|
|
{
|
|
if (_isNetworkAvailable == value) return;
|
|
_isNetworkAvailable = value;
|
|
StateHasChanged();
|
|
}
|
|
}
|
|
|
|
private bool ShowWarning
|
|
{
|
|
get => _showWarning;
|
|
set
|
|
{
|
|
if (_showWarning == value) return;
|
|
_showWarning = value;
|
|
StateHasChanged();
|
|
}
|
|
}
|
|
|
|
// La palette resta quella di SteUP. Forma, ritmo e tipografia arrivano dai
|
|
// token CSS (tokens.css), che pilotano anche le variabili di MudBlazor:
|
|
// qui si dichiara solo il minimo che Mud deve conoscere lato C#.
|
|
private readonly MudTheme _theme = new()
|
|
{
|
|
PaletteLight = new PaletteLight
|
|
{
|
|
Primary = "#ec4c41",
|
|
Secondary = "#002339",
|
|
Tertiary = "#dde5ee",
|
|
Success = "#26b050",
|
|
Error = "#e50000",
|
|
Warning = "#b26a00",
|
|
Info = "#002339",
|
|
Background = "#e9edf2",
|
|
Surface = "#ffffff",
|
|
TextPrimary = "#000000",
|
|
TextSecondary = "#465563",
|
|
LinesDefault = "#d9e0e8",
|
|
LinesInputs = "#d9e0e8",
|
|
Divider = "#d9e0e8"
|
|
},
|
|
LayoutProperties = new LayoutProperties
|
|
{
|
|
DefaultBorderRadius = "16px"
|
|
}
|
|
};
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
_cts = new CancellationTokenSource();
|
|
_ = CheckConnectionState(_cts.Token);
|
|
|
|
var culture = new CultureInfo("it-IT", false);
|
|
|
|
CultureInfo.CurrentCulture = culture;
|
|
CultureInfo.CurrentUICulture = culture;
|
|
}
|
|
|
|
private Task CheckConnectionState(CancellationToken token)
|
|
{
|
|
return Task.Run(async () =>
|
|
{
|
|
while (!token.IsCancellationRequested)
|
|
{
|
|
var isNetworkAvailable = NetworkService.IsNetworkAvailable();
|
|
var servicesDown = ServicesIsDown;
|
|
|
|
if (isNetworkAvailable && (DateTime.UtcNow - _lastApiCheck).TotalSeconds >= DelaySeconds)
|
|
{
|
|
servicesDown = !await IntegryApiService.SystemOk();
|
|
_lastApiCheck = DateTime.UtcNow;
|
|
}
|
|
|
|
await InvokeAsync(async () =>
|
|
{
|
|
IsNetworkAvailable = isNetworkAvailable;
|
|
ServicesIsDown = servicesDown;
|
|
|
|
await Task.Delay(1500, token);
|
|
ShowWarning = !(IsNetworkAvailable && !ServicesIsDown);
|
|
NetworkService.ConnectionAvailable = !ShowWarning;
|
|
});
|
|
|
|
await Task.Delay(500, token);
|
|
}
|
|
}, token);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_cts?.Cancel();
|
|
_cts?.Dispose();
|
|
}
|
|
|
|
}
|