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 { ProjectService } from './project.service' ;
import { ProjectInfo } from '../../utils/entities/projectInfo' ;
import { RouterHelper } from '../../utils/routerHelper.class' ;
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 { ModalLoading } from '../../utils/modal/loading.component' ;
import { ReportsService } from '../../services/reports.service' ;
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' ;
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" ;
2020-03-16 14:09:46 +01:00
import { HtmlProjectReportService } from "../htmlProjectReport/htmlProjectReport.service" ;
2020-05-08 17:04:24 +02:00
import { StringUtils } from "../../utils/string-utils.class" ;
2020-05-19 17:59:20 +02:00
import { ResultPreview } from "../../utils/result-preview/result-preview" ;
import { SearchResult } from "../../utils/entities/searchResult" ;
import { IndexInfoService } from "../../utils/indexInfo.service" ;
2023-07-04 10:53:08 +02:00
import { Subscriber , Subscription , zip } from "rxjs" ;
2020-11-18 17:06:27 +01:00
import { properties } from "../../../../environments/environment" ;
2022-04-28 11:13:06 +02:00
import { Option } from "../../sharedComponents/input/input.component" ;
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-02-23 12:09:42 +01:00
import { LayoutService } from '../../dashboard/sharedComponents/sidebar/layout.service' ;
import { FullScreenModalComponent } from '../../utils/modal/full-screen-modal/full-screen-modal.component' ;
2017-12-19 13:53:46 +01:00
2022-05-05 19:54:01 +02:00
declare var ResizeObserver ;
2017-12-19 13:53:46 +01:00
@Component ( {
2019-07-22 11:16:50 +02:00
selector : 'project' ,
templateUrl : 'project.component.html' ,
} )
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
2019-07-22 11:16:50 +02:00
export class ProjectComponent {
2023-04-20 19:06:53 +02:00
public referrer : string ;
public prevPath : string ;
2019-07-22 11:16:50 +02:00
@Input ( ) communityId = null ;
2017-12-19 13:53:46 +01:00
public projectInfo : ProjectInfo ;
2019-07-22 11:16:50 +02:00
public projectId : string ;
2017-12-19 13:53:46 +01:00
public projectName : string ;
// 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;
2017-12-19 13:53:46 +01:00
// Statistics tab variables
public statsClicked : boolean ;
public chartScientificResultsUrl : string ;
public chartAccessModeUrl : string ;
public chartDatasourcesUrl : string ;
2020-03-16 14:09:46 +01:00
// Clipboard variable for HTML dynamic content
public clipboard ;
2017-12-19 13:53:46 +01:00
2019-07-22 11:16:50 +02:00
public project ;
2017-12-19 13:53:46 +01:00
// CSV variables
public downloadURLAPI : string ;
public csvParams : string ;
2020-03-16 14:09:46 +01:00
// HTML (download) variables
public header1 : string = "" ;
public header2 : string = "" ;
public htmlResultDownload : string = "" ;
2017-12-19 13:53:46 +01:00
// Message variables
public warningMessage = "" ;
public errorMessage = "" ;
public showLoading : boolean = true ;
// Active tab variable for responsiveness
2020-05-26 22:34:04 +02:00
public activeTab : string = "" ;
2022-11-28 18:22:01 +01:00
// @ViewChild('statisticsModal') statisticsModal;
// @ViewChild('linkProjectModal') linkProjectModal;
2022-04-28 11:13:06 +02:00
@ViewChild ( 'embedResultsModal' ) embedResultsModal ;
2023-02-23 12:09:42 +01:00
@ViewChild ( 'embedResultsFsModal' ) embedResultsFsModal : FullScreenModalComponent ;
2020-05-19 01:40:14 +02:00
@ViewChild ( 'downloadReportModal' ) downloadReportModal ;
2023-02-23 12:09:42 +01:00
@ViewChild ( 'downloadReportFsModal' ) downloadReportFsModal : FullScreenModalComponent ;
@ViewChild ( 'addThisModal' ) addThisModal ;
@ViewChild ( 'addThisFsModal' ) addThisFsModal : FullScreenModalComponent ;
2020-05-19 01:40:14 +02:00
2018-06-08 13:21:42 +02:00
// Request results for publications, research data and software only the one time (first time tab is clicked)
private reloadPublications : boolean = true ;
2017-12-19 13:53:46 +01:00
private reloadDatasets : boolean = true ;
private reloadSoftware : boolean = true ;
2018-07-26 18:38:59 +02:00
private reloadOrps : boolean = true ;
2021-03-10 14:24:19 +01:00
private reloadDmps : boolean = true ;
2017-12-19 13:53:46 +01:00
2020-03-16 14:09:46 +01:00
// Variables for entity selections on the right column
2022-04-28 11:13:06 +02:00
public embed_research_results_type : string = "result" ;
2020-03-16 14:09:46 +01:00
public download_research_results_type : string = "" ;
2017-12-19 13:53:46 +01:00
// Variables for publications, research data, software tabs
2019-09-11 11:45:54 +02:00
public fetchPublications : FetchResearchResults ;
public fetchDatasets : FetchResearchResults ;
public fetchSoftware : FetchResearchResults ;
public fetchOrps : FetchResearchResults ;
2021-03-10 14:24:19 +01:00
public fetchDmps : FetchResearchResults ;
2020-05-20 18:45:50 +02:00
public searchNumber : number = 5 ;
2017-12-19 13:53:46 +01: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 ;
2017-12-19 13:53:46 +01:00
2020-03-16 14:09:46 +01:00
public indexUpdateDate : Date ;
public showFeedback : boolean ;
public feedbackFields : string [ ] = [
'Title' , 'Funding Information' , 'Duration' ,
2022-05-04 12:57:13 +02:00
OpenaireEntities . ORGANIZATIONS , 'Other' ] ;
2019-12-10 15:45:13 +01:00
2019-07-22 11:16:50 +02:00
@ViewChild ( ModalLoading ) loading : ModalLoading ;
2017-12-19 13:53:46 +01:00
// Alert box when something is wrong with CSV requests
@ViewChild ( 'AlertModalCsvError' ) alertCsvError ;
2020-03-16 14:09:46 +01:00
// Description variables for view more/less functionality
public thresholdDescription : number = 670 ;
public showNumDescription : number = 670 ;
2022-04-28 11:13:06 +02:00
// // Organizations variables for view more/less functionality
// public thresholdOrganizations: number = 20;
// public showNumOrganizations: number = 20;
/*Show all organizations*/
public viewAllOrganizations : boolean = false ;
public lessBtnOrganizations : boolean = false ;
2020-03-16 14:09:46 +01:00
public thresholdOrganizations : number = 20 ;
2022-04-28 11:13:06 +02:00
@ViewChild ( 'organizationsModal' ) organizationsModal ;
public resultTypesForEmbedding : Option [ ] = [
{ label : "All " + OpenaireEntities . RESULTS , value : "result" } ,
{ label : OpenaireEntities.PUBLICATIONS , value : "publication" } ,
{ label : OpenaireEntities.DATASETS , value : "dataset" } ,
{ label : OpenaireEntities.SOFTWARE , value : "software" } ,
{ label : OpenaireEntities.OTHER , value : "other" } ] ;
public resultTypesForDownloading : Option [ ] = [
{ label : "All " + OpenaireEntities . RESULTS , value : "results" , disabled : true } ,
{ label : OpenaireEntities.PUBLICATIONS , value : "publications" , disabled : true } ,
{ label : OpenaireEntities.DATASETS , value : "datasets" , disabled : true } ,
{ label : OpenaireEntities.SOFTWARE , value : "software" , disabled : true } ,
{ label : OpenaireEntities.OTHER , value : "other" , disabled : true } ] ;
public offset : number ;
public stickyHeader : boolean = false ;
2022-05-03 10:52:07 +02:00
public graph_offset : number = 0 ;
2022-05-05 19:54:01 +02:00
public graph_height : number = 0 ;
2022-05-03 10:52:07 +02:00
@ViewChild ( "graph_and_feedback" ) graph_and_feedback ;
2020-03-16 14:09:46 +01:00
2022-09-21 12:32:21 +02:00
@ViewChild ( "descriptionDiv" ) descriptionDiv : ElementRef ;
@ViewChild ( 'descriptionModal' ) descriptionModal ;
2020-11-11 15:43:13 +01:00
subscriptions = [ ] ;
2023-02-13 14:51:15 +01:00
private sub : Subscription ;
2024-07-02 12:51:15 +02:00
properties : EnvProperties = properties ;
2022-04-28 11:13:06 +02:00
public openaireEntities = OpenaireEntities ;
2023-02-23 12:09:42 +01:00
public isMobile : boolean = false ;
2024-06-03 16:12:52 +02:00
public isBottomIntersecting : boolean = false ;
2023-02-23 12:09:42 +01:00
public mobileContent : "info" | "metrics" | "actions" = "info" ;
public tabMobile : string = "" ;
public viewAllMobile : string = "" ;
// Full screen modals for small screens (mobile)
@ViewChild ( 'summaryFsModal' ) summaryFsModal : FullScreenModalComponent ;
@ViewChild ( 'publicationsFsModal' ) publicationsFsModal : FullScreenModalComponent ;
@ViewChild ( 'datasetsFsModal' ) datasetsFsModal : FullScreenModalComponent ;
@ViewChild ( 'softwareFsModal' ) softwareFsModal : FullScreenModalComponent ;
@ViewChild ( 'otherFsModal' ) otherFsModal : FullScreenModalComponent ;
@ViewChild ( 'dmpsFsModal' ) dmpsFsModal : FullScreenModalComponent ;
@ViewChild ( 'statisticsFsModal' ) statisticsFsModal : FullScreenModalComponent ;
2020-03-16 14:09:46 +01:00
constructor ( private route : ActivatedRoute ,
private _router : Router ,
private _location : Location ,
2019-07-22 11:16:50 +02:00
private _meta : Meta ,
private _title : Title ,
2019-11-07 10:51:09 +01:00
private seoService : SEOService ,
2020-03-16 14:09:46 +01:00
private _piwikService : PiwikService ,
private helper : HelperService ,
private _projectService : ProjectService ,
private _searchResearchResultsService : SearchResearchResultsService ,
private _reportsService : ReportsService ,
2020-05-19 17:59:20 +02:00
private htmlService : HtmlProjectReportService ,
2022-05-05 19:54:01 +02:00
private indexInfoService : IndexInfoService ,
2023-02-13 14:51:15 +01:00
private metricsService : MetricsService ,
2023-02-23 12:09:42 +01:00
private cdr : ChangeDetectorRef ,
private layoutService : LayoutService ) { }
2017-12-19 13:53:46 +01:00
ngOnInit() {
2023-02-23 12:09:42 +01:00
this . subscriptions . push ( this . layoutService . isMobile . subscribe ( isMobile = > {
this . isMobile = isMobile ;
2024-06-03 16:12:52 +02:00
this . cdr . detectChanges ( ) ;
} ) ) ;
this . subscriptions . push ( this . layoutService . isBottomIntersecting . subscribe ( isBottomIntersecting = > {
this . isBottomIntersecting = isBottomIntersecting ;
this . cdr . detectChanges ( ) ;
2023-02-23 12:09:42 +01:00
} ) ) ;
if ( typeof document !== 'undefined' ) {
this . subscriptions . push ( this . indexInfoService . getLastIndexDate ( this . properties ) . subscribe ( lastIndexUpdate = > {
if ( lastIndexUpdate ) {
this . indexUpdateDate = new Date ( lastIndexUpdate ) ;
}
} ) ) ;
}
2024-02-08 13:19:26 +01:00
if ( properties . adminToolsPortalType !== "explore" ) {
//this.getDivContents();
this . getPageContents ( ) ;
}
2023-02-23 12:09:42 +01:00
this . updateUrl ( this . properties . domain + this . properties . baseLink + this . _router . url ) ;
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 ( params = > {
2022-05-04 12:57:13 +02:00
this . stickyHeader = false ;
2019-07-22 11:16:50 +02:00
this . metricsClicked = false ;
this . statsClicked = false ;
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 ) ;
2021-03-10 14:24:19 +01:00
this . fetchDmps = new FetchResearchResults ( this . _searchResearchResultsService ) ;
[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
var title = OpenaireEntities . PROJECT ;
2019-07-22 11:16:50 +02:00
var description = "" ;
2020-03-16 14:09:46 +01:00
this . header1 = "" ;
2019-07-22 11:16:50 +02:00
this . updateTitle ( title ) ;
this . updateDescription ( description ) ;
2023-04-20 19:06:53 +02:00
2023-05-25 17:10:58 +02:00
if ( params [ "return_path" ] ) {
this . prevPath = params [ "return_path" ] + ( params [ "search_params" ] ? ( "?" + params [ "search_params" ] ) : "" ) ;
2023-04-20 19:06:53 +02:00
}
if ( ( typeof document !== 'undefined' ) && document . referrer ) {
this . referrer = document . referrer ;
}
2017-12-19 13:53:46 +01:00
this . projectId = params [ 'projectId' ] ;
2018-03-16 16:56:35 +01:00
var grantId = params [ 'grantId' ] ;
var funder = params [ 'funder' ] ;
2020-06-16 18:42:51 +02:00
if ( this . projectId && StringUtils . isOpenAIREID ( this . projectId ) ) {
2019-07-22 11:16:50 +02:00
this . getProjectInfo ( this . projectId ) ;
this . actionsAfterLoadId ( ) ;
} else if ( grantId && funder ) {
this . getProjectInfoByGrantId ( grantId , funder ) ;
} else {
2018-03-16 16:56:35 +01:00
2019-07-22 11:16:50 +02:00
this . showLoading = false ;
2022-05-11 11:55:14 +02:00
this . _router . navigate ( [ this . properties . errorLink ] , { queryParams : { "page" : this . _location . path ( true ) , "page_type" : "project" } } ) ;
2019-10-31 12:39:23 +01:00
//this.warningMessage = "No valid project id";
2017-12-19 13:53:46 +01:00
}
2018-02-05 14:14:59 +01:00
this . downloadURLAPI = this . properties . csvAPIURL ;
2017-12-19 13:53:46 +01:00
this . createClipboard ( ) ;
2020-11-11 15:43:13 +01:00
} ) ) ;
2022-04-28 11:13:06 +02:00
}
2022-05-03 10:52:07 +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-05 19:54:01 +02:00
if ( this . graph_and_feedback ) {
this . observeGraphAndFeedback ( ) ;
2022-05-04 17:09:35 +02:00
}
2022-05-03 10:52:07 +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-04-28 11:13:06 +02:00
}
2022-05-03 10:52:07 +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 ;
2019-07-22 11:16:50 +02:00
}
2020-03-16 14:09:46 +01:00
public getFileNameType ( type : string ) {
2022-06-03 12:01:55 +02:00
return StringUtils . getEntityFileName ( type ) ;
2020-03-16 14:09:46 +01:00
}
public getCsvParams ( type : string ) {
// if(type == "results") {
// type = "publications&type=datasets&type=software&type=other";
// }
return "?format=csv-special&type=" + type + "&fq=(relprojectid exact \"" + this . projectId + "\")" ;
}
2019-07-22 11:16:50 +02:00
private getPageContents() {
2020-06-29 15:15:52 +02:00
if ( this . communityId ) {
2020-11-11 15:43:13 +01:00
this . subscriptions . push ( this . helper . getPageHelpContents ( this . properties , this . communityId , this . _router . url ) . subscribe ( contents = > {
2020-06-29 15:15:52 +02:00
this . pageContents = contents ;
2020-11-11 15:43:13 +01:00
} ) ) ;
2020-06-29 15:15:52 +02:00
}
2019-07-22 11:16:50 +02:00
}
private getDivContents() {
2020-06-29 15:15:52 +02:00
if ( this . communityId ) {
2020-11-11 15:43:13 +01:00
this . subscriptions . push ( this . helper . getDivHelpContents ( this . properties , this . communityId , this . _router . url ) . subscribe ( contents = > {
2020-06-29 15:15:52 +02:00
this . divContents = contents ;
2020-11-11 15:43:13 +01:00
} ) ) ;
2020-06-29 15:15:52 +02:00
}
2019-07-22 11:16:50 +02:00
}
2020-03-16 14:09:46 +01:00
getDynamicContent ( type : string ) {
return "<script type=\"text/javascript\">"
2019-07-22 11:16:50 +02:00
+ "\n<!--"
+ "\ndocument.write('<div id=\"oa_widget\"></div>');"
+ "\ndocument.write('<script type=\"text/javascript\""
2019-12-11 12:13:57 +01:00
+ " src=\"" + this . properties . widgetLink
2020-03-16 14:09:46 +01:00
+ this . projectId + "&type="
+ type
+ "\"></script>');"
2019-07-22 11:16:50 +02:00
+ "\n-->"
+ "\n</script>" ;
2020-03-16 14:09:46 +01:00
}
2019-07-22 11:16:50 +02:00
2020-03-16 14:09:46 +01:00
actionsAfterLoadId() {
2020-06-10 13:05:59 +02:00
//this.getProjectInfo(this.projectId);
2019-07-22 11:16:50 +02:00
//this.searchPublications();
2020-06-10 13:05:59 +02:00
if ( typeof document !== 'undefined' ) {
this . fetchPublications . getNumForEntity ( "publication" , "project" , this . projectId , this . properties ) ;
this . fetchDatasets . getNumForEntity ( "dataset" , "project" , this . projectId , this . properties ) ;
this . fetchSoftware . getNumForEntity ( "software" , "project" , this . projectId , this . properties ) ;
this . fetchOrps . getNumForEntity ( "other" , "project" , this . projectId , this . properties ) ;
2021-03-10 14:24:19 +01:00
this . searchDmps ( 1 , this . searchNumber ) ;
2020-06-10 13:05:59 +02:00
}
2019-07-22 11:16:50 +02:00
}
2017-12-19 13:53:46 +01: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 ( ) ;
2021-03-10 14:24:19 +01:00
this . fetchOrps . clearSubscriptions ( ) ;
this . fetchDmps . clearSubscriptions ( ) ;
2017-12-19 13:53:46 +01:00
}
private createClipboard() {
2019-07-22 11:16:50 +02:00
if ( typeof window !== 'undefined' ) {
2020-03-16 14:09:46 +01:00
delete this . clipboard ;
2019-07-22 11:16:50 +02:00
let Clipboard ;
Clipboard = require ( 'clipboard' ) ;
2020-03-16 14:09:46 +01:00
this . clipboard = new Clipboard ( '.clipboard_btn' ) ;
2019-07-22 11:16:50 +02:00
}
2017-12-19 13:53:46 +01:00
}
2020-05-31 15:09:26 +02:00
public searchPublications ( page : number , size : number ) {
if ( this . reloadPublications &&
( this . fetchPublications . searchUtils . status == this . errorCodes . LOADING ||
( this . fetchPublications . searchUtils . status == this . errorCodes . DONE && this . fetchPublications . searchUtils . totalResults > 0 )
)
) {
this . fetchPublications . getResultsForEntity ( "publication" , "project" , this . projectId , page , size , this . properties ) ;
2019-07-22 11:16:50 +02:00
}
2020-05-31 15:09:26 +02:00
this . reloadPublications = false ;
2018-06-08 13:21:42 +02:00
}
2021-09-08 14:21:30 +02:00
2021-03-10 14:24:19 +01:00
public searchDmps ( page : number , size : number ) {
if ( this . reloadDmps &&
( this . fetchDmps . searchUtils . status == this . errorCodes . LOADING ||
( this . fetchDmps . searchUtils . status == this . errorCodes . DONE && this . fetchDmps . searchUtils . totalResults > 0 )
)
) {
this . fetchDmps . getDmps ( "project" , this . projectId , page , size , this . properties ) ;
}
this . reloadDmps = false ;
}
2018-06-08 13:21:42 +02:00
2020-05-31 15:09:26 +02:00
public searchDatasets ( page : number , size : number ) {
if ( this . reloadDatasets &&
( this . fetchDatasets . searchUtils . status == this . errorCodes . LOADING ||
( this . fetchDatasets . searchUtils . status == this . errorCodes . DONE && this . fetchDatasets . searchUtils . totalResults > 0 )
)
) {
this . fetchDatasets . getResultsForEntity ( "dataset" , "project" , this . projectId , page , size , this . properties ) ;
2019-07-22 11:16:50 +02:00
}
2020-05-31 15:09:26 +02:00
this . reloadDatasets = false ;
2017-12-19 13:53:46 +01:00
}
2020-05-31 15:09:26 +02:00
private searchSoftware ( page : number , size : number ) {
if ( this . reloadSoftware &&
( this . fetchSoftware . searchUtils . status == this . errorCodes . LOADING ||
( this . fetchSoftware . searchUtils . status == this . errorCodes . DONE && this . fetchSoftware . searchUtils . totalResults > 0 )
)
) {
this . fetchSoftware . getResultsForEntity ( "software" , "project" , this . projectId , page , size , this . properties ) ;
2019-07-22 11:16:50 +02:00
}
2020-05-31 15:09:26 +02:00
this . reloadSoftware = false ;
2017-12-19 13:53:46 +01:00
}
2020-05-31 15:09:26 +02:00
private searchOrps ( page : number , size : number ) {
if ( this . reloadOrps &&
( this . fetchOrps . searchUtils . status == this . errorCodes . LOADING ||
( this . fetchOrps . searchUtils . status == this . errorCodes . DONE && this . fetchOrps . searchUtils . totalResults > 0 )
)
) {
this . fetchOrps . getResultsForEntity ( "other" , "project" , this . projectId , page , size , this . properties ) ;
2019-07-22 11:16:50 +02:00
}
2020-05-31 15:09:26 +02:00
this . reloadOrps = false ;
2018-07-26 18:38:59 +02:00
}
2019-07-22 11:16:50 +02:00
private getProjectInfo ( id : string ) {
this . warningMessage = '' ;
2020-03-17 16:19:25 +01:00
this . errorMessage = "" ;
2017-12-19 13:53:46 +01:00
this . showLoading = true ;
2018-06-28 16:52:45 +02:00
this . projectInfo = null ;
2017-12-19 13:53:46 +01:00
2020-11-11 15:43:13 +01:00
this . subscriptions . push ( this . _projectService . getProjectInfo ( id , this . properties ) . subscribe (
2017-12-19 13:53:46 +01:00
data = > {
2019-07-22 11:16:50 +02:00
this . projectInfo = data ;
2024-05-31 12:59:23 +02:00
this . projectInfo . setBelongsTo ( id ) ;
2023-09-19 15:45:17 +02:00
this . projectInfo . id = this . projectId ;
2017-12-19 13:53:46 +01:00
2019-07-22 11:16:50 +02:00
this . actionsAfterGettingProjectInfo ( ) ;
2017-12-19 13:53:46 +01:00
} ,
err = > {
2019-07-22 11:16:50 +02:00
//console.log(err);
this . handleError ( "Error getting project for id: " + this . projectId , err ) ;
2019-10-31 12:39:23 +01:00
if ( err . status == 404 ) {
2022-05-11 11:55:14 +02:00
this . _router . navigate ( [ this . properties . errorLink ] , { queryParams : { "page" : this . _location . path ( true ) , "page_type" : "project" } } ) ;
2021-12-17 14:39:32 +01:00
} else if ( err . name == "TimeoutError" ) {
this . errorMessage = 'An error occurred please try again later' ;
} else {
this . seoService . createLinkForCanonicalURL ( this . properties . domain + this . properties . baseLink + this . properties . searchLinkToProjects ) ;
2022-06-01 14:29:19 +02:00
this . errorMessage = 'No ' + OpenaireEntities . PROJECT + ' found' ;
2019-10-31 12:39:23 +01:00
}
2019-07-22 11:16:50 +02:00
this . showLoading = false ;
}
2020-11-11 15:43:13 +01:00
) ) ;
2018-03-16 16:56:35 +01:00
}
2019-07-22 11:16:50 +02:00
private getProjectInfoByGrantId ( grantId : string , funder : string ) {
this . warningMessage = '' ;
2020-03-17 16:19:25 +01:00
this . errorMessage = "" ;
2019-07-22 11:16:50 +02:00
this . showLoading = true ;
this . projectInfo = null ;
2020-11-11 15:43:13 +01:00
this . subscriptions . push ( this . _projectService . getProjectInfoByGrantId ( grantId , funder , this . properties ) . subscribe (
2019-07-22 11:16:50 +02:00
data = > {
2022-09-21 12:32:21 +02:00
this . projectInfo = data ;
2019-07-22 11:16:50 +02:00
this . actionsAfterGettingProjectInfo ( ) ;
this . projectId = this . projectInfo . id ;
this . actionsAfterLoadId ( ) ;
} ,
err = > {
//console.log(err);
this . handleError ( "Error getting project for grant id: " + grantId + " and funder: " + funder , err ) ;
2020-03-17 16:19:25 +01:00
if ( err . status == 404 ) {
2022-05-11 11:55:14 +02:00
this . _router . navigate ( [ this . properties . errorLink ] , { queryParams : { "page" : this . _location . path ( true ) , "page_type" : "project" } } ) ;
2021-12-17 14:39:32 +01:00
} else if ( err . name == "TimeoutError" ) {
this . errorMessage = 'An error occurred please try again later' ;
} else {
this . seoService . createLinkForCanonicalURL ( this . properties . domain + this . properties . baseLink + this . properties . searchLinkToProjects ) ;
this . errorMessage = 'No project found' ;
2020-03-17 16:19:25 +01:00
}
2019-07-22 11:16:50 +02:00
this . showLoading = false ;
}
2020-11-11 15:43:13 +01:00
) ) ;
2018-03-16 16:56:35 +01:00
}
2019-07-22 11:16:50 +02:00
actionsAfterGettingProjectInfo() {
this . projectName = this . projectInfo . acronym ;
if ( this . projectName == undefined || this . projectName == '' ) {
this . projectName = this . projectInfo . title ;
}
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
this . updateTitle ( this . projectName ) ;
2022-04-28 11:13:06 +02:00
// this.updateDescription(this.projectInfo.description?this.projectInfo.description: ("project" + (this.projectInfo.title?"," + this.projectInfo.title:"") + (this.projectInfo.funding && this.projectInfo.funding.funderName?", funder: " + this.projectInfo.funding.funderName:"") + (this.projectInfo.acronym?"," + this.projectInfo.acronym:"")));
2022-09-21 12:32:21 +02:00
this . updateDescription ( ( this . projectInfo . description ? ( this . projectInfo . description . substr ( 0 , 157 ) + ( this . projectInfo . description . substr ( 0 , 157 ) . length == 157 ? "..." : "" ) ) : ( this . projectInfo . title ) ) ) ;
2023-07-12 14:05:25 +02:00
this . subscriptions . push ( this . _piwikService . trackView ( this . properties , this . projectName ) . subscribe ( ) ) ;
2019-07-22 11:16:50 +02:00
this . project = {
funderId : "" ,
2020-03-16 14:09:46 +01:00
funderName : ( ( this . projectInfo . funding ) ? this . projectInfo . funding . funderShortName : '' ) ,
2019-07-22 11:16:50 +02:00
projectId : this.projectId ,
projectName : this.projectInfo.title ,
projectAcronym : this.projectInfo.acronym ,
startDate : this.projectInfo.startDate ,
endDate : this.projectInfo.endDate
} ;
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 . projectInfo && ! this . projectInfo . measure ) {
this . getMetrics ( ) ;
2023-05-19 13:37:23 +02:00
} else if ( this . projectInfo && this . projectInfo . measure && this . projectInfo . measure . counts ) {
this . projectInfo . 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
}
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":"projRepoViews","projTitle":"' + this.projectId + '","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":"projRepoDownloads","projTitle":"' + this.projectId + '","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.projects.views.monthly", "parameters":["' + this . projectId + '"], "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.projects.downloads.monthly", "parameters":["' + this . projectId + '"], "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":""}}}' ) ;
2019-07-22 11:16:50 +02:00
//stats tab charts
2020-05-08 17:04:24 +02:00
if ( this . properties . useNewStatistisTool ) {
this . chartScientificResultsUrl = this . properties . statisticsFrameNewAPIURL +
2022-04-28 11:13:06 +02:00
'chart?json=' + StringUtils . URIEncode ( '{"library":"HighCharts","chartDescription":{"queries":[{"name":"' + OpenaireEntities . RESULTS + '","type":"column","query":{"name":"projScient","parameters":["' + this . projectId + '"]}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Produced ' + OpenaireEntities . RESULTS + ' per year"},"subtitle":{},"yAxis":{"title":{"text":"' + OpenaireEntities . RESULTS + '"}},"xAxis":{"title":{"text":"Year"}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}' ) ;
2020-05-08 17:04:24 +02:00
this . chartAccessModeUrl = this . properties . statisticsFrameNewAPIURL +
'chart?json=' + StringUtils . URIEncode (
2022-04-28 11:13:06 +02:00
'{"library":"HighCharts","chartDescription":{"queries":[{"name":"' + OpenaireEntities . RESULTS + '","type":"pie","query":{"name":"projOA","parameters":["' + this . projectId + '"]}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Access mode of ' + OpenaireEntities . RESULTS + '"},"subtitle":{},"yAxis":{"title":{"text":"' + OpenaireEntities . RESULTS + '"}},"xAxis":{"title":{"text":"Access mode"}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}' ) ;
2020-05-08 17:04:24 +02:00
this . chartDatasourcesUrl = this . properties . statisticsFrameNewAPIURL +
'chart?json=' + StringUtils . URIEncode (
2022-04-28 11:13:06 +02:00
'{"library":"HighCharts","chartDescription":{"queries":[{"name":"' + OpenaireEntities . RESULTS + '","type":"bar","query":{"name":"projPubsRepos","parameters":["' + this . projectId + '"]}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"' + OpenaireEntities . RESULTS + ' per datasource"},"subtitle":{},"yAxis":{"title":{"text":"' + OpenaireEntities . RESULTS + '"}},"xAxis":{"title":{"text":"Datasource"}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":true}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}' ) ;
2020-05-08 17:04:24 +02:00
} else {
2022-04-28 11:13:06 +02:00
this . chartScientificResultsUrl = this . properties . statisticsFrameAPIURL + 'chart.php?com=query&persistent=false&data={"query":"projScient","projTitle":"' + this . projectId + '", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "spline", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["' + OpenaireEntities . RESULTS + '"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [" "], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=90%&h=90%' ;
this . chartAccessModeUrl = this . properties . statisticsFrameAPIURL + 'chart.php?com=query&persistent=false&data={"query":"projOA","projTitle":"' + this . projectId + '", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "pie", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["' + OpenaireEntities . RESULTS + '"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [" "], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=90%&h=90%' ;
this . chartDatasourcesUrl = this . properties . statisticsFrameAPIURL + 'chart.php?com=query&persistent=false&data={"query":"projPubsRepos","projTitle":"' + this . projectId + '", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "bar", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["' + OpenaireEntities . RESULTS + '"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [" "], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=90%&h=90%' ;
2020-05-08 17:04:24 +02:00
}
2018-03-16 16:56:35 +01:00
2019-07-22 11:16:50 +02:00
this . showLoading = false ;
2022-09-21 14:39:57 +02:00
this . cdr . detectChanges ( ) ;
2019-07-22 11:16:50 +02:00
}
2020-03-16 14:09:46 +01:00
public downloadCsvFile ( url : string , filename : string ) {
2019-07-22 11:16:50 +02:00
this . openLoading ( ) ;
this . setMessageLoading ( "Downloading CSV file" ) ;
2020-11-11 15:43:13 +01:00
this . subscriptions . push ( this . _reportsService . downloadCSVFile ( url ) . subscribe (
2019-07-22 11:16:50 +02:00
data = > {
this . closeLoading ( ) ;
2020-03-16 14:09:46 +01:00
let url = window . URL . createObjectURL ( data ) ;
this . download ( url , filename + ".csv" ) ;
2023-07-12 14:05:25 +02:00
this . subscriptions . push ( this . _piwikService . trackDownload ( this . properties , "DownloadCSV" + filename ) . subscribe ( ) ) ;
2019-07-22 11:16:50 +02:00
} ,
error = > {
//console.log("Error downloading the file.");
this . handleError ( "Error downloading file: " + filename , error ) ;
this . closeLoading ( ) ;
2020-03-16 14:09:46 +01:00
this . confirmOpenFileDownloadError ( "CSV" ) ;
2019-07-22 11:16:50 +02:00
} / * ,
2019-02-14 11:44:30 +01:00
( ) = > console . log ( 'Completed file download.' ) * /
2020-11-11 15:43:13 +01:00
) ) ;
2019-07-22 11:16:50 +02:00
}
2017-12-19 13:53:46 +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;
2019-07-22 11:16:50 +02:00
}
2021-09-08 14:21:30 +02:00
2023-02-13 14:51:15 +01:00
private getMetrics() {
let obs ;
obs = zip ( this . metricsService . getMetricsNumber ( this . projectId , "usagestats.projects.views" , this . properties ) ,
this . metricsService . getMetricsNumber ( this . projectId , "usagestats.projects.downloads" , 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 . projectInfo . measure = { counts : [ ] } ;
2023-05-19 13:37:23 +02:00
if ( data [ 0 ] && data [ 0 ] > 0 ) {
this . projectInfo . measure . counts . push ( { name : 'views' , order : 0 , icon : 'visibility' , value : data [ 0 ] } ) ;
this . hasViews = true ;
}
if ( data [ 1 ] && data [ 1 ] > 0 ) {
this . projectInfo . 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 ( ) ;
}
// this.totalViews = data[0];
// this.totalDownloads = data[1];
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-05-02 11:00:40 +02:00
// return !(this.totalViews != null && this.totalDownloads != null) || this.totalViews > 0 || this.totalDownloads > 0;
2023-05-04 14:15:47 +02:00
return this . projectInfo . measure ? . counts ? . length > 0 ;
2020-05-05 12:37:36 +02:00
}
2017-12-19 13:53:46 +01:00
2022-04-28 11:13:06 +02:00
public viewAllOrganizationsClick() {
this . viewAllOrganizations = true ;
if ( this . projectInfo . organizations . length <= this . thresholdOrganizations * 2 ) {
this . lessBtnOrganizations = true ;
} else {
this . openOrganizationsModal ( ) ;
}
2020-03-16 14:09:46 +01:00
}
2023-02-23 12:09:42 +01:00
public viewAllOrganizationsMobileClicked() {
this . summaryFsModal . title += " - Partners" ;
this . summaryFsModal . back = true ;
this . lessBtnOrganizations = true ;
this . viewAllMobile = "organizations" ;
}
2022-04-28 11:13:06 +02:00
public openOrganizationsModal() {
this . organizationsModal . cancelButton = false ;
this . organizationsModal . okButton = false ;
2022-05-03 10:52:07 +02:00
this . organizationsModal . alertTitle = "Partners" ;
2022-04-28 11:13:06 +02:00
this . organizationsModal . open ( ) ;
2020-05-19 01:40:14 +02:00
}
2022-04-28 11:13:06 +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 . PROJECT + " in your social networks" ;
2022-04-28 11:13:06 +02:00
this . addThisModal . open ( ) ;
}
public openEmbedResultsModal() {
this . embedResultsModal . cancelButton = false ;
this . embedResultsModal . okButton = false ;
this . embedResultsModal . alertTitle = "Embed results" ;
this . embedResultsModal . open ( ) ;
2020-05-19 01:40:14 +02:00
}
public openDownloadReportModal() {
2020-05-26 22:34:04 +02:00
if ( this . fetchPublications . searchUtils . totalResults > 0 || this . fetchDatasets . searchUtils . totalResults > 0 ||
this . fetchSoftware . searchUtils . totalResults > 0 || this . fetchOrps . searchUtils . totalResults > 0 ) {
this . download_research_results_type = "results" ;
}
2020-05-19 01:40:14 +02:00
this . downloadReportModal . cancelButton = false ;
this . downloadReportModal . okButton = false ;
this . downloadReportModal . alertTitle = "Download report" ;
this . downloadReportModal . open ( ) ;
}
2021-06-17 15:33:16 +02:00
public closeDownloadReportModal() {
this . downloadReportModal . cancel ( ) ;
}
2020-03-16 14:09:46 +01:00
private createHeaders ( type : string ) {
this . openLoading ( ) ;
this . setMessageLoading ( "Downloading HTML file" ) ;
if ( ! this . header1 ) {
this . createHeader1 ( ) ;
}
if ( type == "publications" ) {
2022-04-28 11:13:06 +02:00
this . header2 = this . fetchPublications . searchUtils . totalResults . toLocaleString ( 'en-US' ) + " " + OpenaireEntities . PUBLICATIONS ;
2020-03-16 14:09:46 +01:00
} else if ( type == "datasets" ) {
2022-04-28 11:13:06 +02:00
this . header2 = this . fetchDatasets . searchUtils . totalResults . toLocaleString ( 'en-US' ) + " " + OpenaireEntities . DATASETS ;
2020-03-16 14:09:46 +01:00
} else if ( type == "software" ) {
2022-04-28 11:13:06 +02:00
this . header2 = this . fetchSoftware . searchUtils . totalResults . toLocaleString ( 'en-US' ) + " " + OpenaireEntities . SOFTWARE ;
2020-03-16 14:09:46 +01:00
} else if ( type == "other" ) {
2022-04-28 11:13:06 +02:00
this . header2 = this . fetchOrps . searchUtils . totalResults . toLocaleString ( 'en-US' ) + " " + OpenaireEntities . OTHER ;
2020-03-16 14:09:46 +01:00
} else if ( type == "results" ) {
let totalResults : number = ( + this . fetchPublications . searchUtils . totalResults ) +
( + this . fetchDatasets . searchUtils . totalResults ) +
( + this . fetchSoftware . searchUtils . totalResults ) +
( + this . fetchOrps . searchUtils . totalResults ) ;
2022-04-28 11:13:06 +02:00
this . header2 = totalResults . toLocaleString ( 'en-US' ) + " " + OpenaireEntities . RESULTS ;
2020-03-16 14:09:46 +01:00
}
}
private createHtmlFile ( type : string , filename : string ) {
let intro : string = '<!doctype html>' ;
intro += '<html lang="en-gb" dir="ltr" vocab="http://schema.org/">' ;
intro += '<head>' ;
intro += '<title>' + this . header1 + '</title>' ;
intro += '</head>' ;
if ( typeof window !== 'undefined' ) {
2020-11-11 15:43:13 +01:00
this . subscriptions . push ( this . htmlService . getHTML ( this . projectId , type , this . properties . csvAPIURL ) . subscribe (
2020-03-16 14:09:46 +01:00
data = > {
//console.info(data);
this . htmlResultDownload = intro + '<body><div>' + this . header1 + '</div><div><h4>' + this . header2 + '</h4></div>' ;
this . htmlResultDownload += "<table><thead><tr> <th>Type</th><th>Title</th><th>Authors</th><th>Publication Year</th><th>DOI</th><th>Permanent Identifier</th><th>Publication type</th><th>Journal</th><th>Project Name (GA Number)</th><th>Access Mode</th></tr></thead><tbody>" + data + "</tbody></table>" ;
this . htmlResultDownload += '</body></html>' ;
//console.info(this.htmlResultDownload);
this . closeLoading ( ) ;
let url = window . URL . createObjectURL ( new Blob ( [ this . htmlResultDownload ] , { type : 'text/html' } ) ) ;
this . download ( url , filename + ".html" ) ;
2023-07-12 14:05:25 +02:00
this . subscriptions . push ( this . _piwikService . trackDownload ( this . properties , "DownloadHTML" + filename ) . subscribe ( ) ) ;
2020-03-16 14:09:46 +01:00
} ,
err = > {
this . handleError ( "Error getting html for id: " + this . projectId , err ) ;
//this.errorMessage = 'Service not available';
this . closeLoading ( ) ;
this . confirmOpenFileDownloadError ( "HTML" ) ;
}
2020-11-11 15:43:13 +01:00
) ) ;
2020-03-16 14:09:46 +01:00
} else {
this . closeLoading ( ) ;
this . confirmOpenFileDownloadError ( "HTML" ) ;
}
}
downloadHtmlFile ( type : string , filename : string ) {
this . createHeaders ( type ) ;
this . createHtmlFile ( type , filename ) ;
}
createHeader1() {
// if (title != undefined && title != "") {
// this.header1 += title;
// }
// if ((title != undefined && title != "") &&
// ((acronym != undefined && acronym != "") ||
// (code != undefined && code != ""))) {
// this.header1 += "(";
// }
// if (acronym != undefined && acronym != "") {
// this.header1 += acronym + " - ";
// }
// if (code != undefined && code != "") {
// this.header1 += code;
// }
// if ((title != undefined && title != "") &&
// ((acronym != undefined && acronym != "") ||
// (code != undefined && code != ""))) {
// this.header1 += ")";
// }
this . header1 = "<div style=\"font-size:12px;\"><span>Project</span>" ;
if ( this . projectInfo . startDate || this . projectInfo . endDate ) {
this . header1 += "<span> . "
}
if ( this . projectInfo . startDate && ! this . projectInfo . endDate ) {
this . header1 += "from " ;
}
if ( ! this . projectInfo . startDate && this . projectInfo . endDate ) {
this . header1 += "until " ;
}
if ( this . projectInfo . startDate ) {
let startYear = ( new Date ( this . projectInfo . startDate ) ) . getFullYear ( ) ;
this . header1 += startYear ;
}
if ( this . projectInfo . startDate && this . projectInfo . endDate ) {
this . header1 += " - " ;
}
if ( this . projectInfo . endDate ) {
let endYear = ( new Date ( this . projectInfo . endDate ) ) . getFullYear ( ) ;
this . header1 += endYear ;
}
if ( this . projectInfo . startDate || this . projectInfo . endDate ) {
this . header1 += "</span>"
}
if ( this . projectInfo . status ) {
this . header1 += "<span> . " + this . projectInfo . status + "</span>" ;
}
if ( this . projectInfo . funding && this . projectInfo . funding . code ) {
this . header1 += "<span> . " + this . projectInfo . funding . code + "</span>" ;
}
this . header1 += "</div>" ;
this . header1 += "<h1 style=\"margin:0;\"><div><a href=\"" + window . location . href + "\">" ;
if ( this . projectInfo . acronym ) {
this . header1 += this . projectInfo . acronym ;
} else {
this . header1 += "[no title available]" ;
}
this . header1 += "</a></div></h2>" ;
//<showTitle [titleName]="title" classNames="uk-margin-remove-bottom"></showTitle>
if ( this . projectInfo . title ) {
this . header1 += "<div><span>" + this . projectInfo . title + "</span></div>" ;
}
}
public download ( url , filename ) {
//var url = window.URL.createObjectURL(new Blob([this.htmlResultDownload], { type: 'text/html' }));
var a = window . document . createElement ( 'a' ) ;
window . document . body . appendChild ( a ) ;
a . setAttribute ( 'style' , 'display: none' ) ;
a . href = url ;
a . download = filename ;
a . click ( ) ;
window . URL . revokeObjectURL ( url ) ;
a . remove ( ) ; // remove the element
}
2020-05-19 01:40:14 +02:00
public onSelectActiveTab ( activeTabId ) {
2020-05-20 22:34:29 +02:00
if ( this . activeTab != activeTabId ) { // tab really changed
2020-05-19 01:40:14 +02:00
if ( activeTabId == 'summary' ) {
this . activeTab = 'summary' ;
} else if ( activeTabId == 'publications' ) {
this . activeTab = 'publications' ;
2020-05-31 15:09:26 +02:00
this . searchPublications ( 1 , this . searchNumber ) ;
2020-05-19 01:40:14 +02:00
} else if ( activeTabId == 'datasets' ) {
this . activeTab = 'datasets' ;
2020-05-31 15:09:26 +02:00
this . searchDatasets ( 1 , this . searchNumber ) ;
2020-05-19 01:40:14 +02:00
} else if ( activeTabId == 'software' ) {
this . activeTab = 'software' ;
2020-05-31 15:09:26 +02:00
this . searchSoftware ( 1 , this . searchNumber ) ;
2020-05-19 01:40:14 +02:00
} else if ( activeTabId == 'other' ) {
this . activeTab = "other" ;
2020-05-31 15:09:26 +02:00
this . searchOrps ( 1 , this . searchNumber ) ;
2020-05-19 01:40:14 +02:00
} else if ( activeTabId == 'statistics' ) {
this . activeTab = 'statistics' ;
2022-04-28 11:13:06 +02:00
setTimeout ( ( ) = > {
this . statsClicked = true ;
// this.cdr.detectChanges();
} ) ;
2021-03-10 14:24:19 +01:00
} else if ( activeTabId == 'dmps' ) {
this . activeTab = 'dmps' ;
this . searchDmps ( 1 , this . searchNumber ) ;
2020-05-19 01:40:14 +02:00
}
}
}
2019-07-22 11:16:50 +02:00
private updateDescription ( description : string ) {
2022-04-28 11:13:06 +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
}
2017-12-19 13:53:46 +01: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
}
2017-12-19 13:53:46 +01:00
2019-07-22 11:16:50 +02:00
private updateUrl ( url : string ) {
this . _meta . updateTag ( { content : url } , "property='og:url'" ) ;
}
private openLoading() {
2021-06-17 15:33:16 +02:00
this . closeDownloadReportModal ( ) ;
2021-09-08 14:21:30 +02:00
2019-07-22 11:16:50 +02:00
if ( this . loading ) {
this . loading . open ( ) ;
2017-12-19 13:53:46 +01:00
}
2019-07-22 11:16:50 +02:00
}
2017-12-19 13:53:46 +01:00
2019-07-22 11:16:50 +02:00
private closeLoading() {
2024-01-29 18:53:11 +01:00
setTimeout ( ( ) = > {
if ( this . loading ) {
this . loading . close ( ) ;
}
} , 300 )
2019-07-22 11:16:50 +02:00
}
2019-02-15 13:50:24 +01:00
2019-07-22 11:16:50 +02:00
private setMessageLoading ( message : string ) {
if ( this . loading ) {
this . loading . message = message ;
2019-02-15 13:50:24 +01:00
}
2019-07-22 11:16:50 +02:00
}
2020-03-16 14:09:46 +01:00
public confirmOpenFileDownloadError ( fileType : string ) {
2019-07-22 11:16:50 +02:00
this . alertCsvError . cancelButton = false ;
this . alertCsvError . okButton = true ;
2020-03-16 14:09:46 +01:00
this . alertCsvError . alertTitle = "ERROR DOWNLOADING " + fileType + " FILE" ;
2019-07-22 11:16:50 +02:00
this . alertCsvError . message = "There was an error in csv downloading. Please try again later." ;
this . alertCsvError . okButtonText = "OK" ;
this . alertCsvError . open ( ) ;
}
private handleError ( message : string , error ) {
console . error ( "Project Landing Page: " + message , error ) ;
}
isRouteAvailable ( routeToCheck : string ) {
2020-03-16 14:09:46 +01:00
for ( let i = 0 ; i < this . _router . config . length ; i ++ ) {
let routePath : string = this . _router . config [ i ] . path ;
2019-07-22 11:16:50 +02:00
if ( routePath == routeToCheck ) {
2019-06-12 16:13:56 +02:00
return true ;
}
}
return false ;
}
2020-05-19 01:40:14 +02:00
2020-05-19 17:59:20 +02:00
public getResultPreview ( result : SearchResult , type : string ) : ResultPreview {
return ResultPreview . searchResultConvert ( result , type ) ;
}
2021-09-08 14:21:30 +02:00
2020-05-20 22:48:32 +02:00
public scroll() {
HelperFunctions . scroll ( ) ;
}
2020-05-26 22:34:04 +02:00
2021-03-10 14:24:19 +01:00
public getParamsForSearchLink ( type : string = null , subtype : string = null ) {
2020-05-28 12:53:29 +02:00
if ( type ) {
2021-03-10 14:24:19 +01:00
if ( subtype ) {
return this . routerHelper . createQueryParams ( [ 'f0' , 'fv0' , 'type' , 'instancetypename' , 'qf' , 'sortBy' ] , [ 'relprojectid' , this . projectId , type , subtype , 'false' , 'resultdateofacceptance,descending' ] ) ;
} else {
return this . routerHelper . createQueryParams ( [ 'f0' , 'fv0' , 'type' , 'qf' , 'sortBy' ] , [ 'relprojectid' , this . projectId , type , 'false' , 'resultdateofacceptance,descending' ] ) ;
}
2020-05-28 12:53:29 +02:00
} else {
return this . routerHelper . createQueryParams ( [ 'f0' , 'fv0' ] , [ 'relprojectid' , this . projectId ] ) ;
}
}
2020-05-26 22:34:04 +02:00
public get hasPrimaryInfo ( ) : boolean {
2022-04-28 11:13:06 +02:00
return ! ! this . projectInfo && ( ! ! this . projectInfo . description && this . projectInfo . description . length > 0 ) ;
2020-05-26 22:34:04 +02:00
}
public get hasSecondaryInfo ( ) : boolean {
return ! ! this . projectInfo && (
( ! ! this . projectInfo . organizations && this . projectInfo . organizations . length > 0 )
) ;
}
2020-05-29 16:15:35 +02:00
// public get numberOfTabs(): number {
// if(this.tabsAreInitialized) {
// return this._numberOfTabs;
// }
//
// if(!this.projectInfo
// || this.fetchPublications.searchUtils.status == this.errorCodes.LOADING
// || this.fetchDatasets.searchUtils.status == this.errorCodes.LOADING
// || this.fetchSoftware.searchUtils.status == this.errorCodes.LOADING
// || this.fetchOrps.searchUtils.status == this.errorCodes.LOADING) {
// return 0;
// }
//
// if (this.hasPrimaryInfo || this.hasSecondaryInfo) {
// this.firstTab = "summary";
// this._numberOfTabs++;
// }
// if(this.fetchPublications.searchUtils.totalResults > 0 || this.fetchDatasets.searchUtils.totalResults > 0
// || this.fetchSoftware.searchUtils.totalResults > 0 || this.fetchOrps.searchUtils.totalResults > 0) {
// if(this.fetchPublications.searchUtils.totalResults > 0) {
// if(this._numberOfTabs == 0) {
// this.firstTab = 'publications';
// this.searchPublicationsInit();
// }
// this._numberOfTabs++;
// }
// if(this.fetchDatasets.searchUtils.totalResults > 0) {
// if(this._numberOfTabs == 0) {
// this.firstTab = 'datasets';
// this.searchDatasetsInit();
// }
// this._numberOfTabs++;
// }
// if(this.fetchSoftware.searchUtils.totalResults > 0) {
// if(this._numberOfTabs == 0) {
// this.firstTab = 'software';
// this.searchSoftwareInit();
// }
// this._numberOfTabs++;
// }
// if(this.fetchOrps.searchUtils.totalResults > 0) {
// if(this._numberOfTabs == 0) {
// this.firstTab = 'other';
// this.searchOrpsInit();
// }
// this._numberOfTabs++;
// }
// this._numberOfTabs++;
// }
// this.activeTab = this.firstTab;
// this.tabsAreInitialized = true;
// return this._numberOfTabs;
// }
2022-04-28 11:13:06 +02:00
public buildResultTypesForDownloading() {
this . resultTypesForDownloading = [
{ label : "All " + OpenaireEntities . RESULTS , value : "results" , disabled :
( ! this . projectInfo . funding ||
( this . fetchPublications . searchUtils . totalResults == 0 &&
this . fetchDatasets . searchUtils . totalResults == 0 &&
this . fetchSoftware . searchUtils . totalResults == 0 &&
this . fetchOrps . searchUtils . totalResults == 0 ) ) } ,
{ label : OpenaireEntities.PUBLICATIONS , value : "publications" , disabled :
( ! this . projectInfo . funding || this . fetchPublications . searchUtils . totalResults == 0
|| this . fetchPublications . searchUtils . status != this . errorCodes . DONE ) } ,
{ label : OpenaireEntities.DATASETS , value : "datasets" , disabled :
( ! this . projectInfo . funding || this . fetchDatasets . searchUtils . totalResults == 0
|| this . fetchDatasets . searchUtils . status != this . errorCodes . DONE ) } ,
{ label : OpenaireEntities.SOFTWARE , value : "software" , disabled :
( ! this . projectInfo . funding || this . fetchSoftware . searchUtils . totalResults == 0
|| this . fetchSoftware . searchUtils . status != this . errorCodes . DONE ) } ,
{ label : OpenaireEntities.OTHER , value : "other" , disabled :
( ! this . projectInfo . funding || this . fetchOrps . searchUtils . totalResults == 0
|| this . fetchOrps . searchUtils . status != this . errorCodes . DONE ) }
] ;
}
2022-09-21 12:32:21 +02:00
2023-02-23 12:09: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-02-23 12:09: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
}