Project

General

Profile

« Previous | Next » 

Revision 54352

Delete separate production library

View differences:

modules/uoa-services-library/trunk/ng-openaire-library-production/.angular-cli.json
1
{
2
    "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3
    "project": {
4
      "name": "ng-universal-demo"
5
    },
6
    "apps": [
7
      {
8
        "root": "src",
9
        "outDir": "dist/browser",
10
        "assets": [
11
          "assets",
12
          "favicon.ico"
13
        ],
14
        "index": "index.html",
15
        "main": "main.ts",
16
        "polyfills": "polyfills.ts",
17
        "test": "test.ts",
18
        "tsconfig": "tsconfig.app.json",
19
        "testTsconfig": "tsconfig.spec.json",
20
        "prefix": "app",
21
        "styles": [
22
          "styles.css",
23
          "../node_modules/datatables.net-dt/css/jquery.dataTables.css"
24
        ],
25
        "scripts": [
26
          "../node_modules/jquery/dist/jquery.js",
27
          "../node_modules/datatables.net/js/jquery.dataTables.js"
28
        ],
29
        "environmentSource": "environments/environment.ts",
30
        "environments": {
31
          "dev": "environments/environment.ts",
32
          "prod": "environments/environment.prod.ts"
33
        }
34
      },
35
      {
36
        "platform": "server",
37
        "root": "src",
38
        "outDir": "dist/server",
39
        "assets": [
40
          "assets",
41
          "favicon.ico"
42
        ],
43
        "index": "index.html",
44
        "main": "main.server.ts",
45
        "test": "test.ts",
46
        "tsconfig": "tsconfig.server.json",
47
        "testTsconfig": "tsconfig.spec.json",
48
        "prefix": "app",
49
        "styles": [
50
          "styles.css"
51
        ],
52
        "scripts": [],
53
        "environmentSource": "environments/environment.ts",
54
        "environments": {
55
          "dev": "environments/environment.ts",
56
          "prod": "environments/environment.prod.ts"
57
        }
58
      }
59
    ],
60
    "e2e": {
61
      "protractor": {
62
        "config": "./protractor.conf.js"
63
      }
64
    },
65
    "lint": [
66
      {
67
        "project": "src/tsconfig.app.json",
68
        "exclude": "**/node_modules/**"
69
      },
70
      {
71
        "project": "src/tsconfig.spec.json",
72
        "exclude": "**/node_modules/**"
73
      },
74
      {
75
        "project": "e2e/tsconfig.e2e.json",
76
        "exclude": "**/node_modules/**"
77
      }
78
    ],
79
    "test": {
80
      "karma": {
81
        "config": "./karma.conf.js"
82
      }
83
    },
84
    "defaults": {
85
      "styleExt": "css",
86
      "component": {
87
        "spec": false,
88
        "inlineStyle": true,
89
        "inlineTemplate": true
90
      },
91
      "directive": {
92
        "spec": false
93
      },
94
      "class": {
95
        "spec": false
96
      },
97
      "guard": {
98
        "spec": false
99
      },
100
      "module": {
101
        "spec": false
102
      },
103
      "pipe": {
104
        "spec": false
105
      },
106
      "service": {
107
        "spec": false
108
      }
109
    }
110
  }
modules/uoa-services-library/trunk/ng-openaire-library-production/tsconfig.json
1
{
2
  "compileOnSave": false,
3
  "compilerOptions": {
4
    "outDir": "./dist/out-tsc",
5
    "sourceMap": true,
6
    "declaration": false,
7
    "moduleResolution": "node",
8
    "emitDecoratorMetadata": true,
9
    "experimentalDecorators": true,
10
    "target": "es5",
11
    "typeRoots": [
12
      "node_modules/@types"
13
    ],
14
    "lib": [
15
      "es2017",
16
      "dom"
17
    ]
18
  }
19
}
modules/uoa-services-library/trunk/ng-openaire-library-production/ng-package.json
1
{
2
  "$schema": "./node_modules/ng-packagr/ng-package.schema.json",
3
  "lib": {
4
    "entryFile": "public_api.ts"
5
  }
6
}
modules/uoa-services-library/trunk/ng-openaire-library-production/src/main.server.ts
1
export { AppServerModule } from './app/app.server.module';
modules/uoa-services-library/trunk/ng-openaire-library-production/src/app/landingPages/htmlProjectReport/htmlProjectReport-routing.module.ts
1
// import { NgModule } from '@angular/core';
2
// import { RouterModule } from '@angular/router';
3
//
4
// import { HtmlProjectReportComponent } from './htmlProjectReport.component';
5
// import {FreeGuard} from'../../login/freeGuard.guard';
6
// import {PreviousRouteRecorder} from'../../utils/piwik/previousRouteRecorder.guard';
7
//
8
// @NgModule({
9
//  imports: [
10
//   RouterModule.forChild([
11
//     { path: '', component: HtmlProjectReportComponent , canActivate: [FreeGuard],canDeactivate: [PreviousRouteRecorder]}
12
//   ])
13
// ]
14
// })
15
// export class HtmlProjectReportRoutingModule { }
modules/uoa-services-library/trunk/ng-openaire-library-production/src/app/landingPages/htmlProjectReport/htmlProjectReport.service.ts
1
import {Injectable} from '@angular/core';
2
import {Http, Response} from '@angular/http';
3
import {Observable}     from 'rxjs/Observable';
4
import 'rxjs/add/operator/do';
5

  
6
@Injectable()
7
export class HtmlProjectReportService {
8

  
9
    constructor(private http: Http ) {}
10

  
11
    getHTML(id: string, size: number, type:string, csvAPIURL: string ):any {
12
        console.info("getHTML in service");
13

  
14
        let resultTypeId: string;
15
        let requestType: string;
16
        if(type == "publication") {
17
          resultTypeId = 'publication';
18
          requestType = 'publications';
19
        } else if(type == "research data") {
20
          resultTypeId = 'dataset';
21
          requestType = 'datasets';
22
        } else if(type == "software") {
23
          resultTypeId = 'software';
24
          requestType = 'software'
25
        } else if(type == 'other research products') {
26
          resultTypeId = 'other';
27
          requestType = 'other';
28
        }
29

  
30
        let url = csvAPIURL;
31
        url += '?format=html&type='+requestType+'&fq=(((oaftype exact result) and (resulttypeid exact '+resultTypeId+')) and (relprojectid exact "'+id+'"))';
32

  
33
        let key = url;
34

  
35
        return this.http.get(url)
36
                    .map(res => <any> res.text());
37
    }
38
}
modules/uoa-services-library/trunk/ng-openaire-library-production/src/app/landingPages/htmlProjectReport/htmlProjectReport.component.ts
1
import {Component, Input}               from '@angular/core';
2
import {ActivatedRoute, Params, Router} from '@angular/router';
3
import {Title, Meta}                  from '@angular/platform-browser';
4

  
5
import {Observable}                     from 'rxjs/Observable';
6

  
7
import {EnvProperties}                  from '../../utils/properties/env-properties';
8

  
9
import {HtmlProjectReportService}       from './htmlProjectReport.service';
10
import {ProjectService}                 from '../project/project.service';
11
import {PiwikService}                   from '../../utils/piwik/piwik.service';
12
import { SEOService } from '../../sharedComponents/SEO/SEO.service';
13

  
14
declare var UIkit: any;
15

  
16
@Component({
17
    selector: 'htmlProjectReport',
18
    template: `
19
    <div id="tm-main" class=" uk-section  uk-margin-small-top tm-middle"   >
20
      <div uk-grid uk-grid>
21
       <div class="tm-main uk-width-1-1@s uk-width-1-1@m  uk-width-1-1@l uk-row-first ">
22

  
23
      <div class="uk-container uk-margin-top">
24
          <div *ngIf="warningMessage" class="uk-alert uk-alert-warning" role="alert">{{warningMessage}}</div>
25
          <div [style.display]="showLoading ? 'inline' : 'none'" class="uk-animation-fade uk-margin-large-top  uk-width-1-1" role="alert"><span class="loading-gif  uk-align-center" ></span></div>
26

  
27
          <div *ngIf="!showLoading && !warningMessage">
28
            <h1 *ngIf="header1">{{header1}}</h1>
29
            <h2 *ngIf="header1 || htmlResult">{{header2}}</h2>
30

  
31
            <div class="uk-clearfix uk-margin-bottom">
32
              <button *ngIf="htmlResult" class="uk-icon-clipboard uk-button uk-button-primary clipBtn uk-float-right" (click)="copied()">
33
                  Copy to clipboard
34
              </button>
35
            </div>
36
            <!--div class="uk-panel-scrollable custom-html-table-height" *ngIf="htmlResult" id="clipboard" [innerHTML]="htmlResult"></div-->
37
            <div class="uk-overflow-auto custom-html-table-height" *ngIf="htmlResult" id="clipboard" [innerHTML]="htmlResult"></div>
38

  
39
            <div *ngIf="errorMessage" class="uk-alert uk-alert-danger" role="alert">{{errorMessage}}</div>
40
          </div>
41
      </div>
42
      </div>
43
    </div>
44
  </div>
45

  
46
    `
47
 })
