From 3ea328e7a90106d9920979a7546ada4dd1a85e84 Mon Sep 17 00:00:00 2001 From: xmlking <xmlking@gmail.com> Date: Sun, 23 Sep 2018 13:33:23 -0700 Subject: [PATCH] test(*): using pageTitleService page title is set for home, dashboard --- libs/core/src/lib/services/page-title.service.ts | 11 +++++++---- .../dashboard-layout/dashboard-layout.component.ts | 4 ++++ .../containers/home-layout/home-layout.component.ts | 7 +++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/libs/core/src/lib/services/page-title.service.ts b/libs/core/src/lib/services/page-title.service.ts index 4c1d97347..6f7933880 100644 --- a/libs/core/src/lib/services/page-title.service.ts +++ b/libs/core/src/lib/services/page-title.service.ts @@ -8,7 +8,8 @@ import { Title } from '@angular/platform-browser'; providedIn: 'root', }) export class PageTitleService { - _title = ''; + private readonly defaultTitle; + private _title = ''; get title(): string { return this._title; @@ -17,10 +18,12 @@ export class PageTitleService { set title(title: string) { this._title = title; if (title !== '') { - title = `${title} | `; + title = `${title} |`; } - this.bodyTitle.setTitle(`${title}IS360`); + this.bodyTitle.setTitle(`${title} ${this.defaultTitle}`); } - constructor(private bodyTitle: Title) {} + constructor(private bodyTitle: Title) { + this.defaultTitle = bodyTitle.getTitle() || 'WebApp'; + } } diff --git a/libs/dashboard/src/lib/containers/dashboard-layout/dashboard-layout.component.ts b/libs/dashboard/src/lib/containers/dashboard-layout/dashboard-layout.component.ts index 1a2ed08bd..ddff42671 100644 --- a/libs/dashboard/src/lib/containers/dashboard-layout/dashboard-layout.component.ts +++ b/libs/dashboard/src/lib/containers/dashboard-layout/dashboard-layout.component.ts @@ -7,6 +7,7 @@ import { Actions, Store } from '@ngxs/store'; import { ConnectWebSocket, DisconnectWebSocket } from '@ngx-starter-kit/socketio-plugin'; import { OAuthService } from 'angular-oauth2-oidc'; import { environment } from '@env/environment'; +import { PageTitleService } from '@ngx-starter-kit/core'; @Component({ selector: 'ngx-dashboard-layout', @@ -33,9 +34,12 @@ export class DashboardLayoutComponent implements OnInit, OnDestroy { private actions$: Actions, private media: ObservableMedia, private oauthService: OAuthService, + private pageTitleService: PageTitleService, ) {} ngOnInit() { + this.pageTitleService.title = 'Dashboard'; + this._mediaSubscription = this.media.subscribe((change: MediaChange) => { const isMobile = change.mqAlias === 'xs' || change.mqAlias === 'sm'; diff --git a/libs/home/src/lib/containers/home-layout/home-layout.component.ts b/libs/home/src/lib/containers/home-layout/home-layout.component.ts index c69684d6d..f057f85ce 100644 --- a/libs/home/src/lib/containers/home-layout/home-layout.component.ts +++ b/libs/home/src/lib/containers/home-layout/home-layout.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { routerTransition } from '@ngx-starter-kit/animations'; +import { PageTitleService } from '@ngx-starter-kit/core'; @Component({ selector: 'ngx-home-layout', @@ -8,7 +9,9 @@ import { routerTransition } from '@ngx-starter-kit/animations'; animations: [routerTransition], }) export class HomeLayoutComponent implements OnInit { - constructor() {} + constructor(private pageTitleService: PageTitleService) {} - ngOnInit() {} + ngOnInit() { + this.pageTitleService.title = 'Home'; + } }