Liste Recettes
-
+
+
+
+
-
diff --git a/daidokoro/src/app/component/accueil/accueil.component.ts b/daidokoro/src/app/component/accueil/accueil.component.ts
index 4d1f7d3..21f82a7 100644
--- a/daidokoro/src/app/component/accueil/accueil.component.ts
+++ b/daidokoro/src/app/component/accueil/accueil.component.ts
@@ -3,20 +3,45 @@ import {RecipeListComponent} from "../recipe-list/recipe-list.component";
import {RecipeFormComponent} from "../recipe-form/recipe-form.component";
import {Recipe} from "../../model/recipe.model";
import {RecipeService} from "../../service/recipe.service";
+import {NgForOf, NgIf} from "@angular/common";
+import {LinkService} from "../../service/link.service";
+import {Link} from "../../model/link.model";
+import {LoginService} from "../../service/login.service";
+import {RouterLink, RouterLinkActive,RouterOutlet} from "@angular/router";
+
@Component({
selector: 'app-accueil',
standalone: true,
imports: [
RecipeListComponent,
- RecipeFormComponent
+ RecipeFormComponent,
+ NgIf,
+ NgForOf,
+ RouterLink,
+ RouterOutlet,
+ RouterLinkActive
],
templateUrl: './accueil.component.html'
})
export class AccueilComponent {
+ isFormVisible: boolean = false;
+ links: Link[] = this.linkService.getLinks()
+
+
+ constructor(private recipeService: RecipeService,private linkService: LinkService,private loginService: LoginService) {
+ if(this.loginService.isLogged()){
+ this.links.push({$name: '/logout',$link: '/logout'});
+ }else{
+ this.links.push({$name: '/login',$link: '/login'});
+ }
+ }
- constructor(private recipeService: RecipeService){}
onRecipeSubmitted(recipe : Recipe){
this.recipeService.addRecipe(recipe);
}
+
+ toggleForm() {
+ this.isFormVisible = !this.isFormVisible;
+ }
}
diff --git a/daidokoro/src/app/component/recipe-list/recipe-list.component.html b/daidokoro/src/app/component/recipe-list/recipe-list.component.html
index 1bf4ed4..2809b44 100644
--- a/daidokoro/src/app/component/recipe-list/recipe-list.component.html
+++ b/daidokoro/src/app/component/recipe-list/recipe-list.component.html
@@ -1,77 +1,95 @@
-
-
-
-
-
-

-
-
{{recipe.$name}}
-
{{recipe.$description}}
-
+
+
+
+
+

+
+
{{recipe.$name}}
+
{{recipe.$description}}
+
+
-
+
diff --git a/daidokoro/src/app/component/recipe-list/recipe-list.component.ts b/daidokoro/src/app/component/recipe-list/recipe-list.component.ts
index b0e1d60..f09e231 100644
--- a/daidokoro/src/app/component/recipe-list/recipe-list.component.ts
+++ b/daidokoro/src/app/component/recipe-list/recipe-list.component.ts
@@ -1,7 +1,7 @@
-import { Component, OnInit } from '@angular/core';
+import {Component, Input, OnInit} from '@angular/core';
import { RecipeService } from '../../service/recipe.service';
import { Recipe } from '../../model/recipe.model';
-import {NgOptimizedImage} from "@angular/common";
+import {NgClass, NgOptimizedImage} from "@angular/common";
import {NgFor} from "@angular/common";
@Component({
@@ -9,16 +9,44 @@ import {NgFor} from "@angular/common";
templateUrl: './recipe-list.component.html',
imports: [
NgOptimizedImage,
- NgFor
+ NgFor,
+ NgClass
],
standalone: true
})
export class RecipeListComponent implements OnInit {
recipes: Recipe[] = [];
+ @Input() isFormVisible!: boolean;
+
+ currentPage: number = 0;
+ pageSize: number = 4;
+ totalPages: any = 0;
constructor(private recipeService: RecipeService) {}
ngOnInit(): void {
this.recipes = this.recipeService.getRecipes();
+ this.totalPages = Math.ceil(this.recipes.length / this.pageSize);
+ }
+
+ get paginatedRecipes(): any[] {
+ const startIndex = this.currentPage * this.pageSize;
+ return this.recipes.slice(startIndex, startIndex + this.pageSize);
+ }
+
+ changePage(index: number): void {
+ this.currentPage = index;
+ }
+
+ previousPage(): void {
+ if (this.currentPage > 0) {
+ this.currentPage--;
+ }
+ }
+
+ nextPage(): void {
+ if (this.currentPage < this.totalPages - 1) {
+ this.currentPage++;
+ }
}
}
diff --git a/daidokoro/src/app/data/link.stub.ts b/daidokoro/src/app/data/link.stub.ts
index 1579d01..a4fe53c 100644
--- a/daidokoro/src/app/data/link.stub.ts
+++ b/daidokoro/src/app/data/link.stub.ts
@@ -1,6 +1,5 @@
import {Link} from "../model/link.model";
export var LINKS :Link[] = [
- {$name:"Lien1",$link:"Lien1"},
- {$name:"Lien2",$link:'Lien2'}
+ {$name:"/Accueil",$link:""}
]