48
export class HtmlProjectReportComponent{
49
  @Input() piwikSiteId = null;
50
    private projectId: string;
51
    private totalResults: number = 10;
52
    private resultsType: string = "publication";
53

  
54
    public header1: string = "";
55
    public header2: string = "";
56
    public htmlResult: string = "";
57

  
58
    public sub: any; piwiksub: any;
59
    public subHTML: any;
60
    public subHTMLInfo: any;
61

  
62
    public warningMessage: string = "";
63
    public errorMessage: string = "";
64
    public showLoading: boolean = true;
65
    properties:EnvProperties;
66

  
67
    constructor ( private  route: ActivatedRoute,
68
                  private htmlService: HtmlProjectReportService,
69
                  private _piwikService:PiwikService,
70
                  private _projectService: ProjectService,
71
                  private _meta: Meta,
72
                  private _title: Title,
73
                  private _router: Router,
74
                private seoService: SEOService) {
75
    }
76

  
77
    ngOnInit() {
78
      this.route.data
79
        .subscribe((data: { envSpecific: EnvProperties }) => {
80
           this.properties = data.envSpecific;
81
           this.updateUrl(data.envSpecific.baseLink+this._router.url);
82

  
83
        });
84
        this.sub =  this.route.queryParams.subscribe(params => {
85
            this.projectId = params['projectId'];
86

  
87
            if (params['size'] == parseInt(params['size'], 10)) {
88
              this.totalResults = params['size'];
89
            } else {
90
              this.showLoading = false;
91
    		      this.warningMessage="Requested size is not an integer";
92
            }
93

  
94
            if(params['type'] && (params['type'] == "publication" || params['type'] == "dataset" || params['type'] == "software" || params['type'] == "other")){
95
              if(params['type'] == "publication") {
96
                this.resultsType = 'publication';
97
              } else if(params['type'] == "dataset") {
98
                this.resultsType = 'research data';
99
              } else if(params['type'] == "software") {
100
                this.resultsType = 'software';
101
              } else if(params['type'] == "other") {
102
                this.resultsType = "other research product";
103
              }
104

  
105
              var title = "Project's "+this.resultsType+" report";
106
              var description = "project, project "+ this.resultsType +" report, funding, open access, publications, research data, software, other research products";
107
              this.updateTitle(title);
108
              this.updateDescription(description);
109
              this.seoService.createLinkForCanonicalURL();
110

  
111
            } else {
112
              this.showLoading = false;
113
    		      this.warningMessage="Requested type should be publication or research data or software or other research product";
114
            }
115

  
116
            //showLoading is true if no warnings
117
            if(this.showLoading) {
118
              if(this.projectId) {
119
                this.createHeaders();
120
              } else {
121
                this.showLoading = false;
122
      		      this.warningMessage="No valid project id";
123
              }
124
            }
125
        });
126
    }
127

  
128
    ngOnDestroy() {
129
      this.sub.unsubscribe();
130
      if(this.piwiksub){
131
        this.piwiksub.unsubscribe();
132
      }
133
      if(this.subHTML) {
134
        this.subHTML.unsubscribe();
135
      }
136
      if(this.subHTMLInfo) {
137
        this.subHTMLInfo.unsubscribe();
138
      }
139
    }
140

  
141
    private createHeaders() {
142
        this.subHTMLInfo = this._projectService.getHTMLInfo(this.projectId, this.properties).subscribe(
143
            data => {
144
                this.createHeader1(data);
145
                if(data.acronym) {
146
                  this.updateTitle(data.acronym+" "+this.resultsType+" report");
147
                } else if(data.title){
148
                  this.updateTitle(data.title+" "+this.resultsType+" report");
149
                }
150
                if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
151
                  this.piwiksub = this._piwikService.trackView(this.properties, ((data.acronym)?data.acronym:data.title)+" "+this.resultsType+" report", this.piwikSiteId).subscribe();
152
                }
153
            },
154
            err => {
155
                console.log(err);
156
                this.createClipboard();
157
            }
158
        );
159

  
160
        if(this.resultsType == "publication") {
161
          this.header2 += this.totalResults.toLocaleString('en-US') + " publications";
162
        } else if(this.resultsType == "research data") {
163
          this.header2 += this.totalResults.toLocaleString('en-US') + " research data";
164
        } else if(this.resultsType == "software") {
165
          this.header2 += this.totalResults.toLocaleString('en-US') + " software";
166
        } else if(this.resultsType == "other research product") {
167
          this.header2 += this.totalResults.toLocaleString('en-US') + " other";
168
        }
169
    }
170

  
171
    private createClipboard() {
172
        let intro: string = '<!doctype html>';
173
        intro += '<html lang="en-gb" dir="ltr" vocab="http://schema.org/">';
174
        intro += '<head>';
175
        intro += '<title>'+this.header1+'</title>'
176
        intro += '</head>';
177

  
178
        if (typeof window !== 'undefined') {
179
            this.subHTML = this.htmlService.getHTML(this.projectId, this.totalResults, this.resultsType, this.properties.csvAPIURL).subscribe(
180
                data => {
181
                    //let body: string = intro+'<body><h1>'+this.header1+'</h1><h2>'+this.header2+'</h2>'+data+'</body></html>';
182
                    let body: string = intro+'<body><h1>'+this.header1+'</h1><h2>'+this.header2+'</h2>';
183
                    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>";
184
                    body += '</body></html>';
185

  
186
                    //this.htmlResult = data;
187
                    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>";
188

  
189
                    let clipboard;
190
                    let Clipboard;
191
                    Clipboard = require('clipboard');
192
                    clipboard = new Clipboard('.clipBtn', {
193
                        /*target: function(trigger) {
194
                            return document.getElementById("clipboard");
195
                        }*/
196
                        text: function(trigger) {
197
                            return body;//document.getElementById("clipboard").getAttribute('innerHTML');//"aaaa"+tmp+"oo";
198
                        }
199
                    });
200

  
201
                    this.showLoading = false;
202
                },
203
                err => {
204
                    console.log(err);
205
                    this.errorMessage = 'Service not available';
206
                    this.showLoading = false;
207
                }
208
            );
209
        }
210
    }
211

  
212
    createHeader1(data: {"title": string, "acronym": string, "callIdentifier": string}) {
213
        if(this.resultsType == "publication") {
214
          this.header1 += "Publications";
215
        } else if(this.resultsType == "research data") {
216
          this.header1 += "Research Data";
217
        } else if(this.resultsType == "software") {
218
          this.header1 += "Software";
219
        } else if(this.resultsType == "other research product") {
220
          this.header1 += "Other Research Products";
221
        }
222

  
223
        if(data != undefined) {
224
            if(data.title != undefined && data.title != "") {
225
                this.header1 += data.title;
226
            }
227
            if((data.title != undefined && data.title != "") &&
228
             ((data.acronym != undefined && data.acronym != "") ||
229
              (data.callIdentifier != undefined && data.callIdentifier != ""))) {
230
                    this.header1 += "(";
231
            }
232
            if(data.acronym != undefined && data.acronym != "") {
233
                this.header1 += data.acronym + " - ";
234
            }
235
            if(data.callIdentifier != undefined && data.callIdentifier != "") {
236
                this.header1 += data.callIdentifier;
237
            }
238
            if((data.title != undefined && data.title != "") &&
239
             ((data.acronym != undefined && data.acronym != "") ||
240
              (data.callIdentifier != undefined && data.callIdentifier != ""))) {
241
                    this.header1 += ")";
242
            }
243
        }
244

  
245
        this.createClipboard();
246
    }
247

  
248
    public copied() {
249
      UIkit.notification({
250
          message : '<strong>Raw html is copied. Please paste it on an html file.<strong>',
251
          status  : 'success',
252
          timeout : 3000,
253
          pos     : 'top-center'
254
      });
255
    }
256

  
257
    private updateDescription(description:string){
258
      this._meta.updateTag({content:description},"name='description'");
259
      this._meta.updateTag({content:description},"property='og:description'");
260
    }
261
    private updateTitle(title:string){
262
      var _prefix ="OpenAIRE | ";
263
      var _title = _prefix + ((title.length> 50 ) ?title.substring(0,50):title);
264
      this._title.setTitle(_title);
265
      this._meta.updateTag({content:_title},"property='og:title'");
266
    }
267
    private updateUrl(url:string){
268
      this._meta.updateTag({content:url},"property='og:url'");
269
    }
