diff --git a/LiMan.UI/Components/CmpFooter.razor b/LiMan.UI/Components/CmpFooter.razor new file mode 100644 index 0000000..e85aaf3 --- /dev/null +++ b/LiMan.UI/Components/CmpFooter.razor @@ -0,0 +1,16 @@ +
+
+ GWMS v.@version +
+
+ @adesso + Egalware +
+
+ +@code { + protected DateTime adesso = DateTime.Now; + + Version version = typeof(Program).Assembly.GetName().Version; + +} \ No newline at end of file diff --git a/LiMan.UI/Components/CmpTop.razor b/LiMan.UI/Components/CmpTop.razor new file mode 100644 index 0000000..436c6a1 --- /dev/null +++ b/LiMan.UI/Components/CmpTop.razor @@ -0,0 +1,80 @@ +@using LiMan.UI.Components +@using System.Security.Claims +@using Microsoft.AspNetCore.Components.Authorization +@using LiMan.UI.Data + +@inject MessageService AppMessages +@inject AuthenticationStateProvider AuthenticationStateProvider + +
+
+ @**@ +
+
+ @PageName +
+
+ @if (ShowSearch) + { + + } +
+
+ +@code { + + [CascadingParameter] + private Task AuthenticationStateTask { get; set; } + + [CascadingParameter(Name = "ShowSearch")] + private bool ShowSearch { get; set; } + + private string userName = ""; + + private string PageName { get; set; } + private string PageIcon { get; set; } + + protected override async Task OnInitializedAsync() + { + await forceReload(); + } + + protected override void OnInitialized() + { + AppMessages.EA_PageUpdated += OnPageUpdate; + } + public void OnPageUpdate() + { + PageName = AppMessages.PageName; + PageIcon = AppMessages.PageIcon; + InvokeAsync(() => + { + StateHasChanged(); + }); + } + + public void Dispose() + { + AppMessages.EA_PageUpdated -= OnPageUpdate; + } + + private async Task forceReload() + { + + var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + var user = authState.User; + + if (user.Identity.IsAuthenticated) + { + userName = $"{user.Identity.Name}"; + } + else + { + userName = "N.A."; + } + } +} + +@* // Vedere anche: + // https://docs.microsoft.com/en-us/aspnet/core/blazor/security/?view=aspnetcore-5.0#:~:text=Blazor%20uses%20the%20existing%20ASP.NET%20Core%20authentication%20mechanisms,all%20client-side%20code%20can%20be%20modified%20by%20users + // https://docs.microsoft.com/en-us/aspnet/core/blazor/security/?view=aspnetcore-5.0*@ \ No newline at end of file diff --git a/LiMan.UI/Components/DataPager.razor b/LiMan.UI/Components/DataPager.razor new file mode 100644 index 0000000..3d577d1 --- /dev/null +++ b/LiMan.UI/Components/DataPager.razor @@ -0,0 +1,56 @@ +
+
+
+
+ @if (totalCount > 0) + { +
    +
  • +
  • + @for (int i = @startPage; i <= endPage; ++i) + { + var pageNum = i; +
  • + } +
  • +
  • +
+ } +
+
+
+
+ @if (showLoading) + { +
+
+
+ } +
+
+
+
+
+
+ @if (!showLoading) + { + @totalCount records + } +
+
+ @if (totalCount > 0) + { +
+ +
+ } +
+
+
+
\ No newline at end of file diff --git a/LiMan.UI/Components/DataPager.razor.cs b/LiMan.UI/Components/DataPager.razor.cs new file mode 100644 index 0000000..99fe3f2 --- /dev/null +++ b/LiMan.UI/Components/DataPager.razor.cs @@ -0,0 +1,193 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components; +using LiMan.UI.Components; +using LiMan.UI.Data; + +namespace LiMan.UI.Components +{ + public partial class DataPager : ComponentBase + { + #region Protected Fields + + protected bool _showLoading = false; + + #endregion Protected Fields + + #region Private Properties + + private int endPage + { + get + { + int answ = (int)(currPage / numPages) * numPages + numPages; + answ = answ < LastPage ? answ : LastPage; + return answ; + } + } + + private int LastPage + { + get + { + return Math.Max((int)Math.Ceiling(totalCount / (double)PageSize), 1); + } + } + + private int nextBlock + { + get + { + int answ = currPage + numPages; + answ = answ < LastPage ? answ : LastPage; + return answ; + } + } + + private int numPages { get; set; } = 10; + + private int prevBlock + { + get + { + int answ = currPage - numPages; + answ = answ > 0 ? answ : 1; + return answ; + } + } + + // calcola un set 1 .. numPages centrato sulla pagina corrente... + private int startPage + { + get + { + int answ = (int)(currPage / numPages) * numPages; + answ = answ > 0 ? answ : 1; + return answ; + } + } + + #endregion Private Properties + + #region Protected Properties + + protected int _numPage { get; set; } = 1; + + protected int _numRecord { get; set; } = 10; + + protected int percLoading { get; set; } = 0; + + #endregion Protected Properties + + #region Public Properties + + [Parameter] + public int currPage + { + get + { + return _numPage; + } + set + { + bool doReport = !_numPage.Equals(value); + if (doReport) + { + _numPage = value; + reportChangePage(); + } + } + } + + [Parameter] + public EventCallback numPageChanged { get; set; } + + [Parameter] + public EventCallback numRecordChanged { get; set; } + + [Parameter] + public int PageSize + { + get + { + return _numRecord; + } + set + { + bool doReport = !_numRecord.Equals(value); + if (doReport) + { + _numRecord = value; + reportChange(); + } + } + } + + [Parameter] + public bool showLoading + { + get + { + return _showLoading; + } + set + { + if (value) + { + Random random = new Random(); + percLoading = random.Next(30, 90); + } + else + { + percLoading = 5; + } + _showLoading = value; + } + } + + [Parameter] + public int totalCount { get; set; } = 0; + + #endregion Public Properties + + #region Private Methods + + private void reportChange() + { + numRecordChanged.InvokeAsync(PageSize); + } + + private void reportChangePage() + { + numPageChanged.InvokeAsync(currPage); + } + + #endregion Private Methods + + #region Protected Methods + + protected string cssActive(int numPage) + { + string answ = ""; + if (numPage == currPage) + { + answ = "active"; + } + return answ; + } + + protected override async Task OnInitializedAsync() + { + await Task.Run(() => showLoading = false); + } + + protected void PaginationItemClick(int page) + { + currPage = page; + } + + #endregion Protected Methods + } +} \ No newline at end of file diff --git a/LiMan.UI/Components/LoadingData.razor b/LiMan.UI/Components/LoadingData.razor new file mode 100644 index 0000000..2aa1799 --- /dev/null +++ b/LiMan.UI/Components/LoadingData.razor @@ -0,0 +1,7 @@ +@*

Working

*@ +
+
+

loading data

+ +
+
\ No newline at end of file diff --git a/LiMan.UI/Components/LoginDisplay.razor b/LiMan.UI/Components/LoginDisplay.razor new file mode 100644 index 0000000..c840f5c --- /dev/null +++ b/LiMan.UI/Components/LoginDisplay.razor @@ -0,0 +1,61 @@ +@using Microsoft.AspNetCore.Components.Authorization + +@inject AuthenticationStateProvider AuthenticationStateProvider + + + + + + +
+
+ +
+
+  @userName +
+
+
+
+ +@code{ + + private string userName = ""; + protected override async Task OnInitializedAsync() + { + await forceReload(); + } + private async Task forceReload() + { + + var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + var user = authState.User; + + if (user.Identity.IsAuthenticated) + { + userName = $"{user.Identity.Name}"; + } + else + { + userName = "Non Autenticato"; + } + } + + protected string StringLim(string original, int maxLen) + { + return original.Length <= maxLen ? original : $"{original.Substring(0, maxLen - 3)}..."; + } + +} \ No newline at end of file diff --git a/LiMan.UI/Components/SearchMod.razor b/LiMan.UI/Components/SearchMod.razor new file mode 100644 index 0000000..5250642 --- /dev/null +++ b/LiMan.UI/Components/SearchMod.razor @@ -0,0 +1,41 @@ +@using LiMan.UI.Components +@using LiMan.UI.Data +@inject MessageService MessageService + +
+ +
+ +
+
+ +@code { + + [Parameter] + public EventCallback searchUpdated { get; set; } + + [Parameter] + public string searchVal + { + get + { + return MessageService.SearchVal; + } + set + { + MessageService.SearchVal = value; + reportChange(); + } + } + + private void reportChange() + { + searchUpdated.InvokeAsync(searchVal); + } + + private void reset() + { + searchVal = ""; + } + +} \ No newline at end of file