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
|
|
|
import {Component, Input} from '@angular/core';
|
2017-12-19 13:53:46 +01:00
|
|
|
import {ActivatedRoute, Params, Router} from '@angular/router';
|
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
|
|
|
import {Title, Meta} from '@angular/platform-browser';
|
|
|
|
|
|
|
|
import {Observable} from 'rxjs/Observable';
|
|
|
|
|
|
|
|
import {EnvProperties} from '../../utils/properties/env-properties';
|
|
|
|
|
|
|
|
import {HtmlProjectReportService} from './htmlProjectReport.service';
|
|
|
|
import {ProjectService} from '../project/project.service';
|
|
|
|
import {PiwikService} from '../../utils/piwik/piwik.service';
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
declare var UIkit: any;
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'htmlProjectReport',
|
|
|
|
template: `
|
|
|
|
<div id="tm-main" class=" uk-section uk-margin-small-top tm-middle" >
|
|
|
|
<div uk-grid uk-grid>
|
|
|
|
<div class="tm-main uk-width-1-1@s uk-width-1-1@m uk-width-1-1@l uk-row-first ">
|
|
|
|
|
|
|
|
<div class="uk-container uk-margin-top">
|
|
|
|
<div *ngIf="warningMessage" class="uk-alert uk-alert-warning" role="alert">{{warningMessage}}</div>
|
2018-05-11 13:33:50 +02:00
|
|
|
<div [style.display]="showLoading ? 'inline' : 'none'" class="uk-animation-fade uk-margin-large-top uk-width-1-1" role="alert"><img class="loading-gif uk-align-center" ></div>
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
<div *ngIf="!showLoading && !warningMessage">
|
|
|
|
<h1 *ngIf="header1">{{header1}}</h1>
|
|
|
|
<h2 *ngIf="header1 || htmlResult">{{header2}}</h2>
|
|
|
|
|
|
|
|
<div class="uk-clearfix uk-margin-bottom">
|
|
|
|
<button *ngIf="htmlResult" class="uk-icon-clipboard uk-button uk-button-primary clipBtn uk-float-right" (click)="copied()">
|
|
|
|
Copy to clipboard
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<!--div class="uk-panel-scrollable custom-html-table-height" *ngIf="htmlResult" id="clipboard" [innerHTML]="htmlResult"></div-->
|
|
|
|
<div class="uk-overflow-auto custom-html-table-height" *ngIf="htmlResult" id="clipboard" [innerHTML]="htmlResult"></div>
|
|
|
|
|
|
|
|
<div *ngIf="errorMessage" class="uk-alert uk-alert-danger" role="alert">{{errorMessage}}</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
`
|
|
|
|
})
|
|
|
|
export class HtmlProjectReportComponent{
|
2018-04-11 10:59:01 +02:00
|
|
|
@Input() piwikSiteId = null;
|
2017-12-19 13:53:46 +01:00
|
|
|
private projectId: string;
|
|
|
|
private totalResults: number = 10;
|
|
|
|
private resultsType: string = "publication";
|
|
|
|
|
|
|
|
public header1: string = "";
|
|
|
|
public header2: string = "";
|
|
|
|
public htmlResult: string = "";
|
|
|
|
|
|
|
|
public sub: any; piwiksub: any;
|
|
|
|
public subHTML: any;
|
|
|
|
public subHTMLInfo: any;
|
|
|
|
|
|
|
|
public warningMessage: string = "";
|
|
|
|
public errorMessage: string = "";
|
|
|
|
public showLoading: boolean = true;
|
2018-02-05 14:14:59 +01:00
|
|
|
properties:EnvProperties;
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
constructor ( private route: ActivatedRoute,
|
|
|
|
private htmlService: HtmlProjectReportService,
|
|
|
|
private _piwikService:PiwikService,
|
|
|
|
private _projectService: ProjectService,
|
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
|
|
|
private _meta: Meta,
|
|
|
|
private _title: Title,
|
|
|
|
private _router: Router) {
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
2018-02-05 14:14:59 +01:00
|
|
|
this.route.data
|
|
|
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
|
|
|
this.properties = data.envSpecific;
|
|
|
|
this.updateUrl(data.envSpecific.baseLink+this._router.url);
|
|
|
|
|
|
|
|
});
|
2017-12-19 13:53:46 +01:00
|
|
|
this.sub = this.route.queryParams.subscribe(params => {
|
|
|
|
this.projectId = params['projectId'];
|
|
|
|
|
|
|
|
if (params['size'] == parseInt(params['size'], 10)) {
|
|
|
|
this.totalResults = params['size'];
|
|
|
|
} else {
|
|
|
|
this.showLoading = false;
|
|
|
|
this.warningMessage="Requested size is not an integer";
|
|
|
|
}
|
|
|
|
|
|
|
|
if(params['type'] && (params['type'] == "publication" || params['type'] == "dataset" || params['type'] == "software")){
|
|
|
|
if(params['type'] == "publication") {
|
|
|
|
this.resultsType = 'publication';
|
|
|
|
} else if(params['type'] == "dataset") {
|
|
|
|
this.resultsType = 'research data';
|
|
|
|
} else if(params['type'] == "software") {
|
|
|
|
this.resultsType = 'software';
|
|
|
|
}
|
|
|
|
|
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
|
|
|
var title = "Project's "+this.resultsType+" report";
|
|
|
|
var description = "project, project "+ this.resultsType +" report, funding, open access, publications, research data, software";
|
|
|
|
this.updateTitle(title);
|
|
|
|
this.updateDescription(description);
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
} else {
|
|
|
|
this.showLoading = false;
|
|
|
|
this.warningMessage="Requested type should be publication or research data or software";
|
|
|
|
}
|
|
|
|
|
|
|
|
//showLoading is true if no warnings
|
|
|
|
if(this.showLoading) {
|
|
|
|
if(this.projectId) {
|
|
|
|
this.createHeaders();
|
|
|
|
} else {
|
|
|
|
this.showLoading = false;
|
|
|
|
this.warningMessage="No valid project id";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnDestroy() {
|
|
|
|
this.sub.unsubscribe();
|
|
|
|
if(this.piwiksub){
|
|
|
|
this.piwiksub.unsubscribe();
|
|
|
|
}
|
|
|
|
if(this.subHTML) {
|
|
|
|
this.subHTML.unsubscribe();
|
|
|
|
}
|
|
|
|
if(this.subHTMLInfo) {
|
|
|
|
this.subHTMLInfo.unsubscribe();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private createHeaders() {
|
2018-02-05 14:14:59 +01:00
|
|
|
this.subHTMLInfo = this._projectService.getHTMLInfo(this.projectId, this.properties).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
|
|
|
this.createHeader1(data);
|
|
|
|
if(data.acronym) {
|
|
|
|
this.updateTitle(data.acronym+" "+this.resultsType+" report");
|
|
|
|
} else if(data.title){
|
|
|
|
this.updateTitle(data.title+" "+this.resultsType+" report");
|
|
|
|
}
|
2018-02-05 14:14:59 +01:00
|
|
|
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
|
2018-04-11 10:59:01 +02:00
|
|
|
this.piwiksub = this._piwikService.trackView(this.properties, ((data.acronym)?data.acronym:data.title)+" "+this.resultsType+" report", this.piwikSiteId).subscribe();
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
console.log(err);
|
|
|
|
this.createClipboard();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
if(this.resultsType == "publication") {
|
|
|
|
this.header2 += this.totalResults + " publications";
|
|
|
|
} else if(this.resultsType == "research data") {
|
|
|
|
this.header2 += this.totalResults + " research data";
|
|
|
|
} else if(this.resultsType == "software") {
|
|
|
|
this.header2 += this.totalResults + " software";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private createClipboard() {
|
|
|
|
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') {
|
2018-02-05 14:14:59 +01:00
|
|
|
this.subHTML = this.htmlService.getHTML(this.projectId, this.totalResults, this.resultsType, this.properties.csvAPIURL).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
2018-02-05 14:14:59 +01:00
|
|
|
//let body: string = intro+'<body><h1>'+this.header1+'</h1><h2>'+this.header2+'</h2>'+data+'</body></html>';
|
|
|
|
let body: string = intro+'<body><h1>'+this.header1+'</h1><h2>'+this.header2+'</h2>';
|
|
|
|
body += "<table><thead><tr> <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>";
|
|
|
|
body += '</body></html>';
|
|
|
|
|
|
|
|
//this.htmlResult = data;
|
|
|
|
this.htmlResult = "<table><thead><tr> <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>";
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
let clipboard;
|
|
|
|
let Clipboard;
|
|
|
|
Clipboard = require('clipboard');
|
|
|
|
clipboard = new Clipboard('.clipBtn', {
|
|
|
|
/*target: function(trigger) {
|
|
|
|
return document.getElementById("clipboard");
|
|
|
|
}*/
|
|
|
|
text: function(trigger) {
|
|
|
|
return body;//document.getElementById("clipboard").getAttribute('innerHTML');//"aaaa"+tmp+"oo";
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
this.showLoading = false;
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
console.log(err);
|
|
|
|
this.errorMessage = 'Service not available';
|
|
|
|
this.showLoading = false;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
createHeader1(data: {"title": string, "acronym": string, "callIdentifier": string}) {
|
|
|
|
if(this.resultsType == "publication") {
|
|
|
|
this.header1 += "Publications";
|
|
|
|
} else if(this.resultsType == "research data") {
|
|
|
|
this.header1 += "Research Data";
|
|
|
|
} else if(this.resultsType == "software") {
|
|
|
|
this.header1 += "Software";
|
|
|
|
}
|
|
|
|
|
|
|
|
if(data != undefined) {
|
|
|
|
if(data.title != undefined && data.title != "") {
|
|
|
|
this.header1 += data.title;
|
|
|
|
}
|
|
|
|
if((data.title != undefined && data.title != "") &&
|
|
|
|
((data.acronym != undefined && data.acronym != "") ||
|
|
|
|
(data.callIdentifier != undefined && data.callIdentifier != ""))) {
|
|
|
|
this.header1 += "(";
|
|
|
|
}
|
|
|
|
if(data.acronym != undefined && data.acronym != "") {
|
|
|
|
this.header1 += data.acronym + " - ";
|
|
|
|
}
|
|
|
|
if(data.callIdentifier != undefined && data.callIdentifier != "") {
|
|
|
|
this.header1 += data.callIdentifier;
|
|
|
|
}
|
|
|
|
if((data.title != undefined && data.title != "") &&
|
|
|
|
((data.acronym != undefined && data.acronym != "") ||
|
|
|
|
(data.callIdentifier != undefined && data.callIdentifier != ""))) {
|
|
|
|
this.header1 += ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.createClipboard();
|
|
|
|
}
|
|
|
|
|
|
|
|
public copied() {
|
|
|
|
UIkit.notification({
|
|
|
|
message : '<strong>Raw html is copied. Please paste it on an html file.<strong>',
|
|
|
|
status : 'success',
|
|
|
|
timeout : 3000,
|
|
|
|
pos : 'top-center'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private updateDescription(description:string){
|
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
|
|
|
this._meta.updateTag({content:description},"name='description'");
|
|
|
|
this._meta.updateTag({content:description},"property='og:description'");
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
private updateTitle(title:string){
|
|
|
|
var _prefix ="OpenAIRE | ";
|
|
|
|
var _title = _prefix + ((title.length> 50 ) ?title.substring(0,50):title);
|
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
|
|
|
this._title.setTitle(_title);
|
|
|
|
this._meta.updateTag({content:_title},"property='og:title'");
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
private updateUrl(url:string){
|
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
|
|
|
this._meta.updateTag({content:url},"property='og:url'");
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
}
|