270
}
modules/uoa-services-library/trunk/ng-openaire-library-production/src/app/landingPages/htmlProjectReport/htmlProjectReport.module.ts
1
//import {MaterialModule} from '@angular/material';
2
import { NgModule}            from '@angular/core';
3
import { CommonModule }        from '@angular/common';
4
import { FormsModule }         from '@angular/forms';
5
import { ProjectServiceModule} from '../project/projectService.module';
6

  
7

  
8
import {HtmlProjectReportService} from './htmlProjectReport.service';
9
import {HtmlProjectReportComponent} from './htmlProjectReport.component';
10
// import { HtmlProjectReportRoutingModule } from './htmlProjectReport-routing.module';
11
import {FreeGuard} from'../../login/freeGuard.guard';
12
import {PiwikServiceModule} from '../../utils/piwik/piwikService.module';
13
import { SEOServiceModule } from '../../sharedComponents/SEO/SEOService.module';
14

  
15
@NgModule({
16
  imports: [
17
    CommonModule, FormsModule, ProjectServiceModule,PiwikServiceModule, SEOServiceModule
18
  ],
19
  declarations: [
20
  HtmlProjectReportComponent
21
  ],
22
  providers:[
23
    HtmlProjectReportService, FreeGuard
24
   ],
25
  exports: [
26
  HtmlProjectReportComponent
27
    ]
28
})
29
export class HtmlProjectReportModule { }
modules/uoa-services-library/trunk/ng-openaire-library-production/src/app/landingPages/publication/publication.component.html
1
<div id="tm-main" class=" uk-section  uk-margin-small-top tm-middle"   >
2
  <div uk-grid uk-grid>
3
   <div class="tm-main uk-width-1-1@s uk-width-1-1@m  uk-width-1-1@l uk-row-first ">
4

  
5
<div class="uk-container uk-margin-top publication">
6
    <div *ngIf="warningMessage.length > 0" class="uk-alert uk-alert-warning  uk-margin-large-top" role="alert">{{warningMessage}}</div>
7
    <div *ngIf="errorMessage.length > 0" class="uk-alert uk-alert-danger  uk-margin-large-top" role="alert">{{errorMessage}}</div>
8
    <div [style.display]="showLoading ? 'inline' : 'none'" class="uk-animation-fade uk-margin-large-top  uk-width-1-1" role="alert"><span class="loading-gif  uk-align-center" ></span></div>
9

  
10
    <div  *ngIf="publicationInfo != null"  uk-grid class="uk-grid-large">
11
        <div class="uk-width-expand@m uk-width-1-1@s">
12
            <schema2jsonld *ngIf="publicationInfo.record" [data]=publicationInfo.record [URL]="properties.baseLink+'/search/publication?articleId='+articleId"></schema2jsonld>
13
            <showTitle  [titleName]="publicationInfo.title"></showTitle>
14
            <span *ngIf="publicationInfo.types && publicationInfo.types.length > 0"class="uk-label custom-label label-blue label-publication" title="Type">{{publicationInfo.types.join(", ")}}</span>
15
            <span *ngIf="publicationInfo.languages && publicationInfo.languages.length > 0" class="uk-label custom-label  label-language " title="Language">{{publicationInfo.languages.join(", ")}}</span>
16
            <span *ngIf="publicationInfo.countries && publicationInfo.countries.length > 0" class="uk-label custom-label  label-country " title="Country">{{publicationInfo.countries.join(", ")}}</span>
17
            <!-- <span *ngIf="publicationInfo.title && publicationInfo.title.accessMode" [class]="'uk-label custom-label  label-'+ publicationInfo.title.accessMode ">{{publicationInfo.title.accessMode}}</span> -->
18
            <span *ngIf="publicationInfo.accessMode" [class]="'uk-label custom-label  label-'+ publicationInfo.accessMode " title="Access Mode">{{publicationInfo.accessMode}}</span>
19

  
20
            <span *ngIf="publicationInfo.underCurationMessage" class="uk-label custom-label label-underCuration"  >
21
              <span uk-tooltip="pos:right; delay:10"
22
                  title="{{buildCurationTooltip()}}">
23
              <i>Record in preview</i>
24
              <i class="uk-icon-info-circle"></i>
25
            </span></span>
26

  
27

  
28

  
29
            <div class= " uk-margin-top">
30
                <showAuthors [authors]="publicationInfo.authors" searchPage="publications"></showAuthors>
31
                <span *ngIf="publicationInfo.date != ''">({{publicationInfo.date}})</span>
32
            </div>
33

  
34
            <ul class="uk-list">
35
                <li *ngIf="publicationInfo.publisher"><span class="uk-text-bold">Publisher:</span> {{publicationInfo.publisher}}</li>
36
                <li *ngIf="publicationInfo.journal &&
37
                    (publicationInfo.journal['journal'] || publicationInfo.journal['issn'] || publicationInfo.journal['lissn']
38
                    || publicationInfo.journal['volume'] || publicationInfo.journal['eissn'] || publicationInfo.journal['issue'])">
39
                    <span class="uk-text-bold">Journal:</span>
40
                    <span *ngIf="publicationInfo.journal['journal']">{{publicationInfo.journal['journal']}}</span
41
                    ><span *ngIf="publicationInfo.journal['journal'] && (publicationInfo.journal['volume'] || publicationInfo.journal['issue'])">,</span>
42
                    <span *ngIf="publicationInfo.journal['volume']"
43
                        >volume
44
                        <span *ngIf="publicationInfo.journal['volume'] > 0">{{publicationInfo.journal['volume'] | number}}</span
45
                        ><span *ngIf="!(publicationInfo.journal['volume'] > 0)">{{publicationInfo.journal['volume']}}</span
46
                    ><span *ngIf="publicationInfo.journal['issue'] || publicationInfo.journal['start_page'] || publicationInfo.journal['end_page']">,</span>
47
                    </span>
48
                    <span *ngIf="publicationInfo.journal['issue']"
49
                        >issue
50
                        <span *ngIf="publicationInfo.journal['issue'] > 0">{{publicationInfo.journal['issue'] | number}}</span
51
                        ><span *ngIf="!(publicationInfo.journal['issue'] > 0)">{{publicationInfo.journal['issue']}}</span
52
                    ><span *ngIf="publicationInfo.journal['start_page'] || publicationInfo.journal['end_page']">,</span>
53
                    </span>
54
                    <span *ngIf="(publicationInfo.journal['volume'] || publicationInfo.journal['issue']) &&
55
                                (publicationInfo.journal['start_page'] && publicationInfo.journal['end_page'])">pages</span>
56
                    <span *ngIf="(publicationInfo.journal['volume'] || publicationInfo.journal['issue']) &&
57
                                ((publicationInfo.journal['start_page'] && !publicationInfo.journal['end_page']) ||
58
                                (!publicationInfo.journal['start_page'] && publicationInfo.journal['end_page']))">page</span>
59
                    <span *ngIf="publicationInfo.journal['start_page']"
60
                      ><span *ngIf="publicationInfo.journal['start_page'] > 0">{{publicationInfo.journal['start_page'] | number}}</span
61
                      ><span *ngIf="!(publicationInfo.journal['start_page'] > 0)">{{publicationInfo.journal['start_page']}}</span
62
                    ></span
63
                    ><span *ngIf="publicationInfo.journal['start_page'] && publicationInfo.journal['end_page']">-</span
64
                    ><span *ngIf="publicationInfo.journal['end_page']"
65
                      ><span *ngIf="publicationInfo.journal['end_page'] > 0">{{publicationInfo.journal['end_page'] | number}}</span
66
                      ><span *ngIf="!(publicationInfo.journal['end_page'] > 0)">{{publicationInfo.journal['end_page']}}</span
67
                    ></span>
68
                    <span *ngIf="publicationInfo.journal['issn'] || publicationInfo.journal['eissn'] || publicationInfo.journal['lissn']">(</span
69
                    ><span *ngIf="publicationInfo.journal['issn']">issn: {{publicationInfo.journal['issn']}}<span *ngIf="publicationInfo.journal['eissn'] || publicationInfo.journal['lissn']">, </span
70
                    ></span
71
                    ><span *ngIf="publicationInfo.journal['eissn']">eissn: {{publicationInfo.journal['eissn']}}<span *ngIf="publicationInfo.journal['lissn']">, </span
72
                    ></span
73
                    ><span *ngIf="publicationInfo.journal['lissn']">lissn: {{publicationInfo.journal['lissn']}}
74
                    ></span
75
                    ><span *ngIf="publicationInfo.journal['issn'] || publicationInfo.journal['eissn'] || publicationInfo.journal['lissn']">)</span>
76
                </li>
77

  
78
                <li *ngIf="publicationInfo.embargoEndDate"><span class="uk-text-bold">Embargo end date:</span> {{publicationInfo.embargoEndDate}}</li>
79
                <li *ngIf="publicationInfo.identifiers && publicationInfo.identifiers.size > 0">
