ajout des admins + modifications pour avoir des listes dinamiques
continuous-integration/drone/push Build is failing Details

pull/28/head
Vianney JOURDY 2 years ago
parent 90dc6dbea9
commit 8e56d0cc0f

@ -41,6 +41,16 @@
Title="Fiche Exemple"
ContentTemplate="{DataTemplate Views:ficheAnime}"
Route="fichePage"/>
<ShellContent
Title="Connection Admin"
ContentTemplate="{DataTemplate Views:loginAdminPage}"
Route="connexionAdminPage"/>
<ShellContent
Title="Creation oeuvre"
ContentTemplate="{DataTemplate Views:createOeuvre}"
Route="createOeuvrePage"/>
</Tab>
</TabBar>

@ -14,5 +14,7 @@ public partial class AppShell : Shell
Routing.RegisterRoute("settingsPagedetails", typeof(settingsPage));
Routing.RegisterRoute("listPagedetails", typeof(listPage));
Routing.RegisterRoute("fichePagedetails", typeof(ficheAnime));
Routing.RegisterRoute("connexionAdminPagedetails", typeof(loginAdminPage));
Routing.RegisterRoute("createPagedetails", typeof(createOeuvre));
}
}

@ -26,6 +26,7 @@ public partial class NewContent1 : ContentView
async void ListButton_Clicked(object sender, System.EventArgs e)
{
await Shell.Current.GoToAsync("//page/secondaire/listPage");
//await Shell.Current.GoToAsync("//page/secondaire/listPage");
await Navigation.PushAsync(new listPage());
}
}

@ -72,6 +72,12 @@
<Compile Update="CustomHeader.xaml.cs">
<DependentUpon>CustomHeader.xaml</DependentUpon>
</Compile>
<Compile Update="Views\CreateOeuvre.xaml.cs">
<DependentUpon>createOeuvre.xaml</DependentUpon>
</Compile>
<Compile Update="Views\loginAdminPage.xaml.cs">
<DependentUpon>loginAdminPage.xaml</DependentUpon>
</Compile>
<Compile Update="Views\signUpPage.xaml.cs">
<DependentUpon>signUpPage.xaml</DependentUpon>
</Compile>
@ -87,6 +93,9 @@
<MauiXaml Update="Views\Composants\StyleBouton.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\createOeuvre.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\homePage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
@ -96,6 +105,9 @@
<MauiXaml Update="Views\loginPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\loginAdminPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\settingsPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>

