From 8f245e4ddd2bd584326b5f4d646fc92c4ca16c2a Mon Sep 17 00:00:00 2001 From: Konstantinos Triantafyllou Date: Thu, 15 Apr 2021 18:52:58 +0000 Subject: [PATCH] [Graph | Trunk]: Add meta data information to new pages git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-graph-portal/trunk@60872 d315682c-612b-4755-9ff5-7f18f6832af3 --- src/app/about/about.component.ts | 14 ++++---- src/app/about/team.component.ts | 41 +++++++++++++++++++++-- src/app/app.component.spec.ts | 32 ------------------ src/app/contact/contact.component.ts | 12 ++++--- src/app/home/home.component.ts | 12 ++++--- src/app/resources/references.component.ts | 41 +++++++++++++++++++++-- src/app/resources/resources.component.ts | 12 ++++--- 7 files changed, 107 insertions(+), 57 deletions(-) delete mode 100644 src/app/app.component.spec.ts diff --git a/src/app/about/about.component.ts b/src/app/about/about.component.ts index 5b1fbad..ebb594a 100644 --- a/src/app/about/about.component.ts +++ b/src/app/about/about.component.ts @@ -1,4 +1,4 @@ -import {Component, ElementRef, OnInit, ViewChild} from '@angular/core'; +import {Component, ElementRef, OnDestroy, OnInit, ViewChild} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; import {Meta, Title} from '@angular/platform-browser'; import {Breadcrumb} from "../openaireLibrary/utils/breadcrumbs/breadcrumbs.component"; @@ -15,7 +15,7 @@ declare var UIkit: any; templateUrl: 'about.component.html', styleUrls: ['about.component.css'], }) -export class AboutComponent implements OnInit { +export class AboutComponent implements OnInit, OnDestroy { @ViewChild('tabs') tabs: ElementRef; public architectureImage: string = "gray.png"; public aggregationReadMore: boolean = false; @@ -59,10 +59,12 @@ export class AboutComponent implements OnInit { changeTab(index: number) { UIkit.switcher(this.tabs.nativeElement).show(index); } + public ngOnDestroy() { - for (let sub of this.subs) { - sub.unsubscribe(); - } + this.subs.forEach(sub => { + if(sub instanceof Subscription) { + sub.unsubscribe(); + } + }); } - } diff --git a/src/app/about/team.component.ts b/src/app/about/team.component.ts index ffed138..33e611a 100644 --- a/src/app/about/team.component.ts +++ b/src/app/about/team.component.ts @@ -1,6 +1,13 @@ -import {Component} from '@angular/core'; +import {Component, OnDestroy, OnInit} from '@angular/core'; import {Breadcrumb} from '../openaireLibrary/utils/breadcrumbs/breadcrumbs.component'; import {member, team} from './team'; +import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service'; +import {Meta, Title} from '@angular/platform-browser'; +import {SEOService} from '../openaireLibrary/sharedComponents/SEO/SEO.service'; +import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties'; +import {properties} from '../../environments/environment'; +import {Subscription} from 'rxjs'; +import {Router} from '@angular/router'; @Component({ selector: 'team', @@ -67,8 +74,12 @@ import {member, team} from './team'; `, styleUrls: ['team.component.css'] }) -export class TeamComponent { +export class TeamComponent implements OnInit, OnDestroy { public team: member[] = team; + properties: EnvProperties = properties + description = "The OpenAIRE Research Graph Team"; + title = "OpenAIRE - Research Graph | Team"; + subs: Subscription[] = []; public breadcrumbs: Breadcrumb[] = [ { name: 'home', @@ -82,4 +93,30 @@ export class TeamComponent { name: 'Team' } ]; + + constructor(private _title: Title, private _piwikService:PiwikService, + private _router: Router, private _meta: Meta, + private seoService: SEOService) { + } + + ngOnInit() { + this._title.setTitle(this.title); + this._meta.updateTag({content:this.description},"name='description'"); + this._meta.updateTag({content:this.description},"property='og:description'"); + this._meta.updateTag({content:this.title},"property='og:title'"); + var url = this.properties.domain + this.properties.baseLink+this._router.url; + this.seoService.createLinkForCanonicalURL(url, false); + this._meta.updateTag({content:url},"property='og:url'"); + if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){ + this.subs.push(this._piwikService.trackView(this.properties, this.title).subscribe()); + } + } + + public ngOnDestroy() { + this.subs.forEach(sub => { + if(sub instanceof Subscription) { + sub.unsubscribe(); + } + }); + } } diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts deleted file mode 100644 index 9510495..0000000 --- a/src/app/app.component.spec.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { TestBed, async } from '@angular/core/testing'; - -import { AppComponent } from './app.component'; - -describe('AppComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ - AppComponent - ], - }).compileComponents(); - })); - - it('should create the app', async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.debugElement.componentInstance; - expect(app).toBeTruthy(); - })); - - it(`should have as title 'app'`, async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.debugElement.componentInstance; - expect(app.title).toEqual('app'); - })); - - it('should render title in a h1 tag', async(() => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!'); - })); -}); diff --git a/src/app/contact/contact.component.ts b/src/app/contact/contact.component.ts index 5b713e7..0372281 100644 --- a/src/app/contact/contact.component.ts +++ b/src/app/contact/contact.component.ts @@ -1,4 +1,4 @@ -import {Component, OnInit, ViewChild} from '@angular/core'; +import {Component, OnDestroy, OnInit, ViewChild} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; import {EmailService} from '../openaireLibrary/utils/email/email.service'; import {Email} from '../openaireLibrary/utils/email/email'; @@ -20,7 +20,7 @@ import {SEOService} from '../openaireLibrary/sharedComponents/SEO/SEO.service'; styleUrls: ['contact.component.css'] }) -export class ContactComponent implements OnInit { +export class ContactComponent implements OnInit, OnDestroy { public showLoading = true; public errorMessage = ''; public email: Email; @@ -152,8 +152,10 @@ export class ContactComponent implements OnInit { } public ngOnDestroy() { - for (let sub of this.subs) { - sub.unsubscribe(); - } + this.subs.forEach(sub => { + if(sub instanceof Subscription) { + sub.unsubscribe(); + } + }); } } diff --git a/src/app/home/home.component.ts b/src/app/home/home.component.ts index 39f73d8..1dd4812 100644 --- a/src/app/home/home.component.ts +++ b/src/app/home/home.component.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {Component, OnDestroy, OnInit} from '@angular/core'; import {Subscription} from 'rxjs'; import {ActivatedRoute, Router} from '@angular/router'; import {Location} from '@angular/common'; @@ -18,7 +18,7 @@ import {RouterHelper} from '../openaireLibrary/utils/routerHelper.class'; templateUrl: 'home.component.html', styleUrls: ['home.component.css'] }) -export class HomeComponent { +export class HomeComponent implements OnInit, OnDestroy { public pageTitle = 'OpenAIRE - Research Graph'; public portals: any[] = portals; public state: number = 0; @@ -79,9 +79,11 @@ export class HomeComponent { } public ngOnDestroy() { - for (let sub of this.subs) { - sub.unsubscribe(); - } + this.subs.forEach(sub => { + if(sub instanceof Subscription) { + sub.unsubscribe(); + } + }); this.clearTimeouts(); } diff --git a/src/app/resources/references.component.ts b/src/app/resources/references.component.ts index cbaf015..d4fedc0 100644 --- a/src/app/resources/references.component.ts +++ b/src/app/resources/references.component.ts @@ -1,5 +1,12 @@ -import {Component} from '@angular/core'; +import {Component, OnDestroy, OnInit} from '@angular/core'; import {Breadcrumb} from '../openaireLibrary/utils/breadcrumbs/breadcrumbs.component'; +import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties'; +import {Subscription} from 'rxjs'; +import {properties} from '../../environments/environment'; +import {Meta, Title} from '@angular/platform-browser'; +import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service'; +import {Router} from '@angular/router'; +import {SEOService} from '../openaireLibrary/sharedComponents/SEO/SEO.service'; @Component({ selector: 'references', @@ -161,7 +168,11 @@ import {Breadcrumb} from '../openaireLibrary/utils/breadcrumbs/breadcrumbs.compo `, styleUrls: ['references.component.css'] }) -export class ReferencesComponent { +export class ReferencesComponent implements OnInit, OnDestroy { + properties: EnvProperties = properties; + description = "The OpenAIRE Research Graph references"; + title = "OpenAIRE - Research Graph | References"; + subs: Subscription[] = []; public breadcrumbs: Breadcrumb[] = [ { name: 'home', @@ -175,4 +186,30 @@ export class ReferencesComponent { name: 'References' } ]; + + constructor(private _title: Title, private _piwikService:PiwikService, + private _router: Router, private _meta: Meta, + private seoService: SEOService) { + } + + ngOnInit() { + this._title.setTitle(this.title); + this._meta.updateTag({content:this.description},"name='description'"); + this._meta.updateTag({content:this.description},"property='og:description'"); + this._meta.updateTag({content:this.title},"property='og:title'"); + var url = this.properties.domain + this.properties.baseLink+this._router.url; + this.seoService.createLinkForCanonicalURL(url, false); + this._meta.updateTag({content:url},"property='og:url'"); + if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){ + this.subs.push(this._piwikService.trackView(this.properties, this.title).subscribe()); + } + } + + public ngOnDestroy() { + this.subs.forEach(sub => { + if(sub instanceof Subscription) { + sub.unsubscribe(); + } + }); + } } diff --git a/src/app/resources/resources.component.ts b/src/app/resources/resources.component.ts index ffebc1b..3e8ea38 100644 --- a/src/app/resources/resources.component.ts +++ b/src/app/resources/resources.component.ts @@ -1,4 +1,4 @@ -import {Component, OnInit} from '@angular/core'; +import {Component, OnDestroy, OnInit} from '@angular/core'; import {Meta, Title} from '@angular/platform-browser'; import {Breadcrumb} from "../openaireLibrary/utils/breadcrumbs/breadcrumbs.component"; import {ActivatedRoute, Router} from '@angular/router'; @@ -13,7 +13,7 @@ import {Subscription} from 'rxjs'; templateUrl: 'resources.component.html', styleUrls: ['resources.component.css'], }) -export class ResourcesComponent implements OnInit { +export class ResourcesComponent implements OnInit, OnDestroy { properties:EnvProperties; subs: Subscription[] = []; description = "Start building with OpenAIRE APIs. How to access the graph? XML Metadata schema and documentation."; @@ -48,8 +48,10 @@ export class ResourcesComponent implements OnInit { } public ngOnDestroy() { - for (let sub of this.subs) { - sub.unsubscribe(); - } + this.subs.forEach(sub => { + if(sub instanceof Subscription) { + sub.unsubscribe(); + } + }); } }