80
                  <showIdentifiers [identifiers]="publicationInfo.identifiers"></showIdentifiers>
81
                </li>
82
                <li *ngIf="publicationInfo.subjects || publicationInfo.otherSubjects ||  publicationInfo.classifiedSubjects">
83
                  <showSubjects [subjects]="publicationInfo.subjects"
84
                  [otherSubjects]="publicationInfo.otherSubjects"
85
                  [classifiedSubjects]="publicationInfo.classifiedSubjects">
86
                </showSubjects>
87
                </li>
88
              </ul>
89
              <hr *ngIf="publicationInfo.description">
90
              <div *ngIf="publicationInfo.description" class="uk-margin-bottom uk-text-justify descriptionText">
91
                {{publicationInfo.description}}
92
              </div>
93

  
94

  
95

  
96

  
97

  
98
           <ul class="custom-accordion" uk-accordion>
99

  
100
             <li *ngIf="publicationInfo.references" (click)="activeTab='References'">
101
                 <a class="uk-accordion-title" href="#">
102
                     References
103
                     <!-- <span *ngIf="!publicationInfo.references" class="uk-badge uk-badge-notification">0</span>
104
                     <span *ngIf="publicationInfo.references" class="uk-badge uk-badge-notification">
105
                         {{publicationInfo.references.length | number}}
106
                     </span> -->
107
                     <!-- <span class="uk-badge uk-badge-notification"> -->
108
                         ({{publicationInfo.references.length | number}})
109
                     <!-- </span> -->
110
                 </a>
111
                 <div class="uk-accordion-content">
112
                   <!-- <div *ngIf="!publicationInfo.references" class = "uk-alert  uk-alert-primary" >
113
                       No references available
114
                   </div>
115

  
116
                   <div *ngIf="publicationInfo.references"> -->
117
                   <div>
118
                       <div *ngIf="publicationInfo.references.length > pageSize" class="uk-margin-bottom">
119
                         <span class="uk-h6">{{publicationInfo.references.length | number}} references, page {{referencesPage | number}} of {{totalPages(publicationInfo.references.length) | number}}</span>
120
                         <paging-no-load class="uk-float-right" [currentPage]="referencesPage" [totalResults]="publicationInfo.references.length" [size]="pageSize" (pageChange)="updateReferencesPage($event)"></paging-no-load>
121
                       </div>
122

  
123
                       <div *ngFor="let item of publicationInfo.references.slice((referencesPage-1)*pageSize, referencesPage*pageSize)">
124
                           <p *ngIf=" item && item['url']"
125
                               class="custom-external custom-icon">
126
                               <a href="{{item['url']}}" target="_blank">
127
                                   {{item['name']}}
128
                               </a>
129
                           </p>
130
                           <p  *ngIf="!item['url']" class="pseudo-external custom-icon">
131
                               {{item['name']}}
132
                           </p>
133
                       </div>
134
                   </div>
135
                 </div>
136
              </li>
137

  
138
              <li *ngIf="publicationInfo.relatedResearchResults" (click)="activeTab='Related Research Results'">
139
                  <a class="uk-accordion-title" href="#">
140
                    Related Research Results
141
                      <!-- <span *ngIf="!publicationInfo.relatedResearchResults" class="uk-badge uk-badge-notification">0</span>
142
                      <span *ngIf="publicationInfo.relatedResearchResults" class="uk-badge uk-badge-notification">
143
                          {{relatedResearchResultsNum | number}}
144
                      </span> -->
145
                      <!-- <span class="uk-badge uk-badge-notification"> -->
146
                          ({{relatedResearchResultsNum | number}})
147
                      <!-- </span> -->
148
                  </a>
149
                  <div class="uk-accordion-content">
150
                    <!-- <div *ngIf="!publicationInfo.relatedResearchResults" class = "uk-alert  uk-alert-primary">
151
                        No related research results available
152
                    </div>
153
                    <div *ngIf="publicationInfo.relatedResearchResults"> -->
154
                    <div>
155
                        <div *ngFor="let provenanceaction of getKeys(publicationInfo.relatedResearchResults)">
156
                            <div class="uk-text-large">{{provenanceaction}}</div>
157

  
158
                            <tabTable [percentageName]="trust" [info]="publicationInfo.relatedResearchResults.get(provenanceaction)" [(properties)]=properties></tabTable>
159
                        </div>
160
                    </div>
161
                  </div>
162
               </li>
163

  
164
               <li *ngIf="publicationInfo.similarResearchResults" (click)="activeTab='Similar Research Results'">
165
                   <a class="uk-accordion-title" href="#">
166
                       Similar Research Results
167
                       <!-- <span *ngIf="!publicationInfo.similarResearchResults" class="uk-badge uk-badge-notification">0</span>
168
                       <span *ngIf="publicationInfo.similarResearchResults" class="uk-badge uk-badge-notification">
169
                           {{publicationInfo.similarResearchResults.length | number}}
170
                       </span> -->
171
                       <!-- <span class="uk-badge uk-badge-notification"> -->
172
                           ({{publicationInfo.similarResearchResults.length | number}})
173
                       <!-- </span> -->
174
                   </a>
175
                   <div class="uk-accordion-content">
176
                     <!-- <div *ngIf="!publicationInfo.similarResearchResults" class = "uk-alert  uk-alert-primary" >
177
                         No similar research results available
178
                     </div>
179

  
180
                     <div *ngIf="publicationInfo.similarResearchResults"> -->
181
                     <div>
182
                       <tabTable [percentageName]="similarity" [info]="publicationInfo.similarResearchResults" [(properties)]=properties></tabTable>
183
                     </div>
184
                   </div>
185
                </li>
186

  
187
                <li *ngIf="publicationInfo.organizations" (click)="activeTab='Related Organizations'">
188
                    <a class="uk-accordion-title" href="#">
189
                        Related Organizations
190
                        <!-- <span *ngIf="!publicationInfo.organizations" class="uk-badge uk-badge-notification">0</span>
191
                        <span *ngIf="publicationInfo.organizations" class="uk-badge uk-badge-notification">
192
                            {{publicationInfo.organizations.length | number}}
193
                        </span> -->
194
                        <!-- <span class="uk-badge uk-badge-notification"> -->
195
                            ({{publicationInfo.organizations.length | number}})
196
                        <!-- </span> -->
197
                    </a>
198
                    <div class="uk-accordion-content">
199
                      <!-- <div *ngIf="!publicationInfo.organizations" class = "uk-alert  uk-alert-primary">
200
                          No related organizations available
201
                      </div>
202
                      <div *ngIf="publicationInfo.organizations"> -->
203
                      <div>
204
                          <div *ngIf="publicationInfo.organizations.length > pageSize" class="uk-margin-bottom">
205
                            <span class="uk-text-bold">{{publicationInfo.organizations.length | number}} organizations, page {{organizationsPage | number}} of {{totalPages(publicationInfo.organizations.length) | number}}</span>
206
                            <paging-no-load class="uk-float-right" [currentPage]="organizationsPage" [totalResults]="publicationInfo.organizations.length" [size]="pageSize" (pageChange)="updateOrganizationsPage($event)"></paging-no-load>
207
                          </div>
208

  
209
                          <table class="uk-table uk-table-small uk-table-divider uk-table-middle ">
210
                              <tbody>
211
                                  <tr *ngFor="let organization of publicationInfo.organizations.slice((organizationsPage-1)*pageSize, organizationsPage*pageSize)">
212
                                      <td>
213
                                          <a *ngIf="(organization['id']) && ((organization['name']) || (organization['shortname']))"
214
                                              [queryParams]="{organizationId: organization.id}" routerLinkActive="router-link-active" routerLink="/search/organization">
215
                                                  {{organization['name']}}
216
                                                  <span *ngIf="organization.name && organization.shortname"> ( </span>
217
                                                  <span *ngIf="organization.shortname">{{organization.shortname}}</span>
218
                                                  <span *ngIf="organization.name && organization.shortname"> ) </span>
219
                                          </a>
220
                                          <p *ngIf="(!organization['id']) && ((organization['name']) || (organization['shortname']))">
221
                                              {{organization['name']}}
222
                                              <span *ngIf="organization.name && organization.shortname"> ( </span>
223
                                              <span *ngIf="organization.shortname">{{organization.shortname}}</span>
224
                                              <span *ngIf="organization.name && organization.shortname"> ) </span>
225
                                          </p>
226
                                          <div *ngIf="organization.country">{{organization.country}}</div>
227
                                          <div *ngIf="organization.websiteUrl">Website url:
228
                                              <a href="{{organization.websiteUrl}}" target="_blank">{{organization.websiteUrl}}</a>
229
                                          </div>
230
                                      </td>
231
                                      <td>
232
                                          <div *ngIf="organization['trust']" title="{{organization['trust']}}%" >
233
                                            <div class="uk-text-center">{{organization['trust']}}%</div>
