From 661d2580bca97496374323948c9075996bba9e44 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 20 Sep 2021 16:53:00 +0200 Subject: [PATCH] Cambio: home mostrata con componenti --- MP.Land/Components/HomeLink.razor | 86 +++++++++++++++++++++++++++++++ MP.Land/Components/UserCard.razor | 1 - MP.Land/Pages/Index.razor | 55 +------------------- MP.Land/Pages/Index.razor.cs | 26 ---------- 4 files changed, 87 insertions(+), 81 deletions(-) create mode 100644 MP.Land/Components/HomeLink.razor diff --git a/MP.Land/Components/HomeLink.razor b/MP.Land/Components/HomeLink.razor new file mode 100644 index 00000000..e8ca1aa0 --- /dev/null +++ b/MP.Land/Components/HomeLink.razor @@ -0,0 +1,86 @@ +@using MP.AppAuth.Models +@using MP.Land.Data +@using Microsoft.Extensions.Configuration + +@inject IConfiguration Configuration + +@inject AppAuthService DataService + +
+
+ @if (authOk()) + { + +

@CurrItem.AppName 

+
+ } + else + { + +

@CurrItem.AppName

+
+ } +
+
+
+ @if (authOk()) + { +
+ +
+
+ @(traduci($"{CurrItem.AppName}-TITLE")) +
    + @(traduci($"{CurrItem.AppName}-LIST")) +
+
+ } + else + { +
+ +
+
+ @(traduci($"{CurrItem.AppName}-TITLE")) +
    + @(traduci($"{CurrItem.AppName}-LIST")) +
+
+ } +
+
+ +
+@code { + + [Parameter] + public UpdMan CurrItem { get; set; } + + protected bool authOk() + { + bool answ = !string.IsNullOrEmpty(CurrItem.LicenseKey) && Convert.ToBoolean(CurrItem.IsAuth); + return answ; + } + + protected string fullUrl(string relUrl) + { + return $"{Configuration["BaseUrl"]}{relUrl}"; + } + + protected MarkupString traduci(string lemma) + { + MarkupString answ; + string rawHtml = DataService.Traduci(lemma, "IT"); + answ = new MarkupString(rawHtml); + return answ; + } +} \ No newline at end of file diff --git a/MP.Land/Components/UserCard.razor b/MP.Land/Components/UserCard.razor index e758614f..6e0b7852 100644 --- a/MP.Land/Components/UserCard.razor +++ b/MP.Land/Components/UserCard.razor @@ -21,7 +21,6 @@
- @*Image 12345*@
diff --git a/MP.Land/Pages/Index.razor b/MP.Land/Pages/Index.razor index d3605e12..6c3b2895 100644 --- a/MP.Land/Pages/Index.razor +++ b/MP.Land/Pages/Index.razor @@ -40,60 +40,7 @@ @foreach (var item in ListRecords) {
-
-
- @if (authOk(item)) - { - -

@item.AppName 

-
- } - else - { - -

@item.AppName

-
- } -
-
-
- @if (authOk(item)) - { -
- -
-
- @(traduci($"{item.AppName}-TITLE")) -
    - @(traduci($"{item.AppName}-LIST")) -
-
- } - else - { -
- -
-
- @(traduci($"{item.AppName}-TITLE")) -
    - @(traduci($"{item.AppName}-LIST")) -
-
- } -
-
- -
+
}
diff --git a/MP.Land/Pages/Index.razor.cs b/MP.Land/Pages/Index.razor.cs index eddd4477..a5c69119 100644 --- a/MP.Land/Pages/Index.razor.cs +++ b/MP.Land/Pages/Index.razor.cs @@ -26,9 +26,6 @@ namespace MP.Land.Pages #region Private Properties - [Inject] - private IConfiguration Configuration { get; set; } - private bool isLoading { get; set; } = false; #endregion Private Properties @@ -45,24 +42,11 @@ namespace MP.Land.Pages #region Protected Methods - protected bool authOk(UpdMan currItem) - { - bool answ = !string.IsNullOrEmpty(currItem.LicenseKey) && Convert.ToBoolean(currItem.IsAuth); - return answ; - } - - protected string fullUrl(string relUrl) - { - return $"{Configuration["BaseUrl"]}{relUrl}"; - } - protected override void OnInitialized() { AppMService.ShowSearch = false; AppMService.PageName = "Home"; AppMService.PageIcon = "fas fa-home pr-2"; - //AppMService.EA_SearchUpdated += OnSeachUpdated; - //AppMService.EA_FilterUpdated += OnFilterUpdated; } protected override async Task OnInitializedAsync() @@ -87,16 +71,6 @@ namespace MP.Land.Pages await Task.Delay(1); } - protected MarkupString traduci(string lemma) - { - MarkupString answ; - //string rawHtml = "
  • primo
  • secondo
  • "; - string rawHtml = DataService.Traduci(lemma, "IT"); - answ = new MarkupString(rawHtml); - // cerco nella cache Redis - return answ; - } - #endregion Protected Methods } } \ No newline at end of file