From c3ab3b18fa67f818fa68ea3394bba831e6911d94 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Wed, 24 Apr 2019 12:31:01 +0000 Subject: [PATCH] [Trunk|Library]: Use scroll function from 'HelperFunctions' class (utils folder). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@55418 d315682c-612b-4755-9ff5-7f18f6832af3 --- .../dataProvider/dataProvider.component.ts | 12 ++++------- landingPages/dataset/dataset.component.ts | 14 ++++--------- .../landing-utils/availableOn.component.ts | 9 ++++---- .../landing-utils/fundedBy.component.ts | 9 ++++---- .../landing-utils/publishedIn.component.ts | 9 ++++---- .../landing-utils/showAuthors.component.ts | 9 ++++---- .../showIdentifiers.component.ts | 9 ++++---- .../organization/organization.component.ts | 7 +++---- landingPages/orp/orp.component.ts | 10 ++++----- landingPages/project/project.component.ts | 10 ++++----- .../publication/publication.component.ts | 10 ++++----- landingPages/software/software.component.ts | 10 ++++----- reload/reload.component.ts | 21 +++++-------------- .../searchUtils/searchPage.component.ts | 13 +++++------- 14 files changed, 57 insertions(+), 95 deletions(-) diff --git a/landingPages/dataProvider/dataProvider.component.ts b/landingPages/dataProvider/dataProvider.component.ts index a49e11a4..f2ee50da 100644 --- a/landingPages/dataProvider/dataProvider.component.ts +++ b/landingPages/dataProvider/dataProvider.component.ts @@ -1,5 +1,5 @@ import {Component, ViewChild} from '@angular/core'; -import {ElementRef, Input} from '@angular/core'; +import {Input} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; import {Title, Meta} from '@angular/platform-browser'; @@ -29,6 +29,7 @@ import {ErrorCodes} from '../../utils/properties/errorCo import {RouterHelper} from '../../utils/routerHelper.class'; import {PiwikService} from '../../utils/piwik/piwik.service'; import { SEOService } from '../../sharedComponents/SEO/SEO.service'; +import {HelperFunctions} from "../../utils/HelperFunctions.class"; @Component({ @@ -95,16 +96,13 @@ export class DataProviderComponent { private reloadDataproviders: boolean = true; private reloadRelatedDatasources: boolean = true; - private nativeElement : Node; - sub: any; piwiksub: any; subInfo: any; relatedDatasourcesSub: any; properties:EnvProperties; - constructor (private element: ElementRef, - private _dataproviderService: DataProviderService, + constructor (private _dataproviderService: DataProviderService, private _piwikService:PiwikService, private route: ActivatedRoute, private _meta: Meta, @@ -142,9 +140,7 @@ export class DataProviderComponent { this.getDataProviderInfo(this.datasourceId); } - if (typeof document !== 'undefined') { - this.element.nativeElement.scrollIntoView(); - } + HelperFunctions.scroll(); }); } diff --git a/landingPages/dataset/dataset.component.ts b/landingPages/dataset/dataset.component.ts index a4bc1d54..306181c9 100644 --- a/landingPages/dataset/dataset.component.ts +++ b/landingPages/dataset/dataset.component.ts @@ -1,5 +1,5 @@ import {Component, ViewChild} from '@angular/core'; -import {ElementRef, Input} from '@angular/core'; +import {Input} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; import {Title, Meta} from '@angular/platform-browser'; @@ -12,6 +12,7 @@ import {RouterHelper} from '../../utils/routerHelper.class'; import {DatasetService} from './dataset.service'; import {PiwikService} from '../../utils/piwik/piwik.service'; import { SEOService } from '../../sharedComponents/SEO/SEO.service'; +import {HelperFunctions} from "../../utils/HelperFunctions.class"; @Component({ @@ -61,8 +62,7 @@ export class DatasetComponent { sub: any; piwiksub: any; infoSub: any; properties:EnvProperties; - constructor (private element: ElementRef, - private _datasetService: DatasetService, + constructor (private _datasetService: DatasetService, private _piwikService:PiwikService, private route: ActivatedRoute, private _meta: Meta, @@ -102,7 +102,7 @@ export class DatasetComponent { this.downloadsFrameUrl = this.properties.framesAPIURL+'merge.php?com=query&data=[{"query":"resRepoDownloads", "resTitle":"'+this.datasetId+'", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false'; /*this.downloadsFrameUrl = this.properties.framesAPIURL+'merge.php?com=query&data=[{"query":"resRepoDownloadTimeline", "resTitle":"'+this.datasetId+'", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true'; */ - this.scroll(); + HelperFunctions.scroll(); }); } @@ -202,12 +202,6 @@ export class DatasetComponent { return Array.from(map.keys()); } - public scroll() { - if (typeof document !== 'undefined') { - this.element.nativeElement.scrollIntoView(); - } - } - private handleError(message: string, error) { console.error("Research Data Landing Page: "+message, error); } diff --git a/landingPages/landing-utils/availableOn.component.ts b/landingPages/landing-utils/availableOn.component.ts index ea3c7ac3..de6e6bdc 100644 --- a/landingPages/landing-utils/availableOn.component.ts +++ b/landingPages/landing-utils/availableOn.component.ts @@ -1,4 +1,5 @@ -import {Component, Input, ElementRef} from '@angular/core'; +import {Component, Input} from '@angular/core'; +import {HelperFunctions} from "../../utils/HelperFunctions.class"; @Component({ selector: 'availableOn', @@ -64,13 +65,11 @@ export class AvailableOnComponent { public threshold: number = 5; public showNum: number = 5; - constructor (private element: ElementRef) {} + constructor () {} ngOnInit() {} public scroll() { - if (typeof document !== 'undefined') { - this.element.nativeElement.scrollIntoView(); - } + HelperFunctions.scroll(); } } diff --git a/landingPages/landing-utils/fundedBy.component.ts b/landingPages/landing-utils/fundedBy.component.ts index c66c6ec0..73c0f521 100644 --- a/landingPages/landing-utils/fundedBy.component.ts +++ b/landingPages/landing-utils/fundedBy.component.ts @@ -1,4 +1,5 @@ -import {Component, Input, ElementRef} from '@angular/core'; +import {Component, Input} from '@angular/core'; +import {HelperFunctions} from "../../utils/HelperFunctions.class"; @Component({ selector: 'fundedBy', @@ -71,7 +72,7 @@ export class FundedByComponent { public threshold: number = 5; public showNum: number = 5; - constructor (private element: ElementRef) {} + constructor () {} ngOnInit() {} @@ -124,8 +125,6 @@ export class FundedByComponent { } public scroll() { - if (typeof document !== 'undefined') { - this.element.nativeElement.scrollIntoView(); - } + HelperFunctions.scroll(); } } diff --git a/landingPages/landing-utils/publishedIn.component.ts b/landingPages/landing-utils/publishedIn.component.ts index 597d38f1..0c576702 100644 --- a/landingPages/landing-utils/publishedIn.component.ts +++ b/landingPages/landing-utils/publishedIn.component.ts @@ -1,4 +1,5 @@ -import {Component, Input, ElementRef} from '@angular/core'; +import {Component, Input} from '@angular/core'; +import {HelperFunctions} from "../../utils/HelperFunctions.class"; @Component({ selector: 'publishedIn', @@ -54,14 +55,12 @@ export class PublishedInComponent { public showAll: boolean = false; - constructor (private element: ElementRef) {} + constructor () {} ngOnInit() {} public scroll() { - if (typeof document !== 'undefined') { - this.element.nativeElement.scrollIntoView(); - } + HelperFunctions.scroll(); } public getKeys( map) { return Array.from(map.keys()); diff --git a/landingPages/landing-utils/showAuthors.component.ts b/landingPages/landing-utils/showAuthors.component.ts index 489e5541..be4f6b3c 100644 --- a/landingPages/landing-utils/showAuthors.component.ts +++ b/landingPages/landing-utils/showAuthors.component.ts @@ -1,5 +1,6 @@ -import {Component, Input, ElementRef} from '@angular/core'; +import {Component, Input} from '@angular/core'; import {RouterHelper} from '../../utils/routerHelper.class'; +import {HelperFunctions} from "../../utils/HelperFunctions.class"; @Component({ selector: 'showAuthors', @@ -46,7 +47,7 @@ export class ShowAuthorsComponent { public showAll: boolean = false; public routerHelper:RouterHelper = new RouterHelper(); - constructor (private element: ElementRef) { + constructor () { } ngOnInit() { @@ -57,8 +58,6 @@ export class ShowAuthorsComponent { } public scroll() { - if (typeof document !== 'undefined') { - this.element.nativeElement.scrollIntoView(); - } + HelperFunctions.scroll(); } } diff --git a/landingPages/landing-utils/showIdentifiers.component.ts b/landingPages/landing-utils/showIdentifiers.component.ts index d78376bf..7bb02e2b 100644 --- a/landingPages/landing-utils/showIdentifiers.component.ts +++ b/landingPages/landing-utils/showIdentifiers.component.ts @@ -1,4 +1,5 @@ -import {Component, Input, ElementRef} from '@angular/core'; +import {Component, Input} from '@angular/core'; +import {HelperFunctions} from "../../utils/HelperFunctions.class"; @Component({ selector: 'showIdentifiers', @@ -47,7 +48,7 @@ export class ShowIdentifiersComponent { public sizeOfPreviousIdentifiers: number = -1; public pageSize: number = 10; - constructor (private element: ElementRef) { + constructor () { this.doiURL = "https://dx.doi.org/"; this.pmcURL = "http://europepmc.org/articles/"; this.handleURL = "http://hdl.handle.net/"; @@ -84,9 +85,7 @@ export class ShowIdentifiersComponent { } public scroll() { - if (typeof document !== 'undefined') { - this.element.nativeElement.scrollIntoView(); - } + HelperFunctions.scroll(); } public getKeys( map) { return Array.from(map.keys()); diff --git a/landingPages/organization/organization.component.ts b/landingPages/organization/organization.component.ts index 9a6665af..d50dc553 100644 --- a/landingPages/organization/organization.component.ts +++ b/landingPages/organization/organization.component.ts @@ -27,6 +27,7 @@ import {PiwikService} from '../../utils/piwik/piwik.service'; import {StringUtils} from '../../utils/string-utils.class'; import {EnvProperties} from '../../utils/properties/env-properties'; import { SEOService } from '../../sharedComponents/SEO/SEO.service'; +import {HelperFunctions} from "../../utils/HelperFunctions.class"; @Component({ selector: 'organization', @@ -142,11 +143,9 @@ export class OrganizationComponent { this.warningMessage="No valid organization id"; } - if (typeof document !== 'undefined') { - this.element.nativeElement.scrollIntoView(); - } + HelperFunctions.scroll(); - this.csvParamsTail = '" and relorganizationid exact "'+this.organizationId+'" ))'; + this.csvParamsTail = '" and relorganizationid exact "'+this.organizationId+'" ))'; }); diff --git a/landingPages/orp/orp.component.ts b/landingPages/orp/orp.component.ts index 7404db96..51f77d8a 100644 --- a/landingPages/orp/orp.component.ts +++ b/landingPages/orp/orp.component.ts @@ -1,5 +1,5 @@ import {Component, ViewChild} from '@angular/core'; -import {ElementRef, Input} from '@angular/core'; +import {Input} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; import {Title, Meta} from '@angular/platform-browser'; @@ -12,6 +12,7 @@ import {RouterHelper} from '../../utils/routerHelper.class'; import {OrpService} from './orp.service'; import {PiwikService} from '../../utils/piwik/piwik.service'; import { SEOService } from '../../sharedComponents/SEO/SEO.service'; +import {HelperFunctions} from "../../utils/HelperFunctions.class"; @Component({ @@ -61,8 +62,7 @@ export class OrpComponent { sub: any; piwiksub: any; infoSub: any; properties:EnvProperties; - constructor (private element: ElementRef, - private _orpService: OrpService, + constructor (private _orpService: OrpService, private _piwikService:PiwikService, private route: ActivatedRoute, private _meta: Meta, @@ -189,9 +189,7 @@ export class OrpComponent { } public scroll() { - if (typeof document !== 'undefined') { - this.element.nativeElement.scrollIntoView(); - } + HelperFunctions.scroll(); } private handleError(message: string, error) { diff --git a/landingPages/project/project.component.ts b/landingPages/project/project.component.ts index a0f69f04..77e580f9 100644 --- a/landingPages/project/project.component.ts +++ b/landingPages/project/project.component.ts @@ -1,5 +1,5 @@ import {Component, ViewChild} from '@angular/core'; -import {ElementRef, Input} from '@angular/core'; +import {Input} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; import {Params} from '@angular/router'; import {Title, Meta} from '@angular/platform-browser'; @@ -27,6 +27,7 @@ import {ErrorCodes} from '../../utils/properties/errorCodes' import {PiwikService} from '../../utils/piwik/piwik.service'; import {EnvProperties} from '../../utils/properties/env-properties'; import { SEOService } from '../../sharedComponents/SEO/SEO.service'; +import {HelperFunctions} from "../../utils/HelperFunctions.class"; @Component({ selector: 'project', @@ -101,8 +102,7 @@ export class ProjectComponent{ sub: any; piwiksub: any; infoSub: any; downloadFilePiwikSub: any; properties:EnvProperties; - constructor ( private element: ElementRef, - private _projectService: ProjectService, + constructor ( private _projectService: ProjectService, private _piwikService:PiwikService, private route: ActivatedRoute, private _searchPublicationsService: SearchPublicationsService, @@ -161,9 +161,7 @@ properties:EnvProperties; this.csvParamsSoftware = "?format=csv-special&type=software&fq=(((oaftype exact result) and (resulttypeid exact software)) and (relprojectid exact \""+this.projectId+"\"))"; this.csvParamsOrps = "?format=csv-special&type=other&fq=(((oaftype exact result) and (resulttypeid exact other)) and (relprojectid exact \""+this.projectId+"\"))"; - if (typeof document !== 'undefined') { - this.element.nativeElement.scrollIntoView(); - } + HelperFunctions.scroll(); }); } diff --git a/landingPages/publication/publication.component.ts b/landingPages/publication/publication.component.ts index bcd631a4..ffca4f16 100644 --- a/landingPages/publication/publication.component.ts +++ b/landingPages/publication/publication.component.ts @@ -1,5 +1,5 @@ import {Component, ViewChild} from '@angular/core'; -import {ElementRef, Input} from '@angular/core'; +import {Input} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; import {Title, Meta} from '@angular/platform-browser'; @@ -12,6 +12,7 @@ import {RouterHelper} from '../../utils/routerHelper.class'; import {PiwikService} from '../../utils/piwik/piwik.service'; import {PublicationService} from './publication.service'; import { SEOService } from '../../sharedComponents/SEO/SEO.service'; +import {HelperFunctions} from "../../utils/HelperFunctions.class"; @Component({ @@ -72,8 +73,7 @@ export class PublicationComponent { sub: any; piwiksub: any; infoSub: any; properties:EnvProperties; - constructor ( private element: ElementRef, - private _publicationService: PublicationService, + constructor ( private _publicationService: PublicationService, private _piwikService:PiwikService, private route: ActivatedRoute, private _meta: Meta, @@ -293,9 +293,7 @@ export class PublicationComponent { } public scroll() { - if (typeof document !== 'undefined') { - this.element.nativeElement.scrollIntoView(); - } + HelperFunctions.scroll(); } /* start(i: number, bioentitiesPage: number) { diff --git a/landingPages/software/software.component.ts b/landingPages/software/software.component.ts index 4803e8d4..62a0682c 100644 --- a/landingPages/software/software.component.ts +++ b/landingPages/software/software.component.ts @@ -1,5 +1,5 @@ import {Component, ViewChild} from '@angular/core'; -import {ElementRef, Input} from '@angular/core'; +import {Input} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; import {Title, Meta} from '@angular/platform-browser'; @@ -12,6 +12,7 @@ import {RouterHelper} from '../../utils/routerHelper.class'; import {PiwikService} from '../../utils/piwik/piwik.service'; import {EnvProperties} from '../../utils/properties/env-properties'; import { SEOService } from '../../sharedComponents/SEO/SEO.service'; +import {HelperFunctions} from "../../utils/HelperFunctions.class"; @Component({ selector: 'software', @@ -56,8 +57,7 @@ export class SoftwareComponent { sub: any; piwiksub: any; infoSub: any; properties:EnvProperties; - constructor (private element: ElementRef, - private _softwareService: SoftwareService, + constructor (private _softwareService: SoftwareService, private _piwikService:PiwikService, private route: ActivatedRoute, private _meta: Meta, @@ -196,9 +196,7 @@ export class SoftwareComponent { } public scroll() { - if (typeof document !== 'undefined') { - this.element.nativeElement.scrollIntoView(); - } + HelperFunctions.scroll(); } private handleError(message: string, error) { diff --git a/reload/reload.component.ts b/reload/reload.component.ts index 69d04517..50c5f9e9 100644 --- a/reload/reload.component.ts +++ b/reload/reload.component.ts @@ -1,11 +1,7 @@ -import {Component, Input, Output, EventEmitter, ViewChild, ElementRef} from '@angular/core'; -import {Observable} from 'rxjs/Observable'; +import {Component} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; -import {Location} from '@angular/common'; - -import {ErrorCodes} from '../utils/properties/errorCodes'; -import {RouterHelper} from '../utils/routerHelper.class'; import {Session} from '../login/utils/helper.class'; +import {HelperFunctions} from "../utils/HelperFunctions.class"; @Component({ selector: 'reload', @@ -23,18 +19,11 @@ import {Session} from '../login/utils/helper.class'; }) export class ReloadComponent { - constructor (private element: ElementRef, - private route: ActivatedRoute, - private _router: Router, - private location: Location - ) { - - } + constructor (private route: ActivatedRoute, private _router: Router) {} public ngOnInit() { - if (typeof document !== 'undefined') { - this.element.nativeElement.scrollIntoView(); - } + HelperFunctions.scroll(); + var URL = Session.getReloadUrl(); if(URL && URL["path"] && URL["path"] != null && URL["path"] != ""){ diff --git a/searchPages/searchUtils/searchPage.component.ts b/searchPages/searchUtils/searchPage.component.ts index 46460406..378feeee 100644 --- a/searchPages/searchUtils/searchPage.component.ts +++ b/searchPages/searchUtils/searchPage.component.ts @@ -1,6 +1,6 @@ import {Component, Input} from '@angular/core'; import {ViewChild, Output} from '@angular/core'; -import {EventEmitter,ElementRef} from '@angular/core'; +import {EventEmitter} from '@angular/core'; import {Location} from '@angular/common'; import {Router, ActivatedRoute} from '@angular/router'; import {Title, Meta} from '@angular/platform-browser'; @@ -15,6 +15,7 @@ import {ErrorCodes} from '../../utils/properties/errorCodes'; import {PiwikService} from '../../utils/piwik/piwik.service'; import {EnvProperties} from '../../utils/properties/env-properties'; import { SEOService } from '../../sharedComponents/SEO/SEO.service'; +import {HelperFunctions} from "../../utils/HelperFunctions.class"; @Component({ selector: 'search-page', @@ -78,7 +79,6 @@ export class SearchPageComponent { private location: Location, private _meta: Meta, private _title: Title, - private element: ElementRef, private _piwikService:PiwikService, private router: Router, private seoService: SEOService) { @@ -99,9 +99,8 @@ export class SearchPageComponent { this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, this.piwikSiteId).subscribe(); } }); - if (typeof document !== 'undefined') { - this.element.nativeElement.scrollIntoView(); - } + HelperFunctions.scroll(); + // this.updateBaseUrlWithParameters(this.filters); this.updateTitle(this.pageTitle); var description = "Openaire, search, repositories, open access, type, content provider, funder, project, " + this.type + "," +this.pageTitle; @@ -550,9 +549,7 @@ export class SearchPageComponent { index:indexQuery, params: this.queryParameters }); - if (typeof document !== 'undefined') { - this.element.nativeElement.scrollIntoView(); - } + HelperFunctions.scroll(); } filterChanged($event){ this.goTo(1);