Compare commits

...

2 Commits

Author SHA1 Message Date
Sylvain 55f4a665f8 feat: suppression d'une tâche 2026-09-23 23:35:28 +02:00
Sylvain c09e2655b9 doc: Màj du readme 2026-09-23 13:10:10 +02:00
5 changed files with 91 additions and 76 deletions
+5 -55
View File
@@ -1,59 +1,9 @@
# DoItEarlier
# Do it earlier
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 22.0.4.
Une application *todo list* destinée à un usage personnel. Ses fonctionnalités sont fortement inspirées par Todoist, dont l'abonnement payant m'a poussé à créer ma propre version.
## Development server
# Stack
To start a local development server, run:
Application web réalisée en angular 22.0.4 et node.js 24.18.0.
```bash
ng serve
```
Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.
## Code scaffolding
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
```bash
ng generate component component-name
```
For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
```bash
ng generate --help
```
## Building
To build the project run:
```bash
ng build
```
This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed.
## Running unit tests
To execute unit tests with the [Vitest](https://vitest.dev/) test runner, use the following command:
```bash
ng test
```
## Running end-to-end tests
For end-to-end (e2e) testing, run:
```bash
ng e2e
```
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
## Additional Resources
For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
Elle utilise une API maison interrogeant une base de données privée self-hosted.
+6
View File
@@ -14,4 +14,10 @@ export class BaseService {
protected post<T>(url: string, body: T): Observable<T> {
return this.http.post<T>(this.baseAddress + url, body);
}
protected delete<T>(url: string): Observable<T> {
return this.http.delete<T>(`${this.baseAddress}${url}`);
}
}
+8 -1
View File
@@ -9,7 +9,10 @@ export class TaskService extends BaseService {
return this.get<Task[]>("task");
}
public addTask(name: string, dueDate: string | null, priority: string | null, status: string | null): Observable<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!),
@@ -19,4 +22,8 @@ export class TaskService extends BaseService {
}
return this.post<Task>("task/add", body);
}
public deleteTask(id_task: number): Observable<void> {
return this.delete<void>(`task/delete?id=${id_task}`);
}
}
+5 -1
View File
@@ -6,12 +6,16 @@
Section tâches
</h2>
<div>
<div>
@for (task of tasks(); track task.id_task) {
<p>
{{ task.name_task }}
</p>
}
<button (click)="deleteTask(task.id_task)">Supprimer la tâche </button>
}
</div>
<br/>
<button (click)="toggleTaskForm()">
Ajouter une tâche
</button>
+67 -19
View File
@@ -49,17 +49,32 @@ export class Home {
//#endregion
public ngOnInit(): void {
this.taskService.getTasks().subscribe((response: Task[]): void => {
this.tasks.set(response);
this.taskService.getTasks().subscribe({
next: (response: Task[]) => {
this.tasks.set(response);
},
error: (error) => {
console.error(`Récupération des tâches impossible\nErreur:${error.error.message}`);
}
});
this.groupService.getGroups().subscribe((response: Group[]): void => {
this.groups.set(response);
this.groupService.getGroups().subscribe({
next: (response: Group[]) => {
this.groups.set(response);
},
error: (error) => {
console.error(`Récupération des groupes impossible\nErreur:${error.error.message}`);
}
});
this.projectService.getProjects().subscribe((response: Project[]): void => {
this.projects.set(response);
})
this.projectService.getProjects().subscribe({
next: (response: Project[]) => {
this.projects.set(response);
},
error: (error) => {
console.error(`Récupération des projets impossible\nErreur:${error.error.message}`);
}
});
}
public toggleTaskForm(): void {
@@ -75,10 +90,33 @@ export class Home {
this.newTaskForm.controls.priority.value,
this.newTaskForm.controls.status.value);
response.subscribe(response => {
this.tasks.update(values => {
return [...values, response];
});
response.subscribe({
next: (response) => {
this.tasks.update(values => {
return [...values, response];
});
},
error: (error) => {
console.error(`L'ajout de tâche est impossible\nErreur:${error.error.message}`);
}
});
}
/**
* deleteTask
*/
public deleteTask(id_task: number) {
let response: Observable<void> = this.taskService.deleteTask(id_task);
response.subscribe({
next: () => {
this.tasks.update((tasks) => {
return tasks.filter(((task) => task.id_task != id_task));
});
},
error: (error) => {
console.error(`La suppression de tâche est impossible\nErreur:${error.error.message}`);
}
});
}
@@ -92,10 +130,15 @@ export class Home {
public submitGroup() {
let response: Observable<Group> = this.groupService.addGroup(this.newGroupForm.controls.name.value!);
response.subscribe(response => {
this.groups.update(values => {
return [...values, response];
});
response.subscribe({
next: (response) => {
this.groups.update(values => {
return [...values, response];
});
},
error: (error) => {
console.error(`L'ajout d'un groupe est impossible\nErreur:${error.error.message}`);
}
});
}
@@ -109,10 +152,15 @@ export class Home {
public submitProject() {
let response: Observable<Project> = this.projectService.addProject(this.newProjectForm.controls.name.value!);
response.subscribe(response => {
this.projects.update(values => {
return [...values, response];
});
response.subscribe({
next: (response) => {
this.projects.update(values => {
return [...values, response];
});
},
error: (error) => {
console.error(`L'ajout d'un projet est impossible\nErreur:${error.error.message}`);
}
});
}
}