234
                                            <progress class="uk-progress uk-margin-remove" value="{{organization['trust']}}" max="100"></progress>
235
                                          </div>
236
                                          <div *ngIf="!organization['trust']">
237
                                              <p>no trust available</p>
238
                                          </div>
239
                                      </td>
240
                                  </tr>
241
                              </tbody>
242
                          </table>
243

  
244
                      </div>
245
                    </div>
246
                 </li>
247

  
248
                 <li *ngIf="publicationInfo.bioentities" (click)="activeTab='Bioentities'">
249
                     <a class="uk-accordion-title" href="#">
250
                         Bioentities
251
                         <!-- <span *ngIf="!publicationInfo.bioentities" class="uk-badge uk-badge-notification">0</span>
252
                         <span *ngIf="publicationInfo.bioentities" class="uk-badge uk-badge-notification">
253
                             {{publicationInfo.bioentitiesNum | number}}
254
                         </span> -->
255
                         <!-- <span class="uk-badge uk-badge-notification"> -->
256
                             ({{bioentitiesNum | number}})
257
                         <!-- </span> -->
258
                     </a>
259
                     <div class="uk-accordion-content">
260
                       <div *ngIf="publicationInfo.bioentities && bioentitiesNum > pageSize" class="uk-margin-bottom">
261
                         <span class="uk-text-bold"> {{bioentitiesNum | number}} bioentities, page {{bioentitiesPage | number}} of {{totalPages(bioentitiesNum) | number}}</span>
262
                         <paging-no-load class="uk-float-right" [currentPage]="bioentitiesPage" [totalResults]="bioentitiesNum" [size]="pageSize" (pageChange)="updateBioentitiesPage($event)"></paging-no-load>
263
                       </div>
264

  
265
                       <table id="bioentitiesTable" class="uk-table ">
266
                           <tbody>
267
                             <ng-container *ngFor="let key of getKeys(publicationInfo.bioentities) let i=index">
268
                                 <tr *ngFor="let keyIn of keysToArray(publicationInfo.bioentities.get(key)).slice((bioentitiesPage-1)*pageSize, bioentitiesPage*pageSize)">
269
                                     <td class="uk-text-center" *ngIf="keyIn">
270
                                         <span class="custom-external custom-icon">
271
                                             <a href="{{publicationInfo.bioentities.get(key).get(keyIn)}}"
272
                                                 target="_blank">
273
                                                 {{keyIn}}
274
                                             </a>
275
                                         </span>
276
                                     </td>
277
                                     <td class="uk-text-center">
278
                                         {{key}}
279
                                     </td>
280
                                 </tr>
281
                               </ng-container>
282
                           </tbody>
283
                       </table>
284
                     </div>
285
                  </li>
286

  
287
                  <li *ngIf="publicationInfo.software" (click)="activeTab='Software'">
288
                      <a class="uk-accordion-title" href="#">
289
                          Software
290
                          <!-- <span *ngIf="!publicationInfo.software" class="uk-badge uk-badge-notification">0</span>
291
                          <span *ngIf="publicationInfo.software" class="uk-badge uk-badge-notification">
292
                              {{publicationInfo.software.length | number}}
293
                          </span> -->
294
                          <!-- <span class="uk-badge uk-badge-notification"> -->
295
                              ({{publicationInfo.software.length | number}})
296
                          <!-- </span> -->
297
                      </a>
298
                      <div class="uk-accordion-content">
299
                        <div *ngIf="publicationInfo.software && publicationInfo.software.length > pageSize" class="uk-margin-bottom">
300
                          <span class="uk-text-bold">{{publicationInfo.software.length | number}} software results, page {{softwarePage | number}} of {{totalPages(publicationInfo.software.length) | number}}</span>
301
                          <paging-no-load class="uk-float-right" [currentPage]="softwarePage" [totalResults]="publicationInfo.software.length" [size]="pageSize" (pageChange)="updateSoftwarePage($event)"></paging-no-load>
302
                        </div>
303

  
304
                        <table id="softwareTable" class="uk-table ">
305
                            <tbody>
306
                                <tr *ngFor="let item of publicationInfo.software.slice((softwarePage-1)*pageSize, softwarePage*pageSize)" class="uk-text-center">
307
                                    <td>
308
                                        <span class="custom-external custom-icon">
309
                                            <a href="{{item.url}}" target="_blank">
310
                                                {{item.name}}
311
                                            </a>
312
                                        </span>
313
                                    </td>
314
                                </tr>
315
                            </tbody>
316
                        </table>
317
                      </div>
318
                   </li>
319

  
320
                   <li (click)="metricsClicked=true; activeTab='Metrics'">
321
                       <a class="uk-accordion-title" href="#">
322
                           Metrics
323
                       </a>
324
                       <div class="uk-accordion-content">
325
                         <metrics [pageViews]="pageViews"
326
                             [id]="articleId" [entityType]="'results'" [entity]="'Publication'"
327
                             (metricsResults)="metricsResults($event)" [(properties)] = properties>
328
                         </metrics>
329
                         <!--i-frame *ngIf="metricsClicked" [url]=viewsFrameUrl width="100%" height="250"></i-frame-->
330
                         <i-frame *ngIf="metricsClicked && totalViews>0"
331
                             [url]=viewsFrameUrl width="100%" height="250">
332
                         </i-frame>
333
                         <i-frame *ngIf="metricsClicked && totalDownloads>0"
334
                             [url]=downloadsFrameUrl width="100%" height="250">
335
                         </i-frame>
336
                       </div>
337
                    </li>
338
            </ul>
339

  
340
        </div>
341

  
342
        <div class="uk-width-large@m uk-width-1-1@s">
343
          <div class=" uk-padding-small">
344
          <div  >
345
            <div  class="sideInfoTitle uk-margin-small-bottom">Share - Bookmark</div>
346
            <addThis></addThis>
347
          </div>
348
          <altmetrics  *ngIf="publicationInfo.identifiers && publicationInfo.identifiers.get('doi')"
349
              id="{{publicationInfo.identifiers.get('doi')[0]}}" type="doi">
350
          </altmetrics>
351
            <ul class="uk-list uk-margin-remove-bottom">
352
                <li *ngIf="publicationInfo.hostedBy_collectedFrom && publicationInfo.hostedBy_collectedFrom.length > 0">
353
                    <availableOn [availableOn]="publicationInfo.hostedBy_collectedFrom"></availableOn>
354
                </li>
355
                <li *ngIf="publicationInfo.fundedByProjects != undefined && publicationInfo.fundedByProjects.length > 0">
356
                    <fundedBy [fundedByProjects]="publicationInfo.fundedByProjects"></fundedBy>
357
                </li>
358

  
359
                <li *ngIf="publicationInfo.contexts && publicationInfo.contexts.length >0 ">
360
                    <dl class="uk-description-list-line"  >
361
                        <dt class="sideInfoTitle">Related to</dt>
362
                        <dd class="line" *ngFor="let item of publicationInfo.contexts">
363
                          <span *ngIf = "!item['inline']" >
364
                            <span>{{item['labelContext']}}</span>
365
                            <span *ngIf="item['labelCategory']">-> {{item['labelCategory']}}</span>
366
                            <span *ngIf="item['labelConcept']">: {{item['labelConcept']}}</span>
367
                          </span>
368
                          <mark *ngIf = "item['inline']" >
369
                            <span>{{item['labelContext']}}</span>
370
                            <span *ngIf="item['labelCategory']">-> {{item['labelCategory']}}</span>
371
                            <span *ngIf="item['labelConcept']">: {{item['labelConcept']}}</span>
372
                          </mark>
373
                        </dd>
374
                    </dl>
375

  
376
                </li>
377
                <li>
378
                  <!--metrics [pageViews]="pageViews" shortView=true
379
                      [id]="articleId" [entityType]="'results'" [entity]="'Publication'"
380
                      (metricsResults)="metricsResults($event)" [(properties)] = properties>
381
                  </metrics-->
382
                </li>
383
                <li>
384

  
385
                          <div class=" sideInfoTitle  cite-this-button uk-width-1-1" type="button">
386
                            Cite this publication
387
                          </div>
388
                          <div class=" ">
389
                            <citeThis [result]="publicationInfo" [id]="articleId" type="publication"></citeThis>
390
                          </div>
391
                </li>
392
            </ul>
393

  
394
            <button  class="  uk-button portal-button   uk-width-1-1 ">
395
             <span class="uk-icon">
396
                  <svg icon="link" ratio="1" xmlns="http://www.w3.org/2000/svg" width="25" viewBox="0 0 20 20" height="25"><path d="M10.625,12.375 L7.525,15.475 C6.825,16.175 5.925,16.175 5.225,15.475 L4.525,14.775 C3.825,14.074 3.825,13.175 4.525,12.475 L7.625,9.375" fill="none" stroke="#000" stroke-width="1.1"></path><path d="M9.325,7.375 L12.425,4.275 C13.125,3.575 14.025,3.575 14.724,4.275 L15.425,4.975 C16.125,5.675 16.125,6.575 15.425,7.275 L12.325,10.375" fill="none" stroke="#000" stroke-width="1.1"></path><path d="M7.925,11.875 L11.925,7.975" fill="none" stroke="#000" stroke-width="1.1"></path></svg>
