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 {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";
</div>
`
})
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) {

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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);
}
}