Code Smells from Pages/Acceuil
continuous-integration/drone/push Build is passing Details

master
tomivt 2 months ago
parent 0bead3de61
commit 04110bc503

@ -3,7 +3,7 @@
<PageTitle>Accueil</PageTitle> <PageTitle>Accueil</PageTitle>
<h2><strong>@Localizer["AccueilWelcome"]</strong></h2> <h2><strong>@Localizer["AccueilWelcome"] ?? "Bienvenue"</strong></h2>
<h4>@Localizer["AccueilTitle"]</h4> <h4>@Localizer["AccueilTitle"]</h4>

@ -31,22 +31,55 @@ namespace WF_WebAdmin.Pages
/// </summary> /// </summary>
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
Dailyquote = await Http.GetFromJsonAsync<Quote[]>($"{NavigationManager.BaseUri}fake-dataDailyQuote.json"); var url = $"{NavigationManager.BaseUri}fake-dataDailyQuote.json";
try
{
var response = await Http.GetFromJsonAsync<Quote[]>(url);
Dailyquote = response ?? Array.Empty<Quote>(); // Assurer qu'on ne stocke pas null
}
catch (Exception ex)
{
Console.WriteLine($"Erreur lors du chargement des citations : {ex.Message}");
Dailyquote = Array.Empty<Quote>(); // Éviter une exception en cas d'erreur réseau
}
} }
private async void RandomDailyquote() private async Task RandomDailyquote()
{ {
string _jsonFilePath = Path.Combine(Environment.CurrentDirectory, "wwwroot", "fake-dataDailyQuote.json"); try
Random random = new Random(); {
string _jsonFilePath = Path.Combine(Environment.CurrentDirectory, "wwwroot", "fake-dataDailyQuote.json");
Random random = new Random();
Quote[] quotes = await Http.GetFromJsonAsync<Quote[]>($"{NavigationManager.BaseUri}fake-dataQuote.json"); var response = await Http.GetFromJsonAsync<Quote[]>($"{NavigationManager.BaseUri}fake-dataQuote.json");
Quote[] quotes = response ?? Array.Empty<Quote>(); // Empêche null
Dailyquote = new Quote[] { quotes.OrderBy(x => random.Next()).First() }; if (quotes.Length > 0)
{
Dailyquote = new Quote[] { quotes.OrderBy(x => random.Next()).First() };
}
else
{
Console.WriteLine("Aucune citation disponible dans le fichier JSON.");
return;
}
var json = JsonSerializer.Serialize(Dailyquote, new JsonSerializerOptions { WriteIndented = true }); var json = JsonSerializer.Serialize(Dailyquote, new JsonSerializerOptions { WriteIndented = true });
await File.WriteAllTextAsync(_jsonFilePath, json); await File.WriteAllTextAsync(_jsonFilePath, json);
LoggerSaveStub.Log(Logger, LogLevel.Information, "Random change of quote of the day"); if (Logger != null)
{
LoggerSaveStub.Log(Logger, LogLevel.Information, "Random change of quote of the day");
}
else
{
Console.WriteLine("Logger non initialisé.");
}
}
catch (Exception ex)
{
Console.WriteLine($"Erreur dans RandomDailyquote: {ex.Message}");
}
} }
} }
} }

