Merge branch 'dev' into blandine

This commit is contained in:
AlineRinquin 2022-02-16 17:32:57 +01:00 committed by GitHub
commit a3b89e4043
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 367 additions and 204 deletions

6
package-lock.json generated
View file

@ -14196,6 +14196,12 @@
"resolved": "https://registry.npmjs.org/bootstrap-icons/-/bootstrap-icons-1.8.1.tgz", "resolved": "https://registry.npmjs.org/bootstrap-icons/-/bootstrap-icons-1.8.1.tgz",
"integrity": "sha512-IXUqislddPJfwq6H+2nTkHyr9epO9h6u1AG0OZCx616w+TgzeoCjfmI3qJMQqt1J586gN2IxzB4M99Ip4sTZ1w==" "integrity": "sha512-IXUqislddPJfwq6H+2nTkHyr9epO9h6u1AG0OZCx616w+TgzeoCjfmI3qJMQqt1J586gN2IxzB4M99Ip4sTZ1w=="
}, },
"bootstrap-icons": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/bootstrap-icons/-/bootstrap-icons-1.8.1.tgz",
"integrity": "sha512-IXUqislddPJfwq6H+2nTkHyr9epO9h6u1AG0OZCx616w+TgzeoCjfmI3qJMQqt1J586gN2IxzB4M99Ip4sTZ1w=="
},
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",

View file

@ -12,7 +12,8 @@
</div> </div>
<div class="row align-items-center"> <div class="row align-items-center">
<div class="col-md-6 offset-md-3"> <div class="col-md-6 offset-md-3">
<img style="max-height: 12% ; max-width: 12%" src="../../../assets/images/contact-1.png"/> <p class="fiche-contact" >
{{ personne.couleur }}</p>
<p class="fiche-contact" >{{ personne.prenom }} {{ personne.nom }}</p> <p class="fiche-contact" >{{ personne.prenom }} {{ personne.nom }}</p>
<p class="fiche-contact" ><img style="max-height: 12% ; max-width: 12%" src="../../../assets/images/phone.png"/> <p class="fiche-contact" ><img style="max-height: 12% ; max-width: 12%" src="../../../assets/images/phone.png"/>
{{ personne.telephone }}</p> {{ personne.telephone }}</p>

View file

@ -14,6 +14,7 @@ export class FicheContactComponent implements OnInit {
ngOnInit(): void {} ngOnInit(): void {}
onClickDelete(numPerson: number){ onClickDelete(numPerson: number){
window.alert("Le contact à bien été supprimé!")
this.clickDelete.emit(numPerson); this.clickDelete.emit(numPerson);
} }
} }

View file

