ça ne marche pas mais je n'y arrive pas tant pis au moins la page est propre
continuous-integration/drone/push Build is passing Details

master
Maxime ROCHER 2 months ago
parent 67b4094d81
commit f6bd5d2fc1

@ -10,10 +10,16 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>

@ -0,0 +1,23 @@
using System;
using System.Text.Json.Serialization;
namespace WF_WebAdmin.Converter
{
public class CommentaryDTO
{
[JsonPropertyName("id_comment")]
public int Id { get; set; }
[JsonPropertyName("quote")]
public int Quote { get; set; }
[JsonPropertyName("users")]
public int IdUser { get; set; }
[JsonPropertyName("dateC")]
public string DateCreationRaw { get; set; } = string.Empty;
[JsonPropertyName("comment")]
public string Text { get; set; } = string.Empty;
}
}

@ -0,0 +1,46 @@
using System;
using System.Globalization;
using WF_WebAdmin.Converter;
namespace WF_WebAdmin.Model
{
public static class CommentaryExtensions
{
public static Commentary ToModel(this CommentaryDTO dto)
{
DateTime parsedDate = DateTime.MinValue;
if (!string.IsNullOrEmpty(dto.DateCreationRaw) &&
DateTime.TryParseExact(dto.DateCreationRaw, "yyyy-MM-dd",
CultureInfo.InvariantCulture,
DateTimeStyles.None,
out DateTime result))
{
parsedDate = result;
}
else
{
Console.Out.WriteLine($"Erreur de conversion de la date : {dto.DateCreationRaw}");
}
return new Commentary
{
Id = dto.Id,
IdUser = dto.IdUser,
DateCreation = parsedDate,
Text = dto.Text
};
}
public static CommentaryDTO ToDTO(this Commentary model)
{
return new CommentaryDTO
{
Id = model.Id,
IdUser = model.IdUser,
DateCreationRaw = model.DateCreation.ToString("yyyy-MM-dd"),
Text = model.Text
};
}
}
}

@ -1,10 +1,12 @@
namespace WF_WebAdmin.Model
using System;
namespace WF_WebAdmin.Model
{
public class Commentary
{
//public int Id { get; set; }
//public int IdUser { get; set; }
public string Text { get; set; }
public int Id { get; set; }
public int IdUser { get; set; }
public DateTime DateCreation { get; set; }
public string Text { get; set; } = string.Empty;
}
}

@ -0,0 +1,17 @@
@page "/commentary-chart"
@using MudBlazor
<MudCard Class="p-4">
<MudCardContent>
<h3 class="text-center mb-4">Statistiques des Commentaires - Année @SelectedYear</h3>
<MudSelect T="int" Label="Sélectionner l'année" @bind-SelectedValue="SelectedYear" Dense="true" Immediate="true" OnValueChanged="UpdateChartData">
@foreach (var year in AvailableYears)
{
<MudSelectItem T="int" Value="@year">@year</MudSelectItem>
}
</MudSelect>
<MudChart ChartType="ChartType.Bar" Labels="@Labels" Data="@ChartData" />
</MudCardContent>
</MudCard>

@ -0,0 +1,72 @@
using Microsoft.AspNetCore.Components;
using MudBlazor;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using WF_WebAdmin.Model;
using WF_WebAdmin.Service;
namespace WF_WebAdmin.Pages
{
public partial class CommentaryChart : ComponentBase
{
[Inject] public ICommentaryService CommentaryService { get; set; } = default!;
public List<string> Labels { get; set; } = new();
public List<double[]> ChartData { get; set; } = new();
public List<int> AvailableYears { get; set; } = new();
public int SelectedYear { get; set; }
private List<Commentary> AllComments = new();
protected override async Task OnInitializedAsync()
{
// Charger tous les commentaires
AllComments = await CommentaryService.GetCommentsAsync();
if (!AllComments.Any())
{
Labels = new List<string> { "Aucun commentaire" };
ChartData = new List<double[]> { new double[] { 0 } };
return;
}
AvailableYears = AllComments
.Select(c => c.DateCreation.Year)
.Distinct()
.OrderBy(y => y)
.ToList();
SelectedYear = AvailableYears.Max();
UpdateChartData(SelectedYear);
}
private void UpdateChartData(int newYear)
{
SelectedYear = newYear;
var filteredComments = AllComments
.Where(c => c.DateCreation.Year == SelectedYear)
.ToList();
if (!filteredComments.Any())
{
Labels = new List<string> { "Aucun commentaire" };
ChartData = new List<double[]> { new double[] { 0 } };
return;
}
var grouped = Enumerable.Range(1, 12)
.ToDictionary(
month => new DateTime(SelectedYear, month, 1).ToString("MMMM", CultureInfo.InvariantCulture),
month => filteredComments.Count(c => c.DateCreation.Month == month)
);
Labels = grouped.Keys.ToList();
ChartData = new List<double[]> { grouped.Values.Select(v => (double)v).ToArray() };
}
}
}

