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

View file

@ -3,6 +3,8 @@ import { HttpClient } from '@angular/common/http';
import { map, Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { Contact } from '../models/contact';
import { Router } from '@angular/router';
import { TokenService } from './token.service';
@Injectable({
providedIn: 'root',
@ -11,14 +13,15 @@ export class RepertoireService {
apiUrl: 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
this.apiUrl = environment.apiUrl;
this.tokenKey = environment.tokenKey;
}
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> {
@ -26,16 +29,15 @@ export class RepertoireService {
}
addContact(contact: Contact): Observable<any> {
console.log(contact);
const teamId = this.tokenService.getCurrentTeamId()
return this.http.post(`${this.apiUrl}/contacts/add`, contact);
}
deleteContact(contact: Contact): Observable<any> {
return this.http.delete(`${this.apiUrl}/contacts/delete/1`);
deleteContact(contactId: number): Observable<any> {
return this.http.delete(`${this.apiUrl}/contacts/delete/${contactId}`);
}
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);
}
}