From 8352e4fe28bd537a1bb98d8a40663d5b0f7ae3b6 Mon Sep 17 00:00:00 2001 From: tomivt Date: Tue, 14 Jan 2025 17:33:46 +0100 Subject: [PATCH 01/79] Add UserServiceJson --- .../WF-WebAdmin/Pages/DeleteUser.razor.cs | 20 +++--- .../WF-WebAdmin/Pages/ModifQuote.razor.cs | 4 +- .../WF-WebAdmin/Service/IUserService.cs | 2 +- .../WF-WebAdmin/Service/IUserServiceJson.cs | 17 +++++ .../WF-WebAdmin/Service/QuoteServiceStub.cs | 58 +++++++++++++++-- .../WF-WebAdmin/Service/UserServiceStub.cs | 64 +++++++++++++++++++ 6 files changed, 147 insertions(+), 18 deletions(-) create mode 100644 WF-WebAdmin/WF-WebAdmin/Service/IUserServiceJson.cs create mode 100644 WF-WebAdmin/WF-WebAdmin/Service/UserServiceStub.cs diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs index 0743f27..3daab72 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs @@ -1,30 +1,30 @@ using Microsoft.AspNetCore.Components; using Microsoft.Extensions.Configuration.UserSecrets; using WF_WebAdmin.Model; +using WF_WebAdmin.Service; namespace WF_WebAdmin.Pages { public partial class DeleteUser { - private List users; - - private bool showPopup = false; private User userToDelete = null; + [Inject] public HttpClient Http { get; set; } [Inject] public NavigationManager NavigationManager { get; set; } + + private List users; + private UserServiceStub userService; protected override async Task OnInitializedAsync() { - users = await Http.GetFromJsonAsync>($"{NavigationManager.BaseUri}fake-dataUser.json"); + userService = new UserServiceStub($"fake-dataUser.json"); + users = await userService.GetUsersJson(); } - - - private void ShowConfirmation(User user) { // Afficher la modale et mémoriser l'utilisateur à supprimer @@ -32,8 +32,6 @@ namespace WF_WebAdmin.Pages showPopup = true; } - - private async Task RemoveUser() { if (userToDelete != null) @@ -47,6 +45,6 @@ namespace WF_WebAdmin.Pages { showPopup = false; } - } - + } + } diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs index 6bb7933..5ba6ad3 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs @@ -17,7 +17,9 @@ namespace WF_WebAdmin.Pages protected override async Task OnInitializedAsync() { - quotes = await Http.GetFromJsonAsync($"{NavigationManager.BaseUri}fake-dataModifQuote.json"); + string path = $"{NavigationManager.BaseUri}fake-dataModifQuote.json"; + Console.WriteLine($"filePath {path}"); + quotes = await Http.GetFromJsonAsync(path); } } } diff --git a/WF-WebAdmin/WF-WebAdmin/Service/IUserService.cs b/WF-WebAdmin/WF-WebAdmin/Service/IUserService.cs index 1742e10..3a505f4 100644 --- a/WF-WebAdmin/WF-WebAdmin/Service/IUserService.cs +++ b/WF-WebAdmin/WF-WebAdmin/Service/IUserService.cs @@ -4,7 +4,7 @@ namespace WF_WebAdmin.Service { public interface IUserService { - public void removeUser(User user); + public void removeUserJs(User user); public void updateRole(User user); diff --git a/WF-WebAdmin/WF-WebAdmin/Service/IUserServiceJson.cs b/WF-WebAdmin/WF-WebAdmin/Service/IUserServiceJson.cs new file mode 100644 index 0000000..f6c8383 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Service/IUserServiceJson.cs @@ -0,0 +1,17 @@ +using WF_WebAdmin.Model; + +namespace WF_WebAdmin.Service +{ + public interface IUserServiceJson + { + public Task> GetUsersJson(); + + public Task SaveUsersJson(List users); + + public Task AddUserJson(User user); + + public Task DeleteUserJson(int id); + + public Task UpdateUserJson(User user); + } +} \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Service/QuoteServiceStub.cs b/WF-WebAdmin/WF-WebAdmin/Service/QuoteServiceStub.cs index d6be33b..6619214 100644 --- a/WF-WebAdmin/WF-WebAdmin/Service/QuoteServiceStub.cs +++ b/WF-WebAdmin/WF-WebAdmin/Service/QuoteServiceStub.cs @@ -6,11 +6,59 @@ namespace WF_WebAdmin.Service { public class QuoteServiceStub : IQuoteService { - [Inject] - public HttpClient Http { get; set; } + [Inject] public HttpClient Http { get; set; } - [Inject] - public NavigationManager NavigationManager { get; set; } + [Inject] public NavigationManager NavigationManager { get; set; } - + + public Task addQuote(Quote quote) + { + throw new NotImplementedException(); + } + + public Task removeQuote(Quote quote) + { + throw new NotImplementedException(); + } + + public Task validQuote(Quote quote) + { + throw new NotImplementedException(); + } + + public Task updateQuote(Quote quote) + { + throw new NotImplementedException(); + } + + public Task> getAllQuote() + { + throw new NotImplementedException(); + } + + public Task> getSomeQuote(int nb, int page) + { + throw new NotImplementedException(); + } + + public Task> getOnequote(int id) + { + throw new NotImplementedException(); + } + + public Task> reserchQuote(string reserch, List argument) + { + throw new NotImplementedException(); + } + + public Task> getAllQuoteInvalid() + { + throw new NotImplementedException(); + } + + public Task> getSomeQuoteInvalid(int nb, int page) + { + throw new NotImplementedException(); + } + } } diff --git a/WF-WebAdmin/WF-WebAdmin/Service/UserServiceStub.cs b/WF-WebAdmin/WF-WebAdmin/Service/UserServiceStub.cs new file mode 100644 index 0000000..bc34fbd --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Service/UserServiceStub.cs @@ -0,0 +1,64 @@ +using System.Text.Json; +using WF_WebAdmin.Model; + +namespace WF_WebAdmin.Service; + +public class UserServiceStub : IUserServiceJson +{ + private readonly string _jsonFilePath; + + public UserServiceStub(string filePath) + { + _jsonFilePath = Path.Combine(Environment.CurrentDirectory, "wwwroot", filePath); + } + + public async Task> GetUsersJson() + { + if (!File.Exists(_jsonFilePath)) + { + Console.Out.WriteLine($"{_jsonFilePath} not found"); + return new List(); + } + + var json = await File.ReadAllTextAsync(_jsonFilePath); + return JsonSerializer.Deserialize>(json) ?? new List(); + } + + public async Task SaveUsersJson(List users) + { + var json = JsonSerializer.Serialize(users, new JsonSerializerOptions { WriteIndented = true }); + await File.WriteAllTextAsync(_jsonFilePath, json); + } + + public async Task AddUserJson(User user) + { + var data = await GetUsersJson(); + user.Id = data.Count > 0 ? data.Max(p => p.Id) + 1 : 1; + data.Add(user); + await SaveUsersJson(data); + } + + public async Task DeleteUserJson(int id) + { + var data = await GetUsersJson(); + var person = data.FirstOrDefault(p => p.Id == id); + if (person != null) + { + data.Remove(person); + await SaveUsersJson(data); + } + } + + public async Task UpdateUserJson(User user) + { + var data = await GetUsersJson(); + var person = data.FirstOrDefault(p => p.Id == user.Id); + if (person != null) + { + person.Name = user.Name; + person.Email = user.Email; + person.Image = user.Image; + await SaveUsersJson(data); + } + } +} \ No newline at end of file From dc90d68d79af800e4d40f8d70db119d8b11153bc Mon Sep 17 00:00:00 2001 From: tomivt Date: Wed, 15 Jan 2025 13:42:51 +0100 Subject: [PATCH 02/79] Apply methods on click --- .../WF-WebAdmin/Pages/DeleteUser.razor.cs | 2 + .../WF-WebAdmin/wwwroot/fake-dataUser.json | 38 ++++--------------- 2 files changed, 10 insertions(+), 30 deletions(-) diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs index 3daab72..21b37cc 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs @@ -37,6 +37,8 @@ namespace WF_WebAdmin.Pages if (userToDelete != null) { users.RemoveAll(u => u.Id == userToDelete.Id); + userService = new UserServiceStub($"fake-dataUser.json"); + await userService.DeleteUserJson(userToDelete.Id); ClosePopup(); } } diff --git a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataUser.json b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataUser.json index 60632fc..bc2560f 100644 --- a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataUser.json +++ b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataUser.json @@ -1,31 +1,9 @@ -[ - { - "Id": 1, - "Image": "https://tse4.mm.bing.net/th/id/OIP.fc5TQflh0cbxB1GUeOdk6gHaK8?w=123&h=180&c=7&r=0&o=5&pid=1.7", - "Name": "Demo", - "Email": "demo@gmail.com", - "DateCreation": "2024-12-12" - - }, - { - "Id": 2, - "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7", - "Name": "exploit", - "Email": "exploit@gmail.com", - "DateCreation": "2024-11-12" - }, - { - "Id": 3, - "Image": "https://tse4.mm.bing.net/th/id/OIP.XNQPKwc1OUfvnSO9MsxDYgHaE7?w=202&h=180&c=7&r=0&o=5&pid=1.7", - "Name": "testeur", - "Email": "testeur@gmail.com", - "DateCreation": "2024-08-02" - }, - { - "Id": 4, - "Image": "https://tse2.mm.bing.net/th/id/OIP.3vXkEUJ9J8s-GsnBC6I3KAHaF0?w=185&h=180&c=7&r=0&o=5&pid=1.7", - "Name": "dev", - "Email": "dev@gmail.com", - "DateCreation": "2024-10-10" - } +[ + { + "Id": 4, + "Image": "https://tse2.mm.bing.net/th/id/OIP.3vXkEUJ9J8s-GsnBC6I3KAHaF0?w=185\u0026h=180\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", + "Name": "dev", + "Email": "dev@gmail.com", + "DateCreation": "2024-10-10T00:00:00" + } ] \ No newline at end of file From 750785032ba5f7e4796b7fb9812fe0d008b78f33 Mon Sep 17 00:00:00 2001 From: Louis GUICHARD-MONTGUERS Date: Wed, 15 Jan 2025 13:56:03 +0100 Subject: [PATCH 03/79] Quote stub json --- .../WF-WebAdmin/Service/IQuoteServiceJson.cs | 17 ++++ .../WF-WebAdmin/Service/QuoteServiceStub.cs | 84 ++++++++++--------- 2 files changed, 60 insertions(+), 41 deletions(-) create mode 100644 WF-WebAdmin/WF-WebAdmin/Service/IQuoteServiceJson.cs diff --git a/WF-WebAdmin/WF-WebAdmin/Service/IQuoteServiceJson.cs b/WF-WebAdmin/WF-WebAdmin/Service/IQuoteServiceJson.cs new file mode 100644 index 0000000..0a93f33 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Service/IQuoteServiceJson.cs @@ -0,0 +1,17 @@ +using WF_WebAdmin.Model; + +namespace WF_WebAdmin.Service +{ + public interface IQuoteServiceJson + { + public Task> GetQuoteJson(); + + public Task SaveQuoteJson(List users); + + public Task AddQuoteJson(User user); + + public Task DeleteQuoteJson(int id); + + public Task UpdateQuoteJson(User user); + } +} diff --git a/WF-WebAdmin/WF-WebAdmin/Service/QuoteServiceStub.cs b/WF-WebAdmin/WF-WebAdmin/Service/QuoteServiceStub.cs index 6619214..0ec9970 100644 --- a/WF-WebAdmin/WF-WebAdmin/Service/QuoteServiceStub.cs +++ b/WF-WebAdmin/WF-WebAdmin/Service/QuoteServiceStub.cs @@ -1,64 +1,66 @@ -using Microsoft.AspNetCore.Components; +using System.Text.Json; using WF_WebAdmin.Model; -using static System.Net.WebRequestMethods; -namespace WF_WebAdmin.Service -{ - public class QuoteServiceStub : IQuoteService - { - [Inject] public HttpClient Http { get; set; } - - [Inject] public NavigationManager NavigationManager { get; set; } +namespace WF_WebAdmin.Service; + public class QuoteServiceStub : IQuoteServiceJson + { + private readonly string _jsonFilePath; - public Task addQuote(Quote quote) - { - throw new NotImplementedException(); - } - - public Task removeQuote(Quote quote) - { - throw new NotImplementedException(); - } - - public Task validQuote(Quote quote) + public QuoteServiceStub(string filePath) { - throw new NotImplementedException(); + _jsonFilePath = Path.Combine(Environment.CurrentDirectory, "wwwroot", filePath); } - public Task updateQuote(Quote quote) + public async Task> GetQuoteJson() { - throw new NotImplementedException(); - } + if (!File.Exists(_jsonFilePath)) + { + Console.Out.WriteLine($"{_jsonFilePath} not found"); + return new List(); + } - public Task> getAllQuote() - { - throw new NotImplementedException(); + var json = await File.ReadAllTextAsync(_jsonFilePath); + return JsonSerializer.Deserialize>(json) ?? new List(); } - public Task> getSomeQuote(int nb, int page) + public async Task SaveQuoteJson(List users) { - throw new NotImplementedException(); + var json = JsonSerializer.Serialize(users, new JsonSerializerOptions { WriteIndented = true }); + await File.WriteAllTextAsync(_jsonFilePath, json); } - public Task> getOnequote(int id) + public async Task AddQuoteJson(User user) { - throw new NotImplementedException(); + var data = await GetQuoteJson(); + user.Id = data.Count > 0 ? data.Max(p => p.Id) + 1 : 1; + data.Add(user); + await SaveQuoteJson(data); } - public Task> reserchQuote(string reserch, List argument) + public async Task DeleteQuoteJson(int id) { - throw new NotImplementedException(); + var data = await GetQuoteJson(); + var person = data.FirstOrDefault(p => p.Id == id); + if (person != null) + { + data.Remove(person); + await SaveQuoteJson(data); + } } - public Task> getAllQuoteInvalid() + public async Task UpdateQuoteJson(User user) { - throw new NotImplementedException(); + var data = await GetQuoteJson(); + var person = data.FirstOrDefault(p => p.Id == user.Id); + if (person != null) + { + person.Name = user.Name; + person.Email = user.Email; + person.Image = user.Image; + await SaveQuoteJson(data); + } } - public Task> getSomeQuoteInvalid(int nb, int page) - { - throw new NotImplementedException(); - } - } -} +} + \ No newline at end of file From b3f3133e1aa373a2c67d1b4d87fbe76f71914536 Mon Sep 17 00:00:00 2001 From: tomivt Date: Wed, 15 Jan 2025 14:42:58 +0100 Subject: [PATCH 04/79] Add modify/update on click button --- .../WF-WebAdmin/Pages/DeleteUser.razor | 34 ++++++++++++------- .../WF-WebAdmin/Pages/DeleteUser.razor.cs | 26 +++++++++++--- WF-WebAdmin/WF-WebAdmin/wwwroot/css/site.css | 5 +-- .../WF-WebAdmin/wwwroot/fake-dataUser.json | 4 +-- 4 files changed, 47 insertions(+), 22 deletions(-) diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor index 47af991..d586324 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor @@ -1,11 +1,10 @@ @page "/deleteuser" +@using WF_WebAdmin.Model Gestion utilisateur

Gestion des utilisateurs

- - @if (users != null) {

Utilisateurs présents:

@@ -17,29 +16,38 @@

Nom d'utilisateur : @user.Name

Email de l'utilisateur : @user.Email

Date de création de l'utilisateur : @user.DateCreation.ToShortDateString()

- + + } - - @if (showPopup) + @if (showDeletePopup) {

Êtes-vous sûr de vouloir supprimer cet utilisateur ?

- + + +
+
+ } + @if (showModifyPopup) + { +
+
+

Modifier les informations de l'utilisateur :

+ + + + + + +
} - - } else {

Aucun utilisateurs présents sur le site

} - - -@code { - -} diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs index 21b37cc..bca070f 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs @@ -7,8 +7,10 @@ namespace WF_WebAdmin.Pages { public partial class DeleteUser { - private bool showPopup = false; + private bool showDeletePopup = false; + private bool showModifyPopup = false; private User userToDelete = null; + private User selectedUser; [Inject] public HttpClient Http { get; set; } @@ -25,27 +27,41 @@ namespace WF_WebAdmin.Pages users = await userService.GetUsersJson(); } - private void ShowConfirmation(User user) + private void ShowDeleteConfirmation(User user) { // Afficher la modale et mémoriser l'utilisateur à supprimer userToDelete = user; - showPopup = true; + showDeletePopup = true; + } + + private void ShowModifyConfirmation(User user) + { + // Afficher la modale et mémoriser l'utilisateur à supprimer + selectedUser = user; + showModifyPopup = true; } private async Task RemoveUser() { if (userToDelete != null) { - users.RemoveAll(u => u.Id == userToDelete.Id); userService = new UserServiceStub($"fake-dataUser.json"); await userService.DeleteUserJson(userToDelete.Id); ClosePopup(); } } + private async Task ModifyUser() + { + userService = new UserServiceStub($"fake-dataUser.json"); + await userService.UpdateUserJson(selectedUser); + ClosePopup(); + } + private void ClosePopup() { - showPopup = false; + showDeletePopup = false; + showModifyPopup = false; } } diff --git a/WF-WebAdmin/WF-WebAdmin/wwwroot/css/site.css b/WF-WebAdmin/WF-WebAdmin/wwwroot/css/site.css index 9f8f5cf..17da76e 100644 --- a/WF-WebAdmin/WF-WebAdmin/wwwroot/css/site.css +++ b/WF-WebAdmin/WF-WebAdmin/wwwroot/css/site.css @@ -105,7 +105,7 @@ button { left: 0; width: 100%; height: 100%; - background-color: white border-radius:20px; + border-radius:20px; display: flex; justify-content: center; align-items: center; @@ -113,10 +113,11 @@ button { } .contentPopup { - background-color: white; padding: 20px; border-radius: 20px; + border: 3px solid black; display: flex; + background-color: white; flex-direction: column; gap: 10px; width: 300px; diff --git a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataUser.json b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataUser.json index bc2560f..01ef57f 100644 --- a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataUser.json +++ b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataUser.json @@ -2,8 +2,8 @@ { "Id": 4, "Image": "https://tse2.mm.bing.net/th/id/OIP.3vXkEUJ9J8s-GsnBC6I3KAHaF0?w=185\u0026h=180\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", - "Name": "dev", - "Email": "dev@gmail.com", + "Name": "jesus", + "Email": "jesus@allah.coran", "DateCreation": "2024-10-10T00:00:00" } ] \ No newline at end of file From d84d419ee43cb70e765a9eb864ab72291d0af0d1 Mon Sep 17 00:00:00 2001 From: Kevin MONDEJAR Date: Tue, 21 Jan 2025 09:53:36 +0100 Subject: [PATCH 05/79] J ai ratraper les connerie de tommy pour pas changer --- .../WF-WebAdmin/Pages/ModifQuote.razor | 4 + .../WF-WebAdmin/Pages/ModifQuote.razor.cs | 61 +++++++++- WF-WebAdmin/WF-WebAdmin/Program.cs | 3 +- .../WF-WebAdmin/Service/IQuoteService.cs | 4 +- .../WF-WebAdmin/Service/QuoteServiceStub.cs | 108 ++++++++++++------ .../WF-WebAdmin/wwwroot/fake-dataQuote.json | 40 +++++++ 6 files changed, 180 insertions(+), 40 deletions(-) diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor index d562f7a..2817608 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor @@ -21,4 +21,8 @@ + +
+ @pagination +
} \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs index 5ba6ad3..a9e8524 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs @@ -1,5 +1,7 @@ using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Mvc.RazorPages; using WF_WebAdmin.Model; +using WF_WebAdmin.Service; namespace WF_WebAdmin.Pages { @@ -9,17 +11,64 @@ namespace WF_WebAdmin.Pages private int MaxValue = 5; - [Inject] - public HttpClient Http { get; set; } + private int pages = 1; + + private int maxPage; + + private RenderFragment pagination; [Inject] - public NavigationManager NavigationManager { get; set; } + public IQuoteService QuoteService { get; set; } protected override async Task OnInitializedAsync() { - string path = $"{NavigationManager.BaseUri}fake-dataModifQuote.json"; - Console.WriteLine($"filePath {path}"); - quotes = await Http.GetFromJsonAsync(path); + maxPage = await QuoteService.getNbQuote() / MaxValue; + if(maxPage * MaxValue != await QuoteService.getNbQuote()) + maxPage += 1; + List quotesList = await QuoteService.getSomeQuote(MaxValue, pages); + quotes = quotesList.ToArray(); + buildPagination(); + } + + protected void buildPagination() + { + if (pages == 1) + { + pagination = __builder => + { + __builder.AddMarkupContent(0, @" + + +

...

+ + "); + }; + } + + } + + protected async Task pageSuivante() + { + pages += 1; + List quotesList = await QuoteService.getSomeQuote(MaxValue, pages); + quotes = quotesList.ToArray(); + } + + protected async Task pagePrcdente() + { + if (pages > 1) + { + pages -= 1; + List quotesList = await QuoteService.getSomeQuote(MaxValue, pages); + quotes = quotesList.ToArray(); + } + } + + protected async Task pageNumero(int page) + { + this.pages = page; + List quotesList = await QuoteService.getSomeQuote(MaxValue, this.pages); + quotes = quotesList.ToArray(); } } } diff --git a/WF-WebAdmin/WF-WebAdmin/Program.cs b/WF-WebAdmin/WF-WebAdmin/Program.cs index fa0d376..5af7669 100644 --- a/WF-WebAdmin/WF-WebAdmin/Program.cs +++ b/WF-WebAdmin/WF-WebAdmin/Program.cs @@ -4,6 +4,7 @@ using Blazorise.Icons.FontAwesome; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; using WF_WebAdmin.Data; +using WF_WebAdmin.Service; var builder = WebApplication.CreateBuilder(args); @@ -11,7 +12,7 @@ var builder = WebApplication.CreateBuilder(args); builder.Services.AddRazorPages(); builder.Services.AddServerSideBlazor(); builder.Services.AddSingleton(); - +builder.Services.AddScoped(); builder.Services.AddHttpClient(); builder.Services diff --git a/WF-WebAdmin/WF-WebAdmin/Service/IQuoteService.cs b/WF-WebAdmin/WF-WebAdmin/Service/IQuoteService.cs index a76b4b0..356edd8 100644 --- a/WF-WebAdmin/WF-WebAdmin/Service/IQuoteService.cs +++ b/WF-WebAdmin/WF-WebAdmin/Service/IQuoteService.cs @@ -16,12 +16,14 @@ namespace WF_WebAdmin.Service public Task> getSomeQuote(int nb, int page); - public Task> getOnequote(int id); + public Task getOnequote(int id); public Task> reserchQuote(string reserch, List argument); public Task> getAllQuoteInvalid(); public Task> getSomeQuoteInvalid(int nb, int page); + + public Task getNbQuote(); } } diff --git a/WF-WebAdmin/WF-WebAdmin/Service/QuoteServiceStub.cs b/WF-WebAdmin/WF-WebAdmin/Service/QuoteServiceStub.cs index 0ec9970..6644168 100644 --- a/WF-WebAdmin/WF-WebAdmin/Service/QuoteServiceStub.cs +++ b/WF-WebAdmin/WF-WebAdmin/Service/QuoteServiceStub.cs @@ -3,64 +3,108 @@ using WF_WebAdmin.Model; namespace WF_WebAdmin.Service; - public class QuoteServiceStub : IQuoteServiceJson + public class QuoteServiceStub : IQuoteService { - private readonly string _jsonFilePath; + private readonly string _jsonFilePath = Path.Combine(Environment.CurrentDirectory, "wwwroot", "fake-dataQuote.json"); - public QuoteServiceStub(string filePath) + public async Task saveQuoteJson(List quotes) { - _jsonFilePath = Path.Combine(Environment.CurrentDirectory, "wwwroot", filePath); + var json = JsonSerializer.Serialize(quotes, new JsonSerializerOptions { WriteIndented = true }); + await File.WriteAllTextAsync(_jsonFilePath, json); } - public async Task> GetQuoteJson() + public async Task addQuote(Quote quote) { - if (!File.Exists(_jsonFilePath)) + var data = await getAllQuote(); + quote.Id = data.Count > 0 ? data.Max(p => p.Id) + 1 : 1; + data.Add(quote); + await saveQuoteJson(data); + } + + public async Task removeQuote(Quote quote) + { + var data = await getAllQuote(); + var q = data.FirstOrDefault(p => p.Id == quote.Id); + if (q != null) { - Console.Out.WriteLine($"{_jsonFilePath} not found"); - return new List(); + data.Remove(q); + await saveQuoteJson(data); } + } - var json = await File.ReadAllTextAsync(_jsonFilePath); - return JsonSerializer.Deserialize>(json) ?? new List(); + public async Task validQuote(Quote quote) + { + throw new NotImplementedException(); } - public async Task SaveQuoteJson(List users) + public async Task updateQuote(Quote quote) { - var json = JsonSerializer.Serialize(users, new JsonSerializerOptions { WriteIndented = true }); - await File.WriteAllTextAsync(_jsonFilePath, json); + var data = await getAllQuote(); + var q = data.FirstOrDefault(p => p.Id == quote.Id); + if (q != null) + { + q.Content = quote.Content; + q.Charac = quote.Charac; + q.ImgPath = quote.ImgPath; + q.TitleSrc = quote.TitleSrc; + q.DateSrc = quote.DateSrc; + q.Langue = quote.Langue; + await saveQuoteJson(data); + } } - public async Task AddQuoteJson(User user) + public async Task> getAllQuote() { - var data = await GetQuoteJson(); - user.Id = data.Count > 0 ? data.Max(p => p.Id) + 1 : 1; - data.Add(user); - await SaveQuoteJson(data); + if (!File.Exists(_jsonFilePath)) + { + Console.Out.WriteLine($"{_jsonFilePath} not found"); + return new List(); + } + + var json = await File.ReadAllTextAsync(_jsonFilePath); + return JsonSerializer.Deserialize>(json) ?? new List(); } - public async Task DeleteQuoteJson(int id) + public async Task> getSomeQuote(int nb, int page) { - var data = await GetQuoteJson(); - var person = data.FirstOrDefault(p => p.Id == id); - if (person != null) + var quotes = await getAllQuote(); + if((page - 1) * nb + nb > quotes.Count()) { - data.Remove(person); - await SaveQuoteJson(data); + return quotes.GetRange(quotes.Count()-nb, nb); } + return quotes.GetRange((page - 1) * nb, nb); } - public async Task UpdateQuoteJson(User user) + public async Task getOnequote(int id) { - var data = await GetQuoteJson(); - var person = data.FirstOrDefault(p => p.Id == user.Id); - if (person != null) + var data = await getAllQuote(); + var q = data.FirstOrDefault(p => p.Id == id); + if (q != null) { - person.Name = user.Name; - person.Email = user.Email; - person.Image = user.Image; - await SaveQuoteJson(data); + return q; } + return new Quote(); + } + + public async Task> reserchQuote(string reserch, List argument) + { + throw new NotImplementedException(); + } + + public async Task> getAllQuoteInvalid() + { + throw new NotImplementedException(); } + public async Task> getSomeQuoteInvalid(int nb, int page) + { + throw new NotImplementedException(); + } + + public async Task getNbQuote() + { + var data = await getAllQuote(); + return data.Count; + } } \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataQuote.json b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataQuote.json index f38cd34..2b96570 100644 --- a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataQuote.json +++ b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataQuote.json @@ -18,5 +18,45 @@ "DateSrc": "2002-02-02", "Like": 0, "Langue": "fr" + }, + { + "Id": 3, + "Content": "coucou", + "Charac": "moi", + "ImgPath": "img", + "TitleSrc": "G4", + "DateSrc": "2001-01-01", + "Like": 20, + "Langue": "fr" + }, + { + "Id": 4, + "Content": "boujour", + "Charac": "toi", + "ImgPath": "img", + "TitleSrc": "G4", + "DateSrc": "2002-02-02", + "Like": 0, + "Langue": "fr" + }, + { + "Id": 5, + "Content": "coucou", + "Charac": "moi", + "ImgPath": "img", + "TitleSrc": "G4", + "DateSrc": "2001-01-01", + "Like": 20, + "Langue": "fr" + }, + { + "Id": 6, + "Content": "boujour", + "Charac": "toi", + "ImgPath": "img", + "TitleSrc": "G4", + "DateSrc": "2002-02-02", + "Like": 0, + "Langue": "fr" } ] \ No newline at end of file From f1d4537b72f8cbb4b7ac03fec6198685f6da6bc5 Mon Sep 17 00:00:00 2001 From: Kevin MONDEJAR Date: Tue, 21 Jan 2025 11:39:07 +0100 Subject: [PATCH 06/79] enlever les accent --- .../WF-WebAdmin/Pages/ModifQuote.razor | 14 +++++++++++-- .../WF-WebAdmin/Pages/ModifQuote.razor.cs | 20 +------------------ 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor index 2817608..ca2883e 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor @@ -22,7 +22,17 @@ -
+ @*
@pagination -
+
*@ + + if (pages == 1) + { + + + +

...

+ + + } } \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs index a9e8524..3fecd73 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs @@ -27,24 +27,6 @@ namespace WF_WebAdmin.Pages maxPage += 1; List quotesList = await QuoteService.getSomeQuote(MaxValue, pages); quotes = quotesList.ToArray(); - buildPagination(); - } - - protected void buildPagination() - { - if (pages == 1) - { - pagination = __builder => - { - __builder.AddMarkupContent(0, @" - - -

...

- - "); - }; - } - } protected async Task pageSuivante() @@ -54,7 +36,7 @@ namespace WF_WebAdmin.Pages quotes = quotesList.ToArray(); } - protected async Task pagePrcdente() + protected async Task pagePrecedente() { if (pages > 1) { From 35e33f14fc4b46938725c3f229ebe8bce59d827b Mon Sep 17 00:00:00 2001 From: Kevin MONDEJAR Date: Tue, 21 Jan 2025 15:24:43 +0100 Subject: [PATCH 07/79] comencement datagrid user --- WF-WebAdmin/WF-WebAdmin/Converter/QuoteDTO.cs | 4 +- .../WF-WebAdmin/Converter/QuoteExtension.cs | 4 +- WF-WebAdmin/WF-WebAdmin/Model/Quote.cs | 4 +- WF-WebAdmin/WF-WebAdmin/Model/QuoteModel.cs | 27 ++ .../WF-WebAdmin/Pages/DeleteUser.razor | 7 + .../WF-WebAdmin/Pages/DeleteUser.razor.cs | 22 +- WF-WebAdmin/WF-WebAdmin/Pages/Edit.razor | 5 + WF-WebAdmin/WF-WebAdmin/Pages/Edit.razor.cs | 13 + .../WF-WebAdmin/Pages/ModifQuote.razor | 29 +- .../WF-WebAdmin/Pages/ModifQuote.razor.cs | 44 +-- .../WF-WebAdmin/Service/IUserService.cs | 18 +- .../WF-WebAdmin/Service/UserServiceStub.cs | 141 ++++--- .../WF-WebAdmin/wwwroot/fake-dataQuote.json | 348 ++++++++++++------ 13 files changed, 438 insertions(+), 228 deletions(-) create mode 100644 WF-WebAdmin/WF-WebAdmin/Model/QuoteModel.cs create mode 100644 WF-WebAdmin/WF-WebAdmin/Pages/Edit.razor create mode 100644 WF-WebAdmin/WF-WebAdmin/Pages/Edit.razor.cs diff --git a/WF-WebAdmin/WF-WebAdmin/Converter/QuoteDTO.cs b/WF-WebAdmin/WF-WebAdmin/Converter/QuoteDTO.cs index 092db9d..26a68a8 100644 --- a/WF-WebAdmin/WF-WebAdmin/Converter/QuoteDTO.cs +++ b/WF-WebAdmin/WF-WebAdmin/Converter/QuoteDTO.cs @@ -9,7 +9,7 @@ namespace WF_WebAdmin.Converter public string Content { get; set; } public int Likes { get; set; } public string Langue { get; set; } - public bool? IsValide { get; set; } + public bool IsValide { get; set; } public string? Reason { get; set; } public int? IdCaracter { get; set; } public string NameCharac { get; set; } @@ -21,7 +21,7 @@ namespace WF_WebAdmin.Converter public int? IdImg { get; set; } public string ImgPath { get; set; } - public QuoteDTO(int id_quote,string content,int likes,string langue,bool? isValide,string? reason,int? id_caracter,string name_charac,int? id_source,string title,DateTime date,int? id_user_verif,string name_user ,int? id_img,string img_path) + public QuoteDTO(int id_quote,string content,int likes,string langue,bool isValide,string? reason,int? id_caracter,string name_charac,int? id_source,string title,DateTime date,int? id_user_verif,string name_user ,int? id_img,string img_path) { this.Id = id_quote; this.Content = content; diff --git a/WF-WebAdmin/WF-WebAdmin/Converter/QuoteExtension.cs b/WF-WebAdmin/WF-WebAdmin/Converter/QuoteExtension.cs index 088520a..a7bd57f 100644 --- a/WF-WebAdmin/WF-WebAdmin/Converter/QuoteExtension.cs +++ b/WF-WebAdmin/WF-WebAdmin/Converter/QuoteExtension.cs @@ -6,13 +6,13 @@ namespace WF_WebAdmin.Converter { public QuoteDTO QuoteToDTO(Quote q) { - QuoteDTO quote = new QuoteDTO(q.Id, q.Content, q.Like, q.Langue, null,null, null,q.Charac,null,q.TitleSrc,q.DateSrc,null,q.UserProposition,null,q.ImgPath); + QuoteDTO quote = new QuoteDTO(q.Id, q.Content, q.Like, q.Langue, q.IsValid,null, null,q.Charac,null,q.TitleSrc,q.DateSrc,null,q.UserProposition,null,q.ImgPath); return quote; } public Quote DTOToQuote(QuoteDTO q) { - Quote quote = new Quote(q.Id, q.Content,q.NameCharac,q.ImgPath,q.TitleSrc,q.DateSrc,q.Likes,q.Langue,q.NameUser); + Quote quote = new Quote(q.Id, q.Content,q.NameCharac,q.ImgPath,q.TitleSrc,q.DateSrc,q.Likes,q.Langue,q.NameUser,q.IsValide); return quote; } } diff --git a/WF-WebAdmin/WF-WebAdmin/Model/Quote.cs b/WF-WebAdmin/WF-WebAdmin/Model/Quote.cs index 5a56083..ffc7f05 100644 --- a/WF-WebAdmin/WF-WebAdmin/Model/Quote.cs +++ b/WF-WebAdmin/WF-WebAdmin/Model/Quote.cs @@ -13,8 +13,9 @@ namespace WF_WebAdmin.Model public string TitleSrc { get; set; } public DateTime DateSrc { get; set; } public string UserProposition { get; set; } + public bool IsValid { get; set; } - public Quote(int id, string content, string charac, string imgPath, string titleSrc, DateTime dateSrc, int like, string langue, string userProposition) + public Quote(int id, string content, string charac, string imgPath, string titleSrc, DateTime dateSrc, int like, string langue, string userProposition, bool isvalid) { Id = id; Content = content; @@ -25,6 +26,7 @@ namespace WF_WebAdmin.Model Like = like; Langue = langue; UserProposition = userProposition; + IsValid = isvalid; } /* public int Id { get; set; } diff --git a/WF-WebAdmin/WF-WebAdmin/Model/QuoteModel.cs b/WF-WebAdmin/WF-WebAdmin/Model/QuoteModel.cs new file mode 100644 index 0000000..1db3196 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Model/QuoteModel.cs @@ -0,0 +1,27 @@ +using System.ComponentModel.DataAnnotations; + +namespace WF_WebAdmin.Model +{ + public class QuoteModel + { + public int Id { get; set; } + + [Required] + [StringLength(300, ErrorMessage = "La citation ne peut pas dépasser les 300 caractère.")] + public string Content { get; set; } + + public int Like { get; set; } + + [Required] + [StringLength(2, ErrorMessage = "La langue ne peut pas dépasser 2 caractère.")] + public string Langue { get; set; } + + + public string Charac { get; set; } + public string ImgPath { get; set; } + public string TitleSrc { get; set; } + public DateTime DateSrc { get; set; } + public string UserProposition { get; set; } + public bool IsValid { get; set; } + } +} diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor index 24155f1..398b4c7 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor @@ -55,6 +55,13 @@ else } + + + + + @if (showPopupDelete) { diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs index 7dc042d..cfaecb3 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Components; +using Blazorise.DataGrid; +using Microsoft.AspNetCore.Components; using Microsoft.Extensions.Configuration.UserSecrets; using WF_WebAdmin.Model; using WF_WebAdmin.Service; @@ -14,6 +15,9 @@ namespace WF_WebAdmin.Pages private bool showPopupDelete = false; private bool showPopupAdmin = false; private User userToAdmin = null; + private int MaxValue = 5; + private int totalItem; + [Inject] public HttpClient Http { get; set; } @@ -24,15 +28,29 @@ namespace WF_WebAdmin.Pages private List users; private UserServiceStub userService; + + protected override async Task OnInitializedAsync() { userService = new UserServiceStub($"fake-dataUsers.json"); users = await userService.GetUsersJson(); } - private void ShowDeleteConfirmation(User user) + private async Task OnReadData(DataGridReadDataEventArgs e) { + if (e.CancellationToken.IsCancellationRequested) + { + return; + } + + var response = await userService.getSomeUser(e.PageSize, e.Page); + + if (!e.CancellationToken.IsCancellationRequested) + { + totalItem = await userService.getNbUser(); + users = response.ToArray(); + } } // ------- Popup remove user ------- diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/Edit.razor b/WF-WebAdmin/WF-WebAdmin/Pages/Edit.razor new file mode 100644 index 0000000..5f59560 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Pages/Edit.razor @@ -0,0 +1,5 @@ +@page "/edit/{Id:int}" + +

Editer

+ +
My parameter: @Id
\ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/Edit.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/Edit.razor.cs new file mode 100644 index 0000000..4d09214 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Pages/Edit.razor.cs @@ -0,0 +1,13 @@ +using Microsoft.AspNetCore.Components; +using WF_WebAdmin.Model; + +namespace WF_WebAdmin.Pages +{ + public partial class Edit + { + [Parameter] + public int Id { get; set; } + + private QuoteModel quoteModel = new(); + } +} diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor index cb8f955..ee6cebd 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor @@ -7,11 +7,12 @@

Ajouter une recherche

-@if (quotes != null) -{ @@ -20,19 +21,9 @@ - - - @*
- @pagination -
*@ - - if (pages == 1) - { - - - -

...

- - - } -} \ No newline at end of file + + + Editer + + + \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs index 3fecd73..155481b 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs @@ -1,5 +1,5 @@ +using Blazorise.DataGrid; using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Mvc.RazorPages; using WF_WebAdmin.Model; using WF_WebAdmin.Service; @@ -11,46 +11,26 @@ namespace WF_WebAdmin.Pages private int MaxValue = 5; - private int pages = 1; - - private int maxPage; - - private RenderFragment pagination; + private int totalItem; [Inject] public IQuoteService QuoteService { get; set; } - protected override async Task OnInitializedAsync() + private async Task OnReadData(DataGridReadDataEventArgs e) { - maxPage = await QuoteService.getNbQuote() / MaxValue; - if(maxPage * MaxValue != await QuoteService.getNbQuote()) - maxPage += 1; - List quotesList = await QuoteService.getSomeQuote(MaxValue, pages); - quotes = quotesList.ToArray(); - } + if (e.CancellationToken.IsCancellationRequested) + { + return; + } - protected async Task pageSuivante() - { - pages += 1; - List quotesList = await QuoteService.getSomeQuote(MaxValue, pages); - quotes = quotesList.ToArray(); - } - protected async Task pagePrecedente() - { - if (pages > 1) + var response = await QuoteService.getSomeQuote(e.PageSize, e.Page); + + if (!e.CancellationToken.IsCancellationRequested) { - pages -= 1; - List quotesList = await QuoteService.getSomeQuote(MaxValue, pages); - quotes = quotesList.ToArray(); + totalItem = await QuoteService.getNbQuote(); + quotes = response.ToArray(); } } - - protected async Task pageNumero(int page) - { - this.pages = page; - List quotesList = await QuoteService.getSomeQuote(MaxValue, this.pages); - quotes = quotesList.ToArray(); - } } } diff --git a/WF-WebAdmin/WF-WebAdmin/Service/IUserService.cs b/WF-WebAdmin/WF-WebAdmin/Service/IUserService.cs index 3a505f4..7357e21 100644 --- a/WF-WebAdmin/WF-WebAdmin/Service/IUserService.cs +++ b/WF-WebAdmin/WF-WebAdmin/Service/IUserService.cs @@ -4,18 +4,22 @@ namespace WF_WebAdmin.Service { public interface IUserService { - public void removeUserJs(User user); + public Task removeUser(User user); - public void updateRole(User user); + public Task updateRole(User user); - public void downgradeRole(User user); + public Task downgradeRole(User user); - public List getAllUser(); + public Task updateUser(User user); - public List getSomeUser(int nb, int page); + public Task> getAllUser(); - public User getOneUser(int id); + public Task> getSomeUser(int nb, int page); - public List reserchUsers(string reserch, List args); + public Task getOneUser(int id); + + public Task> reserchUsers(string reserch, List args); + + public Task getNbUser(); } } diff --git a/WF-WebAdmin/WF-WebAdmin/Service/UserServiceStub.cs b/WF-WebAdmin/WF-WebAdmin/Service/UserServiceStub.cs index bc34fbd..9dfd7fb 100644 --- a/WF-WebAdmin/WF-WebAdmin/Service/UserServiceStub.cs +++ b/WF-WebAdmin/WF-WebAdmin/Service/UserServiceStub.cs @@ -3,62 +3,95 @@ using WF_WebAdmin.Model; namespace WF_WebAdmin.Service; -public class UserServiceStub : IUserServiceJson +public class UserServiceStub : IUserService { - private readonly string _jsonFilePath; - - public UserServiceStub(string filePath) - { - _jsonFilePath = Path.Combine(Environment.CurrentDirectory, "wwwroot", filePath); - } - - public async Task> GetUsersJson() - { - if (!File.Exists(_jsonFilePath)) - { - Console.Out.WriteLine($"{_jsonFilePath} not found"); - return new List(); - } - - var json = await File.ReadAllTextAsync(_jsonFilePath); - return JsonSerializer.Deserialize>(json) ?? new List(); - } - - public async Task SaveUsersJson(List users) + private readonly string _jsonFilePath = Path.Combine(Environment.CurrentDirectory, "wwwroot", "fake-dataUsers.json"); + + + public async Task saveUsersJson(List users) { var json = JsonSerializer.Serialize(users, new JsonSerializerOptions { WriteIndented = true }); await File.WriteAllTextAsync(_jsonFilePath, json); - } - - public async Task AddUserJson(User user) - { - var data = await GetUsersJson(); - user.Id = data.Count > 0 ? data.Max(p => p.Id) + 1 : 1; - data.Add(user); - await SaveUsersJson(data); - } - - public async Task DeleteUserJson(int id) - { - var data = await GetUsersJson(); - var person = data.FirstOrDefault(p => p.Id == id); - if (person != null) - { - data.Remove(person); - await SaveUsersJson(data); - } - } - - public async Task UpdateUserJson(User user) - { - var data = await GetUsersJson(); - var person = data.FirstOrDefault(p => p.Id == user.Id); - if (person != null) - { - person.Name = user.Name; - person.Email = user.Email; - person.Image = user.Image; - await SaveUsersJson(data); - } - } + } + + public async Task removeUser(User user) + { + var data = await getAllUser(); + var u = data.FirstOrDefault(p => p.Id == user.Id); + if (u != null) + { + data.Remove(u); + await saveUsersJson(data); + } + } + + public Task updateRole(User user) + { + user.IsAdmin = true; + return updateUser(user); + } + + public Task downgradeRole(User user) + { + user.IsAdmin = false; + return updateUser(user); + } + + public async Task> getAllUser() + { + if (!File.Exists(_jsonFilePath)) + { + Console.Out.WriteLine($"{_jsonFilePath} not found"); + return new List(); + } + + var json = await File.ReadAllTextAsync(_jsonFilePath); + return JsonSerializer.Deserialize>(json) ?? new List(); + } + + public async Task> getSomeUser(int nb, int page) + { + var users = await getAllUser(); + if ((page - 1) * nb + nb > users.Count()) + { + return users.GetRange(users.Count() - nb, nb); + } + return users.GetRange((page - 1) * nb, nb); + } + + public async Task getOneUser(int id) + { + var data = await getAllUser(); + var u = data.FirstOrDefault(p => p.Id == id); + if (u != null) + { + return u; + } + return null; + } + + public Task> reserchUsers(string reserch, List args) + { + throw new NotImplementedException(); + } + + public async Task getNbUser() + { + var data = await getAllUser(); + return data.Count; + } + + public async Task updateUser(User user) + { + var data = await getAllUser(); + var person = data.FirstOrDefault(p => p.Id == user.Id); + if (person != null) + { + person.Name = user.Name; + person.Email = user.Email; + person.Image = user.Image; + person.IsAdmin = user.IsAdmin; + await saveUsersJson(data); + } + } } \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataQuote.json b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataQuote.json index 39d4bd4..c10c1ca 100644 --- a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataQuote.json +++ b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataQuote.json @@ -1,112 +1,242 @@ [ { - "id_quote": "1", - "content": "Dans le monde il n’y a pas d’un côté le bien et le mal, il y a une part de lumière et d’ombre en chacun de nous. Ce qui compte c’est celle que l’on choisit de montrer dans nos actes, ça c’est ce que l’on est vraiment.", - "likes": 0, - "langue": "fr", - "isValide": true, - "reason": "insertion de test", - "id_caracter": 50, - "id_source": 38, - "id_user_verif": 1 - }, - { - "id_quote": "22", - "content": "Nous avons parié, mon père et moi. Je ne crois pas que tu tiendras dix minutes dans ce tournoi. Lui, il n’est pas d’accord, il croit que tu n’en tiendras pas cinq.", - "likes": 0, - "langue": "fr", - "isValide": true, - "reason": "insertion de test", - "id_caracter": 7, - "id_source": 58, - "id_user_verif": 1 - }, - { - "id_quote": "45", - "content": "Je vous aurais suivi mon frère, mon capitaine, mon roi.", - "likes": 0, - "langue": "fr", - "isValide": true, - "reason": "insertion de test", - "id_caracter": 77, - "id_source": 76, - "id_user_verif": 1 - }, - { - "id_quote": "90", - "content": "Si vous le voulez bien, on se taillera des pipes plus tard, les enfants.", - "likes": 0, - "langue": "fr", - "isValide": true, - "reason": "insertion de test", - "id_caracter": 82, - "id_source": 9, - "id_user_verif": 1 - }, - { - "id_quote": "91", - "content": "Je fais le mort dans la 5e.", - "likes": 0, - "langue": "fr", - "isValide": true, - "reason": "insertion de test", - "id_caracter": 53, - "id_source": 9, - "id_user_verif": 1 - }, - { - "id_quote": "110", - "content": "Il les a tuées avec leur amour. C’est comme ça tous les jours dans le monde entier.", - "likes": 0, - "langue": "fr", - "isValide": true, - "reason": "insertion de test", - "id_caracter": 34, - "id_source": 74, - "id_user_verif": 1 - }, - { - "id_quote": "118", - "content": "La vengeance est un déesse dévorante. Eux aussi en sont victimes… Je ne dois pas céder à son appel. La justice finira par triompher.", - "likes": 0, - "langue": "fr", - "isValide": false, - "reason": "insertion de test", - "id_caracter": 44, - "id_source": 30, - "id_user_verif": 1 - }, - { - "id_quote": "185", - "content": "Tu viens de me montrer au complet ?!", - "likes": 0, - "langue": "fr", - "isValide": false, - "reason": "insertion de test", - "id_caracter": 38, - "id_source": 10, - "id_user_verif": 1 - }, - { - "id_quote": "182", - "content": "Nouille ou pas nouille, tu te préoccupes trop de ce qui a été ou de ce qui sera.", - "likes": 0, - "langue": "fr", - "isValide": false, - "reason": "insertion de test", - "id_caracter": 29, - "id_source": 71, - "id_user_verif": 1 - }, - { - "id_quote": "175", - "content": "Arrête de faire ton Jean-Jacques !", - "likes": 0, - "langue": "fr", - "isValide": false, - "reason": "insertion de test", - "id_caracter": 39, - "id_source": 68, - "id_user_verif": 1 + "Id": 1, + "Content": "Que la force soit avec toi.", + "Like": 150, + "Langue": "fr", + "Charac": "test", + "ImgPath": "http://starwars.com", + "TitleSrc": "Star Wars", + "DateSrc": "2025-01-21", + "UserProposition": "user1", + "isValide": true + }, + { + "Id": 2, + "Content": "Il n’y a pas de place comme chez soi.", + "Like": 120, + "Langue": "fr", + "Charac": "test", + "ImgPath": "http://wizardofoz.com", + "TitleSrc": "Le Magicien d'Oz", + "DateSrc": "2025-01-21", + "UserProposition": "user2", + "isValide": true + }, + { + "Id": 3, + "Content": "C'est le choix qui fait l'homme, non le destin.", + "Like": 90, + "Langue": "fr", + "Charac": "test", + "ImgPath": "http://harrypotter.com", + "TitleSrc": "Harry Potter et la Chambre des Secrets", + "DateSrc": "2025-01-21", + "UserProposition": "user3", + "isValide": true + }, + { + "Id": 4, + "Content": "La magie, c’est de croire en soi, c’est ça la magie.", + "Like": 75, + "Langue": "fr", + "Charac": "test", + "ImgPath": "http://disney.com", + "TitleSrc": "La Belle et la Bête", + "DateSrc": "2025-01-21", + "UserProposition": "user4", + "isValide": true + }, + { + "Id": 5, + "Content": "La vérité est plus étrange que la fiction.", + "Like": 65, + "Langue": "fr", + "Charac": "test", + "ImgPath": "http://theimaginarium.com", + "TitleSrc": "L'Imaginarium du Docteur Parnassus", + "DateSrc": "2025-01-21", + "UserProposition": "user5", + "isValide": true + }, + { + "Id": 6, + "Content": "Un homme qui ne croit pas aux miracles n’est pas un homme.", + "Like": 85, + "Langue": "fr", + "Charac": "test", + "ImgPath": "http://theprinceofpersia.com", + "TitleSrc": "Prince of Persia : Les Sables du Temps", + "DateSrc": "2025-01-21", + "UserProposition": "user6", + "isValide": true + }, + { + "Id": 7, + "Content": "La seule limite à notre réalisation de demain sera nos doutes et hésitations d’aujourd’hui.", + "Like": 100, + "Langue": "fr", + "Charac": "test", + "ImgPath": "http://backtothefuture.com", + "TitleSrc": "Retour vers le futur", + "DateSrc": "2025-01-21", + "UserProposition": "user7", + "isValide": true + }, + { + "Id": 8, + "Content": "L’imagination est plus importante que la connaissance.", + "Like": 200, + "Langue": "fr", + "Charac": "test", + "ImgPath": "http://inceptionmovie.com", + "TitleSrc": "Inception", + "DateSrc": "2025-01-21", + "UserProposition": "user8", + "isValide": true + }, + { + "Id": 9, + "Content": "Ce n’est pas de la magie, c’est de la science, mais on ne comprend pas encore tout.", + "Like": 110, + "Langue": "fr", + "Charac": "test", + "ImgPath": "http://doctorstrange.com", + "TitleSrc": "Doctor Strange", + "DateSrc": "2025-01-21", + "UserProposition": "user9", + "isValide": true + }, + { + "Id": 10, + "Content": "L’important ce n’est pas d’être parfait, c’est d’être vrai.", + "Like": 130, + "Langue": "fr", + "Charac": "test", + "ImgPath": "http://narnia.com", + "TitleSrc": "Le Monde de Narnia", + "DateSrc": "2025-01-21", + "UserProposition": "user10", + "isValide": true + }, + { + "Id": 11, + "Content": "Vous ne pouvez pas vivre sans causer de dommages à quelqu'un d'autre.", + "Like": 110, + "Langue": "fr", + "Charac": "test", + "ImgPath": "http://thematrix.com", + "TitleSrc": "The Matrix", + "DateSrc": "2025-01-21", + "UserProposition": "user11", + "isValide": true + }, + { + "Id": 12, + "Content": "Les rêves, ils ne peuvent pas vous mentir.", + "Like": 80, + "Langue": "fr", + "Charac": "test", + "ImgPath": "http://peterpanmovie.com", + "TitleSrc": "Peter Pan", + "DateSrc": "2025-01-21", + "UserProposition": "user12", + "isValide": true + }, + { + "Id": 13, + "Content": "Tous les hommes meurent, mais pas tous vivent.", + "Like": 95, + "Langue": "fr", + "Charac": "test", + "ImgPath": "http://braveheart.com", + "TitleSrc": "Braveheart", + "DateSrc": "2025-01-21", + "UserProposition": "user13", + "isValide": true + }, + { + "Id": 14, + "Content": "La vie, c’est ce qui nous arrive quand on est occupé à faire d’autres projets.", + "Like": 140, + "Langue": "fr", + "Charac": "test", + "ImgPath": "http://forrestgump.com", + "TitleSrc": "Forrest Gump", + "DateSrc": "2025-01-21", + "UserProposition": "user14", + "isValide": true + }, + { + "Id": 15, + "Content": "Il faut toujours croire en l’impossible, sinon la magie disparaît.", + "Like": 60, + "Langue": "fr", + "Charac": "test", + "ImgPath": "http://harrypotter.com", + "TitleSrc": "Harry Potter à l'école des sorciers", + "DateSrc": "2025-01-21", + "UserProposition": "user15", + "isValide": true + }, + { + "Id": 16, + "Content": "Le pouvoir de l’imaginaire est plus fort que tout.", + "Like": 120, + "Langue": "fr", + "Charac": "test", + "ImgPath": "http://theincrediblesmovie.com", + "TitleSrc": "Les Indestructibles", + "DateSrc": "2025-01-21", + "UserProposition": "user16", + "isValide": true + }, + { + "Id": 17, + "Content": "On peut conquérir l’univers en une journée si on travaille ensemble.", + "Like": 130, + "Langue": "fr", + "Charac": "test", + "ImgPath": "http://guardiansofthegalaxy.com", + "TitleSrc": "Les Gardiens de la Galaxie", + "DateSrc": "2025-01-21", + "UserProposition": "user17", + "isValide": true + }, + { + "Id": 18, + "Content": "La véritable magie vient de l’intérieur.", + "Like": 75, + "Langue": "fr", + "Charac": "test", + "ImgPath": "http://maleficentmovie.com", + "TitleSrc": "Maléfique", + "DateSrc": "2025-01-21", + "UserProposition": "user18", + "isValide": true + }, + { + "Id": 19, + "Content": "On ne voit bien qu’avec le cœur.", + "Like": 200, + "Langue": "fr", + "Charac": "test", + "ImgPath": "http://lepetitprince.com", + "TitleSrc": "Le Petit Prince", + "DateSrc": "2025-01-21", + "UserProposition": "user19", + "isValide": true + }, + { + "Id": 20, + "Content": "Les étoiles sont des rêves en attente d’être vécus.", + "Like": 85, + "Langue": "fr", + "Charac": "test", + "ImgPath": "http://interstellar.com", + "TitleSrc": "Interstellar", + "DateSrc": "2025-01-21", + "UserProposition": "user20", + "isValide": true } -] \ No newline at end of file +] From 944c620e806b1c7d7cdf44dbc7d5240145ff996b Mon Sep 17 00:00:00 2001 From: tomivt Date: Wed, 22 Jan 2025 08:57:46 +0100 Subject: [PATCH 08/79] Add QuizService --- WF-WebAdmin/WF-WebAdmin/Model/Quiz.cs | 1 + .../WF-WebAdmin/Pages/ValidQuiz.razor.cs | 18 +- WF-WebAdmin/WF-WebAdmin/Program.cs | 1 + .../WF-WebAdmin/Service/IQuizService.cs | 24 ++ .../WF-WebAdmin/Service/IQuizServiceJson.cs | 17 ++ .../WF-WebAdmin/Service/QuizService.cs | 25 -- .../WF-WebAdmin/Service/QuizServiceStub.cs | 63 ++++ .../WF-WebAdmin/wwwroot/fake-dataQuiz.json | 282 ------------------ .../WF-WebAdmin/wwwroot/fake_data_quiz.json | 68 +++++ 9 files changed, 189 insertions(+), 310 deletions(-) create mode 100644 WF-WebAdmin/WF-WebAdmin/Service/IQuizService.cs create mode 100644 WF-WebAdmin/WF-WebAdmin/Service/IQuizServiceJson.cs delete mode 100644 WF-WebAdmin/WF-WebAdmin/Service/QuizService.cs create mode 100644 WF-WebAdmin/WF-WebAdmin/Service/QuizServiceStub.cs delete mode 100644 WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataQuiz.json create mode 100644 WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_quiz.json diff --git a/WF-WebAdmin/WF-WebAdmin/Model/Quiz.cs b/WF-WebAdmin/WF-WebAdmin/Model/Quiz.cs index c6035df..0e08045 100644 --- a/WF-WebAdmin/WF-WebAdmin/Model/Quiz.cs +++ b/WF-WebAdmin/WF-WebAdmin/Model/Quiz.cs @@ -9,6 +9,7 @@ namespace WF_WebAdmin.Model public string AnswerC { get; set; } public string AnswerD { get; set; } public string CAnswer { get; set; } + public bool IsValid { get; set; } public string UserProposition { get; set; } } } \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuiz.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuiz.razor.cs index d907e84..76b5d55 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuiz.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuiz.razor.cs @@ -1,23 +1,27 @@ using Blazorise.DataGrid; using Microsoft.AspNetCore.Components; using WF_WebAdmin.Model; +using WF_WebAdmin.Service; namespace WF_WebAdmin.Pages { public partial class ValidQuiz { - private Quiz[] quizzes; - private int totalQuizzes; + private List quizzes; + [Inject] public HttpClient Http { get; set; } [Inject] public NavigationManager NavigationManager { get; set; } + + [Inject] + public IQuizServiceJson QuizService { get; set; } protected override async Task OnInitializedAsync() { - quizzes = await Http.GetFromJsonAsync($"{NavigationManager.BaseUri}fake-dataQuiz.json"); + quizzes = await QuizService.getQuizzesToValidateJson(); } private void OnValidButton(Quiz quiz) @@ -28,6 +32,12 @@ namespace WF_WebAdmin.Pages private void ValidateQuiz(Quiz quiz) { Console.WriteLine($"Quiz {quiz.Id} validated!"); + + Quiz newQuiz = quiz; + newQuiz.IsValid = true; + + // Mis à jour de l'état du quiz + QuizService.updateQuizJson(quiz); } private void OnRejectButton(Quiz quiz) @@ -38,6 +48,8 @@ namespace WF_WebAdmin.Pages private void RejectQuiz(Quiz quiz) { Console.WriteLine($"Quiz {quiz.Id} rejected!"); + + QuizService.removeQuizJson(quiz.Id); } } } \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Program.cs b/WF-WebAdmin/WF-WebAdmin/Program.cs index 2a03f66..8ce6fde 100644 --- a/WF-WebAdmin/WF-WebAdmin/Program.cs +++ b/WF-WebAdmin/WF-WebAdmin/Program.cs @@ -14,6 +14,7 @@ builder.Services.AddRazorPages(); builder.Services.AddServerSideBlazor(); builder.Services.AddSingleton(); builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddHttpClient(); builder.Services.AddScoped(); diff --git a/WF-WebAdmin/WF-WebAdmin/Service/IQuizService.cs b/WF-WebAdmin/WF-WebAdmin/Service/IQuizService.cs new file mode 100644 index 0000000..bc7bb44 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Service/IQuizService.cs @@ -0,0 +1,24 @@ +using WF_WebAdmin.Model; + +namespace WF_WebAdmin.Service +{ + public interface IQuizService + { + public Task addQuiz(Quiz quiz); + + public Task updateQuiz(Quiz quiz); + + public Task removeQuiz(int id); + + public Task validateQuiz(int id); + + public Task> getQuizzes(); + + public Task> getQuizzesToValidate(); + + public Task getQuiz(int id); + + public Task getNbQuiz(); + } +} + \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Service/IQuizServiceJson.cs b/WF-WebAdmin/WF-WebAdmin/Service/IQuizServiceJson.cs new file mode 100644 index 0000000..9d51396 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Service/IQuizServiceJson.cs @@ -0,0 +1,17 @@ +using WF_WebAdmin.Model; + +namespace WF_WebAdmin.Service +{ + public interface IQuizServiceJson + { + public Task> getQuizzesJson(); + + public Task> getQuizzesToValidateJson(); + + public Task removeQuizJson(int id); + + public Task updateQuizJson(Quiz quiz); + + public Task saveQuizJson(List quiz); + } +} \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Service/QuizService.cs b/WF-WebAdmin/WF-WebAdmin/Service/QuizService.cs deleted file mode 100644 index 2a6c75f..0000000 --- a/WF-WebAdmin/WF-WebAdmin/Service/QuizService.cs +++ /dev/null @@ -1,25 +0,0 @@ -using WF_WebAdmin.Model; - -namespace WF_WebAdmin.Service; - -public class QuizService -{ - public List GetQuizToConfirm() - { - var res = new List(); - - return res; - } - - public bool AddQuiz(Quiz quiz) - { - var res = false; - return res; - } - - public bool RemoveQuiz(Quiz quiz) - { - var res = false; - return res; - } -} \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Service/QuizServiceStub.cs b/WF-WebAdmin/WF-WebAdmin/Service/QuizServiceStub.cs new file mode 100644 index 0000000..b34a439 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Service/QuizServiceStub.cs @@ -0,0 +1,63 @@ +using System.Text.Json; +using WF_WebAdmin.Model; + +namespace WF_WebAdmin.Service; + +public class QuizServiceStub: IQuizServiceJson +{ + private readonly string _jsonFilePath = + Path.Combine(Environment.CurrentDirectory, "wwwroot", "fake_data_quiz.json"); + + public async Task> getQuizzesJson() + { + if (!File.Exists(_jsonFilePath)) + { + Console.Out.WriteLine($"{_jsonFilePath} not found"); + return new List(); + } + + var json = await File.ReadAllTextAsync(_jsonFilePath); + return JsonSerializer.Deserialize>(json) ?? new List(); + } + + public async Task> getQuizzesToValidateJson() + { + var quizzes = await getQuizzesJson(); + return quizzes.Where(quiz => quiz.IsValid == false).ToList();; + } + + public async Task removeQuizJson(int id) + { + var data = await getQuizzesJson(); + var quiz = data.FirstOrDefault(q => q.Id == id); + if (quiz != null) + { + data.Remove(quiz); + await saveQuizJson(data); + } + } + + public async Task updateQuizJson(Quiz quiz) + { + var data = await getQuizzesJson(); + var existingQuiz = data.FirstOrDefault(q => q.Id == quiz.Id); + if (existingQuiz != null) + { + existingQuiz.Question = quiz.Question; + existingQuiz.AnswerA = quiz.AnswerA; + existingQuiz.AnswerB = quiz.AnswerB; + existingQuiz.AnswerC = quiz.AnswerC; + existingQuiz.AnswerD = quiz.AnswerD; + existingQuiz.CAnswer = quiz.CAnswer; + existingQuiz.IsValid = quiz.IsValid; + existingQuiz.UserProposition = quiz.UserProposition; + await saveQuizJson(data); + } + } + + public async Task saveQuizJson(List quizzes) + { + var json = JsonSerializer.Serialize(quizzes, new JsonSerializerOptions { WriteIndented = true }); + await File.WriteAllTextAsync(_jsonFilePath, json); + } +} diff --git a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataQuiz.json b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataQuiz.json deleted file mode 100644 index 24eb012..0000000 --- a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataQuiz.json +++ /dev/null @@ -1,282 +0,0 @@ -[ - { - "id": 1, - "question": "Voluptate nulla laborum pariatur excepteur consequat officia ea esse ut nisi amet non.", - "answerA": "sit ullamco", - "answerB": "deserunt reprehenderit", - "answerC": "cupidatat deserunt", - "answerD": "ullamco aliqua", - "cAnswer": "B", - "userProposition": "Lori Myers" - }, - { - "id": 2, - "question": "Ea elit esse minim aute aliquip cillum amet cupidatat fugiat exercitation.", - "answerA": "ullamco excepteur", - "answerB": "aliquip occaecat", - "answerC": "incididunt duis", - "answerD": "sunt dolor", - "cAnswer": "A", - "userProposition": "Louella Robinson" - }, - { - "id": 3, - "question": "Aute commodo est proident sunt nulla est cillum eiusmod est voluptate dolore sit aliqua incididunt.", - "answerA": "reprehenderit mollit", - "answerB": "laboris consectetur", - "answerC": "cillum deserunt", - "answerD": "deserunt fugiat", - "cAnswer": "B", - "userProposition": "Richmond Joyner" - }, - { - "id": 4, - "question": "Fugiat duis excepteur non amet tempor deserunt ut occaecat cupidatat eiusmod et amet enim.", - "answerA": "amet aute", - "answerB": "excepteur ad", - "answerC": "laboris veniam", - "answerD": "veniam in", - "cAnswer": "B", - "userProposition": "Brady Patrick" - }, - { - "id": 5, - "question": "Occaecat minim velit dolor est ad ut irure eu labore velit in dolore exercitation.", - "answerA": "eu aliqua", - "answerB": "labore ipsum", - "answerC": "labore reprehenderit", - "answerD": "anim excepteur", - "cAnswer": "C", - "userProposition": "Mavis Boone" - }, - { - "id": 6, - "question": "Non laboris adipisicing anim fugiat labore excepteur tempor elit in.", - "answerA": "in excepteur", - "answerB": "nostrud dolor", - "answerC": "nisi aliqua", - "answerD": "sint nisi", - "cAnswer": "C", - "userProposition": "Douglas Dejesus" - }, - { - "id": 7, - "question": "Lorem proident exercitation elit fugiat do amet aute labore consectetur pariatur consequat.", - "answerA": "eiusmod nulla", - "answerB": "eu id", - "answerC": "proident tempor", - "answerD": "amet proident", - "cAnswer": "A", - "userProposition": "Mia Peterson" - }, - { - "id": 8, - "question": "Incididunt magna commodo laborum do incididunt commodo proident non cillum magna elit irure voluptate.", - "answerA": "laborum fugiat", - "answerB": "laboris est", - "answerC": "in ea", - "answerD": "duis ullamco", - "cAnswer": "A", - "userProposition": "Juliet Fox" - }, - { - "id": 9, - "question": "Qui labore fugiat sint Lorem ut minim in ex dolor.", - "answerA": "et deserunt", - "answerB": "labore sit", - "answerC": "in eiusmod", - "answerD": "amet incididunt", - "cAnswer": "C", - "userProposition": "Earnestine Poole" - }, - { - "id": 10, - "question": "Voluptate pariatur ipsum magna sint Lorem adipisicing.", - "answerA": "sint velit", - "answerB": "non culpa", - "answerC": "nisi ut", - "answerD": "excepteur labore", - "cAnswer": "B", - "userProposition": "Alexis Cross" - }, - { - "id": 11, - "question": "In labore sunt est cupidatat cillum.", - "answerA": "ut ad", - "answerB": "non deserunt", - "answerC": "do officia", - "answerD": "ut nostrud", - "cAnswer": "C", - "userProposition": "Brooks Martinez" - }, - { - "id": 12, - "question": "Irure occaecat sit laborum nulla ea dolore et aliqua sunt Lorem enim esse.", - "answerA": "excepteur occaecat", - "answerB": "pariatur in", - "answerC": "reprehenderit excepteur", - "answerD": "laborum adipisicing", - "cAnswer": "D", - "userProposition": "Shields Roth" - }, - { - "id": 13, - "question": "Laboris sint in sit exercitation nisi id cillum ex ea culpa fugiat in cupidatat.", - "answerA": "labore mollit", - "answerB": "in veniam", - "answerC": "labore eiusmod", - "answerD": "consequat veniam", - "cAnswer": "B", - "userProposition": "Carmella Chase" - }, - { - "id": 14, - "question": "Proident dolor Lorem anim proident laborum sint minim sit laborum aliquip.", - "answerA": "velit exercitation", - "answerB": "voluptate esse", - "answerC": "occaecat cupidatat", - "answerD": "enim adipisicing", - "cAnswer": "D", - "userProposition": "Johns Solomon" - }, - { - "id": 15, - "question": "Do magna dolore enim laborum consequat reprehenderit nisi consequat nostrud.", - "answerA": "proident do", - "answerB": "labore minim", - "answerC": "in elit", - "answerD": "in irure", - "cAnswer": "A", - "userProposition": "Alana Moore" - }, - { - "id": 16, - "question": "Culpa anim id elit dolore veniam.", - "answerA": "ipsum nisi", - "answerB": "officia voluptate", - "answerC": "in excepteur", - "answerD": "ullamco non", - "cAnswer": "B", - "userProposition": "Russo Rios" - }, - { - "id": 17, - "question": "Ea est consectetur exercitation aute ut mollit pariatur irure aute adipisicing dolore.", - "answerA": "fugiat elit", - "answerB": "pariatur nulla", - "answerC": "exercitation ipsum", - "answerD": "exercitation laboris", - "cAnswer": "A", - "userProposition": "Bobbi Lara" - }, - { - "id": 18, - "question": "Laborum consectetur incididunt ad fugiat fugiat proident culpa mollit laborum.", - "answerA": "elit duis", - "answerB": "amet aute", - "answerC": "culpa nostrud", - "answerD": "do pariatur", - "cAnswer": "D", - "userProposition": "Lewis Mullins" - }, - { - "id": 19, - "question": "Culpa anim aliquip mollit non labore.", - "answerA": "labore incididunt", - "answerB": "laborum non", - "answerC": "sunt laborum", - "answerD": "est sunt", - "cAnswer": "B", - "userProposition": "Mccray Mccoy" - }, - { - "id": 20, - "question": "Ex exercitation deserunt aute cillum dolor.", - "answerA": "proident magna", - "answerB": "pariatur exercitation", - "answerC": "ipsum veniam", - "answerD": "culpa quis", - "cAnswer": "C", - "userProposition": "Moss Jefferson" - }, - { - "id": 21, - "question": "Do mollit aute dolore anim id non aliqua.", - "answerA": "ipsum aute", - "answerB": "irure ex", - "answerC": "ex duis", - "answerD": "ipsum cupidatat", - "cAnswer": "B", - "userProposition": "Roth Valdez" - }, - { - "id": 22, - "question": "Commodo sunt reprehenderit tempor sit ut ea Lorem esse minim elit et sunt sint qui.", - "answerA": "et do", - "answerB": "officia culpa", - "answerC": "et commodo", - "answerD": "irure tempor", - "cAnswer": "D", - "userProposition": "Adrienne Carpenter" - }, - { - "id": 23, - "question": "Excepteur cupidatat ut sit commodo magna elit.", - "answerA": "pariatur tempor", - "answerB": "proident non", - "answerC": "velit elit", - "answerD": "pariatur fugiat", - "cAnswer": "D", - "userProposition": "Mcknight Cain" - }, - { - "id": 24, - "question": "Laborum eu nisi consequat voluptate in laboris cillum in aute sint excepteur aliqua Lorem in.", - "answerA": "pariatur in", - "answerB": "voluptate qui", - "answerC": "et cillum", - "answerD": "adipisicing id", - "cAnswer": "D", - "userProposition": "Gay Barlow" - }, - { - "id": 25, - "question": "Laborum ullamco occaecat excepteur deserunt nostrud dolor.", - "answerA": "magna labore", - "answerB": "ullamco veniam", - "answerC": "reprehenderit irure", - "answerD": "magna dolore", - "cAnswer": "B", - "userProposition": "Hannah Battle" - }, - { - "id": 26, - "question": "Commodo in amet laboris Lorem et qui anim ea ullamco dolor dolor commodo.", - "answerA": "amet nulla", - "answerB": "laborum mollit", - "answerC": "amet in", - "answerD": "irure amet", - "cAnswer": "D", - "userProposition": "Dawson Mcpherson" - }, - { - "id": 27, - "question": "Veniam non consectetur sit cillum.", - "answerA": "aliqua cupidatat", - "answerB": "nostrud culpa", - "answerC": "anim ullamco", - "answerD": "adipisicing et", - "cAnswer": "A", - "userProposition": "Reeves Love" - }, - { - "id": 28, - "question": "Ullamco laboris voluptate nostrud commodo Lorem enim ad ipsum.", - "answerA": "id aute", - "answerB": "aliquip incididunt", - "answerC": "duis elit", - "answerD": "mollit ad", - "cAnswer": "B", - "userProposition": "Michael Holmes" - } -] \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_quiz.json b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_quiz.json new file mode 100644 index 0000000..0a91deb --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_quiz.json @@ -0,0 +1,68 @@ +[ + { + "Id": 7, + "Question": "Lorem proident exercitation elit fugiat do amet aute labore consectetur pariatur consequat.", + "AnswerA": "eiusmod nulla", + "AnswerB": "eu Id", + "AnswerC": "proident tempor", + "AnswerD": "amet proident", + "CAnswer": "A", + "IsValid": false, + "UserProposition": "Mia Peterson" + }, + { + "Id": 8, + "Question": "Incididunt magna commodo laborum do incididunt commodo proident non cillum magna elit irure voluptate.", + "AnswerA": "laborum fugiat", + "AnswerB": "laboris est", + "AnswerC": "in ea", + "AnswerD": "duis ullamco", + "CAnswer": "A", + "IsValid": false, + "UserProposition": "Juliet Fox" + }, + { + "Id": 9, + "Question": "Qui labore fugiat sint Lorem ut minim in ex dolor.", + "AnswerA": "et deserunt", + "AnswerB": "labore sit", + "AnswerC": "in eiusmod", + "AnswerD": "amet incididunt", + "CAnswer": "C", + "IsValid": false, + "UserProposition": "Earnestine Poole" + }, + { + "Id": 10, + "Question": "Voluptate pariatur ipsum magna sint Lorem adipisicing.", + "AnswerA": "sint velit", + "AnswerB": "non culpa", + "AnswerC": "nisi ut", + "AnswerD": "excepteur labore", + "CAnswer": "B", + "IsValid": false, + "UserProposition": "Alexis Cross" + }, + { + "Id": 11, + "Question": "In labore sunt est cupidatat cillum.", + "AnswerA": "ut ad", + "AnswerB": "non deserunt", + "AnswerC": "do officia", + "AnswerD": "ut nostrud", + "CAnswer": "C", + "IsValid": false, + "UserProposition": "Brooks Martinez" + }, + { + "Id": 12, + "Question": "Irure occaecat sit laborum nulla ea dolore et aliqua sunt Lorem enim esse.", + "AnswerA": "excepteur occaecat", + "AnswerB": "pariatur in", + "AnswerC": "reprehenderit excepteur", + "AnswerD": "laborum adipisicing", + "CAnswer": "D", + "IsValid": false, + "UserProposition": "Shields Roth" + } +] \ No newline at end of file From 85aeeb061c7aade5f11b850e8bd51ba5b9478ce6 Mon Sep 17 00:00:00 2001 From: tomivt Date: Wed, 22 Jan 2025 09:22:35 +0100 Subject: [PATCH 09/79] Complete setAdmin method --- .../WF-WebAdmin/Pages/DeleteUser.razor | 2 +- .../WF-WebAdmin/Pages/DeleteUser.razor.cs | 56 +-- .../WF-WebAdmin/Service/UserServiceStub.cs | 24 +- ...ke-dataUsers.json => fake_data_users.json} | 339 +++++++++--------- 4 files changed, 207 insertions(+), 214 deletions(-) rename WF-WebAdmin/WF-WebAdmin/wwwroot/{fake-dataUsers.json => fake_data_users.json} (91%) diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor index 398b4c7..a15fe87 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor @@ -97,7 +97,7 @@ else

Êtes-vous sûr de vouloir changer le rôle de cet utilisateur ?

- +
diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs index cfaecb3..44e8616 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs @@ -11,7 +11,7 @@ namespace WF_WebAdmin.Pages private bool showDeletePopup = false; private bool showModifyPopup = false; private User userToDelete = null; - private User selectedUser; + private User selectedUser; private bool showPopupDelete = false; private bool showPopupAdmin = false; private User userToAdmin = null; @@ -32,25 +32,25 @@ namespace WF_WebAdmin.Pages protected override async Task OnInitializedAsync() { - userService = new UserServiceStub($"fake-dataUsers.json"); - users = await userService.GetUsersJson(); + userService = new UserServiceStub(); + users = await userService.getAllUser(); } - private async Task OnReadData(DataGridReadDataEventArgs e) - { - if (e.CancellationToken.IsCancellationRequested) - { - return; - } - - - var response = await userService.getSomeUser(e.PageSize, e.Page); - - if (!e.CancellationToken.IsCancellationRequested) - { - totalItem = await userService.getNbUser(); - users = response.ToArray(); - } + private async Task OnReadData(DataGridReadDataEventArgs e) + { + if (e.CancellationToken.IsCancellationRequested) + { + return; + } + + + var response = await userService.getSomeUser(e.PageSize, e.Page); + + if (!e.CancellationToken.IsCancellationRequested) + { + totalItem = await userService.getNbUser(); + users = new List(response.ToArray()); + } } // ------- Popup remove user ------- @@ -71,16 +71,16 @@ namespace WF_WebAdmin.Pages { if (userToDelete != null) { - userService = new UserServiceStub($"fake-dataUsers.json"); - await userService.DeleteUserJson(userToDelete.Id); + userService = new UserServiceStub(); + await userService.removeUser(userToDelete); ClosePopup(); } } private async Task ModifyUser() { - userService = new UserServiceStub($"fake-dataUsers.json"); - await userService.UpdateUserJson(selectedUser); + userService = new UserServiceStub(); + await userService.updateUser(selectedUser); ClosePopup(); } @@ -102,17 +102,19 @@ namespace WF_WebAdmin.Pages - private async Task Admin() + private async Task setAdmin() { if (!userToAdmin.IsAdmin) - { + { userToAdmin.IsAdmin = true; + await userService.updateUser(userToAdmin); ClosePopup(); } - else - { + else + { userToAdmin.IsAdmin = false; - ClosePopup(); + await userService.updateUser(userToAdmin); + ClosePopup(); } } diff --git a/WF-WebAdmin/WF-WebAdmin/Service/UserServiceStub.cs b/WF-WebAdmin/WF-WebAdmin/Service/UserServiceStub.cs index 9dfd7fb..67cb03f 100644 --- a/WF-WebAdmin/WF-WebAdmin/Service/UserServiceStub.cs +++ b/WF-WebAdmin/WF-WebAdmin/Service/UserServiceStub.cs @@ -1,17 +1,17 @@ -using System.Text.Json; -using WF_WebAdmin.Model; - -namespace WF_WebAdmin.Service; - -public class UserServiceStub : IUserService -{ - private readonly string _jsonFilePath = Path.Combine(Environment.CurrentDirectory, "wwwroot", "fake-dataUsers.json"); +using System.Text.Json; +using WF_WebAdmin.Model; +namespace WF_WebAdmin.Service; - public async Task saveUsersJson(List users) - { - var json = JsonSerializer.Serialize(users, new JsonSerializerOptions { WriteIndented = true }); - await File.WriteAllTextAsync(_jsonFilePath, json); +public class UserServiceStub : IUserService +{ + private readonly string _jsonFilePath = Path.Combine(Environment.CurrentDirectory, "wwwroot", "fake_data_users.json"); + + + public async Task saveUsersJson(List users) + { + var json = JsonSerializer.Serialize(users, new JsonSerializerOptions { WriteIndented = true }); + await File.WriteAllTextAsync(_jsonFilePath, json); } public async Task removeUser(User user) diff --git a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataUsers.json b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_users.json similarity index 91% rename from WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataUsers.json rename to WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_users.json index a6c7f98..5730ccb 100644 --- a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataUsers.json +++ b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_users.json @@ -1,175 +1,166 @@ -[ - { - "Id": 1, - "Image": "https://tse4.mm.bing.net/th/id/OIP.fc5TQflh0cbxB1GUeOdk6gHaK8?w=123\u0026h=180\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", - "Name": "admin", - "Email": "admin@gmail.com", - "DateCreation": "2024-12-12T00:00:00", - "IsAdmin": true, - "Comments": [ - { - "Text": "Commentaire 1", - "DateCreation": "2024-12-12T00:00:00" - }, - { - "Text": "Commentaire 2", - "DateCreation": "2024-11-12T00:00:00" - } - ] - }, - { - "Id": 2, - "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", - "Name": "exploit2", - "Email": "exploit@gmail.com", - "DateCreation": "2024-11-12T00:00:00", - "IsAdmin": true, - "Comments": null - }, - { - "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", - "Name": "testeur", - "Email": "testeur@gmail.com", - "DateCreation": "2024-08-02T00:00:00", - "IsAdmin": false, - "Comments": [ - { - "Text": "Premier test effectu\u00E9, tout semble OK.", - "DateCreation": "2024-08-02T00:00:00" - } - ] - }, - { - "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", - "Email": "dev@gmail.com", - "DateCreation": "2024-10-10T00:00:00", - "IsAdmin": false, - "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", - "Email": "jean.doe@gmail.com", - "DateCreation": "2024-06-25T00:00:00", - "IsAdmin": false, - "Comments": [ - { - "Text": "Utilisateur tr\u00E8s actif, peut \u00EAtre un peu trop intrusif.", - "DateCreation": "2024-06-25T00:00:00" - } - ] - }, - { - "Id": 6, - "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", - "Name": "jane_smith", - "Email": "jane.smith@gmail.com", - "DateCreation": "2024-07-15T00:00:00", - "IsAdmin": false, - "Comments": null - }, - { - "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": "admin_joe", - "Email": "admin.joe@gmail.com", - "DateCreation": "2024-05-30T00:00:00", - "IsAdmin": true, - "Comments": null - }, - { - "Id": 8, - "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_anna", - "Email": "dev.anna@gmail.com", - "DateCreation": "2024-09-05T00:00:00", - "IsAdmin": false, - "Comments": null - }, - { - "Id": 9, - "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", - "Name": "support_mark", - "Email": "support.mark@gmail.com", - "DateCreation": "2024-11-20T00:00:00", - "IsAdmin": false, - "Comments": [ - { - "Text": "Support rapide et efficace, mais manquant un peu de d\u00E9tails.", - "DateCreation": "2024-11-20T00:00:00" - } - ] - }, - { - "Id": 10, - "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_susan", - "Email": "dev.susan@gmail.com", - "DateCreation": "2024-08-12T00:00:00", - "IsAdmin": false, - "Comments": null - }, - { - "Id": 11, - "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", - "Name": "designer_steve", - "Email": "designer.steve@gmail.com", - "DateCreation": "2024-07-01T00:00:00", - "IsAdmin": false, - "Comments": [ - { - "Text": "Le design doit \u00EAtre retravaill\u00E9 pour plus de clart\u00E9.", - "DateCreation": "2024-07-01T00:00:00" - } - ] - }, - { - "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": true, - "Comments": null - }, - { - "Id": 13, - "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", - "Name": "manager_anna", - "Email": "manager.anna@gmail.com", - "DateCreation": "2024-05-01T00: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 - }, - { - "Id": 15, - "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_user_01", - "Email": "test.user01@gmail.com", - "DateCreation": "2024-06-10T00:00:00", - "IsAdmin": false, - "Comments": null - }, - { - "Id": 16, - "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_kate", - "Email": "admin.kate@gmail.com", - "DateCreation": "2024-04-16T00:00:00", - "IsAdmin": true, - "Comments": null - } +[ + { + "Id": 1, + "Image": "https://tse4.mm.bing.net/th/id/OIP.fc5TQflh0cbxB1GUeOdk6gHaK8?w=123\u0026h=180\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", + "Name": "admin", + "Email": "adminop@gmail.com", + "DateCreation": "2024-12-12T00:00:00", + "IsAdmin": true, + "Comments": [ + { + "Text": "Commentaire 1", + "DateCreation": "2024-12-12T00:00:00" + }, + { + "Text": "Commentaire 2", + "DateCreation": "2024-11-12T00:00:00" + } + ] + }, + { + "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", + "Name": "testeur", + "Email": "testeur@gmail.com", + "DateCreation": "2024-08-02T00:00:00", + "IsAdmin": false, + "Comments": [ + { + "Text": "Premier test effectu\u00E9, tout semble OK.", + "DateCreation": "2024-08-02T00:00:00" + } + ] + }, + { + "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", + "Email": "dev@gmail.com", + "DateCreation": "2024-10-10T00:00:00", + "IsAdmin": false, + "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", + "Email": "jean.doe@gmail.com", + "DateCreation": "2024-06-25T00:00:00", + "IsAdmin": false, + "Comments": [ + { + "Text": "Utilisateur tr\u00E8s actif, peut \u00EAtre un peu trop intrusif.", + "DateCreation": "2024-06-25T00:00:00" + } + ] + }, + { + "Id": 6, + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", + "Name": "jane_smith", + "Email": "jane.smith@gmail.com", + "DateCreation": "2024-07-15T00:00:00", + "IsAdmin": false, + "Comments": null + }, + { + "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": "admin_joe", + "Email": "admin.joe@gmail.com", + "DateCreation": "2024-05-30T00:00:00", + "IsAdmin": true, + "Comments": null + }, + { + "Id": 8, + "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_anna", + "Email": "dev.anna@gmail.com", + "DateCreation": "2024-09-05T00:00:00", + "IsAdmin": false, + "Comments": null + }, + { + "Id": 9, + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", + "Name": "support_mark", + "Email": "support.mark@gmail.com", + "DateCreation": "2024-11-20T00:00:00", + "IsAdmin": false, + "Comments": [ + { + "Text": "Support rapide et efficace, mais manquant un peu de d\u00E9tails.", + "DateCreation": "2024-11-20T00:00:00" + } + ] + }, + { + "Id": 10, + "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_susan", + "Email": "dev.susan@gmail.com", + "DateCreation": "2024-08-12T00:00:00", + "IsAdmin": false, + "Comments": null + }, + { + "Id": 11, + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", + "Name": "designer_steve", + "Email": "designer.steve@gmail.com", + "DateCreation": "2024-07-01T00:00:00", + "IsAdmin": false, + "Comments": [ + { + "Text": "Le design doit \u00EAtre retravaill\u00E9 pour plus de clart\u00E9.", + "DateCreation": "2024-07-01T00:00:00" + } + ] + }, + { + "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": true, + "Comments": null + }, + { + "Id": 13, + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", + "Name": "manager_anna", + "Email": "manager.anna@gmail.com", + "DateCreation": "2024-05-01T00: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 + }, + { + "Id": 15, + "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_user_01", + "Email": "test.user01@gmail.com", + "DateCreation": "2024-06-10T00:00:00", + "IsAdmin": false, + "Comments": null + }, + { + "Id": 16, + "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_kate", + "Email": "admin.kate@gmail.com", + "DateCreation": "2024-04-16T00:00:00", + "IsAdmin": true, + "Comments": null + } ] \ No newline at end of file From f79e01ea050eaad801a22d143a8e2549677402ff Mon Sep 17 00:00:00 2001 From: tomivt Date: Fri, 24 Jan 2025 15:51:16 +0100 Subject: [PATCH 10/79] Start editQuote method --- .../WF-WebAdmin/Pages/DeleteUser.razor | 5 +- .../WF-WebAdmin/Pages/ModifQuote.razor | 47 +++++++++++++----- .../WF-WebAdmin/Pages/ModifQuote.razor.cs | 25 +++++++++- WF-WebAdmin/WF-WebAdmin/wwwroot/css/site.css | 12 ++++- WF-WebAdmin/WF-WebAdmin/wwwroot/edit.png | Bin 0 -> 10157 bytes .../WF-WebAdmin/wwwroot/fake_data_users.json | 2 +- 6 files changed, 73 insertions(+), 18 deletions(-) create mode 100644 WF-WebAdmin/WF-WebAdmin/wwwroot/edit.png diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor index a15fe87..bf4a06b 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor @@ -54,13 +54,14 @@ else } - } + + @* - + *@ @if (showPopupDelete) diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor index ee6cebd..c86cdea 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor @@ -7,7 +7,7 @@

Ajouter une recherche

- - - - - - - - - - Editer - - - \ No newline at end of file + + + + + + + + + + @* Editer*@ + + + + + +@if (showEditQuote && selectedQuote != null) +{ +
+
+

Modifier les informations de l'utilisateur :

+ + + + + + + + +
+
+} \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs index 155481b..4c9bd10 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs @@ -12,6 +12,10 @@ namespace WF_WebAdmin.Pages private int MaxValue = 5; private int totalItem; + + private bool showEditQuote = false; + + private Quote? selectedQuote; [Inject] public IQuoteService QuoteService { get; set; } @@ -23,7 +27,6 @@ namespace WF_WebAdmin.Pages return; } - var response = await QuoteService.getSomeQuote(e.PageSize, e.Page); if (!e.CancellationToken.IsCancellationRequested) @@ -32,5 +35,25 @@ namespace WF_WebAdmin.Pages quotes = response.ToArray(); } } + + private void OnEditButtonClicked(Quote quote) + { + if (selectedQuote == null) return; + selectedQuote = quote; + showEditQuote = true; + } + + private void ClosePopup() + { + showEditQuote = false; + selectedQuote = null; + } + + private async Task EditQuote() + { + await QuoteService.updateQuote(selectedQuote); + selectedQuote = null; + ClosePopup(); + } } } diff --git a/WF-WebAdmin/WF-WebAdmin/wwwroot/css/site.css b/WF-WebAdmin/WF-WebAdmin/wwwroot/css/site.css index 0f2ae37..7995488 100644 --- a/WF-WebAdmin/WF-WebAdmin/wwwroot/css/site.css +++ b/WF-WebAdmin/WF-WebAdmin/wwwroot/css/site.css @@ -83,8 +83,18 @@ button { background-color: #C3C4C5; } -.imgProfil, .imgQuote { +.imgProfil { border-radius: 25px; + width: 150px; /* Taille standard */ + height: 150px; /* Taille standard */ + object-fit: cover; +} + +.imgQuote { + border-radius: 20px; + width: 300px; /* Taille standard */ + height: 300px; /* Taille standard */ + object-fit: cover; } .pseudo, .mail, .idUser, .dateCrea, .idQuote, .contentQuote, .CaracterQuote, .SourceQuote, .langueQuote, .UserPropositionQuote { diff --git a/WF-WebAdmin/WF-WebAdmin/wwwroot/edit.png b/WF-WebAdmin/WF-WebAdmin/wwwroot/edit.png new file mode 100644 index 0000000000000000000000000000000000000000..cbf3dce83248c607df9a1d320cbcef1094dc4454 GIT binary patch literal 10157 zcmc&)`y{=8|GIw~g7pFWdX`H+=o#?D2e_$Mbq#ubp!ibJfyRV86tE000Ec{<#DL08Vho z3GC$o|E+}#Z-M`~Juh6j005O3KKhM4;Af5?n5hv^)-UxN{2=T859|s6gvkQ{>M;Q9 z>Z29_;JyX`EV=@~nN$D}4aodtZ3wCYW|uD5hGZ`N3awJNza~2+&}qnH&H3yZN_OwD z%eMSgUW13ZZLu0B_6i?LdQytI*Yoxn|0kbgua5|M+ZD(eo0IrbE!*##rPa(xQthAYGvT8Fmd2nj|F3`NolOf)%i{u-meUE7 zO3OKfT+#OOH`H-RM^T+STE-%<6_Rp??9PGOsfVF|7KMbMJqtpvp)qf$NXhmTSfdtB zTq!$~APSo>#NoW^WAzKn+vow4?MKkV^KYnqVv|P!KsVsGn9EqW zW0m^f?HA>3E2&d;U6}oVsx2aolmd&8{UJ(GBJ_$$h?DjMSY68Mj%fk)UX}U}IYOV3 zpWgUaPSl>x0V@8`QtZ7Kofw`ngT5PFsL)Rr&@HhW#`O;()NnI4PSaCQg@CykZP0?_ z>0%|nWI~M+;#Blmtjxhyt%k;>1trn;AosC&pT0m!bVus_F7qjbLi9Shl+Sm7oD0FX zj34FMSiGy`mqvIahTdAW$;=`od_@SS+R%R@1Px0P;PXH;WF)1 zmx{FK&xob}i>@uA-mQXuO%aj++MTp;|9(Ye_G?Oi{7jDi-jnl(-Y<5JZ|fT*CuT!o z6?TyeYgv{+IPw+oykDOo8-WmekmRo=Ez=r|WuE9EB{7m79^)BpCD4lebPWwXVBGR_5D0in7k9$7SQy@x zLGn5z=DUT&kl=YcF^bI+5$yj*AV7(6GJLpGx)2|0P6G@~?` zKq%FWDBjFc>Nh9H96;dx;_cOcd0>ztsih<{a$|*4`Q{)n=uI9_KRUM=h0w<>**HO? zLLu4k{i(B^lbez0>m zvrM6NJ*9@Aq+ZvHp-YRr`H`Q6hoX60kL;=xM5L(a5Z+M8#k50hjpd(bi*NF52jIlY zwj4#3t>v|Wp3%i_rnx35Wr9+BnKIwueWcuU#Efr4zC3IFJ#rlMyT%U33{qOQJ=*e( zQWUWo&ZiUi@1*R)nfu=!WzE(G$sE4Oi~n>!<^!l&2CC8_wPi2iS3=Ld5BzKSE=kBo z0Z(D}c)?RIWeozVHYJ{nP$+{0s__~V-gn0#>d!a!AR4Iupz&sbGj8LpcdI5Q zH}#Z>qaO`1*^;wyB%8&8FV~5JfyCM=N71d;nH-o@4&mD@?5XkX9Wy+Aa}A_3(_9j`q@5#d&e`i0)U#iw6CHTl^!RRtMU&X!Yk zB-t~5>ToC=))$TpcT3dIMmlKiOP=<#eo$0g*(ozwA4G%PAkW#+M<=)^j&)1*)Q(y_ zqV+TcMV|YSNkyg*7H4f9<1%`DnU(Ucz8J2_gC21O7_LeMxae%Q@e7=&JN50$os#LP zxv<$5XOW6R0}iX$Qyt{PIti}Xl#WOj$hsB9(E3-g5u$>}T#4cB!%0Exm5ZAu?UX#8r~mvF{^=Fd>0#*2FBD&AZq zV4y3`u7x7au#su-yw->Mw`*W$Aoi2OYS#^4sD;OG9CJ{9N?PQ|N0%h(WH;2l4>jJY z{%gl~*x=!+b2R+zEAjUiO9)5=`lAHB#oV8h@_lQ#C2DqZU$$jCQXKsI1t_qtbi6}L1zr+X5LdyMC z43f7FeQuNrTXbKqEEd<`8^D}VxYN9ZgcW4E3WO;!9JM)y>isQ{navJ5T%S_#g{9Z% z$Yz*j1y9o<=E-!_ZKCg(xm1z)cZ){|XPs_UopCj3J0%5&sF4AB@DL>nRbc2wuT%_r zUUpS$-_|4KvaORQAOqhJ#Yq-uY0I>)bi??mWyw#`XNhnjjgO{Q!%3l)B-v*=Bb+ty6L z_3!)(ml4~me-*>?n)Gni)xwYVICdv7rz!L)OKe?_X-8?$@ACfa}~cTuizFjwDAxIwr@V%JVxy4fHGc4XF$SZ?85 zd0n@{!n|pzB>`M~y#ff*h2wY^X4ih2@1jh;#U$QVllKhei(a)5@niJd!tPOcsF__a?s5ObNBCT3< zx3-_5rfG&UE}$%+Ud(b0rhxH~tEjJ@+`xDJkl~$>js9*ccen8h&TyeEGJnD>0jf$~ zUxz(34xDXiO3o2(_IyHbH$2%*+@L{H-lg(pg?Jo}>6m$^AAtxjeg5f__m7jTYwy{IiWw6|?9SMqr>zE>h0HMD<@{Nb|xV0?xN zIJM)@DoQTkC)2e|Vo92JqB_7YSTVD8;1FZy-rHf9Z~D#oZqgdTW%Q!THUo~((Uw>4 z$4Nt!>L&<;BjN6e;#bQ{)3|#xRhYM{KZ(5L`#l`Ysg_Jw`_i&qF3;%e#eTK+`-9H` zxkEb*u6jDdz&K5iAtj-nGZlR5 zVv$K2$9j=Y0xAtg|C8!1^0JnAvYJR5q{eg6O>QYe?YA627oaYhf~m)Acm8yP4>+N9 zOfW(!AO-A-+K!c4<(=(G$is#ajJTh>-1vY>_6}8w5dLwR4-yZZ9x%!bh z?~BBY<8Qc|O-c_57B{|GN#Aw$Dt-H#BTIbR<6~>Pu#+)k45`eM$}Q5kxa8VsgLU@ zMXibhOLuN8L71Uljn&_-%)7>#BX^ZEW#y4m@TiH)2TI}F#I_HCGxZ!uSU zMANZC87G|K=SNzovycr^HyT8J3@lw~; z@3sdkaz~!y2&ES(e!WTLsxk#PE+>E1sCVQ=ey^-SOY-G+{718 z{G6sjG=gXzFW>S0od5CzHqw#AJVPu93Idxcqty|jFWfts;I_rFSyL>2KD>-RDu>^9 zTI+{s@JtjJEg=;#xO4G4|Lc=DWLB6z=X1daNhyyl&aN;u=xm>Hq9E@03W%Enr=VAyu3rkEOc8DeXcwf?qmp`+!9lecbZT zE{LBzI3(C+x{Fl~V>D@82Bm1G<{^svjY*Lq!S<(ipdes&AT09=71ZO0WfcKtVpsl8!d;K88hg?JH1mn8jdc3MwkH7~}*1bGA#>+JI^r zTX6`euw^S+abbm7j7LE!W>+es_J+gNj1^D7UT|{mu9c^)UVsB9%XJ@c<21pVa)Va_ zn6uc;hTw5+pf`y%`#~;;YaDBK#jY4k1t<;&DJ|KcAP5?fJ$qjmk)K9>1vGeBevF}b zP?K!ZixNOsA-J^{>2A@3OGANa9_Ip9|#uQo(+l%0O9|EU>`}cveui(g8~~6?5I@G zJp=3A9&GKs4UEOHoH~4-3p>p&3b zXakXKO35JreAMo?wA3@6*H$cxQ&??ahZQ$h!XU85j@!b7YmgnchLXT}88#158(3mB z&ckEcfG>OG24ZZ}c_79f5wv%oUEunEsH_d#XOHfH7+YElV(ihPHZTiHyKs0aP&@=A z-rw=ks?W(GBp;&8xHjwHc=NB2p@l{WA5yncT>5D>8y&907r3tW>)14^IE`1HwP*bC zm@MGqaTB*UBe!eRe>{sr{_1VG_xXJ0CnGiZ_oIiWn>>nGa>Ik$?XA<=3Dblw+ zT!9j_f|gC=3_{DH@}`yGK~Z~#RDYwnD1X~+x^>k_hU2v5dAJkp&DM^@sMCiZ!?CP5oCS>}R9 z&B!z__<|0{&Q8&4cXz_;1}gw5ALr@*_; zGIPXzUDVc2yZTRTcq+4bf3@aKoM3iCM9l*u(CUZi$Orp_IosZA7nLBl*)==KN1OQUO9|wttyH#dg<%yE9!J-j_Mcu8;q+#H{>wRv86M z;~&Q_Nl*_~*6Z|`3f&ePp34;G9nK$D=}KL!R5XQpC#J1fO|&wX0?#}9ZQG=?%HPo7 zlcF?O&zs@RkTQKld(qdd|QLNO@= zGHICm?+b#JAgdHoo95PqvQAA{|L@$-ZRo$Bu*}V5OAX27Sc%e`(ox`oUTb6JBha&L ztz%x`3G$=-R2~Ew=FTd4ov=B;Z2UqR;pPXin=GuKB8=q&_f@N7ms^laS5O42a(3bW zRg;z5-xjGdS1}@go?PU~&fEK8VXWh*#j%l5Zbil#d&OiWUFQtB*LOm#DjC%DJn-NA zcXBAvlC-v?$&;XJFWXxKl}hfF_r>B;x8H%L1~S<-{RnRC+=K3X=dY=)+GX%#Gq}7f z2N-sJCrnfe_Fbi?9cN{|*8a}EDXUQnH_;$}P6%?Yn-%ZUucO@%%nx%QSZj2bq5ppj za;VX_X>HPdrMnCUY=+&vXkCQ-kCPk|eNO2BE=Nv-wMN6uojB_EAHx!oBCpZVB@aI_|>S|H0ALg|8>dL3r4F7rw-X-+>wXIc(v^ zS;``2bvOB+f@Hwu<1Jwk{i8VKrJZ9Dx2jYa9TsW*ezQ4=qRYDnA7!BA8%Zq0rBA$UA;@PA)rU9W@L%XZd@+5-1LV6)`4 zWsT;Pq;tfsB&Q-|87ANP3$NvAF?))|tGuMYmZ4*RR65mYpH z99qo5v$AL{H&Ds`npUbM*pPU*=2Pi4mOBdzidvJ%id({}twFmyf}l#jx@nro>UEuj zg-d^So8BIO*rT1kd)Vc1TE9@{nSW{e=X==_Lo%@gxVvD2h!RScX5`tc^yz@w7pGe#-LtZf3}KkaQZTWB35r@rbFON|>`T1PN!8LxP+a(=sj3y`gJw!bLLzZF z`e7ax$ODZPVDd~5evWQ1gi+rK`KybToxa}kf#+$(30_UonZ8nN*9a`k_vv z3Hfe|krsQc7%s1BZjBb9MA9pw=$_R(59x%PlX_Es#iV7b)M}b=9bbMjdhN44DPcSB z24d~O($03-r_0Iz{dh+{5YR)PqA~wIVKPRN=uPfa?Uj+Fh@K;>bBE`jH1(&|IvS@1 zxtGD=1;^*x*0{8g6biV}^mz+*-)0dtA{QBch3v1?e7guL-P=}fnzlMK4|;zpX)H^* z!|J<*+eNU7=qS_XCfd3I^S7(6i=;XpRd-gmApvm$+qe-z6N8h7R?~YZE?S8A|MsS9rm|xw=q7)B?-s&S0~bO&B8# zyZOHv*!Q}NfT=?F9V3*PRI+c$dcgXQfb4%K?5( zD<-mny8=NBz9KEW(;~H>H;LqvbOy70O;ga0P-*Rl-KcZDMlw>14C`fj_yzD7{@v)MdJg(qbm;T?3svfcXFHz48js<$Yz$R#WX*^X z>Rm}GZ->~3b>^gEu*+nDi}L$x@0v=2B93jCrWn0pHCl-@D9~09oZ9x?zE?rTae$2l@UqVga)Jdr|Ea2oGFGa z)=jn!4X?sEiPS$~@BS{NdchkvC1hf9JD~=+lgW1~Fj z=4RIzJRa!>PS4KmZ2e()yt^MmI$+N9Qbe{D3~zGO5HiJ*2iK-PX!_Iy-sM+U&X#Ts z=ft3MJLg4t!^b)RuRk66e;ZS05Fq~%qJZ0F!8K3Y9-b-JvO}%T*jGUW16ahB(#Ng} zqE>+q68$;j%9Dh!(RZy8w-a*&t==aI{hhP4MquYjp7=L*Mu23eL0WP)A5$*6qkQlM zy=(Lv7jx-`nbcsBj5#?;5h}0s z$4j`hTzX7*6A3l3S+WEMq>$Nyb z@~5|YDYFaHK??!0^--mj1|zv-(`l_VthS$2t0PrszCy2KrH7`i*FK^vMOOE_=;7%vJGc0r%yt7$$>PWN_bV#Ki7`kW^p}*MwFU{|_vkH;- z+N`G+?ZwECE7%}eMPZ+Jt8oKh`)ycuUL)1 zBWAeJlGRvc$Q3kiLEVE~ci^v@=nlz>%&Ymn!2hiJUr49{#UM$ayTXvxhPYD&4cru- ze{)(tI_0_AHG(U^l=GiT!V{r#xX`Z*I{xIjWP+}79Ji_yB5w3GZ3KN~+?>>=#QvjhL4FK@W`Os| zsl#e#XD>Vw?}6jD`ys(*`3 zUvomgGq6~Q@5OwFMmszk{3XjdvB>6%;K7i~AyRu2x^pOJkN?P-Fxp$`OibB9oIxF< z^gL`4UphCg^jPR8&cG(Z6u?FLql1mN6I}KlrEE;w^S@44DGKqcg3_J{{dsQHwqh3e zI=*pq(=>nQrtD(}D`L`FUCyWjL{aY5Gt(mpkA&RD$z-wQRnDyXi|EZu+h(A#_nneL zv+9qp{}epZgBR{J*o#p9VI^VojAqKPrB!nDwpY7_7zA57KHYzGD~4YBFroopguPK1 zXGYHRf~M^~I(Lw!&un$48tPX7p(IobW+Ne1C~u(CF$j7tqK)tHpBg1gK@87hp^Fix zqt!#gJ`36%L&lScshcT0PlPf$^py}wxLHnz0`E7}YBBk!5s_Cyc|H+JIQ$#xSBR(} z3dCk$^iZ_=rR|u@do`Vjn02BFGo3@@7}9fUQpwVsjPrtq?mN06LyDc&guApND}k}1 z#=aHs(90OTn!oc#{_&W8za>~ayeRsdMsB%T;2#L)3b_~}3f_oYJ<~Crd_O-7*^Irh zst&#tYFcY!rpF0HWYdiNT1>vqM(z20TY!Phvx4>^ zcd Date: Mon, 27 Jan 2025 11:55:05 +0100 Subject: [PATCH 11/79] modification QuizServiceStub/DeleteUser/ModifQuote --- .../WF-WebAdmin/Pages/DeleteUser.razor | 27 +- .../WF-WebAdmin/Pages/DeleteUser.razor.cs | 2 +- .../WF-WebAdmin/Pages/ModifQuote.razor | 6 +- .../WF-WebAdmin/Pages/ValidQuiz.razor.cs | 8 +- WF-WebAdmin/WF-WebAdmin/Program.cs | 3 +- .../WF-WebAdmin/Service/IQuizService.cs | 2 + .../WF-WebAdmin/Service/IQuizServiceJson.cs | 17 - .../WF-WebAdmin/Service/IQuoteServiceJson.cs | 17 - .../WF-WebAdmin/Service/IUserServiceJson.cs | 17 - .../WF-WebAdmin/Service/QuizServiceStub.cs | 118 ++++--- .../WF-WebAdmin/wwwroot/fake_data_quiz.json | 112 +++---- .../WF-WebAdmin/wwwroot/fake_data_users.json | 312 +++++++++--------- 12 files changed, 298 insertions(+), 343 deletions(-) delete mode 100644 WF-WebAdmin/WF-WebAdmin/Service/IQuizServiceJson.cs delete mode 100644 WF-WebAdmin/WF-WebAdmin/Service/IQuoteServiceJson.cs delete mode 100644 WF-WebAdmin/WF-WebAdmin/Service/IUserServiceJson.cs diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor index bf4a06b..c3d8913 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor @@ -12,6 +12,21 @@ else { + + + + + + + + +

Utilisateurs présents:

@foreach (var user in users) { @@ -19,11 +34,11 @@ else @if (user.IsAdmin) { -

Nom d'utilisateur : @user.Name (Administrateur)

+

Nom d'utilisateur : @user.Name (Administrateur)[id:@user.Id]

} else { -

Nom d'utilisateur : @user.Name

+

Nom d'utilisateur : @user.Name [id: @user.Id]

}

Email de l'utilisateur : @user.Email

@@ -54,14 +69,6 @@ else } - - - @* - - - *@ @if (showPopupDelete) diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs index 44e8616..0ade62c 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs @@ -36,7 +36,7 @@ namespace WF_WebAdmin.Pages users = await userService.getAllUser(); } - private async Task OnReadData(DataGridReadDataEventArgs e) + private async Task OnReadData(DataGridReadDataEventArgs e) { if (e.CancellationToken.IsCancellationRequested) { diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor index c86cdea..ca75a01 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor @@ -23,10 +23,10 @@ - - @* Editer*@ + *@ + Editer diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuiz.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuiz.razor.cs index 76b5d55..2c2beec 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuiz.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuiz.razor.cs @@ -17,11 +17,11 @@ namespace WF_WebAdmin.Pages public NavigationManager NavigationManager { get; set; } [Inject] - public IQuizServiceJson QuizService { get; set; } + public IQuizService QuizService { get; set; } protected override async Task OnInitializedAsync() { - quizzes = await QuizService.getQuizzesToValidateJson(); + quizzes = await QuizService.getQuizzesToValidate(); } private void OnValidButton(Quiz quiz) @@ -37,7 +37,7 @@ namespace WF_WebAdmin.Pages newQuiz.IsValid = true; // Mis à jour de l'état du quiz - QuizService.updateQuizJson(quiz); + QuizService.updateQuiz(quiz); } private void OnRejectButton(Quiz quiz) @@ -49,7 +49,7 @@ namespace WF_WebAdmin.Pages { Console.WriteLine($"Quiz {quiz.Id} rejected!"); - QuizService.removeQuizJson(quiz.Id); + QuizService.removeQuiz(quiz.Id); } } } \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Program.cs b/WF-WebAdmin/WF-WebAdmin/Program.cs index 8ce6fde..b32ffda 100644 --- a/WF-WebAdmin/WF-WebAdmin/Program.cs +++ b/WF-WebAdmin/WF-WebAdmin/Program.cs @@ -14,7 +14,8 @@ builder.Services.AddRazorPages(); builder.Services.AddServerSideBlazor(); builder.Services.AddSingleton(); builder.Services.AddScoped(); -builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddHttpClient(); builder.Services.AddScoped(); diff --git a/WF-WebAdmin/WF-WebAdmin/Service/IQuizService.cs b/WF-WebAdmin/WF-WebAdmin/Service/IQuizService.cs index bc7bb44..9c0dd95 100644 --- a/WF-WebAdmin/WF-WebAdmin/Service/IQuizService.cs +++ b/WF-WebAdmin/WF-WebAdmin/Service/IQuizService.cs @@ -18,6 +18,8 @@ namespace WF_WebAdmin.Service public Task getQuiz(int id); + public Task> getSommeQuiz(int nb, int page); + public Task getNbQuiz(); } } diff --git a/WF-WebAdmin/WF-WebAdmin/Service/IQuizServiceJson.cs b/WF-WebAdmin/WF-WebAdmin/Service/IQuizServiceJson.cs deleted file mode 100644 index 9d51396..0000000 --- a/WF-WebAdmin/WF-WebAdmin/Service/IQuizServiceJson.cs +++ /dev/null @@ -1,17 +0,0 @@ -using WF_WebAdmin.Model; - -namespace WF_WebAdmin.Service -{ - public interface IQuizServiceJson - { - public Task> getQuizzesJson(); - - public Task> getQuizzesToValidateJson(); - - public Task removeQuizJson(int id); - - public Task updateQuizJson(Quiz quiz); - - public Task saveQuizJson(List quiz); - } -} \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Service/IQuoteServiceJson.cs b/WF-WebAdmin/WF-WebAdmin/Service/IQuoteServiceJson.cs deleted file mode 100644 index 0a93f33..0000000 --- a/WF-WebAdmin/WF-WebAdmin/Service/IQuoteServiceJson.cs +++ /dev/null @@ -1,17 +0,0 @@ -using WF_WebAdmin.Model; - -namespace WF_WebAdmin.Service -{ - public interface IQuoteServiceJson - { - public Task> GetQuoteJson(); - - public Task SaveQuoteJson(List users); - - public Task AddQuoteJson(User user); - - public Task DeleteQuoteJson(int id); - - public Task UpdateQuoteJson(User user); - } -} diff --git a/WF-WebAdmin/WF-WebAdmin/Service/IUserServiceJson.cs b/WF-WebAdmin/WF-WebAdmin/Service/IUserServiceJson.cs deleted file mode 100644 index f6c8383..0000000 --- a/WF-WebAdmin/WF-WebAdmin/Service/IUserServiceJson.cs +++ /dev/null @@ -1,17 +0,0 @@ -using WF_WebAdmin.Model; - -namespace WF_WebAdmin.Service -{ - public interface IUserServiceJson - { - public Task> GetUsersJson(); - - public Task SaveUsersJson(List users); - - public Task AddUserJson(User user); - - public Task DeleteUserJson(int id); - - public Task UpdateUserJson(User user); - } -} \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Service/QuizServiceStub.cs b/WF-WebAdmin/WF-WebAdmin/Service/QuizServiceStub.cs index b34a439..d8a60df 100644 --- a/WF-WebAdmin/WF-WebAdmin/Service/QuizServiceStub.cs +++ b/WF-WebAdmin/WF-WebAdmin/Service/QuizServiceStub.cs @@ -3,43 +3,24 @@ using WF_WebAdmin.Model; namespace WF_WebAdmin.Service; -public class QuizServiceStub: IQuizServiceJson +public class QuizServiceStub: IQuizService { - private readonly string _jsonFilePath = - Path.Combine(Environment.CurrentDirectory, "wwwroot", "fake_data_quiz.json"); + private readonly string _jsonFilePath = Path.Combine(Environment.CurrentDirectory, "wwwroot", "fake_data_quiz.json"); - public async Task> getQuizzesJson() - { - if (!File.Exists(_jsonFilePath)) - { - Console.Out.WriteLine($"{_jsonFilePath} not found"); - return new List(); - } - - var json = await File.ReadAllTextAsync(_jsonFilePath); - return JsonSerializer.Deserialize>(json) ?? new List(); - } - - public async Task> getQuizzesToValidateJson() - { - var quizzes = await getQuizzesJson(); - return quizzes.Where(quiz => quiz.IsValid == false).ToList();; - } - - public async Task removeQuizJson(int id) - { - var data = await getQuizzesJson(); - var quiz = data.FirstOrDefault(q => q.Id == id); - if (quiz != null) - { - data.Remove(quiz); - await saveQuizJson(data); - } - } - - public async Task updateQuizJson(Quiz quiz) + public async Task saveQuizJson(List quizzes) { - var data = await getQuizzesJson(); + var json = JsonSerializer.Serialize(quizzes, new JsonSerializerOptions { WriteIndented = true }); + await File.WriteAllTextAsync(_jsonFilePath, json); + } + + public Task addQuiz(Quiz quiz) + { + throw new NotImplementedException(); + } + + public async Task updateQuiz(Quiz quiz) + { + var data = await getQuizzes(); var existingQuiz = data.FirstOrDefault(q => q.Id == quiz.Id); if (existingQuiz != null) { @@ -52,12 +33,67 @@ public class QuizServiceStub: IQuizServiceJson existingQuiz.IsValid = quiz.IsValid; existingQuiz.UserProposition = quiz.UserProposition; await saveQuizJson(data); + } + } + + public async Task removeQuiz(int id) + { + var data = await getQuizzes(); + var quiz = data.FirstOrDefault(q => q.Id == id); + if (quiz != null) + { + data.Remove(quiz); + await saveQuizJson(data); + } + } + + public Task validateQuiz(int id) + { + throw new NotImplementedException(); + } + + public async Task> getQuizzes() + { + if (!File.Exists(_jsonFilePath)) + { + Console.Out.WriteLine($"{_jsonFilePath} not found"); + return new List(); } - } - - public async Task saveQuizJson(List quizzes) - { - var json = JsonSerializer.Serialize(quizzes, new JsonSerializerOptions { WriteIndented = true }); - await File.WriteAllTextAsync(_jsonFilePath, json); - } + + var json = await File.ReadAllTextAsync(_jsonFilePath); + return JsonSerializer.Deserialize>(json) ?? new List(); + } + + public async Task> getQuizzesToValidate() + { + var quizzes = await getQuizzes(); + return quizzes.Where(quiz => quiz.IsValid == false).ToList(); + } + + public async Task getQuiz(int id) + { + var data = await getQuizzes(); + var q = data.FirstOrDefault(p => p.Id == id); + if (q != null) + { + return q; + } + return null; + } + + public async Task> getSommeQuiz(int nb, int page) + { + var data = await getQuizzes(); + if ((page - 1) * nb + nb > data.Count()) + { + return data.GetRange(data.Count() - nb, nb); + } + return data.GetRange((page - 1) * nb, nb); + } + + public async Task getNbQuiz() + { + var data = await getQuizzes(); + return data.Count; + } } diff --git a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_quiz.json b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_quiz.json index 0a91deb..1f90e95 100644 --- a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_quiz.json +++ b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_quiz.json @@ -1,68 +1,46 @@ -[ - { - "Id": 7, - "Question": "Lorem proident exercitation elit fugiat do amet aute labore consectetur pariatur consequat.", - "AnswerA": "eiusmod nulla", - "AnswerB": "eu Id", - "AnswerC": "proident tempor", - "AnswerD": "amet proident", - "CAnswer": "A", - "IsValid": false, - "UserProposition": "Mia Peterson" - }, - { - "Id": 8, - "Question": "Incididunt magna commodo laborum do incididunt commodo proident non cillum magna elit irure voluptate.", - "AnswerA": "laborum fugiat", - "AnswerB": "laboris est", - "AnswerC": "in ea", - "AnswerD": "duis ullamco", - "CAnswer": "A", - "IsValid": false, - "UserProposition": "Juliet Fox" - }, - { - "Id": 9, - "Question": "Qui labore fugiat sint Lorem ut minim in ex dolor.", - "AnswerA": "et deserunt", - "AnswerB": "labore sit", - "AnswerC": "in eiusmod", - "AnswerD": "amet incididunt", - "CAnswer": "C", - "IsValid": false, - "UserProposition": "Earnestine Poole" - }, - { - "Id": 10, - "Question": "Voluptate pariatur ipsum magna sint Lorem adipisicing.", - "AnswerA": "sint velit", - "AnswerB": "non culpa", - "AnswerC": "nisi ut", - "AnswerD": "excepteur labore", - "CAnswer": "B", - "IsValid": false, - "UserProposition": "Alexis Cross" - }, - { - "Id": 11, - "Question": "In labore sunt est cupidatat cillum.", - "AnswerA": "ut ad", - "AnswerB": "non deserunt", - "AnswerC": "do officia", - "AnswerD": "ut nostrud", - "CAnswer": "C", - "IsValid": false, - "UserProposition": "Brooks Martinez" - }, - { - "Id": 12, - "Question": "Irure occaecat sit laborum nulla ea dolore et aliqua sunt Lorem enim esse.", - "AnswerA": "excepteur occaecat", - "AnswerB": "pariatur in", - "AnswerC": "reprehenderit excepteur", - "AnswerD": "laborum adipisicing", - "CAnswer": "D", - "IsValid": false, - "UserProposition": "Shields Roth" - } +[ + { + "Id": 9, + "Question": "Qui labore fugiat sint Lorem ut minim in ex dolor.", + "AnswerA": "et deserunt", + "AnswerB": "labore sit", + "AnswerC": "in eiusmod", + "AnswerD": "amet incididunt", + "CAnswer": "C", + "IsValid": false, + "UserProposition": "Earnestine Poole" + }, + { + "Id": 10, + "Question": "Voluptate pariatur ipsum magna sint Lorem adipisicing.", + "AnswerA": "sint velit", + "AnswerB": "non culpa", + "AnswerC": "nisi ut", + "AnswerD": "excepteur labore", + "CAnswer": "B", + "IsValid": false, + "UserProposition": "Alexis Cross" + }, + { + "Id": 11, + "Question": "In labore sunt est cupidatat cillum.", + "AnswerA": "ut ad", + "AnswerB": "non deserunt", + "AnswerC": "do officia", + "AnswerD": "ut nostrud", + "CAnswer": "C", + "IsValid": false, + "UserProposition": "Brooks Martinez" + }, + { + "Id": 12, + "Question": "Irure occaecat sit laborum nulla ea dolore et aliqua sunt Lorem enim esse.", + "AnswerA": "excepteur occaecat", + "AnswerB": "pariatur in", + "AnswerC": "reprehenderit excepteur", + "AnswerD": "laborum adipisicing", + "CAnswer": "D", + "IsValid": false, + "UserProposition": "Shields Roth" + } ] \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_users.json b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_users.json index 7b3f5b7..5b402a6 100644 --- a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_users.json +++ b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_users.json @@ -1,166 +1,148 @@ -[ - { - "Id": 1, - "Image": "https://assets.audiomack.com/merlijnmuziek/80c977f3a319cf2826af53c9faa7a46f787ba806ca3f783d23bbb7123942b697.jpeg?width=1000\u0026height=1000\u0026max=true", - "Name": "admin", - "Email": "adminop@gmail.com", - "DateCreation": "2024-12-12T00:00:00", - "IsAdmin": true, - "Comments": [ - { - "Text": "Commentaire 1", - "DateCreation": "2024-12-12T00:00:00" - }, - { - "Text": "Commentaire 2", - "DateCreation": "2024-11-12T00:00:00" - } - ] - }, - { - "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", - "Name": "testeur", - "Email": "testeur@gmail.com", - "DateCreation": "2024-08-02T00:00:00", - "IsAdmin": false, - "Comments": [ - { - "Text": "Premier test effectu\u00E9, tout semble OK.", - "DateCreation": "2024-08-02T00:00:00" - } - ] - }, - { - "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", - "Email": "dev@gmail.com", - "DateCreation": "2024-10-10T00:00:00", - "IsAdmin": false, - "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", - "Email": "jean.doe@gmail.com", - "DateCreation": "2024-06-25T00:00:00", - "IsAdmin": false, - "Comments": [ - { - "Text": "Utilisateur tr\u00E8s actif, peut \u00EAtre un peu trop intrusif.", - "DateCreation": "2024-06-25T00:00:00" - } - ] - }, - { - "Id": 6, - "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", - "Name": "jane_smith", - "Email": "jane.smith@gmail.com", - "DateCreation": "2024-07-15T00:00:00", - "IsAdmin": false, - "Comments": null - }, - { - "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": "admin_joe", - "Email": "admin.joe@gmail.com", - "DateCreation": "2024-05-30T00:00:00", - "IsAdmin": true, - "Comments": null - }, - { - "Id": 8, - "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_anna", - "Email": "dev.anna@gmail.com", - "DateCreation": "2024-09-05T00:00:00", - "IsAdmin": false, - "Comments": null - }, - { - "Id": 9, - "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", - "Name": "support_mark", - "Email": "support.mark@gmail.com", - "DateCreation": "2024-11-20T00:00:00", - "IsAdmin": false, - "Comments": [ - { - "Text": "Support rapide et efficace, mais manquant un peu de d\u00E9tails.", - "DateCreation": "2024-11-20T00:00:00" - } - ] - }, - { - "Id": 10, - "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_susan", - "Email": "dev.susan@gmail.com", - "DateCreation": "2024-08-12T00:00:00", - "IsAdmin": false, - "Comments": null - }, - { - "Id": 11, - "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", - "Name": "designer_steve", - "Email": "designer.steve@gmail.com", - "DateCreation": "2024-07-01T00:00:00", - "IsAdmin": false, - "Comments": [ - { - "Text": "Le design doit \u00EAtre retravaill\u00E9 pour plus de clart\u00E9.", - "DateCreation": "2024-07-01T00:00:00" - } - ] - }, - { - "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": true, - "Comments": null - }, - { - "Id": 13, - "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", - "Name": "manager_anna", - "Email": "manager.anna@gmail.com", - "DateCreation": "2024-05-01T00: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 - }, - { - "Id": 15, - "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_user_01", - "Email": "test.user01@gmail.com", - "DateCreation": "2024-06-10T00:00:00", - "IsAdmin": false, - "Comments": null - }, - { - "Id": 16, - "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_kate", - "Email": "admin.kate@gmail.com", - "DateCreation": "2024-04-16T00:00:00", - "IsAdmin": true, - "Comments": null - } +[ + { + "Id": 1, + "Image": "https://assets.audiomack.com/merlijnmuziek/80c977f3a319cf2826af53c9faa7a46f787ba806ca3f783d23bbb7123942b697.jpeg?width=1000\u0026height=1000\u0026max=true", + "Name": "admin", + "Email": "adminop@gmail.com", + "DateCreation": "2024-12-12T00:00:00", + "IsAdmin": true, + "Comments": [ + { + "Text": "Commentaire 1", + "DateCreation": "2024-12-12T00:00:00" + }, + { + "Text": "Commentaire 2", + "DateCreation": "2024-11-12T00:00:00" + } + ] + }, + { + "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", + "Name": "testeur", + "Email": "testeur@gmail.com", + "DateCreation": "2024-08-02T00:00:00", + "IsAdmin": false, + "Comments": [ + { + "Text": "Premier test effectu\u00E9, tout semble OK.", + "DateCreation": "2024-08-02T00:00:00" + } + ] + }, + { + "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", + "Email": "dev@gmail.com", + "DateCreation": "2024-10-10T00:00:00", + "IsAdmin": false, + "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", + "Email": "jean.doe@gmail.com", + "DateCreation": "2024-06-25T00:00:00", + "IsAdmin": false, + "Comments": [ + { + "Text": "Utilisateur tr\u00E8s actif, peut \u00EAtre un peu trop intrusif.", + "DateCreation": "2024-06-25T00:00:00" + } + ] + }, + { + "Id": 6, + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", + "Name": "jane_smith", + "Email": "jane.smith@gmail.com", + "DateCreation": "2024-07-15T00:00:00", + "IsAdmin": false, + "Comments": null + }, + { + "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", + "IsAdmin": false, + "Comments": null + }, + { + "Id": 8, + "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_anna", + "Email": "dev.anna@gmail.com", + "DateCreation": "2024-09-05T00:00:00", + "IsAdmin": false, + "Comments": null + }, + { + "Id": 9, + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", + "Name": "support_mark", + "Email": "support.mark@gmail.com", + "DateCreation": "2024-11-20T00:00:00", + "IsAdmin": false, + "Comments": [ + { + "Text": "Support rapide et efficace, mais manquant un peu de d\u00E9tails.", + "DateCreation": "2024-11-20T00:00:00" + } + ] + }, + { + "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": 11, + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", + "Name": "designer_steve", + "Email": "designer.steve@gmail.com", + "DateCreation": "2024-07-01T00:00:00", + "IsAdmin": false, + "Comments": [ + { + "Text": "Le design doit \u00EAtre retravaill\u00E9 pour plus de clart\u00E9.", + "DateCreation": "2024-07-01T00:00:00" + } + ] + }, + { + "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": 13, + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", + "Name": "manager_anna", + "Email": "manager.anna@gmail.com", + "DateCreation": "2024-05-01T00: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 + } ] \ No newline at end of file From e0f3f01d8d7c31c5c08c4b26ef74d55860af40e3 Mon Sep 17 00:00:00 2001 From: lebeaulato Date: Mon, 27 Jan 2025 11:55:17 +0100 Subject: [PATCH 12/79] test encore de cette langue qui marche pas --- .../Controllers/CultureController.cs | 31 +++++ .../WF-WebAdmin/Pages/DeleteUser.razor | 3 +- .../WF-WebAdmin/Pages/DeleteUser.razor.cs | 4 + WF-WebAdmin/WF-WebAdmin/Pages/Login.razor | 5 +- WF-WebAdmin/WF-WebAdmin/Program.cs | 40 +++++- .../Resources/Pages.DeleteUser.en-US.resx | 123 ++++++++++++++++++ .../Resources/Pages.DeleteUser.fr-FR.resx | 123 ++++++++++++++++++ .../WF-WebAdmin/Shared/CultureSelector.razor | 43 ++++++ .../WF-WebAdmin/Shared/MainLayout.razor | 3 + WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj | 12 ++ WF-WebAdmin/WF-WebAdmin/_Imports.razor | 1 + 11 files changed, 385 insertions(+), 3 deletions(-) create mode 100644 WF-WebAdmin/WF-WebAdmin/Controllers/CultureController.cs create mode 100644 WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.en-US.resx create mode 100644 WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.fr-FR.resx create mode 100644 WF-WebAdmin/WF-WebAdmin/Shared/CultureSelector.razor diff --git a/WF-WebAdmin/WF-WebAdmin/Controllers/CultureController.cs b/WF-WebAdmin/WF-WebAdmin/Controllers/CultureController.cs new file mode 100644 index 0000000..8f8cfec --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Controllers/CultureController.cs @@ -0,0 +1,31 @@ +using Microsoft.AspNetCore.Localization; +using Microsoft.AspNetCore.Mvc; + +/// +/// The culture controller. +/// +[Route("[controller]/[action]")] +public class CultureController : Controller +{ + /// + /// Sets the culture. + /// + /// The culture. + /// The redirect URI. + /// + /// The action result. + /// + public IActionResult SetCulture(string culture, string redirectUri) + { + if (culture != null) + { + // Define a cookie with the selected culture + this.HttpContext.Response.Cookies.Append( + CookieRequestCultureProvider.DefaultCookieName, + CookieRequestCultureProvider.MakeCookieValue( + new RequestCulture(culture))); + } + + return this.LocalRedirect(redirectUri); + } +} \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor index c0c86ce..e867a87 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor @@ -1,8 +1,9 @@ @page "/deleteuser" +@using WF_WebAdmin.Model Gestion utilisateur -

Gestion des utilisateurs

+

@Localizer["Title"]

@if(users == null) { diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs index b14bdec..ce460da 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs @@ -1,5 +1,7 @@ using Microsoft.AspNetCore.Components; using Microsoft.Extensions.Configuration.UserSecrets; +using Microsoft.Extensions.Localization; +using System.Collections.Generic; using WF_WebAdmin.Model; namespace WF_WebAdmin.Pages @@ -9,6 +11,8 @@ namespace WF_WebAdmin.Pages private List users; + [Inject] + public IStringLocalizer Localizer { get; set; } private bool showPopupDelete = false; private User userToDelete = null; diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/Login.razor b/WF-WebAdmin/WF-WebAdmin/Pages/Login.razor index 411b655..d035565 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/Login.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/Login.razor @@ -1,5 +1,6 @@ @page "/" @using WF_WebAdmin.Model +@using System.Globalization

▶ Connexion ◀

@@ -22,7 +23,9 @@

Indice de connexion : admin / admin

- +

+ CurrentCulture: @CultureInfo.CurrentCulture +

@code { diff --git a/WF-WebAdmin/WF-WebAdmin/Program.cs b/WF-WebAdmin/WF-WebAdmin/Program.cs index fb07a82..2e00bd1 100644 --- a/WF-WebAdmin/WF-WebAdmin/Program.cs +++ b/WF-WebAdmin/WF-WebAdmin/Program.cs @@ -3,9 +3,13 @@ using Blazorise.Bootstrap; using Blazorise.Icons.FontAwesome; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; +using Microsoft.AspNetCore.Localization; +using System.Globalization; using WF_WebAdmin.Data; using WF_WebAdmin.Model; - +using Microsoft.Extensions.Localization; +using Microsoft.Extensions.Options; +using Blazored.Modal; var builder = WebApplication.CreateBuilder(args); // Add services to the container. @@ -22,6 +26,25 @@ builder.Services .AddHttpClient() .AddFontAwesomeIcons(); + +builder.Services.AddBlazoredModal(); +// Add the controller of the app +builder.Services.AddControllers(); + +// Add the localization to the app and specify the resources path +builder.Services.AddLocalization(opts => { opts.ResourcesPath = "Resources"; }); + +// Configure the localtization +builder.Services.Configure(options => +{ + // Set the default culture of the web site + options.DefaultRequestCulture = new RequestCulture(new CultureInfo("en-US")); + + // Declare the supported culture + options.SupportedCultures = new List { new CultureInfo("en-US"), new CultureInfo("fr-FR") }; + options.SupportedUICultures = new List { new CultureInfo("en-US"), new CultureInfo("fr-FR") }; +}); + var app = builder.Build(); // Configure the HTTP request pipeline. @@ -38,6 +61,21 @@ app.UseStaticFiles(); app.UseRouting(); +// Get the current localization options +var options = ((IApplicationBuilder)app).ApplicationServices.GetService>(); + +if (options?.Value != null) +{ + // use the default localization + app.UseRequestLocalization(options.Value); +} + +// Add the controller to the endpoint +app.UseEndpoints(endpoints => +{ + endpoints.MapControllers(); +}); + app.MapBlazorHub(); app.MapFallbackToPage("/_Host"); diff --git a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.en-US.resx b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.en-US.resx new file mode 100644 index 0000000..edd17b0 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.en-US.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + User management + + \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.fr-FR.resx b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.fr-FR.resx new file mode 100644 index 0000000..8b7d899 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.fr-FR.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Gestion des utilisateurs + + \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Shared/CultureSelector.razor b/WF-WebAdmin/WF-WebAdmin/Shared/CultureSelector.razor new file mode 100644 index 0000000..44d3c10 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Shared/CultureSelector.razor @@ -0,0 +1,43 @@ +@using System.Globalization +@inject NavigationManager NavigationManager + +

+ +

+ +@code +{ + private CultureInfo[] supportedCultures = new[] + { + new CultureInfo("en-US"), + new CultureInfo("fr-FR") + }; + + private CultureInfo Culture + { + get => CultureInfo.CurrentCulture; + set + { + if (CultureInfo.CurrentUICulture == value) + { + return; + } + + var culture = value.Name.ToLower(CultureInfo.InvariantCulture); + + var uri = new Uri(this.NavigationManager.Uri).GetComponents(UriComponents.PathAndQuery, UriFormat.Unescaped); + var query = $"?culture={Uri.EscapeDataString(culture)}&" + $"redirectUri={Uri.EscapeDataString(uri)}"; + + // Redirect the user to the culture controller to set the cookie + this.NavigationManager.NavigateTo("/Culture/SetCulture" + query, forceLoad: true); + } + } +} \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Shared/MainLayout.razor b/WF-WebAdmin/WF-WebAdmin/Shared/MainLayout.razor index d62d291..eab28e1 100644 --- a/WF-WebAdmin/WF-WebAdmin/Shared/MainLayout.razor +++ b/WF-WebAdmin/WF-WebAdmin/Shared/MainLayout.razor @@ -15,6 +15,9 @@
+
+ +
@if (!string.IsNullOrEmpty(uLogin.Name)) { diff --git a/WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj b/WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj index a060d8e..f3b9e76 100644 --- a/WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj +++ b/WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj @@ -8,11 +8,23 @@ + + + + + + + + PublicResXFileCodeGenerator + + + PublicResXFileCodeGenerator + diff --git a/WF-WebAdmin/WF-WebAdmin/_Imports.razor b/WF-WebAdmin/WF-WebAdmin/_Imports.razor index cbc1f08..ebfca63 100644 --- a/WF-WebAdmin/WF-WebAdmin/_Imports.razor +++ b/WF-WebAdmin/WF-WebAdmin/_Imports.razor @@ -9,4 +9,5 @@ @using WF_WebAdmin @using WF_WebAdmin.Shared @using Blazorise.DataGrid +@using Blazored.Modal From b68613d4da92d6c4d2e988944e6acb0fe37409fc Mon Sep 17 00:00:00 2001 From: lebeaulato Date: Mon, 27 Jan 2025 15:26:08 +0100 Subject: [PATCH 13/79] marche pas encore --- .../WF-WebAdmin/Pages/DeleteUser.razor.cs | 1 + .../Resources/Pages.DeleteUser.Designer.cs | 72 ++++++++++ ...er.en-US.resx => Pages.DeleteUser.en.resx} | 0 ...er.fr-FR.resx => Pages.DeleteUser.fr.resx} | 0 .../Resources/Pages.DeleteUser.resx | 123 ++++++++++++++++++ WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj | 16 ++- 6 files changed, 210 insertions(+), 2 deletions(-) create mode 100644 WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.Designer.cs rename WF-WebAdmin/WF-WebAdmin/Resources/{Pages.DeleteUser.en-US.resx => Pages.DeleteUser.en.resx} (100%) rename WF-WebAdmin/WF-WebAdmin/Resources/{Pages.DeleteUser.fr-FR.resx => Pages.DeleteUser.fr.resx} (100%) create mode 100644 WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.resx diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs index ce460da..112e305 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs @@ -13,6 +13,7 @@ namespace WF_WebAdmin.Pages [Inject] public IStringLocalizer Localizer { get; set; } + private bool showPopupDelete = false; private User userToDelete = null; diff --git a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.Designer.cs b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.Designer.cs new file mode 100644 index 0000000..a00ee47 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.Designer.cs @@ -0,0 +1,72 @@ +//------------------------------------------------------------------------------ +// +// Ce code a été généré par un outil. +// Version du runtime :4.0.30319.42000 +// +// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si +// le code est régénéré. +// +//------------------------------------------------------------------------------ + +namespace WF_WebAdmin.Resources { + using System; + + + /// + /// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées. + /// + // Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder + // à l'aide d'un outil, tel que ResGen ou Visual Studio. + // Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen + // avec l'option /str ou régénérez votre projet VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class Pages_DeleteUser { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Pages_DeleteUser() { + } + + /// + /// Retourne l'instance ResourceManager mise en cache utilisée par cette classe. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WF_WebAdmin.Resources.Pages.DeleteUser", typeof(Pages_DeleteUser).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Remplace la propriété CurrentUICulture du thread actuel pour toutes + /// les recherches de ressources à l'aide de cette classe de ressource fortement typée. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Recherche une chaîne localisée semblable à Titre par défaut. + /// + public static string Title { + get { + return ResourceManager.GetString("Title", resourceCulture); + } + } + } +} diff --git a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.en-US.resx b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.en.resx similarity index 100% rename from WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.en-US.resx rename to WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.en.resx diff --git a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.fr-FR.resx b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.fr.resx similarity index 100% rename from WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.fr-FR.resx rename to WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.fr.resx diff --git a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.resx b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.resx new file mode 100644 index 0000000..2e9bfff --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Titre par défaut + + \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj b/WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj index f3b9e76..82f2810 100644 --- a/WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj +++ b/WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj @@ -19,11 +19,23 @@ - + + True + True + Pages.DeleteUser.resx + + + + + + PublicResXFileCodeGenerator + + PublicResXFileCodeGenerator - + PublicResXFileCodeGenerator + Pages.DeleteUser.Designer.cs From 2f32bb42eebcebf049b3fb440289a0811e97081c Mon Sep 17 00:00:00 2001 From: Kevin MONDEJAR Date: Wed, 29 Jan 2025 11:57:09 +0100 Subject: [PATCH 14/79] Page gestion quiz + ajout quiz admin (ne pas aller sur les page elle font planter le site pour l'instant) --- WF-WebAdmin/WF-WebAdmin/Model/Quiz.cs | 27 ++++ WF-WebAdmin/WF-WebAdmin/Model/QuizModel.cs | 30 ++++ WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor | 58 +++++++ .../WF-WebAdmin/Pages/AddQuiz.razor.cs | 36 +++++ .../WF-WebAdmin/Pages/DeleteUser.razor | 2 +- .../WF-WebAdmin/Pages/DeleteUser.razor.cs | 13 +- WF-WebAdmin/WF-WebAdmin/Pages/ModifQuiz.razor | 69 ++++++++ .../WF-WebAdmin/Pages/ModifQuiz.razor.cs | 83 ++++++++++ .../WF-WebAdmin/Pages/ModifQuote.razor | 14 +- .../WF-WebAdmin/Pages/ModifQuote.razor.cs | 34 +++- .../WF-WebAdmin/Service/QuizServiceStub.cs | 11 +- .../WF-WebAdmin/Service/QuoteServiceStub.cs | 6 +- WF-WebAdmin/WF-WebAdmin/Shared/NavMenu.razor | 8 +- .../WF-WebAdmin/wwwroot/fake-dataQuote.json | 152 ++++++------------ .../WF-WebAdmin/wwwroot/fake_data_quiz.json | 16 +- .../WF-WebAdmin/wwwroot/fake_data_users.json | 43 +---- 16 files changed, 435 insertions(+), 167 deletions(-) create mode 100644 WF-WebAdmin/WF-WebAdmin/Model/QuizModel.cs create mode 100644 WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor create mode 100644 WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor.cs create mode 100644 WF-WebAdmin/WF-WebAdmin/Pages/ModifQuiz.razor create mode 100644 WF-WebAdmin/WF-WebAdmin/Pages/ModifQuiz.razor.cs diff --git a/WF-WebAdmin/WF-WebAdmin/Model/Quiz.cs b/WF-WebAdmin/WF-WebAdmin/Model/Quiz.cs index 0e08045..2357f7c 100644 --- a/WF-WebAdmin/WF-WebAdmin/Model/Quiz.cs +++ b/WF-WebAdmin/WF-WebAdmin/Model/Quiz.cs @@ -11,5 +11,32 @@ namespace WF_WebAdmin.Model public string CAnswer { get; set; } public bool IsValid { get; set; } public string UserProposition { get; set; } + + public Quiz(int id, string question, string answerA, string answerB, string answerC, string answerD, string cAnswer, bool isValid, string userProposition) + { + Id = id; + Question = question; + AnswerA = answerA; + AnswerB = answerB; + AnswerC = answerC; + AnswerD = answerD; + CAnswer = cAnswer; + IsValid = isValid; + UserProposition = userProposition; + } + + public Quiz(int id, string question, string answerA, string answerB, string answerC, string answerD, string cAnswer) + { + Id = id; + Question = question; + AnswerA = answerA; + AnswerB = answerB; + AnswerC = answerC; + AnswerD = answerD; + CAnswer = cAnswer; + IsValid = true; + UserProposition = "Admin"; + } + } } \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Model/QuizModel.cs b/WF-WebAdmin/WF-WebAdmin/Model/QuizModel.cs new file mode 100644 index 0000000..ce5c8fa --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Model/QuizModel.cs @@ -0,0 +1,30 @@ +using System.ComponentModel.DataAnnotations; + +namespace WF_WebAdmin.Model +{ + public class QuizModel + { + [Required] + [StringLength(200, ErrorMessage = "La question ne peut pas depasser les 200 caractère.")] + public string Question { get; set; } + + [Required] + [StringLength(50, ErrorMessage = "La réponse ne peut pas depasser les 50 caractère.")] + public string AnswerA { get; set; } + + [Required] + [StringLength(50, ErrorMessage = "La réponse ne peut pas depasser les 50 caractère.")] + public string AnswerB { get; set; } + + [Required] + [StringLength(50, ErrorMessage = "La réponse ne peut pas depasser les 50 caractère.")] + public string AnswerC { get; set; } + + [Required] + [StringLength(50, ErrorMessage = "La réponse ne peut pas depasser les 50 caractère.")] + public string AnswerD { get; set; } + + [Required] + public string CAnswer { get; set; } + } +} diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor b/WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor new file mode 100644 index 0000000..e3ba5e5 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor @@ -0,0 +1,58 @@ +@using WF_WebAdmin.Model; + +@page "/add" + +

Ajouter un quiz

+ + + + + + +

+ +

+ +

+ +

+ +

+ +

+ +

+ +

+ +

+ +

+ +

+ +

+ + +
\ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor.cs new file mode 100644 index 0000000..65a727f --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor.cs @@ -0,0 +1,36 @@ +using Microsoft.AspNetCore.Components; +using WF_WebAdmin.Service; +using WF_WebAdmin.Model; + + +namespace WF_WebAdmin.Pages +{ + public partial class AddQuiz + { + [Inject] + private IQuizService quizService { get; set; } + + private QuizModel QuizModel = new(); + + private async void HandleValidSubmit() + { + int id; + id = await quizService.getNbQuiz(); + id++; + await quizService.addQuiz(new Quiz( + id, + QuizModel.Question, + QuizModel.AnswerA, + QuizModel.AnswerB, + QuizModel.AnswerC, + QuizModel.AnswerD, + QuizModel.CAnswer + )); + } + + private void OnCAwnserChange(string item, object checkedValue) + { + QuizModel.CAnswer = item; + } + } +} diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor index c3d8913..12bd791 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor @@ -30,7 +30,7 @@ else

Utilisateurs présents:

@foreach (var user in users) { -
+
@if (user.IsAdmin) { diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs index 0ade62c..999a372 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs @@ -17,6 +17,7 @@ namespace WF_WebAdmin.Pages private User userToAdmin = null; private int MaxValue = 5; private int totalItem; + private int page = 1; [Inject] @@ -26,14 +27,15 @@ namespace WF_WebAdmin.Pages public NavigationManager NavigationManager { get; set; } private List users; - private UserServiceStub userService; + + [Inject] + private IUserService userService { get; set; } protected override async Task OnInitializedAsync() { - userService = new UserServiceStub(); - users = await userService.getAllUser(); + users = await userService.getSomeUser(MaxValue, 1); } private async Task OnReadData(DataGridReadDataEventArgs e) @@ -50,6 +52,7 @@ namespace WF_WebAdmin.Pages { totalItem = await userService.getNbUser(); users = new List(response.ToArray()); + page = e.Page; } } @@ -71,15 +74,15 @@ namespace WF_WebAdmin.Pages { if (userToDelete != null) { - userService = new UserServiceStub(); await userService.removeUser(userToDelete); ClosePopup(); + var response = await userService.getSomeUser(MaxValue, page); + users = new List(response.ToArray()); } } private async Task ModifyUser() { - userService = new UserServiceStub(); await userService.updateUser(selectedUser); ClosePopup(); } diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuiz.razor b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuiz.razor new file mode 100644 index 0000000..1a5e55b --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuiz.razor @@ -0,0 +1,69 @@ +@using WF_WebAdmin.Model +@page "/modifquiz" + +Gestion des quiz + +

Gestion des quiz

+ +
+ + Ajouter + +
+ + + + + + + + + + + + + + + + + + +@if (showEditQuiz && selectedQuiz != null) +{ +
+
+

Modifier les informations de l'utilisateur :

+ + + + + + + + + + + + + + +
+
+} + +@if (showPopupDelete) +{ +
+
+

Êtes-vous sûr de vouloir supprimer ce quiz ?

+ + +
+
+} \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuiz.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuiz.razor.cs new file mode 100644 index 0000000..9da2e68 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuiz.razor.cs @@ -0,0 +1,83 @@ +using Blazorise.DataGrid; +using Microsoft.AspNetCore.Components; +using WF_WebAdmin.Model; +using WF_WebAdmin.Service; + +namespace WF_WebAdmin.Pages +{ + public partial class ModifQuiz + { + private Quiz[] quiz; + + private int MaxValue = 5; + + private int totalItem; + + private bool showEditQuiz = false; + + private Quiz? selectedQuiz; + + private bool showPopupDelete = false; + + private int page = 1; + + [Inject] + public IQuizService QuizService { get; set; } + + private async Task OnReadData(DataGridReadDataEventArgs e) + { + if (e.CancellationToken.IsCancellationRequested) + { + return; + } + + var response = await QuizService.getSommeQuiz(e.PageSize, e.Page); + + if (!e.CancellationToken.IsCancellationRequested) + { + totalItem = await QuizService.getNbQuiz(); + quiz = response.ToArray(); + page = e.Page; + } + } + + private void OnEditButtonClicked(Quiz quiz) + { + if (quiz == null) return; + selectedQuiz = quiz; + showEditQuiz = true; + } + + private void ClosePopup() + { + showEditQuiz = false; + showPopupDelete = false; + selectedQuiz = null; + } + + private async Task EditQuiz() + { + await QuizService.updateQuiz(selectedQuiz); + selectedQuiz = null; + ClosePopup(); + } + + private void OnDelete(Quiz q) + { + selectedQuiz = q; + showPopupDelete = true; + } + + private async void RemoveQuote() + { + if (selectedQuiz != null) + { + await QuizService.removeQuiz(selectedQuiz.Id); + selectedQuiz = null; + var response = await QuizService.getSommeQuiz(MaxValue, page); + quiz = response.ToArray(); + } + showPopupDelete= false; + } + } +} diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor index ca75a01..25e14d8 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor @@ -27,12 +27,12 @@ Bouton Modifier *@ Editer - + -@if (showEditQuote && selectedQuote != null) +@* @if (showEditQuote && selectedQuote != null) {
@@ -46,5 +46,15 @@
+
*@ + +@if (showPopupDelete) +{ +
+
+

Êtes-vous sûr de vouloir supprimer cette citation ?

+ + +
} \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs index 4c9bd10..d010106 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs @@ -13,10 +13,14 @@ namespace WF_WebAdmin.Pages private int totalItem; - private bool showEditQuote = false; + /*private bool showEditQuote = false;*/ private Quote? selectedQuote; + private bool showPopupDelete = false; + + private int page = 1; + [Inject] public IQuoteService QuoteService { get; set; } @@ -33,27 +37,47 @@ namespace WF_WebAdmin.Pages { totalItem = await QuoteService.getNbQuote(); quotes = response.ToArray(); + page = e.Page; } } - private void OnEditButtonClicked(Quote quote) + /*private void OnEditButtonClicked(Quote quote) { if (selectedQuote == null) return; selectedQuote = quote; showEditQuote = true; - } + }*/ private void ClosePopup() { - showEditQuote = false; + /*showEditQuote = false;*/ + showPopupDelete = false; selectedQuote = null; } - private async Task EditQuote() + /*private async Task EditQuote() { await QuoteService.updateQuote(selectedQuote); selectedQuote = null; ClosePopup(); + }*/ + + private void OnDelete(Quote q) + { + selectedQuote = q; + showPopupDelete = true; + } + + private async void RemoveQuote() + { + if (selectedQuote != null) + { + await QuoteService.removeQuote(selectedQuote); + selectedQuote= null; + var response = await QuoteService.getSomeQuote(MaxValue, page); + quotes = response.ToArray(); + } + showPopupDelete= false; } } } diff --git a/WF-WebAdmin/WF-WebAdmin/Service/QuizServiceStub.cs b/WF-WebAdmin/WF-WebAdmin/Service/QuizServiceStub.cs index d8a60df..7b6b662 100644 --- a/WF-WebAdmin/WF-WebAdmin/Service/QuizServiceStub.cs +++ b/WF-WebAdmin/WF-WebAdmin/Service/QuizServiceStub.cs @@ -13,9 +13,12 @@ public class QuizServiceStub: IQuizService await File.WriteAllTextAsync(_jsonFilePath, json); } - public Task addQuiz(Quiz quiz) + public async Task addQuiz(Quiz quiz) { - throw new NotImplementedException(); + var data = await getQuizzes(); + quiz.Id = data.Count > 0 ? data.Max(p => p.Id) + 1 : 1; + data.Add(quiz); + await saveQuizJson(data); } public async Task updateQuiz(Quiz quiz) @@ -86,6 +89,10 @@ public class QuizServiceStub: IQuizService var data = await getQuizzes(); if ((page - 1) * nb + nb > data.Count()) { + if(nb > data.Count()) + { + return data.GetRange(0, data.Count()-1); + } return data.GetRange(data.Count() - nb, nb); } return data.GetRange((page - 1) * nb, nb); diff --git a/WF-WebAdmin/WF-WebAdmin/Service/QuoteServiceStub.cs b/WF-WebAdmin/WF-WebAdmin/Service/QuoteServiceStub.cs index 36a4d21..bc2dea4 100644 --- a/WF-WebAdmin/WF-WebAdmin/Service/QuoteServiceStub.cs +++ b/WF-WebAdmin/WF-WebAdmin/Service/QuoteServiceStub.cs @@ -19,7 +19,7 @@ namespace WF_WebAdmin.Service; quote.Id = data.Count > 0 ? data.Max(p => p.Id) + 1 : 1; data.Add(quote); await saveQuoteJson(data); - } + } public async Task removeQuote(Quote quote) { @@ -70,6 +70,10 @@ namespace WF_WebAdmin.Service; var quotes = await getAllQuote(); if((page - 1) * nb + nb > quotes.Count()) { + if (nb > quotes.Count()) + { + return quotes.GetRange(0, quotes.Count()); + } return quotes.GetRange(quotes.Count()-nb, nb); } return quotes.GetRange((page - 1) * nb, nb); diff --git a/WF-WebAdmin/WF-WebAdmin/Shared/NavMenu.razor b/WF-WebAdmin/WF-WebAdmin/Shared/NavMenu.razor index 28062bd..5dfc260 100644 --- a/WF-WebAdmin/WF-WebAdmin/Shared/NavMenu.razor +++ b/WF-WebAdmin/WF-WebAdmin/Shared/NavMenu.razor @@ -39,7 +39,13 @@ + + diff --git a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataQuote.json b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataQuote.json index c10c1ca..6d48018 100644 --- a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataQuote.json +++ b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataQuote.json @@ -7,236 +7,188 @@ "Charac": "test", "ImgPath": "http://starwars.com", "TitleSrc": "Star Wars", - "DateSrc": "2025-01-21", + "DateSrc": "2025-01-21T00:00:00", "UserProposition": "user1", - "isValide": true + "IsValid": false }, { "Id": 2, - "Content": "Il n’y a pas de place comme chez soi.", + "Content": "Il n\u2019y a pas de place comme chez soi.", "Like": 120, "Langue": "fr", "Charac": "test", "ImgPath": "http://wizardofoz.com", - "TitleSrc": "Le Magicien d'Oz", - "DateSrc": "2025-01-21", + "TitleSrc": "Le Magicien d\u0027Oz", + "DateSrc": "2025-01-21T00:00:00", "UserProposition": "user2", - "isValide": true + "IsValid": false }, { "Id": 3, - "Content": "C'est le choix qui fait l'homme, non le destin.", + "Content": "C\u0027est le choix qui fait l\u0027homme, non le destin.", "Like": 90, "Langue": "fr", "Charac": "test", "ImgPath": "http://harrypotter.com", "TitleSrc": "Harry Potter et la Chambre des Secrets", - "DateSrc": "2025-01-21", + "DateSrc": "2025-01-21T00:00:00", "UserProposition": "user3", - "isValide": true + "IsValid": false }, { "Id": 4, - "Content": "La magie, c’est de croire en soi, c’est ça la magie.", + "Content": "La magie, c\u2019est de croire en soi, c\u2019est \u00E7a la magie.", "Like": 75, "Langue": "fr", "Charac": "test", "ImgPath": "http://disney.com", - "TitleSrc": "La Belle et la Bête", - "DateSrc": "2025-01-21", + "TitleSrc": "La Belle et la B\u00EAte", + "DateSrc": "2025-01-21T00:00:00", "UserProposition": "user4", - "isValide": true + "IsValid": false }, { "Id": 5, - "Content": "La vérité est plus étrange que la fiction.", + "Content": "La v\u00E9rit\u00E9 est plus \u00E9trange que la fiction.", "Like": 65, "Langue": "fr", "Charac": "test", "ImgPath": "http://theimaginarium.com", - "TitleSrc": "L'Imaginarium du Docteur Parnassus", - "DateSrc": "2025-01-21", + "TitleSrc": "L\u0027Imaginarium du Docteur Parnassus", + "DateSrc": "2025-01-21T00:00:00", "UserProposition": "user5", - "isValide": true + "IsValid": false }, { "Id": 6, - "Content": "Un homme qui ne croit pas aux miracles n’est pas un homme.", + "Content": "Un homme qui ne croit pas aux miracles n\u2019est pas un homme.", "Like": 85, "Langue": "fr", "Charac": "test", "ImgPath": "http://theprinceofpersia.com", "TitleSrc": "Prince of Persia : Les Sables du Temps", - "DateSrc": "2025-01-21", + "DateSrc": "2025-01-21T00:00:00", "UserProposition": "user6", - "isValide": true + "IsValid": false }, { "Id": 7, - "Content": "La seule limite à notre réalisation de demain sera nos doutes et hésitations d’aujourd’hui.", + "Content": "La seule limite \u00E0 notre r\u00E9alisation de demain sera nos doutes et h\u00E9sitations d\u2019aujourd\u2019hui.", "Like": 100, "Langue": "fr", "Charac": "test", "ImgPath": "http://backtothefuture.com", "TitleSrc": "Retour vers le futur", - "DateSrc": "2025-01-21", + "DateSrc": "2025-01-21T00:00:00", "UserProposition": "user7", - "isValide": true + "IsValid": false }, { "Id": 8, - "Content": "L’imagination est plus importante que la connaissance.", + "Content": "L\u2019imagination est plus importante que la connaissance.", "Like": 200, "Langue": "fr", "Charac": "test", "ImgPath": "http://inceptionmovie.com", "TitleSrc": "Inception", - "DateSrc": "2025-01-21", + "DateSrc": "2025-01-21T00:00:00", "UserProposition": "user8", - "isValide": true + "IsValid": false }, { "Id": 9, - "Content": "Ce n’est pas de la magie, c’est de la science, mais on ne comprend pas encore tout.", + "Content": "Ce n\u2019est pas de la magie, c\u2019est de la science, mais on ne comprend pas encore tout.", "Like": 110, "Langue": "fr", "Charac": "test", "ImgPath": "http://doctorstrange.com", "TitleSrc": "Doctor Strange", - "DateSrc": "2025-01-21", + "DateSrc": "2025-01-21T00:00:00", "UserProposition": "user9", - "isValide": true + "IsValid": false }, { "Id": 10, - "Content": "L’important ce n’est pas d’être parfait, c’est d’être vrai.", + "Content": "L\u2019important ce n\u2019est pas d\u2019\u00EAtre parfait, c\u2019est d\u2019\u00EAtre vrai.", "Like": 130, "Langue": "fr", "Charac": "test", "ImgPath": "http://narnia.com", "TitleSrc": "Le Monde de Narnia", - "DateSrc": "2025-01-21", + "DateSrc": "2025-01-21T00:00:00", "UserProposition": "user10", - "isValide": true + "IsValid": false }, { "Id": 11, - "Content": "Vous ne pouvez pas vivre sans causer de dommages à quelqu'un d'autre.", + "Content": "Vous ne pouvez pas vivre sans causer de dommages \u00E0 quelqu\u0027un d\u0027autre.", "Like": 110, "Langue": "fr", "Charac": "test", "ImgPath": "http://thematrix.com", "TitleSrc": "The Matrix", - "DateSrc": "2025-01-21", + "DateSrc": "2025-01-21T00:00:00", "UserProposition": "user11", - "isValide": true + "IsValid": false }, { "Id": 12, - "Content": "Les rêves, ils ne peuvent pas vous mentir.", + "Content": "Les r\u00EAves, ils ne peuvent pas vous mentir.", "Like": 80, "Langue": "fr", "Charac": "test", "ImgPath": "http://peterpanmovie.com", "TitleSrc": "Peter Pan", - "DateSrc": "2025-01-21", + "DateSrc": "2025-01-21T00:00:00", "UserProposition": "user12", - "isValide": true - }, - { - "Id": 13, - "Content": "Tous les hommes meurent, mais pas tous vivent.", - "Like": 95, - "Langue": "fr", - "Charac": "test", - "ImgPath": "http://braveheart.com", - "TitleSrc": "Braveheart", - "DateSrc": "2025-01-21", - "UserProposition": "user13", - "isValide": true + "IsValid": false }, { "Id": 14, - "Content": "La vie, c’est ce qui nous arrive quand on est occupé à faire d’autres projets.", + "Content": "La vie, c\u2019est ce qui nous arrive quand on est occup\u00E9 \u00E0 faire d\u2019autres projets.", "Like": 140, "Langue": "fr", "Charac": "test", "ImgPath": "http://forrestgump.com", "TitleSrc": "Forrest Gump", - "DateSrc": "2025-01-21", + "DateSrc": "2025-01-21T00:00:00", "UserProposition": "user14", - "isValide": true + "IsValid": false }, { "Id": 15, - "Content": "Il faut toujours croire en l’impossible, sinon la magie disparaît.", + "Content": "Il faut toujours croire en l\u2019impossible, sinon la magie dispara\u00EEt.", "Like": 60, "Langue": "fr", "Charac": "test", "ImgPath": "http://harrypotter.com", - "TitleSrc": "Harry Potter à l'école des sorciers", - "DateSrc": "2025-01-21", + "TitleSrc": "Harry Potter \u00E0 l\u0027\u00E9cole des sorciers", + "DateSrc": "2025-01-21T00:00:00", "UserProposition": "user15", - "isValide": true + "IsValid": false }, { "Id": 16, - "Content": "Le pouvoir de l’imaginaire est plus fort que tout.", + "Content": "Le pouvoir de l\u2019imaginaire est plus fort que tout.", "Like": 120, "Langue": "fr", "Charac": "test", "ImgPath": "http://theincrediblesmovie.com", "TitleSrc": "Les Indestructibles", - "DateSrc": "2025-01-21", + "DateSrc": "2025-01-21T00:00:00", "UserProposition": "user16", - "isValide": true + "IsValid": false }, { "Id": 17, - "Content": "On peut conquérir l’univers en une journée si on travaille ensemble.", + "Content": "On peut conqu\u00E9rir l\u2019univers en une journ\u00E9e si on travaille ensemble.", "Like": 130, "Langue": "fr", "Charac": "test", "ImgPath": "http://guardiansofthegalaxy.com", "TitleSrc": "Les Gardiens de la Galaxie", - "DateSrc": "2025-01-21", + "DateSrc": "2025-01-21T00:00:00", "UserProposition": "user17", - "isValide": true - }, - { - "Id": 18, - "Content": "La véritable magie vient de l’intérieur.", - "Like": 75, - "Langue": "fr", - "Charac": "test", - "ImgPath": "http://maleficentmovie.com", - "TitleSrc": "Maléfique", - "DateSrc": "2025-01-21", - "UserProposition": "user18", - "isValide": true - }, - { - "Id": 19, - "Content": "On ne voit bien qu’avec le cœur.", - "Like": 200, - "Langue": "fr", - "Charac": "test", - "ImgPath": "http://lepetitprince.com", - "TitleSrc": "Le Petit Prince", - "DateSrc": "2025-01-21", - "UserProposition": "user19", - "isValide": true - }, - { - "Id": 20, - "Content": "Les étoiles sont des rêves en attente d’être vécus.", - "Like": 85, - "Langue": "fr", - "Charac": "test", - "ImgPath": "http://interstellar.com", - "TitleSrc": "Interstellar", - "DateSrc": "2025-01-21", - "UserProposition": "user20", - "isValide": true + "IsValid": false } -] +] \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_quiz.json b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_quiz.json index 1f90e95..4569231 100644 --- a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_quiz.json +++ b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_quiz.json @@ -1,12 +1,12 @@ [ { "Id": 9, - "Question": "Qui labore fugiat sint Lorem ut minim in ex dolor.", - "AnswerA": "et deserunt", - "AnswerB": "labore sit", - "AnswerC": "in eiusmod", - "AnswerD": "amet incididunt", - "CAnswer": "C", + "Question": "Question_quiz_1", + "AnswerA": "rep_1", + "AnswerB": "rep_2", + "AnswerC": "rep_3", + "AnswerD": "rep_3", + "CAnswer": "A", "IsValid": false, "UserProposition": "Earnestine Poole" }, @@ -23,8 +23,8 @@ }, { "Id": 11, - "Question": "In labore sunt est cupidatat cillum.", - "AnswerA": "ut ad", + "Question": "nv question", + "AnswerA": "repA", "AnswerB": "non deserunt", "AnswerC": "do officia", "AnswerD": "ut nostrud", diff --git a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_users.json b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_users.json index 5b402a6..49c9944 100644 --- a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_users.json +++ b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_users.json @@ -1,29 +1,11 @@ [ - { - "Id": 1, - "Image": "https://assets.audiomack.com/merlijnmuziek/80c977f3a319cf2826af53c9faa7a46f787ba806ca3f783d23bbb7123942b697.jpeg?width=1000\u0026height=1000\u0026max=true", - "Name": "admin", - "Email": "adminop@gmail.com", - "DateCreation": "2024-12-12T00:00:00", - "IsAdmin": true, - "Comments": [ - { - "Text": "Commentaire 1", - "DateCreation": "2024-12-12T00:00:00" - }, - { - "Text": "Commentaire 2", - "DateCreation": "2024-11-12T00:00:00" - } - ] - }, { "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", "Name": "testeur", "Email": "testeur@gmail.com", "DateCreation": "2024-08-02T00:00:00", - "IsAdmin": false, + "IsAdmin": true, "Comments": [ { "Text": "Premier test effectu\u00E9, tout semble OK.", @@ -104,20 +86,6 @@ "IsAdmin": false, "Comments": null }, - { - "Id": 11, - "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", - "Name": "designer_steve", - "Email": "designer.steve@gmail.com", - "DateCreation": "2024-07-01T00:00:00", - "IsAdmin": false, - "Comments": [ - { - "Text": "Le design doit \u00EAtre retravaill\u00E9 pour plus de clart\u00E9.", - "DateCreation": "2024-07-01T00:00:00" - } - ] - }, { "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", @@ -127,15 +95,6 @@ "IsAdmin": false, "Comments": null }, - { - "Id": 13, - "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7", - "Name": "manager_anna", - "Email": "manager.anna@gmail.com", - "DateCreation": "2024-05-01T00: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", From 0b836046d6c03eceef19ae0f427d57763bc78de3 Mon Sep 17 00:00:00 2001 From: lebeaulato Date: Thu, 30 Jan 2025 14:39:19 +0100 Subject: [PATCH 15/79] les langues marchent --- .../Controllers/CultureController.cs | 45 ++++--- .../WF-WebAdmin/Pages/DeleteUser.razor.cs | 1 + WF-WebAdmin/WF-WebAdmin/Pages/Login.razor | 2 +- WF-WebAdmin/WF-WebAdmin/Pages/Login.razor.cs | 3 + WF-WebAdmin/WF-WebAdmin/Program.cs | 12 +- .../Resources/Pages.DeleteUser.Designer.cs | 72 ---------- ...er.en.resx => Pages.DeleteUser.en-US.resx} | 3 +- ...er.fr.resx => Pages.DeleteUser.fr-FR.resx} | 3 +- ...DeleteUser.resx => Pages.Login.en-US.resx} | 5 +- .../Resources/Pages.Login.fr-FR.resx | 124 ++++++++++++++++++ WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj | 22 +--- 11 files changed, 169 insertions(+), 123 deletions(-) delete mode 100644 WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.Designer.cs rename WF-WebAdmin/WF-WebAdmin/Resources/{Pages.DeleteUser.en.resx => Pages.DeleteUser.en-US.resx} (96%) rename WF-WebAdmin/WF-WebAdmin/Resources/{Pages.DeleteUser.fr.resx => Pages.DeleteUser.fr-FR.resx} (96%) rename WF-WebAdmin/WF-WebAdmin/Resources/{Pages.DeleteUser.resx => Pages.Login.en-US.resx} (96%) create mode 100644 WF-WebAdmin/WF-WebAdmin/Resources/Pages.Login.fr-FR.resx diff --git a/WF-WebAdmin/WF-WebAdmin/Controllers/CultureController.cs b/WF-WebAdmin/WF-WebAdmin/Controllers/CultureController.cs index 8f8cfec..834b808 100644 --- a/WF-WebAdmin/WF-WebAdmin/Controllers/CultureController.cs +++ b/WF-WebAdmin/WF-WebAdmin/Controllers/CultureController.cs @@ -1,31 +1,34 @@ using Microsoft.AspNetCore.Localization; using Microsoft.AspNetCore.Mvc; -/// -/// The culture controller. -/// -[Route("[controller]/[action]")] -public class CultureController : Controller +namespace WF_WebAdmin.Controllers { /// - /// Sets the culture. + /// The culture controller. /// - /// The culture. - /// The redirect URI. - /// - /// The action result. - /// - public IActionResult SetCulture(string culture, string redirectUri) + [Route("[controller]/[action]")] + public class CultureController : Controller { - if (culture != null) + /// + /// Sets the culture. + /// + /// The culture. + /// The redirect URI. + /// + /// The action result. + /// + public IActionResult SetCulture(string culture, string redirectUri) { - // Define a cookie with the selected culture - this.HttpContext.Response.Cookies.Append( - CookieRequestCultureProvider.DefaultCookieName, - CookieRequestCultureProvider.MakeCookieValue( - new RequestCulture(culture))); - } + if (culture != null) + { + // Define a cookie with the selected culture + this.HttpContext.Response.Cookies.Append( + CookieRequestCultureProvider.DefaultCookieName, + CookieRequestCultureProvider.MakeCookieValue( + new RequestCulture(culture))); + } - return this.LocalRedirect(redirectUri); + return this.LocalRedirect(redirectUri); + } } -} \ No newline at end of file +} diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs index 112e305..0903099 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs @@ -3,6 +3,7 @@ using Microsoft.Extensions.Configuration.UserSecrets; using Microsoft.Extensions.Localization; using System.Collections.Generic; using WF_WebAdmin.Model; +using WF_WebAdmin.Service; namespace WF_WebAdmin.Pages { diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/Login.razor b/WF-WebAdmin/WF-WebAdmin/Pages/Login.razor index d035565..f82fe75 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/Login.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/Login.razor @@ -2,7 +2,7 @@ @using WF_WebAdmin.Model @using System.Globalization -

▶ Connexion ◀

+

▶@Localizer["LoginTitle"]◀

Indice de connexion : admin / admin

-

- CurrentCulture: @CultureInfo.CurrentCulture -

+ @code { diff --git a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.en-US.resx b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.en-US.resx index 095c714..28d0e43 100644 --- a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.en-US.resx +++ b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.en-US.resx @@ -117,8 +117,53 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + User Management gestionaire user + + Add as Admin + + + Administrator + + + Comment(s) Posted by + + + Confirm + + + Account Creation Date: + + + Delete User + + + Remove as Admin + + + Cancel + + + User Email: + + + Users present: + + + Username + + + No users present on the site + + + No comments on the site + + + Are you sure you want to delete this user? + + + Are you sure you want to change this user's role? + \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.fr-FR.resx b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.fr-FR.resx index de52c05..b43dcf4 100644 --- a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.fr-FR.resx +++ b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.DeleteUser.fr-FR.resx @@ -117,8 +117,53 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + Gestionnaire des utilisateurs gestion user + + Ajouter en tant qu'administrateur + + + Administrateur + + + Commentaire(s) posté(s) par + + + Confirmer + + + Date de création du compte : + + + Supprimer l'utilisateur + + + Retirer en tant qu'administrateur + + + Annuler + + + Email de l'utilisateur : + + + Utilisateurs présents: + + + Nom d'utilisateur : + + + Aucun utilisateur présent sur le site + + + Aucun commentaire sur le site + + + Êtes-vous sûr de vouloir supprimer cet utilisateur ? + + + Êtes-vous sûr de vouloir changer le rôle de cet utilisateur ? + \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.Login.en-US.resx b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.Login.en-US.resx index b485dca..3359872 100644 --- a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.Login.en-US.resx +++ b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.Login.en-US.resx @@ -117,6 +117,22 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Login + + + Enter your password + + + Enter your pseudo + + + Pseudo + id + + + Password + Login connexion diff --git a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.Login.fr-FR.resx b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.Login.fr-FR.resx index 9e7752e..99aef05 100644 --- a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.Login.fr-FR.resx +++ b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.Login.fr-FR.resx @@ -117,6 +117,22 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Se Connecter + + + Entrez votre mot de passe + + + Entrez votre pseudo + + + Identifiant + id + + + Mot de passe + Connexion connexion From 2f381cb77f0ae917c1e70d47869530678db55602 Mon Sep 17 00:00:00 2001 From: lebeaulato Date: Thu, 30 Jan 2025 15:29:38 +0100 Subject: [PATCH 17/79] trad Accueil --- WF-WebAdmin/WF-WebAdmin/Pages/Accueil.razor | 16 +- .../WF-WebAdmin/Pages/Accueil.razor.cs | 3 + WF-WebAdmin/WF-WebAdmin/Pages/Login.razor.cs | 2 +- .../Resources/Pages.Accueil.en-US.resx | 141 ++++++++++++++++++ .../Resources/Pages.Accueil.fr-FR.resx | 141 ++++++++++++++++++ 5 files changed, 294 insertions(+), 9 deletions(-) create mode 100644 WF-WebAdmin/WF-WebAdmin/Resources/Pages.Accueil.en-US.resx create mode 100644 WF-WebAdmin/WF-WebAdmin/Resources/Pages.Accueil.fr-FR.resx diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/Accueil.razor b/WF-WebAdmin/WF-WebAdmin/Pages/Accueil.razor index 1cd75b6..099d4dd 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/Accueil.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/Accueil.razor @@ -1,11 +1,11 @@ @page "/Accueil" - +@using WF_WebAdmin.Model Accueil -

Bienvenu sur le tableau de bord de What the Fantasy

+

@Localizer["AccueilWelcome"]

-

Citation du jour

+

@Localizer["AccueilTitle"]

@if (Dailyquote != null) { @@ -15,8 +15,8 @@

@quote.Content

-

Personnage : @quote.Charac

-

Source : @quote.TitleSrc

+

@Localizer["AccueilCharacter"] @quote.Charac

+

@Localizer["AccueilSrc"] @quote.TitleSrc

} @@ -24,9 +24,9 @@ } else { -

Aucune citation du jour

+

@Localizer["AccueilNoQuote"]

} -

Changement de la citation manuellement

- +

@Localizer["AccueilManualChange"]

+ diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/Accueil.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/Accueil.razor.cs index 379853e..797b255 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/Accueil.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/Accueil.razor.cs @@ -1,5 +1,6 @@ using Blazorise.DataGrid; using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.Localization; using WF_WebAdmin.Model; @@ -15,6 +16,8 @@ namespace WF_WebAdmin.Pages [Inject] public NavigationManager NavigationManager { get; set; } + [Inject] + public IStringLocalizer Localizer { get; set; } protected override async Task OnInitializedAsync() { Dailyquote = await Http.GetFromJsonAsync($"{NavigationManager.BaseUri}fake-dataDailyQuote.json"); diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/Login.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/Login.razor.cs index 2317ada..3ba9767 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/Login.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/Login.razor.cs @@ -47,7 +47,7 @@ namespace WF_WebAdmin.Pages uLogin.Name = user.Name; uLogin.Image = user.Image; - NavigationManager.NavigateTo(NavigationManager.BaseUri + "/accueil"); + NavigationManager.NavigateTo(NavigationManager.BaseUri + "accueil"); return; } diff --git a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.Accueil.en-US.resx b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.Accueil.en-US.resx new file mode 100644 index 0000000..5ff2d4a --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.Accueil.en-US.resx @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Put a New Random Quote + + + Character: + + + Changed Quote Manually + + + No Quote of the Day + + + Source: + + + Quote of the Day + + + Welcome to the What the Fantasy Dashboard + + \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.Accueil.fr-FR.resx b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.Accueil.fr-FR.resx new file mode 100644 index 0000000..607d271 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.Accueil.fr-FR.resx @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Mettre une nouvellement citation aléatoire + + + Personnage : + + + Changement de la citation manuellement + + + Aucune citation du jour + + + Source : + + + Citation du jour + + + Bienvenu sur le tableau de bord de What the Fantasy + + \ No newline at end of file From 4ee638eae7348ee2b0706481da2f67d1d510b8cc Mon Sep 17 00:00:00 2001 From: Kevin MONDEJAR Date: Thu, 30 Jan 2025 15:32:03 +0100 Subject: [PATCH 18/79] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'README.md'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b98784e..417ac1c 100644 --- a/README.md +++ b/README.md @@ -61,8 +61,8 @@ L'application devrait se lancer automatiquement dans votre navigateur par défau # Blazor Apps (30 points) 🟨 En cours / ✅ Fait / ❌ Pas fait

✅ Mise en place d'une page de visualisation des données avec pagination (2 points)
-🟨 Page d'ajout d'un élement avec validation (2 point)
-🟨 Page d'édition d'un élement avec validation (2 point)
+✅ Page d'ajout d'un élement avec validation (2 point)
+✅ Page d'édition d'un élement avec validation (2 point)
✅ Supression d'un élement avec une confirmation (2 point)
🟨 Composant complexe (5 point)
🟨 Use API (Get / Insert / Update / Delete) (3 point)
From f17fa7e31eee4a06f3800537c321eb5b53f8fee9 Mon Sep 17 00:00:00 2001 From: Kevin MONDEJAR Date: Thu, 30 Jan 2025 15:34:16 +0100 Subject: [PATCH 19/79] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'README.md'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 417ac1c..50fc366 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ L'application devrait se lancer automatiquement dans votre navigateur par défau 🟨 Use API (Get / Insert / Update / Delete) (3 point)
❌ Utilisation IOC & DI (4 point)
🟨 Localisation & Globalisation (au moins deux langues) (1 point)
-🟨 Utilisation de la configuration (1 point)
+❌ Utilisation de la configuration (1 point)
🟨 Logs (2 point)
❌ Propreté du code (Vous pouvez vous servir de sonarqube) (2 point)
✅ IHM (Design global, placement des boutons, ...) (2 point)
From 9d8eb2e5d538e1f141e67ae3319bbeeda2ecaa60 Mon Sep 17 00:00:00 2001 From: Kevin MONDEJAR Date: Thu, 30 Jan 2025 15:35:06 +0100 Subject: [PATCH 20/79] fin service --- WF-WebAdmin/WF-WebAdmin/Model/Character.cs | 8 +++ WF-WebAdmin/WF-WebAdmin/Model/Quiz.cs | 2 + WF-WebAdmin/WF-WebAdmin/Model/Source.cs | 11 ++++ WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor | 20 +++---- .../WF-WebAdmin/Pages/AddQuiz.razor.cs | 56 +++++++++++++++++-- WF-WebAdmin/WF-WebAdmin/Pages/Edit.razor | 47 +++++++++++++++- WF-WebAdmin/WF-WebAdmin/Pages/Edit.razor.cs | 52 +++++++++++++++++ WF-WebAdmin/WF-WebAdmin/Pages/ModifQuiz.razor | 2 +- .../WF-WebAdmin/Pages/ModifQuote.razor | 2 - .../WF-WebAdmin/Service/IQuoteService.cs | 4 ++ .../WF-WebAdmin/Service/QuoteServiceLocal.cs | 10 ++++ .../WF-WebAdmin/Service/QuoteServiceStub.cs | 43 +++++++++++++- WF-WebAdmin/WF-WebAdmin/Shared/NavMenu.razor | 2 +- .../WF-WebAdmin/wwwroot/fake-dataQuote.json | 6 +- .../WF-WebAdmin/wwwroot/fake_data_quiz.json | 33 +++++++++++ 15 files changed, 270 insertions(+), 28 deletions(-) create mode 100644 WF-WebAdmin/WF-WebAdmin/Model/Character.cs create mode 100644 WF-WebAdmin/WF-WebAdmin/Model/Source.cs diff --git a/WF-WebAdmin/WF-WebAdmin/Model/Character.cs b/WF-WebAdmin/WF-WebAdmin/Model/Character.cs new file mode 100644 index 0000000..a5e1d87 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Model/Character.cs @@ -0,0 +1,8 @@ +namespace WF_WebAdmin.Model +{ + public class Character + { + public int id_caracter { get; set; } + public string caracter { get; set; } + } +} diff --git a/WF-WebAdmin/WF-WebAdmin/Model/Quiz.cs b/WF-WebAdmin/WF-WebAdmin/Model/Quiz.cs index 2357f7c..a72be08 100644 --- a/WF-WebAdmin/WF-WebAdmin/Model/Quiz.cs +++ b/WF-WebAdmin/WF-WebAdmin/Model/Quiz.cs @@ -38,5 +38,7 @@ namespace WF_WebAdmin.Model UserProposition = "Admin"; } + public Quiz() {} + } } \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Model/Source.cs b/WF-WebAdmin/WF-WebAdmin/Model/Source.cs new file mode 100644 index 0000000..99c390a --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Model/Source.cs @@ -0,0 +1,11 @@ +namespace WF_WebAdmin.Model +{ + public class Source + { + public int id_source { get; set; } + + public string title { get; set; } + + public int date { get; set; } + } +} diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor b/WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor index e3ba5e5..d577939 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor @@ -2,7 +2,7 @@ @page "/add" -

Ajouter un quiz

+

Ajouter une Question

@@ -32,25 +32,25 @@

-

diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor.cs index 65a727f..36de693 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor.cs @@ -1,6 +1,8 @@ using Microsoft.AspNetCore.Components; using WF_WebAdmin.Service; using WF_WebAdmin.Model; +using Microsoft.AspNetCore.Mvc; +using System.Text.RegularExpressions; namespace WF_WebAdmin.Pages @@ -10,27 +12,69 @@ namespace WF_WebAdmin.Pages [Inject] private IQuizService quizService { get; set; } + [Inject] + public NavigationManager NavigationManager { get; set; } + private QuizModel QuizModel = new(); private async void HandleValidSubmit() { + int id; id = await quizService.getNbQuiz(); id++; await quizService.addQuiz(new Quiz( id, - QuizModel.Question, - QuizModel.AnswerA, - QuizModel.AnswerB, - QuizModel.AnswerC, - QuizModel.AnswerD, - QuizModel.CAnswer + validateInformation(QuizModel.Question), + validateInformation(QuizModel.AnswerA), + validateInformation(QuizModel.AnswerB), + validateInformation(QuizModel.AnswerC), + validateInformation(QuizModel.AnswerD), + validateReponse(QuizModel.CAnswer) )); + NavigationManager.NavigateTo("modifquiz"); } private void OnCAwnserChange(string item, object checkedValue) { QuizModel.CAnswer = item; } + + private static string validateInformation(string item) + { + return item; // VALIDATION A FAIRE + } + + private static string validateReponse(string item) + { + try + { + if (!string.IsNullOrEmpty(item)) + { + switch (item) + { + case "A": + break; + case "B": + break; + case "C": + break; + case "D": + break; + default: + throw new InvalidDataException("Invalid item (validateReponse) : item must be A,B,C or D " + item + "give."); + } + } + else + { + throw new ArgumentNullException("Invalid item (validateReponse): null given."); + } + return item; + } + catch (Exception ex) + { + return "A"; //Default Argument + } + } } } diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/Edit.razor b/WF-WebAdmin/WF-WebAdmin/Pages/Edit.razor index 5f59560..edb3822 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/Edit.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/Edit.razor @@ -1,5 +1,48 @@ -@page "/edit/{Id:int}" +@using WF_WebAdmin.Model +@page "/edit/{Id:int}"

Editer

-
My parameter: @Id
\ No newline at end of file + + + + +

+ +

+ +

+ +

+ +

+ +

+ +

+ +

+ + +
\ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/Edit.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/Edit.razor.cs index 4d09214..71bb9f0 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/Edit.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/Edit.razor.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Components; using WF_WebAdmin.Model; +using WF_WebAdmin.Service; namespace WF_WebAdmin.Pages { @@ -8,6 +9,57 @@ namespace WF_WebAdmin.Pages [Parameter] public int Id { get; set; } + [Inject] + private IQuoteService quoteService { get; set; } + + [Inject] + public NavigationManager NavigationManager { get; set; } + + private Quote q{ get; set; } + private QuoteModel quoteModel = new(); + + private List charac = new List(); + + private List src = new List(); + + protected override async Task OnInitializedAsync() + { + q = await quoteService.getOnequote(Id); + quoteModel.Content = q.Content; + quoteModel.Langue = q.Langue; + quoteModel.Charac = q.Charac; + quoteModel.TitleSrc = q.TitleSrc; + quoteModel.Id = q.Id; + quoteModel.Like = q.Like; + quoteModel.ImgPath = q.ImgPath; + quoteModel.DateSrc = q.DateSrc; + quoteModel.UserProposition = q.UserProposition; + quoteModel.IsValid = q.IsValid; + charac = await quoteService.getChar(); + src = await quoteService.getSrc(); + } + + protected async void HandleValidSubmit() + { + q.Content = quoteModel.Content; + q.Langue = quoteModel.Langue; + q.TitleSrc = quoteModel.TitleSrc; + q.Charac = quoteModel.Charac; + await quoteService.updateQuote(q); + NavigationManager.NavigateTo("modifquote"); + } + + private void OnlangChange(string item, object checkedValue) + { + if(item == "fr" || item == "en") + { + quoteModel.Langue = item; + } + } + + + + } } diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuiz.razor b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuiz.razor index 1a5e55b..60d2264 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuiz.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuiz.razor @@ -1,7 +1,7 @@ @using WF_WebAdmin.Model @page "/modifquiz" -Gestion des quiz +Gestion des question

Gestion des quiz

diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor index 25e14d8..a04a0fd 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor @@ -5,8 +5,6 @@

Correction des citations

-

Ajouter une recherche

- > getSomeQuoteInvalid(int nb, int page); public Task getNbQuote(); + + public Task> getChar(); + + public Task> getSrc(); } } diff --git a/WF-WebAdmin/WF-WebAdmin/Service/QuoteServiceLocal.cs b/WF-WebAdmin/WF-WebAdmin/Service/QuoteServiceLocal.cs index 6f9a9b8..4417c5b 100644 --- a/WF-WebAdmin/WF-WebAdmin/Service/QuoteServiceLocal.cs +++ b/WF-WebAdmin/WF-WebAdmin/Service/QuoteServiceLocal.cs @@ -137,5 +137,15 @@ namespace WF_WebAdmin.Service { throw new NotImplementedException(); } + + public Task> getChar() + { + throw new NotImplementedException(); + } + + public Task> getSrc() + { + throw new NotImplementedException(); + } } } diff --git a/WF-WebAdmin/WF-WebAdmin/Service/QuoteServiceStub.cs b/WF-WebAdmin/WF-WebAdmin/Service/QuoteServiceStub.cs index bc2dea4..fcf6102 100644 --- a/WF-WebAdmin/WF-WebAdmin/Service/QuoteServiceStub.cs +++ b/WF-WebAdmin/WF-WebAdmin/Service/QuoteServiceStub.cs @@ -6,8 +6,10 @@ namespace WF_WebAdmin.Service; public class QuoteServiceStub : IQuoteService { private readonly string _jsonFilePath = Path.Combine(Environment.CurrentDirectory, "wwwroot", "fake-dataQuote.json"); + private readonly string _char = Path.Combine(Environment.CurrentDirectory, "wwwroot", "fake-dataCaracter.json"); + private readonly string _src = Path.Combine(Environment.CurrentDirectory, "wwwroot", "fake-dataSource.json"); - public async Task saveQuoteJson(List quotes) + public async Task saveQuoteJson(List quotes) { var json = JsonSerializer.Serialize(quotes, new JsonSerializerOptions { WriteIndented = true }); await File.WriteAllTextAsync(_jsonFilePath, json); @@ -97,12 +99,23 @@ namespace WF_WebAdmin.Service; public async Task> getAllQuoteInvalid() { - throw new NotImplementedException(); + var quotes = await getAllQuote(); + quotes = quotes.Where(q => q.IsValid == false).ToList(); + return quotes; } public async Task> getSomeQuoteInvalid(int nb, int page) { - throw new NotImplementedException(); + var quotes = await getAllQuoteInvalid(); + if ((page - 1) * nb + nb > quotes.Count()) + { + if (nb > quotes.Count()) + { + return quotes.GetRange(0, quotes.Count()); + } + return quotes.GetRange(quotes.Count() - nb, nb); + } + return quotes.GetRange((page - 1) * nb, nb); } public async Task getNbQuote() @@ -110,5 +123,29 @@ namespace WF_WebAdmin.Service; var data = await getAllQuote(); return data.Count; } + + public async Task> getChar() + { + if (!File.Exists(_char)) + { + Console.Out.WriteLine($"{_char} not found"); + return new List(); + } + + var json = await File.ReadAllTextAsync(_char); + return JsonSerializer.Deserialize>(json) ?? new List(); + } + + public async Task> getSrc() + { + if (!File.Exists(_src)) + { + Console.Out.WriteLine($"{_src} not found"); + return new List(); + } + + var json = await File.ReadAllTextAsync(_src); + return JsonSerializer.Deserialize>(json) ?? new List(); + } } \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Shared/NavMenu.razor b/WF-WebAdmin/WF-WebAdmin/Shared/NavMenu.razor index 5dfc260..83deca9 100644 --- a/WF-WebAdmin/WF-WebAdmin/Shared/NavMenu.razor +++ b/WF-WebAdmin/WF-WebAdmin/Shared/NavMenu.razor @@ -45,7 +45,7 @@ diff --git a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataQuote.json b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataQuote.json index 6d48018..a81ebeb 100644 --- a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataQuote.json +++ b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataQuote.json @@ -3,10 +3,10 @@ "Id": 1, "Content": "Que la force soit avec toi.", "Like": 150, - "Langue": "fr", - "Charac": "test", + "Langue": "en", + "Charac": "Drago Malefoy", "ImgPath": "http://starwars.com", - "TitleSrc": "Star Wars", + "TitleSrc": "L\u00E0-haut", "DateSrc": "2025-01-21T00:00:00", "UserProposition": "user1", "IsValid": false diff --git a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_quiz.json b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_quiz.json index 4569231..ef41eeb 100644 --- a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_quiz.json +++ b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_quiz.json @@ -42,5 +42,38 @@ "CAnswer": "D", "IsValid": false, "UserProposition": "Shields Roth" + }, + { + "Id": 13, + "Question": "test", + "AnswerA": "a", + "AnswerB": "b", + "AnswerC": "c", + "AnswerD": "d", + "CAnswer": "D", + "IsValid": true, + "UserProposition": "Admin" + }, + { + "Id": 14, + "Question": "bonjour", + "AnswerA": "ca", + "AnswerB": "va", + "AnswerC": "marcher", + "AnswerD": "!", + "CAnswer": "A", + "IsValid": true, + "UserProposition": "Admin" + }, + { + "Id": 15, + "Question": "test", + "AnswerA": "a", + "AnswerB": "b", + "AnswerC": "c", + "AnswerD": "d", + "CAnswer": "C", + "IsValid": true, + "UserProposition": "Admin" } ] \ No newline at end of file From b58a71448dc0435195424cd7e166d6299b6baaa1 Mon Sep 17 00:00:00 2001 From: Kevin MONDEJAR Date: Thu, 30 Jan 2025 15:42:59 +0100 Subject: [PATCH 21/79] resolve build problem --- WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor index d0ad051..10ce548 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor @@ -108,7 +108,7 @@ else

