From f923af8e5dcb7a3abc628383fcccc4e77eaebf1a Mon Sep 17 00:00:00 2001 From: Mathieu Sanchez Date: Tue, 21 May 2019 13:04:12 +0900 Subject: [PATCH] Add Header and correction for seo service import --- src/app/app.module.ts | 5 ++++- src/app/core/services/seo/seo.service.ts | 20 +++++++++---------- src/app/header/header.component.css | 0 src/app/header/header.component.html | 3 +++ src/app/header/header.component.spec.ts | 25 ++++++++++++++++++++++++ src/app/header/header.component.ts | 15 ++++++++++++++ src/app/home/home.component.html | 6 +++--- 7 files changed, 59 insertions(+), 15 deletions(-) create mode 100644 src/app/header/header.component.css create mode 100644 src/app/header/header.component.html create mode 100644 src/app/header/header.component.spec.ts create mode 100644 src/app/header/header.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 599d92a..1c1f56d 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -10,14 +10,16 @@ import { AngularFireModule } from '@angular/fire'; import { AngularFireDatabaseModule } from '@angular/fire/database'; import { environment } from '@env/environment'; import { GlobalErrorHandler } from '@app/core/global-error-handler/global-error-handler.service'; -import { LogService } from '@app/core/services'; +import { LogService, SEOService } from '@app/core/services'; import { AppMaterialModule } from '@app/app-material.module'; import { AppRoutingModule } from '@app/app-routing.module'; +import { HeaderComponent } from './header/header.component'; @NgModule({ declarations: [ AppComponent, HomeComponent, + HeaderComponent, ], imports: [ BrowserModule, @@ -29,6 +31,7 @@ import { AppRoutingModule } from '@app/app-routing.module'; ], providers: [ LogService, + SEOService, { provide: ErrorHandler, useClass: GlobalErrorHandler, diff --git a/src/app/core/services/seo/seo.service.ts b/src/app/core/services/seo/seo.service.ts index 9bfd42f..445cadf 100644 --- a/src/app/core/services/seo/seo.service.ts +++ b/src/app/core/services/seo/seo.service.ts @@ -7,10 +7,8 @@ import { filter, map, mergeMap } from 'rxjs/operators'; @Injectable() export class SEOService { - private defaultTitle = 'Constat à l\'amiable automatique'; - private defaultDescription = 'Notre projet consiste à aider les automobilistes en automatisant le remplissage du constat. C2A est intégré dans les' + - 'véhicules et récupère lors d’un accident les données de celui-ci (chocs, vitesse, position) pour remplir le constat. L’automobiliste obtiendra' + - 'son constat rempli sur son téléphone et après avoir apposé les signatures, le constat sera envoyé aux assureurs.'; + private defaultTitle = 'DiscoTrip'; + private defaultDescription = 'Nothing'; private defaultNoIndex = false; private defaultNoFollow = false; @@ -47,13 +45,13 @@ export class SEOService { } private setMetas( event: any ) { - event[ 'title' ] = ( !event[ 'title' ] ? this.defaultTitle : event[ 'title' ] ); - event[ 'description' ] = ( !event[ 'description' ] ? this.defaultDescription : event[ 'description' ] ); - event[ 'noindex' ] = ( !event[ 'noindex' ] ? this.defaultNoIndex : event[ 'noindex' ] ); - event[ 'nofollow' ] = ( !event[ 'nofollow' ] ? this.defaultNoFollow : event[ 'nofollow' ] ); - this.updateTitle( event[ 'title' ] + ' | C2A' ); - this.updateDescription( event[ 'description' ] ); - this.updateIndexFollow( event[ 'noindex' ], event[ 'nofollow' ] ); + event.title = ( !event.title ? this.defaultTitle : event.title ); + event.description = ( !event.description ? this.defaultDescription : event.description ); + event.noindex = ( !event.noindex ? this.defaultNoIndex : event.noindex ); + event.nofollow = ( !event.nofollow ? this.defaultNoFollow : event.nofollow ); + this.updateTitle( event.title + ' | C2A' ); + this.updateDescription( event.description ); + this.updateIndexFollow( event.noindex, event.nofollow ); } private routerListener() { diff --git a/src/app/header/header.component.css b/src/app/header/header.component.css new file mode 100644 index 0000000..e69de29 diff --git a/src/app/header/header.component.html b/src/app/header/header.component.html new file mode 100644 index 0000000..51bfb8c --- /dev/null +++ b/src/app/header/header.component.html @@ -0,0 +1,3 @@ +

+ header works! +

diff --git a/src/app/header/header.component.spec.ts b/src/app/header/header.component.spec.ts new file mode 100644 index 0000000..2d0479d --- /dev/null +++ b/src/app/header/header.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { HeaderComponent } from './header.component'; + +describe('HeaderComponent', () => { + let component: HeaderComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ HeaderComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(HeaderComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/header/header.component.ts b/src/app/header/header.component.ts new file mode 100644 index 0000000..3ee4d0f --- /dev/null +++ b/src/app/header/header.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-header', + templateUrl: './header.component.html', + styleUrls: ['./header.component.css'] +}) +export class HeaderComponent implements OnInit { + + constructor() { } + + ngOnInit() { + } + +} diff --git a/src/app/home/home.component.html b/src/app/home/home.component.html index 978ec09..a0e7d56 100644 --- a/src/app/home/home.component.html +++ b/src/app/home/home.component.html @@ -1,3 +1,3 @@ -
- Welcome in our home page -
+ + Test +