Merge pull request 'develop' (#5) from develop into master

Reviewed-on: https://git.gitpushf.uk/SchoolTask/angular-js/pulls/5
This commit is contained in:
ExostFlash 2025-03-07 15:18:37 +00:00
commit 9ec65a118e
50 changed files with 16153 additions and 0 deletions

17
.editorconfig Normal file
View file

@ -0,0 +1,17 @@
# Editor configuration, see https://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.ts]
quote_type = single
ij_typescript_use_double_quotes = false
[*.md]
max_line_length = off
trim_trailing_whitespace = false

42
.gitignore vendored Normal file
View file

@ -0,0 +1,42 @@
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
# Compiled output
/dist
/tmp
/out-tsc
/bazel-out
# Node
/node_modules
npm-debug.log
yarn-error.log
# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*
# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings
# System files
.DS_Store
Thumbs.db

4
.vscode/extensions.json vendored Normal file
View file

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

20
.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,20 @@
{
// 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"
}
]
}

42
.vscode/tasks.json vendored Normal file
View file

@ -0,0 +1,42 @@
{
// 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"
}
}
}
}
]
}

View 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/`. 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.

115
angular.json Normal file
View file

@ -0,0 +1,115 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"angular": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"standalone": false
},
"@schematics/angular:directive": {
"standalone": false
},
"@schematics/angular:pipe": {
"standalone": false
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:application",
"options": {
"outputPath": "dist/angular",
"index": "src/index.html",
"browser": "src/main.ts",
"polyfills": [
"zone.js"
],
"tsConfig": "tsconfig.app.json",
"assets": [
{
"glob": "**/*",
"input": "public"
}
],
"styles": [
"src/styles.css",
"node_modules/bootstrap/dist/css/bootstrap.min.css"
],
"scripts": [
"node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"
]
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kB",
"maximumError": "1MB"
},
{
"type": "anyComponentStyle",
"maximumWarning": "4kB",
"maximumError": "8kB"
}
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"options": {
"port": 80
},
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"buildTarget": "angular:build:production"
},
"development": {
"buildTarget": "angular:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n"
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": [
"zone.js",
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json",
"assets": [
{
"glob": "**/*",
"input": "public"
}
],
"styles": [
"src/styles.css"
],
"scripts": []
}
}
}
}
},
"cli": {
"analytics": false
}
}

14960
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

39
package.json Normal file
View file

@ -0,0 +1,39 @@
{
"name": "angular",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"@angular/animations": "^19.1.0",
"@angular/common": "^19.1.0",
"@angular/compiler": "^19.1.0",
"@angular/core": "^19.1.0",
"@angular/forms": "^19.1.0",
"@angular/platform-browser": "^19.1.0",
"@angular/platform-browser-dynamic": "^19.1.0",
"@angular/router": "^19.1.0",
"bootstrap": "^5.3.3",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.15.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^19.1.6",
"@angular/cli": "^19.1.6",
"@angular/compiler-cli": "^19.1.0",
"@types/jasmine": "~5.1.0",
"jasmine-core": "~5.5.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"typescript": "~5.7.2"
}
}

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View file

View file

@ -0,0 +1,68 @@
<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>

View file

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

View file

@ -0,0 +1,72 @@
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;
}

View file

View file

@ -0,0 +1,124 @@
<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">&#64;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>

View file

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

View file

@ -0,0 +1,49 @@
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();
}
}
}

View file

@ -0,0 +1,20 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { AboutComponent } from './about/about.component';
import { InfoComponent } from './info/info.component';
import { ContactsComponent } from './contacts/contacts.component';
const routes: Routes = [
{ path: '', component: HomeComponent },
{ path: 'home', component: HomeComponent },
{ path: 'about', component: AboutComponent },
{ path: 'info', component: InfoComponent },
{ path: 'contacts', component: ContactsComponent },
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }

View file

View file

@ -0,0 +1,4 @@
<app-nav-bar></app-nav-bar>
<div class="container mt-4">
<router-outlet></router-outlet>
</div>

View file

@ -0,0 +1,35 @@
import { TestBed } from '@angular/core/testing';
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [
RouterModule.forRoot([])
],
declarations: [
AppComponent
],
}).compileComponents();
});
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app).toBeTruthy();
});
it(`should have as title 'angular'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app.title).toEqual('angular');
});
it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, angular');
});
});

11
src/app/app.component.ts Normal file
View file

@ -0,0 +1,11 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
standalone: false,
styleUrl: './app.component.css'
})
export class AppComponent {
title = 'AngularJS';
}

33
src/app/app.module.ts Normal file
View file

