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" ;
[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" ;
2023-02-15 22:56:16 +01:00
import { StringUtils } from "../../utils/string-utils.class" ;
import { RouterHelper } from "../../utils/routerHelper.class" ;
2023-05-11 21:46:28 +02:00
import { Location } from '@angular/common' ;
2023-08-03 12:02:59 +02:00
import { LoginErrorCodes } from "../../login/utils/guardHelper.class" ;
import { UserManagementService } from "../../services/user-management.service" ;
2024-05-09 15:44:54 +02:00
import { ClaimsProperties } from "../claim-utils/claims.properties" ;
2018-02-05 14:14:59 +01:00
2017-12-19 13:53:46 +01:00
@Component ( {
selector : 'linking-generic' ,
2022-07-17 15:01:39 +02:00
templateUrl : 'linkingGeneric.component.html'
2017-12-19 13:53:46 +01:00
} )
export class LinkingGenericComponent {
2022-07-18 17:56:59 +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 [ ] = [ ] ;
2024-05-22 13:48:13 +02:00
properties :EnvProperties = properties ;
[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 [ ] = [ ] ;
2023-02-15 22:56:16 +01:00
public routerHelper : RouterHelper = new RouterHelper ( ) ;
2024-05-10 10:33:42 +02:00
@Input ( ) claimsProperties :ClaimsProperties = new ClaimsProperties ( ) ;
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 ,
2023-05-11 21:46:28 +02:00
private seoService : SEOService , private helper : HelperService , private cdr : ChangeDetectorRef ,
2023-08-03 12:02:59 +02:00
private location : Location , private userManagementService : UserManagementService ) {
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() {
2024-05-09 15:44:54 +02:00
/ * i f ( ! t h i s . c l a i m s P r o p e r t i e s ) {
this . claimsProperties = new ClaimsProperties ( ) ;
} * /
2023-08-03 12:02:59 +02:00
this . subscriptions . push ( this . userManagementService . getUserInfo ( ) . subscribe ( user = > {
if ( ! user ) {
this . saveStateAndRedirectLogin ( ) ;
}
} ) ) ;
if ( this . breadcrumbs . length === 0 ) {
2022-02-25 13:52:36 +01:00
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' ;
2024-05-22 13:48:13 +02:00
this . showOptions . initSelectOptions ( this . claimsProperties ) ;
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 . 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 ) ;
2023-07-12 14:05:25 +02:00
this . subscriptions . push ( this . _piwikService . trackView ( this . properties , this . pageTitle ) . subscribe ( ) ) ;
2019-08-02 16:55:32 +02:00
2024-02-08 13:19:26 +01:00
if ( properties . adminToolsPortalType !== "explore" ) {
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 ;
} )
2024-02-08 13:19:26 +01:00
}
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" ) ) ;
}
2023-08-03 11:45:39 +02:00
if ( localStorage . getItem ( this . localStoragePrefix + "claimsJob" ) ) {
let job = JSON . parse ( localStorage . getItem ( this . localStoragePrefix + "claimsJob" ) ) ;
if ( job . status != "COMPLETE" ) {
this . showOptions . show = 'claim' ; }
}
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' ) {
2024-02-08 13:19:26 +01:00
// console.log("show source")
2022-03-16 17:54:22 +01:00
this . showOptions . showSource ( ) ;
} else if ( stepId == 'target' ) {
2024-02-08 13:19:26 +01:00
// console.log("show target")
2022-03-16 17:54:22 +01:00
this . showOptions . show = this . showOptions . linkTo ;
this . showOptions . showLinkTo ( ) ;
} else if ( stepId == 'claim' ) {
2024-02-08 13:19:26 +01:00
// console.log("show target")
2022-03-16 17:54:22 +01:00
this . showOptions . show = 'claim' ;
}
this . cdr . detectChanges ( ) ;
2023-02-15 22:56:16 +01:00
HelperFunctions . scroll ( true ) ;
2024-02-08 13:19:26 +01:00
// console.log('stepHasChanged', stepId, this.showOptions.show)
2022-03-16 17:54:22 +01:00
}
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' ;
}
}
}
2023-02-15 22:56:16 +01:00
private getEntityName ( entityType :string , plural :boolean ) {
return StringUtils . getEntityName ( entityType , plural ) ;
}
2023-05-11 21:46:28 +02:00
back ( ) : void {
if ( typeof document !== 'undefined' ) {
this . location . back ( ) ;
}
}
2023-08-03 12:02:59 +02:00
saveStateAndRedirectLogin() {
if ( this . results != null ) {
localStorage . setItem ( this . localStoragePrefix + "results" , JSON . stringify ( this . results ) ) ;
}
if ( this . sources != null ) {
localStorage . setItem ( this . localStoragePrefix + "sources" , JSON . stringify ( this . sources ) ) ;
}
this . _router . navigate ( [ '/user-info' ] , {
queryParams : {
"errorCode" : LoginErrorCodes . NOT_VALID ,
"redirectUrl" : this . _router . url
}
} ) ;
}
2017-12-19 13:53:46 +01:00
}