Merge remote-tracking branch 'origin/Service' into Converter

lfjk
Converter
Louis GUICHARD-MONTGUERS 4 months ago
commit c5eefafa96

@ -2,12 +2,13 @@
<PageTitle>Gestion utilisateur</PageTitle> <PageTitle>Gestion utilisateur</PageTitle>
@if(users != null) <h3>Gestion des utilisateurs</h3>
{
<h3>Gestion des utilisateurs</h3>
<p>Utilisateurs présents:</p>
@if (users != null)
{
<p>Utilisateurs présents:</p>
@foreach (var user in users) @foreach (var user in users)
{ {
<div class="userDiv"> <div class="userDiv">
@ -16,10 +17,28 @@
<p class="pseudo"><strong>Nom d'utilisateur :</strong> @user.Name</p> <p class="pseudo"><strong>Nom d'utilisateur :</strong> @user.Name</p>
<p class="mail"><strong>Email de l'utilisateur :</strong> @user.Email</p> <p class="mail"><strong>Email de l'utilisateur :</strong> @user.Email</p>
<p class="dateCrea"><strong>Date de création de l'utilisateur :</strong> @user.DateCreation.ToShortDateString()</p> <p class="dateCrea"><strong>Date de création de l'utilisateur :</strong> @user.DateCreation.ToShortDateString()</p>
<button>Supprimer l'utilisateur</button> <button id="DeleteButton" @onclick="() => ShowConfirmation(user)">Supprimer l'utilisateur</button>
</div> </div>
} }
<!-- Fenêtre de confirmation -->
@if (showPopup)
{
<div class="divPopup">
<div class="contentPopup">
<p>Êtes-vous sûr de vouloir supprimer cet utilisateur ?</p>
<button @onclick="() => RemoveUser()">Confirmer</button>
<button @onclick="ClosePopup">Annuler</button>
</div>
</div>
}
} }
else
{
<p><strong>Aucun utilisateurs présents sur le site</strong></p>
}
@code { @code {

@ -1,12 +1,16 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Configuration.UserSecrets;
using WF_WebAdmin.Model; using WF_WebAdmin.Model;
namespace WF_WebAdmin.Pages namespace WF_WebAdmin.Pages
{ {
public partial class DeleteUser public partial class DeleteUser
{ {
private User[] users; private List<User> users;
private bool showPopup = false;
private User userToDelete = null;
[Inject] [Inject]
public HttpClient Http { get; set; } public HttpClient Http { get; set; }
@ -15,7 +19,34 @@ namespace WF_WebAdmin.Pages
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
users = await Http.GetFromJsonAsync<User[]>($"{NavigationManager.BaseUri}fake-dataUser.json"); users = await Http.GetFromJsonAsync<List<User>>($"{NavigationManager.BaseUri}fake-dataUser.json");
}
private void ShowConfirmation(User user)
{
// Afficher la modale et mémoriser l'utilisateur à supprimer
userToDelete = user;
showPopup = true;
}
private async Task RemoveUser()
{
if (userToDelete != null)
{
users.RemoveAll(u => u.Id == userToDelete.Id);
ClosePopup();
}
}
private void ClosePopup()
{
showPopup = false;
} }
} }
} }

@ -0,0 +1,24 @@
@using WF_WebAdmin.Model
@page "/modifquote"
<PageTitle>Corection des citation</PageTitle>
<h3>Corection des citation</h3>
<p>Ajouter une recherche</p>
@if (quotes != null)
{
<DataGrid TItem="Quote"
Data="@quotes"
PageSize="int.MaxValue"
Responsive>
<DataGridColumn TItem="Quote" Field="@nameof(Quote.Id)" Caption="Id"/>
<DataGridColumn TItem="Quote" Field="@nameof(Quote.Content)" Caption="Citation"/>
<DataGridColumn TItem="Quote" Field="@nameof(Quote.Charac)" Caption="Personage"/>
<DataGridColumn TItem="Quote" Field="@nameof(Quote.TitleSrc)" Caption="Source" />
<DataGridColumn TItem="Quote" Field="@nameof(Quote.Langue)" Caption="Langue" />
<DataGridColumn TItem="Quote" Field="@nameof(Quote.DateSrc)" Caption="Date" DisplayFormat="{0:d}" DisplayFormatProvider="@System.Globalization.CultureInfo.GetCultureInfo("fr-FR")" />
</DataGrid>
}