397
                </span> Link this publication to...
398
           </button>
399

  
400
           <div   class=" uk-margin-remove-top uk-padding-small" uk-dropdown="pos: bottom-left; mode:click" style="background: transparent !important;box-shadow: none; max-width: 70px !important; min-width: 70px !important;">
401
               <ul class="uk-iconnav uk-iconnav-vertical">
402
                 <li  uk-tooltip="pos:right;" title="<div class='tooltip-custom-font-size   '>Projects</div>">
403
                   <a   class="      uk-icon-button portal-button shadowBox"  style="padding: 6px;" [queryParams]="routerHelper.createQueryParams(['id','type','linkTo'],[articleId,'publication','project'])"   routerLinkActive="router-link-active" routerLink="/participate/direct-claim">
404
                     <span class="uk-icon" >
405
                        <svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="album" ratio="1"><rect x="5" y="2" width="10" height="1"></rect><rect x="3" y="4" width="14" height="1"></rect><rect fill="none" stroke="#000" x="1.5" y="6.5" width="17" height="11"></rect></svg></span>
406
                   </a>
407
                 </li>
408
                  <li  uk-tooltip="pos:right;" title="<div class='tooltip-custom-font-size  '>Communities</div>">
409
                    <a   class="     uk-icon-button portal-button shadowBox"  style="padding: 6px;" [queryParams]="routerHelper.createQueryParams(['id','type','linkTo'],[articleId,'publication','context'])"   routerLinkActive="router-link-active" routerLink="/participate/direct-claim" >
410
                      <span class="uk-icon"  >
411
                           <svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="users" ratio="1"><circle fill="none" stroke="#000" stroke-width="1.1" cx="7.7" cy="8.6" r="3.5"></circle><path fill="none" stroke="#000" stroke-width="1.1" d="M1,18.1 C1.7,14.6 4.4,12.1 7.6,12.1 C10.9,12.1 13.7,14.8 14.3,18.3"></path><path fill="none" stroke="#000" stroke-width="1.1" d="M11.4,4 C12.8,2.4 15.4,2.8 16.3,4.7 C17.2,6.6 15.7,8.9 13.6,8.9 C16.5,8.9 18.8,11.3 19.2,14.1"></path></svg></span>
412
                    </a>
413
                  </li>
414
                  <li uk-tooltip="pos:right;" title="<div class='tooltip-custom-font-size uk-margin-small'>Other research results</div>">
415
                    <a   class="    uk-icon-button portal-button shadowBox"  style="padding: 6px;" [queryParams]="routerHelper.createQueryParams(['id','type','linkTo'],[articleId,'publication','result'])"   routerLinkActive="router-link-active" routerLink="/participate/direct-claim" >
416
                      <span class="uk-icon" >
417
                           <svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="copy" ratio="1"><rect fill="none" stroke="#000" x="3.5" y="2.5" width="12" height="16"></rect><polyline fill="none" stroke="#000" points="5 0.5 17.5 0.5 17.5 17"></polyline></svg></span>
418
                    </a>
419
                  </li>
420

  
421
              </ul>
422
           </div>
423
          </div>
424

  
425
        </div>
426
    </div>