@ -1,40 +1,55 @@
<input
type="text"
class="todo-title"
placeholder="Titre"
value = "{{todo.nom}}"
/>
<div>
<button (click)="effacerList()">Effacer la To Do List</button>
</div>
<input <input
type="text" type="text"
class="todo-input" class="todo-input"
placeholder="Ajoute une nouvelle Tâche" placeholder="+ Nouvelle Tâche"
[(ngModel)]="todoTitle" [(ngModel)]="todoTitle"
(keyup.enter)="addTitle()" (keyup.enter)="addTache(todo.id)"
/> />
<div class="element" *ngFor="let todo of todosFilter()">
<div class="element" *ngFor="let tache of todo.taches">
<div class="element-gauche"> <div class="element-gauche">
<input <input
type="checkbox" type="checkbox"
[(ngModel)]="todo.completed" [(ngModel)]="tache.etat"
(change)="doneEdit(todo)" (change)="doneEdit(tache)"
checked="checked"
/> />
<div <div
*ngIf="!todo.editing; else editingTodo" *ngIf="!tache.editing; else editingTodo"
class="nomTache" class="nomTache"
[ngClass]="{ completed: todo.completed }" [ngClass]="{ completed: tache.etat }"
(dblclick)="modifier(todo)" (dblclick)="modifier(tache)"
> >
{{ todo.title }} {{ tache.texte }}
</div> </div>
<ng-template #editingTodo> <ng-template #editingTodo>
<input <input
type="text" type="text"
class="modifier-element" class="modifier-element"
[(ngModel)]="todo.title" [(ngModel)]="tache.texte"
(blur)="doneEdit(todo)" (blur)="doneEdit(tache)"
(keyup.enter)="doneEdit(todo)" (keyup.enter)="doneEdit(tache)"
(keyup.esc)="cancelEdit(todo)" (keyup.esc)="cancelEdit(tache)"
autofocus autofocus
/> />
</ng-template> </ng-template>
</div> </div>
<div class="deleteTache" (click)="deleteTodo(todo.id)">&times;</div> <div class="deleteTache" (click)="deleteTodo(tache.id)">&times;</div>
</div> </div>
<div class="extra-container"> <div class="extra-container">
<div> <div>
<label <label
@ -48,7 +63,7 @@
<div>{{ toDoRest() }} tâches</div> <div>{{ toDoRest() }} tâches</div>
</div> </div>
<div class="extra-container"> <div class="extra-container">
<div> <!-- <div>
<button [ngClass]="{ active: filter === 'tous' }" (click)="filter = 'tous'"> <button [ngClass]="{ active: filter === 'tous' }" (click)="filter = 'tous'">
Toutes la To Do List Toutes la To Do List
</button> </button>
@ -65,8 +80,6 @@
Terminées Terminées
</button> </button>
</div> </div>
-->
<div>
<button (click)="effacerList()">Effacer la To Do List</button>
</div>
</div> </div>

View file

