From: Barath Kumar R Date: Thu, 20 May 2021 07:12:06 +0000 (+0530) Subject: Title will be show in the browser head X-Git-Tag: release-v11.0-start~3 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=250ed205aef6e60544514fc622ccaf1b49a7775b;p=osm%2FNG-UI.git Title will be show in the browser head Change-Id: I9e1a1150661fe57ea75b7c12a29a6c3f92c4b161 Signed-off-by: Barath Kumar R --- diff --git a/src/app/layouts/breadcrumb/BreadcrumbComponent.ts b/src/app/layouts/breadcrumb/BreadcrumbComponent.ts index ccb9588..e273cda 100644 --- a/src/app/layouts/breadcrumb/BreadcrumbComponent.ts +++ b/src/app/layouts/breadcrumb/BreadcrumbComponent.ts @@ -19,6 +19,7 @@ * @file Bread Crumb component. */ import { Component, Injector, OnInit } from '@angular/core'; +import { Title } from '@angular/platform-browser'; import { ActivatedRoute, NavigationEnd, Router, RouterEvent, UrlSegment } from '@angular/router'; import { TranslateService } from '@ngx-translate/core'; import { BREADCRUMBITEM } from 'CommonModel'; @@ -58,11 +59,15 @@ export class BreadcrumbComponent implements OnInit { /** handle translate service @private */ private translateService: TranslateService; + /** Title Service in create ticket page */ + private titleService: Title; + constructor(injector: Injector) { this.injector = injector; this.router = this.injector.get(Router); this.activatedRoute = this.injector.get(ActivatedRoute); this.translateService = this.injector.get(TranslateService); + this.titleService = this.injector.get(Title); } /** Lifecyle Hooks the trigger before component is instantiate @public */ public ngOnInit(): void { @@ -70,7 +75,10 @@ export class BreadcrumbComponent implements OnInit { .pipe(filter((event: RouterEvent) => event instanceof NavigationEnd), startWith(undefined)) .subscribe(() => this.menuItems = this.createBreadcrumbs(this.activatedRoute.root)); } - + /** To set the title if the page @private */ + public setTitle(newTitle: string): void { + this.titleService.setTitle(newTitle); + } /** Generate breadcrumbs from data given the module routes @private */ private createBreadcrumbs(route: ActivatedRoute, url: string = '', breadcrumbs: BREADCRUMBITEM[] = []): BREADCRUMBITEM[] { @@ -99,9 +107,18 @@ export class BreadcrumbComponent implements OnInit { breadcrumbs.push(item); }); } + this.setTitleforApplication(breadcrumbs); return this.createBreadcrumbs(child, url, breadcrumbs); } } + /** Generate title from data given the module routes @private */ + private setTitleforApplication(breadcrumbs: BREADCRUMBITEM[]): void { + let addTitle: string = 'Open Source MANO'; + breadcrumbs.forEach((data: BREADCRUMBITEM): void => { + addTitle += ' | ' + this.translateService.instant(data.title); + }); + this.setTitle(addTitle); + } /** Check and update title based on type of operations @private */ private checkTitle(breadcrumbItem: BREADCRUMBITEM, opertionType: string): string { if (!isNullOrUndefined(breadcrumbItem.url)) {