89 lines
2.3 KiB
C#
89 lines
2.3 KiB
C#
using Blazored.LocalStorage;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
using MP.Data.DTO;
|
|
|
|
namespace MP.INVE.Shared
|
|
{
|
|
public partial class MainLayout
|
|
{
|
|
#region Protected Fields
|
|
|
|
protected string userName = "0";
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
protected bool navLarge { get; set; } = true;
|
|
|
|
protected string sideClass { get; set; } = "sidebar";
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected async Task getId()
|
|
{
|
|
OperatoreDTO answ = new OperatoreDTO();
|
|
answ = await localStorage.GetItemAsync<OperatoreDTO>("MatrOpr");
|
|
if (answ != null)
|
|
{
|
|
userName = $"{answ.Cognome} {answ.Nome} ({answ.MatrOpr})";
|
|
if (NavManager.Uri.Contains("OperatoreLogin"))
|
|
{
|
|
NavManager.NavigateTo("Elencomagazzini", true);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
userName = "0";
|
|
if (Height != 480 && Width != 320)
|
|
{
|
|
if (!NavManager.Uri.Contains("OperatoreLogin"))
|
|
{
|
|
NavManager.NavigateTo("OperatoreLogin", true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public int Height { get; set; }
|
|
public int Width { get; set; }
|
|
|
|
public class WindowDimension
|
|
{
|
|
public int Width { get; set; }
|
|
public int Height { get; set; }
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
var dimension = await JSRuntime.InvokeAsync<WindowDimension>("getWindowDimensions");
|
|
Height = dimension.Height;
|
|
Width = dimension.Width;
|
|
await getId();
|
|
}
|
|
|
|
protected void UpdateNavDisplay()
|
|
{
|
|
navLarge = !navLarge;
|
|
sideClass = navLarge ? "sidebar" : "sidebarSmall";
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Properties
|
|
|
|
[Inject]
|
|
private ILocalStorageService localStorage { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private NavigationManager NavManager { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private IJSRuntime JSRuntime { get; set; } = null!;
|
|
|
|
#endregion Private Properties
|
|
}
|
|
} |