@ -13,6 +13,8 @@ using Microsoft.Extensions.Options;
using Blazored.Modal;
using WF_WebAdmin.Service;
using Microsoft.Extensions.Logging;
using MudBlazor.Services;
[assembly: RootNamespace("WF_WebAdmin")]
@ -24,10 +26,10 @@ builder.Services.AddSingleton<WeatherForecastService>();
builder.Services.AddScoped<IQuoteService,QuoteServiceStub>();
builder.Services.AddScoped<IQuizService,QuizServiceStub>();
builder.Services.AddScoped<IUserService, UserServiceStub>();
builder.Services.AddScoped<ICommentaryService, CommentaryServiceStub>();
builder.Services.AddHttpClient();
builder.Services.AddScoped<UserLogin>();
//builder.WebHost.UseUrls("http://0.0.0.0:5000");
builder.Services.AddMudServices();
builder.Logging.AddConfiguration(builder.Configuration.GetSection("Logging"));
builder.Services

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
using System.Threading.Tasks;
using WF_WebAdmin.Converter;
using WF_WebAdmin.Model;
namespace WF_WebAdmin.Service
{
public class CommentaryServiceStub : ICommentaryService
{
private readonly string? _jsonFilePath = Path.Combine(Environment.CurrentDirectory, "wwwroot", "fake-dataCommentary.json");
public async Task<List<Commentary>> GetCommentsAsync()
{
if (!File.Exists(_jsonFilePath))
{
Console.Out.WriteLine($"{_jsonFilePath} not found");
return new List<Commentary>();
}
var json = await File.ReadAllTextAsync(_jsonFilePath);
var dtoList = JsonSerializer.Deserialize<List<CommentaryDTO>>(json) ?? new List<CommentaryDTO>();
var comments = dtoList.ConvertAll(dto => dto.ToModel());
Console.Out.WriteLine($"Nombre de commentaires chargés : {comments.Count}");
return comments;
}
}
}

@ -0,0 +1,11 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using WF_WebAdmin.Model;
namespace WF_WebAdmin.Service
{
public interface ICommentaryService
{
Task<List<Commentary>> GetCommentsAsync();
}
}

