feat: Ajout d'une tâche
This commit is contained in:
@@ -5,7 +5,13 @@ import { Observable } from 'rxjs';
|
||||
@Service()
|
||||
export class BaseService {
|
||||
private readonly http: HttpClient = inject(HttpClient);
|
||||
protected get<T>(url: string):Observable<T> {
|
||||
return this.http.get<T>(url);
|
||||
private readonly baseAddress: string = "http://127.0.0.1:8080/";
|
||||
|
||||
protected get<T>(url: string): Observable<T> {
|
||||
return this.http.get<T>(this.baseAddress + url);
|
||||
}
|
||||
|
||||
protected post<T>(url: string, body: T): Observable<T> {
|
||||
return this.http.post<T>(this.baseAddress + url, body);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ import { BaseService } from './base.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Group } from '../model/Group';
|
||||
@Service()
|
||||
export class GroupService extends BaseService{
|
||||
public getGroups():Observable<Group[]>{
|
||||
return this.get<Group[]>("http://127.0.0.1:8080/group");
|
||||
export class GroupService extends BaseService {
|
||||
public getGroups(): Observable<Group[]> {
|
||||
return this.get<Group[]>("group");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,6 @@ import { Project } from '../model/Project';
|
||||
@Service()
|
||||
export class ProjectService extends BaseService {
|
||||
public getProjects(): Observable<Project[]> {
|
||||
return this.get<Project[]>("http://127.0.0.1:8080/project");
|
||||
return this.get<Project[]>("project");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,19 @@ import { Task } from '../model/Task';
|
||||
import { BaseService } from './base.service';
|
||||
|
||||
@Service()
|
||||
export class TaskService extends BaseService{
|
||||
export class TaskService extends BaseService {
|
||||
public getTasks(): Observable<Task[]> {
|
||||
return this.get<Task[]>("http://127.0.0.1:8080/task");
|
||||
return this.get<Task[]>("task");
|
||||
}
|
||||
|
||||
public addTask(name: string, dueDate: string | null, priority: string | null, status: string | null): Observable<Task> {
|
||||
let body: Task = {
|
||||
name_task: name,
|
||||
date_task: new Date(dueDate!),
|
||||
priority_task: parseInt(priority!),
|
||||
status_task: status!,
|
||||
id_task: 0
|
||||
}
|
||||
return this.post<Task>("task/add", body);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user