diff --git a/portal-2/package.json b/portal-2/package.json index f5b885b2..11bcd2c1 100644 --- a/portal-2/package.json +++ b/portal-2/package.json @@ -52,11 +52,13 @@ "@angular/upgrade": "~2.1.2", "@angularclass/bootloader": "~1.0.1", "@angularclass/idle-preload": "~1.0.4", + "@types/clipboard": "^1.5.31", "angular2-express-engine": "~2.1.0-rc.1", "angular2-platform-node": "~2.1.0-rc.1", "angular2-universal": "~2.1.0-rc.1", "angular2-universal-polyfills": "~2.1.0-rc.1", "body-parser": "^1.15.2", + "clipboard": "^1.5.16", "compression": "^1.6.2", "express": "^4.14.0", "js.clone": "0.0.3", @@ -98,7 +100,7 @@ "ts-helpers": "^1.1.2", "ts-node": "^1.3.0", "typescript": "2.0.2", - "uglify-js" : "^2.7.4", + "uglify-js": "^2.7.4", "v8-lazy-parse-webpack-plugin": "^0.3.0", "webpack": "2.1.0-beta.27", "webpack-bundle-analyzer": "1.4.1", diff --git a/portal-2/src/app/landingPages/dataProvider/tabs.component.ts b/portal-2/src/app/landingPages/dataProvider/tabs.component.ts index b407e981..b06879bc 100644 --- a/portal-2/src/app/landingPages/dataProvider/tabs.component.ts +++ b/portal-2/src/app/landingPages/dataProvider/tabs.component.ts @@ -137,7 +137,6 @@ import {OpenaireProperties} from '../../utils/properties/openaireProperties'; - @@ -146,8 +145,8 @@ import {OpenaireProperties} from '../../utils/properties/openaireProperties'; [paramsForSearchLink]="paramsForSearchLink" [searchDataprovidersComponent]="searchDataprovidersComponent"> - - [organizations]="organizations" + diff --git a/portal-2/src/app/landingPages/dataset/dataset.component.html b/portal-2/src/app/landingPages/dataset/dataset.component.html index 3c07416f..5d4aa9fd 100644 --- a/portal-2/src/app/landingPages/dataset/dataset.component.html +++ b/portal-2/src/app/landingPages/dataset/dataset.component.html @@ -111,11 +111,22 @@
  • -
    Share - Bookmark
    +
    Share - Bookmark
  • +
  • +
    +
    +
    + + + +
    +
    +
  • Collected from
    diff --git a/portal-2/src/app/landingPages/landing-routing.module.ts b/portal-2/src/app/landingPages/landing-routing.module.ts index bfa9ecac..ec8c4fdd 100644 --- a/portal-2/src/app/landingPages/landing-routing.module.ts +++ b/portal-2/src/app/landingPages/landing-routing.module.ts @@ -8,6 +8,8 @@ import { DatasetComponent } from './dataset/dataset.component'; import { PublicationComponent } from './publication/publication.component'; import { DataProviderComponent } from './dataProvider/dataProvider.component' +import { HtmlProgressReportComponent } from './project/htmlProgressReport.component'; + @NgModule({ imports: [ RouterModule.forChild([ @@ -17,7 +19,7 @@ import { DataProviderComponent } from './dataProvider/dataProvider.component' { path: 'search/dataset', component: DatasetComponent }, { path: 'search/publication', component: PublicationComponent }, { path: 'search/dataprovider', component: DataProviderComponent}, - + { path: 'openaire', component: HtmlProgressReportComponent} ]) ] }) diff --git a/portal-2/src/app/landingPages/landing.module.ts b/portal-2/src/app/landingPages/landing.module.ts index 032a99e6..bbbb7c56 100644 --- a/portal-2/src/app/landingPages/landing.module.ts +++ b/portal-2/src/app/landingPages/landing.module.ts @@ -34,6 +34,7 @@ import { PublicationComponent } from './publication/publication.component'; import { LandingRoutingModule } from './landing-routing.module'; +import { HtmlProgressReportComponent } from './project/htmlProgressReport.component'; @NgModule({ imports: [ //MaterialModule.forRoot(), @@ -48,11 +49,13 @@ import { LandingRoutingModule } from './landing-routing.module'; TabPagingComponent, TabTableComponent, ShowTitleComponent, ShowAuthorsComponent,ShowIdentifiersComponent,ShowSubjectsComponent, MetricsComponent, PublicationsTabComponent, DatasetsTabComponent, StatisticsTabComponent, ProjectsTabComponent, DatasourcesTabComponent, OrganizationsTabComponent, RelatedDatasourcesTabComponent, TabsComponent, DataProviderComponent, PersonComponent, ProjectComponent, PublicationComponent, OrganizationComponent, DatasetComponent, + HtmlProgressReportComponent ], providers:[ ], exports: [ DataProviderComponent, PersonComponent, ProjectComponent, PublicationComponent, OrganizationComponent, DatasetComponent, + HtmlProgressReportComponent ] }) export class LandingModule { } diff --git a/portal-2/src/app/landingPages/project/htmlProgressReport.component.ts b/portal-2/src/app/landingPages/project/htmlProgressReport.component.ts new file mode 100644 index 00000000..a1ed5087 --- /dev/null +++ b/portal-2/src/app/landingPages/project/htmlProgressReport.component.ts @@ -0,0 +1,130 @@ +import {Component} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {ActivatedRoute, Params} from '@angular/router'; +import {isBrowser, isNode} from 'angular2-universal'; +import {HtmlProgressReportService} from '../../services/htmlProgressReport.service'; +import {ProjectService} from '../../services/project.service'; + +@Component({ + selector: 'htmlProgressReport', + template: ` +
    + + +
    +

    Raw html is copied. Please paste it on an html file.

    +
    + +

    {{header1}}

    +

    {{header2}}

    +
    +
    + ` + }) +export class HtmlProgressReportComponent{ + public projectId: string; + public totalResults: number; + + public header1: string; + public header2: string; + public htmlResult: string = ""; + + public sub; + public subHTML; + public subHTMLInfo; + + public copied: boolean = false; + + constructor ( private route: ActivatedRoute, + private htmlService: HtmlProgressReportService, + private _projectService: ProjectService) { + } + + ngOnInit() { + this.sub = this.route.queryParams.subscribe(params => { + this.projectId = params['projectId']; + this.totalResults = params['size']; + + this.createHeaders(); + this.createClipboard(); + }); + } + + ngOnDestroy() {} + + createHeaders() { + this._projectService.getHTMLInfo(this.projectId).subscribe( + data => { + this.createHeader1(data); + }, + err => { + console.log(err); + } + ); + + this.header2 = this.totalResults+" publications"; + } + + createClipboard() { + let intro: string = ''; + intro += ''; + intro += ''; + intro += ''+this.header1+'' + intro += ''; + intro += ''; + + if (typeof window !== 'undefined') { + this.htmlService.getHTML(this.projectId, this.totalResults).subscribe( + data => { + let body: string = intro+'

    '+this.header1+'

    '+this.header2+'

    '+data+''; + + this.htmlResult = data; + + let clipboard; + let Clipboard; + Clipboard = require('clipboard'); + clipboard = new Clipboard('.btn', { + /*target: function(trigger) { + return document.getElementById("clipboard"); + }*/ + text: function(trigger) { + return body;//document.getElementById("clipboard").getAttribute('innerHTML');//"aaaa"+tmp+"oo"; + } + }); + }, + err => { + console.log(err); + } + ); + } + } + + createHeader1(data: {"title": string, "acronym": string, "callIdentifier": string}) { + console.info(data); + this.header1 = "Publications of Project "; + + 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 += ")"; + } + } + } +} diff --git a/portal-2/src/app/landingPages/project/project.component.html b/portal-2/src/app/landingPages/project/project.component.html index d0b7c11e..94ef3fd3 100644 --- a/portal-2/src/app/landingPages/project/project.component.html +++ b/portal-2/src/app/landingPages/project/project.component.html @@ -162,16 +162,19 @@
  • +
  • - + View {{projectInfo.funder}} progress report (HTML) - +
  • @@ -409,6 +404,9 @@
+ + diff --git a/portal-2/src/app/services/htmlProgressReport.service.ts b/portal-2/src/app/services/htmlProgressReport.service.ts new file mode 100644 index 00000000..f213aa40 --- /dev/null +++ b/portal-2/src/app/services/htmlProgressReport.service.ts @@ -0,0 +1,27 @@ +import {Injectable} from '@angular/core'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import {OpenaireProperties} from '../utils/properties/openaireProperties'; +import 'rxjs/add/operator/do'; +import { CacheService } from '../shared/cache.service'; +@Injectable() +export class HtmlProgressReportService { + + constructor(private http: Http, public _cache: CacheService) {} + + getHTML(id: string, size: number):any { + console.info("getHTML in service"); + //let url = OpenaireProperties. getSearchAPIURLLast() + 'publications/' +id+"?format=json"; + let url = OpenaireProperties.getCsvAPIURL(); + url += 'resources?format=html&page=0&size='+size+'&type=publications&query=(((oaftype exact result) and (resulttypeid exact publication)) and (relprojectid exact "'+id+'"))'; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + return this.http.get(url) + .map(res => res.text()) + .do(res => { + this._cache.set(key, res); + }); + } +} diff --git a/portal-2/src/app/services/project.service.ts b/portal-2/src/app/services/project.service.ts index c3f29260..3c9ddf04 100644 --- a/portal-2/src/app/services/project.service.ts +++ b/portal-2/src/app/services/project.service.ts @@ -44,20 +44,43 @@ export class ProjectService { let url = OpenaireProperties. getSearchAPIURLLast()+'projects/'+id+"?format=json"; let key = url+'_projectDates'; if (this._cache.has(key)) { - return Observable.of(this._cache.get(key)).map(res => this.parseProjectDates(id,res)) + return Observable.of(this._cache.get(key)) + .map(res => [res, + res['fundingtree'], + res['rels']['rel']]) + .map(res => this.parseProjectDates(id,res)) } return this.http.get(url) .map(res => res.json()) .map(res => res['result']['metadata']['oaf:entity']['oaf:project']) - .map(res => [res, - res['fundingtree'], - res['rels']['rel']]) .do(res => { this._cache.set(key, res); }) + .map(res => [res, + res['fundingtree'], + res['rels']['rel']]) .map(res => this.parseProjectDates(id,res)) } + + getHTMLInfo(id: string): any { + console.info("getHTMLInfo in service"); + + let url = OpenaireProperties. getSearchAPIURLLast() + 'projects/'+id+"?format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)) + .map(res => this.parseHTMLInfo(res)); + } + return this.http.get(url) + .map(res => res.json()) + .map(res => res['result']['metadata']['oaf:entity']['oaf:project']) + .do(res => { + this._cache.set(key, res); + }) + .map(res => this.parseHTMLInfo(res)); + } + private handleError (error: Response) { // in a real world app, we may send the error to some remote logging infrastructure // instead of just logging it to the console @@ -65,6 +88,16 @@ export class ProjectService { return Observable.throw(error || 'Server error'); } + parseHTMLInfo (data: any):any { + let htmlInfo: {"title": string, "acronym": string, "callIdentifier": string}; + + if(data != null) { + htmlInfo = {"title": data.title, "acronym": data.acronym, "callIdentifier": data.callidentifier}; + } + console.info(htmlInfo); + return htmlInfo; + } + parseProjectInfo (data: any):any { this.projectInfo = new ProjectInfo(); @@ -120,7 +153,6 @@ export class ProjectService { if(data[2].hasOwnProperty("to") && name != "") { url = OpenaireProperties.getsearchLinkToOrganization()+data[2]['to'].content; - console.info("data[2]['to'].content: "+data[2]['to'].content); } if(name != "") { this.projectInfo.organizations.set(name, url); @@ -136,7 +168,6 @@ export class ProjectService { if(data[2][i].hasOwnProperty("to") && name!="") { url = OpenaireProperties.getsearchLinkToOrganization()+data[2][i]['to'].content; - console.info("data[2]["+i+"]['to'].content: "+data[2][i]['to'].content); } if(name != "") { diff --git a/portal-2/src/app/services/reports.service.ts b/portal-2/src/app/services/reports.service.ts index ede3ad0e..7d02f39b 100644 --- a/portal-2/src/app/services/reports.service.ts +++ b/portal-2/src/app/services/reports.service.ts @@ -19,12 +19,24 @@ export class ReportsService { return this.http.get(url) .map(res => new Blob([res['_body']], { type: 'text/csv' })); } - downloadHTMLFile(url: string){ + downloadHTMLFile(url: string, info: string){ var headers = new Headers(); headers.append('responseType', 'arraybuffer'); - return this.http.get(url).do(res => console.log(res['_body'])) - .map(res => new Blob([res['_body']], { type: 'text/html' })) - .do(res => console.log(res)) + return this.http.get(url)//.do(res => console.log(res['_body'])) + .map(res => this.addInfo(res, info)) + .map(res => new Blob([res['_body']], { type: 'text/html' })) + .do(res => console.log(res)) + } + + addInfo(res:any, info:string) { + /* + var para = res.document.createElement("P"); // Create a

element + var t = res.document.createTextNode("This is a paragraph"); // Create a text node + para.appendChild(t); // Append the text to

+ res.document.body.appendChild(para); + */ + res['_body'] = info+res['_body']; + return res; } private handleError (error: Response) { diff --git a/portal-2/src/app/services/services.module.ts b/portal-2/src/app/services/services.module.ts index 005f00e3..44e3270e 100644 --- a/portal-2/src/app/services/services.module.ts +++ b/portal-2/src/app/services/services.module.ts @@ -30,7 +30,7 @@ import {ReportsService} from './reports.service' import {LoginService} from './login.service'; - +import {HtmlProgressReportService} from './htmlProgressReport.service'; @NgModule({ imports: [ CommonModule, FormsModule @@ -47,7 +47,8 @@ import {LoginService} from './login.service'; RefineFieldResultsService, EntitiesSearchService, LoginService, - ReportsService + ReportsService, + HtmlProgressReportService ], exports: [ ] diff --git a/portal-2/src/app/test/test.component.ts b/portal-2/src/app/test/test.component.ts index f7faad12..1023eb2d 100644 --- a/portal-2/src/app/test/test.component.ts +++ b/portal-2/src/app/test/test.component.ts @@ -18,7 +18,7 @@ import {SearchFields} from '../utils/properties/searchFields'; @Component({ selector: 'test', template: ` - + @@ -184,9 +184,10 @@ public ready:boolean = false; //On the component //http://beta.services.openaire.eu:8480/search/rest/v2/api/publications?format=csv&page=0&size=3&q=(%22test%22)&fq=instancetypename%20exact%20%22Dataset%22" downloadfile(){ - this._reportsService.downloadHTMLFile("http://beta.services.openaire.eu:8480/search/rest/v2/api/publications?format=html&page=0&size=3&q=(%22test%22)&fq=instancetypename%20exact%20%22Dataset%22") +/* this._reportsService.downloadHTMLFile("http://beta.services.openaire.eu:8480/search/rest/v2/api/publications?format=html&page=0&size=3&q=(%22test%22)&fq=instancetypename%20exact%20%22Dataset%22") .subscribe(data => window.open(window.URL.createObjectURL(data)), error => console.log("Error downloading the file."), () => console.log('Completed file download.')); +*/ } } diff --git a/portal-2/src/app/utils/altmetrics.component.ts b/portal-2/src/app/utils/altmetrics.component.ts index 9d09edc2..83791728 100644 --- a/portal-2/src/app/utils/altmetrics.component.ts +++ b/portal-2/src/app/utils/altmetrics.component.ts @@ -21,9 +21,9 @@ export class AltMetricsComponent { } ngOnInit() { if(this.type == "doi"){ - this.altmetrics='

'; + this.altmetrics='
'; }else{ - this.altmetrics='
'; + this.altmetrics='
'; } } } diff --git a/portal-2/src/app/utils/properties/openaireProperties.ts b/portal-2/src/app/utils/properties/openaireProperties.ts index 86f469a0..4f148782 100644 --- a/portal-2/src/app/utils/properties/openaireProperties.ts +++ b/portal-2/src/app/utils/properties/openaireProperties.ts @@ -53,7 +53,7 @@ export class OpenaireProperties { // private static searchServiveURL = "http://services.openaire.eu:8380/search/"; // private static searchServiveURL = "http://beta.services.openaire.eu:8480/search/"; - private static csvAPIURL = "http://rudie.di.uoa.gr:6081/dnet-functionality-services-2.0.0-SNAPSHOT/rest/rest/v2/api/";//publications?format=csv + private static csvAPIURL = "http://rudie.di.uoa.gr:6081/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/";//publications?format=csv private static searchCrossrefAPIURL = "http://api.crossref.org/works"; private static searchDataciteAPIURL = "http://search.datacite.org/api"; diff --git a/portal-2/src/app/utils/utils.module.ts b/portal-2/src/app/utils/utils.module.ts index 7be80864..c49e2d21 100644 --- a/portal-2/src/app/utils/utils.module.ts +++ b/portal-2/src/app/utils/utils.module.ts @@ -36,7 +36,6 @@ import {ModalLoading} from './modal/loading.component'; IFrameComponent, SafeHtmlPipe, AltMetricsComponent - ], exports: [ pagingFormatterNoLoad, @@ -51,7 +50,6 @@ import {ModalLoading} from './modal/loading.component'; IFrameComponent, SafeHtmlPipe, AltMetricsComponent - ] }) export class UtilsModule { } diff --git a/portal-2/src/index.html b/portal-2/src/index.html index 57efd8bf..8fe90c0e 100644 --- a/portal-2/src/index.html +++ b/portal-2/src/index.html @@ -66,6 +66,10 @@ } + + + + diff --git a/portal-2/src/typings.d.ts b/portal-2/src/typings.d.ts index dd39e599..74d0c00e 100644 --- a/portal-2/src/typings.d.ts +++ b/portal-2/src/typings.d.ts @@ -31,6 +31,10 @@ declare module 'modern-lru' { export = x; } +//declare var clipboard: any; +//import * as Clipboard from 'clipboard'; + + declare var System: SystemJS; interface SystemJS { @@ -40,6 +44,7 @@ interface SystemJS { declare var ENV: string; declare var HMR: boolean; declare var Zone: {current: any}; + interface GlobalEnvironment { ENV; HMR; diff --git a/portal-2/webpack.config.ts b/portal-2/webpack.config.ts index cbec9f48..a26b7f57 100644 --- a/portal-2/webpack.config.ts +++ b/portal-2/webpack.config.ts @@ -94,7 +94,7 @@ export var serverConfig = { __filename: true, process: true, Buffer: true - } +} }; export default [