1
|
import {Component, Input} from '@angular/core';
|
2
|
import {Observable} from 'rxjs/Observable';
|
3
|
import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties';
|
4
|
import { Router } from '@angular/router';
|
5
|
import { ActivatedRoute } from '@angular/router';
|
6
|
import { FetchDataproviders } from '../utils/fetchEntitiesClasses/fetchDataproviders.class';
|
7
|
import { SearchDataprovidersService } from '../services/searchDataproviders.service';
|
8
|
|
9
|
import {OrganizationService} from '../services/organization.service';
|
10
|
import { Meta} from '../../angular2-meta';
|
11
|
|
12
|
import {RouterHelper} from '../utils/routerHelper.class';
|
13
|
|
14
|
@Component({
|
15
|
selector: 'deposit-result',
|
16
|
template: `
|
17
|
<div class="container uk-margin-top">
|
18
|
<div class="page-header" >
|
19
|
<h2>Deposit {{requestFor}}</h2>
|
20
|
</div>
|
21
|
|
22
|
|
23
|
<div *ngIf="status == errorCodes.LOADING || (status == errorCodes.LOADING && fetchDataproviders.searchUtils.status == errorCodes.LOADING)"
|
24
|
class="uk-alert uk-alert-primary" role="alert">
|
25
|
Loading...
|
26
|
</div>
|
27
|
|
28
|
|
29
|
<div *ngIf="fetchDataproviders.searchUtils.totalResults > 0">
|
30
|
<h2 *ngIf="organization != undefined">
|
31
|
<span>Data providers for institution: </span>
|
32
|
<a *ngIf="organization['url']!=''" href="{{organization.url}}" target="_blank">
|
33
|
<span>{{organization['name']}} (<i class="uk-icon-external-link"></i>)</span>
|
34
|
</a>
|
35
|
<span *ngIf="organization['url']==''">{{organization['name']}}</span>
|
36
|
</h2>
|
37
|
|
38
|
|
39
|
</div>
|
40
|
|
41
|
<div *ngIf="fetchDataproviders.searchUtils.totalResults > 0">
|
42
|
<p>Please use the information/contacts shown below to deposit your {{requestFor}}.</p>
|
43
|
<!--showDataProviders [dataProviders]=dataProviders></showDataProviders-->
|
44
|
<div class = "uk-text-right" *ngIf = "fetchDataproviders.searchUtils.totalResults > 10">
|
45
|
<!--a [href] = "linkToSearchDataproviders">
|
46
|
View all {{fetchDataproviders.searchUtils.totalResults}} results <i class="uk-icon-angle-double-right"></i>
|
47
|
</a-->
|
48
|
|
49
|
<a [queryParams]="routerHelper.createQueryParams(['organizationId', 'or'], [organizationId, 'and'])"
|
50
|
routerLinkActive="router-link-active" [routerLink]="linkToSearchDataproviders">
|
51
|
View all {{fetchDataproviders.searchUtils.totalResults}} results <i class="uk-icon-angle-double-right"></i>
|
52
|
</a>
|
53
|
</div>
|
54
|
<search-result [(results)]="fetchDataproviders.results"
|
55
|
[(status)]= "fetchDataproviders.searchUtils.status"
|
56
|
type="dataprovider" urlParam="datasourceId">
|
57
|
</search-result>
|
58
|
</div>
|
59
|
|
60
|
|
61
|
<div *ngIf="(fetchDataproviders.searchUtils.totalResults == 0 && status == errorCodes.DONE)
|
62
|
|| status == errorCodes.NONE || status == errorCodes.ERROR" class = "alert alert-warning">
|
63
|
<div *ngIf="organization != undefined">
|
64
|
<span *ngIf="fetchDataproviders.searchUtils.status == errorCodes.ERROR">
|
65
|
An error occured.
|
66
|
</span>
|
67
|
No data providers found for institution:
|
68
|
<a *ngIf="organization['url']!=''" target="_blank" href="{{organization.url}}">
|
69
|
<span>{{organization['name']}}</span>
|
70
|
</a>
|
71
|
<span *ngIf="organization['url']==''">{{organization['name']}}</span>
|
72
|
.
|
73
|
</div>
|
74
|
<div *ngIf="status == errorCodes.NONE && organizationId != ''">
|
75
|
No organization with ID: {{organizationId}} found.
|
76
|
</div>
|
77
|
<div *ngIf="status == errorCodes.ERROR && organizationId != ''">
|
78
|
An error occured.
|
79
|
</div>
|
80
|
<div *ngIf="organizationId == ''">
|
81
|
No ID for organization.
|
82
|
</div>
|
83
|
|
84
|
You can still deposit your {{requestFor}} in
|
85
|
<a href="{{zenodo}}" target="_blank">OpenAIRE's Zenodo catch-all repository (<i class="uk-icon-external-link"></i>)</a>
|
86
|
hosted by CERN.
|
87
|
</div>
|
88
|
|
89
|
<button class="uk-button" type="submit" (click)="goToDeposit()">
|
90
|
<i class="uk-icon-arrow-circle-left"></i> Back
|
91
|
</button>
|
92
|
</div>
|
93
|
`
|
94
|
})
|
95
|
|
96
|
export class DepositResultComponent {
|
97
|
public organization: {"name": string, "url": string};
|
98
|
public organizationId: string = "";
|
99
|
|
100
|
public status: number;
|
101
|
public errorCodes:ErrorCodes = new ErrorCodes();
|
102
|
|
103
|
sub: any;
|
104
|
subDataproviders: any;
|
105
|
|
106
|
public routerHelper:RouterHelper = new RouterHelper();
|
107
|
public fetchDataproviders : FetchDataproviders;
|
108
|
public linkToSearchDataproviders = "";
|
109
|
public zenodo: string;
|
110
|
@Input() compatibility: string = '';
|
111
|
@Input() requestFor: string = "Publications";
|
112
|
|
113
|
constructor (private _router: Router,
|
114
|
private route: ActivatedRoute,
|
115
|
private _searchDataprovidersService: SearchDataprovidersService,
|
116
|
private _organizationService: OrganizationService, private _meta: Meta) {
|
117
|
|
118
|
this.zenodo = OpenaireProperties.getZenodoURL();
|
119
|
this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService);
|
120
|
|
121
|
this.status = this.errorCodes.LOADING;
|
122
|
this.updateTitle("Deposit "+this.requestFor);
|
123
|
this.updateDescription("Openaire, repositories, open access, data provider, compatibility, organization, deposit "+ this.requestFor);
|
124
|
}
|
125
|
updateDescription(description:string){
|
126
|
this._meta.updateMeta("description", description);
|
127
|
this._meta.updateMeta("og:description", description);
|
128
|
}
|
129
|
updateTitle(title:string){
|
130
|
var _suffix ="| OpenAIRE";
|
131
|
var _title = ((title.length> 50 ) ?title.substring(0,50):title) + _suffix;
|
132
|
this._meta.setTitle(_title );
|
133
|
this._meta.updateMeta("og:title",_title);
|
134
|
}
|
135
|
|
136
|
|
137
|
ngOnInit() {
|
138
|
console.info('depositResult init');
|
139
|
|
140
|
this.sub = this.route.queryParams.subscribe(params => {
|
141
|
this.organizationId = params['organizationId'];
|
142
|
console.info("Id is :"+this.organizationId);
|
143
|
if(this.organizationId){
|
144
|
this.getOrganizationInfo();
|
145
|
}
|
146
|
});
|
147
|
}
|
148
|
|
149
|
ngDoCheck() {
|
150
|
if(this.organizationId == "" || this.organizationId == undefined) {
|
151
|
this.organizationId = "";
|
152
|
this.status = this.errorCodes.ERROR;
|
153
|
}
|
154
|
}
|
155
|
|
156
|
ngOnDestroy() {
|
157
|
this.sub.unsubscribe();
|
158
|
if(this.subDataproviders != undefined) {
|
159
|
this.subDataproviders.unsubscribe();
|
160
|
}
|
161
|
}
|
162
|
|
163
|
private searchDataproviders() {
|
164
|
// if(this.organization != undefined) {
|
165
|
// this.fetchDataproviders.getResults(this.organization.name, false, 1, 10);
|
166
|
// } else if(this.organizationId != undefined) {
|
167
|
this.fetchDataproviders.getResultsForDeposit( this.organizationId,this.requestFor, 1, 10);
|
168
|
//}
|
169
|
this.linkToSearchDataproviders = OpenaireProperties.getLinkToSearchDataProviders();
|
170
|
}
|
171
|
|
172
|
private getOrganizationInfo () {
|
173
|
console.info("inside getOrganizationInfo of component");
|
174
|
|
175
|
this._organizationService.getOrganizationInfo(this.organizationId).subscribe(
|
176
|
data => {
|
177
|
this.organization = data.title;
|
178
|
this.status = this.errorCodes.DONE;
|
179
|
this.subDataproviders = this.route.queryParams.subscribe(params => {
|
180
|
this.searchDataproviders();
|
181
|
});
|
182
|
},
|
183
|
err => {
|
184
|
//console.log(err)
|
185
|
|
186
|
if(err.status == '404') {
|
187
|
this.status = this.errorCodes.NONE;
|
188
|
console.info("none");
|
189
|
} else {
|
190
|
this.status = this.errorCodes.ERROR;
|
191
|
console.info("error");
|
192
|
}
|
193
|
}
|
194
|
);
|
195
|
}
|
196
|
|
197
|
goToDeposit() {
|
198
|
if(this.requestFor == "Publications") {
|
199
|
this._router.navigate( ['participate/deposit-publications'] );
|
200
|
} else if(this.requestFor == "Research Data") {
|
201
|
this._router.navigate( ['participate/deposit-datasets'] );
|
202
|
}
|
203
|
}
|
204
|
}
|