Compare commits

..

42 Commits

Author SHA1 Message Date
Dorian HODIN ff74739558 Mise à jour de 'daidokoro/Dockerfile'
continuous-integration/drone/push Build is passing Details
1 year ago
Dorian HODIN 0c0d626934 Supprimer 'daidokoro/nginx.conf'
continuous-integration/drone/push Build was killed Details
1 year ago
Dorian HODIN 477d303184 Transférer les fichiers vers 'daidokoro'
continuous-integration/drone/push Build is failing Details
1 year ago
Dorian HODIN e60455b494 Mise à jour de 'daidokoro/Dockerfile'
continuous-integration/drone/push Build is failing Details
1 year ago
Dorian HODIN 998d4c4860 Mise à jour de 'daidokoro/Dockerfile'
continuous-integration/drone/push Build is passing Details
1 year ago
Dorian HODIN b0e716aced Mise à jour de 'daidokoro/Dockerfile'
continuous-integration/drone/push Build is passing Details
1 year ago
Corentin RICHARD 995335e259 Publish ReadMe
continuous-integration/drone/push Build is passing Details
1 year ago
Corentin RICHARD 9315764d01 test deploy
continuous-integration/drone/push Build is failing Details
1 year ago
Dorian HODIN 4cf018fedd Adding Command section, local storage exceed problem, adding error managing
continuous-integration/drone/push Build is failing Details
1 year ago
Dorian HODIN 0e5f4b300c Adding recipe-details front
continuous-integration/drone/push Build is failing Details
1 year ago
Dorian HODIN 18c4c617de Adding Ingredients from API, add and edit working good, front of the ingredients page
continuous-integration/drone/push Build is passing Details
1 year ago
Dorian HODIN 49ae2dc7f6 Merge pull request 'formFront' (#6) from formFront into master
continuous-integration/drone/push Build is passing Details
1 year ago
Dorian HODIN 4f6bdfb558 Adding Form front with the new form
continuous-integration/drone/push Build is passing Details
1 year ago
Dorian HODIN eb5dc52a84 Merge branch 'refs/heads/master' into formFront
1 year ago
Corentin RICHARD e038252020 Merge pull request 'Adding image to Recipe and one ingredient checker' (#5) from formImage into master
continuous-integration/drone/push Build is passing Details
1 year ago
Corentin RICHARD cd07d96d44 Adding image to Recipe and one ingredient checker
continuous-integration/drone/push Build is passing Details
1 year ago
Corentin RICHARD 45a802414e Merge pull request 'listIngredients' (#4) from listIngredients into master
continuous-integration/drone/push Build is passing Details
1 year ago
Corentin RICHARD 51580432bd Adding list of ingredients with guards and detail of recipe
continuous-integration/drone/push Build is passing Details
1 year ago
Corentin RICHARD dafff55563 Adding list of ingredients with guards and detail of recipe
1 year ago
Corentin RICHARD 62b1b37320 Merge pull request 'formAdvanced' (#3) from formAdvanced into master
continuous-integration/drone/push Build is passing Details
1 year ago
Corentin RICHARD e2cd09bb99 Adding login and giuard
continuous-integration/drone/push Build is passing Details
1 year ago
Corentin RICHARD 95ee995051 Merge branch 'master' of https://codefirst.iut.uca.fr/git/dorian.hodin/Daidokoro into formAdvanced
1 year ago
Corentin RICHARD 016118938c Adding logging
1 year ago
Corentin RICHARD 46da11e3c8 Adding routing
1 year ago
Dorian HODIN 4f43477810 Adding Form Front, and verification of empty field or not
continuous-integration/drone/push Build is passing Details
1 year ago
Dorian HODIN 7cc4820475 Merge branch 'refs/heads/formAdvanced' into formFront
1 year ago
Corentin RICHARD 2b85d50087 Adding ingredients in form
continuous-integration/drone/push Build is passing Details
1 year ago
Dorian HODIN 370b3467b2 Adding new gitignore for workspace
continuous-integration/drone/push Build is passing Details
1 year ago
Dorian HODIN 61e915eca0 Adding good front and pagination
continuous-integration/drone/push Build is passing Details
1 year ago
Corentin RICHARD 23edc7adda Merge pull request 'formRecipe' (#2) from formRecipe into master
continuous-integration/drone/push Build is passing Details
1 year ago
Corentin RICHARD 06e2af1d68 Merge branch 'master' of https://codefirst.iut.uca.fr/git/dorian.hodin/Daidokoro into formRecipe
continuous-integration/drone/push Build is passing Details
1 year ago
Corentin RICHARD 766627c169 Adding form to front
continuous-integration/drone/push Build is passing Details
1 year ago
Dorian HODIN 4c65a7dffa Adding favicon.ico
continuous-integration/drone/push Build is passing Details
1 year ago
Dorian HODIN bdd18a6c7d Mise à jour de 'README.md'
continuous-integration/drone/push Build is passing Details
1 year ago
Corentin RICHARD 0342736841 Merge branch 'master' of https://codefirst.iut.uca.fr/git/dorian.hodin/Daidokoro into formRecipe
continuous-integration/drone/push Build is passing Details
1 year ago
Dorian HODIN 1d1a65d0df Merge branch 'refs/heads/front'
continuous-integration/drone/push Build is passing Details
1 year ago
Dorian HODIN a6e933e210 Adding Front
1 year ago
Corentin RICHARD 4346246165 Merge branch 'master' of https://codefirst.iut.uca.fr/git/dorian.hodin/Daidokoro into formRecipe
continuous-integration/drone/push Build is passing Details
1 year ago
Corentin RICHARD 9f3e86b395 Adding form component
continuous-integration/drone/push Build is passing Details
1 year ago
Dorian HODIN ed7b77cc61 Adding Front
continuous-integration/drone/push Build is passing Details
1 year ago
Corentin RICHARD cc3d72ff00 Merge pull request 'stubModel' (#1) from stubModel into master
continuous-integration/drone/push Build is passing Details
1 year ago
Corentin RICHARD c2b8535946 merge master to master
1 year ago

5
.idea/.gitignore vendored

@ -0,0 +1,5 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/Daidokoro.iml" filepath="$PROJECT_DIR$/.idea/Daidokoro.iml" />
</modules>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

@ -0,0 +1,150 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="c5a06892-a370-4c6a-a9cf-5d61f93a285b" name="Changes" comment="Adding Command section, local storage exceed problem, adding error managing">
<change afterPath="$PROJECT_DIR$/daidokoro/src/app/service/command.service.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/daidokoro/src/app/component/command/command.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/daidokoro/src/app/component/command/command.component.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/daidokoro/src/app/component/command/command.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/daidokoro/src/app/component/command/command.component.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/daidokoro/src/app/component/recipe-list/recipe-list.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/daidokoro/src/app/component/recipe-list/recipe-list.component.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/daidokoro/src/app/component/recipe-list/recipe-list.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/daidokoro/src/app/component/recipe-list/recipe-list.component.ts" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="TypeScript File" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$" value="formFront" />
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 7
}</component>
<component name="ProjectId" id="2hxUMd4IvFZ2RBuUoixQsBySsiP" />
<component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="2" id="Add" />
</component>
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;ASKED_ADD_EXTERNAL_FILES&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;master&quot;,
&quot;last_opened_file_path&quot;: &quot;/home/dorian/Documents/but3/Angular/Daidokoro&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.lookFeel&quot;,
&quot;ts.external.directory.path&quot;: &quot;/home/dorian/Documents/but3/Angular/Daidokoro/daidokoro/node_modules/typescript/lib&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/daidokoro/public" />
<recent name="$PROJECT_DIR$/daidokoro/src/app" />
</key>
</component>
<component name="SharedIndexes">
<attachedChunks>
<set>
<option value="bundled-js-predefined-1d06a55b98c1-0b3e54e931b4-JavaScript-WS-241.17890.13" />
</set>
</attachedChunks>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="c5a06892-a370-4c6a-a9cf-5d61f93a285b" name="Changes" comment="" />
<created>1718535175328</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1718535175328</updated>
<workItem from="1718535176543" duration="94000" />
<workItem from="1718535276928" duration="51000" />
<workItem from="1718535331746" duration="130000" />
<workItem from="1718624272278" duration="96000" />
<workItem from="1718625479373" duration="4985000" />
<workItem from="1719217543390" duration="31000" />
<workItem from="1719217580949" duration="135000" />
<workItem from="1719755658119" duration="6807000" />
</task>
<task id="LOCAL-00001" summary="Adding Front">
<option name="closed" value="true" />
<created>1718630357884</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1718630357884</updated>
</task>
<task id="LOCAL-00002" summary="Adding Form front with the new form">
<option name="closed" value="true" />
<created>1719666928847</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1719666928847</updated>
</task>
<task id="LOCAL-00003" summary="Adding Ingredients from API, add and edit working good, front of the ingredients page">
<option name="closed" value="true" />
<created>1719757925681</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1719757925681</updated>
</task>
<task id="LOCAL-00004" summary="Adding recipe-details front">
<option name="closed" value="true" />
<created>1719760748129</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1719760748129</updated>
</task>
<option name="localTasksCounter" value="5" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
</component>
<component name="VcsManagerConfiguration">
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
<MESSAGE value="Adding Front" />
<MESSAGE value="Adding Form front with the new form" />
<MESSAGE value="Adding Ingredients from API, add and edit working good, front of the ingredients page" />
<MESSAGE value="Adding recipe-details front" />
<MESSAGE value="Adding Command section, local storage exceed problem, adding error managing" />
<option name="LAST_COMMIT_MESSAGE" value="Adding Command section, local storage exceed problem, adding error managing" />
</component>
</project>

@ -1,6 +1,6 @@
<div align = center>
<img src="https://i.pinimg.com/736x/17/79/83/177983f3e806df254b8099b1d191f848.jpg" width="550" height="">
<img src="https://i.pinimg.com/736x/17/79/83/177983f3e806df254b8099b1d191f848.jpg" width="100%" height="">
</div>
@ -12,9 +12,72 @@
![BuyMeACoffee](https://img.shields.io/badge/Buy%20Me%20a%20Coffee-ffdd00?style=for-the-badge&logo=buy-me-a-coffee&logoColor=black)
</div>
# :bookmark: Présentation
# Daidokoro
## Lancer l'application
Pour lancer l'application, veuillez suivre les étapes suivantes :
1. Cloner le repository du projet.
2. Se rendre dans le dossier `daidokoro`.
3. Exécuter la commande suivante : `ng serve --open`.
## Présentation rapide du projet
Daidokoro est un projet réalisé en Angular. Il s'agit d'une application web de gestion de recettes et d'ingrédients.
Les fonctionnalités incluent la gestion des utilisateurs, la consultation, l'ajout, la modification et la suppression d'ingrédients, ainsi que la création et la commande de recettes.
Le projet est conçu pour être intuitif et facile à utiliser, avec une interface utilisateur agréable et des fonctionnalités robustes.
## Prérequis demandés
Pour ce projet, les fonctionnalités suivantes étaient requises :
- Une barre de navigation commune à tout le site avec :
- Une page de connexion (/login) permettant de créer un cookie ou un local storage avec une valeur `isAdmin = true` et une redirection vers la page des ingrédients. Le bouton de connexion n'apparaît que si la valeur `isAdmin` est `false` ou inexistante.
- Une page de déconnexion (/logout) ayant le comportement inverse de la connexion.
- Un bouton vers la page des ingrédients avec une guard qui vérifie la valeur `isAdmin`. Si `true`, l'accès est permis, sinon, redirection vers la page d'accueil.
- Listing des ingrédients existants.
- Ajout d'un ingrédient.
- Modification d'un ingrédient.
- Connexion à une API pour les ingrédients, remplaçant le stub actuel.
- Sur la page d'accueil :
- Liste de recettes chargées depuis le local storage avec une image enregistrée ou un placeholder (`placehold.co/50x50`).
- Pagination de la liste de recettes.
- Un bouton pour ajouter une recette, faisant apparaître un formulaire avec :
- Nom
- Image
- Description
- Liste d'ingrédients avec possibilité de rajouter et de supprimer des ingrédients, au moins un devant être sélectionné.
- Un bouton "Commander" sur chaque recette qui ajoute la recette commandée à une liste "Commande en cours" sur la page d'accueil.
- Un bouton "Détail" redirigeant vers `/recettes/:id` et affichant la recette avec tous ses attributs.
## Réalisation des prérequis
Nous avons mis en œuvre toutes les fonctionnalités demandées :
- **Barre de navigation :** Elle est présente sur toutes les pages et comprend les boutons de connexion et de déconnexion. La gestion de `isAdmin` est effectuée via le local storage.
- **Guard d'accès aux ingrédients :** Nous avons implémenté une guard qui vérifie si l'utilisateur est connecté avant de permettre l'accès à la page des ingrédients.
- **Gestion des ingrédients :** Nous avons créé des pages pour lister, ajouter et modifier les ingrédients via l'API.
- **Page d'accueil :** La liste des recettes est chargée depuis le local storage et paginée. Un formulaire d'ajout de recette permet de créer de nouvelles recettes avec tous les champs requis. Chaque recette a des boutons "Commander" et "Détail".
## Fonctionnalités supplémentaires
En plus des fonctionnalités de base demandées, nous avons :
- Implémenté un style personnalisé pour l'application afin d'améliorer l'expérience utilisateur.
## Difficultés
Nous avons aussi rencontrer certaines difficultés :
- L'application a du mal à stocker dans le local storage à partir d'un certain quota, il est limité.
- Nous avons tenté de déployer l'application mais sans succès, le hub de codefirst était surchargé.
## Organisation du travail
Nous avons utilisé un système de branches et de merge requests pour organiser notre travail de manière efficace. Chaque fonctionnalité a été développée sur une branche dédiée et intégrée dans la branche principale via des merge requests. Cela nous a permis de travailler en parallèle tout en maintenant un code base stable et propre.
## Conclusion
Le projet Daidokoro a été une expérience enrichissante, nous permettant d'acquérir des connaissances en Angular et en gestion de projets.
このプロジェクトはレシピを閲覧・追加できるサイトを目指したプロジェクトです!あなたの作品を世界と共有しましょう!
# :construction: Développeurs

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

@ -1,4 +0,0 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
"recommendations": ["angular.ng-template"]
}

@ -1,20 +0,0 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "ng serve",
"type": "chrome",
"request": "launch",
"preLaunchTask": "npm: start",
"url": "http://localhost:4200/"
},
{
"name": "ng test",
"type": "chrome",
"request": "launch",
"preLaunchTask": "npm: test",
"url": "http://localhost:9876/debug.html"
}
]
}

@ -1,42 +0,0 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "start",
"isBackground": true,
"problemMatcher": {
"owner": "typescript",
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "(.*?)"
},
"endsPattern": {
"regexp": "bundle generation complete"
}
}
}
},
{
"type": "npm",
"script": "test",
"isBackground": true,
"problemMatcher": {
"owner": "typescript",
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "(.*?)"
},
"endsPattern": {
"regexp": "bundle generation complete"
}
}
}
}
]
}

