Maxime ROCHER 2 months ago
commit 0e564f580b

@ -10,7 +10,7 @@ namespace WF_WebAdmin.Converter
public DateTime DateCreation { get; set; } public DateTime DateCreation { get; set; }
public Boolean IsAdmin { get; set; } public Boolean IsAdmin { get; set; }
public List<Commentary> Comments { get; set; } public List<Commentary>? Comments { get; set; }
public UserDTO(string image, string name, string email, DateTime dateCreation) public UserDTO(string image, string name, string email, DateTime dateCreation)
{ {

@ -3,6 +3,6 @@
public class Character public class Character
{ {
public int id_caracter { get; set; } public int id_caracter { get; set; }
public string caracter { get; set; } public string? caracter { get; set; }
} }
} }

@ -23,19 +23,3 @@ namespace WF_WebAdmin.Model
} }
} }
/*
[Inject]
public ILogger< Class > Logger { get; set; }
LoggerSaveStub.Log(Logger,LogLevel. level , message );
LogLevel:
Trace = 0,
Debug = 1,
Information = 2,
Warning = 3,
Error = 4,
Critical = 5,
None = 6,
*/

@ -3,7 +3,7 @@ namespace WF_WebAdmin.Model
public class Quiz public class Quiz
{ {
public int Id { get; set; } public int Id { get; set; }
public string Question { get; set; } public string? Question { get; set; }
public string AnswerA { get; set; } public string AnswerA { get; set; }
public string AnswerB { get; set; } public string AnswerB { get; set; }
public string AnswerC { get; set; } public string AnswerC { get; set; }

@ -6,25 +6,25 @@ namespace WF_WebAdmin.Model
{ {
[Required] [Required]
[StringLength(200, ErrorMessage = "La question ne peut pas depasser les 200 caractère.")] [StringLength(200, ErrorMessage = "La question ne peut pas depasser les 200 caractère.")]
public string Question { get; set; } public string? Question { get; set; }
[Required] [Required]
[StringLength(50, ErrorMessage = "La réponse ne peut pas depasser les 50 caractère.")] [StringLength(50, ErrorMessage = "La réponse ne peut pas depasser les 50 caractère.")]
public string AnswerA { get; set; } public string? AnswerA { get; set; }
[Required] [Required]
[StringLength(50, ErrorMessage = "La réponse ne peut pas depasser les 50 caractère.")] [StringLength(50, ErrorMessage = "La réponse ne peut pas depasser les 50 caractère.")]
public string AnswerB { get; set; } public string? AnswerB { get; set; }
[Required] [Required]
[StringLength(50, ErrorMessage = "La réponse ne peut pas depasser les 50 caractère.")] [StringLength(50, ErrorMessage = "La réponse ne peut pas depasser les 50 caractère.")]
public string AnswerC { get; set; } public string? AnswerC { get; set; }
[Required] [Required]
[StringLength(50, ErrorMessage = "La réponse ne peut pas depasser les 50 caractère.")] [StringLength(50, ErrorMessage = "La réponse ne peut pas depasser les 50 caractère.")]
public string AnswerD { get; set; } public string? AnswerD { get; set; }
[Required] [Required]
public string CAnswer { get; set; } public string? CAnswer { get; set; }
} }
} }

@ -28,42 +28,6 @@ namespace WF_WebAdmin.Model
UserProposition = userProposition; UserProposition = userProposition;
IsValid = isvalid; IsValid = isvalid;
} }
/*
public int Id { get; set; }
public string Content { get; set; }
public int Likes { get; set; }
public string Langue { get; set; }
public bool IsValide { get; set; }
public string? Reason { get; set; }
public int IdCaracter { get; set; }
public int IdSource { get; set; }
public int? IdUserVerif { get; set; }
public Quote(int id, string content, int likes, string langue, bool isValide, string? reason, int idCaracter, int idSource, int idUserVerif)
{
Id = id;
Content = content;
Likes = likes;
Langue = langue;
IsValide = isValide;
Reason = reason;
IdCaracter = idCaracter;
IdSource = idSource;
IdUserVerif = idUserVerif;
}
public Quote(int id, string content, int likes, string langue, bool isValide, string? reason, int idCaracter, int idSource, int? idUserVerif)
{
Id = id;
Content = content;
Likes = likes;
Langue = langue;
IsValide = isValide;
Reason = reason;
IdCaracter = idCaracter;
IdSource = idSource;
IdUserVerif = idUserVerif;
}
*/
} }
} }