@ -10,17 +10,17 @@ namespace WF_WebAdmin.Service;
private readonly string _src = Path.Combine(Environment.CurrentDirectory, "wwwroot", "fake-dataSource.json");
/// <summary>
/// Asynchronously saves a list of quotes to a JSON file.
/// </summary>
/// <param name="quotes">The list of <see cref="Quote"/> objects to be serialized and saved to the file.</param>
/// <returns>A task representing the asynchronous operation of saving the quotes to the file.</returns>
/// <remarks>
/// This method serializes the provided list of <see cref="Quote"/> objects into JSON format using <see cref="JsonSerializer"/>.
/// The serialized JSON is then saved to the file path specified in the <see cref="_jsonFilePath"/> field. The JSON is written
/// with indentation for better readability.
/// If the file does not already exist, it will be created.
/// </remarks>
/// <summary>
/// Asynchronously saves a list of quotes to a JSON file.
/// </summary>
/// <param name="quotes">The list of <see cref="Quote"/> objects to be serialized and saved to the file.</param>
/// <returns>A task representing the asynchronous operation of saving the quotes to the file.</returns>
/// <remarks>
/// This method serializes the provided list of <see cref="Quote"/> objects into JSON format using <see cref="JsonSerializer"/>.
/// The serialized JSON is then saved to the file path specified in the <see cref="_jsonFilePath"/> field. The JSON is written
/// with indentation for better readability.
/// If the file does not already exist, it will be created.
/// </remarks>
public async Task saveQuoteJson(List<Quote> quotes)
{
var json = JsonSerializer.Serialize(quotes, new JsonSerializerOptions { WriteIndented = true });
@ -28,17 +28,17 @@ namespace WF_WebAdmin.Service;
}
/// <summary>
/// Asynchronously adds a new quote to the list and saves it to a JSON file.
/// </summary>
/// <param name="quote">The <see cref="Quote"/> object to be added to the list.</param>
/// <returns>A task representing the asynchronous operation of adding the quote and saving the updated list to the file.</returns>
/// <remarks>
/// This method retrieves the current list of quotes using the <see cref="getAllQuote"/> method, assigns a new ID to the
/// provided quote (incremented from the maximum existing ID), and adds the quote to the list. After updating the list,
/// the method saves the updated list back to the JSON file using <see cref="saveQuoteJson"/>.
/// If the list is empty, the new quote is assigned an ID of 1.
/// </remarks>
/// <summary>
/// Asynchronously adds a new quote to the list and saves it to a JSON file.
/// </summary>
/// <param name="quote">The <see cref="Quote"/> object to be added to the list.</param>
/// <returns>A task representing the asynchronous operation of adding the quote and saving the updated list to the file.</returns>
/// <remarks>
/// This method retrieves the current list of quotes using the <see cref="getAllQuote"/> method, assigns a new ID to the
/// provided quote (incremented from the maximum existing ID), and adds the quote to the list. After updating the list,
/// the method saves the updated list back to the JSON file using <see cref="saveQuoteJson"/>.
/// If the list is empty, the new quote is assigned an ID of 1.
/// </remarks>
public async Task addQuote(Quote quote)
{
var data = await getAllQuote();
@ -48,17 +48,17 @@ namespace WF_WebAdmin.Service;
}
/// <summary>
/// Asynchronously removes a quote from the list and saves the updated list to a JSON file.
/// </summary>
/// <param name="quote">The <see cref="Quote"/> object to be removed from the list.</param>
/// <returns>A task representing the asynchronous operation of removing the quote and saving the updated list to the file.</returns>
/// <remarks>
/// This method retrieves the current list of quotes using the <see cref="getAllQuote"/> method.
/// It searches for the provided quote by its `Id` and, if found, removes it from the list.
/// After removing the quote, the method saves the updated list back to the JSON file using <see cref="saveQuoteJson"/>.
/// If the quote is not found in the list, no action is taken.
/// </remarks>
/// <summary>
/// Asynchronously removes a quote from the list and saves the updated list to a JSON file.
/// </summary>
/// <param name="quote">The <see cref="Quote"/> object to be removed from the list.</param>
/// <returns>A task representing the asynchronous operation of removing the quote and saving the updated list to the file.</returns>
/// <remarks>
/// This method retrieves the current list of quotes using the <see cref="getAllQuote"/> method.
/// It searches for the provided quote by its `Id` and, if found, removes it from the list.
/// After removing the quote, the method saves the updated list back to the JSON file using <see cref="saveQuoteJson"/>.
/// If the quote is not found in the list, no action is taken.
/// </remarks>
public async Task removeQuote(Quote quote)
{
var data = await getAllQuote();
@ -71,23 +71,23 @@ namespace WF_WebAdmin.Service;
}
public async Task validQuote(Quote quote)
public async Task validQuote(Quote quote)
{
throw new NotImplementedException();
}
/// <summary>
/// Asynchronously updates the details of an existing quote and saves the updated list to a JSON file.
/// </summary>
/// <param name="quote">The <see cref="Quote"/> object containing the updated details of the quote.</param>
/// <returns>A task representing the asynchronous operation of updating the quote and saving the updated list to the file.</returns>
/// <remarks>
/// This method retrieves the current list of quotes using the <see cref="getAllQuote"/> method.
/// It searches for the quote with the provided `Id` and, if found, updates its properties (e.g., content, character, image path, etc.)
/// with the values from the provided `quote` object. After updating the quote, the method saves the updated list back to the JSON file
/// using <see cref="saveQuoteJson"/>. If the quote with the specified `Id` is not found, no action is taken.
/// </remarks>
/// <summary>
/// Asynchronously updates the details of an existing quote and saves the updated list to a JSON file.
/// </summary>
/// <param name="quote">The <see cref="Quote"/> object containing the updated details of the quote.</param>
/// <returns>A task representing the asynchronous operation of updating the quote and saving the updated list to the file.</returns>
/// <remarks>
/// This method retrieves the current list of quotes using the <see cref="getAllQuote"/> method.
/// It searches for the quote with the provided `Id` and, if found, updates its properties (e.g., content, character, image path, etc.)
/// with the values from the provided `quote` object. After updating the quote, the method saves the updated list back to the JSON file
/// using <see cref="saveQuoteJson"/>. If the quote with the specified `Id` is not found, no action is taken.
/// </remarks>
public async Task updateQuote(Quote quote)
{
var data = await getAllQuote();
@ -105,16 +105,16 @@ namespace WF_WebAdmin.Service;
}
/// <summary>
/// Asynchronously retrieves all quotes from a JSON file.
/// </summary>
/// <returns>A task representing the asynchronous operation, with a result of a list of <see cref="Quote"/> objects.</returns>
/// <remarks>
/// This method checks if the JSON file exists at the specified file path (<see cref="_jsonFilePath"/>).
/// If the file does not exist, it logs a message and returns an empty list of quotes.
/// If the file exists, it reads the JSON content, deserializes it into a list of <see cref="Quote"/> objects,
/// and returns that list. If the deserialization results in a null value, an empty list is returned.
/// </remarks>
/// <summary>
/// Asynchronously retrieves all quotes from a JSON file.
/// </summary>
/// <returns>A task representing the asynchronous operation, with a result of a list of <see cref="Quote"/> objects.</returns>
/// <remarks>
/// This method checks if the JSON file exists at the specified file path (<see cref="_jsonFilePath"/>).
/// If the file does not exist, it logs a message and returns an empty list of quotes.
/// If the file exists, it reads the JSON content, deserializes it into a list of <see cref="Quote"/> objects,
/// and returns that list. If the deserialization results in a null value, an empty list is returned.
/// </remarks>
public async Task<List<Quote>> getAllQuote()
{
if (!File.Exists(_jsonFilePath))
@ -128,20 +128,20 @@ namespace WF_WebAdmin.Service;
}
/// <summary>
/// Asynchronously retrieves a subset of quotes based on the specified page number and the number of quotes per page.
/// </summary>
/// <param name="nb">The number of quotes to retrieve per page.</param>
/// <param name="page">The page number for pagination.</param>
/// <returns>A task representing the asynchronous operation, with a result of a list of <see cref="Quote"/> objects for the specified page.</returns>
/// <remarks>
/// This method retrieves all quotes using the <see cref="getAllQuote"/> method and then calculates the range of quotes
/// to be returned based on the provided `nb` (number of quotes per page) and `page` (the page number). It ensures that
/// the returned subset does not exceed the total number of quotes available.
///
/// If the calculated range is larger than the available quotes, it returns a subset of quotes from the end of the list.
/// If the requested page number exceeds the total number of pages, the method will return the last available page of quotes.
/// </remarks>
/// <summary>
/// Asynchronously retrieves a subset of quotes based on the specified page number and the number of quotes per page.
/// </summary>
/// <param name="nb">The number of quotes to retrieve per page.</param>
/// <param name="page">The page number for pagination.</param>
/// <returns>A task representing the asynchronous operation, with a result of a list of <see cref="Quote"/> objects for the specified page.</returns>
/// <remarks>
/// This method retrieves all quotes using the <see cref="getAllQuote"/> method and then calculates the range of quotes
/// to be returned based on the provided `nb` (number of quotes per page) and `page` (the page number). It ensures that
/// the returned subset does not exceed the total number of quotes available.
///
/// If the calculated range is larger than the available quotes, it returns a subset of quotes from the end of the list.
/// If the requested page number exceeds the total number of pages, the method will return the last available page of quotes.
/// </remarks>
public async Task<List<Quote>> getSomeQuote(int nb, int page)
{
var quotes = await getAllQuote();
@ -157,15 +157,15 @@ namespace WF_WebAdmin.Service;
}
/// <summary>
/// Asynchronously retrieves a single quote based on its ID.
/// </summary>
/// <param name="id">The unique identifier of the <see cref="Quote"/> to be retrieved.</param>
/// <returns>A task representing the asynchronous operation, with a result of the <see cref="Quote"/> object if found, otherwise null.</returns>
/// <remarks>
/// This method retrieves all quotes using the <see cref="getAllQuote"/> method and searches for the quote that matches the provided `id`.
/// If a matching quote is found, it returns that quote; otherwise, it returns `null`.
/// </remarks>
/// <summary>
/// Asynchronously retrieves a single quote based on its ID.
/// </summary>
/// <param name="id">The unique identifier of the <see cref="Quote"/> to be retrieved.</param>
/// <returns>A task representing the asynchronous operation, with a result of the <see cref="Quote"/> object if found, otherwise null.</returns>
/// <remarks>
/// This method retrieves all quotes using the <see cref="getAllQuote"/> method and searches for the quote that matches the provided `id`.
/// If a matching quote is found, it returns that quote; otherwise, it returns `null`.
/// </remarks>
public async Task<Quote> getOnequote(int id)
{
var data = await getAllQuote();
@ -184,15 +184,15 @@ namespace WF_WebAdmin.Service;
}
/// <summary>
/// Asynchronously retrieves all invalid quotes from the list.
/// </summary>
/// <returns>A task representing the asynchronous operation, with a result of a list of invalid <see cref="Quote"/> objects.</returns>
/// <remarks>
/// This method retrieves all quotes using the <see cref="getAllQuote"/> method and filters them by the `IsValid` property.
/// It returns only those quotes where `IsValid` is set to `false`.
/// If no invalid quotes are found, an empty list is returned.
/// </remarks>
/// <summary>
/// Asynchronously retrieves all invalid quotes from the list.
/// </summary>
/// <returns>A task representing the asynchronous operation, with a result of a list of invalid <see cref="Quote"/> objects.</returns>
/// <remarks>
/// This method retrieves all quotes using the <see cref="getAllQuote"/> method and filters them by the `IsValid` property.
/// It returns only those quotes where `IsValid` is set to `false`.
/// If no invalid quotes are found, an empty list is returned.
/// </remarks>
public async Task<List<Quote>> getAllQuoteInvalid()
{
var quotes = await getAllQuote();
@ -201,20 +201,20 @@ namespace WF_WebAdmin.Service;
}
/// <summary>
/// Asynchronously retrieves a subset of invalid quotes based on the specified page number and the number of quotes per page.
/// </summary>
/// <param name="nb">The number of invalid quotes to retrieve per page.</param>
/// <param name="page">The page number for pagination.</param>
/// <returns>A task representing the asynchronous operation, with a result of a list of invalid <see cref="Quote"/> objects for the specified page.</returns>
/// <remarks>
/// This method retrieves all invalid quotes using the <see cref="getAllQuoteInvalid"/> method and then calculates the range of invalid quotes
/// to be returned based on the provided `nb` (number of quotes per page) and `page` (the page number). It ensures that
/// the returned subset does not exceed the total number of invalid quotes available.
///
/// If the calculated range is larger than the available invalid quotes, it returns a subset of quotes from the end of the list.
/// If the requested page number exceeds the total number of pages, the method will return the last available page of invalid quotes.
/// </remarks>
/// <summary>
/// Asynchronously retrieves a subset of invalid quotes based on the specified page number and the number of quotes per page.
/// </summary>
/// <param name="nb">The number of invalid quotes to retrieve per page.</param>
/// <param name="page">The page number for pagination.</param>
/// <returns>A task representing the asynchronous operation, with a result of a list of invalid <see cref="Quote"/> objects for the specified page.</returns>
/// <remarks>
/// This method retrieves all invalid quotes using the <see cref="getAllQuoteInvalid"/> method and then calculates the range of invalid quotes
/// to be returned based on the provided `nb` (number of quotes per page) and `page` (the page number). It ensures that
/// the returned subset does not exceed the total number of invalid quotes available.
///
/// If the calculated range is larger than the available invalid quotes, it returns a subset of quotes from the end of the list.
/// If the requested page number exceeds the total number of pages, the method will return the last available page of invalid quotes.
/// </remarks>
public async Task<List<Quote>> getSomeQuoteInvalid(int nb, int page)
{
var quotes = await getAllQuoteInvalid();
@ -230,14 +230,14 @@ namespace WF_WebAdmin.Service;
}
/// <summary>
/// Asynchronously retrieves the total number of quotes.
/// </summary>
/// <returns>A task representing the asynchronous operation, with a result of the total number of <see cref="Quote"/> objects.</returns>
/// <remarks>
/// This method retrieves all quotes using the <see cref="getAllQuote"/> method and returns the count of quotes.
/// It provides the total number of quotes currently available in the data source.
/// </remarks>
/// <summary>
/// Asynchronously retrieves the total number of quotes.
/// </summary>
/// <returns>A task representing the asynchronous operation, with a result of the total number of <see cref="Quote"/> objects.</returns>
/// <remarks>
/// This method retrieves all quotes using the <see cref="getAllQuote"/> method and returns the count of quotes.
/// It provides the total number of quotes currently available in the data source.
/// </remarks>
public async Task<int> getNbQuote()
{
var data = await getAllQuote();
@ -245,16 +245,16 @@ namespace WF_WebAdmin.Service;
}
/// <summary>
/// Asynchronously retrieves a list of characters from a JSON file.
/// </summary>
/// <returns>A task representing the asynchronous operation, with a result of a list of <see cref="Character"/> objects.</returns>
/// <remarks>
/// This method checks if the JSON file containing character data exists at the specified file path (`_char`).
/// If the file does not exist, it logs a message to the console and returns an empty list of characters.
/// If the file exists, it reads the JSON content, deserializes it into a list of <see cref="Character"/> objects,
/// and returns that list. If the deserialization results in a null value, an empty list is returned.
/// </remarks>
/// <summary>
/// Asynchronously retrieves a list of characters from a JSON file.
/// </summary>
/// <returns>A task representing the asynchronous operation, with a result of a list of <see cref="Character"/> objects.</returns>
/// <remarks>
/// This method checks if the JSON file containing character data exists at the specified file path (`_char`).
/// If the file does not exist, it logs a message to the console and returns an empty list of characters.
/// If the file exists, it reads the JSON content, deserializes it into a list of <see cref="Character"/> objects,
/// and returns that list. If the deserialization results in a null value, an empty list is returned.
/// </remarks>
public async Task<List<Character>> getChar()
{
if (!File.Exists(_char))
@ -268,16 +268,16 @@ namespace WF_WebAdmin.Service;
}
/// <summary>
/// Asynchronously retrieves a list of sources from a JSON file.
/// </summary>
/// <returns>A task representing the asynchronous operation, with a result of a list of <see cref="Source"/> objects.</returns>
/// <remarks>
/// This method checks if the JSON file containing source data exists at the specified file path (`_src`).
/// If the file does not exist, it logs a message to the console and returns an empty list of sources.
/// If the file exists, it reads the JSON content, deserializes it into a list of <see cref="Source"/> objects,
/// and returns that list. If the deserialization results in a null value, an empty list is returned.
/// </remarks>
/// <summary>
/// Asynchronously retrieves a list of sources from a JSON file.
/// </summary>
/// <returns>A task representing the asynchronous operation, with a result of a list of <see cref="Source"/> objects.</returns>
/// <remarks>
/// This method checks if the JSON file containing source data exists at the specified file path (`_src`).
/// If the file does not exist, it logs a message to the console and returns an empty list of sources.
/// If the file exists, it reads the JSON content, deserializes it into a list of <see cref="Source"/> objects,
/// and returns that list. If the deserialization results in a null value, an empty list is returned.
/// </remarks>
public async Task<List<Source>> getSrc()
{
if (!File.Exists(_src))
@ -288,6 +288,6 @@ namespace WF_WebAdmin.Service;
var json = await File.ReadAllTextAsync(_src);
return JsonSerializer.Deserialize<List<Source>>(json) ?? new List<Source>();
}
}
}