@Localizer["UserPopupTitle2"]

- +
From 3a896aa3ce27731fe99bdf638a5857e5dfa05fa2 Mon Sep 17 00:00:00 2001 From: lebeaulato Date: Mon, 3 Feb 2025 13:59:34 +0100 Subject: [PATCH 22/79] Trad AddQuiz et ValidQuote --- WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor | 16 +- .../WF-WebAdmin/Pages/AddQuiz.razor.cs | 5 + .../WF-WebAdmin/Pages/ValidQuote.razor | 22 +-- .../WF-WebAdmin/Pages/ValidQuote.razor.cs | 6 +- .../Resources/Pages.AddQuiz.en-US.resx | 144 +++++++++++++++++ .../Resources/Pages.AddQuiz.fr-FR.resx | 144 +++++++++++++++++ .../Resources/Pages.ValidQuote.en-US.resx | 153 ++++++++++++++++++ .../Resources/Pages.ValidQuote.fr-FR.resx | 153 ++++++++++++++++++ 8 files changed, 623 insertions(+), 20 deletions(-) create mode 100644 WF-WebAdmin/WF-WebAdmin/Resources/Pages.AddQuiz.en-US.resx create mode 100644 WF-WebAdmin/WF-WebAdmin/Resources/Pages.AddQuiz.fr-FR.resx create mode 100644 WF-WebAdmin/WF-WebAdmin/Resources/Pages.ValidQuote.en-US.resx create mode 100644 WF-WebAdmin/WF-WebAdmin/Resources/Pages.ValidQuote.fr-FR.resx diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor b/WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor index d577939..5505f94 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor @@ -2,7 +2,7 @@ @page "/add" -