@ -8,4 +8,6 @@ RUN npm install -g @angular/cli
RUN npm install
ENTRYPOINT ["ng", "serve", "--host", "0.0.0.0","--port","80"]
EXPOSE 4200
ENTRYPOINT ["ng", "serve", "--host", "0.0.0.0"]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 220 KiB

@ -1,336 +1,53 @@
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<!-- * * * * * * * * * * * The content below * * * * * * * * * * * -->
<!-- * * * * * * * * * * is only a placeholder * * * * * * * * * * -->
<!-- * * * * * * * * * * and can be replaced. * * * * * * * * * * -->
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<!-- * * * * * * * * * Delete the template below * * * * * * * * * -->
<!-- * * * * * * * to get started with your project! * * * * * * * -->
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<style>
:host {
--bright-blue: oklch(51.01% 0.274 263.83);
--electric-violet: oklch(53.18% 0.28 296.97);
--french-violet: oklch(47.66% 0.246 305.88);
--vivid-pink: oklch(69.02% 0.277 332.77);
--hot-red: oklch(61.42% 0.238 15.34);
--orange-red: oklch(63.32% 0.24 31.68);
--gray-900: oklch(19.37% 0.006 300.98);
--gray-700: oklch(36.98% 0.014 302.71);
--gray-400: oklch(70.9% 0.015 304.04);
--red-to-pink-to-purple-vertical-gradient: linear-gradient(
180deg,
var(--orange-red) 0%,
var(--vivid-pink) 50%,
var(--electric-violet) 100%
);
--red-to-pink-to-purple-horizontal-gradient: linear-gradient(
90deg,
var(--orange-red) 0%,
var(--vivid-pink) 50%,
var(--electric-violet) 100%
);
--pill-accent: var(--bright-blue);
font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji",
"Segoe UI Symbol";
box-sizing: border-box;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
h1 {
font-size: 3.125rem;
color: var(--gray-900);
font-weight: 500;
line-height: 100%;
letter-spacing: -0.125rem;
margin: 0;
font-family: "Inter Tight", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji",
"Segoe UI Symbol";
}
p {
margin: 0;
color: var(--gray-700);
}
main {
width: 100%;
min-height: 100%;
display: flex;
justify-content: center;
align-items: center;
padding: 1rem;
box-sizing: inherit;
position: relative;
}
.angular-logo {
max-width: 9.2rem;
}
.content {
display: flex;
justify-content: space-around;
width: 100%;
max-width: 700px;
margin-bottom: 3rem;
}
.content h1 {
margin-top: 1.75rem;
}
.content p {
margin-top: 1.5rem;
}
.divider {
width: 1px;
background: var(--red-to-pink-to-purple-vertical-gradient);
margin-inline: 0.5rem;
}
.pill-group {
display: flex;
flex-direction: column;
align-items: start;
flex-wrap: wrap;
gap: 1.25rem;
}
.pill {
display: flex;
align-items: center;
--pill-accent: var(--bright-blue);
background: color-mix(in srgb, var(--pill-accent) 5%, transparent);
color: var(--pill-accent);
padding-inline: 0.75rem;
padding-block: 0.375rem;
border-radius: 2.75rem;
border: 0;
transition: background 0.3s ease;
font-family: var(--inter-font);
font-size: 0.875rem;
font-style: normal;
font-weight: 500;
line-height: 1.4rem;
letter-spacing: -0.00875rem;
text-decoration: none;
}
.pill:hover {
background: color-mix(in srgb, var(--pill-accent) 15%, transparent);
}
.pill-group .pill:nth-child(6n + 1) {
--pill-accent: var(--bright-blue);
}
.pill-group .pill:nth-child(6n + 2) {
--pill-accent: var(--french-violet);
}
.pill-group .pill:nth-child(6n + 3),
.pill-group .pill:nth-child(6n + 4),
.pill-group .pill:nth-child(6n + 5) {
--pill-accent: var(--hot-red);
}
.pill-group svg {
margin-inline-start: 0.25rem;
}
.social-links {
display: flex;
align-items: center;
gap: 0.73rem;
margin-top: 1.5rem;
}
.social-links path {
transition: fill 0.3s ease;
fill: var(--gray-400);
}
.social-links a:hover svg path {
fill: var(--gray-900);
}
@media screen and (max-width: 650px) {
.content {
flex-direction: column;
width: max-content;
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Daidokoro</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Karma">
<style>
body, h1, h2, h3, h4, h5, h6 {
font-family: "Karma", sans-serif;
margin: 0;
padding: 0;
}
.divider {
height: 1px;
width: 100%;
background: var(--red-to-pink-to-purple-horizontal-gradient);
margin-block: 1.5rem;
.navbar {
display: flex;
justify-content: space-around;
align-items: center;
background-color: #333;
padding: 1em;
}
.navbar a {
color: white;
text-decoration: none;
padding: 0.5em 1em;
}
.navbar a:hover {
background-color: #ddd;
color: black;
}
}
</style>
.recipe-container h2 {
font-size: 3em;
margin-bottom: 10px;
}
</style>
</head>
<body>
<div class="navbar">
<div *ngIf="isLogged()">
<a href="/" (click)="onClickLogout($event)">Logout</a>
</div>
<div *ngIf="!isLogged()">
<a href="" (click)="onClickLogin($event)">Login</a>
</div>
<main class="main">
<div class="content">
<div class="left-side">
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 982 239"
fill="none"
class="angular-logo"
>
<g clip-path="url(#a)">
<path
fill="url(#b)"
d="M388.676 191.625h30.849L363.31 31.828h-35.758l-56.215 159.797h30.848l13.174-39.356h60.061l13.256 39.356Zm-65.461-62.675 21.602-64.311h1.227l21.602 64.311h-44.431Zm126.831-7.527v70.202h-28.23V71.839h27.002v20.374h1.392c2.782-6.71 7.2-12.028 13.255-15.956 6.056-3.927 13.584-5.89 22.503-5.89 8.264 0 15.465 1.8 21.684 5.318 6.137 3.518 10.964 8.673 14.319 15.382 3.437 6.71 5.074 14.81 4.992 24.383v76.175h-28.23v-71.92c0-8.019-2.046-14.237-6.219-18.819-4.173-4.5-9.819-6.791-17.102-6.791-4.91 0-9.328 1.063-13.174 3.272-3.846 2.128-6.792 5.237-9.001 9.328-2.046 4.009-3.191 8.918-3.191 14.728ZM589.233 239c-10.147 0-18.82-1.391-26.103-4.091-7.282-2.7-13.092-6.382-17.511-10.964-4.418-4.582-7.528-9.655-9.164-15.219l25.448-6.136c1.145 2.372 2.782 4.663 4.991 6.954 2.209 2.291 5.155 4.255 8.837 5.81 3.683 1.554 8.428 2.291 14.074 2.291 8.019 0 14.647-1.964 19.884-5.81 5.237-3.845 7.856-10.227 7.856-19.064v-22.665h-1.391c-1.473 2.946-3.601 5.892-6.383 9.001-2.782 3.109-6.464 5.645-10.965 7.691-4.582 2.046-10.228 3.109-17.101 3.109-9.165 0-17.511-2.209-25.039-6.545-7.446-4.337-13.42-10.883-17.757-19.474-4.418-8.673-6.628-19.473-6.628-32.565 0-13.091 2.21-24.301 6.628-33.383 4.419-9.082 10.311-15.955 17.839-20.7 7.528-4.746 15.874-7.037 25.039-7.037 7.037 0 12.846 1.145 17.347 3.518 4.582 2.373 8.182 5.236 10.883 8.51 2.7 3.272 4.746 6.382 6.137 9.327h1.554v-19.8h27.821v121.749c0 10.228-2.454 18.737-7.364 25.447-4.91 6.709-11.538 11.7-20.048 15.055-8.509 3.355-18.165 4.991-28.884 4.991Zm.245-71.266c5.974 0 11.047-1.473 15.302-4.337 4.173-2.945 7.446-7.118 9.573-12.519 2.21-5.482 3.274-12.027 3.274-19.637 0-7.609-1.064-14.155-3.274-19.8-2.127-5.646-5.318-10.064-9.491-13.255-4.174-3.11-9.329-4.746-15.384-4.746s-11.537 1.636-15.792 4.91c-4.173 3.272-7.365 7.772-9.492 13.418-2.128 5.727-3.191 12.191-3.191 19.392 0 7.2 1.063 13.745 3.273 19.228 2.127 5.482 5.318 9.736 9.573 12.764 4.174 3.027 9.41 4.582 15.629 4.582Zm141.56-26.51V71.839h28.23v119.786h-27.412v-21.273h-1.227c-2.7 6.709-7.119 12.191-13.338 16.446-6.137 4.255-13.747 6.382-22.748 6.382-7.855 0-14.81-1.718-20.783-5.237-5.974-3.518-10.72-8.591-14.075-15.382-3.355-6.709-5.073-14.891-5.073-24.464V71.839h28.312v71.921c0 7.609 2.046 13.664 6.219 18.083 4.173 4.5 9.655 6.709 16.365 6.709 4.173 0 8.183-.982 12.111-3.028 3.927-2.045 7.118-5.072 9.655-9.082 2.537-4.091 3.764-9.164 3.764-15.218Zm65.707-109.395v159.796h-28.23V31.828h28.23Zm44.841 162.169c-7.61 0-14.402-1.391-20.457-4.091-6.055-2.7-10.883-6.791-14.32-12.109-3.518-5.319-5.237-11.946-5.237-19.801 0-6.791 1.228-12.355 3.765-16.773 2.536-4.419 5.891-7.937 10.228-10.637 4.337-2.618 9.164-4.664 14.647-6.055 5.4-1.391 11.046-2.373 16.856-3.027 7.037-.737 12.683-1.391 17.102-1.964 4.337-.573 7.528-1.555 9.574-2.782 1.963-1.309 3.027-3.273 3.027-5.973v-.491c0-5.891-1.718-10.391-5.237-13.664-3.518-3.191-8.51-4.828-15.056-4.828-6.955 0-12.356 1.473-16.447 4.5-4.009 3.028-6.71 6.546-8.183 10.719l-26.348-3.764c2.046-7.282 5.483-13.336 10.31-18.328 4.746-4.909 10.638-8.59 17.511-11.045 6.955-2.455 14.565-3.682 22.912-3.682 5.809 0 11.537.654 17.265 2.045s10.965 3.6 15.711 6.71c4.746 3.109 8.51 7.282 11.455 12.6 2.864 5.318 4.337 11.946 4.337 19.883v80.184h-27.166v-16.446h-.9c-1.719 3.355-4.092 6.464-7.201 9.328-3.109 2.864-6.955 5.237-11.619 6.955-4.828 1.718-10.229 2.536-16.529 2.536Zm7.364-20.701c5.646 0 10.556-1.145 14.729-3.354 4.173-2.291 7.364-5.237 9.655-9.001 2.292-3.763 3.355-7.854 3.355-12.273v-14.155c-.9.737-2.373 1.391-4.5 2.046-2.128.654-4.419 1.145-7.037 1.636-2.619.491-5.155.9-7.692 1.227-2.537.328-4.746.655-6.628.901-4.173.572-8.019 1.472-11.292 2.781-3.355 1.31-5.973 3.11-7.855 5.401-1.964 2.291-2.864 5.318-2.864 8.918 0 5.237 1.882 9.164 5.728 11.782 3.682 2.782 8.51 4.091 14.401 4.091Zm64.643 18.328V71.839h27.412v19.965h1.227c2.21-6.955 5.974-12.274 11.292-16.038 5.319-3.763 11.456-5.645 18.329-5.645 1.555 0 3.355.082 5.237.163 1.964.164 3.601.328 4.91.573v25.938c-1.227-.41-3.109-.819-5.646-1.146a58.814 58.814 0 0 0-7.446-.49c-5.155 0-9.738 1.145-13.829 3.354-4.091 2.209-7.282 5.236-9.655 9.164-2.373 3.927-3.519 8.427-3.519 13.5v70.448h-28.312ZM222.077 39.192l-8.019 125.923L137.387 0l84.69 39.192Zm-53.105 162.825-57.933 33.056-57.934-33.056 11.783-28.556h92.301l11.783 28.556ZM111.039 62.675l30.357 73.803H80.681l30.358-73.803ZM7.937 165.115 0 39.192 84.69 0 7.937 165.115Z"
/>
<path
fill="url(#c)"
d="M388.676 191.625h30.849L363.31 31.828h-35.758l-56.215 159.797h30.848l13.174-39.356h60.061l13.256 39.356Zm-65.461-62.675 21.602-64.311h1.227l21.602 64.311h-44.431Zm126.831-7.527v70.202h-28.23V71.839h27.002v20.374h1.392c2.782-6.71 7.2-12.028 13.255-15.956 6.056-3.927 13.584-5.89 22.503-5.89 8.264 0 15.465 1.8 21.684 5.318 6.137 3.518 10.964 8.673 14.319 15.382 3.437 6.71 5.074 14.81 4.992 24.383v76.175h-28.23v-71.92c0-8.019-2.046-14.237-6.219-18.819-4.173-4.5-9.819-6.791-17.102-6.791-4.91 0-9.328 1.063-13.174 3.272-3.846 2.128-6.792 5.237-9.001 9.328-2.046 4.009-3.191 8.918-3.191 14.728ZM589.233 239c-10.147 0-18.82-1.391-26.103-4.091-7.282-2.7-13.092-6.382-17.511-10.964-4.418-4.582-7.528-9.655-9.164-15.219l25.448-6.136c1.145 2.372 2.782 4.663 4.991 6.954 2.209 2.291 5.155 4.255 8.837 5.81 3.683 1.554 8.428 2.291 14.074 2.291 8.019 0 14.647-1.964 19.884-5.81 5.237-3.845 7.856-10.227 7.856-19.064v-22.665h-1.391c-1.473 2.946-3.601 5.892-6.383 9.001-2.782 3.109-6.464 5.645-10.965 7.691-4.582 2.046-10.228 3.109-17.101 3.109-9.165 0-17.511-2.209-25.039-6.545-7.446-4.337-13.42-10.883-17.757-19.474-4.418-8.673-6.628-19.473-6.628-32.565 0-13.091 2.21-24.301 6.628-33.383 4.419-9.082 10.311-15.955 17.839-20.7 7.528-4.746 15.874-7.037 25.039-7.037 7.037 0 12.846 1.145 17.347 3.518 4.582 2.373 8.182 5.236 10.883 8.51 2.7 3.272 4.746 6.382 6.137 9.327h1.554v-19.8h27.821v121.749c0 10.228-2.454 18.737-7.364 25.447-4.91 6.709-11.538 11.7-20.048 15.055-8.509 3.355-18.165 4.991-28.884 4.991Zm.245-71.266c5.974 0 11.047-1.473 15.302-4.337 4.173-2.945 7.446-7.118 9.573-12.519 2.21-5.482 3.274-12.027 3.274-19.637 0-7.609-1.064-14.155-3.274-19.8-2.127-5.646-5.318-10.064-9.491-13.255-4.174-3.11-9.329-4.746-15.384-4.746s-11.537 1.636-15.792 4.91c-4.173 3.272-7.365 7.772-9.492 13.418-2.128 5.727-3.191 12.191-3.191 19.392 0 7.2 1.063 13.745 3.273 19.228 2.127 5.482 5.318 9.736 9.573 12.764 4.174 3.027 9.41 4.582 15.629 4.582Zm141.56-26.51V71.839h28.23v119.786h-27.412v-21.273h-1.227c-2.7 6.709-7.119 12.191-13.338 16.446-6.137 4.255-13.747 6.382-22.748 6.382-7.855 0-14.81-1.718-20.783-5.237-5.974-3.518-10.72-8.591-14.075-15.382-3.355-6.709-5.073-14.891-5.073-24.464V71.839h28.312v71.921c0 7.609 2.046 13.664 6.219 18.083 4.173 4.5 9.655 6.709 16.365 6.709 4.173 0 8.183-.982 12.111-3.028 3.927-2.045 7.118-5.072 9.655-9.082 2.537-4.091 3.764-9.164 3.764-15.218Zm65.707-109.395v159.796h-28.23V31.828h28.23Zm44.841 162.169c-7.61 0-14.402-1.391-20.457-4.091-6.055-2.7-10.883-6.791-14.32-12.109-3.518-5.319-5.237-11.946-5.237-19.801 0-6.791 1.228-12.355 3.765-16.773 2.536-4.419 5.891-7.937 10.228-10.637 4.337-2.618 9.164-4.664 14.647-6.055 5.4-1.391 11.046-2.373 16.856-3.027 7.037-.737 12.683-1.391 17.102-1.964 4.337-.573 7.528-1.555 9.574-2.782 1.963-1.309 3.027-3.273 3.027-5.973v-.491c0-5.891-1.718-10.391-5.237-13.664-3.518-3.191-8.51-4.828-15.056-4.828-6.955 0-12.356 1.473-16.447 4.5-4.009 3.028-6.71 6.546-8.183 10.719l-26.348-3.764c2.046-7.282 5.483-13.336 10.31-18.328 4.746-4.909 10.638-8.59 17.511-11.045 6.955-2.455 14.565-3.682 22.912-3.682 5.809 0 11.537.654 17.265 2.045s10.965 3.6 15.711 6.71c4.746 3.109 8.51 7.282 11.455 12.6 2.864 5.318 4.337 11.946 4.337 19.883v80.184h-27.166v-16.446h-.9c-1.719 3.355-4.092 6.464-7.201 9.328-3.109 2.864-6.955 5.237-11.619 6.955-4.828 1.718-10.229 2.536-16.529 2.536Zm7.364-20.701c5.646 0 10.556-1.145 14.729-3.354 4.173-2.291 7.364-5.237 9.655-9.001 2.292-3.763 3.355-7.854 3.355-12.273v-14.155c-.9.737-2.373 1.391-4.5 2.046-2.128.654-4.419 1.145-7.037 1.636-2.619.491-5.155.9-7.692 1.227-2.537.328-4.746.655-6.628.901-4.173.572-8.019 1.472-11.292 2.781-3.355 1.31-5.973 3.11-7.855 5.401-1.964 2.291-2.864 5.318-2.864 8.918 0 5.237 1.882 9.164 5.728 11.782 3.682 2.782 8.51 4.091 14.401 4.091Zm64.643 18.328V71.839h27.412v19.965h1.227c2.21-6.955 5.974-12.274 11.292-16.038 5.319-3.763 11.456-5.645 18.329-5.645 1.555 0 3.355.082 5.237.163 1.964.164 3.601.328 4.91.573v25.938c-1.227-.41-3.109-.819-5.646-1.146a58.814 58.814 0 0 0-7.446-.49c-5.155 0-9.738 1.145-13.829 3.354-4.091 2.209-7.282 5.236-9.655 9.164-2.373 3.927-3.519 8.427-3.519 13.5v70.448h-28.312ZM222.077 39.192l-8.019 125.923L137.387 0l84.69 39.192Zm-53.105 162.825-57.933 33.056-57.934-33.056 11.783-28.556h92.301l11.783 28.556ZM111.039 62.675l30.357 73.803H80.681l30.358-73.803ZM7.937 165.115 0 39.192 84.69 0 7.937 165.115Z"
/>
</g>
<defs>
<radialGradient
id="c"
cx="0"
cy="0"
r="1"
gradientTransform="rotate(118.122 171.182 60.81) scale(205.794)"
gradientUnits="userSpaceOnUse"
>
<stop stop-color="#FF41F8" />
<stop offset=".707" stop-color="#FF41F8" stop-opacity=".5" />
<stop offset="1" stop-color="#FF41F8" stop-opacity="0" />
</radialGradient>
<linearGradient
id="b"
x1="0"
x2="982"
y1="192"
y2="192"
gradientUnits="userSpaceOnUse"
>
<stop stop-color="#F0060B" />
<stop offset="0" stop-color="#F0070C" />
<stop offset=".526" stop-color="#CC26D5" />
<stop offset="1" stop-color="#7702FF" />
</linearGradient>
<clipPath id="a"><path fill="#fff" d="M0 0h982v239H0z" /></clipPath>
</defs>
</svg>
<h1>Hello, {{ title }}</h1>
<p>Congratulations! Your app is running. 🎉</p>
</div>
<div class="divider" role="separator" aria-label="Divider"></div>
<div class="right-side">
<div class="pill-group">
@for (item of [
{ title: 'Explore the Docs', link: 'https://angular.dev' },
{ title: 'Learn with Tutorials', link: 'https://angular.dev/tutorials' },
{ title: 'CLI Docs', link: 'https://angular.dev/tools/cli' },
{ title: 'Angular Language Service', link: 'https://angular.dev/tools/language-service' },
{ title: 'Angular DevTools', link: 'https://angular.dev/tools/devtools' },
]; track item.title) {
<a
class="pill"
[href]="item.link"
target="_blank"
rel="noopener"
>
<span>{{ item.title }}</span>
<svg
xmlns="http://www.w3.org/2000/svg"
height="14"
viewBox="0 -960 960 960"
width="14"
fill="currentColor"
>
<path
d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h280v80H200v560h560v-280h80v280q0 33-23.5 56.5T760-120H200Zm188-212-56-56 372-372H560v-80h280v280h-80v-144L388-332Z"
/>
</svg>
</a>
}
</div>
<div class="social-links">
<a
href="https://github.com/angular/angular"
aria-label="Github"
target="_blank"
rel="noopener"
>
<svg
width="25"
height="24"
viewBox="0 0 25 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
alt="Github"
>
<path
d="M12.3047 0C5.50634 0 0 5.50942 0 12.3047C0 17.7423 3.52529 22.3535 8.41332 23.9787C9.02856 24.0946 9.25414 23.7142 9.25414 23.3871C9.25414 23.0949 9.24389 22.3207 9.23876 21.2953C5.81601 22.0377 5.09414 19.6444 5.09414 19.6444C4.53427 18.2243 3.72524 17.8449 3.72524 17.8449C2.61064 17.082 3.81137 17.0973 3.81137 17.0973C5.04697 17.1835 5.69604 18.3647 5.69604 18.3647C6.79321 20.2463 8.57636 19.7029 9.27978 19.3881C9.39052 18.5924 9.70736 18.0499 10.0591 17.7423C7.32641 17.4347 4.45429 16.3765 4.45429 11.6618C4.45429 10.3185 4.9311 9.22133 5.72065 8.36C5.58222 8.04931 5.16694 6.79833 5.82831 5.10337C5.82831 5.10337 6.85883 4.77319 9.2121 6.36459C10.1965 6.09082 11.2424 5.95546 12.2883 5.94931C13.3342 5.95546 14.3801 6.09082 15.3644 6.36459C17.7023 4.77319 18.7328 5.10337 18.7328 5.10337C19.3942 6.79833 18.9789 8.04931 18.8559 8.36C19.6403 9.22133 20.1171 10.3185 20.1171 11.6618C20.1171 16.3888 17.2409 17.4296 14.5031 17.7321C14.9338 18.1012 15.3337 18.8559 15.3337 20.0084C15.3337 21.6552 15.3183 22.978 15.3183 23.3779C15.3183 23.7009 15.5336 24.0854 16.1642 23.9623C21.0871 22.3484 24.6094 17.7341 24.6094 12.3047C24.6094 5.50942 19.0999 0 12.3047 0Z"
/>
</svg>
</a>
<a
href="https://twitter.com/angular"
aria-label="Twitter"
target="_blank"
rel="noopener"
>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
alt="Twitter"
>
<path
d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"
/>
</svg>
</a>
<a
href="https://www.youtube.com/channel/UCbn1OgGei-DV7aSRo_HaAiw"
aria-label="Youtube"
target="_blank"
rel="noopener"
>
<svg
width="29"
height="20"
viewBox="0 0 29 20"
fill="none"
xmlns="http://www.w3.org/2000/svg"
alt="Youtube"
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M27.4896 1.52422C27.9301 1.96749 28.2463 2.51866 28.4068 3.12258C29.0004 5.35161 29.0004 10 29.0004 10C29.0004 10 29.0004 14.6484 28.4068 16.8774C28.2463 17.4813 27.9301 18.0325 27.4896 18.4758C27.0492 18.9191 26.5 19.2389 25.8972 19.4032C23.6778 20 14.8068 20 14.8068 20C14.8068 20 5.93586 20 3.71651 19.4032C3.11363 19.2389 2.56449 18.9191 2.12405 18.4758C1.68361 18.0325 1.36732 17.4813 1.20683 16.8774C0.613281 14.6484 0.613281 10 0.613281 10C0.613281 10 0.613281 5.35161 1.20683 3.12258C1.36732 2.51866 1.68361 1.96749 2.12405 1.52422C2.56449 1.08095 3.11363 0.76113 3.71651 0.596774C5.93586 0 14.8068 0 14.8068 0C14.8068 0 23.6778 0 25.8972 0.596774C26.5 0.76113 27.0492 1.08095 27.4896 1.52422ZM19.3229 10L11.9036 5.77905V14.221L19.3229 10Z"
/>
</svg>
</a>
</div>
</div>
<div *ngFor="let link of links">
<a routerLink="{{link.$link}}" routerLinkActive="active" ariaCurrentWhenActive="page">{{link.$name}}</a>
</div>
</main>
</div>
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<!-- * * * * * * * * * * * The content above * * * * * * * * * * * * -->
<!-- * * * * * * * * * * is only a placeholder * * * * * * * * * * * -->
<!-- * * * * * * * * * * and can be replaced. * * * * * * * * * * * -->
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<!-- * * * * * * * * * * End of Placeholder * * * * * * * * * * * * -->
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<router-outlet></router-outlet>
<router-outlet />
</body>
</html>

@ -1,13 +1,36 @@
import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import {Component, NgModule} from '@angular/core';
import {Router, RouterLink, RouterLinkActive, RouterOutlet} from '@angular/router';
import {RecipeFormComponent} from "./component/recipe-form/recipe-form.component";
import {AccueilComponent} from "./component/accueil/accueil.component";
import {NgForOf, NgIf} from "@angular/common";
import {RecipeListComponent} from "./component/recipe-list/recipe-list.component";
import {LoginService} from "./service/login.service";
import {Link} from "./model/link.model";
import {LinkService} from "./service/link.service";
@Component({
selector: 'app-root',
standalone: true,
imports: [RouterOutlet],
imports: [RouterOutlet, AccueilComponent, RecipeFormComponent, NgForOf, NgIf, RecipeListComponent, RouterLink, RouterLinkActive],
templateUrl: './app.component.html',
styleUrl: './app.component.css'
})
export class AppComponent {
title = 'daidokoro';
links : Link[] = this.linkService.getLinks()
constructor(private loginService: LoginService,private linkService: LinkService) {
}
onClickLogin(event: Event): void {
event.preventDefault();
this.loginService.login();
}
onClickLogout(event: Event): void {
event.preventDefault();
this.loginService.logout();
}
isLogged(): boolean {
return this.loginService.isLogged();
}
}

@ -1,8 +1,13 @@
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
import { provideRouter } from '@angular/router';
import {provideRouter, withComponentInputBinding} from '@angular/router';
import { routes } from './app.routes';
import { provideHttpClient } from "@angular/common/http";
export const appConfig: ApplicationConfig = {
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes)]
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
provideRouter(routes,withComponentInputBinding()),
provideHttpClient()
]
};

