2023-07-04 10:53:08 +02:00
import { ChangeDetectorRef , Component , ElementRef , Input , ViewChild } from '@angular/core' ;
2019-07-22 11:16:50 +02:00
import { ActivatedRoute , Router } from '@angular/router' ;
import { Meta , Title } from '@angular/platform-browser' ;
import { EnvProperties } from '../../utils/properties/env-properties' ;
import { DataProviderInfo } from '../../utils/entities/dataProviderInfo' ;
import { DataProviderService } from './dataProvider.service' ;
2019-09-11 11:45:54 +02:00
import { FetchResearchResults } from '../../utils/fetchEntitiesClasses/fetchResearchResults.class' ;
import { SearchResearchResultsService } from '../../services/searchResearchResults.service' ;
2019-07-22 11:16:50 +02:00
import { FetchProjects } from '../../utils/fetchEntitiesClasses/fetchProjects.class' ;
import { SearchProjectsService } from '../../services/searchProjects.service' ;
import { FetchDataproviders } from '../../utils/fetchEntitiesClasses/fetchDataproviders.class' ;
import { SearchDataprovidersService } from '../../services/searchDataproviders.service' ;
import { ErrorCodes } from '../../utils/properties/errorCodes' ;
import { RouterHelper } from '../../utils/routerHelper.class' ;
import { PiwikService } from '../../utils/piwik/piwik.service' ;
import { SEOService } from '../../sharedComponents/SEO/SEO.service' ;
2019-04-24 14:31:01 +02:00
import { HelperFunctions } from "../../utils/HelperFunctions.class" ;
2019-07-22 11:16:50 +02:00
import { HelperService } from "../../utils/helper/helper.service" ;
2019-11-07 10:51:09 +01:00
import { Location } from "@angular/common" ;
2022-05-30 09:39:10 +02:00
import { Identifier , StringUtils } from "../../utils/string-utils.class" ;
2020-05-26 22:36:14 +02:00
import { SearchResult } from "../../utils/entities/searchResult" ;
import { ResultPreview } from "../../utils/result-preview/result-preview" ;
import { IndexInfoService } from "../../utils/indexInfo.service" ;
2020-07-13 16:42:34 +02:00
import { properties } from "../../../../environments/environment" ;
2023-02-13 14:51:15 +01:00
import { Subscriber , Subscription , zip } from "rxjs" ;
2022-05-03 13:22:53 +02:00
import { OpenaireEntities } from "../../utils/properties/searchFields" ;
2023-02-13 14:51:15 +01:00
import { MetricsService } from '../../services/metrics.service' ;
import { NumberUtils } from '../../utils/number-utils.class' ;
2023-03-01 15:49:42 +01:00
import { LayoutService } from '../../dashboard/sharedComponents/sidebar/layout.service' ;
import { FullScreenModalComponent } from '../../utils/modal/full-screen-modal/full-screen-modal.component' ;
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
2022-05-05 19:54:01 +02:00
declare var ResizeObserver ;
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
2017-12-19 13:53:46 +01:00
@Component ( {
2019-07-22 11:16:50 +02:00
selector : 'dataprovider' ,
templateUrl : 'dataProvider.component.html' ,
2022-04-08 17:26:27 +02:00
2019-07-22 11:16:50 +02:00
} )
2017-12-19 13:53:46 +01:00
export class DataProviderComponent {
2023-04-20 19:06:53 +02:00
public referrer : string ;
public prevPath : string ;
2022-05-13 14:57:31 +02:00
@Input ( ) type : string = "dataprovider" ;
private typeQueryPathParam : string = "datasources" ;
2019-07-22 11:16:50 +02:00
@Input ( ) communityId = null ;
2017-12-19 13:53:46 +01:00
public dataProviderInfo : DataProviderInfo ;
public datasourceId : string ;
2022-05-30 09:39:10 +02:00
public identifier : Identifier = null ;
2022-05-05 19:54:01 +02:00
public provenanceUrls : string [ ] = null ;
2021-09-08 14:21:30 +02:00
2022-05-13 14:57:31 +02:00
// Links for SEO
public linkToLandingPage : string = null ;
public linkToSearchPage : string = null ;
2022-05-30 09:39:10 +02:00
public canonicalUrl : string = null ;
2022-05-13 14:57:31 +02:00
2017-12-19 13:53:46 +01:00
// Message variables
public warningMessage = "" ;
public errorMessage = "" ;
public showLoading : boolean = true ;
2020-11-11 15:43:13 +01:00
2017-12-19 13:53:46 +01:00
// Metrics tab variables
public metricsClicked : boolean ;
public viewsFrameUrl : string ;
public downloadsFrameUrl : string ;
2023-05-19 13:37:23 +02:00
/** @deprecated*/
public totalViews : number = null ;
/** @deprecated*/
public totalDownloads : number = null ;
public hasViews : boolean = false ;
public hasDownloads : boolean = false ;
2023-02-13 14:51:15 +01:00
// public pageViews: number;
2021-09-08 14:21:30 +02:00
2017-12-19 13:53:46 +01:00
// Statistics tab variables
public statsClicked : boolean = false ;
2021-09-08 14:21:30 +02:00
2022-11-28 18:22:01 +01:00
// @ViewChild('statisticsModal') statisticsModal;
// @ViewChild('relatedDatasourcesModal') relatedDatasourcesModal;
2023-03-01 15:49:42 +01:00
@ViewChild ( 'addThisModal' ) addThisModal ;
@ViewChild ( 'addThisFsModal' ) addThisFsModal : FullScreenModalComponent ;
2021-09-08 14:21:30 +02:00
[Monitor Dashboard & Library | new-theme]: Renaming entity types using OpenaireEntities.
Files updated: develop.component.ts, methodology.component.ts, claimEntitiesSelection.component.ts, directLinking.component.ts, linkingGeneric.component.html, linkingGeneric.component.ts, approved.component.ts, searchDataprovidersToDeposit.component.ts, errorPage.component.ts, dataProvider.component.html, dataProvider.component.ts, dataProvider.service.ts, relatedDatasourcesTab.component.ts, project.component.ts, myOrcidLinks.component.ts, searchMyOrcidResults.component.html, searchMyOrcidResults.component.ts, searchAll.component.html, searchAll.component.ts, advancedSearchForm.component.html, advancedSearchForm.component.ts, searchDataProviders.component.ts, searchResearchResults.service.ts, numbers.component.ts, other-portals.component.html, other-portals.component.ts, fetchDataproviders.class.ts, fetchResearchResults.class.ts, searchFields.ts, result-preview.component.ts
2022-05-09 12:13:44 +02:00
// Variables for publications, research data, projects, datasources, related datasources tabs
2019-09-11 11:45:54 +02:00
public fetchPublications : FetchResearchResults ;
public fetchDatasets : FetchResearchResults ;
public fetchSoftware : FetchResearchResults ;
public fetchOrps : FetchResearchResults ;
2017-12-19 13:53:46 +01:00
public fetchProjects : FetchProjects ;
public fetchDataproviders : FetchDataproviders ;
2020-03-16 14:09:46 +01:00
public fetchAggregatorsResults : FetchResearchResults ;
2020-05-26 22:36:14 +02:00
public searchNumber : number = 5 ;
2021-09-08 14:21:30 +02:00
2020-05-26 22:36:14 +02:00
public aggregationStatusIsInitialized : boolean = false ;
2021-09-08 14:21:30 +02:00
2017-12-19 13:53:46 +01:00
public loadingRelatedDatasources : boolean = true ;
2021-09-08 14:21:30 +02:00
2017-12-19 13:53:46 +01:00
// Active tab variable for responsiveness - show tabs only if main request is completed
public activeTab : string = "" ;
2019-07-22 11:16:50 +02:00
public showTabs : boolean = false ;
2021-09-08 14:21:30 +02:00
2020-05-26 22:36:14 +02:00
public _numberOfTabs : number = 0 ;
public tabsAreInitialized : boolean = false ;
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
public routerHelper : RouterHelper = new RouterHelper ( ) ;
public errorCodes : ErrorCodes = new ErrorCodes ( ) ;
public pageContents = null ;
public divContents = null ;
2021-09-08 14:21:30 +02:00
2017-12-19 13:53:46 +01:00
// Request results of each tab only the one time (first time tab is clicked)
private reloadPublications : boolean = true ;
private reloadDatasets : boolean = true ;
2018-05-08 14:59:30 +02:00
private reloadSoftware : boolean = true ;
2018-07-26 18:38:59 +02:00
private reloadOrps : boolean = true ;
2017-12-19 13:53:46 +01:00
private reloadProjects : boolean = true ;
private reloadDataproviders : boolean = true ;
private reloadRelatedDatasources : boolean = true ;
2021-09-08 14:21:30 +02:00
2020-03-16 14:09:46 +01:00
// Organizations variables for view more/less functionality
2022-05-03 13:22:53 +02:00
public viewAllOrganizations : boolean = false ;
public lessBtnOrganizations : boolean = false ;
2020-03-17 11:04:17 +01:00
public thresholdOrganizations : number = 20 ;
2022-05-03 13:22:53 +02:00
@ViewChild ( 'organizationsModal' ) organizationsModal ;
2021-09-08 14:21:30 +02:00
2020-03-16 14:09:46 +01:00
// Subjects variables for view more/less functionality
2022-05-03 13:22:53 +02:00
public viewAllSubjects : boolean = false ;
public lessBtnSubjects : boolean = false ;
2020-03-16 14:09:46 +01:00
public thresholdSubjects : number = 20 ;
2022-05-03 13:22:53 +02:00
@ViewChild ( 'subjectsModal' ) subjectsModal ;
2021-09-08 14:21:30 +02:00
2020-03-16 14:09:46 +01:00
// Description variables for view more/less functionality
public thresholdDescription : number = 670 ;
public showNumDescription : number = 670 ;
2021-09-08 14:21:30 +02:00
2020-03-16 14:09:46 +01:00
public indexUpdateDate : Date ;
public showFeedback : boolean = false ;
2020-07-13 16:42:34 +02:00
public feedbackFields : string [ ] = [ 'Name' , 'Organizations' , 'Country' , 'Other' ] ;
2021-09-08 14:21:30 +02:00
2022-05-03 13:22:53 +02:00
public offset : number ;
public stickyHeader : boolean = false ;
public graph_offset : number = 0 ;
2022-05-05 19:54:01 +02:00
public graph_height : number = 0 ;
2022-05-03 13:22:53 +02:00
@ViewChild ( "graph_and_feedback" ) graph_and_feedback ;
2022-09-21 12:32:21 +02:00
@ViewChild ( "descriptionDiv" ) descriptionDiv : ElementRef ;
@ViewChild ( 'descriptionModal' ) descriptionModal ;
2022-05-06 15:31:40 +02:00
// public shouldSticky: boolean = true;
2022-05-04 17:09:35 +02:00
2020-11-11 15:43:13 +01:00
subscriptions = [ ] ;
2023-02-13 14:51:15 +01:00
private sub : Subscription ;
2020-07-13 16:42:34 +02:00
properties : EnvProperties = properties ;
2022-05-03 13:22:53 +02:00
public openaireEntities = OpenaireEntities ;
2023-03-01 15:49:42 +01:00
public isMobile : boolean = false ;
public mobileContent : "info" | "metrics" | "actions" = "info" ;
public tabMobile : string = "" ;
public viewAllMobile : string = "" ;
// Full screen modals for small screens (mobile)
@ViewChild ( 'summaryFsModal' ) summaryFsModal : FullScreenModalComponent ;
@ViewChild ( 'projectsFsModal' ) projectsFsModal : FullScreenModalComponent ;
@ViewChild ( 'dataprovidersFsModal' ) dataprovidersFsModal : FullScreenModalComponent ;
@ViewChild ( 'publicationsFsModal' ) publicationsFsModal : FullScreenModalComponent ;
@ViewChild ( 'datasetsFsModal' ) datasetsFsModal : FullScreenModalComponent ;
@ViewChild ( 'softwareFsModal' ) softwareFsModal : FullScreenModalComponent ;
@ViewChild ( 'otherFsModal' ) otherFsModal : FullScreenModalComponent ;
@ViewChild ( 'relatedDatasourcesFsModal' ) relatedDatasourcesFsModal : FullScreenModalComponent ;
@ViewChild ( 'statisticsFsModal' ) statisticsFsModal : FullScreenModalComponent ;
2019-07-22 11:16:50 +02:00
constructor ( private _dataproviderService : DataProviderService ,
private _piwikService : PiwikService ,
private route : ActivatedRoute ,
private _meta : Meta ,
private _title : Title ,
private _router : Router ,
2019-09-11 11:45:54 +02:00
private _searchResearchResultsService : SearchResearchResultsService ,
2019-07-22 11:16:50 +02:00
private _searchProjectsService : SearchProjectsService ,
private _searchDataprovidersService : SearchDataprovidersService ,
private seoService : SEOService ,
2019-11-07 10:51:09 +01:00
private helper : HelperService ,
2020-05-26 22:36:14 +02:00
private _location : Location ,
2022-05-05 19:54:01 +02:00
private indexInfoService : IndexInfoService ,
2023-02-13 14:51:15 +01:00
private metricsService : MetricsService ,
2023-03-01 15:49:42 +01:00
private cdr : ChangeDetectorRef ,
private layoutService : LayoutService ) {
2019-09-11 11:45:54 +02:00
this . fetchPublications = new FetchResearchResults ( this . _searchResearchResultsService ) ;
this . fetchDatasets = new FetchResearchResults ( this . _searchResearchResultsService ) ;
this . fetchSoftware = new FetchResearchResults ( this . _searchResearchResultsService ) ;
this . fetchOrps = new FetchResearchResults ( this . _searchResearchResultsService ) ;
2019-07-22 11:16:50 +02:00
this . fetchProjects = new FetchProjects ( this . _searchProjectsService ) ;
this . fetchDataproviders = new FetchDataproviders ( this . _searchDataprovidersService ) ;
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
ngOnInit() {
2023-03-01 15:49:42 +01:00
this . subscriptions . push ( this . layoutService . isMobile . subscribe ( isMobile = > {
this . isMobile = isMobile ;
} ) ) ;
2020-07-13 16:42:34 +02:00
if ( typeof document !== 'undefined' ) {
2020-11-11 15:43:13 +01:00
this . subscriptions . push ( this . indexInfoService . getLastIndexDate ( this . properties ) . subscribe ( lastIndexUpdate = > {
2020-07-13 16:42:34 +02:00
if ( lastIndexUpdate ) {
this . indexUpdateDate = new Date ( lastIndexUpdate ) ;
2020-06-10 13:05:59 +02:00
}
2020-11-11 15:43:13 +01:00
} ) ) ;
2020-07-13 16:42:34 +02:00
}
//this.getDivContents();
this . getPageContents ( ) ;
2020-09-18 09:57:42 +02:00
this . updateUrl ( this . properties . domain + this . properties . baseLink + this . _router . url ) ;
2021-12-17 14:39:32 +01:00
this . seoService . createLinkForCanonicalURL ( this . properties . domain + this . properties . baseLink + this . _router . url ) ;
2020-11-11 15:43:13 +01:00
this . subscriptions . push ( this . route . queryParams . subscribe ( data = > {
2022-05-04 12:57:13 +02:00
this . stickyHeader = false ;
2019-02-08 13:19:26 +01:00
this . updateDescription ( "" ) ;
2023-04-20 19:06:53 +02:00
2023-05-25 17:10:58 +02:00
if ( data [ "return_path" ] ) {
this . prevPath = data [ "return_path" ] + ( data [ "search_params" ] ? ( "?" + data [ "search_params" ] ) : "" ) ;
2023-04-20 19:06:53 +02:00
}
if ( ( typeof document !== 'undefined' ) && document . referrer ) {
this . referrer = document . referrer ;
}
2022-05-13 14:57:31 +02:00
// this.datasourceId = data['datasourceId'];
if ( data [ 'datasourceId' ] ) {
this . datasourceId = data [ 'datasourceId' ] ;
this . typeQueryPathParam = "datasources" ;
this . initMetaAndLinks ( "dataprovider" ) ;
} else if ( data [ 'serviceId' ] ) {
this . datasourceId = data [ 'serviceId' ] ;
this . typeQueryPathParam = "services" ;
this . initMetaAndLinks ( "service" ) ;
2022-05-30 09:39:10 +02:00
} else if ( data [ "pid" ] ) {
this . identifier = Identifier . getIdentifierFromString ( decodeURIComponent ( data [ "pid" ] ) , false ) ;
2022-06-01 14:48:57 +02:00
if ( this . type == "service" ) {
this . typeQueryPathParam = "services" ;
}
2022-05-30 09:39:10 +02:00
this . initMetaAndLinks ( this . type ) ;
2022-05-13 14:57:31 +02:00
}
2022-05-30 09:39:10 +02:00
if ( this . datasourceId && StringUtils . isOpenAIREID ( this . datasourceId ) || ( this . identifier ) ) {
2020-05-26 22:36:14 +02:00
this . initializeValues ( ) ;
2019-07-22 11:16:50 +02:00
this . getDataProviderInfo ( this . datasourceId ) ;
2019-10-31 12:39:23 +01:00
} else {
this . showLoading = false ;
2022-05-11 11:55:14 +02:00
this . _router . navigate ( [ this . properties . errorLink ] , {
2020-07-13 16:42:34 +02:00
queryParams : {
"page" : this . _location . path ( true ) ,
2022-05-13 14:57:31 +02:00
"page_type" : this . type
2020-07-13 16:42:34 +02:00
}
} ) ;
2017-12-19 13:53:46 +01:00
}
2020-11-11 15:43:13 +01:00
} ) ) ;
2019-07-22 11:16:50 +02:00
}
2021-09-08 14:21:30 +02:00
2022-05-03 13:22:53 +02:00
ngAfterViewInit() {
if ( typeof document !== 'undefined' ) {
2023-03-16 16:53:28 +01:00
if ( document . getElementById ( "main-menu" ) ) {
this . offset = Number . parseInt ( getComputedStyle ( document . documentElement ) . getPropertyValue ( '--header-height' ) ) ;
} else {
this . offset = 0 ;
}
2022-05-06 15:31:40 +02:00
// let bottom = document.getElementById('bottom');
// if(bottom) {
// let observer = new IntersectionObserver(entries => {
// entries.forEach(entry => {
// this.shouldSticky = !entry.isIntersecting;
// })
// });
// this.subscriptions.push(observer);
// observer.observe(bottom);
// }
2022-05-05 19:54:01 +02:00
if ( this . graph_and_feedback ) {
this . observeGraphAndFeedback ( ) ;
2022-05-04 17:09:35 +02:00
}
2022-05-03 13:22:53 +02:00
}
}
ngAfterContentChecked() {
2022-05-16 23:31:28 +02:00
if ( this . graph_and_feedback && typeof document !== 'undefined' ) {
2022-05-05 19:54:01 +02:00
this . graph_offset = this . calcGraphOffset ( this . graph_and_feedback . nativeElement ) ;
2022-05-03 13:22:53 +02:00
}
}
2022-05-05 19:54:01 +02:00
2022-09-21 12:32:21 +02:00
get showViewMoreButton ( ) : boolean {
return ! ! this . descriptionDiv && ( this . descriptionDiv . nativeElement . clientHeight >= 10 * 21 ) ;
}
2022-05-05 19:54:01 +02:00
public observeGraphAndFeedback() {
let resizeObs = new ResizeObserver ( entries = > {
entries . forEach ( entry = > {
setTimeout ( ( ) = > {
// console.log(entry);
this . graph_offset = this . calcGraphOffset ( entry . target ) ;
this . cdr . detectChanges ( ) ;
} ) ;
} )
} ) ;
this . subscriptions . push ( resizeObs ) ;
resizeObs . observe ( this . graph_and_feedback . nativeElement ) ;
}
calcGraphOffset ( element ) {
this . graph_height = element . offsetHeight ;
return window . innerHeight - this . graph_height ;
2022-05-03 13:22:53 +02:00
}
2022-05-13 14:57:31 +02:00
private initMetaAndLinks ( type : string ) {
if ( type == "service" ) {
this . type = "service" ;
this . updateTitle ( this . openaireEntities . SERVICE ) ;
this . linkToLandingPage = this . properties . searchLinkToService ;
this . linkToSearchPage = this . properties . searchLinkToServices ;
} else if ( type == "dataprovider" ) {
this . type = "dataprovider" ;
this . updateTitle ( this . openaireEntities . DATASOURCE ) ;
this . linkToLandingPage = this . properties . searchLinkToDataProvider ;
this . linkToSearchPage = this . properties . searchLinkToDataProviders ;
}
}
2020-05-26 22:36:14 +02:00
public initializeValues() {
this . _numberOfTabs = 0 ;
this . tabsAreInitialized = false ;
this . dataProviderInfo = null ;
2022-05-05 19:54:01 +02:00
this . provenanceUrls = null ;
2020-05-26 22:36:14 +02:00
this . aggregationStatusIsInitialized = false ;
this . fetchProjects . searchUtils . status = this . errorCodes . LOADING ;
this . fetchProjects . searchUtils . totalResults = 0 ;
this . fetchDataproviders . searchUtils . status = this . errorCodes . LOADING ;
this . fetchDataproviders . searchUtils . totalResults = 0 ;
this . fetchPublications . searchUtils . status = this . errorCodes . LOADING ;
this . fetchPublications . searchUtils . totalResults = 0 ;
this . fetchDatasets . searchUtils . status = this . errorCodes . LOADING ;
this . fetchDatasets . searchUtils . totalResults = 0 ;
this . fetchSoftware . searchUtils . status = this . errorCodes . LOADING ;
this . fetchSoftware . searchUtils . totalResults = 0 ;
this . fetchOrps . searchUtils . status = this . errorCodes . LOADING ;
this . fetchOrps . searchUtils . totalResults = 0 ;
this . statsClicked = false ;
this . metricsClicked = false ;
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
private getPageContents() {
2020-11-11 15:43:13 +01:00
this . subscriptions . push ( this . helper . getPageHelpContents ( this . properties , this . communityId , this . _router . url ) . subscribe ( contents = > {
2019-07-22 11:16:50 +02:00
this . pageContents = contents ;
2020-11-11 15:43:13 +01:00
} ) ) ;
2019-07-22 11:16:50 +02:00
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
private getDivContents() {
2020-11-11 15:43:13 +01:00
this . subscriptions . push ( this . helper . getDivHelpContents ( this . properties , this . communityId , this . _router . url ) . subscribe ( contents = > {
2019-07-22 11:16:50 +02:00
this . divContents = contents ;
2020-11-11 15:43:13 +01:00
} ) ) ;
2019-07-22 11:16:50 +02:00
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
ngOnDestroy() {
2020-11-11 15:43:13 +01:00
this . subscriptions . forEach ( subscription = > {
if ( subscription instanceof Subscriber ) {
subscription . unsubscribe ( ) ;
2023-07-04 10:53:08 +02:00
} else if ( ( typeof ResizeObserver != 'undefined' && subscription instanceof ResizeObserver ) ||
( typeof IntersectionObserver != 'undefined' && subscription instanceof IntersectionObserver ) ) {
2022-05-05 19:54:01 +02:00
subscription . disconnect ( ) ;
2020-11-11 15:43:13 +01:00
}
} ) ;
this . fetchDatasets . clearSubscriptions ( ) ;
this . fetchPublications . clearSubscriptions ( ) ;
this . fetchSoftware . clearSubscriptions ( ) ;
this . fetchPublications . clearSubscriptions ( ) ;
this . fetchDataproviders . clearSubscriptions ( ) ;
this . fetchProjects . clearSubscriptions ( ) ;
2019-07-22 11:16:50 +02:00
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
private getDataProviderInfo ( id : string ) {
2017-12-19 13:53:46 +01:00
this . warningMessage = '' ;
2020-03-16 14:09:46 +01:00
this . errorMessage = "" ;
2017-12-19 13:53:46 +01:00
this . showLoading = true ;
2021-09-08 14:21:30 +02:00
2018-06-28 16:52:45 +02:00
this . dataProviderInfo = null ;
2022-05-05 19:54:01 +02:00
this . provenanceUrls = null ;
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
this . showTabs = false ;
2022-05-30 09:39:10 +02:00
if ( ( this . datasourceId == null || this . datasourceId == '' ) && this . identifier == null ) {
2017-12-19 13:53:46 +01:00
this . showLoading = false ;
2022-05-13 14:57:31 +02:00
this . warningMessage = "No valid " + this . getTypeName ( ) + " id" ;
2019-07-22 11:16:50 +02:00
} else {
2022-05-30 09:39:10 +02:00
this . subscriptions . push ( this . _dataproviderService . getDataproviderInfo ( this . datasourceId , this . identifier , this . properties , this . typeQueryPathParam ) . subscribe (
2017-12-19 13:53:46 +01:00
data = > {
2019-07-22 11:16:50 +02:00
this . dataProviderInfo = data ;
2022-05-05 19:54:01 +02:00
this . getProvenanceUrls ( ) ;
2022-05-30 09:39:10 +02:00
this . datasourceId = this . dataProviderInfo . objIdentifier ;
let pid :Identifier = Identifier . getPIDFromIdentifiers ( this . dataProviderInfo . identifiers ) ;
this . canonicalUrl = this . properties . domain + properties . baseLink + ( pid ? ( this . linkToLandingPage . split ( "?" ) [ 0 ] + "?pid=" + encodeURIComponent ( pid . id ) ) :
( this . linkToLandingPage + this . dataProviderInfo . relcanId ) ) ;
this . seoService . createLinkForCanonicalURL ( this . canonicalUrl ) ;
this . updateUrl ( this . canonicalUrl ) ;
2020-09-18 09:57:42 +02:00
this . seoService . createLinkForCanonicalURL ( this . properties . domain + this . properties . baseLink + this . _router . url ) ;
2019-07-22 11:16:50 +02:00
if ( typeof document !== 'undefined' ) {
2023-11-10 18:44:15 +01:00
// this.getDataProviderAggregationStatus(this.dataProviderInfo.originalId);
this . getCollectedFulltexts ( ) ;
2021-07-14 13:19:57 +02:00
this . countResultsWithFundingInfo ( ) ;
2020-05-26 22:36:14 +02:00
} else {
this . aggregationStatusIsInitialized = true ;
2019-07-22 11:16:50 +02:00
}
2020-06-10 13:05:59 +02:00
if ( typeof document !== 'undefined' ) {
this . initTabs ( ) ;
}
2019-07-22 11:16:50 +02:00
this . showTabs = true ;
2020-11-12 10:51:34 +01:00
this . updateTitle ( this . dataProviderInfo.title.name?this.dataProviderInfo.title.name :this.dataProviderInfo.officialName ) ;
2022-09-21 12:32:21 +02:00
this . updateDescription ( ( this . dataProviderInfo . description ? ( this . dataProviderInfo . description . substr ( 0 , 157 ) + ( this . dataProviderInfo . description . substr ( 0 , 157 ) . length == 157 ? "..." : "" ) ) : ( this . dataProviderInfo.title.name?this.dataProviderInfo.title.name :this.dataProviderInfo.officialName ) ) ) ;
2023-07-12 14:05:25 +02:00
this . subscriptions . push ( this . _piwikService . trackView ( this . properties , this . dataProviderInfo . title . name ) . subscribe ( ) ) ;
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
this . showLoading = false ;
2023-05-15 12:09:45 +02:00
2023-05-19 13:37:23 +02:00
this . hasViews = false ;
this . hasDownloads = false ;
2023-05-15 12:09:45 +02:00
// ensure that if the API call to index does not have metrics, we get them from old metrics service call
if ( this . dataProviderInfo && ! this . dataProviderInfo . measure ) {
this . getMetrics ( ) ;
2023-05-19 13:37:23 +02:00
} else if ( this . dataProviderInfo && this . dataProviderInfo . measure && this . dataProviderInfo . measure . counts ) {
this . dataProviderInfo . measure . counts . forEach ( measure = > {
if ( measure . name == "views" && measure . value > 0 ) {
this . hasViews = true ;
}
if ( measure . name == "downloads" && measure . value > 0 ) {
this . hasDownloads = true ;
}
} ) ;
2023-05-15 12:09:45 +02:00
}
2022-09-21 14:39:57 +02:00
this . cdr . detectChanges ( ) ;
2021-09-08 14:21:30 +02:00
2020-05-26 22:36:14 +02:00
// if (this.dataProviderInfo.tabs != undefined && this.dataProviderInfo.tabs.length > 0) {
// this.activeTab = this.dataProviderInfo.tabs[0].name;
// }
2017-12-19 13:53:46 +01:00
} ,
err = > {
2019-02-15 13:50:24 +01:00
//console.log(err);
2023-10-30 09:53:19 +01:00
this . handleError ( "Error getting " + this . type + " for " + ( this . datasourceId ? ( "id: " + this . datasourceId ) : ( "pid: " + this . identifier . id ) ) , err ) ;
2020-07-13 16:42:34 +02:00
if ( err . status == 404 ) {
2022-05-11 11:55:14 +02:00
this . _router . navigate ( [ this . properties . errorLink ] , {
2020-07-13 16:42:34 +02:00
queryParams : {
"page" : this . _location . path ( true ) ,
2022-05-13 14:57:31 +02:00
"page_type" : this . type
2020-07-13 16:42:34 +02:00
}
} ) ;
2021-12-17 14:39:32 +01:00
} else if ( err . name == "TimeoutError" ) {
this . errorMessage = 'An error occurred please try again later' ;
} else {
2022-05-13 14:57:31 +02:00
this . errorMessage = 'No ' + this . getTypeName ( ) + ' found' ;
this . seoService . createLinkForCanonicalURL ( this . properties . domain + this . properties . baseLink + this . linkToSearchPage ) ;
2019-10-31 12:39:23 +01:00
}
2017-12-19 13:53:46 +01:00
this . showLoading = false ;
}
2020-11-11 15:43:13 +01:00
) ) ;
2017-12-19 13:53:46 +01:00
}
2019-07-22 11:16:50 +02:00
}
2021-09-08 14:21:30 +02:00
2023-11-10 18:44:15 +01:00
// private getDataProviderAggregationStatus(originalId: string) {
// this.subscriptions.push(this._dataproviderService.getDataproviderAggregationStatus(originalId, this.properties).subscribe(
// data => {
// this.dataProviderInfo.aggregationStatus = data;
2023-07-04 18:10:15 +02:00
// this.aggregationStatusIsInitialized = true;
// },
// err => {
// //console.log(err);
// this.aggregationStatusIsInitialized = true;
2023-11-10 18:44:15 +01:00
// this.handleError("Error getting "+this.getTypeName()+" aggregation status for id: " + this.datasourceId, err);
2023-07-04 18:10:15 +02:00
// }
// ));
// }
2023-11-10 18:44:15 +01:00
private getCollectedFulltexts() {
this . subscriptions . push ( this . _dataproviderService . getCollectedFulltexts ( this . datasourceId ) . subscribe (
( data : string ) = > {
this . dataProviderInfo . aggregationStatus = { "fulltexts" : data } ;
this . aggregationStatusIsInitialized = true ;
} ,
err = > {
//console.log(err);
this . aggregationStatusIsInitialized = true ;
this . handleError ( "Error getting " + this . getTypeName ( ) + " collected fulltexts for id: " + this . datasourceId , err ) ;
}
) ) ;
}
2021-07-14 13:19:57 +02:00
private countResultsWithFundingInfo() {
this . subscriptions . push ( this . _searchResearchResultsService . countCollectedResultsWithFundingInfo ( this . datasourceId ) . subscribe (
fundedContent = > {
this . dataProviderInfo . fundedContent = fundedContent ;
2022-02-16 10:40:05 +01:00
// console.log(this.dataProviderInfo.fundedContent);
2021-07-14 13:19:57 +02:00
} ,
err = > {
this . handleError ( "Error getting results with funding information for datasource id: " + this . datasourceId , err ) ;
}
) )
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
private updateDescription ( description : string ) {
2022-05-03 13:22:53 +02:00
// this._meta.updateTag({content: description.substring(0, 160)}, "name='description'");
// this._meta.updateTag({content: description.substring(0, 160)}, "property='og:description'");
this . _meta . updateTag ( { content : description } , "name='description'" ) ;
this . _meta . updateTag ( { content : description } , "property='og:description'" ) ;
2019-07-22 11:16:50 +02:00
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
private updateTitle ( title : string ) {
2019-08-02 16:55:32 +02:00
var _prefix = "" ;
2019-12-05 17:07:07 +01:00
// if(this.communityId) {
// _prefix = "OpenAIRE | ";
// }
// var _title = _prefix + ((title.length > 50) ? title.substring(0, 50) : title);
this . _title . setTitle ( title ) ;
this . _meta . updateTag ( { content : title } , "property='og:title'" ) ;
2019-07-22 11:16:50 +02:00
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
private updateUrl ( url : string ) {
this . _meta . updateTag ( { content : url } , "property='og:url'" ) ;
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
private initTabs() {
2021-09-08 14:21:30 +02:00
2020-03-17 11:04:17 +01:00
//if (this.dataProviderInfo.tabs != undefined && this.dataProviderInfo.tabs.length > 0) {
2020-07-13 16:42:34 +02:00
this . reloadPublications = true ;
this . reloadDatasets = true ;
this . reloadSoftware = true ;
this . reloadOrps = true ;
this . reloadProjects = true ;
this . reloadDataproviders = true ;
this . reloadRelatedDatasources = true ;
this . statsClicked = false ;
2021-09-08 14:21:30 +02:00
2020-07-13 16:42:34 +02:00
//this.search(this.dataProviderInfo.tabs[0].content, 1, 10);
this . count ( 1 , 0 ) ;
2021-09-08 14:21:30 +02:00
2020-07-13 16:42:34 +02:00
this . metricsClicked = false ;
2021-08-10 12:46:33 +02:00
//old
2021-09-08 14:21:30 +02:00
// this.viewsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"dtsrcRepoViews","dtsrcName":"' + this.datasourceId + '","table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["column"]&stacking=&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(124, 181, 236, 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":"dtsrcRepoDownloads","dtsrcName":"' + this.datasourceId + '","table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["column"]&stacking=&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(124, 181, 236, 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';
2021-08-10 12:46:33 +02:00
//new
2021-09-08 14:21:30 +02:00
this . viewsFrameUrl = this . properties . statisticsFrameNewAPIURL + 'chart?json=' + encodeURIComponent ( '{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly views","type":"column","query":{"name":"usagestats.views.monthly", "parameters":["' + this . datasourceId + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Monthly views"},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":""}}}' ) ;
this . downloadsFrameUrl = this . properties . statisticsFrameNewAPIURL + 'chart?json=' +
encodeURIComponent ( '{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly downloads","type":"column","query":{"name":"usagestats.downloads.monthly", "parameters":["' + this . datasourceId + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Monthly downloads"},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":""}}}' ) ;
2020-07-13 16:42:34 +02:00
this . fetchAggregatorsResults = new FetchResearchResults ( this . _searchResearchResultsService ) ;
2020-11-11 15:43:13 +01:00
2019-07-22 11:16:50 +02:00
}
2021-09-08 14:21:30 +02:00
2020-03-16 14:09:46 +01:00
public getParamsForSearchLink ( type : string = "" ) {
2020-11-11 15:43:13 +01:00
2020-07-13 16:42:34 +02:00
if ( type ) {
2020-05-28 12:53:29 +02:00
return this . routerHelper . createQueryParams ( [ 'f0' , 'fv0' , 'f1' , 'fv1' , 'type' , 'qf' , 'sortBy' ] , [ "collectedfromdatasourceid" , this . datasourceId , "resulthostingdatasourceid,or" , this . datasourceId , type , "false" , 'resultdateofacceptance,descending' ] ) ;
2020-03-16 14:09:46 +01:00
} else {
return this . routerHelper . createQueryParams ( [ 'f0' , 'fv0' , 'f1' , 'fv1' ] , [ "collectedfromdatasourceid" , this . datasourceId , "resulthostingdatasourceid,or" , this . datasourceId ] ) ;
}
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
private count ( page : number , size : number ) {
2020-11-11 15:43:13 +01:00
2020-07-13 16:42:34 +02:00
this . countPublications ( page , size ) ;
this . countDatasets ( page , size ) ;
this . countSoftware ( page , size ) ;
this . countOrps ( page , size ) ;
this . countProjects ( page , size ) ;
this . countDatasources ( page , size ) ;
2020-11-11 15:43:13 +01:00
2019-07-22 11:16:50 +02:00
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
public search ( content : string , page : number , size : number ) {
if ( content == 'publicationsTab' ) {
this . searchPublications ( page , size ) ;
} else if ( content == 'datasetsTab' ) {
this . searchDatasets ( page , size ) ;
} else if ( content == 'softwareTab' ) {
this . searchSoftware ( page , size ) ;
} else if ( content == 'orpsTab' ) {
this . searchOrps ( page , size ) ;
} else if ( content == 'projectsTab' ) {
this . searchProjects ( page , size ) ;
} else if ( content == 'datasourcesTab' ) {
this . searchDatasources ( page , size ) ;
} else if ( content == 'relatedDatasourcesTab' ) {
this . searchRelatedDatasources ( 1 , 0 ) ;
} else if ( content == 'metricsTab' ) {
this . metricsClicked = true ;
} else if ( content == 'statisticsTab' ) {
this . statsClicked = ! this . statsClicked ;
2017-12-19 13:53:46 +01:00
}
2019-07-22 11:16:50 +02:00
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
private searchPublications ( page : number , size : number ) {
if ( this . reloadPublications &&
( this . fetchPublications . searchUtils . status == this . errorCodes . LOADING ||
2020-05-31 15:09:26 +02:00
( this . fetchPublications . searchUtils . status == this . errorCodes . DONE && this . fetchPublications . searchUtils . totalResults > 0 )
)
) {
2019-09-11 11:45:54 +02:00
this . fetchPublications . getResultsForDataproviders ( "publication" , this . datasourceId , this . dataProviderInfo . resultsBy , page , size , this . properties ) ;
2017-12-19 13:53:46 +01:00
}
2019-07-22 11:16:50 +02:00
this . reloadPublications = false ;
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
private countPublications ( page : number , size : number ) {
2019-09-11 11:45:54 +02:00
this . fetchPublications . getResultsForDataproviders ( "publication" , this . datasourceId , this . dataProviderInfo . resultsBy , page , size , this . properties ) ;
2019-07-22 11:16:50 +02:00
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
private searchDatasets ( page : number , size : number ) {
if ( this . reloadDatasets &&
( this . fetchDatasets . searchUtils . status == this . errorCodes . LOADING ||
2020-05-31 15:09:26 +02:00
( this . fetchDatasets . searchUtils . status == this . errorCodes . DONE && this . fetchDatasets . searchUtils . totalResults > 0 )
)
) {
2019-09-11 11:45:54 +02:00
this . fetchDatasets . getResultsForDataproviders ( "dataset" , this . datasourceId , this . dataProviderInfo . resultsBy , page , size , this . properties ) ;
2017-12-19 13:53:46 +01:00
}
2019-07-22 11:16:50 +02:00
this . reloadDatasets = false ;
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
private countDatasets ( page : number , size : number ) {
2019-09-11 11:45:54 +02:00
this . fetchDatasets . getResultsForDataproviders ( "dataset" , this . datasourceId , this . dataProviderInfo . resultsBy , page , size , this . properties ) ;
2019-07-22 11:16:50 +02:00
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
private searchSoftware ( page : number , size : number ) {
if ( this . reloadSoftware &&
( this . fetchSoftware . searchUtils . status == this . errorCodes . LOADING ||
2020-05-31 15:09:26 +02:00
( this . fetchSoftware . searchUtils . status == this . errorCodes . DONE && this . fetchSoftware . searchUtils . totalResults > 0 )
)
) {
2019-09-11 11:45:54 +02:00
this . fetchSoftware . getResultsForDataproviders ( "software" , this . datasourceId , this . dataProviderInfo . resultsBy , page , size , this . properties ) ;
2018-05-08 14:59:30 +02:00
}
2019-07-22 11:16:50 +02:00
this . reloadSoftware = false ;
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
private countSoftware ( page : number , size : number ) {
2019-09-11 11:45:54 +02:00
this . fetchSoftware . getResultsForDataproviders ( "software" , this . datasourceId , this . dataProviderInfo . resultsBy , page , size , this . properties ) ;
2019-07-22 11:16:50 +02:00
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
private searchOrps ( page : number , size : number ) {
if ( this . reloadOrps &&
( this . fetchOrps . searchUtils . status == this . errorCodes . LOADING ||
2020-05-31 15:09:26 +02:00
( this . fetchOrps . searchUtils . status == this . errorCodes . DONE && this . fetchOrps . searchUtils . totalResults > 0 )
)
) {
2019-09-11 11:45:54 +02:00
this . fetchOrps . getResultsForDataproviders ( "other" , this . datasourceId , this . dataProviderInfo . resultsBy , page , size , this . properties ) ;
2018-07-26 18:38:59 +02:00
}
2019-07-22 11:16:50 +02:00
this . reloadOrps = false ;
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
private countOrps ( page : number , size : number ) {
2019-09-11 11:45:54 +02:00
this . fetchOrps . getResultsForDataproviders ( "other" , this . datasourceId , this . dataProviderInfo . resultsBy , page , size , this . properties ) ;
2019-07-22 11:16:50 +02:00
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
private searchProjects ( page : number , size : number ) {
if ( this . reloadProjects &&
( this . fetchProjects . searchUtils . status == this . errorCodes . LOADING ||
2020-05-31 15:09:26 +02:00
( this . fetchProjects . searchUtils . status == this . errorCodes . DONE && this . fetchProjects . searchUtils . totalResults > 0 )
)
) {
2018-02-05 14:14:59 +01:00
this . fetchProjects . getResultsForDataproviders ( this . datasourceId , page , size , this . properties ) ;
2017-12-19 13:53:46 +01:00
}
2019-07-22 11:16:50 +02:00
this . reloadProjects = false ;
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
private countProjects ( page : number , size : number ) {
this . fetchProjects . getResultsForDataproviders ( this . datasourceId , page , size , this . properties ) ;
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
private searchDatasources ( page : number , size : number ) {
if ( this . reloadDataproviders &&
( this . fetchDataproviders . searchUtils . status == this . errorCodes . LOADING ||
2020-05-31 15:09:26 +02:00
( this . fetchDataproviders . searchUtils . status == this . errorCodes . DONE && this . fetchDataproviders . searchUtils . totalResults > 0 )
)
) {
2018-02-05 14:14:59 +01:00
this . fetchDataproviders . getResultsForDataproviders ( this . datasourceId , page , size , this . properties ) ;
2017-12-19 13:53:46 +01:00
}
2019-07-22 11:16:50 +02:00
this . reloadDataproviders = false ;
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
private countDatasources ( page : number , size : number ) {
this . fetchDataproviders . getResultsForDataproviders ( this . datasourceId , page , size , this . properties ) ;
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
private searchRelatedDatasources ( page : number , size : number ) {
// Currently no counting is done for this tab. Following condition is always false
2021-09-08 14:21:30 +02:00
2020-03-16 14:09:46 +01:00
// if (this.reloadRelatedDatasources &&
// (this.fetchAggregatorsPublications.searchUtils.status == this.errorCodes.LOADING ||
// this.fetchAggregatorsPublications.searchUtils.status == this.errorCodes.DONE)
// &&
// (this.fetchAggregatorsDatasets.searchUtils.status == this.errorCodes.LOADING ||
// this.fetchAggregatorsDatasets.searchUtils.status == this.errorCodes.DONE)
// &&
// (this.fetchAggregatorsSoftware.searchUtils.status == this.errorCodes.LOADING ||
// this.fetchAggregatorsSoftware.searchUtils.status == this.errorCodes.DONE)
// &&
// (this.fetchAggregatorsOrps.searchUtils.status == this.errorCodes.LOADING ||
// this.fetchAggregatorsOrps.searchUtils.status == this.errorCodes.DONE)
// ) {
// this.relatedDatasourcesSub = observableMerge(this.fetchAggregatorsPublications.requestComplete, this.fetchAggregatorsDatasets.requestComplete, this.fetchAggregatorsSoftware.requestComplete, this.fetchAggregatorsOrps.requestComplete)
// .subscribe(
// data => {
// },
// err => {
// },
// () => {
// this.preprocessRelatedDatasources();
// }
// );
//
// this.fetchAggregatorsPublications.getAggregatorResults("publication", this.datasourceId, page, size, this.properties);
// this.fetchAggregatorsDatasets.getAggregatorResults("dataset", this.datasourceId, page, size, this.properties);
// this.fetchAggregatorsSoftware.getAggregatorResults("software", this.datasourceId, page, size, this.properties);
// this.fetchAggregatorsOrps.getAggregatorResults("other", this.datasourceId, page, size, this.properties);
2019-07-22 11:16:50 +02:00
if ( this . reloadRelatedDatasources &&
2020-03-16 14:09:46 +01:00
( this . fetchAggregatorsResults . searchUtils . status == this . errorCodes . LOADING ||
2020-05-31 15:09:26 +02:00
( this . fetchAggregatorsResults . searchUtils . status == this . errorCodes . DONE && this . fetchAggregatorsResults . searchUtils . totalResults > 0 )
)
2020-03-16 14:09:46 +01:00
) {
2020-11-11 15:43:13 +01:00
this . subscriptions . push ( this . fetchAggregatorsResults . requestComplete . subscribe (
2020-07-13 16:42:34 +02:00
data = > {
} ,
err = > {
} ,
2020-03-16 14:09:46 +01:00
( ) = > {
2020-07-13 16:42:34 +02:00
//this.preprocessRelatedDatasources();
2020-03-16 14:09:46 +01:00
this . dataProviderInfo . relatedDatasources = this . fetchAggregatorsResults . results ;
this . loadingRelatedDatasources = false ;
}
2020-11-11 15:43:13 +01:00
) ) ;
2021-09-08 14:21:30 +02:00
2020-03-16 14:09:46 +01:00
this . fetchAggregatorsResults . getAggregatorResults ( "results" , this . datasourceId , page , size , this . properties ) ;
2019-07-22 11:16:50 +02:00
} else {
this . loadingRelatedDatasources = false ;
2017-12-19 13:53:46 +01:00
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
this . reloadRelatedDatasources = false ;
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
private countRelatedDatasources ( page : number , size : number ) {
2020-03-16 14:09:46 +01:00
this . fetchAggregatorsResults . getAggregatorResults ( "results" , this . datasourceId , page , size , this . properties ) ;
2019-07-22 11:16:50 +02:00
}
2020-11-11 15:43:13 +01:00
2019-07-22 11:16:50 +02:00
public metricsResults ( $event ) {
this . totalViews = $event . totalViews ;
this . totalDownloads = $event . totalDownloads ;
2023-02-13 14:51:15 +01:00
// this.pageViews = $event.pageViews;
}
private getMetrics() {
let obs ;
obs = zip ( this . metricsService . getMetricsNumber ( this . datasourceId , "usagestats.views.repository.local" , this . properties ) ,
this . metricsService . getMetricsNumber ( this . datasourceId , "usagestats.downloads.repository.local" , this . properties ) ) ;
this . sub = obs . subscribe ( data = > {
2023-05-19 13:37:23 +02:00
if ( ( data [ 0 ] && data [ 0 ] > 0 ) || ( data [ 1 ] && data [ 1 ] > 0 ) ) {
2023-05-15 12:09:45 +02:00
this . dataProviderInfo . measure = { counts : [ ] } ;
2023-05-19 13:37:23 +02:00
if ( data [ 0 ] && data [ 0 ] > 0 ) {
this . dataProviderInfo . measure . counts . push ( { name : 'views' , order : 0 , icon : 'visibility' , value : data [ 0 ] } ) ;
this . hasViews = true ;
}
if ( data [ 1 ] && data [ 1 ] > 0 ) {
this . dataProviderInfo . measure . counts . push ( { name : 'downloads' , order : 1 , icon : 'downloads' , value : data [ 1 ] } ) ;
this . hasDownloads = true ;
}
2023-05-15 12:09:45 +02:00
this . cdr . detectChanges ( ) ;
}
2023-02-13 14:51:15 +01:00
} ) ;
}
2021-09-08 14:21:30 +02:00
2020-05-05 12:37:36 +02:00
public get hasMetrics ( ) : boolean {
2023-02-22 01:23:10 +01:00
// return !(this.totalViews != null && this.totalDownloads != null) || this.totalViews > 0 || this.totalDownloads > 0;
2023-05-02 11:00:40 +02:00
// return (this.totalViews != null && this.totalViews > 0) || (this.totalDownloads != null && this.totalDownloads > 0);
2023-05-04 14:15:47 +02:00
return this . dataProviderInfo . measure ? . counts ? . length > 0 ;
2020-05-05 12:37:36 +02:00
}
2021-09-08 14:21:30 +02:00
2022-11-28 18:22:01 +01:00
// public openStatistics() {
// this.statsClicked = true;
// this.statisticsModal.cancelButton = false;
// this.statisticsModal.okButton = false;
// this.statisticsModal.alertTitle = "Statistics of";
// this.statisticsModal.open();
// }
//
// public openRelatedDatasources() {
// this.searchRelatedDatasources(1, 0);
// this.relatedDatasourcesModal.cancelButton = false;
// this.relatedDatasourcesModal.okButton = false;
// this.relatedDatasourcesModal.alertTitle = "Related "+this.openaireEntities.DATASOURCES+" of";
// this.relatedDatasourcesModal.open();
// }
2021-09-08 14:21:30 +02:00
2022-05-03 13:22:53 +02:00
public openAddThisModal() {
this . addThisModal . cancelButton = false ;
this . addThisModal . okButton = false ;
2022-07-12 12:20:28 +02:00
this . addThisModal . alertTitle = "Share this " + OpenaireEntities . DATASOURCE + " in your social networks" ;
2022-05-03 13:22:53 +02:00
this . addThisModal . open ( ) ;
}
public viewAllOrganizationsClick() {
this . viewAllOrganizations = true ;
if ( this . dataProviderInfo . organizations . length <= this . thresholdOrganizations * 2 ) {
this . lessBtnOrganizations = true ;
} else {
2023-03-01 15:49:42 +01:00
if ( this . isMobile ) {
this . summaryFsModal . title += " - Organizations" ;
this . summaryFsModal . back = true ;
this . viewAllMobile = "organizations" ;
} else {
this . openOrganizationsModal ( ) ;
}
2022-05-03 13:22:53 +02:00
}
}
public openOrganizationsModal() {
this . organizationsModal . cancelButton = false ;
this . organizationsModal . okButton = false ;
2022-05-04 12:57:13 +02:00
this . organizationsModal . alertTitle = this . openaireEntities . ORGANIZATIONS ;
2022-05-03 13:22:53 +02:00
this . organizationsModal . open ( ) ;
}
public viewAllSubjectsClick() {
this . viewAllSubjects = true ;
if ( this . dataProviderInfo . subjects . length <= this . thresholdSubjects * 2 ) {
this . lessBtnSubjects = true ;
} else {
2023-03-01 15:49:42 +01:00
if ( this . isMobile ) {
this . summaryFsModal . title += " - Subjects" ;
this . summaryFsModal . back = true ;
this . viewAllMobile = "subjects" ;
} else {
this . openSubjectsModal ( ) ;
}
2022-05-03 13:22:53 +02:00
}
}
public openSubjectsModal() {
this . subjectsModal . cancelButton = false ;
this . subjectsModal . okButton = false ;
this . subjectsModal . alertTitle = "Subjects" ;
this . subjectsModal . open ( ) ;
}
2020-05-29 16:15:35 +02:00
public scroll() {
HelperFunctions . scroll ( ) ;
}
2021-09-08 14:21:30 +02:00
2020-03-16 14:09:46 +01:00
public removeUnknown ( array : string [ ] ) : string [ ] {
return array . filter ( value = > value . toLowerCase ( ) !== 'unknown' ) ;
}
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
private handleError ( message : string , error ) {
2022-06-03 12:01:55 +02:00
console . error ( this . getTypeName ( ) + " Landing Page: " + message , error ) ;
2019-07-22 11:16:50 +02:00
}
2021-09-08 14:21:30 +02:00
2020-05-26 22:36:14 +02:00
public getResultPreview ( result : SearchResult , type : string ) : ResultPreview {
return ResultPreview . searchResultConvert ( result , type ) ;
}
2021-09-08 14:21:30 +02:00
2020-05-26 22:36:14 +02:00
public onSelectActiveTab ( activeTabId ) {
2022-04-06 16:01:25 +02:00
if ( this . activeTab != activeTabId ) { // tab really changed
2020-05-26 22:36:14 +02:00
if ( activeTabId == 'summary' ) {
this . activeTab = 'summary' ;
} else if ( activeTabId == 'publications' ) {
this . activeTab = 'publications' ;
this . searchPublications ( 1 , this . searchNumber ) ;
} else if ( activeTabId == 'datasets' ) {
this . activeTab = 'datasets' ;
this . searchDatasets ( 1 , this . searchNumber ) ;
} else if ( activeTabId == 'software' ) {
this . activeTab = 'software' ;
this . searchSoftware ( 1 , this . searchNumber ) ;
} else if ( activeTabId == 'other' ) {
this . activeTab = "other" ;
this . searchOrps ( 1 , this . searchNumber ) ;
2020-07-13 16:42:34 +02:00
} else if ( activeTabId == 'projects' ) {
2020-05-26 22:36:14 +02:00
this . activeTab = "projects" ;
this . searchProjects ( 1 , this . searchNumber ) ;
2020-07-13 16:42:34 +02:00
} else if ( activeTabId == 'datasources' ) {
2020-05-26 22:36:14 +02:00
this . activeTab = "datasources" ;
this . searchDatasources ( 1 , this . searchNumber ) ;
2020-07-13 16:42:34 +02:00
} else if ( activeTabId == 'relatedDatasources' ) {
2020-05-26 22:36:14 +02:00
this . activeTab = "relatedDatasources" ;
2022-05-19 18:08:04 +02:00
this . searchRelatedDatasources ( 1 , 0 ) ;
2020-05-26 22:36:14 +02:00
} else if ( activeTabId == 'statistics' ) {
this . activeTab = 'statistics' ;
this . statsClicked = true ;
}
}
}
2021-09-08 14:21:30 +02:00
2020-05-26 22:36:14 +02:00
public get hasAggregationStatusInfo ( ) : boolean {
2021-07-14 13:19:57 +02:00
// return (!!this.dataProviderInfo.aggregationStatus &&
// ((!!this.dataProviderInfo.aggregationStatus.fulltexts && parseInt(this.dataProviderInfo.aggregationStatus.fulltexts) != -1)
// || (!!this.dataProviderInfo.aggregationStatus.fundedContent && parseInt(this.dataProviderInfo.aggregationStatus.fundedContent) != -1)
// || !!this.dataProviderInfo.aggregationStatus.lastUpdateDate));
2020-05-26 22:36:14 +02:00
return ( ! ! this . dataProviderInfo . aggregationStatus &&
2021-07-14 13:19:57 +02:00
( ( ! ! this . dataProviderInfo . aggregationStatus . fulltexts && parseInt ( this . dataProviderInfo . aggregationStatus . fulltexts ) != - 1 ) ) ) ;
2020-05-26 22:36:14 +02:00
}
2021-07-14 13:19:57 +02:00
2020-05-26 22:36:14 +02:00
public get hasJournalInfo ( ) : boolean {
return ( ! ! this . dataProviderInfo . journal && (
! ! this . dataProviderInfo . journal [ 'journal' ] || ! ! this . dataProviderInfo . journal [ 'issn' ] ||
! ! this . dataProviderInfo . journal [ 'lissn' ] || ! ! this . dataProviderInfo . journal [ 'eissn' ] ||
! ! this . dataProviderInfo . journal [ 'volume' ] || ! ! this . dataProviderInfo . journal [ 'issue' ] ||
! ! this . dataProviderInfo . journal [ 'start_page' ] || ! ! this . dataProviderInfo . journal [ 'end_page' ] ) ) ;
//return true;
}
2021-09-08 14:21:30 +02:00
2020-05-26 22:36:14 +02:00
public get hasPrimaryInfo ( ) : boolean {
return ! ! this . dataProviderInfo && (
2022-05-03 13:22:53 +02:00
( ! ! this . dataProviderInfo . description && this . dataProviderInfo . description . length > 0 ) ||
2020-05-26 22:36:14 +02:00
this . hasJournalInfo ||
2020-05-29 16:15:35 +02:00
//this.hasAggregationStatusInfo ||
2020-05-26 22:36:14 +02:00
! ! this . dataProviderInfo . countries ||
( ! ! this . dataProviderInfo . subjects && this . dataProviderInfo . subjects . length > 0 ) ) ;
}
2021-09-08 14:21:30 +02:00
2020-05-26 22:36:14 +02:00
public get hasSecondaryInfo ( ) : boolean {
return ! ! this . dataProviderInfo && (
( ! ! this . dataProviderInfo . organizations && this . dataProviderInfo . organizations . length > 0 )
2022-05-03 13:22:53 +02:00
|| ! ! this . dataProviderInfo . oaiPmhURL || ( this . dataProviderInfo . provenance && this . dataProviderInfo . provenance . size > 0 )
2020-05-26 22:36:14 +02:00
) ;
}
2020-11-11 15:43:13 +01:00
2022-05-03 13:22:53 +02:00
public getKeys ( map ) {
return Array . from ( map . keys ( ) ) ;
}
2022-05-05 19:54:01 +02:00
public getProvenanceUrls() {
this . provenanceUrls = Array . from ( this . dataProviderInfo . provenance . values ( ) ) . map ( res = > res [ 'url' ] ) . reduce ( ( acc , val ) = > acc . concat ( val ) , [ ] ) ;
}
2022-05-13 14:57:31 +02:00
public getTypeName ( ) : string {
2022-06-03 12:01:55 +02:00
return StringUtils . getEntityName ( this . type , false ) ;
2022-05-13 14:57:31 +02:00
}
2022-09-21 12:32:21 +02:00
2023-03-01 15:49:42 +01:00
public viewAllDescriptionClicked() {
if ( this . isMobile ) {
this . summaryFsModal . title += " - Description" ;
this . summaryFsModal . back = true ;
this . viewAllMobile = "description" ;
} else {
this . openDescriptionModal ( ) ;
}
}
2022-09-21 12:32:21 +02:00
public openDescriptionModal() {
this . descriptionModal . alertFooter = false ;
this . descriptionModal . alertTitle = "Description" ;
this . descriptionModal . open ( ) ;
}
2023-04-20 19:06:53 +02:00
2023-02-13 14:51:15 +01:00
public clickedUsageMetrics() {
setTimeout ( ( ) = > {
this . metricsClicked = true ;
} ) ;
}
public formatNumber ( num : number | string ) {
let formatted = NumberUtils . roundNumber ( + num ) ;
return formatted . number + formatted . size ;
}
2023-02-20 18:29:21 +01:00
2023-03-01 15:49:42 +01:00
public cancelSummaryClicked() {
this . summaryFsModal . title = "Summary" ;
this . summaryFsModal . back = false ;
this . lessBtnOrganizations = false ;
this . viewAllMobile = "" ;
}
public openFsModal ( fsModal : FullScreenModalComponent , title : string ) {
fsModal . title = title ;
fsModal . okButton = false ;
fsModal . stayOpenInBack = true ;
fsModal . open ( ) ;
this . tabMobile = title ;
}
2023-02-21 18:13:15 +01:00
public getMetricsTooltip ( value : string ) {
if ( value == 'downloads' ) {
2023-03-27 15:32:41 +02:00
return "<div class='uk-flex uk-flex-middle'><a href='https://usagecounts.openaire.eu/' target='_blank'><img src='assets/common-assets/logo-small-usage-counts.png' loading='lazy' alt='OpenAIRE UsageCounts'></a><span class='uk-text-uppercase uk-margin-small-left'>Downloads provided by <a href='https://usagecounts.openaire.eu/' target='_blank' class='uk-link-reset'><strong>UsageCounts</strong></a></div>" ;
2023-02-21 18:13:15 +01:00
} else if ( value == 'views' ) {
2023-03-27 15:32:41 +02:00
return "<div class='uk-flex uk-flex-middle'><a href='https://usagecounts.openaire.eu/' target='_blank'><img class='uk-margin-small-right' src='assets/common-assets/logo-small-usage-counts.png' loading='lazy' alt='OpenAIRE UsageCounts'></a><span class='uk-text-uppercase uk-margin-small-left'>Views provided by <a href='https://usagecounts.openaire.eu/' target='_blank' class='uk-link-reset'><strong>UsageCounts</strong></a></div>" ;
2023-02-21 18:13:15 +01:00
}
2023-02-20 18:29:21 +01:00
}
2023-05-09 18:04:06 +02:00
2023-04-20 19:06:53 +02:00
public addEoscPrevInParams ( obj ) {
if ( properties . adminToolsPortalType == "eosc" && this . prevPath ) {
2023-05-25 17:10:58 +02:00
let splitted : string [ ] = this . prevPath . split ( "?" ) ;
obj = this . routerHelper . addQueryParam ( "return_path" , splitted [ 0 ] , obj ) ;
if ( splitted . length > 0 ) {
obj = this . routerHelper . addQueryParam ( "search_params" , splitted [ 1 ] , obj ) ;
}
2023-04-20 19:06:53 +02:00
}
return obj ;
}
public get eoscBackLink() {
if ( this . prevPath && this . referrer && ( ( this . referrer == "https://eosc-search-service.grid.cyfronet.pl/" ) || ( this . referrer == "https://beta.search.marketplace.eosc-portal.eu/" ) || ( this . referrer == "https://search.marketplace.eosc-portal.eu/" ) ) ) {
2023-04-21 18:56:19 +02:00
return this . referrer + this . prevPath ;
2023-04-20 19:06:53 +02:00
} else {
2023-04-20 19:48:12 +02:00
return "https://" + ( this . properties . environment == "beta" ? "beta." : "" ) + "search.marketplace.eosc-portal.eu/" ;
2023-04-20 19:06:53 +02:00
}
}
2017-12-19 13:53:46 +01:00
}