@ -8,20 +8,20 @@ namespace WF_WebAdmin.Model
[Required] [Required]
[StringLength(300, ErrorMessage = "La citation ne peut pas dépasser les 300 caractère.")] [StringLength(300, ErrorMessage = "La citation ne peut pas dépasser les 300 caractère.")]
public string Content { get; set; } public string? Content { get; set; }
public int Like { get; set; } public int Like { get; set; }
[Required] [Required]
[StringLength(2, ErrorMessage = "La langue ne peut pas dépasser 2 caractère.")] [StringLength(2, ErrorMessage = "La langue ne peut pas dépasser 2 caractère.")]
public string Langue { get; set; } public string? Langue { get; set; }
public string Charac { get; set; } public string? Charac { get; set; }
public string ImgPath { get; set; } public string? ImgPath { get; set; }
public string TitleSrc { get; set; } public string? TitleSrc { get; set; }
public DateTime DateSrc { get; set; } public DateTime DateSrc { get; set; }
public string UserProposition { get; set; } public string? UserProposition { get; set; }
public bool IsValid { get; set; } public bool IsValid { get; set; }
} }
} }

@ -4,7 +4,7 @@
{ {
public int id_source { get; set; } public int id_source { get; set; }
public string title { get; set; } public string? title { get; set; }
public int date { get; set; } public int date { get; set; }
} }

