diff --git a/MP-TAB/MP-TAB.Client/Pages/User.razor b/MP-TAB/MP-TAB.Client/Pages/User.razor new file mode 100644 index 00000000..5f282702 --- /dev/null +++ b/MP-TAB/MP-TAB.Client/Pages/User.razor @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/MP-TAB/MP-TAB.Client/Program.cs b/MP-TAB/MP-TAB.Client/Program.cs index 7eeaa159..7dd4a88c 100644 --- a/MP-TAB/MP-TAB.Client/Program.cs +++ b/MP-TAB/MP-TAB.Client/Program.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Components.WebAssembly.Hosting; var builder = WebAssemblyHostBuilder.CreateDefault(args); + // aggiunto x gestione chiamate WebAPI builder.Services.AddScoped(sp => new HttpClient diff --git a/MP-TAB/MP-TAB/Components/App.razor b/MP-TAB/MP-TAB/Components/App.razor index 965b0d4e..040d30a9 100644 --- a/MP-TAB/MP-TAB/Components/App.razor +++ b/MP-TAB/MP-TAB/Components/App.razor @@ -25,6 +25,7 @@ + diff --git a/MP-TAB/MP-TAB/Components/Pages/User.razor b/MP-TAB/MP-TAB/Components/Pages/User.razor index 985c4da4..b34d9c81 100644 --- a/MP-TAB/MP-TAB/Components/Pages/User.razor +++ b/MP-TAB/MP-TAB/Components/Pages/User.razor @@ -1,8 +1,97 @@ @page "/user" +@* *@ +@using NLog; +@* @attribute [RenderModeAuto] *@ +@attribute [RenderModeServer] + +@inject IJSRuntime JSRuntime +@inject HttpClient Http +@inject IHttpContextAccessor httpContextAccessor

User

-@code { +
+
+
+
+
+ +
+
+ USER DATA +
+
+
+
+
    +
  • +
    User
    +
    USERNAME[999]
    +
  • +
  • +
    Server Time
    +
    @($"{DateTime.Now.ToString("dddd d.M.yyyy HH:mm.ss")}")
    +
  • +
  • +
    Client IP
    +
    @currIpv4
    +
  • +
  • +
    Browser Size
    +
    @($"{Width}x{Height}")
    +
  • +
+
+
+ +
+
+
+ +@code { + public int Height { get; set; } = 0; + public int Width { get; set; } = 0; + public string currIpv4 { get; set; } = ""; + + public class WindowDimension + { + public int Width { get; set; } + public int Height { get; set; } + } + protected async override Task OnAfterRenderAsync(bool firstRender) + { + //await Task.Delay(500); + if (firstRender) + { + await getWDim(); + StateHasChanged(); + Log.Debug($"Dimensioni schermo: {Width}x{Height}"); + } + } + protected async override Task OnInitializedAsync() + { + await Task.Delay(1); + if (string.IsNullOrEmpty(currIpv4)) + { + // ricalcolo e salvo... + if (httpContextAccessor.HttpContext != null) + { + var remoteIp = $"{httpContextAccessor.HttpContext.Connection?.RemoteIpAddress}"; + // provo a recuperare ipV4... + currIpv4 = EgwCoreLib.Razor.Data.IpUtils.getLocalIpv4(remoteIp); + } + } + } + protected async Task getWDim() + { + var dimension = await JSRuntime.InvokeAsync("getWindowDimensions"); + Height = dimension.Height; + Width = dimension.Width; + } + + + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); } + diff --git a/MP-TAB/MP-TAB/Program.cs b/MP-TAB/MP-TAB/Program.cs index 8228ff64..3f6b191e 100644 --- a/MP-TAB/MP-TAB/Program.cs +++ b/MP-TAB/MP-TAB/Program.cs @@ -20,6 +20,9 @@ builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddScoped(); + +builder.Services.AddHttpContextAccessor(); + // nuova versione contenuti... builder.Services.AddRazorComponents() .AddServerComponents() diff --git a/MP-TAB/MP-TAB/wwwroot/lib/WindowSize.js b/MP-TAB/MP-TAB/wwwroot/lib/WindowSize.js new file mode 100644 index 00000000..a8d2d770 --- /dev/null +++ b/MP-TAB/MP-TAB/wwwroot/lib/WindowSize.js @@ -0,0 +1,6 @@ +window.getWindowDimensions = function () { + return { + width: window.innerWidth, + height: window.innerHeight + }; +}; \ No newline at end of file