@ -3,6 +3,7 @@
@inject UserLogin uLogin
<PageTitle>WF-WebAdmin</PageTitle>
<MudThemeProvider />
<div class="page">

@ -54,8 +54,11 @@
<span class="oi oi-list-rich" aria-hidden="true"></span> Logs
</NavLink>
</div>
<div class="nav-item px-3">
<MudNavLink class="nav-link" Href="/commentary-chart">
<span class="oi oi-list-rich" aria-hidden="true"></span> Stats commentaires
</MudNavLink>
</div>
</nav>
</div>

@ -15,6 +15,7 @@
<PackageReference Include="bootstrap" Version="5.3.3" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="9.0.1" />
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="9.0.1" />
<PackageReference Include="MudBlazor" Version="6.2.0" />
<PackageReference Include="Npgsql" Version="9.0.2" />
<PackageReference Include="Blazored.Modal" Version="7.2.0" />
</ItemGroup>

@ -10,4 +10,5 @@
@using WF_WebAdmin.Shared
@using Blazorise.DataGrid
@using Blazored.Modal
@using MudBlazor

@ -0,0 +1,5 @@
{
"version": "3.0",
"defaultProvider": "cdnjs",
"libraries": []
}

@ -0,0 +1,359 @@
[
{
"id_comment": 1,
"quote": 1,
"users": 1,
"dateC": "2024-10-10",
"comment": "coucou"
},
{
"id_comment": 2,
"quote": 1,
"users": 2,
"dateC": "2024-10-11",
"comment": "Super citation !"
},
{
"id_comment": 3,
"quote": 1,
"users": 3,
"dateC": "2024-10-12",
"comment": "Très inspirant."
},
{
"id_comment": 4,
"quote": 2,
"users": 4,
"dateC": "2024-10-13",
"comment": "J'adore cette phrase."
},
{
"id_comment": 5,
"quote": 2,
"users": 5,
"dateC": "2024-10-14",
"comment": "Citation profonde."
},
{
"id_comment": 6,
"quote": 2,
"users": 6,
"dateC": "2024-10-15",
"comment": "Belle pensée."
},
{
"id_comment": 7,
"quote": 3,
"users": 7,
"dateC": "2024-10-16",
"comment": "Très motivant."
},
{
"id_comment": 8,
"quote": 3,
"users": 8,
"dateC": "2024-10-17",
"comment": "Citation puissante."
},
{
"id_comment": 9,
"quote": 3,
"users": 9,
"dateC": "2024-10-18",
"comment": "Paroles sages."
},
{
"id_comment": 10,
"quote": 4,
"users": 10,
"dateC": "2024-10-19",
"comment": "Très réfléchi."
},
{
"id_comment": 11,
"quote": 4,
"users": 11,
"dateC": "2024-10-20",
"comment": "Citation magnifique."
},
{
"id_comment": 12,
"quote": 4,
"users": 12,
"dateC": "2024-10-21",
"comment": "Très touchant."
},
{
"id_comment": 13,
"quote": 5,
"users": 13,
"dateC": "2024-10-22",
"comment": "Citation parfaite."
},
{
"id_comment": 14,
"quote": 5,
"users": 14,
"dateC": "2024-10-23",
"comment": "Très émouvant."
},
{
"id_comment": 15,
"quote": 5,
"users": 15,
"dateC": "2024-10-24",
"comment": "Citation merveilleuse."
},
{
"id_comment": 16,
"quote": 6,
"users": 16,
"dateC": "2024-10-25",
"comment": "Très poétique."
},
{
"id_comment": 17,
"quote": 6,
"users": 17,
"dateC": "2024-10-26",
"comment": "Citation exceptionnelle."
},
{
"id_comment": 18,
"quote": 6,
"users": 18,
"dateC": "2024-10-27",
"comment": "Très inspirant."
},
{
"id_comment": 19,
"quote": 7,
"users": 19,
"dateC": "2024-10-28",
"comment": "J'adore cette phrase."
},
{
"id_comment": 20,
"quote": 7,
"users": 20,
"dateC": "2024-10-29",
"comment": "Citation profonde."
},
{
"id_comment": 21,
"quote": 7,
"users": 21,
"dateC": "2024-8-30",
"comment": "Belle pensée."
},
{
"id_comment": 22,
"quote": 8,
"users": 22,
"dateC": "2024-10-31",
"comment": "Très motivant."
},
{
"id_comment": 23,
"quote": 8,
"users": 23,
"dateC": "2024-11-01",
"comment": "Citation puissante."
},
{
"id_comment": 24,
"quote": 8,
"users": 24,
"dateC": "2024-11-02",
"comment": "Paroles sages."
},
{
"id_comment": 25,
"quote": 9,
"users": 25,
"dateC": "2024-11-03",
"comment": "Très réfléchi."
},
{
"id_comment": 26,
"quote": 9,
"users": 26,
"dateC": "2024-11-04",
"comment": "Citation magnifique."
},
{
"id_comment": 27,
"quote": 9,
"users": 27,
"dateC": "2024-11-05",
"comment": "Très touchant."
},
{
"id_comment": 28,
"quote": 10,
"users": 28,
"dateC": "2024-11-06",
"comment": "Citation parfaite."
},
{
"id_comment": 29,
"quote": 10,
"users": 29,
"dateC": "2024-11-07",
"comment": "Très émouvant."
},
{
"id_comment": 30,
"quote": 10,
"users": 30,
"dateC": "2024-11-08",
"comment": "Citation merveilleuse."
},
{
"id_comment": 31,
"quote": 11,
"users": 31,
"dateC": "2024-11-09",
"comment": "Très poétique."
},
{
"id_comment": 32,
"quote": 11,
"users": 32,
"dateC": "2024-11-10",
"comment": "Citation exceptionnelle."
},
{
"id_comment": 33,
"quote": 11,
"users": 33,
"dateC": "2024-11-11",
"comment": "Très inspirant."
},
{
"id_comment": 34,
"quote": 12,
"users": 34,
"dateC": "2024-11-12",
"comment": "J'adore cette phrase."
},
{
"id_comment": 35,
"quote": 12,
"users": 35,
"dateC": "2024-11-13",
"comment": "Citation profonde."
},
{
"id_comment": 36,
"quote": 12,
"users": 36,
"dateC": "2024-11-14",
"comment": "Belle pensée."
},
{
"id_comment": 37,
"quote": 13,
"users": 37,
"dateC": "2024-11-15",
"comment": "Très motivant."
},
{
"id_comment": 38,
"quote": 13,
"users": 38,
"dateC": "2024-11-16",
"comment": "Citation puissante."
},
{
"id_comment": 39,
"quote": 13,
"users": 39,
"dateC": "2024-11-17",
"comment": "Paroles sages."
},
{
"id_comment": 40,
"quote": 14,
"users": 40,
"dateC": "2024-11-18",
"comment": "Très réfléchi."
},
{
"id_comment": 41,
"quote": 14,
"users": 41,
"dateC": "2024-11-19",
"comment": "Citation magnifique."
},
{
"id_comment": 42,
"quote": 14,
"users": 42,
"dateC": "2024-11-20",
"comment": "Très touchant."
},
{
"id_comment": 43,
"quote": 15,
"users": 43,
"dateC": "2024-11-21",
"comment": "Citation parfaite."
},
{
"id_comment": 44,
"quote": 15,
"users": 44,
"dateC": "2024-11-22",
"comment": "Très émouvant."
},
{
"id_comment": 45,
"quote": 15,
"users": 45,
"dateC": "2024-11-23",
"comment": "Citation merveilleuse."
},
{
"id_comment": 46,
"quote": 16,
"users": 46,
"dateC": "2024-11-24",
"comment": "Très poétique."
},
{
"id_comment": 47,
"quote": 16,
"users": 47,
"dateC": "2024-11-25",
"comment": "Citation exceptionnelle."
},
{
"id_comment": 48,
"quote": 16,
"users": 48,
"dateC": "2024-11-26",
"comment": "Très inspirant."
},
{
"id_comment": 49,
"quote": 17,
"users": 49,
"dateC": "2024-11-27",
"comment": "J'adore cette phrase."
},
{
"id_comment": 50,
"quote": 17,
"users": 50,
"dateC": "2024-11-28",
"comment": "Citation profonde."
},
{
"id_comment": 51,
"quote": 17,
"users": 51,
"dateC": "2024-11-29",
"comment": "Belle pensée."
}
]

@ -1,9 +0,0 @@
[
{
"id_comment": 1,
"quote": 1,
"users": 1,
"dateC":"2024-10-10",
"comment": "coucou"
}
]
Loading…
Cancel
Save