@ -15,12 +15,14 @@ namespace MangaMap.Model
public List<Oeuvre> Oeuvres { get; private set; }
public Utilisateur UtilisateurActuel { get; set; }
public bool isAdmin { get; set; }
public Manager(IPersistanceManager Pers) {
Admins = new List<Admin>();
Utilisateurs = new List<Utilisateur>();
Oeuvres = new List<Oeuvre>();
UtilisateurActuel = new Utilisateur();
isAdmin = false;
Persistance = Pers;
}
@ -31,6 +33,7 @@ namespace MangaMap.Model
Utilisateurs = new List<Utilisateur>();
Oeuvres = new List<Oeuvre>();
UtilisateurActuel = new Utilisateur();
isAdmin = false;
}
/*public Utilisateur charger()

@ -36,6 +36,15 @@ namespace MangaMap.Model
Affiche = affiche;
}
public Oeuvre(string nom, string type, string description, int nbEpisode, string affiche)
{
Nom = nom;
Type = type;
Description = description;
NbEpisodes = nbEpisode;
Affiche = affiche;
}
public void AjouterEpisode(int nb)
{
NbEpisodes = NbEpisodes + nb;

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
@ -17,13 +18,13 @@ namespace MangaMap.Model
[DataMember]
public int age { get; private set; }
[DataMember]
public List<Oeuvre> ListeOeuvreEnVisionnage { get; set; }
public ObservableCollection<Oeuvre> ListeOeuvreEnVisionnage { get; set; }
[DataMember]
public List<Oeuvre> ListeOeuvreDejaVu { get; set; }
public ObservableCollection<Oeuvre> ListeOeuvreDejaVu { get; set; }
[DataMember]
public List<Oeuvre> ListeOeuvrePourPlusTard { get; set; }
public ObservableCollection<Oeuvre> ListeOeuvrePourPlusTard { get; set; }
[DataMember]
public List<Oeuvre> ListeOeuvreFavorites { get; set; }
public ObservableCollection<Oeuvre> ListeOeuvreFavorites { get; set; }
public Utilisateur(string email, string pseudo, string mdp, string nom, string prenom, int age)
{
@ -34,17 +35,17 @@ namespace MangaMap.Model
this.prenom = prenom;
this.age = age;
ListeOeuvreEnVisionnage = new List<Oeuvre>();
ListeOeuvreDejaVu = new List<Oeuvre>();
ListeOeuvrePourPlusTard = new List<Oeuvre>();
ListeOeuvreFavorites = new List<Oeuvre>();
ListeOeuvreEnVisionnage = new ObservableCollection<Oeuvre>();
ListeOeuvreDejaVu = new ObservableCollection<Oeuvre>();
ListeOeuvrePourPlusTard = new ObservableCollection<Oeuvre>();
ListeOeuvreFavorites = new ObservableCollection<Oeuvre>();
}
public Utilisateur() {
ListeOeuvreEnVisionnage = new List<Oeuvre>();
ListeOeuvreDejaVu = new List<Oeuvre>();
ListeOeuvrePourPlusTard = new List<Oeuvre>();
ListeOeuvreFavorites = new List<Oeuvre>();
ListeOeuvreEnVisionnage = new ObservableCollection<Oeuvre>();
ListeOeuvreDejaVu = new ObservableCollection<Oeuvre>();
ListeOeuvrePourPlusTard = new ObservableCollection<Oeuvre>();
ListeOeuvreFavorites = new ObservableCollection<Oeuvre>();
}
public void SupprimerUtilisateur()

@ -0,0 +1,52 @@
using System.Text.RegularExpressions;
using MangaMap.Model;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace MangaMap.Views;
public partial class createOeuvre : ContentPage
{
public Manager my_manager => (App.Current as App).MyManager;
public createOeuvre()
{
InitializeComponent();
}
async void AddClicked(object sender, System.EventArgs e)
{
// Récupérer les valeurs des entrées
string nom = nameEntry.Text;
string type = typeEntry.Text;
int nbEp = Convert.ToInt32(nbEpisodeEntry.Text);
string description = descriptionEntry.Text;
foreach (Oeuvre o in my_manager.Oeuvres)
{
if (o.Nom == nom)
{
await DisplayAlert("Erreur", "L'oeuvre existe déjà.", "OK");
return;
}
}
if (string.IsNullOrWhiteSpace(nom) ||
string.IsNullOrWhiteSpace(description) || string.IsNullOrWhiteSpace(type))
{
await DisplayAlert("Erreur", "Veuillez remplir tous les champs.", "OK");
return;
}
if (nbEp < 0)
{
await DisplayAlert("Erreur", "Il faut avoir au 1 épisode pour l'application.", "OK");
return;
}
Oeuvre oeuv = new Oeuvre(nom, type, description, nbEp, "logo.png");
my_manager.Oeuvres.Add(oeuv);
my_manager.sauvegarder();
await Navigation.PushAsync(new homePage());
return;
}
}

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MangaMap.Views.createOeuvre"
Background="{StaticResource Secondary}">
<VerticalStackLayout>
<Label Text="Création d'une nouvelle série" FontSize="Title" Margin="0,0,0,20" TextColor="#ffffff"/>
<Entry x:Name="nameEntry" Placeholder="Nom" Margin="0,0,0,10" Style="{StaticResource Champs}"/>
<Entry x:Name="typeEntry" Placeholder="Type" Margin="0,0,0,10" Style="{StaticResource Champs}"/>
<Entry x:Name="descriptionEntry" Placeholder="Description" Margin="0,0,0,10" Style="{StaticResource Champs}"/>
<Entry x:Name="nbEpisodeEntry" Placeholder="Nombre d'épisodes" Margin="0,0,0,10" Style="{StaticResource Champs}"/>
<Button Text="Ajouter série" Style="{StaticResource Bouton}" Clicked="AddClicked"/>
</VerticalStackLayout>
</ContentPage>

@ -11,7 +11,7 @@
Grid.Row="1">
<VerticalStackLayout>
<Label Text="Watching" TextColor="White" FontSize="Title" Margin="50,10,0,0" Grid.Row="0"/>
<Label Text="Watching" TextColor="White" FontSize="Large" Margin="50,10,0,0" Grid.Row="0"/>
<Frame Grid.Row="1" BackgroundColor="Black" Margin="20" BorderColor="Black">
<Grid BackgroundColor="#333333" >
@ -37,10 +37,10 @@
<BindableLayout.ItemTemplate>
<DataTemplate>
<Grid Margin="20,0,20,20" ColumnDefinitions="*,*,300,300">
<ImageButton Grid.Column="0" Source="{Binding Affiche}" Style="{StaticResource ImageAnime}" HorizontalOptions="Start"/>
<ImageButton Grid.Column="0" Source="{Binding Affiche}" Style="{StaticResource ImageAnime}" HorizontalOptions="Start" Clicked="AnimeImageClickedList"/>
<Label Grid.Column="1" Text="{Binding Nom}" TextColor="White" FontSize="Medium" VerticalOptions="Center" Margin="15"/>
<Label Grid.Column="2" Text="4/5" TextColor="White" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="Center"/>
<Label Grid.Column="3" Text="10/85" TextColor="White" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="End"/>
<Label Grid.Column="3" Text="{Binding NbEpisodes}" TextColor="White" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="End"/>
</Grid>
</DataTemplate>
@ -50,7 +50,7 @@
</Grid>
</Frame>
<Label Text="Completed" TextColor="White" FontSize="Title" Margin="50,10,0,0" Grid.Row="2"/>
<Label Text="Completed" TextColor="White" FontSize="Large" Margin="50,10,0,0" Grid.Row="2"/>
<Frame Grid.Row="3" BackgroundColor="Black" Margin="20" BorderColor="Black">
<Grid BackgroundColor="#333333" >
@ -76,10 +76,10 @@
<BindableLayout.ItemTemplate>
<DataTemplate>
<Grid Margin="20,0,20,20" ColumnDefinitions="*,*,300,300">
<ImageButton Grid.Column="0" Source="{Binding Affiche}" Style="{StaticResource ImageAnime}" HorizontalOptions="Start"/>
<ImageButton Grid.Column="0" Source="{Binding Affiche}" Style="{StaticResource ImageAnime}" HorizontalOptions="Start" Clicked="AnimeImageClickedList"/>
<Label Grid.Column="1" Text="{Binding Nom}" FontSize="Medium" VerticalOptions="Center" Margin="15"/>
<Label Grid.Column="2" Text="4/5" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="Center"/>
<Label Grid.Column="3" Text="10/85" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="End"/>
<Label Grid.Column="3" Text="{Binding NbEpisodes}" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="End"/>
</Grid>
</DataTemplate>
</BindableLayout.ItemTemplate>
@ -115,10 +115,49 @@
<BindableLayout.ItemTemplate>
<DataTemplate>
<Grid Margin="20,0,20,20" ColumnDefinitions="*,*,300,300">
<ImageButton Grid.Column="0" Source="{Binding Affiche}" Style="{StaticResource ImageAnime}" HorizontalOptions="Start"/>
<ImageButton Grid.Column="0" Source="{Binding Affiche}" Style="{StaticResource ImageAnime}" HorizontalOptions="Start" Clicked="AnimeImageClickedList"/>
<Label Grid.Column="1" Text="{Binding Nom}" FontSize="Medium" VerticalOptions="Center" Margin="15"/>
<Label Grid.Column="2" Text="4/5" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="Center"/>
<Label Grid.Column="3" Text="10/85" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="End"/>
<Label Grid.Column="3" Text="{Binding NbEpisodes}" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="End"/>
</Grid>
</DataTemplate>
</BindableLayout.ItemTemplate>
</VerticalStackLayout>
</ScrollView>
</Grid>
</Frame>
<Label Text="Favorite" TextColor="White" FontSize="Large" Margin="50,10,0,0" Grid.Row="2"/>
<Frame Grid.Row="3" BackgroundColor="Black" Margin="20" BorderColor="Black">
<Grid BackgroundColor="#333333" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Margin="20" Grid.Row="0" ColumnDefinitions="*,300,300">
<Label Grid.Column="0"
Text="Titre" FontSize="Large" TextColor="White"
HorizontalOptions="Start" VerticalOptions="Center"/>
<Label Grid.Column="1"
Text="Score" FontSize="Large" TextColor="White"
HorizontalOptions="Center" VerticalOptions="Center"/>
<Label Grid.Column="2"
Text="Progression" FontSize="Large" TextColor="White"
HorizontalOptions="End" VerticalOptions="Center"/>
</Grid>
<ScrollView Grid.Row="1" VerticalScrollBarVisibility="Always">
<VerticalStackLayout BindableLayout.ItemsSource="{Binding UtilisateurActuel.ListeOeuvreFavorites}" Spacing="10">
<BindableLayout.ItemTemplate>
<DataTemplate>
<Grid Margin="20,0,20,20" ColumnDefinitions="*,*,300,300">
<ImageButton Grid.Column="0" Source="{Binding Affiche}" Style="{StaticResource ImageAnime}" HorizontalOptions="Start" Clicked="AnimeImageClickedList"/>
<Label Grid.Column="1" Text="{Binding Nom}" FontSize="Medium" VerticalOptions="Center" Margin="15"/>
<Label Grid.Column="2" Text="4/5" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="Center"/>
<Label Grid.Column="3" Text="{Binding NbEpisodes}" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="End"/>
</Grid>
</DataTemplate>
</BindableLayout.ItemTemplate>

@ -11,4 +11,14 @@ public partial class listPage : ContentPage
InitializeComponent();
BindingContext = my_manager;
}
private async void AnimeImageClickedList(object sender, EventArgs e)
{
var selectedAnime = (sender as ImageButton)?.BindingContext as Oeuvre;
if (selectedAnime != null)
{
// Naviguez vers la page de la fiche d'anime en passant l'objet sélectionné
await Navigation.PushAsync(new ficheAnime(selectedAnime));
}
}
}

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MangaMap.Views.loginAdminPage"
Background="#1E1E1E">
<StackLayout VerticalOptions="Center" HorizontalOptions="Center">
<Label Text="Se connecter à MapManga (ADMIN)" FontSize="Large" Margin="0,0,0,20" TextColor="#FFFFFF"/>
<Entry x:Name="pseudoEntry" Placeholder="Pseudo" Margin="0,0,0,10" Style="{StaticResource Champs}"/>
<Entry x:Name="passwordEntry" Placeholder="Mot de passe" Margin="0,0,0,20" Style="{StaticResource ChampsMdp}"/>
<Button Text="Se connecter" Clicked="OnLoginClicked" Style="{StaticResource Bouton}" />
<StackLayout Orientation="Horizontal" HorizontalOptions="Center">
<Label Text="Pas admin ? " TextColor="#FFFFFF" Margin="0,12,5,0"/>
<Button Text="Se connecter en utilisateur" TextColor="{StaticResource Primary}" BackgroundColor="{StaticResource Secondary}" Clicked="userClicked"/>
</StackLayout>
</StackLayout>
</ContentPage>

@ -0,0 +1,47 @@
namespace MangaMap.Views;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using MangaMap.Stub;
using MangaMap.Model;
public partial class loginAdminPage : ContentPage
{
public Manager my_manager => (App.Current as App).MyManager;
public loginAdminPage()
{
InitializeComponent();
}
async void userClicked(object sender, EventArgs e)
{
await Shell.Current.GoToAsync("//page/secondaire/inscriptionPage");
}
async void OnLoginClicked(object sender, EventArgs e)
{
// Récupération du pseudo et du mot de passe entrés
string pseudo = pseudoEntry.Text;
string password = passwordEntry.Text;
if (string.IsNullOrWhiteSpace(pseudo) ||
string.IsNullOrWhiteSpace(password))
{
await DisplayAlert("Erreur", "Veuillez remplir tous les champs.", "OK");
return;
}
// Vérifier que l'admin existe
Admin admin = my_manager.Admins.FirstOrDefault(a => a.Pseudo == pseudo && a.MotDePasse == password);
if (admin == null)
{
await DisplayAlert("Erreur", "Le mot de passe entré est incorrect.", "OK");
return;
}
// On garde la connection admin
my_manager.isAdmin = true;
// Rediriger l'utilisateur vers la page principale
await Shell.Current.GoToAsync("//page/homePage");
}
}

@ -12,7 +12,9 @@
<Button Text="Deconnexion" Clicked="OnDisconnectClicked" Margin="0,0,0,30" Style="{StaticResource Bouton}"/>
<Button Text="Connexion/Inscription" Clicked="OnLoginClicked" Style="{StaticResource Bouton}"/>
<Button Text="Connexion Admin" Clicked="LoginAdminClicked" Style="{StaticResource Bouton}"/>
<Button Text="Ajouter une série" Clicked="AddClicked" Style="{StaticResource Bouton}"/>
</StackLayout>
</Grid>

@ -13,11 +13,22 @@ public partial class settingsPage : ContentPage
private async void OnDisconnectClicked(object sender, EventArgs e)
{
my_manager.UtilisateurActuel = new Utilisateur();
my_manager.isAdmin = false;
await Shell.Current.Navigation.PushAsync(new loginPage());
}
private void OnLoginClicked(object sender, EventArgs e)
private async void LoginAdminClicked(object sender, EventArgs e)
{
//
await Shell.Current.Navigation.PushAsync(new loginAdminPage());
}
private async void AddClicked(object sender, EventArgs e)
{
if(my_manager.isAdmin)
{
await Shell.Current.Navigation.PushAsync(new createOeuvre());
}
await DisplayAlert("Erreur", "Vous n'êtes pas connecté en tant qu'Administrateur.", "OK");
return;
}
}
Loading…
Cancel
Save