@ -1,5 +1,15 @@
.todo-title {
width: 25%;
padding: 10px 18px;
font-size: xx-large;
margin-bottom: 16px;
&:focus {
outline: 0;
}
}
.todo-input { .todo-input {
width: 100%; width: 20%;
padding: 10px 18px; padding: 10px 18px;
font-size: 18px; font-size: 18px;
margin-bottom: 16px; margin-bottom: 16px;
@ -7,6 +17,8 @@
outline: 0; outline: 0;
} }
} }
.element { .element {
margin-bottom: 12px; margin-bottom: 12px;
display: flex; display: flex;
@ -16,6 +28,7 @@
} }
.deleteTache { .deleteTache {
width: 75%;
cursor: pointer; cursor: pointer;
margin-left: 14px; margin-left: 14px;
&:hover { &:hover {
@ -40,11 +53,12 @@
margin-left: 12px; margin-left: 12px;
width: 100%; width: 100%;
padding: 10px; padding: 10px;
border: 1px solid #ccc; //override defaults border: 1px solid rgb(204, 204, 204); //override defaults
font-family: 'Avenir', Helvetica, Arial, sans-serif; font-family: 'Avenir', Helvetica, Arial, sans-serif;
&:focus { &:focus {
outline: none; outline: none;
background-color:aquamarine;
} }
} }
@ -53,15 +67,6 @@
color: grey; color: grey;
} }
.extra-container {
display: flex;
align-items: center;
justify-content: space-between;
font-size: 16px;
border-top: 1px solid lightgrey;
padding-top: 14px;
margin-bottom: 14px;
}
button { button {
font-size: 14px; font-size: 14px;

View file

@ -1,5 +1,9 @@
import { Component, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { Todo } from 'src/app/interfaces/todo'; import { Router } from '@angular/router';
import { Tache} from 'src/app/models/tache';
import { ToDoList} from 'src/app/models/to-do-list';
import { TodoService } from 'src/app/services/todo.service';
import { TodoList } from 'src/app/todo-list';
@Component({ @Component({
selector: 'app-to-do-list', selector: 'app-to-do-list',
@ -7,22 +11,26 @@ import { Todo } from 'src/app/interfaces/todo';
styleUrls: ['./to-do-list.component.scss'], styleUrls: ['./to-do-list.component.scss'],
}) })
export class ToDoListComponent implements OnInit { export class ToDoListComponent implements OnInit {
@Input() todo!: ToDoList;
public beforeEditCache: string; public beforeEditCache: string;
public todos: Todo[]; //public todos: ToDoList[];
public todoTitle: string; public todoTitle: string;
public idTodo: number; public idTodo: number;
public filter : string; public filter : string;
public casesRestantes : boolean; public casesRestantes : boolean;
public masterSelected: boolean; public masterSelected: boolean;
public result : any;
public tache : Tache [];
constructor() { constructor(private TodoService : TodoService, private router: Router ) {
this.beforeEditCache = ''; this.beforeEditCache = '';
this.todos = []; //this.todos = [];
this.todoTitle = ''; this.todoTitle = '';
this.idTodo = 0; this.idTodo = 0;
this.filter =''; this.filter ='';
this.casesRestantes=true; this.casesRestantes=true;
this.masterSelected= false; this.masterSelected= false;
this.tache = [];
} }
ngOnInit(): void { ngOnInit(): void {
@ -31,89 +39,78 @@ export class ToDoListComponent implements OnInit {
this.filter='tous'; this.filter='tous';
this.idTodo = 4; this.idTodo = 4;
this.todoTitle = ''; this.todoTitle = '';
this.todos = [
{
id: 1,
title: 'Finish Angular Screencast',
completed: false,
editing: false,
},
{
id: 2,
title: 'Take over world',
completed: false,
editing: false,
},
{
id: 3,
title: 'One more thing',
completed: false,
editing: false,
},
];
} }
//ajouter tache //ajouter tache
addTitle(): void {
if (this.todoTitle.trim().length === 0) {
return;
}
this.todos.push({ addTache(idTodoList : number) {//idTodoList id que la todoList que l'on récupère
id: this.idTodo, console.log(idTodoList);
title: this.todoTitle, const tache: Tache = {
completed: false, id : 0,
editing: false, texte: this.todoTitle,
}); etat : false,
this.todoTitle = ''; editing : false,
this.idTodo++;
}
console.log(this.tache);
this.TodoService.addTache(tache,idTodoList).subscribe((resp)=>{
window.location.reload();
})
} }
//modifier la tâche //modifier la tâche
modifier(todo: Todo): void { modifier(tache: Tache): void {
this.beforeEditCache = todo.title; this.beforeEditCache = tache.texte;
todo.editing = true; tache.editing = true;
} }
// modifier l'apparence focus // modifier l'apparence focus
doneEdit(todo: Todo): void { doneEdit(tache: Tache): void {
if (todo.title.trim().length === 0) { if (tache.texte.trim().length === 0) {
todo.title = this.beforeEditCache; tache.texte = this.beforeEditCache;
} }
this.casesRestantes= this.casesQuiRestes(); this.casesRestantes= this.casesQuiRestes();
todo.editing = false; tache.editing = false;
} }
// annuler la modification // annuler la modification
cancelEdit(todo: Todo): void { cancelEdit(tache: Tache): void {
todo.title = this.beforeEditCache; tache.texte = this.beforeEditCache;
todo.editing = false; tache.editing = false;
} }
//supprimer la tache //supprimer la tache
deleteTodo(id: number): void { deleteTodo(id: number) {
this.todos = this.todos.filter((todo) => todo.id !== id); this.TodoService.deleteTacheById(id).subscribe(
} resp =>{
window.location.reload();
}
);}
//nombre de tâches restantes //nombre de tâches restantes
toDoRest(): number{ toDoRest(): number{
return this.todos.filter(todo=> !todo.completed).length; return this.todo.taches.filter((tache: Tache)=> !tache.etat).length;
} }
//Cocher toutes les tâches de la liste //Cocher toutes les tâches de la liste
listComplete(): boolean { listComplete(): boolean {
return this.todos.filter(todo=> todo.completed).length>0; return this.todo.taches.filter((tache: Tache)=> tache).length>0;
} }
//Effacer la to do list //Effacer la to do list
effacerList(): void { effacerList(): void {
this.todos = []; //this.todo = [];
} }
//cocher toutes les cases de la todoList //cocher toutes les cases de la todoList
cocherAllTodoList(): void { cocherAllTodoList(): void {
for (var i = 0; i < this.todos.length; i++) { for (var i = 0; i < this.todo.taches.length; i++) {
this.todos[i].completed = this.masterSelected; this.todo.taches[i].etat = this.masterSelected;
} }
this.cocherAllTodoList(); this.cocherAllTodoList();
} }
@ -123,16 +120,16 @@ export class ToDoListComponent implements OnInit {
} }
//barre de filtre des tâches //barre de filtre des tâches
todosFilter(): Todo[] { /* todosFilter(): ToDoList[] {
if(this.filter === 'tous'){ if(this.filter === 'tous'){
return this.todos return this.todo.taches
}else if (this.filter === 'active'){ }else if (this.filter === 'active'){
return this.todos.filter(todo=> !todo.completed) return this.todo.taches.filter((tache: Tache)=> !tache.etat)
}else if (this.filter === 'complete'){ }else if (this.filter === 'complete'){
return this.todos.filter(todo=>todo.completed) return this.todo.taches.filter((tache: Tache)=>tache.etat)
}
return this.todos
} }
return this.todo
} */
} }

View file

@ -1,7 +1,7 @@
export interface Todo { export interface Todo {
id : number, id : number,
title : string, texte : string,
completed: boolean, etat: boolean,
editing: boolean // todoListId: number // FK
} }

View file

@ -1,5 +1,6 @@
export interface Contact { export interface Contact {
id: string; id: string;
couleur: string;
nom: string; nom: string;
prenom: string; prenom: string;
telephone: string; telephone: string;

10
src/app/models/tache.ts Normal file
View file

@ -0,0 +1,10 @@
import { ToDoList } from './to-do-list';
export interface Tache {
id : number,
texte: string,
etat : boolean,
editing : boolean
}

View file

@ -1,7 +1,11 @@
import { Tache } from './tache';
import { Team } from './team'; import { Team } from './team';
export interface ToDoList { export interface ToDoList {
nom: string; nom: string;
team: Team; team: Team;
tache: string; taches: Tache [];
id:number;
} }

View file

@ -3,10 +3,14 @@
<app-side-bar></app-side-bar> <app-side-bar></app-side-bar>
</div> </div>
<div class="ajoutContact-form text-center"> <div class="ajoutContact-form text-center">
<h1>Ajouter un contact</h1>
<main class="form-ajoutContact"> <main class="form-ajoutContact">
<form (ngSubmit)="onSubmit()" [formGroup]="ajoutContactForm"> <form (ngSubmit)="onSubmit()" [formGroup]="ajoutContactForm">
<h1>Ajouter un contact</h1>
<div class="form-floating">
<input type="color" class="form-control" id="floatingInputcouleur" placeholder="" name="couleur"
formControlName="couleurFc">
</div>
<div class="form-floating"> <div class="form-floating">
<input type="text" <input type="text"

View file

@ -1,14 +1,20 @@
.login-form { .login-form {
height: 100vh; height: 100vh;
padding-top: 40px; padding-top: 40px;
background-color: #f5f5f5; background-color: #e286d3;
} }
.form-ajoutContact { .form-ajoutContact {
width: 100%; width: 100%;
max-width: 330px; max-width: 330px;
padding: 15px; padding: 15px;
margin: auto; margin-top: 50px;
margin-left: auto;
margin-right: auto;
border: solid 1px;
border-radius: 10px;
background-color: #fcddec;
border-color: #81164d;
} }
.form-ajoutContact .checkbox { .form-ajoutContact .checkbox {
@ -20,12 +26,45 @@
} }
.form-ajoutContact input[type="email"] { .form-ajoutContact input[type="email"] {
margin-bottom: -1px; margin-bottom: 10px;
border-bottom-right-radius: 0; border-bottom-right-radius: 0;
border-bottom-left-radius: 0; border-bottom-left-radius: 0;
} }
.form-ajoutContact input[type="color"] {
border: none;
margin-bottom: 10px;
margin-top: -70px;
margin-left: 100px;
border-radius: 50%;
width: 100px;
height: 100px;
}
.form-ajoutContact input[type="color"]::-webkit-color-swatch {
border: none;
margin-top: -15px;
border-radius: 80%;
width: 80px;
height: 80px;
}
.form-ajoutContact input[type="text"] {
margin-bottom: 10px;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}
.form-ajoutContact input[type="date"] {
margin-bottom: 10px;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}
.btn-secondary { .btn-secondary {
color: #fff; margin-top: 10px;
background-color: #ffff;
color: rgb(255, 255, 255);
background-color: #5a1e63 !important; background-color: #5a1e63 !important;
} }

View file

@ -6,6 +6,7 @@ import {
Validators, Validators,
} from '@angular/forms'; } from '@angular/forms';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { TokenService } from 'src/app/services/token.service';
import { Contact } from '../../models/contact'; import { Contact } from '../../models/contact';
import { RepertoireService } from '../../services/repertoire.service'; import { RepertoireService } from '../../services/repertoire.service';
@ -19,6 +20,7 @@ export class PageAjoutContactComponent implements OnInit {
constructor( constructor(
private repertoireService: RepertoireService, private repertoireService: RepertoireService,
private tokenService: TokenService,
private router: Router, private router: Router,
private fb: FormBuilder private fb: FormBuilder
) { ) {
@ -42,24 +44,25 @@ export class PageAjoutContactComponent implements OnInit {
} }
public onSubmit(): void { public onSubmit(): void {
console.log('value : ', this.ajoutContactForm.value); const couleurValue = this.ajoutContactForm.value['couleurFc'];
console.log('form : ', this.ajoutContactForm);
const firstNameValue = this.ajoutContactForm.value['firstNameFc']; const firstNameValue = this.ajoutContactForm.value['firstNameFc'];
const lastNameValue = this.ajoutContactForm.value['lastNameFc']; const lastNameValue = this.ajoutContactForm.value['lastNameFc'];
const telephoneValue = this.ajoutContactForm.value['telephoneFc']; const telephoneValue = this.ajoutContactForm.value['telephoneFc'];
const emailValue = this.ajoutContactForm.value['emailFc']; const emailValue = this.ajoutContactForm.value['emailFc'];
const dateNaissanceValue = this.ajoutContactForm.value['dateNaissanceFc']; const dateNaissanceValue = this.ajoutContactForm.value['dateNaissanceFc'];
const adresseValue = this.ajoutContactForm.value['adresseFc']; const adresseValue = this.ajoutContactForm.value['adresseFc'];
const teamId = this.tokenService.getCurrentTeamId()
const contact: Contact = { const contact: Contact = {
id: '', id: '',
couleur: couleurValue,
nom: lastNameValue, nom: lastNameValue,
prenom: firstNameValue, prenom: firstNameValue,
telephone: telephoneValue, telephone: telephoneValue,
email: emailValue, email: emailValue,
dateNaissance: dateNaissanceValue, dateNaissance: dateNaissanceValue,
adresse: adresseValue, adresse: adresseValue,
team: { id: '1' }, // changer l'id quand la personne est logé => recuperer l'id de la team du membre team: { id: teamId }, // changer l'id quand la personne est logé => recuperer l'id de la team du membre
}; };
if (contact.nom !== '') { if (contact.nom !== '') {
@ -67,7 +70,7 @@ export class PageAjoutContactComponent implements OnInit {
this.router.navigate(['repertoire/']); this.router.navigate(['repertoire/']);
}); });
} else { } else {
// affichage erreur window.alert("Le contact ne peut pas être ajouté!")
} }
} }
} }

View file

@ -4,10 +4,14 @@
</div> </div>
<div class="modifContact-form text-center"> <div class="modifContact-form text-center">
<h1>Modifier ce contact</h1>
<main class="form-modifContact"> <main class="form-modifContact">
<form (ngSubmit)="onSubmit()" [formGroup]="modifContactForm"> <form (ngSubmit)="onSubmit()" [formGroup]="modifContactForm">
<h1>Modifier ce contact</h1>
<div class="form-floating">
<input type="color" class="form-control" id="floatingInputcouleur" placeholder="" name="couleur"
formControlName="couleurFc">
</div>
<div class="form-floating"> <div class="form-floating">
<input type="text" <input type="text"

View file

@ -8,7 +8,13 @@
width: 100%; width: 100%;
max-width: 330px; max-width: 330px;
padding: 15px; padding: 15px;
margin: auto; margin-top: 50px;
margin-left: auto;
margin-right: auto;
border: solid 1px;
border-radius: 10px;
background-color: #fcddec;
border-color: #81164d;
} }
.form-modifContact .checkbox { .form-modifContact .checkbox {
@ -25,7 +31,40 @@
border-bottom-left-radius: 0; border-bottom-left-radius: 0;
} }
.form-modifContact input[type="color"] {
border: none;
margin-bottom: 10px;
margin-top: -70px;
margin-left: 100px;
border-radius: 50%;
width: 100px;
height: 100px;
}
.form-modifContact input[type="color"]::-webkit-color-swatch {
border: none;
margin-top: -15px;
border-radius: 80%;
width: 80px;
height: 80px;
}
.form-modifContact input[type="text"] {
margin-bottom: 10px;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}
.form-modifContact input[type="date"] {
margin-bottom: 10px;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}
.btn-secondary { .btn-secondary {
color: #fff; margin-top: 10px;
background-color: #ffff;
color: rgb(255, 255, 255);
background-color: #5a1e63 !important; background-color: #5a1e63 !important;
} }

