diff --git a/daidokoro/src/app/app.component.html b/daidokoro/src/app/app.component.html
index 82a24de..aede23f 100644
--- a/daidokoro/src/app/app.component.html
+++ b/daidokoro/src/app/app.component.html
@@ -1,2 +1,80 @@
-
-
+
+
+
+
Liste Recettes
diff --git a/daidokoro/src/app/component/accueil/accueil.component.ts b/daidokoro/src/app/component/accueil/accueil.component.ts
index a9cdaa1..6dac259 100644
--- a/daidokoro/src/app/component/accueil/accueil.component.ts
+++ b/daidokoro/src/app/component/accueil/accueil.component.ts
@@ -5,9 +5,9 @@ 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";
+
import {CommonModule} from "@angular/common";
@Component({
@@ -18,18 +18,14 @@ import {CommonModule} from "@angular/common";
RecipeFormComponent,
CommonModule,
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) {
+ constructor(private recipeService: RecipeService) {
}
@@ -41,18 +37,4 @@ export class AccueilComponent {
this.isFormVisible = !this.isFormVisible;
}
- onClickLogin(event: Event): void {
- event.preventDefault(); // Prevent the default anchor behavior
- this.loginService.login();
- }
-
- onClickLogout(event: Event): void {
- event.preventDefault(); // Prevent the default anchor behavior
- this.loginService.logout();
- }
-
- isLogged(): boolean {
- return this.loginService.isLogged();
- }
-
}
diff --git a/daidokoro/src/app/component/ingredients/ingredients.component.css b/daidokoro/src/app/component/ingredients/ingredients.component.css
new file mode 100644
index 0000000..e69de29
diff --git a/daidokoro/src/app/component/ingredients/ingredients.component.html b/daidokoro/src/app/component/ingredients/ingredients.component.html
new file mode 100644
index 0000000..97f0504
--- /dev/null
+++ b/daidokoro/src/app/component/ingredients/ingredients.component.html
@@ -0,0 +1,50 @@
+
+
+
+
+
+

+
+
{{ ingredient.$name }}
+
+
+
+
+
diff --git a/daidokoro/src/app/component/ingredients/ingredients.component.spec.ts b/daidokoro/src/app/component/ingredients/ingredients.component.spec.ts
new file mode 100644
index 0000000..dc7c651
--- /dev/null
+++ b/daidokoro/src/app/component/ingredients/ingredients.component.spec.ts
@@ -0,0 +1,23 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { IngredientsComponent } from './ingredients.component';
+
+describe('IngredientsComponent', () => {
+ let component: IngredientsComponent;
+ let fixture: ComponentFixture
;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ imports: [IngredientsComponent]
+ })
+ .compileComponents();
+
+ fixture = TestBed.createComponent(IngredientsComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/daidokoro/src/app/component/ingredients/ingredients.component.ts b/daidokoro/src/app/component/ingredients/ingredients.component.ts
new file mode 100644
index 0000000..af71741
--- /dev/null
+++ b/daidokoro/src/app/component/ingredients/ingredients.component.ts
@@ -0,0 +1,45 @@
+import {Component, OnInit} from '@angular/core';
+import {IngredientService} from "../../service/ingredient.service";
+import {Ingredient} from "../../model/ingredient.model";
+import {NgFor} from "@angular/common";
+import {LoginService} from "../../service/login.service";
+import {Link} from "../../model/link.model";
+import {LinkService} from "../../service/link.service";
+
+@Component({
+ selector: 'app-ingredients',
+ standalone: true,
+ imports: [
+ NgFor,
+ ],
+ templateUrl: './ingredients.component.html',
+ styleUrl: './ingredients.component.css'
+})
+export class IngredientsComponent implements OnInit{
+
+ ingredients: Ingredient[] = [];
+ links: Link[] = this.linkService.getLinks()
+
+ constructor(private ingredientService : IngredientService,private loginService: LoginService,private linkService : LinkService) {}
+
+ ngOnInit() {
+ this.ingredientService.getAll().subscribe(ingredients => {
+ this.ingredients = ingredients;
+ });
+ }
+
+ onClickLogin(event: Event): void {
+ event.preventDefault(); // Prevent the default anchor behavior
+ this.loginService.login();
+ }
+
+ onClickLogout(event: Event): void {
+ event.preventDefault(); // Prevent the default anchor behavior
+ this.loginService.logout();
+ }
+
+ isLogged(): boolean {
+ return this.loginService.isLogged();
+ }
+
+}
diff --git a/daidokoro/src/app/component/recipe-detail/recipe-detail.component.css b/daidokoro/src/app/component/recipe-detail/recipe-detail.component.css
new file mode 100644
index 0000000..e69de29
diff --git a/daidokoro/src/app/component/recipe-detail/recipe-detail.component.html b/daidokoro/src/app/component/recipe-detail/recipe-detail.component.html
new file mode 100644
index 0000000..f411fb3
--- /dev/null
+++ b/daidokoro/src/app/component/recipe-detail/recipe-detail.component.html
@@ -0,0 +1,5 @@
+{{recipe?.$name}}
+ {{recipe?.$createdAt}}
+
+{{recipe?.$description}}
+
diff --git a/daidokoro/src/app/component/recipe-detail/recipe-detail.component.spec.ts b/daidokoro/src/app/component/recipe-detail/recipe-detail.component.spec.ts
new file mode 100644
index 0000000..3db95b6
--- /dev/null
+++ b/daidokoro/src/app/component/recipe-detail/recipe-detail.component.spec.ts
@@ -0,0 +1,23 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { RecipeDetailComponent } from './recipe-detail.component';
+
+describe('RecipeDetailComponent', () => {
+ let component: RecipeDetailComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ imports: [RecipeDetailComponent]
+ })
+ .compileComponents();
+
+ fixture = TestBed.createComponent(RecipeDetailComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/daidokoro/src/app/component/recipe-detail/recipe-detail.component.ts b/daidokoro/src/app/component/recipe-detail/recipe-detail.component.ts
new file mode 100644
index 0000000..2949c8a
--- /dev/null
+++ b/daidokoro/src/app/component/recipe-detail/recipe-detail.component.ts
@@ -0,0 +1,26 @@
+import {Component, Input} from '@angular/core';
+import {Recipe} from "../../model/recipe.model";
+import {RecipeService} from "../../service/recipe.service";
+import {RouterLink, RouterLinkActive, RouterOutlet} from "@angular/router";
+import {NgFor} from "@angular/common";
+
+@Component({
+ selector: 'app-recipe-detail',
+ standalone: true,
+ imports: [RouterOutlet,RouterLink, RouterLinkActive,NgFor],
+ templateUrl: './recipe-detail.component.html',
+ styleUrl: './recipe-detail.component.css'
+})
+export class RecipeDetailComponent {
+
+ recipe : Recipe|null = null;
+
+ constructor(private recipeService : RecipeService) {
+ }
+
+ @Input()
+ set id(id: number) {
+ this.recipe = this.recipeService.getRecipe(id)!;
+ }
+
+}
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 2809b44..737a844 100644
--- a/daidokoro/src/app/component/recipe-list/recipe-list.component.html
+++ b/daidokoro/src/app/component/recipe-list/recipe-list.component.html
@@ -83,13 +83,13 @@
{{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 f09e231..c46619b 100644
--- a/daidokoro/src/app/component/recipe-list/recipe-list.component.ts
+++ b/daidokoro/src/app/component/recipe-list/recipe-list.component.ts
@@ -3,6 +3,7 @@ import { RecipeService } from '../../service/recipe.service';
import { Recipe } from '../../model/recipe.model';
import {NgClass, NgOptimizedImage} from "@angular/common";
import {NgFor} from "@angular/common";
+import {Router, RouterLinkActive} from "@angular/router";
@Component({
selector: 'app-recipe-list',
@@ -10,7 +11,8 @@ import {NgFor} from "@angular/common";
imports: [
NgOptimizedImage,
NgFor,
- NgClass
+ NgClass,
+ RouterLinkActive
],
standalone: true
})
@@ -22,7 +24,7 @@ export class RecipeListComponent implements OnInit {
pageSize: number = 4;
totalPages: any = 0;
- constructor(private recipeService: RecipeService) {}
+ constructor(private recipeService: RecipeService,private router : Router) {}
ngOnInit(): void {
this.recipes = this.recipeService.getRecipes();
@@ -49,4 +51,8 @@ export class RecipeListComponent implements OnInit {
this.currentPage++;
}
}
+
+ detailsRecipe(id : number){
+ this.router.navigateByUrl('/recipe/'+id);
+ }
}
diff --git a/daidokoro/src/app/data/ingredient.stub.ts b/daidokoro/src/app/data/ingredient.stub.ts
index fdb9b58..0899070 100644
--- a/daidokoro/src/app/data/ingredient.stub.ts
+++ b/daidokoro/src/app/data/ingredient.stub.ts
@@ -1,9 +1,56 @@
import {Ingredient} from "../model/ingredient.model";
export var $INGREDIENTS : Ingredient[] = [
- {$id:1,$name:'Patate'},
- {$id:2,$name:'Gruyere'},
- {$id:3,$name:'Quenelle'},
- {$id:4,$name:'Faux-filet de Boeuf'},
- {$id:5,$name:'Concassé de tomates'}
+ { $id: 1, $name: 'Patate' },
+ { $id: 2, $name: 'Gruyere' },
+ { $id: 3, $name: 'Quenelle' },
+ { $id: 4, $name: 'Faux-filet de Boeuf' },
+ { $id: 5, $name: 'Concassé de tomates' },
+ { $id: 6, $name: 'Carotte' },
+ // { $id: 7, $name: 'Oignon' },
+ // { $id: 8, $name: 'Ail' },
+ // { $id: 9, $name: 'Poivron' },
+ // { $id: 10, $name: 'Courgette' },
+ // { $id: 11, $name: 'Champignon' },
+ // { $id: 12, $name: 'Céleri' },
+ // { $id: 13, $name: 'Épinard' },
+ // { $id: 14, $name: 'Tomate' },
+ // { $id: 15, $name: 'Poulet' },
+ // { $id: 16, $name: 'Poisson' },
+ // { $id: 17, $name: 'Crevette' },
+ // { $id: 18, $name: 'Pâtes' },
+ // { $id: 19, $name: 'Riz' },
+ // { $id: 20, $name: 'Lait' },
+ // { $id: 21, $name: 'Crème' },
+ // { $id: 22, $name: 'Fromage' },
+ // { $id: 23, $name: 'Beurre' },
+ // { $id: 24, $name: 'Huile d’olive' },
+ // { $id: 25, $name: 'Sel' },
+ // { $id: 26, $name: 'Poivre' },
+ // { $id: 27, $name: 'Paprika' },
+ // { $id: 28, $name: 'Cumin' },
+ // { $id: 29, $name: 'Curcuma' },
+ // { $id: 30, $name: 'Thym' },
+ // { $id: 31, $name: 'Laurier' },
+ // { $id: 32, $name: 'Persil' },
+ // { $id: 33, $name: 'Basilic' },
+ // { $id: 34, $name: 'Coriandre' },
+ // { $id: 35, $name: 'Gingembre' },
+ // { $id: 36, $name: 'Citron' },
+ // { $id: 37, $name: 'Pomme de terre' },
+ // { $id: 38, $name: 'Betterave' },
+ // { $id: 39, $name: 'Radis' },
+ // { $id: 40, $name: 'Chou-fleur' },
+ // { $id: 41, $name: 'Brocoli' },
+ // { $id: 42, $name: 'Haricot vert' },
+ // { $id: 43, $name: 'Pois' },
+ // { $id: 44, $name: 'Lentille' },
+ // { $id: 45, $name: 'Noix' },
+ // { $id: 46, $name: 'Amandes' },
+ // { $id: 47, $name: 'Noisettes' },
+ // { $id: 48, $name: 'Chocolat' },
+ // { $id: 49, $name: 'Vanille' },
+ // { $id: 50, $name: 'Sucre' }
+
+
]
diff --git a/daidokoro/src/app/guard.guard.ts b/daidokoro/src/app/guard.guard.ts
index 22257e9..e9688c5 100644
--- a/daidokoro/src/app/guard.guard.ts
+++ b/daidokoro/src/app/guard.guard.ts
@@ -8,10 +8,8 @@ export const AuthGuard: CanActivateFn = (route, state) => {
const router = inject(Router);
if(!auth.isLogged()){
- router.navigateByUrl('/login');
- auth.login();
+ router.navigateByUrl('/');
return false;
}
- auth.logout();
return true;
};
diff --git a/daidokoro/src/app/service/recipe.service.ts b/daidokoro/src/app/service/recipe.service.ts
index 7e9abff..08a4fff 100644
--- a/daidokoro/src/app/service/recipe.service.ts
+++ b/daidokoro/src/app/service/recipe.service.ts
@@ -15,4 +15,7 @@ export class RecipeService {
this.recipes.push(recipe);
localStorage.setItem('recipes', JSON.stringify(this.recipes));
}
+ getRecipe($id:number):Recipe{
+ return this.recipes.find(x => x.$id == $id)!
+ }
}