@ -1,3 +1,13 @@
import { Routes } from '@angular/router';
import {AuthGuard} from "./guard.guard";
import {IngredientsComponent} from "./component/ingredients/ingredients.component";
import {AccueilComponent} from "./component/accueil/accueil.component";
import {RecipeDetailComponent} from "./component/recipe-detail/recipe-detail.component";
import {CommandComponent} from "./component/command/command.component";
export const routes: Routes = [];
export const routes: Routes = [
{path: 'ingredients', component:IngredientsComponent,canActivate: [AuthGuard]},
{path: 'recipe/:id', component: RecipeDetailComponent},
{path: '', component:AccueilComponent},
{path: 'command', component: CommandComponent}
];

@ -0,0 +1,62 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Daidokoro</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Karma">
<style>
body, h1, h2, h3, h4, h5, h6 {
font-family: "Karma", sans-serif;
margin: 0;
padding: 0;
}
.content {
padding: 20px;
display: flex;
gap: 20px;
}
.recipe-container, .form-container {
background-color: #bab6b6;
color: black;
padding: 20px;
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;
}
</style>
</head>
<body>
<div class="content" [class.show-form]="isFormVisible">
<div class="recipe-container">
<h2>Liste Recettes</h2>
<div class="button-container">
<button (click)="toggleForm()">Ajouter une recette</button>
</div>
<app-recipe-list [isFormVisible]="isFormVisible"></app-recipe-list>
</div>
<div class="form-container" *ngIf="isFormVisible">
<app-recipe-form (formSubmitted)="onRecipeSubmitted($event)"></app-recipe-form>
</div>
</div>
</body>
</html>