@ -16,7 +16,6 @@ namespace WF_WebAdmin.Pages
private List<User> users; private List<User> users;
private bool showDeletePopup = false;
private bool showModifyPopup = false; private bool showModifyPopup = false;
private User userToDelete = null; private User userToDelete = null;
private User selectedUser; private User selectedUser;
@ -164,7 +163,6 @@ namespace WF_WebAdmin.Pages
private void ClosePopup() private void ClosePopup()
{ {
// Set all popup visibility flags to false to hide the popups // Set all popup visibility flags to false to hide the popups
showDeletePopup = false; // Close the delete confirmation popup
showModifyPopup = false; // Close the modify confirmation popup showModifyPopup = false; // Close the modify confirmation popup
showPopupDelete = false; // Close any additional delete popups showPopupDelete = false; // Close any additional delete popups
showPopupAdmin = false; // Close the admin-related popup (if any) showPopupAdmin = false; // Close the admin-related popup (if any)

@ -1,4 +1,13 @@
@page "/" @*
File: _Host.cshtml
Project: WF_WebAdmin
Description: ...
Author: What The Fantasy
Created: 10/02/2025
Last Modified: 10/02/2025
*@
@page "/"
@namespace WF_WebAdmin.Pages @namespace WF_WebAdmin.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{ @{
@ -8,5 +17,5 @@
<component type="typeof(App)" render-mode="ServerPrerendered" /> <component type="typeof(App)" render-mode="ServerPrerendered" />
<body> <body>
<script src=https://cdn.syncfusion.com/blazor/22.1.38/syncfusion-blazor.min.js type="text/javascript"></script> <script src="https://cdn.syncfusion.com/blazor/22.1.38/syncfusion-blazor.min.js" type="text/javascript"></script>
</body> </body>

@ -1,4 +1,13 @@
@using Microsoft.AspNetCore.Components.Web @*
File: _Layout.cshtml
Project: WF_WebAdmin
Description: ...
Author: What The Fantasy
Created: 10/02/2025
Last Modified: 10/02/2025
*@
@using Microsoft.AspNetCore.Components.Web
@namespace WF_WebAdmin.Pages @namespace WF_WebAdmin.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

@ -1,98 +1,70 @@
[ [
{ {
"Id": 3, "Id": 3,
"Image": "https://tse4.mm.bing.net/th/id/OIP.XNQPKwc1OUfvnSO9MsxDYgHaE7?w=202\u0026h=180\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", "Image": "https://tse4.mm.bing.net/th/id/OIP.XNQPKwc1OUfvnSO9MsxDYgHaE7?w=202\u0026h=180\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7",
"Name": "testeur", "Name": "testeur",
"Email": "testeur@gmail.com", "Email": "testeur@gmail.com",
"DateCreation": "2024-08-02T00:00:00", "DateCreation": "2024-08-02T00:00:00",
"IsAdmin": false, "IsAdmin": false,
"Comments": [ "Comments": [
{ {
"Text": "Premier test effectu\u00E9, tout semble OK.", "Id": 0,
"DateCreation": "2024-08-02T00:00:00" "IdUser": 0,
} "DateCreation": "2024-08-02T00:00:00",
] "Text": "Premier test effectu\u00E9, tout semble OK."
}, }
{ ]
"Id": 4, },
"Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", {
"Name": "dev", "Id": 4,
"Email": "dev@gmail.com", "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7",
"DateCreation": "2024-10-10T00:00:00", "Name": "dev",
"IsAdmin": true, "Email": "dev@gmail.com",
"Comments": null "DateCreation": "2024-10-10T00:00:00",
}, "IsAdmin": true,
{ "Comments": null
"Id": 5, },
"Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", {
"Name": "jean_doe", "Id": 5,
"Email": "jean.doe@gmail.com", "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7",
"DateCreation": "2024-06-25T00:00:00", "Name": "jean_doe",
"IsAdmin": false, "Email": "jean.doe@gmail.com",
"Comments": [ "DateCreation": "2024-06-25T00:00:00",
{ "IsAdmin": false,
"Text": "Utilisateur tr\u00E8s actif, peut \u00EAtre un peu trop intrusif.", "Comments": [
"DateCreation": "2024-06-25T00:00:00" {
} "Id": 0,
] "IdUser": 0,
}, "DateCreation": "2024-06-25T00:00:00",
{ "Text": "Utilisateur tr\u00E8s actif, peut \u00EAtre un peu trop intrusif."
"Id": 7, }
"Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", ]
"Name": "test_n1", },
"Email": "admin.joe@gmail.com", {
"DateCreation": "2024-05-30T00:00:00", "Id": 7,
"IsAdmin": false, "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7",
"Comments": null "Name": "test_n1",
}, "Email": "admin.joe@gmail.com",
{ "DateCreation": "2024-05-30T00:00:00",
"Id": 8, "IsAdmin": false,
"Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", "Comments": null
"Name": "dev_anna", },
"Email": "dev.anna@gmail.com", {
"DateCreation": "2024-09-05T00:00:00", "Id": 10,
"IsAdmin": false, "Image": "https://th.bing.com/th/id/OIP.24T00MDK-RUhFnm1Do5PFwHaFj?w=229\u0026h=180\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7",
"Comments": null "Name": "dev_susan",
}, "Email": "dev.susan@gmail.com",
{ "DateCreation": "2024-08-12T00:00:00",
"Id": 9, "IsAdmin": false,
"Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", "Comments": null
"Name": "support_mark", },
"Email": "support.mark@gmail.com", {
"DateCreation": "2024-11-20T00:00:00", "Id": 12,
"IsAdmin": false, "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7",
"Comments": [ "Name": "admin_lucas",
{ "Email": "admin.lucas@gmail.com",
"Text": "Support rapide et efficace, mais manquant un peu de d\u00E9tails.", "DateCreation": "2024-09-22T00:00:00",
"DateCreation": "2024-11-20T00:00:00" "IsAdmin": false,
} "Comments": null
] }
},
{
"Id": 10,
"Image": "https://th.bing.com/th/id/OIP.24T00MDK-RUhFnm1Do5PFwHaFj?w=229\u0026h=180\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7",
"Name": "dev_susan",
"Email": "dev.susan@gmail.com",
"DateCreation": "2024-08-12T00:00:00",
"IsAdmin": false,
"Comments": null
},
{
"Id": 12,
"Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7",
"Name": "admin_lucas",
"Email": "admin.lucas@gmail.com",
"DateCreation": "2024-09-22T00:00:00",
"IsAdmin": false,
"Comments": null
},
{
"Id": 14,
"Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7",
"Name": "developer_mike",
"Email": "developer.mike@gmail.com",
"DateCreation": "2024-11-02T00:00:00",
"IsAdmin": false,
"Comments": null
}
] ]
Loading…
Cancel
Save