parent
62b1b37320
commit
dafff55563
@ -1,2 +1,80 @@
|
|||||||
<app-accueil></app-accueil>
|
<!DOCTYPE html>
|
||||||
<!-- <app-recipe-form></app-recipe-form> -->
|
<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;
|
||||||
|
}
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
.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="navbar">
|
||||||
|
<div *ngIf="isLogged()">
|
||||||
|
<a href="/" (click)="onClickLogout($event)">Logout</a>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="!isLogged()">
|
||||||
|
<a href="" (click)="onClickLogin($event)">Login</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div *ngFor="let link of links">
|
||||||
|
<a routerLink="{{link.$link}}" routerLinkActive="active" ariaCurrentWhenActive="page">{{link.$name}}</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<router-outlet></router-outlet>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
@ -1,15 +1,37 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { RouterOutlet } from '@angular/router';
|
import {Router, RouterLink, RouterLinkActive, RouterOutlet} from '@angular/router';
|
||||||
import {RecipeFormComponent} from "./component/recipe-form/recipe-form.component";
|
import {RecipeFormComponent} from "./component/recipe-form/recipe-form.component";
|
||||||
import {AccueilComponent} from "./component/accueil/accueil.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({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [RouterOutlet, AccueilComponent,RecipeFormComponent],
|
imports: [RouterOutlet, AccueilComponent, RecipeFormComponent, NgForOf, NgIf, RecipeListComponent, RouterLink, RouterLinkActive],
|
||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
styleUrl: './app.component.css'
|
styleUrl: './app.component.css'
|
||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent {
|
||||||
title = 'daidokoro';
|
links : Link[] = this.linkService.getLinks()
|
||||||
|
|
||||||
|
constructor(private loginService: LoginService,private linkService: LinkService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
|
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
|
||||||
import { provideRouter } from '@angular/router';
|
import {provideRouter, withComponentInputBinding} from '@angular/router';
|
||||||
|
|
||||||
import { routes } from './app.routes';
|
import { routes } from './app.routes';
|
||||||
|
|
||||||
export const appConfig: ApplicationConfig = {
|
export const appConfig: ApplicationConfig = {
|
||||||
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes)]
|
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes,withComponentInputBinding())]
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
import { Routes } from '@angular/router';
|
import { Routes } from '@angular/router';
|
||||||
import {AuthGuard} from "./guard.guard";
|
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";
|
||||||
|
|
||||||
export const routes: Routes = [
|
export const routes: Routes = [
|
||||||
|
{path: 'ingredients', component:IngredientsComponent,canActivate: [AuthGuard]},
|
||||||
|
{path: 'recipe/:id', component: RecipeDetailComponent},
|
||||||
|
{path: '', component:AccueilComponent}
|
||||||
];
|
];
|
||||||
|
Loading…
Reference in new issue