@ -0,0 +1,40 @@
import { Component } from '@angular/core';
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 {LoginService} from "../../service/login.service";
import {CommonModule} from "@angular/common";
@Component({
selector: 'app-accueil',
standalone: true,
imports: [
RecipeListComponent,
RecipeFormComponent,
CommonModule,
NgForOf,
],
templateUrl: './accueil.component.html'
})
export class AccueilComponent {
isFormVisible: boolean = false;
constructor(private recipeService: RecipeService) {
}
onRecipeSubmitted(recipe : Recipe){
this.recipeService.addRecipe(recipe);
}
toggleForm() {
this.isFormVisible = !this.isFormVisible;
}
}

@ -0,0 +1,51 @@
<style>
.command-list {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 20px;
display: flex;
flex-direction: column;
align-items: center;
}
.recipe-item {
background-color: #fff;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
margin: 10px 0;
padding: 10px 20px;
width: 80%;
display: flex;
justify-content: space-between;
align-items: center;
}
.recipe-item h3 {
margin: 0;
}
.recipe-item button {
background-color: #ff5252;
color: #fff;
border: none;
border-radius: 5px;
padding: 5px 10px;
cursor: pointer;
}
.recipe-item button:hover {
background-color: #ff0000;
}
</style>
<div class="command-list">
<h2>Ma Commande</h2>
<div *ngFor="let recipe of recipes" class="recipe-item">
<img src="{{recipe.$image}}" width="10%" alt="ImageRecipe"
onerror="this.onerror=null;this.src='https://placehold.co/100x100/black/white?text=Not+Found';">
<h3>{{ recipe.$name }}</h3>
<button (click)="removeRecipe(recipe)">Retirer</button>
</div>
<p *ngIf="recipes.length === 0">Aucune recette dans la commande.</p>
</div>

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CommandComponent } from './command.component';
describe('CommandComponent', () => {
let component: CommandComponent;
let fixture: ComponentFixture<CommandComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [CommandComponent]
})
.compileComponents();
fixture = TestBed.createComponent(CommandComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -0,0 +1,25 @@
import { Component } from '@angular/core';
import { CommandService } from '../../service/command.service';
import { Recipe } from '../../model/recipe.model';
import {NgFor, NgIf} from '@angular/common';
import { RouterLink } from '@angular/router';
@Component({
selector: 'app-command',
standalone: true,
imports: [NgFor, RouterLink, NgIf],
templateUrl: './command.component.html'
})
export class CommandComponent {
recipes: Recipe[] = [];
errorMessage: string | null = null;
constructor(private commandService: CommandService) {
this.recipes = this.commandService.getRecipes();
}
removeRecipe(recipe: Recipe) {
this.commandService.removeRecipe(recipe);
this.recipes = this.commandService.getRecipes();
}
}

@ -0,0 +1,118 @@
<style>
.ingredients {
font-family: Arial, sans-serif;
background-color: #bab6b6;
margin: 0;
padding: 20px;
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.ingredient-card {
background-color: #fff;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
overflow: hidden;
transition: transform 0.2s;
width: 200px;
margin: 20px;
}
.ingredient-card:hover {
transform: scale(1.05);
}
.ingredient-content {
padding: 15px;
}
.ingredient-title {
font-size: 1em;
margin: 0 0 10px;
}
.ingredient-actions {
margin-top: 10px;
}
.ingredient-actions button {
margin-right: 5px;
}
.general-form-add {
margin-top: 2%;
background-color: #bab6b6;
float: left;
width: 49%;
}
.general-form-edit {
margin-top: 2%;
background-color: #bab6b6;
float: right;
width: 49%;
}
.form-group {
margin-bottom: 10px;
margin-right: 2%;
margin-left: 2%
}
.form-group label {
display: block;
margin-bottom: 5px;
}
.form-group input, .form-group textarea {
width: 100%;
padding: 8px;
box-sizing: border-box;
}
.button-form{
margin-left: 2%;
}
</style>
<body>
<div class="ingredients">
<div class="ingredient-card" *ngFor="let ingredient of ingredients">
<div class="ingredient-content">
<h2 class="ingredient-title">{{ ingredient.name }}</h2>
<p>{{ ingredient.description }}</p>
<div class="ingredient-actions">
<button (click)="edit(ingredient)">Modifier</button>
</div>
</div>
</div>
</div>
<div class="general-form-add">
<h2>Ajouter un ingrédient</h2>
<div class="form-group">
<label for="newName">Nom:</label>
<input id="newName" [(ngModel)]="newIngredient.name" required>
</div>
<div class="form-group">
<label for="newDescription">Description:</label>
<textarea id="newDescription" [(ngModel)]="newIngredient.description" required></textarea>
</div>
<button class="button-form" (click)="addIngredient()">Ajouter</button>
</div>
<div *ngIf="editIngredient" class="general-form-edit">
<h2>Modifier l'ingrédient</h2>
<div class="form-group">
<label for="editName">Nom:</label>
<input id="editName" [(ngModel)]="editIngredient.name">
</div>
<div class="form-group">
<label for="editDescription">Description:</label>
<textarea id="editDescription" [(ngModel)]="editIngredient.description"></textarea>
</div>
<button class="button-form" (click)="updateIngredient()">Enregistrer</button>
<button class="button-form" (click)="cancelEdit()">Annuler</button>
</div>
</body>

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { IngredientsComponent } from './ingredients.component';
describe('IngredientsComponent', () => {
let component: IngredientsComponent;
let fixture: ComponentFixture<IngredientsComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [IngredientsComponent]
})
.compileComponents();
fixture = TestBed.createComponent(IngredientsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -0,0 +1,62 @@
import { Component, OnInit } from '@angular/core';
import { IngredientService } from "../../service/ingredient.service";
import { Ingredient } from "../../model/ingredient.model";
import { NgFor, NgIf } from "@angular/common";
import { FormsModule } from "@angular/forms";
import { HttpClient } from "@angular/common/http";
@Component({
selector: 'app-ingredients',
standalone: true,
imports: [
NgFor,
NgIf,
FormsModule
],
providers: [IngredientService, HttpClient],
templateUrl: './ingredients.component.html',
styleUrl: './ingredients.component.css'
})
export class IngredientsComponent implements OnInit {
ingredients: Ingredient[] = [];
newIngredient: Ingredient = { id: '0', name: '', description: '' };
editIngredient: Ingredient | null = null;
constructor(private ingredientService: IngredientService) {}
ngOnInit() {
this.loadIngredients();
}
loadIngredients() {
this.ingredientService.getAll().subscribe(ingredients => {
this.ingredients = ingredients;
});
}
addIngredient() {
this.ingredientService.add(this.newIngredient).subscribe(ingredient => {
this.ingredients.push(ingredient);
this.newIngredient = { id: '0', name: '', description: '' };
});
}
edit(ingredient: Ingredient) {
this.editIngredient = { ...ingredient };
}
updateIngredient() {
if (this.editIngredient) {
this.ingredientService.update(this.editIngredient).subscribe(updatedIngredient => {
const index = this.ingredients.findIndex(i => i.id === updatedIngredient.id);
this.ingredients[index] = updatedIngredient;
this.editIngredient = null;
});
}
}
cancelEdit() {
this.editIngredient = null;
}
}

@ -0,0 +1,85 @@
<style>
.recipe-details {
font-family: Arial, sans-serif;
background-color: #bab6b6;
margin: 0;
padding: 20px;
display: flex;
flex-direction: column;
align-items: center;
}
.recipe-card {
background-color: #fff;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
overflow: hidden;
transition: transform 0.2s;
width: 80%;
margin: 20px;
padding: 20px;
}
.recipe-card:hover {
transform: scale(1.05);
}
.recipe-image {
width: 100%;
max-width: 300px;
border-radius: 10px;
}
.recipe-content {
padding: 15px;
text-align: center;
}
.recipe-title {
font-size: 2em;
margin: 0 0 10px;
}
.recipe-date {
color: #777;
margin-bottom: 20px;
}
.recipe-description {
font-size: 1.2em;
margin: 20px 0;
}
.ingredient-list {
list-style-type: none;
padding: 0;
}
.ingredient-item {
background-color: #f9f9f9;
border: 1px solid #ddd;
border-radius: 5px;
padding: 10px;
margin: 5px 0;
}
</style>
<div class="recipe-details">
<div class="recipe-card">
<h1 class="recipe-title">{{ recipe?.$name }}</h1>
<p class="recipe-date">{{ recipe?.$createdAt }}</p>
<img [src]="recipe?.$image" alt="{{ recipe?.$name }}" class="recipe-image"
onerror="this.onerror=null;this.src='https://placehold.co/300x300/black/white?text=Not+Found';">
<div class="recipe-content">
<h3 class="recipe-description">{{ recipe?.$description }}</h3>
<h4>Ingrédients</h4>
<ul class="ingredient-list">
<li class="ingredient-item" *ngFor="let ingredient of ingredients">
{{ ingredient.ingredient.name }} : {{ ingredient.quantity }} {{ ingredient.unit }}
</li>
</ul>
</div>
</div>
</div>

@ -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<RecipeDetailComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [RecipeDetailComponent]
})
.compileComponents();
fixture = TestBed.createComponent(RecipeDetailComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -0,0 +1,31 @@
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";
import {QuantifiedIngredientGetter} from "../../model/quantified-ingredient-getter.model";
@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;
ingredients : QuantifiedIngredientGetter[] = [];
constructor(private recipeService : RecipeService) {
}
@Input()
set id(id: number) {
this.recipe = this.recipeService.getRecipe(id)!;
this.ingredients = this.recipe.$ingredients;
}
}

@ -0,0 +1,138 @@
<style>
body {
font-family: Arial, sans-serif;
background-color: #bab6b6;
margin: 0;
padding: 20px;
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.form-container {
background-color: #fff;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
padding: 20px;
width: 100%;
}
.form-container h2 {
margin-top: 0;
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 5px;
}
.form-group input,
.form-group select,
.form-group button {
width: 97%;
padding: 10px;
margin-top: 5px;
border: 1px solid #ccc;
border-radius: 5px;
}
.form-group button {
background-color: black;
color: white;
border: none;
cursor: pointer;
}
.form-group button:hover {
background-color: #525259;
}
.form-group .remove-button {
background-color: red;
}
.form-group .remove-button:hover {
background-color: darkred;
}
.add-ingredient-button {
background-color: #4CAF50;
color: white;
}
.add-ingredient-button:hover {
background-color: #45a049;
}
.submit-button {
background-color: black;
color: white;
}
.submit-button:hover {
background-color: #525259;
}
.error-message {
color: red;
font-size: 0.9em;
margin-top: 5px;
}
.form-group.invalid input,
.form-group.invalid select {
border-color: red;
}
</style>
<body>
<div class="form-container">
<h2>Ajouter une Recette</h2>
<form [formGroup]="recipeForm" (ngSubmit)="onSubmit()">
<div class="form-group" [class.invalid]="recipeForm.get('id')?.invalid && recipeForm.get('id')?.touched">
<label for="id">ID: </label>
<input id="id" type="number" formControlName="id" required>
<div class="error-message" *ngIf="recipeForm.get('id')?.invalid && recipeForm.get('id')?.touched">
L'ID est requis.
</div>
</div>
<div class="form-group" [class.invalid]="recipeForm.get('name')?.invalid && recipeForm.get('name')?.touched">
<label for="name">Name: </label>
<input id="name" type="text" formControlName="name" required>
<div class="error-message" *ngIf="recipeForm.get('name')?.invalid && recipeForm.get('name')?.touched">
Le nom est requis.
</div>
</div>
<div class="form-group" [class.invalid]="recipeForm.get('description')?.invalid && recipeForm.get('description')?.touched">
<label for="description">Description: </label>
<input id="description" type="text" formControlName="description" required>
<div class="error-message" *ngIf="recipeForm.get('description')?.invalid && recipeForm.get('description')?.touched">
La description est requise.
</div>
</div>
<label for="image">Image: </label>
<input id="image" type="file" (change)="onFileChange($event)">
<br>
<div *ngIf="imageBase64">
<img [src]="imageBase64" alt="Selected Image" style="max-width: 200px; max-height: 200px;">
</div>
<br>
<div formArrayName="ingredients">
<div *ngFor="let ingredient of ingredients.controls; let i=index" [formGroupName]="i" class="form-group">
<label for="ingredient-quantity">Quantity:</label>
<input id="ingredient-quantity" type="number" formControlName="quantity" required>
<label for="ingredient-unit">Unit:</label>
<select id="ingredient-unit" formControlName="unit" required>
<option *ngFor="let unit of unity" [value]="unit">{{ unit }}</option>
</select>
<label for="ingredient-name">Ingredient:</label>
<select id="ingredient-name" formControlName="ingredient" required>
<option *ngFor="let ingredient of ingredientsList" [value]="ingredient.name">{{ ingredient.name }}</option>
</select>
<button type="button" class="remove-button" (click)="removeIngredient(i)">Remove</button>
</div>
</div>
<button type="button" class="add-ingredient-button" (click)="addIngredient()">Add Ingredient</button>
<p>Complete the form to enable the button.</p>
<button type="submit" class="submit-button">Submit</button>
</form>
</div>
</body>

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RecipeFormComponent } from './recipe-form.component';
describe('RecipeFormComponent', () => {
let component: RecipeFormComponent;
let fixture: ComponentFixture<RecipeFormComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [RecipeFormComponent]
})
.compileComponents();
fixture = TestBed.createComponent(RecipeFormComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -0,0 +1,99 @@
import { Component, EventEmitter, Output } from '@angular/core';
import { Recipe } from "../../model/recipe.model";
import { FormControl, FormGroup, ReactiveFormsModule, FormArray, FormBuilder, Validators } from "@angular/forms";
import { Ingredient } from '../../model/ingredient.model';
import { Unity } from '../../model/unity';
import { IngredientService } from '../../service/ingredient.service';
import {NgFor, NgIf} from "@angular/common";
@Component({
selector: 'app-recipe-form',
standalone: true,
imports: [ReactiveFormsModule, NgFor, NgIf],
templateUrl: './recipe-form.component.html'
})
export class RecipeFormComponent {
@Output() formSubmitted = new EventEmitter<Recipe>();
ingredientsList: Ingredient[] = [];
unity = Object.values(Unity);
imageBase64: string | null = null;
constructor(private formBuilder: FormBuilder, private ingredientService: IngredientService) { }
ngOnInit(): void {
this.ingredientService.getAll().subscribe(ingredients => {
this.ingredientsList = ingredients;
});
}
recipeForm: FormGroup = this.formBuilder.group({
id: new FormControl('', { nonNullable: true, validators: [Validators.required] }),
name: new FormControl('', { nonNullable: true, validators: [Validators.required] }),
description: new FormControl('', { nonNullable: true, validators: [Validators.required] }),
ingredients: this.formBuilder.array([this.newIngredient()]),
image: new FormControl('', {nonNullable: false})
});
get ingredients(): FormArray {
return this.recipeForm.get('ingredients') as FormArray;
}
newIngredient(): FormGroup {
return this.formBuilder.group({
quantity: new FormControl(0, { nonNullable: true, validators: [Validators.required] }),
unit: new FormControl('', { nonNullable: true, validators: [Validators.required] }),
ingredient: new FormControl('', { nonNullable: true, validators: [Validators.required] })
});
}
addIngredient() {
this.ingredients.push(this.newIngredient());
}
removeIngredient(index: number) {
if (this.ingredients.length > 1) {
this.ingredients.removeAt(index);
} else {
}
}
onFileChange(event: Event) {
const input = event.target as HTMLInputElement;
if (input.files && input.files[0]) {
const file = input.files[0];
const reader = new FileReader();
reader.onload = () => {
this.imageBase64 = reader.result as string;
this.recipeForm.patchValue({image: this.imageBase64});
};
reader.readAsDataURL(file);
}
}
onSubmit() {
if (this.recipeForm.valid) {
const recipe: Recipe = {
$id: parseInt(this.recipeForm.value.id!),
$name: this.recipeForm.value.name!,
$description: this.recipeForm.value.description!,
$createdAt: new Date(),
$ingredients: this.recipeForm.value.ingredients!.map((ingredient: any) => ({
quantity: ingredient.quantity,
unit: ingredient.unit,
ingredient: this.ingredientsList.find(ing => ing.name === ingredient.ingredient)
})),
$image: this.recipeForm.value.image
};
this.formSubmitted.emit(recipe);
this.recipeForm.reset()
this.ingredients.clear()
this.imageBase64 = null;
this.addIngredient()
}else{
alert("Veuillez remplir tous les champs")
}
}
}

@ -0,0 +1,99 @@
<style>
body {
font-family: Arial, sans-serif;
background-color: #bab6b6;
margin: 0;
padding: 20px;
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.recipe-container {
display: grid;
gap: 20px;
width: 100%;
}
.recipe-card {
background-color: #fff;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
overflow: hidden;
transition: transform 0.2s;
}
.recipe-card:hover {
transform: scale(1.05);
}
.recipe-image {
width: 100%;
height: 200px;
object-fit: cover;
}
.recipe-content {
padding: 15px;
}
.recipe-title {
font-size: 1.5em;
margin: 0 0 10px;
}
.recipe-description {
font-size: 1em;
color: #666;
}
.details-button {
display: inline-block;
padding: 10px 15px;
background-color: black;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
margin-top: 10px;
}
.details-button:hover {
background-color: #525259;
}
.four-column {
grid-template-columns: repeat(4, 1fr);
}
.two-column {
grid-template-columns: repeat(2, 1fr);
}
.pagination {
display: flex;
justify-content: center;
margin-top: 20px;
}
.page-link {
padding: 10px;
margin: 0 5px;
cursor: pointer;
background-color: #ddd;
border: 1px solid #bbb;
border-radius: 5px;
}
.error-message {
color: red;
font-weight: bold;
margin-bottom: 4%;
}
</style>
<body>
<div *ngIf="errorMessageDisplay" class="error-message">{{ errorMessage }}</div>
<div [ngClass]="{'four-column': !isFormVisible, 'two-column': isFormVisible}" class="recipe-container">
<div class="recipe-card" *ngFor="let recipe of paginatedRecipes">
<img [src]="recipe.$image" alt="Recette 1" class="recipe-image"
onerror="this.onerror=null;this.src='https://placehold.co/100x100/black/white?text=Not+Found';">
<div class="recipe-content">
<h2 class="recipe-title">{{recipe.$name}}</h2>
<p class="recipe-description">{{recipe.$description}}</p>
<button (click)="detailsRecipe(recipe.$id)" class="details-button">Détails</button>
<button (click)="addToCommand(recipe)" class="details-button" >Ajouter à ma commande</button>
</div>
</div>
</div>
<div class="pagination">
<button class="page-link" (click)="previousPage()" [disabled]="currentPage === 0">Précédent</button>
<p>{{ currentPage +1 }}</p>
<button class="page-link" (click)="nextPage()" [disabled]="currentPage === totalPages - 1">Suivant</button>
</div>
</body>

@ -0,0 +1,78 @@
import {Component, Input, OnInit} from '@angular/core';
import { RecipeService } from '../../service/recipe.service';
import { Recipe } from '../../model/recipe.model';
import {NgClass, NgIf, NgOptimizedImage} from "@angular/common";
import {NgFor} from "@angular/common";
import {Router, RouterLinkActive} from "@angular/router";
import {CommandService} from "../../service/command.service";
@Component({
selector: 'app-recipe-list',
templateUrl: './recipe-list.component.html',
imports: [
NgOptimizedImage,
NgFor,
NgClass,
RouterLinkActive,
NgIf
],
standalone: true
})
export class RecipeListComponent implements OnInit {
recipes: Recipe[] = [];
errorMessageDisplay: boolean = false;
errorMessage: string | null = null;
@Input() isFormVisible!: boolean;
currentPage: number = 0;
pageSize: number = 4;
totalPages: any = 0;
constructor(private recipeService: RecipeService,private router : Router, private commandService: CommandService) {}
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++;
}
}
detailsRecipe(id : number){
this.router.navigateByUrl('/recipe/'+id);
}
addToCommand(recipe: Recipe) {
try {
this.commandService.addRecipe(recipe);
this.errorMessageDisplay = false;
} catch (e) {
if (e instanceof DOMException && e.name === 'QuotaExceededError') {
this.errorMessageDisplay = true;
this.errorMessage = 'Local Storage saturé, impossible d\'ajouter la recette dans le local storage des commandes.';
} else {
throw e;
}
}
}
}

@ -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 dolive' },
// { $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' }
]

@ -1,6 +1,8 @@
import {Link} from "../model/link.model";
export var LINKS :Link[] = [
{$name:"Lien1",$link:"Lien1"},
{$name:"Lien2",$link:'Lien2'}
]
{$name:"Accueil",$link:""},
{$name:"Ingredients",$link:"/ingredients"},
{$name:"Commande",$link:"/command"}
]

@ -0,0 +1,15 @@
import {CanActivateFn, Router} from '@angular/router';
import {LoginService} from "./service/login.service";
import {inject} from "@angular/core";
export const AuthGuard: CanActivateFn = (route, state) => {
const auth = inject(LoginService)
const router = inject(Router);
if(!auth.isLogged()){
router.navigateByUrl('/');
return false;
}
return true;
};

@ -1,5 +1,6 @@
export interface Ingredient {
$id : number,
$name : string
id : string,
name : string,
description : string,
}

@ -0,0 +1,23 @@
import { Unity } from "./unity";
import { Ingredient } from "./ingredient.model";
import { QuantifiedIngredient } from "./quantified-ingredient.model";
export class QuantifiedIngredientGetter implements QuantifiedIngredient {
constructor(
public $quantity: number,
public $unit: Unity,
public $ingredient: Ingredient
) {}
get quantity(): number {
return this.$quantity;
}
get unit(): Unity {
return this.$unit;
}
get ingredient(): Ingredient {
return this.$ingredient;
}
}

