1
|
import {Component, Input} from '@angular/core';
|
2
|
import {Router, ActivatedRoute} from '@angular/router';
|
3
|
import {Title, Meta} from '@angular/platform-browser';
|
4
|
|
5
|
import {Observable} from 'rxjs/Observable';
|
6
|
import {ErrorCodes} from '../utils/properties/errorCodes';
|
7
|
|
8
|
import{EnvProperties} from '../utils/properties/env-properties';
|
9
|
|
10
|
import {RouterHelper} from '../utils/routerHelper.class';
|
11
|
import {FetchDataproviders} from '../utils/fetchEntitiesClasses/fetchDataproviders.class';
|
12
|
import {SearchDataprovidersService} from '../services/searchDataproviders.service';
|
13
|
import {OrganizationService} from '../services/organization.service';
|
14
|
import {PiwikService} from '../utils/piwik/piwik.service';
|
15
|
|
16
|
@Component({
|
17
|
selector: 'deposit-result',
|
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 class="uk-article-title custom-article-title">
|
25
|
Deposit {{requestFor}}
|
26
|
</div-->
|
27
|
<helper position="top"></helper>
|
28
|
<div class="uk-grid helper-grid">
|
29
|
<helper position="left" styleName=" uk-width-1-5 uk-padding-left"></helper>
|
30
|
<div class="uk-width-expand">
|
31
|
<div *ngIf="status == errorCodes.LOADING || (status == errorCodes.LOADING && fetchDataproviders.searchUtils.status == errorCodes.LOADING)"
|
32
|
class="uk-animation-fade uk-margin-top uk-width-1-1" role="alert"><img class="loading-gif uk-align-center" >
|
33
|
</div>
|
34
|
|
35
|
|
36
|
<!--div *ngIf="status != errorCodes.LOADING" class="uk-margin-bottom uk-margin-top">
|
37
|
<h3>See if your institution has a repository </h3>
|
38
|
|
39
|
<form class= "uk-grid">
|
40
|
<div class="uk-width-1-2 ">
|
41
|
<entities-autocomplete [(properties)]=properties fieldId="organization" (click)="warningMessage = ''" [entityType]="'organization'"
|
42
|
[depositType]=compatibility [showSelected]=true [placeHolderMessage] = "'Organization name'"
|
43
|
[title] = "'Organizations'" [multipleSelections]=false (selectedValueChanged)="valueChanged($event)">
|
44
|
</entities-autocomplete>
|
45
|
</div>
|
46
|
<button class=" uk-button uk-button-default" type="submit" (click)="organizationSelected(selectedId)" >
|
47
|
Locate
|
48
|
</button>
|
49
|
<div *ngIf="warningMessage.length > 0" class="uk-alert uk-alert-warning uk-animation-fade" role="alert">{{warningMessage}}</div>
|
50
|
</form>
|
51
|
</div-->
|
52
|
|
53
|
|
54
|
<div *ngIf="fetchDataproviders.searchUtils.totalResults > 0">
|
55
|
<h2 *ngIf="organization" class="organization">
|
56
|
<a *ngIf="organization['url']!=''" href="{{organization.url}}" target="_blank">
|
57
|
<span><i class="custom-external"></i>{{organization['name']}}</span>
|
58
|
</a>
|
59
|
<span *ngIf="organization['url']==''">{{organization['name']}}</span>
|
60
|
</h2>
|
61
|
|
62
|
|
63
|
</div>
|
64
|
|
65
|
<div *ngIf="fetchDataproviders.searchUtils.totalResults > 0">
|
66
|
<p class="uk-text-meta">Please use the information below and contact your repository to deposit your <span class="uk-text-lowercase">{{requestFor}}</span>.</p>
|
67
|
<!--showDataProviders [dataProviders]=dataProviders></showDataProviders-->
|
68
|
<div class = "uk-text-right" *ngIf = "fetchDataproviders.searchUtils.totalResults > 10">
|
69
|
<!--a [href] = "linkToSearchDataproviders">
|
70
|
View all {{fetchDataproviders.searchUtils.totalResults | number}} results <span class="uk-icon">
|
71
|
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="chevron-right" ratio="1"><polyline fill="none" stroke="#000" stroke-width="1.03" points="7 4 13 10 7 16"></polyline></svg>
|
72
|
</span>
|
73
|
</a-->
|
74
|
|
75
|
<a [queryParams]="routerHelper.createQueryParams(['organizationId', 'og'], [organizationId, 'and'])"
|
76
|
routerLinkActive="router-link-active" [routerLink]="linkToSearchDataproviders" class="uk-button uk-button-text">
|
77
|
View all {{fetchDataproviders.searchUtils.totalResults | number}} results
|
78
|
</a>
|
79
|
</div>
|
80
|
<search-result [(results)]="fetchDataproviders.results"
|
81
|
[(status)]= "fetchDataproviders.searchUtils.status"
|
82
|
type="dataprovider" urlParam="datasourceId" [showOrganizations] = false
|
83
|
[custom_class]="'other-results'" [(properties)] =properties>
|
84
|
</search-result>
|
85
|
</div>
|
86
|
|
87
|
|
88
|
<div *ngIf="(fetchDataproviders.searchUtils.totalResults == 0 && status == errorCodes.DONE)
|
89
|
|| status == errorCodes.NOT_FOUND || status == errorCodes.ERROR || status == errorCodes.NOT_AVAILABLE" class = "alert alert-warning">
|
90
|
<div *ngIf="organization">
|
91
|
<span *ngIf="fetchDataproviders.searchUtils.status == errorCodes.ERROR">
|
92
|
An error occured.
|
93
|
</span>
|
94
|
No content providers found for institution:
|
95
|
<a *ngIf="organization['url']!=''" target="_blank" href="{{organization.url}}">
|
96
|
<span>{{organization['name']}} (<i class="custom-external"></i>)</span>
|
97
|
</a>
|
98
|
<span *ngIf="organization['url']==''">{{organization['name']}}</span>
|
99
|
.
|
100
|
</div>
|
101
|
<div *ngIf="status == errorCodes.NOT_FOUND && organizationId != ''">
|
102
|
No organization with ID: {{organizationId}} found.
|
103
|
</div>
|
104
|
<div *ngIf="status == errorCodes.ERROR && organizationId != ''">
|
105
|
An error occured.
|
106
|
</div>
|
107
|
<span *ngIf="status == errorCodes.NOT_AVAILABLE && organizationId != ''">
|
108
|
Service temprorarily unavailable. Please try again later.
|
109
|
</span>
|
110
|
<div *ngIf="organizationId == ''">
|
111
|
No ID for organization.
|
112
|
</div>
|
113
|
|
114
|
You can still deposit your {{requestFor}} in
|
115
|
<a href="{{zenodo}}" target="_blank">OpenAIRE's Zenodo catch-all repository (<i class="custom-external"></i>)</a>
|
116
|
hosted by CERN.
|
117
|
</div>
|
118
|
</div>
|
119
|
<helper position="right" styleName=" uk-width-1-5"></helper>
|
120
|
</div>
|
121
|
<button class=" uk-button uk-button-primary uk-margin-small-top" type="submit" (click)="goToDeposit()">
|
122
|
<span class="uk-icon"><svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="chevron-left" ratio="1"><polyline fill="none" stroke="#000" stroke-width="1.03" points="13 16 7 10 13 4"></polyline></svg></span> Back
|
123
|
</button>
|
124
|
<helper position="bottom"></helper>
|
125
|
</div>
|
126
|
</div>
|
127
|
</div>
|
128
|
</div>
|
129
|
|
130
|
`
|
131
|
})
|
132
|
|
133
|
export class DepositResultComponent {
|
134
|
@Input() compatibility: string = '';
|
135
|
@Input() piwikSiteId = null;
|
136
|
// Type of entity: Publication or Research Data
|
137
|
@Input() requestFor: string = "Publications";
|
138
|
|
139
|
public organization: {"name": string, "url": string};
|
140
|
public organizationId: string = "";
|
141
|
|
142
|
// Id of the new selected organization to be searched
|
143
|
public selectedId: string = "";
|
144
|
|
145
|
public status: number;
|
146
|
public warningMessage: string = "";
|
147
|
|
148
|
public fetchDataproviders : FetchDataproviders;
|
149
|
public linkToSearchDataproviders: string = "";
|
150
|
|
151
|
// url of Zenodo
|
152
|
public zenodo: string;
|
153
|
|
154
|
public routerHelper:RouterHelper = new RouterHelper();
|
155
|
public errorCodes:ErrorCodes = new ErrorCodes();
|
156
|
|
157
|
sub: any; piwiksub: any;
|
158
|
properties:EnvProperties;
|
159
|
|
160
|
constructor ( private _router: Router,
|
161
|
private route: ActivatedRoute,
|
162
|
private _searchDataprovidersService: SearchDataprovidersService,
|
163
|
private _organizationService: OrganizationService,
|
164
|
private _meta: Meta,
|
165
|
private _title: Title,
|
166
|
private _piwikService:PiwikService) {
|
167
|
|
168
|
this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService);
|
169
|
|
170
|
this.status = this.errorCodes.LOADING;
|
171
|
|
172
|
var description = "Deposit "+this.requestFor;
|
173
|
var title = "Openaire, repositories, open access, content provider, compatibility, organization, deposit "+ this.requestFor;
|
174
|
|
175
|
this.updateTitle(title);
|
176
|
this.updateDescription(description);
|
177
|
|
178
|
}
|
179
|
ngOnInit() {
|
180
|
this.route.data
|
181
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
182
|
this.properties = data.envSpecific;
|
183
|
this.zenodo = this.properties.zenodo;
|
184
|
this.updateUrl(data.envSpecific.baseLink+this._router.url);
|
185
|
|
186
|
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
|
187
|
this.piwiksub = this._piwikService.trackView(this.properties, "Deposit "+this.requestFor, this.piwikSiteId).subscribe();
|
188
|
}
|
189
|
});
|
190
|
|
191
|
console.info('depositResult init');
|
192
|
|
193
|
this.sub = this.route.queryParams.subscribe(params => {
|
194
|
this.organizationId = params['organizationId'];
|
195
|
console.info("Id is :"+this.organizationId);
|
196
|
if(this.organizationId){
|
197
|
this.getOrganizationInfo();
|
198
|
}
|
199
|
this.selectedId = "";
|
200
|
});
|
201
|
}
|
202
|
|
203
|
ngDoCheck() {
|
204
|
if(this.organizationId == "" || this.organizationId == undefined) {
|
205
|
this.organizationId = "";
|
206
|
this.status = this.errorCodes.ERROR;
|
207
|
}
|
208
|
}
|
209
|
|
210
|
ngOnDestroy() {
|
211
|
this.sub.unsubscribe();
|
212
|
if(this.piwiksub){
|
213
|
this.piwiksub.unsubscribe();
|
214
|
}
|
215
|
}
|
216
|
|
217
|
private searchDataproviders() {
|
218
|
// if(this.organization != undefined) {
|
219
|
// this.fetchDataproviders.getResults(this.organization.name, false, 1, 10);
|
220
|
// } else if(this.organizationId != undefined) {
|
221
|
this.fetchDataproviders.getResultsForDeposit( this.organizationId,this.requestFor, 1, 10, this.properties);
|
222
|
//}
|
223
|
this.linkToSearchDataproviders = this.properties.searchLinkToDataProviders;
|
224
|
}
|
225
|
|
226
|
private getOrganizationInfo () {
|
227
|
console.info("inside getOrganizationInfo of component");
|
228
|
|
229
|
this._organizationService.getOrganizationInfo(this.organizationId,this.properties).subscribe(
|
230
|
data => {
|
231
|
if(data == null) {
|
232
|
this.status = this.errorCodes.NOT_FOUND;
|
233
|
} else {
|
234
|
this.organization = data.title;
|
235
|
this.status = this.errorCodes.DONE;
|
236
|
this.searchDataproviders();
|
237
|
}
|
238
|
},
|
239
|
err => {
|
240
|
//console.log(err)
|
241
|
|
242
|
if(err.status == '404') {
|
243
|
this.status = this.errorCodes.NOT_FOUND;
|
244
|
console.info("not found");
|
245
|
} else if(err.status == '500') {
|
246
|
this.status = this.errorCodes.ERROR;
|
247
|
console.info("error");
|
248
|
} else {
|
249
|
this.status = this.errorCodes.NOT_AVAILABLE;
|
250
|
console.info("not available");
|
251
|
}
|
252
|
}
|
253
|
);
|
254
|
}
|
255
|
|
256
|
public goToDeposit() {
|
257
|
if(this.requestFor == "Publications") {
|
258
|
this._router.navigate( ['participate/deposit-publications'] );
|
259
|
} else if(this.requestFor == "Research Data") {
|
260
|
this._router.navigate( ['participate/deposit-datasets'] );
|
261
|
}
|
262
|
}
|
263
|
|
264
|
public valueChanged($event){
|
265
|
this.selectedId = $event.value;
|
266
|
}
|
267
|
|
268
|
public organizationSelected(id: string) {
|
269
|
console.info("organization selected");
|
270
|
if(id && id.length > 0 && id != this.organizationId){
|
271
|
this.organization = null;
|
272
|
this.status = this.errorCodes.LOADING;
|
273
|
|
274
|
if(this.requestFor == "Publications") {
|
275
|
this._router.navigate( ['participate/deposit-publications-result'], { queryParams: { "organizationId": id } } );
|
276
|
} else if(this.requestFor == "Research Data") {
|
277
|
this._router.navigate( ['participate/deposit-datasets-result'], { queryParams: { "organizationId": id } } );
|
278
|
}
|
279
|
} else {
|
280
|
this.warningMessage = "No new organization selected";
|
281
|
}
|
282
|
}
|
283
|
|
284
|
private updateDescription(description:string) {
|
285
|
this._meta.updateTag({content:description},"name='description'");
|
286
|
this._meta.updateTag({content:description},"property='og:description'");
|
287
|
}
|
288
|
private updateTitle(title:string){
|
289
|
var _prefix ="OpenAIRE | ";
|
290
|
var _title = _prefix + ((title.length> 50 ) ?title.substring(0,50):title);
|
291
|
this._title.setTitle(_title);
|
292
|
this._meta.updateTag({content:_title},"property='og:title'");
|
293
|
}
|
294
|
private updateUrl(url:string){
|
295
|
this._meta.updateTag({content:url},"property='og:url'");
|
296
|
}
|
297
|
}
|