@ -3,14 +3,14 @@
public class User public class User
{ {
public int Id { get; set; } public int Id { get; set; }
public string Image { get; set; } public string? Image { get; set; }
public string Name { get; set; } public string Name { get; set; }
public string Email { get; set; } public string Email { get; set; }
public DateTime DateCreation { get; set; } public DateTime DateCreation { get; set; }
public Boolean IsAdmin { get; set; } public Boolean IsAdmin { get; set; }
public List<Commentary> Comments { get; set; } public List<Commentary>? Comments { get; set; }
public User(string image, string name, string email, DateTime dateCreation, bool isAdmin) public User(string image, string name, string email, DateTime dateCreation, bool isAdmin)
{ {

@ -4,7 +4,7 @@ namespace WF_WebAdmin.Model
public class UserLogin public class UserLogin
{ {
public int Id { get; set; } public int Id { get; set; }
public string Image { get; set; } public string? Image { get; set; }
public string Name { get; set;} public string Name { get; set;}
public Boolean IsAdmin { get; set; } public Boolean IsAdmin { get; set; }
public string Mdp { get; set; } public string Mdp { get; set; }

@ -9,18 +9,18 @@ namespace WF_WebAdmin.Pages
{ {
public partial class Accueil public partial class Accueil
{ {
private Quote[] Dailyquote; private Quote[]? Dailyquote;
[Inject] [Inject]
public ILogger<Accueil> Logger { get; set; } public ILogger<Accueil>? Logger { get; set; }
[Inject] [Inject]
public HttpClient Http { get; set; } public HttpClient? Http { get; set; }
[Inject] [Inject]
public NavigationManager NavigationManager { get; set; } public NavigationManager? NavigationManager { get; set; }
[Inject] [Inject]
public IStringLocalizer<Accueil> Localizer { get; set; } public IStringLocalizer<Accueil>? Localizer { get; set; }
/// <summary> /// <summary>

@ -33,7 +33,7 @@ namespace WF_WebAdmin.Pages
/// Finally, it navigates to the "modifquiz" page. /// Finally, it navigates to the "modifquiz" page.
/// </summary> /// </summary>
private async void HandleValidSubmit() private async Task HandleValidSubmit()
{ {
// Declare a variable to hold the ID of the new quiz. // Declare a variable to hold the ID of the new quiz.
int id; int id;

@ -0,0 +1,14 @@
@page "/graph"
@using Syncfusion.Blazor.Charts
<script src=https://cdn.syncfusion.com/blazor/22.1.38/syncfusion-blazor.min.js type="text/javascript"></script>
<SfChart>
<ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.Category"></ChartPrimaryXAxis>
<ChartSeriesCollection>
<ChartSeries DataSource="@Sales" Opacity="1" Fill="blue" XName="Month" YName="SalesValue" Type="ChartSeriesType.Column" ColumnSpacing="0.2" ColumnWidth="0.8">
</ChartSeries>
</ChartSeriesCollection>
</SfChart>

@ -0,0 +1,92 @@
using Microsoft.AspNetCore.Components;
using MudBlazor;
using Syncfusion.Blazor.Charts.Chart.Internal;
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 class SalesInfo
{
public string Month { get; set; }
public double SalesValue { get; set; }
}
public partial class ComposentComplex : 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();
public List<SalesInfo> Sales = new List<SalesInfo>
{
new SalesInfo { Month = "Jan", SalesValue = 35 },
new SalesInfo { Month = "Feb", SalesValue = 28 },
new SalesInfo { Month = "Mar", SalesValue = 34 },
new SalesInfo { Month = "Apr", SalesValue = 28 },
new SalesInfo { Month = "May", SalesValue = 40 },
new SalesInfo { Month = "Jun", SalesValue = 32 },
new SalesInfo { Month = "Jul", SalesValue = 35 },
new SalesInfo { Month = "Aug", SalesValue = 55 },
new SalesInfo { Month = "Sep", SalesValue = 38 },
new SalesInfo { Month = "Oct", SalesValue = 30 },
new SalesInfo { Month = "Nov", SalesValue = 25 },
new SalesInfo { Month = "Dec", SalesValue = 32 }
};
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;
}
foreach (var sale in Sales)
{
sale.SalesValue = filteredComments.Count(c => c.DateCreation.Month.ToString("MMM", CultureInfo.InvariantCulture) == sale.Month);
}
}
}
}

@ -16,7 +16,7 @@ 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;

@ -62,7 +62,7 @@ namespace WF_WebAdmin.Pages
/// and then calls the `quoteService.updateQuote` method to persist the changes. /// and then calls the `quoteService.updateQuote` method to persist the changes.
/// After updating, it navigates to the "modifquote" page. /// After updating, it navigates to the "modifquote" page.
/// </summary> /// </summary>
protected async void HandleValidSubmit() protected async Task HandleValidSubmit()
{ {
// Update the properties of the selected quote (`q`) with the data from `quoteModel`. // Update the properties of the selected quote (`q`) with the data from `quoteModel`.
LoggerSaveStub.Log(Logger, LogLevel.Information, $"Editing the quote {q.Content}"); LoggerSaveStub.Log(Logger, LogLevel.Information, $"Editing the quote {q.Content}");

@ -7,7 +7,7 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Error</title> <title>error</title>
<link href="~/css/bootstrap/bootstrap.min.css" rel="stylesheet" /> <link href="~/css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="~/css/site.css" rel="stylesheet" asp-append-version="true" /> <link href="~/css/site.css" rel="stylesheet" asp-append-version="true" />
</head> </head>
@ -27,12 +27,12 @@
<h3>Development Mode</h3> <h3>Development Mode</h3>
<p> <p>
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred. Swapping to the <strong>development</strong> environment displays detailed information about the error that occurred.
</p> </p>
<p> <p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong> <strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users. It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong> For local debugging, enable the <strong>development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app. and restarting the app.
</p> </p>
</div> </div>

@ -12,7 +12,7 @@ namespace WF_WebAdmin.Pages
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
private readonly ILogger<ErrorModel> _logger;
/// <summary> /// <summary>

@ -138,7 +138,7 @@ namespace WF_WebAdmin.Pages
/// This method first checks if a quiz is selected, and if so, it deletes the quiz by calling the service. /// This method first checks if a quiz is selected, and if so, it deletes the quiz by calling the service.
/// After removal, it clears the `selectedQuiz`, updates the quiz list, and closes the delete confirmation popup. /// After removal, it clears the `selectedQuiz`, updates the quiz list, and closes the delete confirmation popup.
/// </summary> /// </summary>
private async void RemoveQuote() private async Task RemoveQuote()
{ {
// Check if a quiz is selected for deletion // Check if a quiz is selected for deletion
if (selectedQuiz != null) if (selectedQuiz != null)

@ -111,7 +111,7 @@ namespace WF_WebAdmin.Pages
/// This method checks if a quote is selected. If so, it removes the quote using the `QuoteService`, clears the selected quote, /// This method checks if a quote is selected. If so, it removes the quote using the `QuoteService`, clears the selected quote,
/// and fetches the updated list of quotes. It also closes the delete confirmation popup after the operation. /// and fetches the updated list of quotes. It also closes the delete confirmation popup after the operation.
/// </summary> /// </summary>
private async void RemoveQuote() private async Task RemoveQuote()
{ {
// Check if a quote is selected for removal // Check if a quote is selected for removal
if (selectedQuote != null) if (selectedQuote != null)

@ -5,6 +5,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<title>layout</title>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="~/" /> <base href="~/" />
@ -24,7 +25,7 @@
<environment include="Development"> <environment include="Development">
An unhandled exception has occurred. See browser dev tools for details. An unhandled exception has occurred. See browser dev tools for details.
</environment> </environment>
<a href="" class="reload">Reload</a> <a href="" class="reload">reload</a>
<a class="dismiss">🗙</a> <a class="dismiss">🗙</a>
</div> </div>

@ -14,6 +14,7 @@ using Blazored.Modal;
using WF_WebAdmin.Service; using WF_WebAdmin.Service;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using MudBlazor.Services; using MudBlazor.Services;
using Syncfusion.Blazor;
[assembly: RootNamespace("WF_WebAdmin")] [assembly: RootNamespace("WF_WebAdmin")]
@ -32,6 +33,8 @@ builder.Services.AddScoped<UserLogin>();
builder.Services.AddMudServices(); builder.Services.AddMudServices();
builder.Logging.AddConfiguration(builder.Configuration.GetSection("Logging")); builder.Logging.AddConfiguration(builder.Configuration.GetSection("Logging"));
builder.Services.AddSyncfusionBlazor();
builder.Services builder.Services
.AddBlazorise() .AddBlazorise()
.AddBootstrapProviders() .AddBootstrapProviders()

@ -6,7 +6,7 @@ namespace WF_WebAdmin.Service
{ {
public class QuoteServiceLocal: IQuoteService public class QuoteServiceLocal: IQuoteService
{ {
private readonly string? _connectionString = "Host=localhost;Port=5432;Username=loguichard3;Password=Reglisse15.;Database=dbloguichard3"; private readonly string? _connectionString = "Host=localhost;Port=5432;Username=;Password=;Database=";

@ -59,6 +59,11 @@
<span class="oi oi-list-rich" aria-hidden="true"></span> Stats commentaires <span class="oi oi-list-rich" aria-hidden="true"></span> Stats commentaires
</MudNavLink> </MudNavLink>
</div> </div>
<div class="nav-item px-3">
<MudNavLink class="nav-link" Href="/graph">
<span class="oi oi-list-rich" aria-hidden="true"></span> Stats commentaires
</MudNavLink>
</div>
</nav> </nav>
</div> </div>

@ -18,6 +18,7 @@
<PackageReference Include="MudBlazor" Version="6.2.0" /> <PackageReference Include="MudBlazor" Version="6.2.0" />
<PackageReference Include="Npgsql" Version="9.0.2" /> <PackageReference Include="Npgsql" Version="9.0.2" />
<PackageReference Include="Blazored.Modal" Version="7.2.0" /> <PackageReference Include="Blazored.Modal" Version="7.2.0" />
<PackageReference Include="Syncfusion.Blazor.Charts" Version="28.2.4" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -7,6 +7,17 @@ html, body {
color: black; color: black;
} }
h1 {
text-align: center;
font-size: 32px;
margin-top: 10%;
font-family: "Roboto", serif;
}
h1:focus { h1:focus {
outline: none; outline: none;
} }
@ -169,12 +180,7 @@ td {
text-align: center; text-align: center;
} }
h1 {
text-align: center;
font-size: 32px;
margin-top: 10%;
font-family: "Roboto", serif;
}
p { p {
margin-bottom: 2%; margin-bottom: 2%;

Loading…
Cancel
Save