todo en cours
This commit is contained in:
parent
9287f531d2
commit
efb86420d0
10 changed files with 143 additions and 87 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
16
src/app/services/todo.service.spec.ts
Normal file
16
src/app/services/todo.service.spec.ts
Normal 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();
|
||||
});
|
||||
});
|
||||
30
src/app/services/todo.service.ts
Normal file
30
src/app/services/todo.service.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { Todo } from '../interfaces/todo';
|
||||
|
||||
@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(todo:Todo): Observable<any> {
|
||||
console.log(todo);
|
||||
return this.http.post(`${this.apiUrl}/taches/add`, todo);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue