From d378a0fc7df9331eefd1dc3cf5409c0bf82f8368 Mon Sep 17 00:00:00 2001 From: Enzo JOLYS Date: Wed, 14 Dec 2022 17:33:09 +0100 Subject: [PATCH] tmp --- .../Controllers/CraftingController.cs | 10 +++ Minecraft.Crafting.Api/Data/musique.json | 2 +- .../Minecraft.Crafting.Api.csproj | 5 ++ Minecraft.Crafting.Api/Program.cs | 6 ++ ProjetBlazor/Pages/CreateLog.razor | 5 ++ ProjetBlazor/Pages/CreateLog.razor.cs | 21 ++++++ ProjetBlazor/Pages/Edit.razor.cs | 68 ------------------- ProjetBlazor/Pages/MusiquesListe.razor | 21 +++++- ProjetBlazor/Program.cs | 3 + ...FR.resx => Pages.MusiquesListe.fr-FR.resx} | 3 + ...uesListe.resx => Pages.MusiquesListe.resx} | 0 ProjetBlazor/Shared/MainLayout.razor | 2 +- ProjetBlazor/wwwroot/appsettings.json | 19 ++++++ 13 files changed, 92 insertions(+), 73 deletions(-) create mode 100644 ProjetBlazor/Pages/CreateLog.razor create mode 100644 ProjetBlazor/Pages/CreateLog.razor.cs rename ProjetBlazor/Resources/{MusiquesListe.fr-FR.resx => Pages.MusiquesListe.fr-FR.resx} (98%) rename ProjetBlazor/Resources/{MusiquesListe.resx => Pages.MusiquesListe.resx} (100%) create mode 100644 ProjetBlazor/wwwroot/appsettings.json diff --git a/Minecraft.Crafting.Api/Controllers/CraftingController.cs b/Minecraft.Crafting.Api/Controllers/CraftingController.cs index a0f0c6f..1d6ac43 100644 --- a/Minecraft.Crafting.Api/Controllers/CraftingController.cs +++ b/Minecraft.Crafting.Api/Controllers/CraftingController.cs @@ -10,6 +10,8 @@ namespace Minecraft.Crafting.Api.Controllers [Route("api/[controller]")] public class CraftingController : ControllerBase { + public IWebHostEnvironment WebHostEnvironment { get; set; } + private readonly JsonSerializerOptions _jsonSerializerOptions = new() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, @@ -75,6 +77,14 @@ namespace Minecraft.Crafting.Api.Controllers return Task.FromResult(item); } + [HttpGet] + [Route("image")] + public Task GetImage(String nameImage) + { + var image = File.Exists($"{WebHostEnvironment.WebRootPath}/Data/images/{nameImage}"); + return null; + } + [HttpGet] [Route("recipe")] public Task> GetRecipe() diff --git a/Minecraft.Crafting.Api/Data/musique.json b/Minecraft.Crafting.Api/Data/musique.json index dba8f84..df19145 100644 --- a/Minecraft.Crafting.Api/Data/musique.json +++ b/Minecraft.Crafting.Api/Data/musique.json @@ -41,7 +41,7 @@ "auteur": "armor", "duree": 1653, "genre": "acacia_planks", - "image": "UklGRjYHAABXRUJQVlA4ICoHAABwNwCdASoEARgBPjEYi0QiIaERytSIIAMEtLdwufsgDVzSoPPvYn/gPxv6zPxp6ecYF5z7AfZuE3eHfx3\u002Ba/lL/R/Mz7eYAH49/KP5t\u002BUX9s/brpb7zP8n/pf5S/1Xni\u002B8PYA/mH87/uX5I/1r5A/37\u002B0fuF/e/dn88f4P\u002B3fuB/b/sB/iv8h/u39q/wv\u002B7/t////8nkW/W72P/08CqsqWNhgTsgJ2QE7ICdkBOyAnZATsgJ2QE7ICaIaLhx3g47wblCdS/9tGWU/xzEnemwwJ2PjjHNO9TuNfQ2BiHHeDjtAwyVOGwAqKB3esqV6ImXz8bvfSGjouQBSQE7IBQLmODqxrtrk3x2gF2bhJATsgFayma7LSHiLJoypw/9lY1sP946Z3G1pkgE2rL57nLi4sbCcOacJ6iLKlhWUGgvpXdNoCO3hLaGCpL5C62/Ia8rfzFJATsgJ2QE7ICdkBOyAnZATsgJ2QE7ICdK7GcyXAU2QhQkJoPgR40AilD/WJoQsS03xGVA09MlKegs4SO1fw95uk9Iw0NMEOULQgSxJwDH5DQh3VIAQORANLCkQwWLGdKsuBN0E/t9ipgASdgVRRL7r1MAD\u002B/59IABwRoCH3ot42c9RcG9s7mobP0nxPxsKNVBk5xgFRSuSpj9zGfv\u002B\u002Bsev\u002BvSUinZ9OFhF439/576vzfR7nwuyv7YcLBnUbCw9WzfjUmE2LDCVU5P2TLq6eLAMhzn18800Pv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ugrUUQ/GQQv6dOd6LY1tsi00/s8ZeUmdXEK\u002B4Scv3sO/uks/f/b/84XvZeq0oiAUf2u9Tpc1\u002BUQipIlhxWMlPhbonWKs8Ume5CA0ltWK967\u002B5XuAcQxonvvX/nuiGL/9GQ8iydenfwgNIPH4tmLYz01FbB/vAAf/nVD4Xk44GPlYL3tjNYYssidDIZ7TD0YBc78DMfD5Q504933IgqhFZOZovZXcyjaGx19qU75VVpPx5z89hhAH0c0sNpqDLc7\u002BmdjqgCUFTjS5sZF6PVrKlqwwq8GJIQeKeNgtTy3T5fRDYFbOvDE71ZLvpjDNBTh6DPtcUgdcFvZCExUzspaDhVGD3pU/Lvl0bSzuaNRGrQy1BP8YLk3fUoLyCREh5BVhLm\u002Bz9vCLFGhIqYCyKDmn/mAeIbvfiebp83YSrqubtsESyhnYEdM\u002BOeKMo2EJcWyimVCu5Wz1sxwJ1Wue3wAHxO07rNLX0WtIbhfH/1CjJHQCIdhTtTJqk7p/zs1Zm\u002Bh0/whZ//u320SCHelgPN1OEKmZWk/qki1ZiR4\u002B8O3QKbfNyRKxmNW5UaTx5G9UW1ih6kcMYH6Zy4DukhYiRvUFbM84DjE\u002BWPmXx2Pj\u002Bor2jFE1M8o7uU\u002BcGrcaRQ069wr4WEiNssne/AhjtGnzRFAGl/dshGtxCj/sk0X50ZnPTwTd9igYdz04tpjUbgAAA", + "image": "default.png", "date": "1989-01-11T00:00:00" }, { diff --git a/Minecraft.Crafting.Api/Minecraft.Crafting.Api.csproj b/Minecraft.Crafting.Api/Minecraft.Crafting.Api.csproj index 9538b55..83a91e5 100644 --- a/Minecraft.Crafting.Api/Minecraft.Crafting.Api.csproj +++ b/Minecraft.Crafting.Api/Minecraft.Crafting.Api.csproj @@ -17,4 +17,9 @@ + + + + + diff --git a/Minecraft.Crafting.Api/Program.cs b/Minecraft.Crafting.Api/Program.cs index 48863a6..1ce8d54 100644 --- a/Minecraft.Crafting.Api/Program.cs +++ b/Minecraft.Crafting.Api/Program.cs @@ -22,4 +22,10 @@ app.UseAuthorization(); app.MapControllers(); +app.UseStaticFiles(new StaticFileOptions +{ + RequestPath = "/data", + +}); + app.Run(); diff --git a/ProjetBlazor/Pages/CreateLog.razor b/ProjetBlazor/Pages/CreateLog.razor new file mode 100644 index 0000000..89c8922 --- /dev/null +++ b/ProjetBlazor/Pages/CreateLog.razor @@ -0,0 +1,5 @@ +@page "/logs" + +

CreateLog

+ + \ No newline at end of file diff --git a/ProjetBlazor/Pages/CreateLog.razor.cs b/ProjetBlazor/Pages/CreateLog.razor.cs new file mode 100644 index 0000000..c4a3c1b --- /dev/null +++ b/ProjetBlazor/Pages/CreateLog.razor.cs @@ -0,0 +1,21 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.Logging; + +namespace ProjetBlazor.Pages +{ + public partial class CreateLog + { + [Inject] + public ILogger Logger { get; set; } + + private void CreateLogs() + { + var logLevels = Enum.GetValues(typeof(LogLevel)).Cast(); + + foreach (var logLevel in logLevels.Where(l => l != LogLevel.None)) + { + Logger.Log(logLevel, $"Log message for the level: {logLevel}"); + } + } + } +} diff --git a/ProjetBlazor/Pages/Edit.razor.cs b/ProjetBlazor/Pages/Edit.razor.cs index 225bf68..0611e27 100644 --- a/ProjetBlazor/Pages/Edit.razor.cs +++ b/ProjetBlazor/Pages/Edit.razor.cs @@ -22,74 +22,6 @@ namespace ProjetBlazor.Pages [Inject] public IDataService DataService { get; set; } - /* - [Inject] - public NavigationManager NavigationManager { get; set; } - */ - - /* - [Inject] - public IWebHostEnvironment WebHostEnvironment { get; set; } - */ - /* - protected override async Task OnInitializedAsync() - { - var item = await DataService.GetById(Id); - - var fileContent = await File.ReadAllBytesAsync($"{WebHostEnvironment.WebRootPath}/images/default.png"); - - if (File.Exists($"{WebHostEnvironment.WebRootPath}/images/{itemModel.Name}.png")) - { - fileContent = await File.ReadAllBytesAsync($"{WebHostEnvironment.WebRootPath}/images/{item.Name}.png"); - } - - // Set the model with the item - itemModel = ItemFactory.ToModel(item, fileContent); - } - - private async void HandleValidSubmit() - { - await DataService.Update(Id, itemModel); - - NavigationManager.NavigateTo("list"); - } - - private void OnEnchantCategoriesChange(string item, object checkedValue) - { - if ((bool)checkedValue) - { - if (!itemModel.EnchantCategories.Contains(item)) - { - itemModel.EnchantCategories.Add(item); - } - - return; - } - - if (itemModel.EnchantCategories.Contains(item)) - { - itemModel.EnchantCategories.Remove(item); - } - } - - private void OnRepairWithChange(string item, object checkedValue) - { - if ((bool)checkedValue) - { - if (!itemModel.RepairWith.Contains(item)) - { - itemModel.RepairWith.Add(item); - } - - return; - } - - if (itemModel.RepairWith.Contains(item)) - { - itemModel.RepairWith.Remove(item); - } - } - */ private async void HandleValidSubmit() { diff --git a/ProjetBlazor/Pages/MusiquesListe.razor b/ProjetBlazor/Pages/MusiquesListe.razor index 4567b93..b11daf1 100644 --- a/ProjetBlazor/Pages/MusiquesListe.razor +++ b/ProjetBlazor/Pages/MusiquesListe.razor @@ -18,7 +18,22 @@ ShowPager Responsive> - - - + + + @if (File.Exists($"{WebHostEnvironment.WebRootPath}/images/{context.image}.png")) + { + + } + else + { + + } + + + + + + + + \ No newline at end of file diff --git a/ProjetBlazor/Program.cs b/ProjetBlazor/Program.cs index a57014e..4068dea 100644 --- a/ProjetBlazor/Program.cs +++ b/ProjetBlazor/Program.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Localization; using Microsoft.Extensions.Options; using ProjetBlazor.Services; using System.Globalization; +using Microsoft.Extensions.Logging; var builder = WebApplication.CreateBuilder(args); @@ -27,6 +28,8 @@ builder.Services.AddControllers(); // Add the localization to the app and specify the resources path builder.Services.AddLocalization(opts => { opts.ResourcesPath = "Resources"; }); +builder.Logging.AddConfiguration(builder.Configuration.GetSection("Logging")); + // Configure the localtization builder.Services.Configure(options => { diff --git a/ProjetBlazor/Resources/MusiquesListe.fr-FR.resx b/ProjetBlazor/Resources/Pages.MusiquesListe.fr-FR.resx similarity index 98% rename from ProjetBlazor/Resources/MusiquesListe.fr-FR.resx rename to ProjetBlazor/Resources/Pages.MusiquesListe.fr-FR.resx index 26c3d8d..bb82739 100644 --- a/ProjetBlazor/Resources/MusiquesListe.fr-FR.resx +++ b/ProjetBlazor/Resources/Pages.MusiquesListe.fr-FR.resx @@ -120,4 +120,7 @@ Ma playlist + + Titre + \ No newline at end of file diff --git a/ProjetBlazor/Resources/MusiquesListe.resx b/ProjetBlazor/Resources/Pages.MusiquesListe.resx similarity index 100% rename from ProjetBlazor/Resources/MusiquesListe.resx rename to ProjetBlazor/Resources/Pages.MusiquesListe.resx diff --git a/ProjetBlazor/Shared/MainLayout.razor b/ProjetBlazor/Shared/MainLayout.razor index 91aff6c..12b2ed0 100644 --- a/ProjetBlazor/Shared/MainLayout.razor +++ b/ProjetBlazor/Shared/MainLayout.razor @@ -8,7 +8,7 @@
-
+
diff --git a/ProjetBlazor/wwwroot/appsettings.json b/ProjetBlazor/wwwroot/appsettings.json new file mode 100644 index 0000000..5b0788e --- /dev/null +++ b/ProjetBlazor/wwwroot/appsettings.json @@ -0,0 +1,19 @@ +{ + "Logging": { + "LogLevel": { // All providers, LogLevel applies to all the enabled providers. + "Default": "Error", // Default logging, Error and higher. + "Microsoft": "Warning" // All Microsoft* categories, Warning and higher. + }, + "Debug": { // Debug provider. + "LogLevel": { + "Default": "Information", // Overrides preceding LogLevel:Default setting. + "Microsoft.Hosting": "Trace" // Debug:Microsoft.Hosting category. + } + }, + "EventSource": { // EventSource provider + "LogLevel": { + "Default": "Warning" // All categories of EventSource provider. + } + } + } +}