diff --git a/monitor/indicators/indicator-themes.component.ts b/monitor/indicators/indicator-themes.component.ts index 8f9a3925..63b88e0f 100644 --- a/monitor/indicators/indicator-themes.component.ts +++ b/monitor/indicators/indicator-themes.component.ts @@ -1,9 +1,10 @@ -import {Component, OnInit} from "@angular/core"; +import {Component, OnDestroy, OnInit} from "@angular/core"; import {properties} from "../../../../environments/environment"; import {ActivatedRoute, Router} from "@angular/router"; import {Meta, Title} from "@angular/platform-browser"; import {SEOService} from "../../sharedComponents/SEO/SEO.service"; import {Breadcrumb} from "../../utils/breadcrumbs/breadcrumbs.component"; +import {Subscriber} from "rxjs"; @Component({ selector: 'indicator-themes-page', @@ -40,7 +41,8 @@ import {Breadcrumb} from "../../utils/breadcrumbs/breadcrumbs.component"; ` }) -export class IndicatorThemesComponent implements OnInit { +export class IndicatorThemesComponent implements OnInit, OnDestroy { + private subscriptions: any[] = []; public properties = properties; public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'Resources'}, {name: 'Themes'}]; @@ -52,9 +54,20 @@ export class IndicatorThemesComponent implements OnInit { } ngOnInit() { - const description = "Monitor | Indicator Themes"; - const title = "Monitor | Indicator Themes"; - this.metaTags(title, description); + this.subscriptions.push(this.route.params.subscribe(params => { + const description = "Monitor | Indicator Themes"; + const title = "Monitor | Indicator Themes"; + this.metaTags(title, description); + this.breadcrumbs[0].route = '/' + (params['stakeholder']?params['stakeholder']:''); + })); + } + + ngOnDestroy() { + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); } metaTags(title, description) { diff --git a/monitor/indicators/indicators.component.ts b/monitor/indicators/indicators.component.ts index b0062b49..157299c4 100644 --- a/monitor/indicators/indicators.component.ts +++ b/monitor/indicators/indicators.component.ts @@ -37,7 +37,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy { ngOnInit() { this.subscriptions.push(this.route.params.subscribe(params => { - if(params['type']){ + if(params['type']) { let type = this.types.find(type => type.value === params['type']); if(type) { this.getPageContents(type.value); @@ -47,7 +47,16 @@ export class IndicatorsComponent implements OnInit, OnDestroy { this.breadcrumbs[2] = {name: type.label}; } } - })) + this.breadcrumbs[0].route = '/' + (params['stakeholder']?params['stakeholder']:''); + })); + } + + ngOnDestroy() { + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); } metaTags(title, description) { @@ -60,14 +69,6 @@ export class IndicatorsComponent implements OnInit, OnDestroy { this.title.setTitle(title); } - ngOnDestroy() { - this.subscriptions.forEach(subscription => { - if (subscription instanceof Subscriber) { - subscription.unsubscribe(); - } - }); - } - public getPageContents(type: string) { this.subscriptions.push(this.resourcesService.isPagesEnabled().subscribe(status => { let index = this.types.findIndex(t => t.value === type); diff --git a/monitor/methodology/see-how-it-works.component.ts b/monitor/methodology/see-how-it-works.component.ts index bf65b931..b69fd1b5 100644 --- a/monitor/methodology/see-how-it-works.component.ts +++ b/monitor/methodology/see-how-it-works.component.ts @@ -4,7 +4,6 @@ import {Meta, Title} from "@angular/platform-browser"; import {ActivatedRoute, Router} from "@angular/router"; import {Stakeholder} from "../entities/stakeholder"; import {OpenaireEntities} from "../../utils/properties/searchFields"; -import {StakeholderService} from "../services/stakeholder.service"; import {SEOService} from "../../sharedComponents/SEO/SEO.service"; import {properties} from "../../../../environments/environment"; import {Breadcrumb} from "../../utils/breadcrumbs/breadcrumbs.component"; @@ -69,34 +68,21 @@ export class SeeHowItWorksComponent implements OnInit, OnDestroy { public tab: 'entities' | 'attributes' = 'entities'; private subscriptions: any[] = []; public openaireEntities = OpenaireEntities; - public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'Resources'}, { - name: 'See how it works', - keepFormat: true - }]; + public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'Resources'}, {name: 'See how it works', keepFormat: true}]; - constructor(private stakeholderService: StakeholderService, - private seoService: SEOService, - private _meta: Meta, - private _router: Router, + constructor(private seoService: SEOService, + private meta: Meta, + private router: Router, private route: ActivatedRoute, - private _title: Title) { + private title: Title) { } ngOnInit() { - this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { - this.stakeholder = stakeholder; - if (this.stakeholder) { - /* Metadata */ - const url = properties.domain + properties.baseLink + this._router.url; - this.seoService.createLinkForCanonicalURL(url, false); - this._meta.updateTag({content: url}, "property='og:url'"); - const description = "Methodology | " + this.stakeholder.name; - const title = "Methodology | " + this.stakeholder.name; - this._meta.updateTag({content: description}, "name='description'"); - this._meta.updateTag({content: description}, "property='og:description'"); - this._meta.updateTag({content: title}, "property='og:title'"); - this._title.setTitle(title); - } + this.subscriptions.push(this.route.params.subscribe(params => { + const description = "Monitor | See how it works"; + const title = "Monitor | See how it works"; + this.metaTags(title, description); + this.breadcrumbs[0].route = '/' + (params['stakeholder']?params['stakeholder']:''); })); } @@ -107,4 +93,14 @@ export class SeeHowItWorksComponent implements OnInit, OnDestroy { } }); } + + metaTags(title, description) { + const url = properties.domain + properties.baseLink + this.router.url; + this.seoService.createLinkForCanonicalURL(url, false); + this.meta.updateTag({content: url}, "property='og:url'"); + this.meta.updateTag({content: description}, "name='description'"); + this.meta.updateTag({content: description}, "property='og:description'"); + this.meta.updateTag({content: title}, "property='og:title'"); + this.title.setTitle(title); + } } diff --git a/monitor/methodology/terminology.component.ts b/monitor/methodology/terminology.component.ts index 5320ce93..baab49f0 100644 --- a/monitor/methodology/terminology.component.ts +++ b/monitor/methodology/terminology.component.ts @@ -2,9 +2,7 @@ import {Component, OnDestroy, OnInit} from "@angular/core"; import {Subscription} from "rxjs"; import {Meta, Title} from "@angular/platform-browser"; import {ActivatedRoute, Router} from "@angular/router"; -import {Stakeholder} from "../entities/stakeholder"; import {OpenaireEntities} from "../../utils/properties/searchFields"; -import {StakeholderService} from "../services/stakeholder.service"; import {SEOService} from "../../sharedComponents/SEO/SEO.service"; import {properties} from "../../../../environments/environment"; import {Breadcrumb} from "../../utils/breadcrumbs/breadcrumbs.component"; @@ -448,38 +446,24 @@ import {Breadcrumb} from "../../utils/breadcrumbs/breadcrumbs.component"; ` }) export class TerminologyComponent implements OnInit, OnDestroy { - public stakeholder: Stakeholder; public tab: 'entities' | 'attributes' = 'entities'; private subscriptions: any[] = []; public openaireEntities = OpenaireEntities; - public breadcrumbs: Breadcrumb[] = [{ - name: 'home', - route: '/' - }, {name: 'Resources'}, {name: 'Terminology and construction', keepFormat: true}]; + public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'Resources'}, {name: 'Terminology and construction', keepFormat: true}]; - constructor(private stakeholderService: StakeholderService, - private seoService: SEOService, - private _meta: Meta, - private _router: Router, + constructor(private seoService: SEOService, + private meta: Meta, + private router: Router, private route: ActivatedRoute, - private _title: Title) { + private title: Title) { } ngOnInit() { - this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { - this.stakeholder = stakeholder; - if (this.stakeholder) { - /* Metadata */ - const url = properties.domain + properties.baseLink + this._router.url; - this.seoService.createLinkForCanonicalURL(url, false); - this._meta.updateTag({content: url}, "property='og:url'"); - const description = "Methodology | " + this.stakeholder.name; - const title = "Methodology | " + this.stakeholder.name; - this._meta.updateTag({content: description}, "name='description'"); - this._meta.updateTag({content: description}, "property='og:description'"); - this._meta.updateTag({content: title}, "property='og:title'"); - this._title.setTitle(title); - } + this.subscriptions.push(this.route.params.subscribe(params => { + const description = "Monitor | Terminology and construction"; + const title = "Monitor | Terminology and construction"; + this.metaTags(title, description); + this.breadcrumbs[0].route = '/' + (params['stakeholder']?params['stakeholder']:''); })); } @@ -490,4 +474,14 @@ export class TerminologyComponent implements OnInit, OnDestroy { } }); } + + metaTags(title, description) { + const url = properties.domain + properties.baseLink + this.router.url; + this.seoService.createLinkForCanonicalURL(url, false); + this.meta.updateTag({content: url}, "property='og:url'"); + this.meta.updateTag({content: description}, "name='description'"); + this.meta.updateTag({content: description}, "property='og:description'"); + this.meta.updateTag({content: title}, "property='og:title'"); + this.title.setTitle(title); + } }