2019-07-23 14:23:12 +02:00
|
|
|
import {Component, Input, ViewChild} from '@angular/core';
|
|
|
|
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";
|
2018-02-05 14:14:59 +01:00
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
declare var UIkit:any;
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'linking-generic',
|
|
|
|
templateUrl: 'linkingGeneric.component.html'
|
|
|
|
|
|
|
|
})
|
|
|
|
export class LinkingGenericComponent {
|
2019-08-02 16:55:32 +02:00
|
|
|
@Input() piwikSiteId = null;
|
2019-08-27 15:19:58 +02:00
|
|
|
@Input() pageTitle: string = null;
|
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[] =[];
|
2017-12-19 13:53:46 +01:00
|
|
|
sub:any =null;
|
2018-02-05 14:14:59 +01:00
|
|
|
properties:EnvProperties;
|
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;
|
2019-07-23 14:23:12 +02:00
|
|
|
|
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,
|
|
|
|
private seoService: SEOService, private helper: HelperService ) {
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
ngOnInit() {
|
2019-07-23 14:23:12 +02:00
|
|
|
this.showOptions.show = 'source';
|
|
|
|
if(this.inlineEntity){
|
|
|
|
this.showOptions.basketShowSources = false;
|
|
|
|
this.showOptions.basketShowLinksTo = true;
|
|
|
|
this.showOptions.show = this.showOptions.linkTo;
|
|
|
|
}
|
2018-02-05 14:14:59 +01:00
|
|
|
this.route.data
|
|
|
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
|
|
|
this.properties = data.envSpecific;
|
2018-11-14 11:38:53 +01:00
|
|
|
this.url = data.envSpecific.baseLink+this._router.url;
|
2019-08-02 16:55:32 +02:00
|
|
|
|
|
|
|
var description = "Openaire, linking, claim, publication, research data, software, other research product, project, community";
|
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')){
|
2019-08-27 15:19:58 +02:00
|
|
|
this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, this.piwikSiteId).subscribe();
|
2019-08-02 16:55:32 +02:00
|
|
|
}
|
|
|
|
|
2019-07-24 17:46:49 +02:00
|
|
|
this.helper.getPageHelpContents(this._router.url, this.properties, this.communityId).subscribe(contents => {
|
|
|
|
this.pageContents = contents;
|
|
|
|
})
|
2018-02-05 14:14:59 +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() {
|
|
|
|
if(this.piwiksub){
|
|
|
|
this.piwiksub.unsubscribe();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|