@ -0,0 +1,23 @@
using Microsoft.AspNetCore.Components;
using WF_WebAdmin.Model;
namespace WF_WebAdmin.Pages
{
public partial class ModifQuote
{
private Quote[] quotes;
private int MaxValue = 5;
[Inject]
public HttpClient Http { get; set; }
[Inject]
public NavigationManager NavigationManager { get; set; }
protected override async Task OnInitializedAsync()
{
quotes = await Http.GetFromJsonAsync<Quote[]>($"{NavigationManager.BaseUri}fake-dataModifQuote.json");
}
}
}

@ -28,5 +28,10 @@
</div> </div>
<script src="_framework/blazor.server.js"></script> <script src="_framework/blazor.server.js"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
<link href="_content/Blazorise/blazorise.css" rel="stylesheet" />
<link href="_content/Blazorise.Bootstrap/blazorise.bootstrap.css" rel="stylesheet" />
</body> </body>
</html> </html>

@ -1,3 +1,6 @@
using Blazorise;
using Blazorise.Bootstrap;
using Blazorise.Icons.FontAwesome;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.Web;
using WF_WebAdmin.Data; using WF_WebAdmin.Data;
@ -11,6 +14,11 @@ builder.Services.AddSingleton<WeatherForecastService>();
builder.Services.AddHttpClient(); builder.Services.AddHttpClient();
builder.Services
.AddBlazorise()
.AddBootstrapProviders()
.AddFontAwesomeIcons();
var app = builder.Build(); var app = builder.Build();
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.

@ -0,0 +1,27 @@
using WF_WebAdmin.Model;
namespace WF_WebAdmin.Service
{
public interface IQuoteService
{
public void addQuote(Quote quote);
public void removeQuote(Quote quote);
public void validQuote(Quote quote);
public void updateQuote(Quote quote);
public List<Quote> getAllQuote();
public List<Quote> getSomeQuote(int nb, int page);
public Quote getOnequote(int id);
public List<Quote> reserchQuote(string reserch, List<string> argument);
public List<Quote> getAllQuoteInvalid();
public List<Quote> getSomeQuoteInvalid(int nb, int page);
}
}

@ -0,0 +1,21 @@
using WF_WebAdmin.Model;
namespace WF_WebAdmin.Service
{
public interface IUserService
{
public void removeUser(User user);
public void updateRole(User user);
public void downgradeRole(User user);
public List<User> getAllUser();
public List<User> getSomeUser(int nb, int page);
public User getOneUser(int id);
public List<User> reserchUsers(string reserch, List<string> args);
}
}

@ -0,0 +1,65 @@
using Microsoft.AspNetCore.Components;
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; }
public void addQuote(Quote quote)
{
}
public List<Quote> getAllQuote()
{
throw new NotImplementedException();
}
public List<Quote> getAllQuoteInvalid()
{
throw new NotImplementedException();
}
public Quote getOnequote(int id)
{
throw new NotImplementedException();
}
public List<Quote> getSomeQuote(int nb, int page)
{
throw new NotImplementedException();
}
public List<Quote> getSomeQuoteInvalid(int nb, int page)
{
throw new NotImplementedException();
}
public void removeQuote(Quote quote)
{
throw new NotImplementedException();
}
public List<Quote> reserchQuote(string reserch, List<string> argument)
{
throw new NotImplementedException();
}
public void updateQuote(Quote quote)
{
throw new NotImplementedException();
}
public void validQuote(Quote quote)
{
throw new NotImplementedException();
}
}
}

@ -31,6 +31,13 @@
</NavLink> </NavLink>
</div> </div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="modifquote">
<span class="oi oi-list-rich" aria-hidden="true"></span> Corection des citation
</NavLink>
</div>
</nav> </nav>
</div> </div>

@ -8,6 +8,10 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Blazorise.Bootstrap" Version="1.7.2" />
<PackageReference Include="Blazorise.DataGrid" Version="1.7.2" />
<PackageReference Include="Blazorise.Icons.FontAwesome" Version="1.7.2" />
<PackageReference Include="bootstrap" Version="5.3.3" />
<PackageReference Include="Npgsql" Version="9.0.2" /> <PackageReference Include="Npgsql" Version="9.0.2" />
</ItemGroup> </ItemGroup>