Ajouter une Question

+

@Localizer["TitleAddQuiz"]

@@ -11,42 +11,42 @@

- +
\ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor.cs index 36de693..ff10734 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/AddQuiz.razor.cs @@ -3,12 +3,17 @@ using WF_WebAdmin.Service; using WF_WebAdmin.Model; using Microsoft.AspNetCore.Mvc; using System.Text.RegularExpressions; +using Microsoft.Extensions.Localization; namespace WF_WebAdmin.Pages { public partial class AddQuiz { + + [Inject] + public IStringLocalizer Localizer { get; set; } + [Inject] private IQuizService quizService { get; set; } diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuote.razor b/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuote.razor index 0f7606d..962b59a 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuote.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuote.razor @@ -1,11 +1,11 @@ @page "/ValidQuote" @using WF_WebAdmin.Model -

Citations non validées

+

@Localizer["TitleValid"]

@if (quotes is null) { -

Chargement des citations...

+

@Localizer["LoginQuote"]

} @* else if (quotes.Count == 0) { @@ -13,20 +13,20 @@ } *@ else { -

Citations en attente de validation :

+

@Localizer["QuoteValid"]

@foreach (var quote in quotes) {
-

ID : @quote.Id

-

Contenu : @quote.Content

-

Langue : @quote.Langue

+

@Localizer["Id"] : @quote.Id

+

@Localizer["Content"] : @quote.Content

+

@Localizer["Language"] @quote.Langue

-

Personnage : @quote.Charac

-

Image : @quote.ImgPath

-

Source : @quote.TitleSrc

-

Date de source : @quote.DateSrc.ToShortDateString()

-

Utilisateur : @quote.UserProposition

+

@Localizer["Character"] @quote.Charac

+

@Localizer["Image"] @quote.ImgPath

+

@Localizer["Source"] @quote.TitleSrc

+

@Localizer["Date"] @quote.DateSrc.ToShortDateString()

+

@Localizer["User"] @quote.UserProposition

@* *@ diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuote.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuote.razor.cs index 95b04d5..4c9a4b5 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuote.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuote.razor.cs @@ -6,12 +6,16 @@ using System.Collections.Generic; using System; using System.Threading.Tasks; using System.Linq; +using Microsoft.Extensions.Localization; namespace WF_WebAdmin.Pages { public partial class ValidQuote { - private Quote[] quotes; + private Quote[] quotes; + + [Inject] + public IStringLocalizer Localizer { get; set; } [Inject] public HttpClient Http { get; set; } diff --git a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.AddQuiz.en-US.resx b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.AddQuiz.en-US.resx new file mode 100644 index 0000000..e171091 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.AddQuiz.en-US.resx @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Answer A: + + + Answer B: + + + Answer C: + + + Answer D: + + + Good answer: + + + Submit + + + Add a question + + + Question: + + \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.AddQuiz.fr-FR.resx b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.AddQuiz.fr-FR.resx new file mode 100644 index 0000000..092f847 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.AddQuiz.fr-FR.resx @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Réponse A: + + + Réponse B: + + + Réponse C: + + + Réponse D: + + + Bonne réponse: + + + Valider + + + Ajouter une Question + + + Question: + + \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.ValidQuote.en-US.resx b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.ValidQuote.en-US.resx new file mode 100644 index 0000000..2412f03 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.ValidQuote.en-US.resx @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Character : + + + Content : + + + Source date + + + ID : + + + Image : + + + Language : + + + Loading quotes + + + Quotes awaiting validation + + + Source : + + + Unvalidated quotes + + + User : + + \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.ValidQuote.fr-FR.resx b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.ValidQuote.fr-FR.resx new file mode 100644 index 0000000..8dd6b34 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.ValidQuote.fr-FR.resx @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Personnage : + + + Contenu : + + + Date de la source : + + + ID : + + + Image : + + + Langue : + + + Chargement des citations... + + + Citations en attente de validation : + + + Source : + + + Citations non validées + + + Utilisateur : + + \ No newline at end of file From 13f435d606e6c1dcbc5f040e272eb2b199f88139 Mon Sep 17 00:00:00 2001 From: lebeaulato Date: Mon, 3 Feb 2025 14:45:31 +0100 Subject: [PATCH 23/79] fin trad --- WF-WebAdmin/WF-WebAdmin/Pages/ModifQuiz.razor | 50 ++--- .../WF-WebAdmin/Pages/ModifQuiz.razor.cs | 4 + .../WF-WebAdmin/Pages/ModifQuote.razor | 28 +-- .../WF-WebAdmin/Pages/ModifQuote.razor.cs | 4 + WF-WebAdmin/WF-WebAdmin/Pages/ValidQuiz.razor | 22 +-- .../WF-WebAdmin/Pages/ValidQuiz.razor.cs | 7 +- .../WF-WebAdmin/Pages/ValidQuote.razor | 4 +- .../Resources/Pages.ModifQuiz.en-US.resx | 171 ++++++++++++++++++ .../Resources/Pages.ModifQuiz.fr-FR.resx | 171 ++++++++++++++++++ .../Resources/Pages.ModifQuote.en-US.resx | 159 ++++++++++++++++ .../Resources/Pages.ModifQuote.fr-FR.resx | 159 ++++++++++++++++ .../Resources/Pages.ValidQuiz.en-US.resx | 153 ++++++++++++++++ .../Resources/Pages.ValidQuiz.fr-FR.resx | 153 ++++++++++++++++ .../WF-WebAdmin/wwwroot/fake_data_quiz.json | 13 +- 14 files changed, 1032 insertions(+), 66 deletions(-) create mode 100644 WF-WebAdmin/WF-WebAdmin/Resources/Pages.ModifQuiz.en-US.resx create mode 100644 WF-WebAdmin/WF-WebAdmin/Resources/Pages.ModifQuiz.fr-FR.resx create mode 100644 WF-WebAdmin/WF-WebAdmin/Resources/Pages.ModifQuote.en-US.resx create mode 100644 WF-WebAdmin/WF-WebAdmin/Resources/Pages.ModifQuote.fr-FR.resx create mode 100644 WF-WebAdmin/WF-WebAdmin/Resources/Pages.ValidQuiz.en-US.resx create mode 100644 WF-WebAdmin/WF-WebAdmin/Resources/Pages.ValidQuiz.fr-FR.resx diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuiz.razor b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuiz.razor index 60d2264..d1b1829 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuiz.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuiz.razor @@ -1,13 +1,13 @@ @using WF_WebAdmin.Model @page "/modifquiz" -Gestion des question +@Localizer["TitlePage"] -

Gestion des quiz

+

@Localizer["TitlePage"]

- Ajouter + @Localizer["Add"]
@@ -19,17 +19,17 @@ ShowPager Responsive> - - - - - - - - + + + + + + + + - - + + @@ -38,21 +38,21 @@ {
-

Modifier les informations de l'utilisateur :

- +

@Localizer["ModifInfoUser"]

+ - + - + - + - + - + - - + +
} @@ -61,9 +61,9 @@ {
-

Êtes-vous sûr de vouloir supprimer ce quiz ?

- - +

@Localizer["PopupQuestion"]

+ +
} \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuiz.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuiz.razor.cs index 9da2e68..6ba0d53 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuiz.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuiz.razor.cs @@ -1,5 +1,6 @@ using Blazorise.DataGrid; using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.Localization; using WF_WebAdmin.Model; using WF_WebAdmin.Service; @@ -21,6 +22,9 @@ namespace WF_WebAdmin.Pages private int page = 1; + [Inject] + public IStringLocalizer Localizer { get; set; } + [Inject] public IQuizService QuizService { get; set; } diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor index a04a0fd..c9acc83 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor @@ -1,9 +1,9 @@ @using WF_WebAdmin.Model @page "/modifquote" -Corection des citation +@Localizer["TitlePage"] -

Correction des citations

+

@Localizer["TitlePage"]

- - - - - - - + + + + + + + @* *@ - Editer - + @Localizer["Edit"] + @@ -50,9 +50,9 @@ {
-

Êtes-vous sûr de vouloir supprimer cette citation ?

- - +

@Localizer["PopupQuestion"]

+ +
} \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs index d010106..8bf4ed1 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ModifQuote.razor.cs @@ -1,5 +1,6 @@ using Blazorise.DataGrid; using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.Localization; using WF_WebAdmin.Model; using WF_WebAdmin.Service; @@ -21,6 +22,9 @@ namespace WF_WebAdmin.Pages private int page = 1; + [Inject] + public IStringLocalizer Localizer { get; set; } + [Inject] public IQuoteService QuoteService { get; set; } diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuiz.razor b/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuiz.razor index db4c5ef..3640318 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuiz.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuiz.razor @@ -2,28 +2,28 @@ @using System.Dynamic @using WF_WebAdmin.Model -

Quiz à valider

+

@Localizer["TitleQuiz"]

@if (quizzes == null) { -

Chargement des quiz ...

+

@Localizer["LoadQuiz"]

} else { -

Quizs en attente de validation :

+

@Localizer["QuizAwait"]

- - - - - - - - + + + + + + + + diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuiz.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuiz.razor.cs index 2c2beec..6239fdd 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuiz.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuiz.razor.cs @@ -1,5 +1,6 @@ using Blazorise.DataGrid; using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.Localization; using WF_WebAdmin.Model; using WF_WebAdmin.Service; @@ -7,8 +8,10 @@ namespace WF_WebAdmin.Pages { public partial class ValidQuiz { - private List quizzes; - + private List quizzes; + + [Inject] + public IStringLocalizer Localizer { get; set; } [Inject] public HttpClient Http { get; set; } diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuote.razor b/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuote.razor index 962b59a..7ddd1ae 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuote.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuote.razor @@ -18,8 +18,8 @@ else @foreach (var quote in quotes) {
-

@Localizer["Id"] : @quote.Id

-

@Localizer["Content"] : @quote.Content

+

@Localizer["Id"] @quote.Id

+

@Localizer["Content"] @quote.Content

@Localizer["Language"] @quote.Langue

@Localizer["Character"] @quote.Charac

diff --git a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.ModifQuiz.en-US.resx b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.ModifQuiz.en-US.resx new file mode 100644 index 0000000..fe93fab --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.ModifQuiz.en-US.resx @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Action + + + Add + + + Answer A + + + Answer B + + + Answer C + + + Answer D + + + Cancel + + + Cancel + + + Edit + + + Good Answer + + + ID + + + Edit user information : + + + Are you sure you want to delete this quiz ? + + + Question + + + Save + + + Quiz Management + + + Confirm + + \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.ModifQuiz.fr-FR.resx b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.ModifQuiz.fr-FR.resx new file mode 100644 index 0000000..1d19f68 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.ModifQuiz.fr-FR.resx @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Action + + + Ajouter + + + Réponse A + + + Réponse B + + + Réponse C + + + Réponse D + + + Annuler + + + Supprimer + + + Editer + + + Bonne réponse + + + ID + + + Modifier les informations de l'utilisateur : + + + Êtes-vous sûr de vouloir supprimer ce quiz ? + + + Question + + + Sauvegarder + + + Gestion des quiz + + + Confirmer + + \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.ModifQuote.en-US.resx b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.ModifQuote.en-US.resx new file mode 100644 index 0000000..9cbae8a --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.ModifQuote.en-US.resx @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Action + + + Cancel + + + Character + + + Date + + + Delete + + + Edit + + + Id + + + Language + + + Are you sure you want to delete this quote ? + + + Quote + + + Source + + + Corrections of quotes + + + Confirm + + \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.ModifQuote.fr-FR.resx b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.ModifQuote.fr-FR.resx new file mode 100644 index 0000000..565aca8 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.ModifQuote.fr-FR.resx @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Action + + + Annuler + + + Personage + + + Date + + + Supprimer + + + Editer + + + Id + + + Langue + + + Êtes-vous sûr de vouloir supprimer cette citation ? + + + Citation + + + Source + + + Correction des citations + + + Confirmer + + \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.ValidQuiz.en-US.resx b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.ValidQuiz.en-US.resx new file mode 100644 index 0000000..9766936 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.ValidQuiz.en-US.resx @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Actions + + + Answer A + + + Answer B + + + Answer C + + + Answer D + + + Correct answer + + + Loading quizzes + + + Question + + + Quiz awaiting validation + + + Quiz to validate + + + User + + \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/Resources/Pages.ValidQuiz.fr-FR.resx b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.ValidQuiz.fr-FR.resx new file mode 100644 index 0000000..aacbae4 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Resources/Pages.ValidQuiz.fr-FR.resx @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Actions + + + Réponse A + + + Réponse B + + + Réponse C + + + Réponse D + + + Réponse Correcte + + + Chargement des quiz ... + + + Question + + + Quizs en attente de validation : + + + Quiz à valider + + + Utilisateur + + \ No newline at end of file diff --git a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_quiz.json b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_quiz.json index ef41eeb..862d16b 100644 --- a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_quiz.json +++ b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake_data_quiz.json @@ -1,15 +1,4 @@ [ - { - "Id": 9, - "Question": "Question_quiz_1", - "AnswerA": "rep_1", - "AnswerB": "rep_2", - "AnswerC": "rep_3", - "AnswerD": "rep_3", - "CAnswer": "A", - "IsValid": false, - "UserProposition": "Earnestine Poole" - }, { "Id": 10, "Question": "Voluptate pariatur ipsum magna sint Lorem adipisicing.", @@ -34,7 +23,7 @@ }, { "Id": 12, - "Question": "Irure occaecat sit laborum nulla ea dolore et aliqua sunt Lorem enim esse.", + "Question": "Irure occaecat sit laborum nul ea dolore et aliqua sunt Lorem enim esse.", "AnswerA": "excepteur occaecat", "AnswerB": "pariatur in", "AnswerC": "reprehenderit excepteur", From bb660e1ff89f4df6737af3cf4d975249b6d2820b Mon Sep 17 00:00:00 2001 From: Leni BEAULATON Date: Mon, 3 Feb 2025 14:50:28 +0100 Subject: [PATCH 24/79] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'README.md'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 50fc366..e7d6506 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ L'application devrait se lancer automatiquement dans votre navigateur par défau 🟨 Composant complexe (5 point)
🟨 Use API (Get / Insert / Update / Delete) (3 point)
❌ Utilisation IOC & DI (4 point)
-🟨 Localisation & Globalisation (au moins deux langues) (1 point)
+✅ Localisation & Globalisation (au moins deux langues) (1 point)
❌ Utilisation de la configuration (1 point)
🟨 Logs (2 point)
❌ Propreté du code (Vous pouvez vous servir de sonarqube) (2 point)
From c11f07171459ca328492011853d2d07abbdca073 Mon Sep 17 00:00:00 2001 From: Leni BEAULATON Date: Mon, 3 Feb 2025 14:51:23 +0100 Subject: [PATCH 25/79] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'README.md'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e7d6506..05159a8 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,6 @@ L'application devrait se lancer automatiquement dans votre navigateur par défau ✅ Emplacement du code (Pas de code dans les vues) (2 point)
# Documentation (10 points) -🟨Le Readme (2 points)
+✅Le Readme (2 points)
❌Description du fonctionnement de la solution client (illustrutration au niveau du code) (6 points)
✅Merge request (2 points)
From 92104077571a53df937d0a0bf5ae2c398a8b1d39 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 10:19:52 +0100 Subject: [PATCH 26/79] test CI --- .drone.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..c31fa77 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,21 @@ +kind: pipeline +type: docker +name: deploy + +steps: + - name: Pull, tag and push existing Docker image + image: docker + environment: + DOCKER_USERNAME: + from_secret: docker_username + DOCKER_PASSWORD: + from_secret: docker_password + commands: + - docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD hub.codefirst.iut.uca.fr + - docker pull hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dotnet7-maui:latest + - docker tag hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dotnet7-maui:latest hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dotnet7-maui:deploy + - docker push hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dotnet7-maui:deploy + +trigger: + branch: + - main From f75579fe9926df3cd02aff641c9582da0df15be4 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 10:24:33 +0100 Subject: [PATCH 27/79] test CI 2 --- .drone.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.drone.yml b/.drone.yml index c31fa77..0d42970 100644 --- a/.drone.yml +++ b/.drone.yml @@ -19,3 +19,5 @@ steps: trigger: branch: - main + event: + - push From 9603dbbb53c66ea826263663e2173374a5b9b728 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 10:30:14 +0100 Subject: [PATCH 28/79] test CI 3 --- .drone.yml | 59 +++++++++++++++++++++++++++++++++-------------- Docker/Dockerfile | 17 ++++++++++++++ 2 files changed, 59 insertions(+), 17 deletions(-) create mode 100644 Docker/Dockerfile diff --git a/.drone.yml b/.drone.yml index 0d42970..4e44234 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,23 +1,48 @@ kind: pipeline type: docker -name: deploy - -steps: - - name: Pull, tag and push existing Docker image - image: docker - environment: - DOCKER_USERNAME: - from_secret: docker_username - DOCKER_PASSWORD: - from_secret: docker_password - commands: - - docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD hub.codefirst.iut.uca.fr - - docker pull hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dotnet7-maui:latest - - docker tag hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dotnet7-maui:latest hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dotnet7-maui:deploy - - docker push hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dotnet7-maui:deploy +name: CI trigger: - branch: - - main event: - push + +steps: + - name: build + image: mcr.microsoft.com/dotnet/sdk:7.0 + commands: + - cd Sources/ + - dotnet restore MySolution.sln + - dotnet build MySolution.sln -c Release --no-restore + - dotnet publish WF-WebAdmin/WF-WebAdmin.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/publish + + - name: tests + image: mcr.microsoft.com/dotnet/sdk:7.0 + commands: + - cd Sources/ + - dotnet restore MySolution.sln + - dotnet test MySolution.sln --no-restore + depends_on: [build] + + - name: analyze + image: mcr.microsoft.com/dotnet/sdk:7.0 + commands: + - cd Sources/ + # Lancer l'analyse statique en forçant l'exécution des analyzers + - dotnet build MySolution.sln -c Release --no-restore /p:RunAnalyzers=true + depends_on: [build] + + - name: docker_build + image: plugins/docker + settings: + # Nom de l'image Docker qui hébergera votre application Blazor + repo: hub.codefirst.iut.uca.fr/marc.chevaldonne/your-blazor-app + # Dockerfile pour construire l'image (placé à la racine de votre dépôt) + dockerfile: Dockerfile + tags: + - latest + # Secrets pour l'authentification sur votre registry (à configurer dans Drone) + username: + from_secret: docker_username + password: + from_secret: docker_password + depends_on: [build, tests, analyze] diff --git a/Docker/Dockerfile b/Docker/Dockerfile new file mode 100644 index 0000000..8b30a39 --- /dev/null +++ b/Docker/Dockerfile @@ -0,0 +1,17 @@ +# Étape de base avec l'image runtime ASP.NET +FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base +WORKDIR /app +EXPOSE 80 + +# Étape de build pour publier l'application +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +WORKDIR /src +COPY . . +RUN dotnet restore "YourBlazorApp/YourBlazorApp.csproj" +RUN dotnet publish "YourBlazorApp/YourBlazorApp.csproj" -c Release -o /app/publish + +# Étape finale : copie des fichiers publiés et définition du point d'entrée +FROM base AS final +WORKDIR /app +COPY --from=build /app/publish . +ENTRYPOINT ["dotnet", "YourBlazorApp.dll"] From cf739c6b2eae03a2db82b7b4a615fbba4d919978 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 10:31:51 +0100 Subject: [PATCH 29/79] test CI 4 --- .drone.yml | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/.drone.yml b/.drone.yml index 4e44234..92530f9 100644 --- a/.drone.yml +++ b/.drone.yml @@ -8,39 +8,43 @@ trigger: steps: - name: build - image: mcr.microsoft.com/dotnet/sdk:7.0 + image: mcr.microsoft.com/dotnet/sdk:6.0 commands: - - cd Sources/ - - dotnet restore MySolution.sln - - dotnet build MySolution.sln -c Release --no-restore - - dotnet publish WF-WebAdmin/WF-WebAdmin.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/publish + # On se positionne dans le dossier du projet + - cd WF-WebAdmin/WF-WebAdmin + # Restauration des dépendances + - dotnet restore WF-WebAdmin.csproj + # Compilation en mode Release + - dotnet build WF-WebAdmin.csproj -c Release --no-restore + # Publication de l'application dans le dossier build/publish du workspace + - dotnet publish WF-WebAdmin.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/publish - name: tests - image: mcr.microsoft.com/dotnet/sdk:7.0 + image: mcr.microsoft.com/dotnet/sdk:6.0 commands: - - cd Sources/ - - dotnet restore MySolution.sln - - dotnet test MySolution.sln --no-restore + - cd WF-WebAdmin/WF-WebAdmin + - dotnet restore WF-WebAdmin.csproj + - dotnet test WF-WebAdmin.csproj --no-restore depends_on: [build] - name: analyze - image: mcr.microsoft.com/dotnet/sdk:7.0 + image: mcr.microsoft.com/dotnet/sdk:6.0 commands: - - cd Sources/ - # Lancer l'analyse statique en forçant l'exécution des analyzers - - dotnet build MySolution.sln -c Release --no-restore /p:RunAnalyzers=true + - cd WF-WebAdmin/WF-WebAdmin + # Lancer la build avec les analyzers pour détecter d'éventuelles alertes + - dotnet build WF-WebAdmin.csproj -c Release --no-restore /p:RunAnalyzers=true depends_on: [build] - name: docker_build image: plugins/docker settings: - # Nom de l'image Docker qui hébergera votre application Blazor - repo: hub.codefirst.iut.uca.fr/marc.chevaldonne/your-blazor-app - # Dockerfile pour construire l'image (placé à la racine de votre dépôt) - dockerfile: Dockerfile + # Nom complet de l'image à pousser (à adapter si besoin) + repo: hub.codefirst.iut.uca.fr/marc.chevaldonne/wf-webadmin + # Chemin vers votre Dockerfile dans le dossier Docker + dockerfile: Docker/Dockerfile tags: - latest - # Secrets pour l'authentification sur votre registry (à configurer dans Drone) + # Les identifiants pour votre registry doivent être définis dans Drone en tant que secrets username: from_secret: docker_username password: From 050fdcff630539991c0716188c0127a418a273cf Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 10:33:42 +0100 Subject: [PATCH 30/79] test CI 5 --- .drone.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 92530f9..54bbdce 100644 --- a/.drone.yml +++ b/.drone.yml @@ -31,10 +31,11 @@ steps: image: mcr.microsoft.com/dotnet/sdk:6.0 commands: - cd WF-WebAdmin/WF-WebAdmin - # Lancer la build avec les analyzers pour détecter d'éventuelles alertes - - dotnet build WF-WebAdmin.csproj -c Release --no-restore /p:RunAnalyzers=true + - dotnet restore WF-WebAdmin.csproj + - dotnet build WF-WebAdmin.csproj -c Release /p:RunAnalyzers=true depends_on: [build] + - name: docker_build image: plugins/docker settings: From 09552612b659d2d05026360d6d3b981ec114eb70 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 10:35:42 +0100 Subject: [PATCH 31/79] test CI 6 --- .drone.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index 54bbdce..e9974ef 100644 --- a/.drone.yml +++ b/.drone.yml @@ -39,15 +39,14 @@ steps: - name: docker_build image: plugins/docker settings: - # Nom complet de l'image à pousser (à adapter si besoin) repo: hub.codefirst.iut.uca.fr/marc.chevaldonne/wf-webadmin - # Chemin vers votre Dockerfile dans le dossier Docker + registry: hub.codefirst.iut.uca.fr # Spécifie explicitement le registry à utiliser dockerfile: Docker/Dockerfile tags: - latest - # Les identifiants pour votre registry doivent être définis dans Drone en tant que secrets username: from_secret: docker_username password: from_secret: docker_password depends_on: [build, tests, analyze] + From 193556acdb2c629050822fdafecb97c1e2a4feea Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 10:36:48 +0100 Subject: [PATCH 32/79] test CI 7 --- Docker/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 8b30a39..f8ce4b8 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -7,11 +7,11 @@ EXPOSE 80 FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build WORKDIR /src COPY . . -RUN dotnet restore "YourBlazorApp/YourBlazorApp.csproj" -RUN dotnet publish "YourBlazorApp/YourBlazorApp.csproj" -c Release -o /app/publish +RUN dotnet restore "WF-WebAdmin/WF-WebAdmin.csproj" +RUN dotnet publish "WF-WebAdmin/WF-WebAdmin.csproj" -c Release -o /app/publish # Étape finale : copie des fichiers publiés et définition du point d'entrée FROM base AS final WORKDIR /app COPY --from=build /app/publish . -ENTRYPOINT ["dotnet", "YourBlazorApp.dll"] +ENTRYPOINT ["dotnet", "WF-WebAdmin.dll"] From 9d64672696bdffdc65e183ce68285474c58cc77d Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 10:38:27 +0100 Subject: [PATCH 33/79] test CI 8 --- Docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Docker/Dockerfile b/Docker/Dockerfile index f8ce4b8..69c0975 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -7,8 +7,8 @@ EXPOSE 80 FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build WORKDIR /src COPY . . -RUN dotnet restore "WF-WebAdmin/WF-WebAdmin.csproj" -RUN dotnet publish "WF-WebAdmin/WF-WebAdmin.csproj" -c Release -o /app/publish +RUN dotnet restore "WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj" +RUN dotnet publish "WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj" -c Release -o /app/publish # Étape finale : copie des fichiers publiés et définition du point d'entrée FROM base AS final From 56d6cac2e24d95ba903c5d022523e509fe39d584 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 10:40:58 +0100 Subject: [PATCH 34/79] test CI 9 --- .drone.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index e9974ef..3f73c30 100644 --- a/.drone.yml +++ b/.drone.yml @@ -40,7 +40,7 @@ steps: image: plugins/docker settings: repo: hub.codefirst.iut.uca.fr/marc.chevaldonne/wf-webadmin - registry: hub.codefirst.iut.uca.fr # Spécifie explicitement le registry à utiliser + registry: hub.codefirst.iut.uca.fr # S'assure que le push se fait vers le bon registry dockerfile: Docker/Dockerfile tags: - latest @@ -50,3 +50,4 @@ steps: from_secret: docker_password depends_on: [build, tests, analyze] + From f71147c972a3b1ecc20490aeff6543cae2b4ebab Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 10:43:50 +0100 Subject: [PATCH 35/79] test CI 10 --- .drone.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.drone.yml b/.drone.yml index 3f73c30..561b983 100644 --- a/.drone.yml +++ b/.drone.yml @@ -8,7 +8,7 @@ trigger: steps: - name: build - image: mcr.microsoft.com/dotnet/sdk:6.0 + image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 commands: # On se positionne dans le dossier du projet - cd WF-WebAdmin/WF-WebAdmin @@ -20,7 +20,7 @@ steps: - dotnet publish WF-WebAdmin.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/publish - name: tests - image: mcr.microsoft.com/dotnet/sdk:6.0 + image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 commands: - cd WF-WebAdmin/WF-WebAdmin - dotnet restore WF-WebAdmin.csproj @@ -28,7 +28,7 @@ steps: depends_on: [build] - name: analyze - image: mcr.microsoft.com/dotnet/sdk:6.0 + image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 commands: - cd WF-WebAdmin/WF-WebAdmin - dotnet restore WF-WebAdmin.csproj @@ -39,8 +39,8 @@ steps: - name: docker_build image: plugins/docker settings: - repo: hub.codefirst.iut.uca.fr/marc.chevaldonne/wf-webadmin - registry: hub.codefirst.iut.uca.fr # S'assure que le push se fait vers le bon registry + repo: hub.codefirst.iut.uca.fr/WhatTheFantasy/WF-WebAdmin + registry: hub.codefirst.iut.uca.fr dockerfile: Docker/Dockerfile tags: - latest From bd925d84643e00a4c1db141e44734d8efe724102 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 10:44:55 +0100 Subject: [PATCH 36/79] test CI 10 --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 561b983..fa0f6e8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -39,7 +39,7 @@ steps: - name: docker_build image: plugins/docker settings: - repo: hub.codefirst.iut.uca.fr/WhatTheFantasy/WF-WebAdmin + repo: hub.codefirst.iut.uca.fr/whatthefantasy/wf-webadmin registry: hub.codefirst.iut.uca.fr dockerfile: Docker/Dockerfile tags: From f0dce9458de456bca42478a53d4278df0bfb9a16 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 10:56:16 +0100 Subject: [PATCH 37/79] test CI 12 --- .drone.yml | 69 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 20 deletions(-) diff --git a/.drone.yml b/.drone.yml index fa0f6e8..4eb8bd5 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,44 +3,75 @@ type: docker name: CI trigger: + branch: + - master event: - push steps: + # 1) Build - name: build image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 commands: - # On se positionne dans le dossier du projet - - cd WF-WebAdmin/WF-WebAdmin - # Restauration des dépendances - - dotnet restore WF-WebAdmin.csproj - # Compilation en mode Release - - dotnet build WF-WebAdmin.csproj -c Release --no-restore - # Publication de l'application dans le dossier build/publish du workspace - - dotnet publish WF-WebAdmin.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/publish + # Restaurer les dépendances + - dotnet restore WF-WebAdmin.sln + # Compiler en mode Release (sans refaire la restore) + - dotnet build WF-WebAdmin.sln -c Release --no-restore + # 2) Tests - name: tests image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 commands: - - cd WF-WebAdmin/WF-WebAdmin - - dotnet restore WF-WebAdmin.csproj - - dotnet test WF-WebAdmin.csproj --no-restore + - dotnet restore WF-WebAdmin.sln + - dotnet test WF-WebAdmin.sln --no-restore depends_on: [build] - - name: analyze + # 3) Analyse Sonar + Couverture + - name: code-inspection image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 + secrets: [ sonar_token ] + environment: + sonar_host: https://codefirst.iut.uca.fr/sonar/ + sonar_token: + from_secret: sonar_token + project_key: wf-webadmin # Clé projet Sonar, adaptez si besoin + coverage_exclusions: 'UnitTesting/**' # Exclusions de couverture, ajustez selon vos besoins commands: - - cd WF-WebAdmin/WF-WebAdmin - - dotnet restore WF-WebAdmin.csproj - - dotnet build WF-WebAdmin.csproj -c Release /p:RunAnalyzers=true - depends_on: [build] + # Restauration + - dotnet restore WF-WebAdmin.sln + + # Début de l'analyse Sonar + - dotnet sonarscanner begin /k:$${project_key} \ + /d:sonar.host.url=$${sonar_host} \ + /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" \ + /d:sonar.coverage.exclusions=$${coverage_exclusions} \ + /d:sonar.login=$${sonar_token} + + # Compilation + - dotnet build WF-WebAdmin.sln -c Release --no-restore + + # Test avec génération de couverture + - dotnet test WF-WebAdmin.sln --logger trx --no-restore \ + /p:CollectCoverage=true \ + /p:CoverletOutputFormat=cobertura \ + --collect "XPlat Code Coverage" + # Génération du rapport compatible SonarQube + - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" + # Publication (optionnelle) en Release, si besoin pour valider le build final + - dotnet publish WF-WebAdmin.sln -c Release --no-restore -o $CI_PROJECT_DIR/build/release + + # Fin de l'analyse Sonar + - dotnet sonarscanner end /d:sonar.login=$${sonar_token} + depends_on: [build, tests] + + # 4) Construction et push de l'image Docker - name: docker_build image: plugins/docker settings: repo: hub.codefirst.iut.uca.fr/whatthefantasy/wf-webadmin - registry: hub.codefirst.iut.uca.fr + registry: hub.codefirst.iut.uca.fr dockerfile: Docker/Dockerfile tags: - latest @@ -48,6 +79,4 @@ steps: from_secret: docker_username password: from_secret: docker_password - depends_on: [build, tests, analyze] - - + depends_on: [build, tests, code-inspection] From 321dc6feb534a3573ad07ea2c7ba6d2c3353b2d7 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 10:57:04 +0100 Subject: [PATCH 38/79] test CI 13 --- .drone.yml | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/.drone.yml b/.drone.yml index 4eb8bd5..e7be69e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,30 +3,30 @@ type: docker name: CI trigger: - branch: - - master event: - push steps: - # 1) Build - name: build image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 commands: - # Restaurer les dépendances - - dotnet restore WF-WebAdmin.sln - # Compiler en mode Release (sans refaire la restore) - - dotnet build WF-WebAdmin.sln -c Release --no-restore + # On se positionne dans le dossier du projet + - cd WF-WebAdmin/WF-WebAdmin + # Restauration des dépendances + - dotnet restore WF-WebAdmin.csproj + # Compilation en mode Release + - dotnet build WF-WebAdmin.csproj -c Release --no-restore + # Publication de l'application dans le dossier build/publish du workspace + - dotnet publish WF-WebAdmin.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/publish - # 2) Tests - name: tests image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 commands: - - dotnet restore WF-WebAdmin.sln - - dotnet test WF-WebAdmin.sln --no-restore + - cd WF-WebAdmin/WF-WebAdmin + - dotnet restore WF-WebAdmin.csproj + - dotnet test WF-WebAdmin.csproj --no-restore depends_on: [build] - # 3) Analyse Sonar + Couverture - name: code-inspection image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 secrets: [ sonar_token ] @@ -66,12 +66,12 @@ steps: - dotnet sonarscanner end /d:sonar.login=$${sonar_token} depends_on: [build, tests] - # 4) Construction et push de l'image Docker + - name: docker_build image: plugins/docker settings: repo: hub.codefirst.iut.uca.fr/whatthefantasy/wf-webadmin - registry: hub.codefirst.iut.uca.fr + registry: hub.codefirst.iut.uca.fr dockerfile: Docker/Dockerfile tags: - latest @@ -79,4 +79,6 @@ steps: from_secret: docker_username password: from_secret: docker_password - depends_on: [build, tests, code-inspection] + depends_on: [build, tests, analyze] + + From 21a6ba117921f7aa0c7b8c2faeef02ed4ce1f835 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 10:57:37 +0100 Subject: [PATCH 39/79] retour a une version valable --- .drone.yml | 41 +++++------------------------------------ 1 file changed, 5 insertions(+), 36 deletions(-) diff --git a/.drone.yml b/.drone.yml index e7be69e..fa0f6e8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -27,44 +27,13 @@ steps: - dotnet test WF-WebAdmin.csproj --no-restore depends_on: [build] - - name: code-inspection + - name: analyze image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 - secrets: [ sonar_token ] - environment: - sonar_host: https://codefirst.iut.uca.fr/sonar/ - sonar_token: - from_secret: sonar_token - project_key: wf-webadmin # Clé projet Sonar, adaptez si besoin - coverage_exclusions: 'UnitTesting/**' # Exclusions de couverture, ajustez selon vos besoins commands: - # Restauration - - dotnet restore WF-WebAdmin.sln - - # Début de l'analyse Sonar - - dotnet sonarscanner begin /k:$${project_key} \ - /d:sonar.host.url=$${sonar_host} \ - /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" \ - /d:sonar.coverage.exclusions=$${coverage_exclusions} \ - /d:sonar.login=$${sonar_token} - - # Compilation - - dotnet build WF-WebAdmin.sln -c Release --no-restore - - # Test avec génération de couverture - - dotnet test WF-WebAdmin.sln --logger trx --no-restore \ - /p:CollectCoverage=true \ - /p:CoverletOutputFormat=cobertura \ - --collect "XPlat Code Coverage" - - # Génération du rapport compatible SonarQube - - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" - - # Publication (optionnelle) en Release, si besoin pour valider le build final - - dotnet publish WF-WebAdmin.sln -c Release --no-restore -o $CI_PROJECT_DIR/build/release - - # Fin de l'analyse Sonar - - dotnet sonarscanner end /d:sonar.login=$${sonar_token} - depends_on: [build, tests] + - cd WF-WebAdmin/WF-WebAdmin + - dotnet restore WF-WebAdmin.csproj + - dotnet build WF-WebAdmin.csproj -c Release /p:RunAnalyzers=true + depends_on: [build] - name: docker_build From c31576b3cc39e3cd7478cf6cb06985c60a9c8d73 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 11:03:00 +0100 Subject: [PATCH 40/79] retour a une version valable --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index fa0f6e8..62e26f3 100644 --- a/.drone.yml +++ b/.drone.yml @@ -37,7 +37,7 @@ steps: - name: docker_build - image: plugins/docker + image: plugins/docker settings: repo: hub.codefirst.iut.uca.fr/whatthefantasy/wf-webadmin registry: hub.codefirst.iut.uca.fr From 18a4bfd070118fc283d85496074d59f7e3111e31 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 11:05:55 +0100 Subject: [PATCH 41/79] Test CI --- .drone.yml | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/.drone.yml b/.drone.yml index 62e26f3..49d5747 100644 --- a/.drone.yml +++ b/.drone.yml @@ -27,14 +27,23 @@ steps: - dotnet test WF-WebAdmin.csproj --no-restore depends_on: [build] - - name: analyze - image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 + - name: code-inspection + image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dronesonarplugin-dotnet6 + secrets: [ sonar_token ] + environment: + sonar_host: https://codefirst.iut.uca.fr/sonar/ + sonar_token: + from_secret: sonar_token + project_key: S201 + coverage_exclusions: 'UnitTesting/**' commands: - - cd WF-WebAdmin/WF-WebAdmin - - dotnet restore WF-WebAdmin.csproj - - dotnet build WF-WebAdmin.csproj -c Release /p:RunAnalyzers=true - depends_on: [build] - + - dotnet restore DamesWithoutMAUI.sln + - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions=$${coverage_exclusions} /d:sonar.login=$${sonar_token} + - dotnet build DamesWithoutMAUI.sln -c Release --no-restore + - dotnet test DamesWithoutMAUI.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" + - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" + - dotnet publish DamesWithoutMAUI.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release + - dotnet sonarscanner end /d:sonar.login=$${sonar_token} - name: docker_build image: plugins/docker From daa004e9b2d39a9c574736fb4eb8d5d8601ca949 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 11:06:51 +0100 Subject: [PATCH 42/79] Test CI 2 --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 49d5747..ce65899 100644 --- a/.drone.yml +++ b/.drone.yml @@ -57,6 +57,6 @@ steps: from_secret: docker_username password: from_secret: docker_password - depends_on: [build, tests, analyze] + depends_on: [build, tests, code-inspection] From 24daff406cf8d7cf6b5d33fafff7324fb9938e77 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 11:07:49 +0100 Subject: [PATCH 43/79] Test CI 3 --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index ce65899..094c50c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -28,7 +28,7 @@ steps: depends_on: [build] - name: code-inspection - image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dronesonarplugin-dotnet6 + image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 secrets: [ sonar_token ] environment: sonar_host: https://codefirst.iut.uca.fr/sonar/ From d4dc0ce2e627e53ec18bbda4026ffb901d50af56 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 11:09:00 +0100 Subject: [PATCH 44/79] Test CI 4 --- .drone.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.drone.yml b/.drone.yml index 094c50c..ce2323c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -37,12 +37,13 @@ steps: project_key: S201 coverage_exclusions: 'UnitTesting/**' commands: - - dotnet restore DamesWithoutMAUI.sln - - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions=$${coverage_exclusions} /d:sonar.login=$${sonar_token} - - dotnet build DamesWithoutMAUI.sln -c Release --no-restore - - dotnet test DamesWithoutMAUI.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" + - cd WF-WebAdmin/WF-WebAdmin + - dotnet restore WF-WebAdmin.csproj + - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions=$${coverage_exclusions} /d:sonar.login=$${sonar_token} + - dotnet build WF-WebAdmin.csproj -c Release --no-restore + - dotnet test WF-WebAdmin.csproj --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" - - dotnet publish DamesWithoutMAUI.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release + - dotnet publish WF-WebAdmin.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/publish - dotnet sonarscanner end /d:sonar.login=$${sonar_token} - name: docker_build From 4be7866a60b0736c8c2702d5f094f585b82ab7d0 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 11:10:39 +0100 Subject: [PATCH 45/79] Test CI 5 --- .drone.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.drone.yml b/.drone.yml index ce2323c..e611651 100644 --- a/.drone.yml +++ b/.drone.yml @@ -10,13 +10,9 @@ steps: - name: build image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 commands: - # On se positionne dans le dossier du projet - cd WF-WebAdmin/WF-WebAdmin - # Restauration des dépendances - dotnet restore WF-WebAdmin.csproj - # Compilation en mode Release - dotnet build WF-WebAdmin.csproj -c Release --no-restore - # Publication de l'application dans le dossier build/publish du workspace - dotnet publish WF-WebAdmin.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/publish - name: tests @@ -42,6 +38,7 @@ steps: - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions=$${coverage_exclusions} /d:sonar.login=$${sonar_token} - dotnet build WF-WebAdmin.csproj -c Release --no-restore - dotnet test WF-WebAdmin.csproj --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" + - ls -R - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" - dotnet publish WF-WebAdmin.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/publish - dotnet sonarscanner end /d:sonar.login=$${sonar_token} @@ -59,5 +56,3 @@ steps: password: from_secret: docker_password depends_on: [build, tests, code-inspection] - - From c4a7ae258a6061e7bac9be096867315b92f9d6fb Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 11:13:52 +0100 Subject: [PATCH 46/79] Test CI 6 --- .drone.yml | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index e611651..61a5bdb 100644 --- a/.drone.yml +++ b/.drone.yml @@ -35,14 +35,38 @@ steps: commands: - cd WF-WebAdmin/WF-WebAdmin - dotnet restore WF-WebAdmin.csproj - - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions=$${coverage_exclusions} /d:sonar.login=$${sonar_token} + + # Début de l'analyse Sonar + - dotnet sonarscanner begin /k:$${project_key} \ + /d:sonar.host.url=$${sonar_host} \ + /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" \ + /d:sonar.coverage.exclusions=$${coverage_exclusions} \ + /d:sonar.login=$${sonar_token} + + # Build - dotnet build WF-WebAdmin.csproj -c Release --no-restore - - dotnet test WF-WebAdmin.csproj --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" + + # Test + Collecte de la couverture en format Cobertura + - dotnet test WF-WebAdmin.csproj --logger trx --no-restore \ + /p:CollectCoverage=true \ + /p:CoverletOutput=coveragereport/coverage.cobertura.xml \ + /p:CoverletOutputFormat=cobertura + + # Vérifier la présence du fichier de couverture - ls -R - - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" + + # Générer le rapport SonarQube + - reportgenerator -reports:"coveragereport/coverage.cobertura.xml" \ + -reporttypes:SonarQube \ + -targetdir:"coveragereport" + + # (Optionnel) Publish si besoin - dotnet publish WF-WebAdmin.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/publish + + # Fin de l’analyse Sonar - dotnet sonarscanner end /d:sonar.login=$${sonar_token} + - name: docker_build image: plugins/docker settings: From 7cf5395f14872b721a6368f865f14c55086708b4 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 11:17:33 +0100 Subject: [PATCH 47/79] Test CI 7 --- .drone.yml | 48 +++++++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/.drone.yml b/.drone.yml index 61a5bdb..9677654 100644 --- a/.drone.yml +++ b/.drone.yml @@ -21,7 +21,7 @@ steps: - cd WF-WebAdmin/WF-WebAdmin - dotnet restore WF-WebAdmin.csproj - dotnet test WF-WebAdmin.csproj --no-restore - depends_on: [build] + depends_on: [ build ] - name: code-inspection image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 @@ -30,48 +30,42 @@ steps: sonar_host: https://codefirst.iut.uca.fr/sonar/ sonar_token: from_secret: sonar_token - project_key: S201 + project_key: WF-WebAdmin coverage_exclusions: 'UnitTesting/**' commands: - cd WF-WebAdmin/WF-WebAdmin - dotnet restore WF-WebAdmin.csproj - - # Début de l'analyse Sonar - - dotnet sonarscanner begin /k:$${project_key} \ - /d:sonar.host.url=$${sonar_host} \ - /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" \ - /d:sonar.coverage.exclusions=$${coverage_exclusions} \ - /d:sonar.login=$${sonar_token} - - # Build + + # SonarScanner (en une seule ligne pour éviter les soucis d'arguments) + - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions=$${coverage_exclusions} /d:sonar.login=$${sonar_token} + - dotnet build WF-WebAdmin.csproj -c Release --no-restore - - # Test + Collecte de la couverture en format Cobertura + + # Exécution des tests + Coverlet => fichier Cobertura (coverage.cobertura.xml) - dotnet test WF-WebAdmin.csproj --logger trx --no-restore \ /p:CollectCoverage=true \ /p:CoverletOutput=coveragereport/coverage.cobertura.xml \ /p:CoverletOutputFormat=cobertura - - # Vérifier la présence du fichier de couverture + + # Vérification du contenu - ls -R - - # Générer le rapport SonarQube - - reportgenerator -reports:"coveragereport/coverage.cobertura.xml" \ - -reporttypes:SonarQube \ - -targetdir:"coveragereport" - - # (Optionnel) Publish si besoin + + # Génération du rapport SonarQube depuis Cobertura + - reportgenerator -reports:"coveragereport/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" + + # (Optionnel) Publication si besoin - dotnet publish WF-WebAdmin.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/publish - - # Fin de l’analyse Sonar + + # Clôture de l'analyse Sonar - dotnet sonarscanner end /d:sonar.login=$${sonar_token} + depends_on: [ build, tests ] - name: docker_build - image: plugins/docker + image: plugins/docker settings: repo: hub.codefirst.iut.uca.fr/whatthefantasy/wf-webadmin - registry: hub.codefirst.iut.uca.fr + registry: hub.codefirst.iut.uca.fr dockerfile: Docker/Dockerfile tags: - latest @@ -79,4 +73,4 @@ steps: from_secret: docker_username password: from_secret: docker_password - depends_on: [build, tests, code-inspection] + depends_on: [ build, tests, code-inspection ] From 188c759f07a834cccdfed046890b5faf55de134c Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 11:22:13 +0100 Subject: [PATCH 48/79] Test CI 8 --- .drone.yml | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/.drone.yml b/.drone.yml index 9677654..2bbd14a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -24,43 +24,46 @@ steps: depends_on: [ build ] - name: code-inspection + # On garde l'image du prof, comme demandé image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 - secrets: [ sonar_token ] + + secrets: [ sonar_tocken ] + environment: sonar_host: https://codefirst.iut.uca.fr/sonar/ sonar_token: - from_secret: sonar_token - project_key: WF-WebAdmin - coverage_exclusions: 'UnitTesting/**' + from_secret: sonar_tocken + project_key: "web_admin" # mettre ici votre vraie clé sonar + coverage_exclusions: "Tests/**" # ou tout autre dossier à exclure + commands: + # Se placer dans votre répertoire de projet - cd WF-WebAdmin/WF-WebAdmin + + # Restauration des dépendances - dotnet restore WF-WebAdmin.csproj - # SonarScanner (en une seule ligne pour éviter les soucis d'arguments) + # Démarrage de l'analyse SonarQube - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions=$${coverage_exclusions} /d:sonar.login=$${sonar_token} + # Build en Release - dotnet build WF-WebAdmin.csproj -c Release --no-restore - # Exécution des tests + Coverlet => fichier Cobertura (coverage.cobertura.xml) + # Exécution des tests avec collecte de couverture Cobertura - dotnet test WF-WebAdmin.csproj --logger trx --no-restore \ /p:CollectCoverage=true \ - /p:CoverletOutput=coveragereport/coverage.cobertura.xml \ - /p:CoverletOutputFormat=cobertura + /p:CoverletOutputFormat=cobertura \ + --collect "XPlat Code Coverage" - # Vérification du contenu - - ls -R + # Génération du rapport SonarQube à partir du Cobertura + - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" - # Génération du rapport SonarQube depuis Cobertura - - reportgenerator -reports:"coveragereport/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" + # (Optionnel) Publication de l'appli si vous en avez besoin + - dotnet publish WF-WebAdmin.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/release - # (Optionnel) Publication si besoin - - dotnet publish WF-WebAdmin.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/publish - - # Clôture de l'analyse Sonar + # Fin de l'analyse SonarQube - dotnet sonarscanner end /d:sonar.login=$${sonar_token} - depends_on: [ build, tests ] - - name: docker_build image: plugins/docker settings: From 2b3e93121e8b48e6255a9492eb4e4ad7c12acc61 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 11:25:47 +0100 Subject: [PATCH 49/79] Test CI 9 --- .drone.yml | 42 ++++++++++-------------------------------- 1 file changed, 10 insertions(+), 32 deletions(-) diff --git a/.drone.yml b/.drone.yml index 2bbd14a..abbb8be 100644 --- a/.drone.yml +++ b/.drone.yml @@ -24,44 +24,22 @@ steps: depends_on: [ build ] - name: code-inspection - # On garde l'image du prof, comme demandé image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 - - secrets: [ sonar_tocken ] - + secrets: [ sonar_token ] environment: sonar_host: https://codefirst.iut.uca.fr/sonar/ sonar_token: - from_secret: sonar_tocken - project_key: "web_admin" # mettre ici votre vraie clé sonar - coverage_exclusions: "Tests/**" # ou tout autre dossier à exclure - + from_secret: sonar_token + project_key: web_admin + coverage_exclusions: "Tests/**" commands: - # Se placer dans votre répertoire de projet - - cd WF-WebAdmin/WF-WebAdmin - - # Restauration des dépendances - - dotnet restore WF-WebAdmin.csproj - - # Démarrage de l'analyse SonarQube - - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions=$${coverage_exclusions} /d:sonar.login=$${sonar_token} - - # Build en Release - - dotnet build WF-WebAdmin.csproj -c Release --no-restore - - # Exécution des tests avec collecte de couverture Cobertura - - dotnet test WF-WebAdmin.csproj --logger trx --no-restore \ - /p:CollectCoverage=true \ - /p:CoverletOutputFormat=cobertura \ - --collect "XPlat Code Coverage" - - # Génération du rapport SonarQube à partir du Cobertura + - cd Sources/ + - dotnet restore WF-WebAdmin/WF-WebAdmin.sln + - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions=$${coverage_exclusions} /d:sonar.login=$${sonar_token} + - dotnet build WF-WebAdmin/WF-WebAdmin.sln -c Release --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 + - dotnet test WF-WebAdmin/WF-WebAdmin.sln --logger trx --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" - - # (Optionnel) Publication de l'appli si vous en avez besoin - - dotnet publish WF-WebAdmin.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/release - - # Fin de l'analyse SonarQube + - dotnet publish WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/release -f:net7.0-android /p:AndroidSdkDirectory=/usr/lib/android-sdk - dotnet sonarscanner end /d:sonar.login=$${sonar_token} - name: docker_build From b9cb6fe4b349fe6e0bf354b4f8d85e6ab2cee810 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 11:26:26 +0100 Subject: [PATCH 50/79] Test CI 10 --- .drone.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index abbb8be..bc4c963 100644 --- a/.drone.yml +++ b/.drone.yml @@ -33,7 +33,6 @@ steps: project_key: web_admin coverage_exclusions: "Tests/**" commands: - - cd Sources/ - dotnet restore WF-WebAdmin/WF-WebAdmin.sln - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions=$${coverage_exclusions} /d:sonar.login=$${sonar_token} - dotnet build WF-WebAdmin/WF-WebAdmin.sln -c Release --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 From 9b1c324dfde7f36aa46ee5fe7e0af05854a9cbde Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 11:31:12 +0100 Subject: [PATCH 51/79] Test CI 11 --- .drone.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.drone.yml b/.drone.yml index bc4c963..eea6e1e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -31,14 +31,13 @@ steps: sonar_token: from_secret: sonar_token project_key: web_admin - coverage_exclusions: "Tests/**" commands: - - dotnet restore WF-WebAdmin/WF-WebAdmin.sln + - dotnet restore WF-WebAdmin.sln - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions=$${coverage_exclusions} /d:sonar.login=$${sonar_token} - - dotnet build WF-WebAdmin/WF-WebAdmin.sln -c Release --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 - - dotnet test WF-WebAdmin/WF-WebAdmin.sln --logger trx --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" + - dotnet build WF-WebAdmin.sln -c Release --no-restore + - dotnet test WF-WebAdmin.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" - - dotnet publish WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/release -f:net7.0-android /p:AndroidSdkDirectory=/usr/lib/android-sdk + - dotnet publish WF-WebAdmin.sln -c Release --no-restore -o $CI_PROJECT_DIR/build/release - dotnet sonarscanner end /d:sonar.login=$${sonar_token} - name: docker_build From 68483c3178e45ccdc4880fb626f41e063be6ba84 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 11:31:44 +0100 Subject: [PATCH 52/79] Test CI 12 --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index eea6e1e..d9cd652 100644 --- a/.drone.yml +++ b/.drone.yml @@ -32,6 +32,7 @@ steps: from_secret: sonar_token project_key: web_admin commands: + - cd WF-WebAdmin - dotnet restore WF-WebAdmin.sln - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions=$${coverage_exclusions} /d:sonar.login=$${sonar_token} - dotnet build WF-WebAdmin.sln -c Release --no-restore From 6e40ec6ca92e6b1adceebda5a3a16eb312516cdc Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 11:32:53 +0100 Subject: [PATCH 53/79] Test CI 13 --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index d9cd652..baba3bb 100644 --- a/.drone.yml +++ b/.drone.yml @@ -34,7 +34,7 @@ steps: commands: - cd WF-WebAdmin - dotnet restore WF-WebAdmin.sln - - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions=$${coverage_exclusions} /d:sonar.login=$${sonar_token} + - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions="**/Migrations/**" /d:sonar.login=$${sonar_token} - dotnet build WF-WebAdmin.sln -c Release --no-restore - dotnet test WF-WebAdmin.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" From 10970ffd9a1cc12093cdd86e0c20065b1c986a35 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 11:33:54 +0100 Subject: [PATCH 54/79] Test CI 14 --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index baba3bb..355f846 100644 --- a/.drone.yml +++ b/.drone.yml @@ -34,7 +34,7 @@ steps: commands: - cd WF-WebAdmin - dotnet restore WF-WebAdmin.sln - - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions="**/Migrations/**" /d:sonar.login=$${sonar_token} + - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverage.exclusions="**/Migrations/**" /d:sonar.login=$${sonar_token} - dotnet build WF-WebAdmin.sln -c Release --no-restore - dotnet test WF-WebAdmin.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" From 356bff207242b786c4a86932a0d27f5cb8b4722e Mon Sep 17 00:00:00 2001 From: Kevin MONDEJAR Date: Tue, 4 Feb 2025 11:36:05 +0100 Subject: [PATCH 55/79] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'README.md'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 05159a8..4a5ee23 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ L'application devrait se lancer automatiquement dans votre navigateur par défau ✅ Supression d'un élement avec une confirmation (2 point)
🟨 Composant complexe (5 point)
🟨 Use API (Get / Insert / Update / Delete) (3 point)
-❌ Utilisation IOC & DI (4 point)
+✅ Utilisation IOC & DI (4 point)
✅ Localisation & Globalisation (au moins deux langues) (1 point)
❌ Utilisation de la configuration (1 point)
🟨 Logs (2 point)
From 82a534d9c74c4f9d1c0cfd6ee57ba0d45ee22e38 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 11:43:12 +0100 Subject: [PATCH 56/79] Test CI 15 --- .drone.yml | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/.drone.yml b/.drone.yml index 355f846..3fd233b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -23,23 +23,38 @@ steps: - dotnet test WF-WebAdmin.csproj --no-restore depends_on: [ build ] - - name: code-inspection + - name: code-analysis image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 - secrets: [ sonar_token ] - environment: - sonar_host: https://codefirst.iut.uca.fr/sonar/ - sonar_token: - from_secret: sonar_token - project_key: web_admin commands: - - cd WF-WebAdmin + - cd WF-WebAdmin/ - dotnet restore WF-WebAdmin.sln - - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverage.exclusions="**/Migrations/**" /d:sonar.login=$${sonar_token} + - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions=$${coverage_exclusions} /d:sonar.login=$${sonar_token} - dotnet build WF-WebAdmin.sln -c Release --no-restore - dotnet test WF-WebAdmin.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" - dotnet publish WF-WebAdmin.sln -c Release --no-restore -o $CI_PROJECT_DIR/build/release - dotnet sonarscanner end /d:sonar.login=$${sonar_token} + secrets: [ SECRET_SONAR_LOGIN ] + environment: + sonar_host: https://codefirst.iut.uca.fr/sonar/ + sonar_token: + from_secret: sonar_token + project_key: WF-WebAdmin + coverage_exclusions: "Tests/**" + depends_on: [tests] + + - name: generate-and-deploy-docs + image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-docdeployer + failure: ignore + volumes: + - name: docs + path: /docs + commands: + - /entrypoint.sh + when: + branch: + - master + depends_on: [ build ] - name: docker_build image: plugins/docker From e052f95ad95b05f4e1be0039f1ac721aba0655a9 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 11:44:21 +0100 Subject: [PATCH 57/79] Test CI 16 --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 3fd233b..16f4f53 100644 --- a/.drone.yml +++ b/.drone.yml @@ -68,4 +68,4 @@ steps: from_secret: docker_username password: from_secret: docker_password - depends_on: [ build, tests, code-inspection ] + depends_on: [ build, tests, code-analysis ] From 5a63b9916e20734ef797f766aa981a8212fc49a8 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 11:45:39 +0100 Subject: [PATCH 58/79] Test CI 17 --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 16f4f53..4d200ff 100644 --- a/.drone.yml +++ b/.drone.yml @@ -39,7 +39,7 @@ steps: sonar_host: https://codefirst.iut.uca.fr/sonar/ sonar_token: from_secret: sonar_token - project_key: WF-WebAdmin + project_key: web_admin coverage_exclusions: "Tests/**" depends_on: [tests] From d3fe3e7323747682fced9e6f003d2bc1247e395a Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 11:49:10 +0100 Subject: [PATCH 59/79] Test CI 18 --- WF-WebAdmin/UnitTesting/UnitTest1.cs | 11 ++++++++++ WF-WebAdmin/UnitTesting/UnitTesting.csproj | 24 ++++++++++++++++++++++ WF-WebAdmin/UnitTesting/Usings.cs | 1 + 3 files changed, 36 insertions(+) create mode 100644 WF-WebAdmin/UnitTesting/UnitTest1.cs create mode 100644 WF-WebAdmin/UnitTesting/UnitTesting.csproj create mode 100644 WF-WebAdmin/UnitTesting/Usings.cs diff --git a/WF-WebAdmin/UnitTesting/UnitTest1.cs b/WF-WebAdmin/UnitTesting/UnitTest1.cs new file mode 100644 index 0000000..6427e49 --- /dev/null +++ b/WF-WebAdmin/UnitTesting/UnitTest1.cs @@ -0,0 +1,11 @@ +namespace UnitTesting +{ + public class UnitTest1 + { + [Fact] + public void Test1() + { + + } + } +} \ No newline at end of file diff --git a/WF-WebAdmin/UnitTesting/UnitTesting.csproj b/WF-WebAdmin/UnitTesting/UnitTesting.csproj new file mode 100644 index 0000000..c5d1063 --- /dev/null +++ b/WF-WebAdmin/UnitTesting/UnitTesting.csproj @@ -0,0 +1,24 @@ + + + + net6.0 + enable + enable + + false + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + diff --git a/WF-WebAdmin/UnitTesting/Usings.cs b/WF-WebAdmin/UnitTesting/Usings.cs new file mode 100644 index 0000000..8c927eb --- /dev/null +++ b/WF-WebAdmin/UnitTesting/Usings.cs @@ -0,0 +1 @@ +global using Xunit; \ No newline at end of file From 99db1ed7a24b6d60d71c4db5fd5cc20f7f9f1d69 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 11:52:34 +0100 Subject: [PATCH 60/79] Test CI 19 --- WF-WebAdmin/UnitTestWF/UnitTest1.cs | 11 +++++++++++ WF-WebAdmin/UnitTestWF/UnitTestWF.csproj | 23 +++++++++++++++++++++++ WF-WebAdmin/WF-WebAdmin.sln | 6 ++++++ 3 files changed, 40 insertions(+) create mode 100644 WF-WebAdmin/UnitTestWF/UnitTest1.cs create mode 100644 WF-WebAdmin/UnitTestWF/UnitTestWF.csproj diff --git a/WF-WebAdmin/UnitTestWF/UnitTest1.cs b/WF-WebAdmin/UnitTestWF/UnitTest1.cs new file mode 100644 index 0000000..35e952c --- /dev/null +++ b/WF-WebAdmin/UnitTestWF/UnitTest1.cs @@ -0,0 +1,11 @@ +namespace UnitTestWF +{ + public class UnitTest1 + { + [Fact] + public void Test1() + { + + } + } +} \ No newline at end of file diff --git a/WF-WebAdmin/UnitTestWF/UnitTestWF.csproj b/WF-WebAdmin/UnitTestWF/UnitTestWF.csproj new file mode 100644 index 0000000..9c5b30a --- /dev/null +++ b/WF-WebAdmin/UnitTestWF/UnitTestWF.csproj @@ -0,0 +1,23 @@ + + + + net8.0 + enable + enable + + false + true + + + + + + + + + + + + + + diff --git a/WF-WebAdmin/WF-WebAdmin.sln b/WF-WebAdmin/WF-WebAdmin.sln index f97bd2a..65628e6 100644 --- a/WF-WebAdmin/WF-WebAdmin.sln +++ b/WF-WebAdmin/WF-WebAdmin.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 17.9.34723.18 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WF-WebAdmin", "WF-WebAdmin\WF-WebAdmin.csproj", "{0E8D1007-ADDC-4103-847D-8EE48ACCDC62}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting", "UnitTesting\UnitTesting.csproj", "{C632BAF9-4F1A-4B48-8275-ED519BE66F9B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {0E8D1007-ADDC-4103-847D-8EE48ACCDC62}.Debug|Any CPU.Build.0 = Debug|Any CPU {0E8D1007-ADDC-4103-847D-8EE48ACCDC62}.Release|Any CPU.ActiveCfg = Release|Any CPU {0E8D1007-ADDC-4103-847D-8EE48ACCDC62}.Release|Any CPU.Build.0 = Release|Any CPU + {C632BAF9-4F1A-4B48-8275-ED519BE66F9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C632BAF9-4F1A-4B48-8275-ED519BE66F9B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C632BAF9-4F1A-4B48-8275-ED519BE66F9B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C632BAF9-4F1A-4B48-8275-ED519BE66F9B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 67252ff84f3aec70a0f3b87e5ae9f7fe8025ef03 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Wed, 5 Feb 2025 08:17:10 +0100 Subject: [PATCH 61/79] test deploy --- .drone.yml | 13 +++++++++++++ WF-WebAdmin/WF-WebAdmin.sln | 10 +++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.drone.yml b/.drone.yml index 4d200ff..1fcdf7c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -69,3 +69,16 @@ steps: password: from_secret: docker_password depends_on: [ build, tests, code-analysis ] + + - name: deploy + image: hub.codefirst.iut.uca.fr/celeste.barbosa/codefirst-dockerproxy-clientdrone + environment: + IMAGENAME: hub.codefirst.iut.uca.fr/whatthefantasy/wf-webadmin + CONTAINERNAME: WF-WebAdmin + COMMAND: create + OVERWRITE: true + ADMINS: maximerocher,kevinmondejar,lenibeaulaton,kentinbrongniart,tommynguyen,louisguichard + when: + branch: + - master + depends_on: [ docker-build ] diff --git a/WF-WebAdmin/WF-WebAdmin.sln b/WF-WebAdmin/WF-WebAdmin.sln index 65628e6..ae4047e 100644 --- a/WF-WebAdmin/WF-WebAdmin.sln +++ b/WF-WebAdmin/WF-WebAdmin.sln @@ -5,7 +5,7 @@ VisualStudioVersion = 17.9.34723.18 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WF-WebAdmin", "WF-WebAdmin\WF-WebAdmin.csproj", "{0E8D1007-ADDC-4103-847D-8EE48ACCDC62}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting", "UnitTesting\UnitTesting.csproj", "{C632BAF9-4F1A-4B48-8275-ED519BE66F9B}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestWF", "UnitTestWF\UnitTestWF.csproj", "{A4EC0EC4-7A46-4F8E-99C3-4FD32F173F2F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -17,10 +17,10 @@ Global {0E8D1007-ADDC-4103-847D-8EE48ACCDC62}.Debug|Any CPU.Build.0 = Debug|Any CPU {0E8D1007-ADDC-4103-847D-8EE48ACCDC62}.Release|Any CPU.ActiveCfg = Release|Any CPU {0E8D1007-ADDC-4103-847D-8EE48ACCDC62}.Release|Any CPU.Build.0 = Release|Any CPU - {C632BAF9-4F1A-4B48-8275-ED519BE66F9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C632BAF9-4F1A-4B48-8275-ED519BE66F9B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C632BAF9-4F1A-4B48-8275-ED519BE66F9B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C632BAF9-4F1A-4B48-8275-ED519BE66F9B}.Release|Any CPU.Build.0 = Release|Any CPU + {A4EC0EC4-7A46-4F8E-99C3-4FD32F173F2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4EC0EC4-7A46-4F8E-99C3-4FD32F173F2F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4EC0EC4-7A46-4F8E-99C3-4FD32F173F2F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4EC0EC4-7A46-4F8E-99C3-4FD32F173F2F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From fab75f2fe80cca58893082d8e4625735817e78f0 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Wed, 5 Feb 2025 08:18:28 +0100 Subject: [PATCH 62/79] test deploy --- .drone.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.drone.yml b/.drone.yml index 1fcdf7c..4860fdc 100644 --- a/.drone.yml +++ b/.drone.yml @@ -71,14 +71,14 @@ steps: depends_on: [ build, tests, code-analysis ] - name: deploy - image: hub.codefirst.iut.uca.fr/celeste.barbosa/codefirst-dockerproxy-clientdrone - environment: - IMAGENAME: hub.codefirst.iut.uca.fr/whatthefantasy/wf-webadmin - CONTAINERNAME: WF-WebAdmin - COMMAND: create - OVERWRITE: true - ADMINS: maximerocher,kevinmondejar,lenibeaulaton,kentinbrongniart,tommynguyen,louisguichard - when: - branch: - - master - depends_on: [ docker-build ] + image: hub.codefirst.iut.uca.fr/celeste.barbosa/codefirst-dockerproxy-clientdrone + environment: + IMAGENAME: hub.codefirst.iut.uca.fr/whatthefantasy/wf-webadmin + CONTAINERNAME: WF-WebAdmin + COMMAND: create + OVERWRITE: true + ADMINS: maximerocher,kevinmondejar,lenibeaulaton,kentinbrongniart,tommynguyen + when: + branch: + - master + depends_on: [ docker_build ] From e77505db6d661baf61cba0c8c93b5340c05c7dde Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Wed, 5 Feb 2025 08:19:13 +0100 Subject: [PATCH 63/79] test deploy --- .drone.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.drone.yml b/.drone.yml index 4860fdc..5dbcb0c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -70,15 +70,15 @@ steps: from_secret: docker_password depends_on: [ build, tests, code-analysis ] - - name: deploy - image: hub.codefirst.iut.uca.fr/celeste.barbosa/codefirst-dockerproxy-clientdrone - environment: - IMAGENAME: hub.codefirst.iut.uca.fr/whatthefantasy/wf-webadmin - CONTAINERNAME: WF-WebAdmin - COMMAND: create - OVERWRITE: true - ADMINS: maximerocher,kevinmondejar,lenibeaulaton,kentinbrongniart,tommynguyen - when: - branch: - - master - depends_on: [ docker_build ] + - name: deploy + image: hub.codefirst.iut.uca.fr/celeste.barbosa/codefirst-dockerproxy-clientdrone + environment: + IMAGENAME: hub.codefirst.iut.uca.fr/whatthefantasy/wf-webadmin + CONTAINERNAME: WF-WebAdmin + COMMAND: create + OVERWRITE: true + ADMINS: maximerocher,kevinmondejar,lenibeaulaton,kentinbrongniart,tommynguyen + when: + branch: + - master + depends_on: [ docker_build ] From 0c6dd6026cf194b3818f3b9ad1be073bd5b91f01 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Wed, 5 Feb 2025 08:20:30 +0100 Subject: [PATCH 64/79] test deploy --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 5dbcb0c..143b4b2 100644 --- a/.drone.yml +++ b/.drone.yml @@ -24,7 +24,7 @@ steps: depends_on: [ build ] - name: code-analysis - image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 + image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dronesonarplugin-dotnet8 commands: - cd WF-WebAdmin/ - dotnet restore WF-WebAdmin.sln From 5a93a72b765a24f2761b60c21b5ec842801d1b90 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Wed, 5 Feb 2025 08:25:28 +0100 Subject: [PATCH 65/79] test deploy --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 143b4b2..d5d0c67 100644 --- a/.drone.yml +++ b/.drone.yml @@ -71,7 +71,7 @@ steps: depends_on: [ build, tests, code-analysis ] - name: deploy - image: hub.codefirst.iut.uca.fr/celeste.barbosa/codefirst-dockerproxy-clientdrone + image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-docdeployer environment: IMAGENAME: hub.codefirst.iut.uca.fr/whatthefantasy/wf-webadmin CONTAINERNAME: WF-WebAdmin From d83a99fec1ef76528d37c1ef117f51e979cf5898 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Wed, 5 Feb 2025 09:02:54 +0100 Subject: [PATCH 66/79] m --- WF-WebAdmin/UnitTesting/UnitTest1.cs | 11 ---------- WF-WebAdmin/UnitTesting/UnitTesting.csproj | 24 ---------------------- WF-WebAdmin/UnitTesting/Usings.cs | 1 - 3 files changed, 36 deletions(-) delete mode 100644 WF-WebAdmin/UnitTesting/UnitTest1.cs delete mode 100644 WF-WebAdmin/UnitTesting/UnitTesting.csproj delete mode 100644 WF-WebAdmin/UnitTesting/Usings.cs diff --git a/WF-WebAdmin/UnitTesting/UnitTest1.cs b/WF-WebAdmin/UnitTesting/UnitTest1.cs deleted file mode 100644 index 6427e49..0000000 --- a/WF-WebAdmin/UnitTesting/UnitTest1.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace UnitTesting -{ - public class UnitTest1 - { - [Fact] - public void Test1() - { - - } - } -} \ No newline at end of file diff --git a/WF-WebAdmin/UnitTesting/UnitTesting.csproj b/WF-WebAdmin/UnitTesting/UnitTesting.csproj deleted file mode 100644 index c5d1063..0000000 --- a/WF-WebAdmin/UnitTesting/UnitTesting.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - net6.0 - enable - enable - - false - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - diff --git a/WF-WebAdmin/UnitTesting/Usings.cs b/WF-WebAdmin/UnitTesting/Usings.cs deleted file mode 100644 index 8c927eb..0000000 --- a/WF-WebAdmin/UnitTesting/Usings.cs +++ /dev/null @@ -1 +0,0 @@ -global using Xunit; \ No newline at end of file From 050d401443c00c28dc9f21bd3ab2ffb14c764444 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Wed, 5 Feb 2025 09:05:37 +0100 Subject: [PATCH 67/79] deploiement --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index d5d0c67..bfb9c9b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -71,7 +71,7 @@ steps: depends_on: [ build, tests, code-analysis ] - name: deploy - image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-docdeployer + image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 environment: IMAGENAME: hub.codefirst.iut.uca.fr/whatthefantasy/wf-webadmin CONTAINERNAME: WF-WebAdmin From 3b96126e7d235e8e7bce63429b0c2c9986e5c9f3 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Wed, 5 Feb 2025 09:08:22 +0100 Subject: [PATCH 68/79] deploiement 2 --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index bfb9c9b..143b4b2 100644 --- a/.drone.yml +++ b/.drone.yml @@ -71,7 +71,7 @@ steps: depends_on: [ build, tests, code-analysis ] - name: deploy - image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 + image: hub.codefirst.iut.uca.fr/celeste.barbosa/codefirst-dockerproxy-clientdrone environment: IMAGENAME: hub.codefirst.iut.uca.fr/whatthefantasy/wf-webadmin CONTAINERNAME: WF-WebAdmin From 08754520048d03e7603bebc15f9cbfa82b8c67c5 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Wed, 5 Feb 2025 09:16:14 +0100 Subject: [PATCH 69/79] deploiement 3 --- .drone.yml | 16 +++++++++++----- Docker/Dockerfile | 27 ++++++++++++++++----------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/.drone.yml b/.drone.yml index 143b4b2..f4223fe 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,6 +1,6 @@ kind: pipeline -type: docker name: CI +type: docker trigger: event: @@ -8,7 +8,7 @@ trigger: steps: - name: build - image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 + image: mcr.microsoft.com/dotnet/sdk:6.0 commands: - cd WF-WebAdmin/WF-WebAdmin - dotnet restore WF-WebAdmin.csproj @@ -16,7 +16,7 @@ steps: - dotnet publish WF-WebAdmin.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/publish - name: tests - image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 + image: mcr.microsoft.com/dotnet/sdk:6.0 commands: - cd WF-WebAdmin/WF-WebAdmin - dotnet restore WF-WebAdmin.csproj @@ -41,7 +41,7 @@ steps: from_secret: sonar_token project_key: web_admin coverage_exclusions: "Tests/**" - depends_on: [tests] + depends_on: [ tests ] - name: generate-and-deploy-docs image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-docdeployer @@ -71,14 +71,20 @@ steps: depends_on: [ build, tests, code-analysis ] - name: deploy - image: hub.codefirst.iut.uca.fr/celeste.barbosa/codefirst-dockerproxy-clientdrone + image: mcr.microsoft.com/dotnet/aspnet:6.0 environment: IMAGENAME: hub.codefirst.iut.uca.fr/whatthefantasy/wf-webadmin CONTAINERNAME: WF-WebAdmin COMMAND: create OVERWRITE: true ADMINS: maximerocher,kevinmondejar,lenibeaulaton,kentinbrongniart,tommynguyen + commands: + - dotnet /app/WF-WebAdmin.dll when: branch: - master depends_on: [ docker_build ] + +volumes: + - name: docs + temp: {} \ No newline at end of file diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 69c0975..08390ff 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -1,17 +1,22 @@ -# Étape de base avec l'image runtime ASP.NET -FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base -WORKDIR /app -EXPOSE 80 - -# Étape de build pour publier l'application -FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +# Étape 1 : Build de l'application +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src + +# Copier les fichiers de solution et restaurer les dépendances +COPY WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj ./WF-WebAdmin/WF-WebAdmin/ +RUN dotnet restore ./WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj + +# Copier tout le reste et publier COPY . . -RUN dotnet restore "WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj" -RUN dotnet publish "WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj" -c Release -o /app/publish +RUN dotnet publish ./WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj -c Release -o /app/publish -# Étape finale : copie des fichiers publiés et définition du point d'entrée -FROM base AS final +# Étape 2 : Image runtime +FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS runtime WORKDIR /app COPY --from=build /app/publish . + +# Exposer le port utilisé par l'application +EXPOSE 5000 + +# Lancer l'application ENTRYPOINT ["dotnet", "WF-WebAdmin.dll"] From d11ce9cbc924dd3e81f8630df26de3b4ac3d8756 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Wed, 5 Feb 2025 09:19:27 +0100 Subject: [PATCH 70/79] deploiement 4 --- Docker/Dockerfile | 6 +++--- WF-WebAdmin/WF-WebAdmin/Program.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 08390ff..4029a9e 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -2,18 +2,18 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src -# Copier les fichiers de solution et restaurer les dépendances +# Copier les fichiers de projet et restaurer les dépendances COPY WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj ./WF-WebAdmin/WF-WebAdmin/ RUN dotnet restore ./WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj # Copier tout le reste et publier COPY . . -RUN dotnet publish ./WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj -c Release -o /app/publish +RUN dotnet publish ./WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj -c Release -o /app # Étape 2 : Image runtime FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS runtime WORKDIR /app -COPY --from=build /app/publish . +COPY --from=build /app . # Exposer le port utilisé par l'application EXPOSE 5000 diff --git a/WF-WebAdmin/WF-WebAdmin/Program.cs b/WF-WebAdmin/WF-WebAdmin/Program.cs index c459806..51f1d46 100644 --- a/WF-WebAdmin/WF-WebAdmin/Program.cs +++ b/WF-WebAdmin/WF-WebAdmin/Program.cs @@ -17,7 +17,6 @@ using WF_WebAdmin.Service; var builder = WebApplication.CreateBuilder(args); -// Add services to the container. builder.Services.AddRazorPages(); builder.Services.AddServerSideBlazor(); builder.Services.AddSingleton(); @@ -26,6 +25,7 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddHttpClient(); builder.Services.AddScoped(); +builder.WebHost.UseUrls("http://0.0.0.0:5000"); builder.Services .AddBlazorise() From 0ba067027097405e6436b670e109a999bf8f4990 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Wed, 5 Feb 2025 09:23:07 +0100 Subject: [PATCH 71/79] deploiement 5 --- .drone.yml | 3 ++- Docker/Dockerfile | 33 +++++++++++++++++++++------------ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/.drone.yml b/.drone.yml index f4223fe..c1d023c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -79,7 +79,8 @@ steps: OVERWRITE: true ADMINS: maximerocher,kevinmondejar,lenibeaulaton,kentinbrongniart,tommynguyen commands: - - dotnet /app/WF-WebAdmin.dll + - ls /app # Vérification que WF-WebAdmin.dll est bien présent + - dotnet WF-WebAdmin.dll when: branch: - master diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 4029a9e..b6aa57c 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -1,22 +1,31 @@ -# Étape 1 : Build de l'application +# Étape 1 : Image de base ASP.NET pour le runtime +FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +# Étape 2 : Build de l'application avec le SDK .NET FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src -# Copier les fichiers de projet et restaurer les dépendances -COPY WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj ./WF-WebAdmin/WF-WebAdmin/ -RUN dotnet restore ./WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj +# Copier le fichier .csproj et restaurer les dépendances +COPY ["WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj", "./"] +RUN dotnet restore "WF-WebAdmin.csproj" -# Copier tout le reste et publier +# Copier tout le reste des fichiers sources COPY . . -RUN dotnet publish ./WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj -c Release -o /app -# Étape 2 : Image runtime -FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS runtime -WORKDIR /app -COPY --from=build /app . +# Compiler le projet +RUN dotnet build "WF-WebAdmin.csproj" -c Release -o /app/build -# Exposer le port utilisé par l'application -EXPOSE 5000 +# Étape 3 : Publication de l'application +FROM build AS publish +RUN dotnet publish "WF-WebAdmin.csproj" -c Release -o /app/publish + +# Étape 4 : Préparer l'image finale pour exécution +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . # Lancer l'application ENTRYPOINT ["dotnet", "WF-WebAdmin.dll"] From 5fbd65e3ba0137fa01055bd57d115363d2fdf878 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Wed, 5 Feb 2025 09:26:54 +0100 Subject: [PATCH 72/79] deploiement 6 --- Docker/Dockerfile | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Docker/Dockerfile b/Docker/Dockerfile index b6aa57c..11f153c 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -4,18 +4,16 @@ WORKDIR /app EXPOSE 80 EXPOSE 443 -# Étape 2 : Build de l'application avec le SDK .NET +# Étape 2 : Build de l'application FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src -# Copier le fichier .csproj et restaurer les dépendances +# Copier le fichier projet et restaurer les dépendances COPY ["WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj", "./"] RUN dotnet restore "WF-WebAdmin.csproj" -# Copier tout le reste des fichiers sources -COPY . . - -# Compiler le projet +# Copier tout le reste des fichiers et compiler +COPY WF-WebAdmin/WF-WebAdmin/. . RUN dotnet build "WF-WebAdmin.csproj" -c Release -o /app/build # Étape 3 : Publication de l'application From 37a0b0688546a3c38b10699d20a5f0d9f64e0b83 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Wed, 5 Feb 2025 09:31:14 +0100 Subject: [PATCH 73/79] deploiement 7 --- .drone.yml | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/.drone.yml b/.drone.yml index c1d023c..736c9f8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -7,6 +7,7 @@ trigger: - push steps: + # 1. BUILD - name: build image: mcr.microsoft.com/dotnet/sdk:6.0 commands: @@ -15,6 +16,7 @@ steps: - dotnet build WF-WebAdmin.csproj -c Release --no-restore - dotnet publish WF-WebAdmin.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/publish + # 2. TESTS - name: tests image: mcr.microsoft.com/dotnet/sdk:6.0 commands: @@ -23,12 +25,13 @@ steps: - dotnet test WF-WebAdmin.csproj --no-restore depends_on: [ build ] + # 3. CODE ANALYSIS (SONARQUBE) - name: code-analysis image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dronesonarplugin-dotnet8 commands: - cd WF-WebAdmin/ - dotnet restore WF-WebAdmin.sln - - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions=$${coverage_exclusions} /d:sonar.login=$${sonar_token} + - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions=$${coverage_exclusions} /d:sonar.login=$${sonar_token} - dotnet build WF-WebAdmin.sln -c Release --no-restore - dotnet test WF-WebAdmin.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" @@ -43,6 +46,7 @@ steps: coverage_exclusions: "Tests/**" depends_on: [ tests ] + # 4. GENERATION ET DEPLOIEMENT DE DOCS (OPTIONNEL) - name: generate-and-deploy-docs image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-docdeployer failure: ignore @@ -56,6 +60,7 @@ steps: - master depends_on: [ build ] + # 5. CONSTRUCTION DE L'IMAGE DOCKER - name: docker_build image: plugins/docker settings: @@ -70,17 +75,13 @@ steps: from_secret: docker_password depends_on: [ build, tests, code-analysis ] + # 6. DEPLOIEMENT - name: deploy - image: mcr.microsoft.com/dotnet/aspnet:6.0 - environment: - IMAGENAME: hub.codefirst.iut.uca.fr/whatthefantasy/wf-webadmin - CONTAINERNAME: WF-WebAdmin - COMMAND: create - OVERWRITE: true - ADMINS: maximerocher,kevinmondejar,lenibeaulaton,kentinbrongniart,tommynguyen + # On réutilise l'image que l'on vient de builder et de pousser + image: hub.codefirst.iut.uca.fr/whatthefantasy/wf-webadmin:latest commands: - - ls /app # Vérification que WF-WebAdmin.dll est bien présent - - dotnet WF-WebAdmin.dll + - ls /app + - dotnet /app/WF-WebAdmin.dll when: branch: - master @@ -88,4 +89,4 @@ steps: volumes: - name: docs - temp: {} \ No newline at end of file + temp: {} From 0af5d9587870c4874af3e7e6dae6b41b92f3aeb8 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Wed, 5 Feb 2025 09:34:57 +0100 Subject: [PATCH 74/79] deploiement 7 --- .drone.yml | 9 ++++----- Docker/Dockerfile | 40 +++++++++++++++++++--------------------- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/.drone.yml b/.drone.yml index 736c9f8..1e9ad41 100644 --- a/.drone.yml +++ b/.drone.yml @@ -25,7 +25,7 @@ steps: - dotnet test WF-WebAdmin.csproj --no-restore depends_on: [ build ] - # 3. CODE ANALYSIS (SONARQUBE) + # 3. CODE ANALYSIS (SONARQUBE) - Exemple, si tu utilises Sonar - name: code-analysis image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dronesonarplugin-dotnet8 commands: @@ -46,7 +46,7 @@ steps: coverage_exclusions: "Tests/**" depends_on: [ tests ] - # 4. GENERATION ET DEPLOIEMENT DE DOCS (OPTIONNEL) + # 4. GÉNÉRATION ET DÉPLOIEMENT DE DOCS (optionnel) - name: generate-and-deploy-docs image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-docdeployer failure: ignore @@ -60,7 +60,7 @@ steps: - master depends_on: [ build ] - # 5. CONSTRUCTION DE L'IMAGE DOCKER + # 5. BUILD DE L'IMAGE DOCKER ET PUSH - name: docker_build image: plugins/docker settings: @@ -75,9 +75,8 @@ steps: from_secret: docker_password depends_on: [ build, tests, code-analysis ] - # 6. DEPLOIEMENT + # 6. DEPLOY - name: deploy - # On réutilise l'image que l'on vient de builder et de pousser image: hub.codefirst.iut.uca.fr/whatthefantasy/wf-webadmin:latest commands: - ls /app diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 11f153c..055b3a2 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -1,29 +1,27 @@ -# Étape 1 : Image de base ASP.NET pour le runtime -FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base -WORKDIR /app -EXPOSE 80 -EXPOSE 443 - -# Étape 2 : Build de l'application +# 1. Étape de build (SDK .NET 6) FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src -# Copier le fichier projet et restaurer les dépendances -COPY ["WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj", "./"] -RUN dotnet restore "WF-WebAdmin.csproj" - -# Copier tout le reste des fichiers et compiler -COPY WF-WebAdmin/WF-WebAdmin/. . -RUN dotnet build "WF-WebAdmin.csproj" -c Release -o /app/build +# Copier le csproj et restaurer les dépendances +COPY WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj ./ +RUN dotnet restore WF-WebAdmin.csproj -# Étape 3 : Publication de l'application -FROM build AS publish -RUN dotnet publish "WF-WebAdmin.csproj" -c Release -o /app/publish +# Copier le reste du code et compiler +COPY WF-WebAdmin/WF-WebAdmin/ ./ +RUN dotnet publish WF-WebAdmin.csproj -c Release -o /app/publish -# Étape 4 : Préparer l'image finale pour exécution -FROM base AS final +# 2. Étape finale (runtime .NET 6) +FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS final WORKDIR /app -COPY --from=publish /app/publish . -# Lancer l'application +# Désactiver le rechargement de config pour éviter les erreurs inotify +ENV ASPNETCORE_HOSTBUILDER__RELOADCONFIGONCHANGE=false + +# Copier les binaires publiés +COPY --from=build /app/publish ./ + +# Exposer le port HTTP (80) ; adapte si besoin +EXPOSE 80 + +# Lancement ENTRYPOINT ["dotnet", "WF-WebAdmin.dll"] From 21acb505efff7e3c0308b765dd32ca343fe2c088 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Wed, 5 Feb 2025 09:46:25 +0100 Subject: [PATCH 75/79] roll back --- .drone.yml | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/.drone.yml b/.drone.yml index 1e9ad41..ce8794e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,37 +1,34 @@ kind: pipeline -name: CI type: docker +name: CI trigger: event: - push steps: - # 1. BUILD - name: build - image: mcr.microsoft.com/dotnet/sdk:6.0 + image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 commands: - cd WF-WebAdmin/WF-WebAdmin - dotnet restore WF-WebAdmin.csproj - dotnet build WF-WebAdmin.csproj -c Release --no-restore - dotnet publish WF-WebAdmin.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/publish - # 2. TESTS - name: tests - image: mcr.microsoft.com/dotnet/sdk:6.0 + image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 commands: - cd WF-WebAdmin/WF-WebAdmin - dotnet restore WF-WebAdmin.csproj - dotnet test WF-WebAdmin.csproj --no-restore depends_on: [ build ] - # 3. CODE ANALYSIS (SONARQUBE) - Exemple, si tu utilises Sonar - name: code-analysis image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dronesonarplugin-dotnet8 commands: - cd WF-WebAdmin/ - dotnet restore WF-WebAdmin.sln - - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions=$${coverage_exclusions} /d:sonar.login=$${sonar_token} + - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions=$${coverage_exclusions} /d:sonar.login=$${sonar_token} - dotnet build WF-WebAdmin.sln -c Release --no-restore - dotnet test WF-WebAdmin.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" @@ -44,9 +41,8 @@ steps: from_secret: sonar_token project_key: web_admin coverage_exclusions: "Tests/**" - depends_on: [ tests ] + depends_on: [tests] - # 4. GÉNÉRATION ET DÉPLOIEMENT DE DOCS (optionnel) - name: generate-and-deploy-docs image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-docdeployer failure: ignore @@ -60,7 +56,6 @@ steps: - master depends_on: [ build ] - # 5. BUILD DE L'IMAGE DOCKER ET PUSH - name: docker_build image: plugins/docker settings: @@ -75,17 +70,15 @@ steps: from_secret: docker_password depends_on: [ build, tests, code-analysis ] - # 6. DEPLOY - name: deploy - image: hub.codefirst.iut.uca.fr/whatthefantasy/wf-webadmin:latest - commands: - - ls /app - - dotnet /app/WF-WebAdmin.dll + image: + environment: + IMAGENAME: hub.codefirst.iut.uca.fr/whatthefantasy/wf-webadmin + CONTAINERNAME: WF-WebAdmin + COMMAND: create + OVERWRITE: true + ADMINS: maximerocher,kevinmondejar,lenibeaulaton,kentinbrongniart,tommynguyen when: branch: - master depends_on: [ docker_build ] - -volumes: - - name: docs - temp: {} From 6eef5957776f357504b125e4e3806d6109963d37 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Wed, 5 Feb 2025 09:46:46 +0100 Subject: [PATCH 76/79] roll back --- .drone.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.drone.yml b/.drone.yml index ce8794e..f4223fe 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,6 +1,6 @@ kind: pipeline -type: docker name: CI +type: docker trigger: event: @@ -8,7 +8,7 @@ trigger: steps: - name: build - image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 + image: mcr.microsoft.com/dotnet/sdk:6.0 commands: - cd WF-WebAdmin/WF-WebAdmin - dotnet restore WF-WebAdmin.csproj @@ -16,7 +16,7 @@ steps: - dotnet publish WF-WebAdmin.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/publish - name: tests - image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 + image: mcr.microsoft.com/dotnet/sdk:6.0 commands: - cd WF-WebAdmin/WF-WebAdmin - dotnet restore WF-WebAdmin.csproj @@ -41,7 +41,7 @@ steps: from_secret: sonar_token project_key: web_admin coverage_exclusions: "Tests/**" - depends_on: [tests] + depends_on: [ tests ] - name: generate-and-deploy-docs image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-docdeployer @@ -71,14 +71,20 @@ steps: depends_on: [ build, tests, code-analysis ] - name: deploy - image: + image: mcr.microsoft.com/dotnet/aspnet:6.0 environment: IMAGENAME: hub.codefirst.iut.uca.fr/whatthefantasy/wf-webadmin CONTAINERNAME: WF-WebAdmin COMMAND: create OVERWRITE: true ADMINS: maximerocher,kevinmondejar,lenibeaulaton,kentinbrongniart,tommynguyen + commands: + - dotnet /app/WF-WebAdmin.dll when: branch: - master depends_on: [ docker_build ] + +volumes: + - name: docs + temp: {} \ No newline at end of file From 757643c47bb23698503892560d29bfe143e2eaef Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Wed, 5 Feb 2025 09:48:12 +0100 Subject: [PATCH 77/79] roll back --- .drone.yml | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/.drone.yml b/.drone.yml index f4223fe..0d2e24d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -69,22 +69,3 @@ steps: password: from_secret: docker_password depends_on: [ build, tests, code-analysis ] - - - name: deploy - image: mcr.microsoft.com/dotnet/aspnet:6.0 - environment: - IMAGENAME: hub.codefirst.iut.uca.fr/whatthefantasy/wf-webadmin - CONTAINERNAME: WF-WebAdmin - COMMAND: create - OVERWRITE: true - ADMINS: maximerocher,kevinmondejar,lenibeaulaton,kentinbrongniart,tommynguyen - commands: - - dotnet /app/WF-WebAdmin.dll - when: - branch: - - master - depends_on: [ docker_build ] - -volumes: - - name: docs - temp: {} \ No newline at end of file From 7ad71358048df718df28de60511a52c6bf9883aa Mon Sep 17 00:00:00 2001 From: Tommy NGUYEN Date: Wed, 5 Feb 2025 15:31:52 +0100 Subject: [PATCH 78/79] =?UTF-8?q?Documentation=20r=C3=A9alis=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4a5ee23..c82a3dd 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,6 @@ L'application devrait se lancer automatiquement dans votre navigateur par défau ✅ Emplacement du code (Pas de code dans les vues) (2 point)
# Documentation (10 points) -✅Le Readme (2 points)
-❌Description du fonctionnement de la solution client (illustrutration au niveau du code) (6 points)
-✅Merge request (2 points)
+✅ Le Readme (2 points)
+✅ Description du fonctionnement de la solution client (illustrutration au niveau du code) (6 points)
+✅ Merge request (2 points)
From c0596f6810fedef79a506f5f81bfbb7bd977ed31 Mon Sep 17 00:00:00 2001 From: Leni BEAULATON Date: Fri, 7 Feb 2025 13:02:04 +0100 Subject: [PATCH 79/79] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'README.md'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit non, la doc n'est pas faite --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c82a3dd..4e3fa78 100644 --- a/README.md +++ b/README.md @@ -76,5 +76,5 @@ L'application devrait se lancer automatiquement dans votre navigateur par défau # Documentation (10 points) ✅ Le Readme (2 points)
-✅ Description du fonctionnement de la solution client (illustrutration au niveau du code) (6 points)
+❌ Description du fonctionnement de la solution client (illustrutration au niveau du code) (6 points)
✅ Merge request (2 points)
#QuestionRéponse ARéponse BRéponse CRéponse DRéponse CorrecteUtilisateurActions@Localizer["Question"]@Localizer["AnswerA"]@Localizer["AnswerB"]@Localizer["AnswerC"]@Localizer["AnswerD"]@Localizer["GoodAnswer"]@Localizer["User"]@Localizer["Action"]