2022-03-16 17:54:22 +01:00
import { ChangeDetectorRef , Component , Input , ViewChild } from '@angular/core' ;
2019-07-23 14:23:12 +02:00
import { ActivatedRoute , Router } from '@angular/router' ;
import { Meta , Title } from '@angular/platform-browser' ;
import { EnvProperties } from '../../utils/properties/env-properties' ;
import { ClaimEntity , ShowOptions } from '../claim-utils/claimHelper.class' ;
import { EntitiesSearchService } from '../../utils/entitiesAutoComplete/entitySearch.service' ;
import { SEOService } from '../../sharedComponents/SEO/SEO.service' ;
import { AlertModal } from "../../utils/modal/alert" ;
import { HelperFunctions } from "../../utils/HelperFunctions.class" ;
2019-07-24 17:46:49 +02:00
import { HelperService } from "../../utils/helper/helper.service" ;
2019-08-02 16:55:32 +02:00
import { PiwikService } from "../../utils/piwik/piwik.service" ;
2020-11-11 15:43:13 +01:00
import { Subscriber } from "rxjs" ;
2020-11-18 17:06:27 +01:00
import { properties } from "../../../../environments/environment" ;
2022-02-25 13:52:36 +01:00
import { Breadcrumb } from "../../utils/breadcrumbs/breadcrumbs.component" ;
2022-03-16 17:54:22 +01:00
import { MetricsService } from "../../services/metrics.service" ;
[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
import { OpenaireEntities } from "../../utils/properties/searchFields" ;
2018-02-05 14:14:59 +01:00
2017-12-19 13:53:46 +01:00
declare var UIkit :any ;
@Component ( {
selector : 'linking-generic' ,
2022-03-02 17:08:37 +01:00
templateUrl : 'linkingGeneric.component.html' ,
2022-04-05 17:36:08 +02:00
styleUrls : [ 'linkingGeneric.component.css' ]
2017-12-19 13:53:46 +01:00
} )
export class LinkingGenericComponent {
2019-08-02 16:55:32 +02:00
@Input ( ) piwikSiteId = null ;
2020-08-19 12:16:43 +02:00
@Input ( ) pageTitle : string = " Create links between research objects" ;
2019-08-02 16:55:32 +02:00
piwiksub :any ;
2018-07-06 15:35:03 +02:00
@Input ( ) communityId :string = null ;
2017-12-19 13:53:46 +01:00
sourceType :string ;
targetType :string ;
step :number = 1 ;
2019-07-23 14:23:12 +02:00
@Input ( ) results :ClaimEntity [ ] = [ ] ;
@Input ( ) inlineEntity :ClaimEntity = null ;
2019-07-24 14:46:29 +02:00
basketLimit = 100 ;
2019-07-23 14:23:12 +02:00
@Input ( ) showOptions :ShowOptions = new ShowOptions ( ) ;
//show values: source, result, project, context, claim
// linkTo /values: result, project, context
// show linkToEntities /values: result, project, context
@Input ( ) sources :ClaimEntity [ ] = [ ] ;
2018-02-05 14:14:59 +01:00
properties :EnvProperties ;
[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
public openaireEntities = OpenaireEntities ;
2019-07-23 14:23:12 +02:00
@Input ( ) localStoragePrefix :string = "linking_" ;
2018-11-14 11:38:53 +01:00
url = null ;
2019-07-23 14:23:12 +02:00
@ViewChild ( AlertModal ) alert ;
2019-07-24 17:46:49 +02:00
public pageContents = null ;
2022-02-25 13:52:36 +01:00
@Input ( ) breadcrumbs : Breadcrumb [ ] = [ ] ;
2018-02-05 14:14:59 +01:00
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
constructor ( private _router : Router , private route : ActivatedRoute , private entitySearch :EntitiesSearchService ,
2019-08-02 16:55:32 +02:00
private _meta : Meta , private _title : Title , private _piwikService :PiwikService ,
2022-03-16 17:54:22 +01:00
private seoService : SEOService , private helper : HelperService , private cdr : ChangeDetectorRef ) {
2017-12-19 13:53:46 +01:00
}
2020-11-11 15:43:13 +01:00
subscriptions = [ ] ;
2017-12-19 13:53:46 +01:00
ngOnInit() {
2022-02-25 13:52:36 +01:00
if ( this . breadcrumbs . length === 0 ) {
this . breadcrumbs . push ( { name : 'home' , route : '/' } ) ;
this . breadcrumbs . push ( { name : "Link" , route : null } ) ;
}
2019-07-23 14:23:12 +02:00
this . showOptions . show = 'source' ;
2022-04-08 15:55:22 +02:00
this . showOptions . initSelectOptions ( ) ;
2019-07-23 14:23:12 +02:00
if ( this . inlineEntity ) {
2022-03-16 17:54:22 +01:00
this . showOptions . showLinkTo ( ) ;
// this.showOptions.basketShowLinksTo = true;
2019-07-23 14:23:12 +02:00
this . showOptions . show = this . showOptions . linkTo ;
}
2020-11-18 17:06:27 +01:00
this . properties = properties ;
this . url = this . properties . domain + this . properties . baseLink + this . _router . url ;
2019-08-02 16:55:32 +02:00
2020-08-19 12:16:43 +02:00
var description = "Linking is a functionality provided by OpenAIRE, in order to link research results with a project, a research community or other research results." ;
2019-08-27 15:19:58 +02:00
this . updateTitle ( this . pageTitle ) ;
2019-08-02 16:55:32 +02:00
this . updateDescription ( description ) ;
this . updateUrl ( this . url ) ;
this . seoService . createLinkForCanonicalURL ( this . url , false ) ;
if ( this . properties . enablePiwikTrack && ( typeof document !== 'undefined' ) ) {
2020-11-11 15:43:13 +01:00
this . subscriptions . push ( this . _piwikService . trackView ( this . properties , this . pageTitle , this . piwikSiteId ) . subscribe ( ) ) ;
2019-08-02 16:55:32 +02:00
}
2020-04-07 13:15:28 +02:00
this . helper . getPageHelpContents ( this . properties , this . communityId , this . _router . url ) . subscribe ( contents = > {
2019-07-24 17:46:49 +02:00
this . pageContents = contents ;
} )
2018-02-05 14:14:59 +01:00
2020-11-18 17:06:27 +01:00
2017-12-19 13:53:46 +01:00
if ( typeof localStorage !== 'undefined' ) {
2019-07-23 14:23:12 +02:00
this . localStoragePrefix += ( this . communityId ? this . communityId + "_" : "" ) ;
2018-07-25 15:56:02 +02:00
if ( localStorage . getItem ( this . localStoragePrefix + "results" ) ) {
this . results = JSON . parse ( localStorage . getItem ( this . localStoragePrefix + "results" ) ) ;
2017-12-19 13:53:46 +01:00
}
2019-07-23 14:23:12 +02:00
if ( localStorage . getItem ( this . localStoragePrefix + "sources" ) ) {
this . sources = JSON . parse ( localStorage . getItem ( this . localStoragePrefix + "sources" ) ) ;
}
2017-12-19 13:53:46 +01:00
}
}
2019-08-02 16:55:32 +02:00
ngOnDestroy() {
2020-11-11 15:43:13 +01:00
this . subscriptions . forEach ( subscription = > {
if ( subscription instanceof Subscriber ) {
subscription . unsubscribe ( ) ;
}
} ) ;
2019-08-02 16:55:32 +02:00
}
2019-07-23 14:23:12 +02:00
openSelectionModal() {
this . alert . cancelButton = false ;
this . alert . okButton = false ;
this . alert . alertTitle = "Select the type of Entity to Link to your sources" ;
// this.alert.message = "<div>All the links you provided will be published in the OpenAIRE platform. " +
// "<br>Make sure you have checked all the information you provided. In some cases some links take more time to be published. " +
// "<br>For more information please check the linking status in My-Links page. " +
// "<br><br>Do you confirm the information you provide are valid?</div>";
2017-12-19 13:53:46 +01:00
2019-07-23 14:23:12 +02:00
this . alert . open ( ) ;
2017-12-19 13:53:46 +01:00
}
2019-07-23 14:23:12 +02:00
closeSelectionModal ( show :string = null ) {
if ( show ) {
this . showOptions . show = show ;
this . showOptions . basketShowSources = false ;
this . showOptions . basketShowLinksTo = true ;
2017-12-19 13:53:46 +01:00
}
2019-07-23 14:23:12 +02:00
this . alert . cancel ( ) ;
this . scrollUp ( ) ;
2017-12-19 13:53:46 +01:00
}
2019-07-23 14:23:12 +02:00
scrollUp ( ) {
HelperFunctions . scroll ( ) ;
2019-08-02 16:55:32 +02:00
}
2017-12-19 13:53:46 +01:00
2019-08-02 16:55:32 +02:00
private updateDescription ( description :string ) {
this . _meta . updateTag ( { content :description } , "name='description'" ) ;
this . _meta . updateTag ( { content :description } , "property='og:description'" ) ;
}
private updateTitle ( title :string ) {
var _prefix = "" ;
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'" ) ;
}
private updateUrl ( url :string ) {
this . _meta . updateTag ( { content :url } , "property='og:url'" ) ;
2017-12-19 13:53:46 +01:00
}
2022-03-16 17:54:22 +01:00
stepHasChanged ( stepId ) {
if ( stepId == 'source' ) {
console . log ( "show source" )
this . showOptions . showSource ( ) ;
} else if ( stepId == 'target' ) {
console . log ( "show target" )
this . showOptions . show = this . showOptions . linkTo ;
this . showOptions . showLinkTo ( ) ;
} else if ( stepId == 'claim' ) {
console . log ( "show target" )
this . showOptions . show = 'claim' ;
}
this . cdr . detectChanges ( ) ;
console . log ( 'stepHasChanged' , stepId , this . showOptions . show )
}
stepStatus ( stepId ) {
if ( stepId == 'source' ) {
if ( this . showOptions . show == 'source' ) {
return 'active' ;
} else if ( this . sources . length > 0 ) {
return 'done' ;
} else {
return 'default' ;
}
} else if ( stepId == 'target' ) {
if ( this . showOptions . show != 'source' && this . showOptions . show != 'claim' ) {
return 'active' ;
} else if ( this . results . length > 0 ) {
return 'done' ;
2022-04-19 15:25:24 +02:00
} else if ( this . sources . length == 0 && ! this . inlineEntity ) {
2022-03-16 17:54:22 +01:00
return 'disabled' ;
} else {
return 'default' ;
}
} else if ( stepId == 'claim' ) {
if ( this . showOptions . show == 'claim' ) {
return 'active' ;
} else if ( this . results . length > 0 && ( this . inlineEntity || this . sources . length > 0 ) ) {
return 'default' ;
} else if ( ! ( this . results . length > 0 && ( this . inlineEntity || this . sources . length > 0 ) ) ) {
return 'disabled' ;
}
}
}
2017-12-19 13:53:46 +01:00
}