Compare commits
No commits in common. "master" and "feature/02" have entirely different histories.
master
...
feature/02
56 changed files with 262 additions and 524 deletions
BIN
PrésentationSession1_06022025.pptx
Normal file
BIN
PrésentationSession1_06022025.pptx
Normal file
Binary file not shown.
59
README.md
59
README.md
|
|
@ -1,59 +0,0 @@
|
||||||
# Angular
|
|
||||||
|
|
||||||
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.1.6.
|
|
||||||
|
|
||||||
## Development server
|
|
||||||
|
|
||||||
To start a local development server, run:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
ng serve
|
|
||||||
```
|
|
||||||
|
|
||||||
Once the server is running, open your browser and navigate to `http://localhost/`. The application will automatically reload whenever you modify any of the source files.
|
|
||||||
|
|
||||||
## Code scaffolding
|
|
||||||
|
|
||||||
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
ng generate component component-name
|
|
||||||
```
|
|
||||||
|
|
||||||
For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
ng generate --help
|
|
||||||
```
|
|
||||||
|
|
||||||
## Building
|
|
||||||
|
|
||||||
To build the project run:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
ng build
|
|
||||||
```
|
|
||||||
|
|
||||||
This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed.
|
|
||||||
|
|
||||||
## Running unit tests
|
|
||||||
|
|
||||||
To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
ng test
|
|
||||||
```
|
|
||||||
|
|
||||||
## Running end-to-end tests
|
|
||||||
|
|
||||||
For end-to-end (e2e) testing, run:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
ng e2e
|
|
||||||
```
|
|
||||||
|
|
||||||
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
|
|
||||||
|
|
||||||
## Additional Resources
|
|
||||||
|
|
||||||
For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
|
|
||||||
0
.gitignore → angular/.gitignore
vendored
0
.gitignore → angular/.gitignore
vendored
59
angular/README.md
Normal file
59
angular/README.md
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
# Angular
|
||||||
|
|
||||||
|
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.1.6.
|
||||||
|
|
||||||
|
## Development server
|
||||||
|
|
||||||
|
To start a local development server, run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ng serve
|
||||||
|
```
|
||||||
|
|
||||||
|
Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.
|
||||||
|
|
||||||
|
## Code scaffolding
|
||||||
|
|
||||||
|
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ng generate component component-name
|
||||||
|
```
|
||||||
|
|
||||||
|
For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ng generate --help
|
||||||
|
```
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
To build the project run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ng build
|
||||||
|
```
|
||||||
|
|
||||||
|
This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed.
|
||||||
|
|
||||||
|
## Running unit tests
|
||||||
|
|
||||||
|
To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ng test
|
||||||
|
```
|
||||||
|
|
||||||
|
## Running end-to-end tests
|
||||||
|
|
||||||
|
For end-to-end (e2e) testing, run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ng e2e
|
||||||
|
```
|
||||||
|
|
||||||
|
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
|
||||||
|
|
||||||
|
## Additional Resources
|
||||||
|
|
||||||
|
For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
|
||||||
|
|
@ -40,9 +40,7 @@
|
||||||
"src/styles.css",
|
"src/styles.css",
|
||||||
"node_modules/bootstrap/dist/css/bootstrap.min.css"
|
"node_modules/bootstrap/dist/css/bootstrap.min.css"
|
||||||
],
|
],
|
||||||
"scripts": [
|
"scripts": []
|
||||||
"node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"production": {
|
"production": {
|
||||||
0
package-lock.json → angular/package-lock.json
generated
0
package-lock.json → angular/package-lock.json
generated
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
37
angular/src/app/about/about.component.html
Normal file
37
angular/src/app/about/about.component.html
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
<div class="container d-flex flex-column align-items-center mt-4">
|
||||||
|
<!-- Liste des informations avec un style amélioré -->
|
||||||
|
<ul class="list-group w-50 shadow-sm mb-4">
|
||||||
|
<li class="list-group-item active text-center">Informations</li>
|
||||||
|
<li class="list-group-item">{{info.name}}</li>
|
||||||
|
<li class="list-group-item">{{info.email}}</li>
|
||||||
|
<li class="list-group-item">{{info.phone}}</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<!-- Champ d'entrée réduit et centré -->
|
||||||
|
<div class="w-50">
|
||||||
|
<div class="input-group mb-3 shadow-sm">
|
||||||
|
<span class="input-group-text">Message</span>
|
||||||
|
<input type="text" [(ngModel)]="comment.message" (keydown.enter)="addComment()" class="form-control">
|
||||||
|
<button type="submit" (click)="addComment()" class="btn btn-primary">Add</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Liste des commentaires -->
|
||||||
|
<div *ngIf="comments.length > 0; else noComment" class="d-flex flex-column align-items-center w-50">
|
||||||
|
<h3 class="text-center text-primary">Liste des commentaires</h3>
|
||||||
|
<ol class="list-group list-group-numbered shadow-sm">
|
||||||
|
<li class="list-group-item d-flex justify-content-between align-items-start" *ngFor="let comment of comments">
|
||||||
|
<div class="ms-2 me-auto">
|
||||||
|
<div class="fw-bold breakWord">{{ comment.message }}</div>
|
||||||
|
</div>
|
||||||
|
<!-- <span> </span> -->
|
||||||
|
<span class="badge text-bg-primary rounded-pill SpaceMargin-02">{{ comment.date | date:'dd/MM/yyyy' }}</span>
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Message si aucun commentaire -->
|
||||||
|
<ng-template #noComment>
|
||||||
|
<p class="text-muted text-center mt-3">Aucun commentaire pour le moment</p>
|
||||||
|
</ng-template>
|
||||||
|
</div>
|
||||||
42
angular/src/app/about/about.component.ts
Normal file
42
angular/src/app/about/about.component.ts
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-about',
|
||||||
|
standalone: false,
|
||||||
|
templateUrl: './about.component.html',
|
||||||
|
styleUrl: './about.component.css'
|
||||||
|
})
|
||||||
|
|
||||||
|
export class AboutComponent implements OnInit {
|
||||||
|
|
||||||
|
info: Info = new Info();
|
||||||
|
comments: Array<Comment> = [];
|
||||||
|
comment: Comment = new Comment();
|
||||||
|
newComment: boolean = false;
|
||||||
|
|
||||||
|
constructor() {}
|
||||||
|
|
||||||
|
ngOnInit(): void {}
|
||||||
|
|
||||||
|
addComment() {
|
||||||
|
if (this.comment.message) {
|
||||||
|
this.comment.date = new Date();
|
||||||
|
this.comments.push({
|
||||||
|
message: this.comment.message,
|
||||||
|
date: this.comment.date
|
||||||
|
});
|
||||||
|
this.comment.message = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Info {
|
||||||
|
name: string = "Test";
|
||||||
|
email: string = "test@mail.com";
|
||||||
|
phone: string= "000000000";
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Comment {
|
||||||
|
message: string = '';
|
||||||
|
date: Date | null = null;
|
||||||
|
}
|
||||||
67
angular/src/app/account/account.component.html
Normal file
67
angular/src/app/account/account.component.html
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
<div class="container d-flex flex-column align-items-center mt-5">
|
||||||
|
|
||||||
|
<!-- Formulaire d'entrée -->
|
||||||
|
<div class="w-50">
|
||||||
|
<div class="card shadow-sm">
|
||||||
|
<div class="card-body">
|
||||||
|
<h4 class="card-title text-center mb-4">Ajouter vos informations</h4>
|
||||||
|
|
||||||
|
<div class="input-group mb-3">
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-text">
|
||||||
|
<input class="form-check-input mt-0" type="radio" value="Mr." aria-label="Mr." [(ngModel)]="info.gender" name="gender" (change)="updateGender()">
|
||||||
|
</div>
|
||||||
|
<input type="text" class="form-control" aria-label="Mr." placeholder="Mr." disabled>
|
||||||
|
|
||||||
|
<div class="input-group-text">
|
||||||
|
<input class="form-check-input mt-0" type="radio" value="Ms." aria-label="Ms." [(ngModel)]="info.gender" name="gender" (change)="updateGender()">
|
||||||
|
</div>
|
||||||
|
<input type="text" class="form-control" aria-label="Ms." placeholder="Ms." disabled>
|
||||||
|
|
||||||
|
<div class="input-group-text">
|
||||||
|
<input class="form-check-input mt-0" type="radio" value="Other." aria-label="Othef=r." [(ngModel)]="info.gender" name="gender" (change)="updateGender()">
|
||||||
|
</div>
|
||||||
|
<input type="text" class="form-control" aria-label="Other." placeholder="Other." disabled>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="input-group mb-3">
|
||||||
|
<input type="text" [(ngModel)]="info.nameLast" class="form-control" placeholder="Last name" aria-label="Last name">
|
||||||
|
<span class="input-group-text">@</span>
|
||||||
|
<input type="text" [(ngModel)]="info.nameFirst" class="form-control" placeholder="First name" aria-label="First name">
|
||||||
|
</div>
|
||||||
|
<div class="input-group mb-3">
|
||||||
|
<input type="text" [(ngModel)]="info.email" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username" aria-describedby="basic-addon2">
|
||||||
|
<span class="input-group-text" id="basic-addon2">@edu.igensia.com</span>
|
||||||
|
</div>
|
||||||
|
<div class="input-group mb-3">
|
||||||
|
<span class="input-group-text">Adresse</span>
|
||||||
|
<textarea class="form-control" [(ngModel)]="info.address" aria-label="Adresse"></textarea>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary w-100" (click)="addInfo()">Ajouter</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Liste des commentaires -->
|
||||||
|
<div *ngIf="infos.length > 0; else noComment" class="d-flex flex-column align-items-center w-50">
|
||||||
|
<h3 class="text-center text-primary">Liste des commentaires</h3>
|
||||||
|
<ul class="list-group shadow-sm">
|
||||||
|
<li class="list-group-item d-flex justify-content-between align-items-start" *ngFor="let info of infos">
|
||||||
|
<div class="ms-2 me-auto">
|
||||||
|
<div class="fw-bold breakWord">{{ info.nameLast }} {{ info.nameFirst }}</div>
|
||||||
|
<div class="fw-bold breakWord"><a href="mailto:{{ info.email }}">{{ info.email }}</a></div>
|
||||||
|
<div class="fw-bold breakWord">{{ info.address }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="ms-2 me-auto d-flex flex-column">
|
||||||
|
<span class="badge text-bg-primary rounded-pill mb-1">{{ info.gender }}</span>
|
||||||
|
<span class="badge text-bg-success rounded-pill">{{ info.date | date:'dd/MM/yyyy' }}</span>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Message si aucun commentaire -->
|
||||||
|
<ng-template #noComment>
|
||||||
|
<p class="text-muted text-center mt-3">Aucun commentaire pour le moment</p>
|
||||||
|
</ng-template>
|
||||||
|
</div>
|
||||||
51
angular/src/app/account/account.component.ts
Normal file
51
angular/src/app/account/account.component.ts
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
import { Component } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-account',
|
||||||
|
standalone: false,
|
||||||
|
templateUrl: './account.component.html',
|
||||||
|
styleUrl: './account.component.css'
|
||||||
|
})
|
||||||
|
|
||||||
|
export class AccountComponent {
|
||||||
|
info: Info = new Info();
|
||||||
|
infos: Array<Info> = [];
|
||||||
|
newInfo: boolean = false;
|
||||||
|
|
||||||
|
constructor() {}
|
||||||
|
ngOnInit(): void {}
|
||||||
|
|
||||||
|
addInfo() {
|
||||||
|
if (this.info.gender && this.info.nameFirst && this.info.nameLast && this.info.email && this.info.address) {
|
||||||
|
this.info.date = new Date();
|
||||||
|
this.info.nameFirst = this.info.nameFirst.charAt(0).toUpperCase() + this.info.nameFirst.slice(1).toLowerCase()
|
||||||
|
this.infos.push({
|
||||||
|
gender: this.info.gender,
|
||||||
|
nameFirst: this.info.nameFirst,
|
||||||
|
nameLast: this.info.nameLast.toUpperCase(),
|
||||||
|
email: this.info.email.toLowerCase() + '@edu.igensia.com',
|
||||||
|
address: this.info.address,
|
||||||
|
date: this.info.date
|
||||||
|
})
|
||||||
|
this.info.nameFirst = '';
|
||||||
|
this.info.nameLast = '';
|
||||||
|
this.info.email = '';
|
||||||
|
this.info.address = '';
|
||||||
|
this.info.gender = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateGender() {
|
||||||
|
// console.log("Le genre sélectionné est :", this.info.gender);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Info {
|
||||||
|
gender: string = '';
|
||||||
|
nameFirst: string = '';
|
||||||
|
nameLast: string = '';
|
||||||
|
email: string = '';
|
||||||
|
address: string= '';
|
||||||
|
date: Date | null = null;
|
||||||
|
}
|
||||||
|
|
@ -2,14 +2,12 @@ import { NgModule } from '@angular/core';
|
||||||
import { RouterModule, Routes } from '@angular/router';
|
import { RouterModule, Routes } from '@angular/router';
|
||||||
import { HomeComponent } from './home/home.component';
|
import { HomeComponent } from './home/home.component';
|
||||||
import { AboutComponent } from './about/about.component';
|
import { AboutComponent } from './about/about.component';
|
||||||
import { InfoComponent } from './info/info.component';
|
|
||||||
import { ContactsComponent } from './contacts/contacts.component';
|
import { ContactsComponent } from './contacts/contacts.component';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: '', component: HomeComponent },
|
{ path: '', component: HomeComponent },
|
||||||
{ path: 'home', component: HomeComponent },
|
{ path: 'home', component: HomeComponent },
|
||||||
{ path: 'about', component: AboutComponent },
|
{ path: 'about', component: AboutComponent },
|
||||||
{ path: 'info', component: InfoComponent },
|
|
||||||
{ path: 'contacts', component: ContactsComponent },
|
{ path: 'contacts', component: ContactsComponent },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -4,12 +4,11 @@ import { BrowserModule } from '@angular/platform-browser';
|
||||||
import { AppRoutingModule } from './app-routing.module';
|
import { AppRoutingModule } from './app-routing.module';
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
import { AboutComponent } from './about/about.component';
|
import { AboutComponent } from './about/about.component';
|
||||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import { ContactsComponent } from './contacts/contacts.component';
|
import { ContactsComponent } from './contacts/contacts.component';
|
||||||
import { HomeComponent } from './home/home.component';
|
import { HomeComponent } from './home/home.component';
|
||||||
import { NavBarComponent } from './nav-bar/nav-bar.component';
|
import { NavBarComponent } from './nav-bar/nav-bar.component';
|
||||||
import { AccountComponent } from './account/account.component';
|
import { AccountComponent } from './account/account.component';
|
||||||
import { InfoComponent } from './info/info.component';
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
|
|
@ -18,14 +17,12 @@ import { InfoComponent } from './info/info.component';
|
||||||
ContactsComponent,
|
ContactsComponent,
|
||||||
HomeComponent,
|
HomeComponent,
|
||||||
NavBarComponent,
|
NavBarComponent,
|
||||||
AccountComponent,
|
AccountComponent
|
||||||
InfoComponent
|
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
AppRoutingModule,
|
AppRoutingModule,
|
||||||
FormsModule,
|
FormsModule
|
||||||
ReactiveFormsModule
|
|
||||||
],
|
],
|
||||||
providers: [],
|
providers: [],
|
||||||
bootstrap: [AppComponent]
|
bootstrap: [AppComponent]
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<!-- Contenu principal -->
|
<!-- Contenu principal -->
|
||||||
<div class="container text-center mt-4">
|
<div class="container text-center mt-4">
|
||||||
<h1 class="text-primary">Bienvenue à la formation Angular</h1>
|
<h1 class="text-primary">Bienvenue à la formation AngularJS</h1>
|
||||||
|
|
||||||
<div class="mt-3">
|
<div class="mt-3">
|
||||||
<a class="btn btn-outline-primary me-2" routerLink="/about">About</a>
|
<a class="btn btn-outline-primary me-2" routerLink="/about">About</a>
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<!-- Navbar Bootstrap -->
|
<!-- Navbar Bootstrap -->
|
||||||
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<a class="navbar-brand" routerLink="/">Angular</a>
|
<a class="navbar-brand" routerLink="/">AngularJS</a>
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -20,9 +20,6 @@
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" routerLink="/about" routerLinkActive="active-link">About</a>
|
<a class="nav-link" routerLink="/about" routerLinkActive="active-link">About</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" routerLink="/info" routerLinkActive="active-link">Infos</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" routerLink="/contacts" routerLinkActive="active-link">Contacts</a>
|
<a class="nav-link" routerLink="/contacts" routerLinkActive="active-link">Contacts</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
@ -5,15 +5,6 @@
|
||||||
border-bottom: 2px solid #ffc107;
|
border-bottom: 2px solid #ffc107;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fs-40 {
|
|
||||||
padding-top: 2px !important;
|
|
||||||
padding-bottom: 2px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.fs-20 {
|
|
||||||
width: 5vw;
|
|
||||||
}
|
|
||||||
|
|
||||||
.breakWord {
|
.breakWord {
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
|
|
@ -1,68 +0,0 @@
|
||||||
<div class="container d-flex flex-column align-items-center mt-4">
|
|
||||||
<!-- Liste des informations avec un style amélioré -->
|
|
||||||
<ul class="list-group w-50 shadow-sm mb-4">
|
|
||||||
<li class="list-group-item active text-center">Informations</li>
|
|
||||||
<li class="list-group-item">{{info.gender}}{{info.nameLast}} {{info.nameFirst}}</li>
|
|
||||||
<li class="list-group-item">{{info.email}}</li>
|
|
||||||
<li class="list-group-item">{{info.address}}, {{info.codePostal}}</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<!-- Champ d'entrée réduit et centré -->
|
|
||||||
<div class="w-50">
|
|
||||||
<form [formGroup]="messageForm" (ngSubmit)="addComment()">
|
|
||||||
<div class="input-group mb-3 shadow-sm">
|
|
||||||
<span class="input-group-text" id="message-addon">Message</span>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
formControlName="message"
|
|
||||||
class="form-control"
|
|
||||||
aria-describedby="message-addon"
|
|
||||||
placeholder="Entrez votre message">
|
|
||||||
<button
|
|
||||||
type="submit"
|
|
||||||
class="btn btn-primary"
|
|
||||||
[disabled]="messageForm.invalid">
|
|
||||||
Add
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Liste des commentaires -->
|
|
||||||
<div *ngIf="comments.length > 0; else noComment" class="d-flex flex-column align-items-center w-50">
|
|
||||||
<h3 class="text-center text-primary">Liste des commentaires</h3>
|
|
||||||
<div class="list-group shadow-sm w-100">
|
|
||||||
<div
|
|
||||||
*ngFor="let msg of comments.slice().reverse()"
|
|
||||||
class="list-group-item d-flex justify-content-between align-items-start">
|
|
||||||
<div class="ms-2 me-auto">
|
|
||||||
<div class="fw-bold breakWord">{{ msg.user }}</div>
|
|
||||||
<div class="breakWord">{{ msg.message }}</div>
|
|
||||||
</div>
|
|
||||||
<span class="badge text-bg-primary rounded-pill SpaceMargin-02">
|
|
||||||
{{ msg.date | date:'dd/MM/yyyy' }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div *ngIf="commentsAll.length > 0;" class="d-flex flex-column align-items-center w-50">
|
|
||||||
<div class="list-group shadow-sm w-100">
|
|
||||||
<div
|
|
||||||
*ngFor="let msg of commentsAll"
|
|
||||||
class="list-group-item d-flex justify-content-between align-items-start">
|
|
||||||
<div class="ms-2 me-auto">
|
|
||||||
<div class="fw-bold breakWord">{{ msg.user }}</div>
|
|
||||||
<div class="breakWord">{{ msg.message }}</div>
|
|
||||||
</div>
|
|
||||||
<span class="badge text-bg-primary rounded-pill SpaceMargin-02">
|
|
||||||
{{ msg.date | date:'dd/MM/yyyy' }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Message si aucun commentaire -->
|
|
||||||
<ng-template #noComment>
|
|
||||||
<p class="text-muted text-center mt-3">Aucun commentaire pour le moment</p>
|
|
||||||
</ng-template>
|
|
||||||
</div>
|
|
||||||
|
|
@ -1,72 +0,0 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
|
||||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
|
||||||
import { InfoService } from '../services/info.service';
|
|
||||||
import { MessageService } from '../services/message.service';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-about',
|
|
||||||
standalone: false,
|
|
||||||
templateUrl: './about.component.html',
|
|
||||||
styleUrls: ['./about.component.css']
|
|
||||||
})
|
|
||||||
|
|
||||||
export class AboutComponent implements OnInit {
|
|
||||||
messageForm: FormGroup;
|
|
||||||
|
|
||||||
infos: Info[] = [];
|
|
||||||
info: Info = new Info();
|
|
||||||
commentsAll: Comment[] = [];
|
|
||||||
|
|
||||||
|
|
||||||
comments: Comment[] = [];
|
|
||||||
comment: Comment = new Comment();
|
|
||||||
newComment: boolean = false;
|
|
||||||
|
|
||||||
constructor(private fb: FormBuilder, private infoService: InfoService, private messageService: MessageService) {
|
|
||||||
this.messageForm = this.fb.group({
|
|
||||||
message: ['', [Validators.required, Validators.minLength(3)]],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
this.infos = this.infoService.getInfos();
|
|
||||||
this.info = this.infos.length > 0 ? this.infos[this.infos.length - 1] : new Info();
|
|
||||||
|
|
||||||
this.commentsAll = this.messageService.getMessage().slice().reverse();
|
|
||||||
this.comment = this.commentsAll.length > 0 ? this.commentsAll[0] : new Comment();
|
|
||||||
}
|
|
||||||
|
|
||||||
addComment() {
|
|
||||||
if (this.messageForm.valid) {
|
|
||||||
const formData = this.messageForm.value;
|
|
||||||
|
|
||||||
const user = this.info.gender + this.info.nameLast + ' ' + this.info.nameFirst;
|
|
||||||
|
|
||||||
const newComment = {
|
|
||||||
...formData,
|
|
||||||
user: user,
|
|
||||||
date: new Date()
|
|
||||||
};
|
|
||||||
|
|
||||||
this.comments.push(newComment);
|
|
||||||
this.messageService.addMessage(newComment);
|
|
||||||
|
|
||||||
this.messageForm.reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Info {
|
|
||||||
gender: string = 'Mister.';
|
|
||||||
nameLast: string = 'Inconnu';
|
|
||||||
nameFirst: string = 'PASLA';
|
|
||||||
email: string = 'inconnu.pasla@edu.igensia.com';
|
|
||||||
address: string = '0 rue d\'inconnu';
|
|
||||||
codePostal: number = 1234;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Comment {
|
|
||||||
user: string = '';
|
|
||||||
message: string = '';
|
|
||||||
date: Date | null = null;
|
|
||||||
}
|
|
||||||
|
|
@ -1,124 +0,0 @@
|
||||||
<div class="container d-flex flex-column align-items-center mt-5">
|
|
||||||
|
|
||||||
<!-- Formulaire d'entrée -->
|
|
||||||
<div class="w-50">
|
|
||||||
<div class="card shadow-sm">
|
|
||||||
<div class="card-body">
|
|
||||||
<h4 class="card-title text-center mb-4">Ajouter vos informations</h4>
|
|
||||||
|
|
||||||
<form [formGroup]="infoForm" (ngSubmit)="addInfo()">
|
|
||||||
|
|
||||||
<!-- Sélection du genre -->
|
|
||||||
<div class="input-group mb-3">
|
|
||||||
<div class="input-group">
|
|
||||||
<div class="input-group-text">
|
|
||||||
<input class="form-check-input mt-0" type="radio" formControlName="gender" value="Mr.">
|
|
||||||
</div>
|
|
||||||
<input type="text" class="form-control" placeholder="Mr." disabled>
|
|
||||||
|
|
||||||
<div class="input-group-text">
|
|
||||||
<input class="form-check-input mt-0" type="radio" formControlName="gender" value="Ms.">
|
|
||||||
</div>
|
|
||||||
<input type="text" class="form-control" placeholder="Ms." disabled>
|
|
||||||
|
|
||||||
<div class="input-group-text">
|
|
||||||
<input class="form-check-input mt-0" type="radio" formControlName="gender" value="Other.">
|
|
||||||
</div>
|
|
||||||
<input type="text" class="form-control" placeholder="Other." disabled>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="alert alert-danger fs-40" role="alert" *ngIf="infoForm.get('gender')?.invalid && infoForm.get('gender')?.touched">
|
|
||||||
Veuillez sélectionner un genre.
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Nom & Prénom -->
|
|
||||||
<div class="input-group mb-3">
|
|
||||||
<input type="text" formControlName="nameLast" class="form-control" placeholder="Nom">
|
|
||||||
<span class="input-group-text"> — </span>
|
|
||||||
<input type="text" formControlName="nameFirst" class="form-control" placeholder="Prénom">
|
|
||||||
</div>
|
|
||||||
<div class="input-group mb-3" *ngIf="(infoForm.get('nameLast')?.invalid && infoForm.get('nameLast')?.touched) ||
|
|
||||||
(infoForm.get('nameFirst')?.invalid && infoForm.get('nameFirst')?.touched)">
|
|
||||||
<div class="alert alert-danger fs-40" role="alert" *ngIf="infoForm.get('nameLast')?.hasError('required') && infoForm.get('nameLast')?.touched">
|
|
||||||
Le nom est requis.
|
|
||||||
</div>
|
|
||||||
<div class="alert alert-danger fs-40" role="alert" *ngIf="infoForm.get('nameLast')?.hasError('minlength') && infoForm.get('nameLast')?.touched">
|
|
||||||
Le nom doit comporter au moins 3 caractères.
|
|
||||||
</div>
|
|
||||||
<div class="alert alert-dark fs-40" role="alert"> — </div>
|
|
||||||
<div class="alert alert-danger fs-40" role="alert" *ngIf="infoForm.get('nameFirst')?.hasError('required') && infoForm.get('nameFirst')?.touched">
|
|
||||||
Le prénom est requis.
|
|
||||||
</div>
|
|
||||||
<div class="alert alert-danger fs-40" role="alert" *ngIf="infoForm.get('nameFirst')?.hasError('minlength') && infoForm.get('nameFirst')?.touched">
|
|
||||||
Le prénom doit comporter au moins 3 caractères.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Email -->
|
|
||||||
<div class="input-group mb-3">
|
|
||||||
<input type="text" formControlName="email" class="form-control" placeholder="Nom d'utilisateur">
|
|
||||||
<span class="input-group-text">@edu.igensia.com</span>
|
|
||||||
</div>
|
|
||||||
<div class="alert alert-danger fs-40" role="alert" *ngIf="infoForm.get('email')?.invalid && infoForm.get('email')?.touched">
|
|
||||||
Veuillez entrer un nom d'utilisateur valide.
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Adresse -->
|
|
||||||
<div class="input-group mb-3">
|
|
||||||
<input type="text" formControlName="address" class="form-control" placeholder="Adresse">
|
|
||||||
<span class="input-group-text"> — </span>
|
|
||||||
<input type="text" formControlName="codePostal" class="form-control fs-20" placeholder="Code Postal">
|
|
||||||
</div>
|
|
||||||
<div class="input-group mb-3" *ngIf="(infoForm.get('address')?.invalid && infoForm.get('address')?.touched) ||
|
|
||||||
(infoForm.get('codePostal')?.invalid && infoForm.get('codePostal')?.touched)">
|
|
||||||
<div class="alert alert-danger fs-40" role="alert" *ngIf="infoForm.get('address')?.hasError('required') && infoForm.get('address')?.touched">
|
|
||||||
L'adresse est requise.
|
|
||||||
</div>
|
|
||||||
<div class="alert alert-danger fs-40" role="alert" *ngIf="infoForm.get('address')?.hasError('minlength') && infoForm.get('address')?.touched">
|
|
||||||
L'adresse doit comporter au moins 10 caractères.
|
|
||||||
</div>
|
|
||||||
<div class="d-flex justify-content-center align-items-center alert alert-dark fs-40" role="alert"> — </div>
|
|
||||||
<div *ngIf="infoForm.get('codePostal')?.invalid">
|
|
||||||
<div class="alert alert-danger fs-40" role="alert" *ngIf="infoForm.get('codePostal')?.hasError('required')">
|
|
||||||
Le code postal est requis.
|
|
||||||
</div>
|
|
||||||
<div class="alert alert-danger fs-40" role="alert" *ngIf="infoForm.get('codePostal')?.hasError('minlength')">
|
|
||||||
Le code postal doit comporter au moins 4 chiffres.
|
|
||||||
</div>
|
|
||||||
<div class="alert alert-danger fs-40" role="alert" *ngIf="infoForm.get('codePostal')?.hasError('pattern')">
|
|
||||||
Le code postal doit comporter uniquement des chiffres.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Bouton Ajouter -->
|
|
||||||
<button type="submit" class="btn btn-primary w-100" [disabled]="infoForm.invalid">Ajouter</button>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Liste des informations -->
|
|
||||||
<div *ngIf="infos.length > 0; else noComment" class="d-flex flex-column align-items-center w-50">
|
|
||||||
<h3 class="text-center text-primary">Liste des informations</h3>
|
|
||||||
<ul class="list-group shadow-sm">
|
|
||||||
<li class="list-group-item d-flex justify-content-between align-items-start" *ngFor="let info of infos">
|
|
||||||
<div class="ms-2 me-auto">
|
|
||||||
<div class="fw-bold breakWord">{{ info.nameLast }} {{ info.nameFirst }}</div>
|
|
||||||
<div class="fw-bold breakWord"><a href="mailto:{{ info.email }}">{{ info.email }}</a></div>
|
|
||||||
<div class="fw-bold breakWord">{{ info.address }}</div>
|
|
||||||
</div>
|
|
||||||
<div class="ms-2 me-auto d-flex flex-column">
|
|
||||||
<span class="badge text-bg-primary rounded-pill mb-1">{{ info.gender }}</span>
|
|
||||||
<span class="badge text-bg-success rounded-pill">{{ info.date | date:'dd/MM/yyyy' }}</span>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Message si aucun commentaire -->
|
|
||||||
<ng-template #noComment>
|
|
||||||
<p class="text-muted text-center mt-3">Aucune information pour le moment</p>
|
|
||||||
</ng-template>
|
|
||||||
</div>
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
import { Component } from '@angular/core';
|
|
||||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
|
||||||
import { InfoService } from '../services/info.service';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-account',
|
|
||||||
standalone: false,
|
|
||||||
templateUrl: './account.component.html',
|
|
||||||
styleUrl: './account.component.css'
|
|
||||||
})
|
|
||||||
|
|
||||||
export class AccountComponent {
|
|
||||||
infoForm: FormGroup;
|
|
||||||
infos: any[] = [];
|
|
||||||
|
|
||||||
constructor(private fb: FormBuilder, private infoService: InfoService) {
|
|
||||||
this.infoForm = this.fb.group({
|
|
||||||
gender: ['', Validators.required],
|
|
||||||
nameLast: ['', [Validators.required, Validators.minLength(3)]],
|
|
||||||
nameFirst: ['', [Validators.required, Validators.minLength(3)]],
|
|
||||||
email: ['', [Validators.required, Validators.pattern(/^[a-zA-Z0-9._%+-]+$/)]],
|
|
||||||
address: ['', [Validators.required, Validators.minLength(10)]],
|
|
||||||
codePostal: ['', [Validators.required, Validators.minLength(4), Validators.pattern(/^\d+$/)]],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
addInfo() {
|
|
||||||
if (this.infoForm.valid) {
|
|
||||||
const formData = this.infoForm.value;
|
|
||||||
|
|
||||||
const email = formData.email.toLowerCase();
|
|
||||||
const fullEmail = `${email}@edu.igensia.com`;
|
|
||||||
const nameLast = formData.nameLast.toUpperCase();
|
|
||||||
const nameFirst = formData.nameFirst.charAt(0).toUpperCase() + formData.nameFirst.slice(1).toLowerCase();
|
|
||||||
|
|
||||||
const newInfo = {
|
|
||||||
...formData,
|
|
||||||
nameLast: nameLast,
|
|
||||||
nameFirst: nameFirst,
|
|
||||||
email: fullEmail,
|
|
||||||
date: new Date()
|
|
||||||
};
|
|
||||||
|
|
||||||
this.infos.push(newInfo);
|
|
||||||
this.infoService.addInfo(newInfo);
|
|
||||||
this.infoForm.reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
<div class="container d-flex flex-column align-items-center mt-4">
|
|
||||||
|
|
||||||
<ul class="list-group w-50 shadow-sm mb-4" *ngFor="let info of infos">
|
|
||||||
<li class="list-group-item active text-center">
|
|
||||||
<div class="ms-2 me-auto">
|
|
||||||
Informations de {{ info.gender }}{{ info.nameLast }}
|
|
||||||
<span class="badge text-bg-success rounded-pill">{{ info.date | date:'dd/MM/yyyy' }}</span>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
<li class="list-group-item">{{ info.gender }}{{ info.nameLast }} {{info.nameFirst}}</li>
|
|
||||||
<li class="list-group-item">{{ info.email }}</li>
|
|
||||||
<li class="list-group-item">{{ info.address }}, {{ info.codePostal }}</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { InfoComponent } from './info.component';
|
|
||||||
|
|
||||||
describe('InfoComponent', () => {
|
|
||||||
let component: InfoComponent;
|
|
||||||
let fixture: ComponentFixture<InfoComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [InfoComponent]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
|
|
||||||
fixture = TestBed.createComponent(InfoComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
import { Component } from '@angular/core';
|
|
||||||
import { InfoService } from '../services/info.service';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-info',
|
|
||||||
standalone: false,
|
|
||||||
templateUrl: './info.component.html',
|
|
||||||
styleUrl: './info.component.css'
|
|
||||||
})
|
|
||||||
export class InfoComponent {
|
|
||||||
infos: any[] = [];
|
|
||||||
|
|
||||||
constructor(private infoService: InfoService) {}
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
this.infos = this.infoService.getInfos().slice().reverse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
import { TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { InfoService } from './info.service';
|
|
||||||
|
|
||||||
describe('InfoService', () => {
|
|
||||||
let service: InfoService;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
TestBed.configureTestingModule({});
|
|
||||||
service = TestBed.inject(InfoService);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be created', () => {
|
|
||||||
expect(service).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
import { Injectable } from '@angular/core';
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root'
|
|
||||||
})
|
|
||||||
export class InfoService {
|
|
||||||
private infos: any[] = [];
|
|
||||||
|
|
||||||
constructor() { }
|
|
||||||
|
|
||||||
// Ajouter une info
|
|
||||||
addInfo(info: any) {
|
|
||||||
this.infos.push(info);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Récupérer toutes les infos
|
|
||||||
getInfos() {
|
|
||||||
return this.infos;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
import { TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { MessageService } from './message.service';
|
|
||||||
|
|
||||||
describe('MessageService', () => {
|
|
||||||
let service: MessageService;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
TestBed.configureTestingModule({});
|
|
||||||
service = TestBed.inject(MessageService);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be created', () => {
|
|
||||||
expect(service).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
import { Injectable } from '@angular/core';
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root'
|
|
||||||
})
|
|
||||||
export class MessageService {
|
|
||||||
private messages: any[] = [];
|
|
||||||
|
|
||||||
constructor() { }
|
|
||||||
|
|
||||||
// Ajouter une info
|
|
||||||
addMessage(message: any) {
|
|
||||||
this.messages.push(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Récupérer toutes les infos
|
|
||||||
getMessage() {
|
|
||||||
return this.messages;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Reference in a new issue