Add Header and correction for seo service import

This commit is contained in:
Mathieu Sanchez 2019-05-21 13:04:12 +09:00
parent b70bcfbe12
commit f923af8e5d
7 changed files with 59 additions and 15 deletions

View File

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

View File

@ -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 dun accident les données de celui-ci (chocs, vitesse, position) pour remplir le constat. Lautomobiliste 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() {

View File

View File

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

View File

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

View File

@ -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() {
}
}

View File

@ -1,3 +1,3 @@
<div>
Welcome in our home page
</div>
<app-header>
Test
</app-header>