427

  
428
</div>
429
</div>
430
</div>
431
</div>
modules/uoa-services-library/trunk/ng-openaire-library-production/src/app/landingPages/publication/publication.service.ts
1

  
2
import {Injectable} from '@angular/core';
3
import {Http, Response} from '@angular/http';
4
import {Observable}     from 'rxjs/Observable';
5
import {PublicationInfo} from '../../utils/entities/publicationInfo';
6
import 'rxjs/add/observable/of';
7
import 'rxjs/add/operator/do';
8
import 'rxjs/add/operator/share';
9
import 'rxjs/add/operator/map';
10
import{EnvProperties} from '../../utils/properties/env-properties';
11

  
12

  
13
import { ParsingFunctions } from '../landing-utils/parsingFunctions.class';
14

  
15
@Injectable()
16
export class PublicationService {
17

  
18
  constructor(private http: Http ) {
19
    this.parsingFunctions = new ParsingFunctions();
20
  }
21

  
22
  public parsingFunctions: ParsingFunctions;
23
  publicationInfo: PublicationInfo;
24

  
25
  getPublicationInfo (id: string, properties:EnvProperties):any {
26
    console.info("getPublicationInfo in service");
27
    let url = properties.searchAPIURLLAst + 'publications/' +id+"?format=json";
28
    let key = url;
29

  
30
    return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
31
                .map(res => <any> res.json())
32
                .map(res => [res['result']['header']['dri:status'], res['result']['metadata']['oaf:entity'], res])
33
                .map(res => [ res[1]['oaf:result'],
34
                              res[1]['oaf:result']['title'],
35
                              res[1]['oaf:result']['rels']['rel'],
36
                              res[1]['oaf:result']['children'],
37
                              res[1]['oaf:result']['pid'],
38
                              res[1]['oaf:result']['journal'],
39
                              res[1]['oaf:result']['language'],
40
                              res[1]['oaf:result']['subject'],
41
                              res[1]['oaf:result']['bestaccessright'],
42
                              res[1]['oaf:result']['collectedfrom'],
43
                              (res[1]['extraInfo']!= undefined && res[1]['extraInfo']['citations']!= undefined)? res[1]['extraInfo']['citations']['citation']:null,
44
                              res[1]['oaf:result']['context'],
45
                              res[0],
46
                              res[1]['oaf:result']['creator'],
47
                              res[2],
48
                              res[1]['oaf:result']['country'],
49
                ])
50
                .map(res => this.parsePublicationInfo(res));
51
  }
52

  
53
  private handleError (error: Response) {
54
  // in a real world app, we may send the error to some remote logging infrastructure
55
  // instead of just logging it to the console
56
    console.log(error);
57
    return Observable.throw(error  || 'Server error');
58
  }
59

  
60
  parsePublicationInfo (data: any):any {
61
    this.publicationInfo = new PublicationInfo();
62
    this.publicationInfo.record = data[14];
63
    if(data[0] != null) {
64
      var date:string = (data[0].dateofacceptance)+""; // transform to string in case it is an integer
65
      this.publicationInfo.date  = (date && (date).indexOf('-') !== -1)?date.split('-')[0]:date;
66
      this.publicationInfo.dateofacceptance = data[0].dateofacceptance;
67
      this.publicationInfo.publisher = data[0].publisher;
68
      if(!Array.isArray(data[0].description)) {
69
          this.publicationInfo.description = data[0].description;
70
      } else {
71
          this.publicationInfo.description = data[0].description[0];
72
      }
73
      this.publicationInfo.embargoEndDate = data[0].embargoenddate;
74
    }
75

  
76
/*
77
    this.publicationInfo.title = {"name": "", "url": "", "accessMode": ""};
78
    if(data[0]['bestaccessright'] && data[0]['bestaccessright'].hasOwnProperty("classid")) {
79
      this.publicationInfo.title.accessMode = data[0]['bestaccessright'].classid;
80
    }
81

  
82
    if(data[1] != null) {
83
      if(Array.isArray(data[1])) {
84
        this.publicationInfo.title['name'] = data[1][0].content;
85
      } else {
86
        this.publicationInfo.title['name'] = data[1].content;
87
      }
88
    }
89
*/
90
    if(data[0]['bestaccessright'] && data[0]['bestaccessright'].hasOwnProperty("classid")) {
91
      this.publicationInfo.accessMode = data[0]['bestaccessright'].classid;
92
    }
93
    if(data[1] != null) {
94
      if(Array.isArray(data[1])) {
95
        this.publicationInfo.title = data[1][0].content;
96
      } else {
97
        this.publicationInfo.title = data[1].content;
98
      }
99
    }
100

  
101
    if(data[2] != null) {
102
      let relation;
103
      let length = Array.isArray(data[2]) ? data[2].length : 1;
104

  
105
      for(let i=0; i<length; i++) {
106
        relation = Array.isArray(data[2]) ? data[2][i] : data[2];
107
        if(relation.hasOwnProperty("to")) {
108
          if(relation['to'].class == "isProducedBy") {
109
            this.publicationInfo.fundedByProjects = this.parsingFunctions.parseFundingByProjects(this.publicationInfo.fundedByProjects, relation, this.publicationInfo.projectsProvenanceVocabulary);
110
          } else if(relation['to'].class == "isRelatedTo") {
111
            let provenanceAction: string;
112
            if(relation.provenanceaction in this.publicationInfo.researchResultsProvenanceVocabulary) {
113
              provenanceAction = this.publicationInfo.researchResultsProvenanceVocabulary[relation.provenanceaction];
114
            } else {
115
              provenanceAction = "Other";
116
            }
117

  
118
            this.publicationInfo.relatedResearchResults = this.parsingFunctions.parseRelatedResearchResults(this.publicationInfo.relatedResearchResults, relation, provenanceAction);
119
          } else if(relation['to'].class == "hasAmongTopNSimilarDocuments") {
120
            this.publicationInfo.similarResearchResults = this.parsingFunctions.parseSimilarResearchResults(this.publicationInfo.similarResearchResults, relation);
121
          } else if(relation['to'].class == "hasAuthorInstitution") {
122
            this.publicationInfo.organizations = this.parseRelatedOrganizations(this.publicationInfo.organizations, relation);
123
          }
124
        }
125
      }
126
    }
127

  
128
    if(data[3] != null) {
129
      if(data[3].hasOwnProperty("instance")) {
130
        //this.publicationInfo.collectedFrom = new Array<{"name": string, "id": string}>();
131
        //this.publicationInfo.downloadFrom = new Map<string, {"url": string[], "accessMode": string[], "bestAccessMode": string}>();
132
        //this.publicationInfo.publishedIn = new Map<string, {"url": string[], "accessMode": string[], "bestAccessMode": string}>();
133

  
134

  
135
        this.publicationInfo.hostedBy_collectedFrom = new Array<{"downloadName": string, "downloadUrl": string[], "collectedName": string, "collectedId": string, "accessMode": string[], "bestAccessMode": string, "type": string, "year":string}>();
136

  
137

  
138
        this.publicationInfo.types = new Array<string>();
139
        let types = new Set<string>();
140

  
141
        let counter = 0;
142
        let instance;
143

  
144
        let length = Array.isArray(data[3]['instance']) ? data[3]['instance'].length : 1;
145

  
146
        for(let i=0; i<length; i++) {
147
          instance = Array.isArray(data[3]['instance']) ? data[3]['instance'][i] : data[3]['instance'];
148

  
149
          this.parsingFunctions.parseTypes(this.publicationInfo.types, types, instance);
150

  
151
          if(instance.hasOwnProperty("webresource")) {
152
            let url;
153
            if(!Array.isArray(instance['webresource'])) {
154
              url = instance['webresource'].url;
155
            } else{
156
              url = instance['webresource'][0].url;
157
            }
158

  
159
            /**********************************************************/
160
            if(instance.hasOwnProperty("hostedby")) {
161
              counter = this.parsingFunctions.parseHostedBy_collectedFrom(this.publicationInfo.hostedBy_collectedFrom, instance, data[0], url, counter/*, this.publicationInfo.title*/, this.publicationInfo.accessMode);
162
            }
163
            /**********************************************************/
164
          }
165
        }
166
      }
167

  
168
      if(data[3].hasOwnProperty("externalreference")) {
169
        let externalResults: [Map<string, Map<string, string>>, { "name": string, "url": string}[]] = this.parseBioentitiesAndSoftware(data[3]);
170
        this.publicationInfo.bioentities = externalResults[0];
171
        this.publicationInfo.software = externalResults[1];
172
      }
173
    }
174

  
175
    if(data[4] != null) {
176
      this.publicationInfo.identifiers = this.parsingFunctions.parseIdentifiers(data[4]);
177
    }
178

  
179
    if(data[5] != null) {
180
      this.publicationInfo.journal = {"journal": "", "issn": "", "lissn": "", "eissn": "", "issue": "", "volume": "", "start_page": "", "end_page": ""}
181

  
182
      this.publicationInfo.journal['journal'] = data[5].content;
183
      this.publicationInfo.journal['issn'] = data[5].issn;
184
      this.publicationInfo.journal['lissn'] = data[5].lissn;
185
      this.publicationInfo.journal['eissn'] = data[5].eissn;
186
      this.publicationInfo.journal['issue'] = data[5].iss;
187
      this.publicationInfo.journal['volume'] = data[5].vol;
188
      this.publicationInfo.journal['start_page'] = data[5].sp;
189
      this.publicationInfo.journal['end_page'] = data[5].ep;
190
    }
191

  
192
    if(data[6] != null) {
193
      this.publicationInfo.languages = this.parsingFunctions.parseLanguages(data[6]);
194
    }
195
    if(data[15] != null) {
196
      this.publicationInfo.countries = this.parsingFunctions.parseCountries(data[15]);
197
    }
198

  
199
    if(data[7] != null) {
200
      let subjectResults: [string[], Map<string, string[]>, Map<string, string[]>] = this.parsingFunctions.parseAllSubjects(data[7]);
201
      this.publicationInfo.subjects = subjectResults[0];
202
      this.publicationInfo.otherSubjects = subjectResults[1];
203
      this.publicationInfo.classifiedSubjects = subjectResults[2];
204
    }
205

  
206
    // if(data[8] != null) {
207
    //     this.publicationInfo.bestaccessright = data[8].classid;
208
    // }
209

  
210
    // if(data[9] != null) {
211
    //   this.publicationInfo.collectedFrom = this.parsingFunctions.parseCollectedFrom(data[9]);
212
    // }
213

  
214
    this.publicationInfo.hostedBy_collectedFrom = this.parsingFunctions.addPublisherToHostedBy_collectedFrom(
215
                this.publicationInfo.hostedBy_collectedFrom, this.publicationInfo.publisher,
216
                this.publicationInfo.journal, this.publicationInfo.identifiers/*,
217
                this.publicationInfo.title*/);
218

  
219
    if(data[10] != null) {
220
      this.publicationInfo.references = this.parseReferences(data[10]);
221
    }
222

  
223
    if(data[11] != null) {
224
      this.publicationInfo.contexts = this.parsingFunctions.parseContexts(data[11]);
225
    }
226

  
227
    if(data[12] != null && data[12] == "under curation") {
228
      this.publicationInfo.underCurationMessage = true;
229
    } else {
230
      this.publicationInfo.underCurationMessage = false;
231
    }
232

  
233
    if(data[13] != null) {
234
      if(this.publicationInfo.authors == undefined) {
235
        this.publicationInfo.authors = new Array<string>();
236
      }
237

  
238
      let authors = data[13];
239
      let length = Array.isArray(authors) ? authors.length : 1;
240

  
241
      for(let i=0; i<length; i++) {
242
        let author = Array.isArray(authors) ? authors[i] : authors;
243
        this.publicationInfo.authors[author.rank-1] = author.content;
244
      }
245
      this.publicationInfo.authors = this.publicationInfo.authors.filter(function (item) {
246
        return (item != undefined);
247
      });
248
    }
249

  
250
    if(this.publicationInfo.relatedResearchResults) {
251
      let self = this;
252
      this.publicationInfo.relatedResearchResults.forEach(function (value, key, map) {
253
        self.publicationInfo.relatedResearchResults.set(key, self.parsingFunctions.sortByPercentage(value));
254
      });
255
    }
256
    this.publicationInfo.similarResearchResults = this.parsingFunctions.sortByPercentage(this.publicationInfo.similarResearchResults);
257

  
258
    return this.publicationInfo;
259
  }
260

  
261
  parseRelatedOrganizations(organizations: {"name": string, "shortname":string, "id": string, "websiteUrl": string, "country": string, "trust": number}[], relation: any):
262
                  {"name": string, "shortname":string, "id": string, "websiteUrl": string, "country": string, "trust": number}[] {
263
    if(organizations == undefined) {
264
      organizations = new Array<{
265
                  "name": string, "shortname": string,
266
                  "id": string, "websiteUrl": string,
267
                  "country": string, "trust": number}>();
268
    }
269

  
270
    let organization: { "name": string, "shortname": string,
271
                        "id": string, "websiteUrl": string,
272
                        "country": string, "trust": number
273
                      } = {
274
                        "name": "", "shortname": "",
275
                        "id": "", "websiteUrl": "",
276
                        "country": "", "trust": null
277
                      };
278

  
279
    organization.id = relation['to'].content;
280
    organization.name = relation.legalname;
281
    organization.shortname = relation.legalshortname;
282
    organization.websiteUrl = relation.websiteurl;
283
    if(relation.country) {
284
      organization.country = relation.country.classname;
285
    }
286
    if(relation.trust) {
287
      organization.trust = Math.round(relation.trust*100);
288
    }
289

  
290
    organizations.push(organization);
291
    return organizations;
292
  }
293

  
294
  parseBioentitiesAndSoftware(children: any) : [Map<string, Map<string, string>>, { "name": string, "url": string}[]] {
295
    let bioentities: Map<string, Map<string, string>>;
296
    let software: {"name": string, "url": string}[];
297

  
298
    let length = Array.isArray(children['externalreference']) ? children['externalreference'].length : 1;
299

  
300
    let externalreference;
301
    for(let i=0; i<length; i++) {
302
      externalreference = Array.isArray(children['externalreference']) ? children['externalreference'][i] : children['externalreference'];
303

  
304
      if(externalreference.hasOwnProperty("qualifier")) {
305
        if(externalreference['qualifier'].classid == "accessionNumber") {
306

  
307
          if(bioentities == undefined) {
308
            bioentities = new Map<string, Map<string, string>>();
309
          }
310

  
311
          if(!bioentities.has(externalreference.sitename)) {
312
            bioentities.set(externalreference.sitename, new Map<string, string>());
313
          }
314
          bioentities.get(externalreference.sitename).set(externalreference.refidentifier, externalreference.url);
315

  
316
        } else if(externalreference['qualifier'].classid == "software") {
317

  
318
          if(software == undefined) {
319
            software = new Array<{"name": string, "url": string}>();
320
          }
321

  
322
          software.push({"name": externalreference.sitename, "url": externalreference.url});
323
        }
324
      }
325
    }
326

  
327
    return [bioentities, software];
328
  }
329

  
330
  parseReferences(citations: any): {"name": string, "url": string}[] {
331
    let references = new Array<{"name": string, "url": string}>();
332

  
333
    let citation;
334
    let length = Array.isArray(citations) ? citations.length : 1;
335
    for(let i=0; i<length; i++) {
336
      citation = Array.isArray(citations) ? citations[i] : citations;
337

  
338
      let url;
339
      if(citation.hasOwnProperty("id")) {
340
        let citationId;
341
        let length1 = Array.isArray(citation['id']) ? citation['id'].length : 1;
342
        for(let j=0; j<length1; j++) {
343
          citationId = Array.isArray(citation['id']) ? citation['id'][j] : citation['id'];
344

  
345
          if(citationId.type == "pmid") {
346
            url = "http://www.ncbi.nlm.nih.gov/pubmed/"+citationId.value;
347
          }
348
        }
349
      }
350

  
351
      references[citation.position-1] = { "name": "", "url": ""};
352
      references[citation.position-1]['name'] = citation.rawText;
353
      references[citation.position-1]['url'] = url;
354
    }
355
    return references;
356
  }
357
}
modules/uoa-services-library/trunk/ng-openaire-library-production/src/app/landingPages/publication/publication.component.ts
1
import {Component, ViewChild}         from '@angular/core';
2
import {ElementRef, Input}            from '@angular/core';
3
import {ActivatedRoute, Router}       from '@angular/router';
4
import {Title, Meta}                  from '@angular/platform-browser';
5

  
6
import {Observable}                   from 'rxjs/Observable';
7

  
8
import {EnvProperties}                from '../../utils/properties/env-properties';
9
import {PublicationInfo}              from '../../utils/entities/publicationInfo';
10
import {RouterHelper}                 from '../../utils/routerHelper.class';
11

  
12
import {PiwikService}                 from '../../utils/piwik/piwik.service';
13
import {PublicationService}           from './publication.service';
14
import { SEOService } from '../../sharedComponents/SEO/SEO.service';
15

  
16

  
17
@Component({
18
    selector: 'publication',
19
    templateUrl: 'publication.component.html',
20

  
21
})
22

  
23
export class PublicationComponent {
24
  @Input() piwikSiteId = null;
25
  public publicationInfo: PublicationInfo;
26
  public articleId: string;
27

  
28
  // APP BOX variables
29
  public showAllCollectedFrom: boolean = false;
30
  public showAllDownloadFrom: boolean = false;
31

  
32
  // Metrics tab variables
33
  public metricsClicked: boolean;
34
  public viewsFrameUrl: string;
35
  public downloadsFrameUrl: string;
36
  public totalViews: number;
37
  public totalDownloads: number;
38
  public pageViews: number;
39

  
40
  // Custom tab paging variables
41
  public referencesPage: number = 1;
42
  public organizationsPage: number = 1;
43
  public softwarePage: number = 1;
44
  public bioentitiesPage: number = 1;
45
  public pageSize: number = 10;
46
  /*
47
    public startt: number = 0;
48
    public stopp: number = 0;
49
  */
50

  
51
  // Active tab variable for responsiveness
52
  public activeTab: string = "References";
53

  
54
  // Map counting variables
55
  public bioentitiesNum: number = 0;
56
  public relatedResearchResultsNum: number = 0;
57

  
58
  // Message variables
59
  public warningMessage = "";
60
  public errorMessage = "";
61
  public showLoading: boolean = true;
62

  
63
  public routerHelper:RouterHelper = new RouterHelper();
64

  
65
  private doi: string;
66
  private result;
67
  sub: any; piwiksub: any; infoSub: any;
68
  properties:EnvProperties;
69

  
70
  constructor ( private element: ElementRef,
71
                private _publicationService: PublicationService,
72
                private _piwikService:PiwikService,
73
                private route: ActivatedRoute,
74
                private _meta: Meta,
75
                private _title: Title,
76
                private _router: Router,
77
              private seoService: SEOService) {
78
  }
79

  
80
  ngOnInit() {
81
    this.route.data
82
      .subscribe((data: { envSpecific: EnvProperties }) => {
83
         this.properties = data.envSpecific;
84
         this.updateUrl(data.envSpecific.baseLink+this._router.url);
85

  
86
      });
87
       this.sub =  this.route.queryParams.subscribe(data => {
88
           this.publicationInfo = null;
89
           this.updateTitle("Publication");
90
           this.updateDescription("Publication, open access, collected from");
91
           this.seoService.createLinkForCanonicalURL();
92

  
93
          this.articleId = data['articleId'];
94
          console.info("Article id is :"+this.articleId);
95

  
96
          this.metricsClicked = false;
97

  
98
          if(this.articleId){
99

  
100
              this.getPublicationInfo(this.articleId);
101
              // if (typeof document !== 'undefined') {
102
              //   switcher(UIkit);
103
              // }
104
          }else{
105
              this.showLoading = false;
106
              this.warningMessage="No valid publication id";
107
          }
108

  
109
          this.viewsFrameUrl = this.properties.framesAPIURL+'merge.php?com=query&data=[{"query":"resRepoViews", "resTitle":"'+this.articleId+'", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false';
110

  
111
          this.downloadsFrameUrl =this.properties.framesAPIURL+'merge.php?com=query&data=[{"query":"resRepoDownloads", "resTitle":"'+this.articleId+'", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false';
112

  
113
          if (typeof document !== 'undefined') {
114
             this.element.nativeElement.scrollIntoView();
115
          }
116
    });
117
  }
118

  
119
    ngOnDestroy() {
120
        if(this.sub){
121
          this.sub.unsubscribe();
122
        }
123
        if(this.piwiksub){
124
          this.piwiksub.unsubscribe();
125
        }
126
        if(this.infoSub) {
127
          this.infoSub.unsubscribe();
128
        }
129
    }
130

  
131
    private getPublicationInfo(id:string) {
132
        this.warningMessage = '';
133
        this.errorMessage=""
134
        this.showLoading = true;
135

  
136
        this.publicationInfo = null;
137

  
138
        this.infoSub = this._publicationService.getPublicationInfo(this.articleId, this.properties).subscribe(
139
            data => {
140
                this.publicationInfo = data;
141

  
142
                // this.result = []
143
                // this.result = {id: id, type :"dataset", source : "openaire", title: this.publicationInfo.title,url: '', result: '', accessRights: this.publicationInfo.bestaccessright, embargoEndDate: ''};
144
                /*if(this.publicationInfo.title.name != undefined && this.publicationInfo.title.name!= ''){
145
                  this.updateTitle(this.publicationInfo.title.name);
146
                  this.updateDescription("Dataset, search, repositories, open access,"+this.publicationInfo.title.name);
147
                }*/
148
                if(this.publicationInfo.title){
149
                  this.updateTitle(this.publicationInfo.title);
150
                  this.updateDescription("Dataset, search, repositories, open access,"+this.publicationInfo.title);
151
                }
152
                if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
153
                  this.piwiksub =  this._piwikService.trackView(this.properties, this.publicationInfo.title/*.name*/, this.piwikSiteId).subscribe();
154
                }
155

  
156
                let bioentitiesNum = 0;
157
                if(this.publicationInfo.bioentities != undefined) {
158
                    this.publicationInfo.bioentities.forEach(function (value, key, map) {
159
                        bioentitiesNum += value.size;
160
                    });
161
                }
162
                this.bioentitiesNum = bioentitiesNum;
163

  
164
                let relatedResearchResultsNum = 0;
165
                if(this.publicationInfo.relatedResearchResults != undefined) {
166
                    this.publicationInfo.relatedResearchResults.forEach(function (value, key, map) {
167
                        relatedResearchResultsNum += value.length;
168
                    });
169
                }
170
                this.relatedResearchResultsNum = relatedResearchResultsNum;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff