diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 377f6bc..c7beb9b 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,32 +1,70 @@ + + - + + + + + + + + + + + + - - + { + "associatedIndex": 7 +} + + + + - { + "keyToString": { + "ASKED_ADD_EXTERNAL_FILES": "true", + "RunOnceActivity.ShowReadmeOnStart": "true", + "git-widget-placeholder": "master", + "last_opened_file_path": "/home/dorian/Documents/but3/Angular/Daidokoro", + "node.js.detected.package.eslint": "true", + "node.js.detected.package.tslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "node.js.selected.package.tslint": "(autodetect)", + "nodejs_package_manager_path": "npm", + "settings.editor.selected.configurable": "preferences.lookFeel", + "ts.external.directory.path": "/home/dorian/Documents/but3/Angular/Daidokoro/daidokoro/node_modules/typescript/lib", + "vue.rearranger.settings.migration": "true" } -}]]> +} + + + + + + @@ -37,13 +75,47 @@ - - 1718625373590 + + 1718535175328 + + + + + + + + + + \ No newline at end of file diff --git a/daidokoro/.gitignore b/daidokoro/.gitignore index cc7b141..bf82add 100644 --- a/daidokoro/.gitignore +++ b/daidokoro/.gitignore @@ -1,5 +1,5 @@ # See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files. - +.idea/workspace.xml # Compiled output /dist /tmp diff --git a/daidokoro/src/app/app.routes.ts b/daidokoro/src/app/app.routes.ts index dc39edb..1654526 100644 --- a/daidokoro/src/app/app.routes.ts +++ b/daidokoro/src/app/app.routes.ts @@ -1,3 +1,6 @@ import { Routes } from '@angular/router'; +import {LoginComponent} from "./component/login/login.component"; -export const routes: Routes = []; +export const routes: Routes = [ + {path: 'login',component:LoginComponent} +]; diff --git a/daidokoro/src/app/component/accueil/accueil.component.html b/daidokoro/src/app/component/accueil/accueil.component.html index 86d5105..2e76ae7 100644 --- a/daidokoro/src/app/component/accueil/accueil.component.html +++ b/daidokoro/src/app/component/accueil/accueil.component.html @@ -31,33 +31,55 @@ display: flex; gap: 20px; } - .recipe-container { + .recipe-container, .form-container { background-color: #bab6b6; color: black; padding: 20px; - margin-top: 0; + flex: 1; + } + .recipe-container { + display: flex; + flex-direction: column; } .recipe-container h2 { font-size: 3em; margin-bottom: 10px; } + .form-container { + display: none; + flex-direction: column; + } + .show-form .form-container { + display: flex; + } + .show-form .recipe-container, .show-form .form-container { + flex: 1; + } + .button-container { + margin-top: 20px; + } - -
+

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 @@ - - - - -
- Recette 1 -
-

{{recipe.$name}}

-

{{recipe.$description}}

- + + +
+
+ Recette 1 +
+

{{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:""} ]