@ -8,3 +8,4 @@
@using Microsoft.JSInterop @using Microsoft.JSInterop
@using WF_WebAdmin @using WF_WebAdmin
@using WF_WebAdmin.Shared @using WF_WebAdmin.Shared
@using Blazorise.DataGrid

@ -88,4 +88,37 @@ button {
.pseudo, .mail, .idUser, .dateCrea, .idQuote, .contentQuote, .CaracterQuote, .SourceQuote, .langueQuote, .UserPropositionQuote { .pseudo, .mail, .idUser, .dateCrea, .idQuote, .contentQuote, .CaracterQuote, .SourceQuote, .langueQuote, .UserPropositionQuote {
margin-left: 10px; margin-left: 10px;
}
/*ModifQuote*/
.imgTab{
width: 5vw;
height: 5vw;
object-fit: contain;
}
/*Popup DeleteUser*/
.divPopup {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: white border-radius:20px;
display: flex;
justify-content: center;
align-items: center;
z-index: 2;
}
.contentPopup {
background-color: white;
padding: 20px;
border-radius: 20px;
display: flex;
flex-direction: column;
gap: 10px;
width: 300px;
text-align: center;
} }

@ -0,0 +1,90 @@
[
{
"Id": 1,
"ImgPath": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7",
"Content": "Harry POTTER JE SUIS TON PERE",
"Charac": "Sirius Black",
"TitleSrc": "Harry Potter",
"Langue": "fr",
"UserProposition": "demo",
"DateSrc": "2001-01-01",
"Like": 20
},
{
"Id": 2,
"ImgPath": "https://tse2.mm.bing.net/th/id/OIP.zR4rzkK7q2wCcNwZd6jjegHaIC?w=163&h=180&c=7&r=0&o=5&pid=1.7",
"Content": "'Une autre citation'",
"Charac": "Un personnage",
"TitleSrc": "Un super film",
"Langue": "fr",
"DateSrc": "2002-02-02",
"Like": 0,
"UserProposition": "exploit"
},
{
"Id": 1,
"ImgPath": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7",
"Content": "Harry POTTER JE SUIS TON PERE",
"Charac": "Sirius Black",
"TitleSrc": "Harry Potter",
"Langue": "fr",
"UserProposition": "demo",
"DateSrc": "2001-01-01",
"Like": 20
},
{
"Id": 2,
"ImgPath": "https://tse2.mm.bing.net/th/id/OIP.zR4rzkK7q2wCcNwZd6jjegHaIC?w=163&h=180&c=7&r=0&o=5&pid=1.7",
"Content": "'Une autre citation'",
"Charac": "Un personnage",
"TitleSrc": "Un super film",
"Langue": "fr",
"DateSrc": "2002-02-02",
"Like": 0,
"UserProposition": "exploit"
},
{
"Id": 1,
"ImgPath": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7",
"Content": "Harry POTTER JE SUIS TON PERE",
"Charac": "Sirius Black",
"TitleSrc": "Harry Potter",
"Langue": "fr",
"UserProposition": "demo",
"DateSrc": "2001-01-01",
"Like": 20
},
{
"Id": 2,
"ImgPath": "https://tse2.mm.bing.net/th/id/OIP.zR4rzkK7q2wCcNwZd6jjegHaIC?w=163&h=180&c=7&r=0&o=5&pid=1.7",
"Content": "'Une autre citation'",
"Charac": "Un personnage",
"TitleSrc": "Un super film",
"Langue": "fr",
"DateSrc": "2002-02-02",
"Like": 0,
"UserProposition": "exploit"
},
{
"Id": 1,
"ImgPath": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7",
"Content": "Harry POTTER JE SUIS TON PERE",
"Charac": "Sirius Black",
"TitleSrc": "Harry Potter",
"Langue": "fr",
"UserProposition": "demo",
"DateSrc": "2001-01-01",
"Like": 20
},
{
"Id": 2,
"ImgPath": "https://tse2.mm.bing.net/th/id/OIP.zR4rzkK7q2wCcNwZd6jjegHaIC?w=163&h=180&c=7&r=0&o=5&pid=1.7",
"Content": "'Une autre citation'",
"Charac": "Un personnage",
"TitleSrc": "Un super film",
"Langue": "fr",
"DateSrc": "2002-02-02",
"Like": 0,
"UserProposition": "exploit"
}
]
Loading…
Cancel
Save