Resources pages: Change breadcrumbs home route

This commit is contained in:
Konstantinos Triantafyllou 2022-08-29 16:57:04 +03:00
parent 81b3a5f8b4
commit 27b47975aa
4 changed files with 69 additions and 65 deletions

View File

@ -1,9 +1,10 @@
import {Component, OnInit} from "@angular/core"; import {Component, OnDestroy, OnInit} from "@angular/core";
import {properties} from "../../../../environments/environment"; import {properties} from "../../../../environments/environment";
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {Meta, Title} from "@angular/platform-browser"; import {Meta, Title} from "@angular/platform-browser";
import {SEOService} from "../../sharedComponents/SEO/SEO.service"; import {SEOService} from "../../sharedComponents/SEO/SEO.service";
import {Breadcrumb} from "../../utils/breadcrumbs/breadcrumbs.component"; import {Breadcrumb} from "../../utils/breadcrumbs/breadcrumbs.component";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'indicator-themes-page', selector: 'indicator-themes-page',
@ -40,7 +41,8 @@ import {Breadcrumb} from "../../utils/breadcrumbs/breadcrumbs.component";
</div> </div>
` `
}) })
export class IndicatorThemesComponent implements OnInit { export class IndicatorThemesComponent implements OnInit, OnDestroy {
private subscriptions: any[] = [];
public properties = properties; public properties = properties;
public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'Resources'}, {name: 'Themes'}]; public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'Resources'}, {name: 'Themes'}];
@ -52,9 +54,20 @@ export class IndicatorThemesComponent implements OnInit {
} }
ngOnInit() { ngOnInit() {
const description = "Monitor | Indicator Themes"; this.subscriptions.push(this.route.params.subscribe(params => {
const title = "Monitor | Indicator Themes"; const description = "Monitor | Indicator Themes";
this.metaTags(title, description); 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) { metaTags(title, description) {

View File

@ -37,7 +37,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy {
ngOnInit() { ngOnInit() {
this.subscriptions.push(this.route.params.subscribe(params => { this.subscriptions.push(this.route.params.subscribe(params => {
if(params['type']){ if(params['type']) {
let type = this.types.find(type => type.value === params['type']); let type = this.types.find(type => type.value === params['type']);
if(type) { if(type) {
this.getPageContents(type.value); this.getPageContents(type.value);
@ -47,7 +47,16 @@ export class IndicatorsComponent implements OnInit, OnDestroy {
this.breadcrumbs[2] = {name: type.label}; 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) { metaTags(title, description) {
@ -60,14 +69,6 @@ export class IndicatorsComponent implements OnInit, OnDestroy {
this.title.setTitle(title); this.title.setTitle(title);
} }
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
public getPageContents(type: string) { public getPageContents(type: string) {
this.subscriptions.push(this.resourcesService.isPagesEnabled().subscribe(status => { this.subscriptions.push(this.resourcesService.isPagesEnabled().subscribe(status => {
let index = this.types.findIndex(t => t.value === type); let index = this.types.findIndex(t => t.value === type);

View File

@ -4,7 +4,6 @@ import {Meta, Title} from "@angular/platform-browser";
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {Stakeholder} from "../entities/stakeholder"; import {Stakeholder} from "../entities/stakeholder";
import {OpenaireEntities} from "../../utils/properties/searchFields"; import {OpenaireEntities} from "../../utils/properties/searchFields";
import {StakeholderService} from "../services/stakeholder.service";
import {SEOService} from "../../sharedComponents/SEO/SEO.service"; import {SEOService} from "../../sharedComponents/SEO/SEO.service";
import {properties} from "../../../../environments/environment"; import {properties} from "../../../../environments/environment";
import {Breadcrumb} from "../../utils/breadcrumbs/breadcrumbs.component"; import {Breadcrumb} from "../../utils/breadcrumbs/breadcrumbs.component";
@ -69,34 +68,21 @@ export class SeeHowItWorksComponent implements OnInit, OnDestroy {
public tab: 'entities' | 'attributes' = 'entities'; public tab: 'entities' | 'attributes' = 'entities';
private subscriptions: any[] = []; private subscriptions: any[] = [];
public openaireEntities = OpenaireEntities; public openaireEntities = OpenaireEntities;
public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'Resources'}, { public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'Resources'}, {name: 'See how it works', keepFormat: true}];
name: 'See how it works',
keepFormat: true
}];
constructor(private stakeholderService: StakeholderService, constructor(private seoService: SEOService,
private seoService: SEOService, private meta: Meta,
private _meta: Meta, private router: Router,
private _router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
private _title: Title) { private title: Title) {
} }
ngOnInit() { ngOnInit() {
this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { this.subscriptions.push(this.route.params.subscribe(params => {
this.stakeholder = stakeholder; const description = "Monitor | See how it works";
if (this.stakeholder) { const title = "Monitor | See how it works";
/* Metadata */ this.metaTags(title, description);
const url = properties.domain + properties.baseLink + this._router.url; this.breadcrumbs[0].route = '/' + (params['stakeholder']?params['stakeholder']:'');
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);
}
})); }));
} }
@ -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);
}
} }

View File

@ -2,9 +2,7 @@ import {Component, OnDestroy, OnInit} from "@angular/core";
import {Subscription} from "rxjs"; import {Subscription} from "rxjs";
import {Meta, Title} from "@angular/platform-browser"; import {Meta, Title} from "@angular/platform-browser";
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {Stakeholder} from "../entities/stakeholder";
import {OpenaireEntities} from "../../utils/properties/searchFields"; import {OpenaireEntities} from "../../utils/properties/searchFields";
import {StakeholderService} from "../services/stakeholder.service";
import {SEOService} from "../../sharedComponents/SEO/SEO.service"; import {SEOService} from "../../sharedComponents/SEO/SEO.service";
import {properties} from "../../../../environments/environment"; import {properties} from "../../../../environments/environment";
import {Breadcrumb} from "../../utils/breadcrumbs/breadcrumbs.component"; import {Breadcrumb} from "../../utils/breadcrumbs/breadcrumbs.component";
@ -448,38 +446,24 @@ import {Breadcrumb} from "../../utils/breadcrumbs/breadcrumbs.component";
` `
}) })
export class TerminologyComponent implements OnInit, OnDestroy { export class TerminologyComponent implements OnInit, OnDestroy {
public stakeholder: Stakeholder;
public tab: 'entities' | 'attributes' = 'entities'; public tab: 'entities' | 'attributes' = 'entities';
private subscriptions: any[] = []; private subscriptions: any[] = [];
public openaireEntities = OpenaireEntities; public openaireEntities = OpenaireEntities;
public breadcrumbs: Breadcrumb[] = [{ public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'Resources'}, {name: 'Terminology and construction', keepFormat: true}];
name: 'home',
route: '/'
}, {name: 'Resources'}, {name: 'Terminology and construction', keepFormat: true}];
constructor(private stakeholderService: StakeholderService, constructor(private seoService: SEOService,
private seoService: SEOService, private meta: Meta,
private _meta: Meta, private router: Router,
private _router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
private _title: Title) { private title: Title) {
} }
ngOnInit() { ngOnInit() {
this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { this.subscriptions.push(this.route.params.subscribe(params => {
this.stakeholder = stakeholder; const description = "Monitor | Terminology and construction";
if (this.stakeholder) { const title = "Monitor | Terminology and construction";
/* Metadata */ this.metaTags(title, description);
const url = properties.domain + properties.baseLink + this._router.url; this.breadcrumbs[0].route = '/' + (params['stakeholder']?params['stakeholder']:'');
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);
}
})); }));
} }
@ -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);
}
} }