@ -1,8 +1,8 @@
import {Unite} from "./unity";
import {Ingredient} from "./ingredient.model";
import { Unity } from "./unity";
import { Ingredient } from "./ingredient.model";
export interface QuantifiedIngredient {
$quantity : number,
$unit : Unite,
$ingredient : Ingredient
$quantity: number;
$unit: Unity;
$ingredient: Ingredient;
}

@ -1,9 +1,10 @@
import {QuantifiedIngredient} from "./quantified-ingredient.model";
import {QuantifiedIngredientGetter} from "./quantified-ingredient-getter.model";
export interface Recipe {
$id : number,
$name : string,
$description: string,
$createdAt : Date,
$ingredients: QuantifiedIngredient[]
$ingredients: QuantifiedIngredientGetter[],
$image?: string
}

@ -0,0 +1,25 @@
import { Injectable } from '@angular/core';
import { Recipe } from "../model/recipe.model";
@Injectable({
providedIn: 'root'
})
export class CommandService {
private recipes: Recipe[] = JSON.parse(localStorage.getItem('command') || '[]');
addRecipe(recipe: Recipe) {
this.recipes.push(recipe);
localStorage.setItem('command', JSON.stringify(this.recipes));
}
getRecipes(): Recipe[] {
return this.recipes;
}
removeRecipe(recipe: Recipe) {
const index = this.recipes.indexOf(recipe);
if (index > -1) {
this.recipes.splice(index, 1);
}
}
}

