From d32eb0b686a399b5652b38b810102fd9f398a4d2 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Sat, 15 May 2021 16:17:43 +0200 Subject: [PATCH] Completato setup iniziale componenti (from BBM) --- MP-STATS/Components/CmpFooter.razor | 18 +++ MP-STATS/Components/CmpTop.razor | 52 ++++++++ MP-STATS/Components/DataPager.razor | 21 ++++ MP-STATS/Components/HomeButton.razor | 16 +++ MP-STATS/Components/SearchMod.razor | 41 +++++++ MP-STATS/Data/MessageService.cs | 86 +++++++++++++ MP-STATS/Pages/Index.razor | 47 ++++++- MP-STATS/Pages/_Host.cshtml | 2 + MP-STATS/Pages/_Host.cshtml.bak | 35 ++++++ MP-STATS/Shared/MainLayout.razor | 58 +++++++-- MP-STATS/Shared/MainLayout.razor.css | 34 +++++- MP-STATS/Shared/NavMenu.razor | 16 +-- MP-STATS/Shared/SurveyPrompt.razor | 16 --- MP-STATS/Startup.cs | 21 ++++ MP-STATS/Startup.cs.bak | 74 +++++++++++ MP-STATS/appsettings.Production.json | 13 ++ MP-STATS/appsettings.Staging.json | 13 ++ MP-STATS/appsettings.json | 20 +-- MP-STATS/appsettings.json.bak | 10 ++ MP-STATS/wwwroot/css/fonts.less | 24 ++++ MP-STATS/wwwroot/css/site.less | 175 +++++++++++++++++++++++++++ MP-STATS/wwwroot/img/LogoBlu.svg | 95 +++++++++++++++ MP-STATS/wwwroot/js/debounce.js | 5 + MP-STATS/wwwroot/js/external.js | 10 ++ 24 files changed, 854 insertions(+), 48 deletions(-) create mode 100644 MP-STATS/Components/CmpFooter.razor create mode 100644 MP-STATS/Components/CmpTop.razor create mode 100644 MP-STATS/Components/DataPager.razor create mode 100644 MP-STATS/Components/HomeButton.razor create mode 100644 MP-STATS/Components/SearchMod.razor create mode 100644 MP-STATS/Data/MessageService.cs create mode 100644 MP-STATS/Pages/_Host.cshtml.bak delete mode 100644 MP-STATS/Shared/SurveyPrompt.razor create mode 100644 MP-STATS/Startup.cs.bak create mode 100644 MP-STATS/appsettings.Production.json create mode 100644 MP-STATS/appsettings.Staging.json create mode 100644 MP-STATS/appsettings.json.bak create mode 100644 MP-STATS/wwwroot/css/fonts.less create mode 100644 MP-STATS/wwwroot/css/site.less create mode 100644 MP-STATS/wwwroot/img/LogoBlu.svg create mode 100644 MP-STATS/wwwroot/js/debounce.js create mode 100644 MP-STATS/wwwroot/js/external.js diff --git a/MP-STATS/Components/CmpFooter.razor b/MP-STATS/Components/CmpFooter.razor new file mode 100644 index 00000000..71530453 --- /dev/null +++ b/MP-STATS/Components/CmpFooter.razor @@ -0,0 +1,18 @@ +
+
+ MP-STATS v.@version +
+
+ @adesso +
+
+ powered by Egalware +
+
+ +@code { + protected DateTime adesso = DateTime.Now; + + Version version = typeof(Program).Assembly.GetName().Version; + +} \ No newline at end of file diff --git a/MP-STATS/Components/CmpTop.razor b/MP-STATS/Components/CmpTop.razor new file mode 100644 index 00000000..4128b284 --- /dev/null +++ b/MP-STATS/Components/CmpTop.razor @@ -0,0 +1,52 @@ +@using MP_STATS.Components +@using System.Security.Claims +@using Microsoft.AspNetCore.Components.Authorization + +@inject AuthenticationStateProvider AuthenticationStateProvider + +
+
+ @userName +
+
+
+
+ @if (ShowSearch) + { + + } +
+
+ +@code { + + [CascadingParameter(Name = "ShowSearch")] + private bool ShowSearch { get; set; } + + 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 = "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/MP-STATS/Components/DataPager.razor b/MP-STATS/Components/DataPager.razor new file mode 100644 index 00000000..8516e5d9 --- /dev/null +++ b/MP-STATS/Components/DataPager.razor @@ -0,0 +1,21 @@ +
+ +
+ + @*# record*@ +
+
+ +@code { + + [Parameter] + public int numRecord { get; set; } = 10; + + [Parameter] + public EventCallback numRecordChanged { get; set; } + + private async Task reportChange() + { + await numRecordChanged.InvokeAsync(numRecord); + } +} \ No newline at end of file diff --git a/MP-STATS/Components/HomeButton.razor b/MP-STATS/Components/HomeButton.razor new file mode 100644 index 00000000..a95e548a --- /dev/null +++ b/MP-STATS/Components/HomeButton.razor @@ -0,0 +1,16 @@ + + + @Descript + + +@code { + + [Parameter] + public string Icon { get; set; } + + [Parameter] + public string NavLink { get; set; } + + [Parameter] + public string Descript { get; set; } +} \ No newline at end of file diff --git a/MP-STATS/Components/SearchMod.razor b/MP-STATS/Components/SearchMod.razor new file mode 100644 index 00000000..85d0eb95 --- /dev/null +++ b/MP-STATS/Components/SearchMod.razor @@ -0,0 +1,41 @@ +@using MP_STATS.Components +@using MP_STATS.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 diff --git a/MP-STATS/Data/MessageService.cs b/MP-STATS/Data/MessageService.cs new file mode 100644 index 00000000..0ea09851 --- /dev/null +++ b/MP-STATS/Data/MessageService.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace MP_STATS.Data +{ + public class MessageService + { + #region Private Fields + + private string searchVal; + private bool showSearch; + + #endregion Private Fields + + #region Public Events + + public event Action EA_HideSearch; + + public event Action EA_SearchUpdated; + + public event Action EA_ShowSearch; + + #endregion Public Events + + #region Public Properties + + public string SearchVal + { + get => searchVal; + set + { + if (searchVal != value) + { + searchVal = value; + + if (EA_SearchUpdated != null) + { + EA_SearchUpdated?.Invoke(); + } + } + } + } + + public bool ShowSearch + { + get => showSearch; + set + { + if (showSearch != value) + { + showSearch = value; + if (showSearch) + { + if (EA_ShowSearch != null) + { + EA_ShowSearch?.Invoke(); + } + } + else + { + if (EA_HideSearch != null) + { + EA_HideSearch?.Invoke(); + } + } + } + } + } + + #endregion Public Properties + + #region Protected Methods + + protected void ReportSearch() + { + if (EA_SearchUpdated != null) + { + EA_SearchUpdated?.Invoke(); + } + } + + #endregion Protected Methods + } +} \ No newline at end of file diff --git a/MP-STATS/Pages/Index.razor b/MP-STATS/Pages/Index.razor index e54d9143..2762d330 100644 --- a/MP-STATS/Pages/Index.razor +++ b/MP-STATS/Pages/Index.razor @@ -1,7 +1,48 @@ @page "/" -

Hello, world!

+@using MP_STATS.Components +@using MP_STATS.Data -Welcome to your new app. +
+
+
+

MP STATS

+
+ Modulo Statistiche per MoonPro +
+
+
+
+ | | | | | | +
+
+
+
+
+
+
+
+
@Anno
+
+
+
+
+
+
+
+ + + + @**@ + + +
+
+
+
+
- +@code { + + private int Anno { get; set; } = DateTime.Today.Year; +} \ No newline at end of file diff --git a/MP-STATS/Pages/_Host.cshtml b/MP-STATS/Pages/_Host.cshtml index 0b5cdcf0..499c43d3 100644 --- a/MP-STATS/Pages/_Host.cshtml +++ b/MP-STATS/Pages/_Host.cshtml @@ -1,4 +1,6 @@ @page "/" +@using System.Globalization +@using Microsoft.AspNetCore.Localization @namespace MP_STATS.Pages @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @{ diff --git a/MP-STATS/Pages/_Host.cshtml.bak b/MP-STATS/Pages/_Host.cshtml.bak new file mode 100644 index 00000000..0b5cdcf0 --- /dev/null +++ b/MP-STATS/Pages/_Host.cshtml.bak @@ -0,0 +1,35 @@ +@page "/" +@namespace MP_STATS.Pages +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers +@{ + Layout = null; +} + + + + + + + MP-STATS + + + + + + + + +
+ + An error has occurred. This application may no longer respond until reloaded. + + + An unhandled exception has occurred. See browser dev tools for details. + + Reload + 🗙 +
+ + + + diff --git a/MP-STATS/Shared/MainLayout.razor b/MP-STATS/Shared/MainLayout.razor index 2281c4f7..0604e969 100644 --- a/MP-STATS/Shared/MainLayout.razor +++ b/MP-STATS/Shared/MainLayout.razor @@ -1,17 +1,59 @@ @inherits LayoutComponentBase +@using MP_STATS.Data +@using MP_STATS.Components +@inject MessageService MessageService +@implements IDisposable +
-
-
- About + +
+
+ +
+
+ @Body +
+
+ +
- -
- @Body -
-
+
+ +@code { + bool ShowSearch { get; set; } = false; + + protected override void OnInitialized() + { + MessageService.EA_ShowSearch += OnShowSearch; + MessageService.EA_HideSearch += OnHideSearch; + } + public void OnShowSearch() + { + ShowSearch = true; + InvokeAsync(() => + { + StateHasChanged(); + }); + } + public void OnHideSearch() + { + ShowSearch = false; + InvokeAsync(() => + { + StateHasChanged(); + }); + } + + public void Dispose() + { + MessageService.EA_ShowSearch -= OnShowSearch; + MessageService.EA_ShowSearch -= OnHideSearch; + } + +} \ No newline at end of file diff --git a/MP-STATS/Shared/MainLayout.razor.css b/MP-STATS/Shared/MainLayout.razor.css index 43c355a4..83f592d8 100644 --- a/MP-STATS/Shared/MainLayout.razor.css +++ b/MP-STATS/Shared/MainLayout.razor.css @@ -9,15 +9,15 @@ } .sidebar { - background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); + background-image: linear-gradient(180deg, rgb(5, 39, 103) 20%, #3aa6ff 90%); } .top-row { background-color: #f7f7f7; border-bottom: 1px solid #d6d5d5; - justify-content: flex-end; height: 3.5rem; - display: flex; + /*justify-content: space-evenly; + display: flex;*/ align-items: center; } @@ -31,6 +31,26 @@ text-overflow: ellipsis; } +.bottom-row { + color: #dedede; + background-color: #000000; + /*border-bottom: 1px solid #313131;*/ + /*justify-content: flex-end;*/ + height: 2rem; + /*display: flex;*/ + align-items: center; +} + + .bottom-row ::deep a, .top-row .btn-link { + white-space: nowrap; + margin-left: 1.5rem; + } + + .bottom-row a:first-child { + overflow: hidden; + text-overflow: ellipsis; + } + @media (max-width: 640.98px) { .top-row:not(.auth) { display: none; @@ -63,8 +83,14 @@ z-index: 1; } + .bottom-row { + position: fixed; + bottom: 0; + z-index: 1; + } + .main > div { padding-left: 2rem !important; padding-right: 1.5rem !important; } -} +} \ No newline at end of file diff --git a/MP-STATS/Shared/NavMenu.razor b/MP-STATS/Shared/NavMenu.razor index 0ce829a6..c7710983 100644 --- a/MP-STATS/Shared/NavMenu.razor +++ b/MP-STATS/Shared/NavMenu.razor @@ -12,14 +12,14 @@ Home + @**@ - @*