1
|
import {Component, Input} from '@angular/core';
|
2
|
import {Observable} from 'rxjs/Observable';
|
3
|
import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties';
|
4
|
|
5
|
import { ActivatedRoute } from '@angular/router';
|
6
|
import { SearchDataprovidersComponent } from '../searchPages/searchDataproviders.component';
|
7
|
import { SearchDataprovidersService } from '../services/searchDataproviders.service';
|
8
|
import { SearchResultComponent } from '../searchPages/searchUtils/searchResult.component';
|
9
|
|
10
|
import {OrganizationService} from '../services/organization.service';
|
11
|
|
12
|
@Component({
|
13
|
selector: 'deposit-result',
|
14
|
template: `
|
15
|
<div class="container">
|
16
|
<div class="page-header" >
|
17
|
<h2>Deposit {{requestFor}}</h2>
|
18
|
</div>
|
19
|
|
20
|
<div *ngIf="searchDataprovidersComponent.totalResults > 0">
|
21
|
<h2 *ngIf="organization != undefined">
|
22
|
<span>Data providers for institution: </span>
|
23
|
<a *ngIf="organization['url']!=''" href="{{organization.url}}">
|
24
|
<span>{{organization['name']}}</span>
|
25
|
</a>
|
26
|
<span *ngIf="organization['url']==''">{{organization['name']}}</span>
|
27
|
</h2>
|
28
|
|
29
|
</div>
|
30
|
|
31
|
<div *ngIf="searchDataprovidersComponent.totalResults > 0">
|
32
|
<p>Please use the information/contacts shown below to deposit your publications.</p>
|
33
|
<!--showDataProviders [dataProviders]=dataProviders></showDataProviders-->
|
34
|
<div class = "text-right" *ngIf = "searchDataprovidersComponent.totalResults > 10" ><a [href] = "linkToSearchDataproviders" >View all {{searchDataprovidersComponent.totalResults}} results</a></div>
|
35
|
<search-result [(results)]="searchDataprovidersComponent.results" [(status)]= "searchDataprovidersComponent.status"></search-result>
|
36
|
</div>
|
37
|
|
38
|
<div *ngIf="searchDataprovidersComponent.totalResults == 0" class = "alert alert-warning">
|
39
|
<div *ngIf="organization != undefined">
|
40
|
No data providers found
|
41
|
<span *ngIf="organization != undefined">
|
42
|
for institution:
|
43
|
<a *ngIf="organization['url']!=''" href="{{organization.url}}">
|
44
|
<span>{{organization['name']}}</span>
|
45
|
</a>
|
46
|
<span *ngIf="organization['url']==''">{{organization['name']}}</span>
|
47
|
</span>
|
48
|
.
|
49
|
</div>
|
50
|
<div *ngIf="organization == undefined">
|
51
|
No organization with ID: {{organizationId}} found.
|
52
|
</div>
|
53
|
|
54
|
You can still deposit your publications and/or research data in
|
55
|
<a href="{{zenodo}}">OpenAIRE's Zenodo catch-all repository </a>
|
56
|
hosted by CERN.
|
57
|
</div>
|
58
|
</div>
|
59
|
`
|
60
|
})
|
61
|
|
62
|
export class DepositResultComponent {
|
63
|
private organization: {"name": string, "url": string};
|
64
|
private organizationId: string;
|
65
|
|
66
|
sub: any;
|
67
|
subDataproviders: any;
|
68
|
|
69
|
private searchDataprovidersComponent : SearchDataprovidersComponent;
|
70
|
private linkToSearchDataproviders = "";
|
71
|
private zenodo: string;
|
72
|
@Input() compatibility: string = '';
|
73
|
@Input() requestFor: string = "Publications";
|
74
|
|
75
|
constructor (private route: ActivatedRoute,
|
76
|
private _searchDataprovidersService: SearchDataprovidersService,
|
77
|
private _organizationService: OrganizationService) {
|
78
|
console.info("depositResult constructor");
|
79
|
|
80
|
this.zenodo = OpenaireProperties.getZenodoURL();
|
81
|
this.searchDataprovidersComponent = new SearchDataprovidersComponent(this.route, this._searchDataprovidersService);
|
82
|
}
|
83
|
|
84
|
ngOnInit() {
|
85
|
console.info('depositResult init');
|
86
|
|
87
|
this.sub = this.route.queryParams.subscribe(params => {
|
88
|
this.organizationId = params['organizationId'];
|
89
|
console.info("Id is :"+this.organizationId);
|
90
|
if(this.organizationId){
|
91
|
this.getOrganizationInfo();
|
92
|
}
|
93
|
});
|
94
|
}
|
95
|
|
96
|
ngOnDestroy() {
|
97
|
this.sub.unsubscribe();
|
98
|
if(this.subDataproviders != undefined) {
|
99
|
this.subDataproviders.unsubscribe();
|
100
|
}
|
101
|
}
|
102
|
|
103
|
private searchDataproviders() {
|
104
|
// if(this.organization != undefined) {
|
105
|
// this.searchDataprovidersComponent.getResults(this.organization.name, false, 1, 10);
|
106
|
// } else if(this.organizationId != undefined) {
|
107
|
this.searchDataprovidersComponent.getResultsForDeposit( this.organizationId,this.requestFor, 1, 10);
|
108
|
//}
|
109
|
this.linkToSearchDataproviders = OpenaireProperties.getLinkToSearchDataProviders();
|
110
|
}
|
111
|
|
112
|
private getOrganizationInfo () {
|
113
|
console.info("inside getOrganizationInfo of component");
|
114
|
|
115
|
this._organizationService.getOrganizationInfo(this.organizationId).subscribe(
|
116
|
data => {
|
117
|
this.organization = data.title;
|
118
|
this.subDataproviders = this.route.queryParams.subscribe(params => {
|
119
|
this.searchDataproviders();
|
120
|
});
|
121
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
122
|
//this.status = errorCodes.DONE;
|
123
|
},
|
124
|
err => {
|
125
|
console.error(err)
|
126
|
console.info("error");
|
127
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
128
|
//this.status = errorCodes.ERROR;
|
129
|
}
|
130
|
);
|
131
|
}
|
132
|
}
|