@ -1,16 +1,26 @@
import { Injectable } from '@angular/core';
import {Ingredient} from "../model/ingredient.model";
import {$INGREDIENTS} from "../data/ingredient.stub";
import { Ingredient } from "../model/ingredient.model";
import { Observable } from "rxjs";
import { HttpClient } from "@angular/common/http";
@Injectable({
providedIn: 'root'
})
export class IngredientService {
constructor() { }
private apiUrl = 'https://664ba07f35bbda10987d9f99.mockapi.io/api/ingredients';
constructor(private http: HttpClient) { }
getAll(): Observable<Ingredient[]> {
return this.http.get<Ingredient[]>(this.apiUrl);
}
add(ingredient: Ingredient): Observable<Ingredient> {
return this.http.post<Ingredient>(this.apiUrl, ingredient);
}
getAll() : Ingredient[] {
return $INGREDIENTS;
update(ingredient: Ingredient): Observable<Ingredient> {
return this.http.put<Ingredient>(`${this.apiUrl}/${ingredient.id}`, ingredient);
}
}

@ -0,0 +1,20 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class LoginService {
login(): void {
localStorage.setItem('login', 'true');
}
logout(): void {
localStorage.setItem('login', 'false');
}
isLogged(): boolean {
const login = localStorage.getItem('login');
return login === 'true';
}
}

@ -1,15 +1,21 @@
import { Injectable } from '@angular/core';
import {Recipe} from "../model/recipe.model";
import {$RECEPIES} from "../data/recipe.stub";
import { Recipe } from '../model/recipe.model';
@Injectable({
providedIn: 'root'
})
export class RecipeService {
private recipes: Recipe[] = JSON.parse(localStorage.getItem('recipes') || '[]');
constructor() { }
getRecipes(): Recipe[] {
return this.recipes;
}
getAll() : Recipe[]{
return $RECEPIES;
addRecipe(recipe: Recipe): void {
this.recipes.push(recipe);
localStorage.setItem('recipes', JSON.stringify(this.recipes));
}
getRecipe($id:number):Recipe{
return this.recipes.find(x => x.$id == $id)!
}
}

@ -1,5 +1,5 @@
import { TestBed } from '@angular/core/testing';
import { AppComponent } from './app.component';
import { AppComponent } from '../../app/app.component';
describe('AppComponent', () => {
beforeEach(async () => {

@ -0,0 +1,17 @@
import { TestBed } from '@angular/core/testing';
import { CanActivateFn } from '@angular/router';
import { AuthGuard } from '../../app/guard.guard';
describe('guardGuard', () => {
const executeGuard: CanActivateFn = (...guardParameters) =>
TestBed.runInInjectionContext(() => AuthGuard(...guardParameters));
beforeEach(() => {
TestBed.configureTestingModule({});
});
it('should be created', () => {
expect(executeGuard).toBeTruthy();
});
});

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { LoginService } from '../../app/service/login.service';
describe('LoginService', () => {
let service: LoginService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(LoginService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
Loading…
Cancel
Save