View file

@ -71,8 +71,7 @@ export class PageModifierContactComponent implements OnInit {
//Méthode qui envoie les champs modifiés pour mise à jour //Méthode qui envoie les champs modifiés pour mise à jour
public onSubmit(): void { public onSubmit(): void {
console.log('value : ', this.modifContactForm.value); const couleurValue = this.modifContactForm.value[''];
console.log('form : ', this.modifContactForm);
const firstNameValue = this.modifContactForm.value['firstNameFc']; const firstNameValue = this.modifContactForm.value['firstNameFc'];
const lastNameValue = this.modifContactForm.value['lastNameFc']; const lastNameValue = this.modifContactForm.value['lastNameFc'];
const telephoneValue = this.modifContactForm.value['telephoneFc']; const telephoneValue = this.modifContactForm.value['telephoneFc'];
@ -82,6 +81,7 @@ export class PageModifierContactComponent implements OnInit {
const contact: Contact = { const contact: Contact = {
id: this.personneid, id: this.personneid,
couleur: couleurValue,
nom: lastNameValue, nom: lastNameValue,
prenom: firstNameValue, prenom: firstNameValue,
telephone: telephoneValue, telephone: telephoneValue,

View file

@ -1,31 +1,42 @@
<app-header></app-header> <app-header></app-header>
<app-side-bar></app-side-bar> <div class="row">
<div class="col-md-auto">
<app-side-bar></app-side-bar>
</div>
<div> <div class=" col compte text-center">
<button class="w-100 btn btn-lg btn-secondary " <div>
type="submit">Tous les contacts <button class="w-100 btn btn-lg btn-secondary " type="submit">Tous les contacts
</button> </button>
<button routerLink="/ajouter-contact" class="w-100 btn btn-lg btn-rounded btn-secondary"> <button routerLink="/ajouter-contact" class="w-100 btn btn-lg btn-rounded btn-secondary">
Ajouter un contact Ajouter un contact
</button> </button>
<div class="input-group mb-3"> <div class="input-group mb-3 d-flex justify-content-center">
<input type="text" class="form-control" <input type="text" class="form-control" placeholder="Rechercher un contact"
placeholder="Rechercher un contact" aria-label="Rechercher un contact" aria-describedby="basic-addon2" #word
aria-label="Rechercher un contact" (keyup)="onSearchChange(word.value)">
aria-describedby="basic-addon2"
#word <div class="input-group-append"></div>
(keyup)="onSearchChange(word.value)"> </div>
<div>
<h4>Liste des Contacts</h4>
</div>
<div class="row justify-content-evenly">
<div class="col-4">
<div *ngFor="let personne of listContact" (click)="onClick(personne)">
<img style="max-height: 12% ; max-width: 12%" src="../../../assets/images/contact-1.png" />
<p class="fiche-contact">{{ personne.prenom }} {{ personne.nom }}</p>
</div>
</div>
<div class="input-group-append"> <div class="col-4" *ngIf="openDetails">
<app-fiche-contact [personne]="openDetails" (clickDelete)="onClickDelete($event)"></app-fiche-contact>
</div>
</div>
</div> </div>
</div> </div>
</div>
<div *ngFor="let personne of listContact" (click)="onClick(personne)" >
<img style="max-height: 12% ; max-width: 12%" src="../../../assets/images/contact-1.png"/>
<p class="fiche-contact" >{{ personne.prenom }} {{ personne.nom }}</p>
</div>
<div *ngIf="openDetails"><app-fiche-contact [personne]="openDetails" (clickDelete)="onClickDelete($event)"></app-fiche-contact></div>
</div>

View file

@ -7,9 +7,16 @@
margin: auto; margin: auto;
} }
.input-group mb-3 { .input-group.mb-3 {
width: 100%; width: 50%;
max-width: 330px; max-width: 330px;
padding: 15px; padding: 15px;
margin: auto; margin: auto;
display: flex;
flex-direction: row;
} }
;h4 {
color: black;
font-weight: bold;
}

View file

@ -33,16 +33,6 @@ export class PageRepertoireComponent implements OnInit {
this.listContact = listContact; this.listContact = listContact;
this.listFull = listContact; this.listFull = listContact;
}); });
this.personneid = this.route.snapshot.paramMap.get('id');
console.log(this.personneid);
this.repertoireService
.getContactById(this.personneid)
.subscribe((listContactInfo: any) => {
console.log(listContactInfo);
this.listContactInfo = listContactInfo;
});
} }
// Méthode pour récuper ce qui est saisi dans l'input // Méthode pour récuper ce qui est saisi dans l'input
@ -63,15 +53,20 @@ export class PageRepertoireComponent implements OnInit {
this.listContact = prenom; this.listContact = prenom;
} }
// Méthode qui au click va ouvrir les détails d'un contat // Méthode qui au click va ouvrir les détails d'un contact
onClick(personne: any) { onClick(personne: any) {
console.log(personne); console.log(personne);
this.openDetails = personne; this.openDetails = personne;
} }
// Méthode qui au click va supprimer un contact
onClickDelete(contact: Contact){ onClickDelete(contactId: number){
this.repertoireService.deleteContact(contact).subscribe((resp) => { this.repertoireService.deleteContact(contactId).subscribe((resp) => {
if(contactId) {
this.listContact.forEach(contactId => console.log(contactId))
}else{
window.alert("Le contact ne peut pas être supprimé!")
}
this.router.navigate(['repertoire/']); this.router.navigate(['repertoire/']);
}); });
} }