@ -0,0 +1,33 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { AboutComponent } from './about/about.component';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ContactsComponent } from './contacts/contacts.component';
import { HomeComponent } from './home/home.component';
import { NavBarComponent } from './nav-bar/nav-bar.component';
import { AccountComponent } from './account/account.component';
import { InfoComponent } from './info/info.component';
@NgModule({
declarations: [
AppComponent,
AboutComponent,
ContactsComponent,
HomeComponent,
NavBarComponent,
AccountComponent,
InfoComponent
],
imports: [
BrowserModule,
AppRoutingModule,
FormsModule,
ReactiveFormsModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

View file

View file

@ -0,0 +1 @@
<p>contacts works!</p>

View file

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

View file

@ -0,0 +1,11 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-contacts',
standalone: false,
templateUrl: './contacts.component.html',
styleUrl: './contacts.component.css'
})
export class ContactsComponent {
}

View file

View file

@ -0,0 +1,11 @@
<!-- Contenu principal -->
<div class="container text-center mt-4">
<h1 class="text-primary">Bienvenue à la formation Angular</h1>
<div class="mt-3">
<a class="btn btn-outline-primary me-2" routerLink="/about">About</a>
<a class="btn btn-outline-primary" routerLink="/contacts">Contacts</a>
</div>
</div>
<app-account></app-account>

View file

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

View file

@ -0,0 +1,11 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-home',
standalone: false,
templateUrl: './home.component.html',
styleUrl: './home.component.css'
})
export class HomeComponent {
}

View file

View file

@ -0,0 +1,14 @@
<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>

View file

@ -0,0 +1,23 @@
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();
});
});

View file

@ -0,0 +1,18 @@
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();
}
}

View file

View file

@ -0,0 +1,32 @@
<!-- Navbar Bootstrap -->
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<div class="container">
<a class="navbar-brand" routerLink="/">Angular</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a class="nav-link"
routerLink="/"
routerLinkActive="active-link"
[routerLinkActiveOptions]="{ exact: isHomeActiveBool() }"
[class.active-link]="isHomeActive()">
Home
</a>
</li>
<li class="nav-item">
<a class="nav-link" routerLink="/about" routerLinkActive="active-link">About</a>
</li>
<li class="nav-item">
<a class="nav-link" routerLink="/info" routerLinkActive="active-link">Infos</a>
</li>
<li class="nav-item">
<a class="nav-link" routerLink="/contacts" routerLinkActive="active-link">Contacts</a>
</li>
</ul>
</div>
</div>
</nav>

View file

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

View file

@ -0,0 +1,24 @@
import { Component } from '@angular/core';
import { Router } from '@angular/router';
@Component({
selector: 'app-nav-bar',
standalone: false,
templateUrl: './nav-bar.component.html',
styleUrl: './nav-bar.component.css'
})
export class NavBarComponent {
constructor(private router: Router) {}
isHomeActive(): boolean {
return this.router.url === '/' || this.router.url === '/home';
}
isHomeActiveBool(): boolean {
if (this.router.url != '/home') {
return true
} else {
return false
}
}
}

View file

@ -0,0 +1,16 @@
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();
});
});

View file

@ -0,0 +1,20 @@
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;
}
}

View file

@ -0,0 +1,16 @@
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();
});
});

View file

@ -0,0 +1,20 @@
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;
}
}

13
src/index.html Normal file
View file

@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Angular</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root></app-root>
</body>
</html>

7
src/main.ts Normal file
View file

@ -0,0 +1,7 @@
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
platformBrowserDynamic().bootstrapModule(AppModule, {
ngZoneEventCoalescing: true,
})
.catch(err => console.error(err));

30
src/styles.css Normal file
View file

@ -0,0 +1,30 @@
/* You can add global styles to this file, and also import other style files */
.active-link {
color: #ffc107 !important; /* Jaune Bootstrap */
font-weight: bold;
border-bottom: 2px solid #ffc107;
}
.fs-40 {
padding-top: 2px !important;
padding-bottom: 2px !important;
}
.fs-20 {
width: 5vw;
}
.breakWord {
word-break: break-word;
word-wrap: break-word;
}
.SpaceMargin-02 {
margin-left: 10px;
margin-top: 2px;
}
.SpaceMargin-05 {
margin-left: 10px;
margin-top: 10px;
}

15
tsconfig.app.json Normal file
View file

@ -0,0 +1,15 @@
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
},
"files": [
"src/main.ts"
],
"include": [
"src/**/*.d.ts"
]
}

27
tsconfig.json Normal file
View file

@ -0,0 +1,27 @@
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"skipLibCheck": true,
"isolatedModules": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"moduleResolution": "bundler",
"importHelpers": true,
"target": "ES2022",
"module": "ES2022"
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}

15
tsconfig.spec.json Normal file
View file

@ -0,0 +1,15 @@
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/spec",
"types": [
"jasmine"
]
},
"include": [
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
}