View file

@ -1,5 +1,9 @@
<app-header></app-header> <app-header></app-header>
<app-side-bar></app-side-bar> <app-side-bar></app-side-bar>
<div class="container"> <div class="d-flex align-items-stretch">
<app-to-do-list></app-to-do-list> <div class="row">
<div class="col" *ngFor="let todos of result">
<app-to-do-list [todo]="todos"> </app-to-do-list>
</div>
</div>
</div> </div>

View file

@ -1,4 +1,7 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { TodoService } from 'src/app/services/todo.service';
@Component({ @Component({
selector: 'app-page-to-do-list', selector: 'app-page-to-do-list',
@ -6,10 +9,18 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./page-to-do-list.component.scss'] styleUrls: ['./page-to-do-list.component.scss']
}) })
export class PageToDoListComponent implements OnInit { export class PageToDoListComponent implements OnInit {
public result : any;
constructor() { } constructor(private TodoService : TodoService) { }
ngOnInit(): void { ngOnInit(): void {
this.TodoService.getToDoListByTeamId().subscribe((data :any)=>{
this.result = data;
console.log(data);
});
} }
} }

View file

@ -3,6 +3,8 @@ import { HttpClient } from '@angular/common/http';
import { map, Observable } from 'rxjs'; import { map, Observable } from 'rxjs';
import { environment } from 'src/environments/environment'; import { environment } from 'src/environments/environment';
import { Contact } from '../models/contact'; import { Contact } from '../models/contact';
import { Router } from '@angular/router';
import { TokenService } from './token.service';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
@ -11,14 +13,15 @@ export class RepertoireService {
apiUrl: string; apiUrl: string;
tokenKey: string; tokenKey: string;
constructor(private http: HttpClient) { constructor(private http: HttpClient, private router: Router, private tokenService: TokenService) {
// On se sert des variables d'environnement de notre application // On se sert des variables d'environnement de notre application
this.apiUrl = environment.apiUrl; this.apiUrl = environment.apiUrl;
this.tokenKey = environment.tokenKey; this.tokenKey = environment.tokenKey;
} }
getContact(): Observable<any> { getContact(): Observable<any> {
return this.http.get(`${this.apiUrl}/contacts/team/1`); const teamId = this.tokenService.getCurrentTeamId()
return this.http.get(`${this.apiUrl}/contacts/team/${teamId}`);
} }
getContactById(id: any): Observable<any> { getContactById(id: any): Observable<any> {
@ -26,16 +29,15 @@ export class RepertoireService {
} }
addContact(contact: Contact): Observable<any> { addContact(contact: Contact): Observable<any> {
console.log(contact); const teamId = this.tokenService.getCurrentTeamId()
return this.http.post(`${this.apiUrl}/contacts/add`, contact); return this.http.post(`${this.apiUrl}/contacts/add`, contact);
} }
deleteContact(contact: Contact): Observable<any> { deleteContact(contactId: number): Observable<any> {
return this.http.delete(`${this.apiUrl}/contacts/delete/1`); return this.http.delete(`${this.apiUrl}/contacts/delete/${contactId}`);
} }
updateContact(contact: Contact): Observable<any> { updateContact(contact: Contact): Observable<any> {
return this.http.put(`${this.apiUrl}/contacts/update/1`, contact); return this.http.put(`${this.apiUrl}/contacts/update/`, contact);
} }
} }

View file

@ -1,43 +0,0 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { environment } from 'src/environments/environment';
@Injectable({
providedIn: 'root'
})
export class TodoServiceService {
private toDoList: any;
private apiUrl: string;
constructor(private http: HttpClient) {
this.apiUrl = environment.apiUrl;
}
//consulter toDoList
getToDoList(){
this.toDoList = this.http.get(`${this.apiUrl}/todolist/team/{team_id}`);
return this.toDoList;
console.log(this.toDoList)
}
//ajouter une tache
addTitle(title:string){
this.toDoList.push({
title:title,
isChecked: false
});
}
// cocher et décocher la checkbox
checkOrUnCheckTitle($key: string,flag: boolean){
this.toDoList.update($key,{isChecked:flag});
}
//supprimer la tache
removeTitle($key : string){
this.toDoList.remove($key);
}
}

View file

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { TodoService } from './todo.service';
describe('TodoService', () => {
let service: TodoService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(TodoService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View file

@ -0,0 +1,31 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { Tache } from '../models/tache';
import { ToDoList } from '../models/to-do-list';
@Injectable({
providedIn: 'root',
})
export class TodoService {
private toDoList: any;
private apiUrl: string;
constructor(private http: HttpClient) {
this.apiUrl = environment.apiUrl;
}
getToDoListByTeamId(): Observable<any> {
return this.http.get(`${this.apiUrl}/todolist/team/1`);
}
deleteTacheById(idTache: any): Observable<any> {
return this.http.delete(`${this.apiUrl}/taches/delete/${idTache}`,{responseType:'text'});
}
addTache(newtache: Tache,idTodoList:number): Observable<any> {
console.log(newtache +'gkggg');
return this.http.post(`${this.apiUrl}/taches/add/${idTodoList}`, newtache);
}
}

2
src/app/todo-list.ts Normal file
View file

@ -0,0 +1,2 @@
export interface TodoList {
}