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
|
import {PiwikService} from '../../utils/piwik/piwik.service';
|
14
|
|
15
|
@Component({
|
16
|
selector: 'deposit-by-subject-result',
|
17
|
template: `
|
18
|
<div id="tm-main" class=" uk-section uk-margin-small-top tm-middle" >
|
19
|
<div uk-grid uk-grid>
|
20
|
<div class="tm-main uk-width-1-1@s uk-width-1-1@m uk-width-1-1@l uk-row-first ">
|
21
|
|
22
|
<div class="uk-container uk-margin-top">
|
23
|
<div class="page-header" >
|
24
|
<h2>Deposit {{requestFor}}</h2>
|
25
|
</div>
|
26
|
|
27
|
<div class="uk-width-1-1 uk-margin uk-padding uk-panel uk-background-muted">
|
28
|
<form class= "uk-margin uk-text-center uk-margin-top">
|
29
|
<input type="text" [(ngModel)]="newSubject" class=" uk-input uk-width-1-2" name="subject" placeholder="Search for classifications..." />
|
30
|
|
31
|
<button class=" uk-button uk-button-default" type="submit" (click)="searchDataproviders()" >
|
32
|
Search
|
33
|
</button>
|
34
|
</form>
|
35
|
<div *ngIf="subject.length > 0" class=" uk-text-center ">
|
36
|
<span>Keywords: {{subject}}<span><a class="uk-icon-button" (click) = "subject = ''"><span aria-hidden="true" class=" clickable "><span class="clickable uk-icon">
|
37
|
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="close" ratio="1"><path fill="none" stroke="#000" stroke-width="1.06" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.06" d="M16,4 L4,16"></path></svg>
|
38
|
</span></span></a></span>
|
39
|
</span>
|
40
|
</div>
|
41
|
</div>
|
42
|
<div *ngIf="fetchDataproviders.searchUtils.status == errorCodes.LOADING"
|
43
|
class="uk-animation-fade uk-margin-top uk-width-1-1" role="alert"><img src="./assets/loading.gif" class="uk-align-center" alt="Loading">
|
44
|
</div>
|
45
|
|
46
|
|
47
|
|
48
|
<div *ngIf="fetchDataproviders.searchUtils.totalResults > 0">
|
49
|
<p>Please use the information/contacts shown below to deposit your {{requestFor}}.</p>
|
50
|
<!--showDataProviders [dataProviders]=dataProviders></showDataProviders-->
|
51
|
<div *ngIf="fetchDataproviders.searchUtils.totalResults" class="">
|
52
|
<paging-no-load [currentPage]="page" [totalResults]="fetchDataproviders.searchUtils.totalResults" size=10 (pageChange)="pageChange($event)"> </paging-no-load>
|
53
|
</div>
|
54
|
<div class="" *ngIf="fetchDataproviders.results && fetchDataproviders.searchUtils.totalResults > 0">
|
55
|
{{fetchDataproviders.searchUtils.totalResults}} content providers, page {{fetchDataproviders.searchUtils.page}} of {{(totalPages())}}
|
56
|
</div>
|
57
|
|
58
|
<search-result [(results)]="fetchDataproviders.results"
|
59
|
type="dataprovider" urlParam="datasourceId" [showSubjects]=true
|
60
|
[custom_class]="'other-results'">
|
61
|
</search-result>
|
62
|
</div>
|
63
|
|
64
|
<div *ngIf="fetchDataproviders.searchUtils.status == errorCodes.NONE && subject != ''" class = "uk-alert uk-alert-primary">
|
65
|
No content providers found with classification "{{subject}}".
|
66
|
</div>
|
67
|
<div *ngIf="fetchDataproviders.searchUtils.status == errorCodes.ERROR && subject != ''" class = "uk-alert uk-alert-danger">
|
68
|
An error occured.
|
69
|
</div>
|
70
|
|
71
|
<div *ngIf="(fetchDataproviders.searchUtils.totalResults == 0 && fetchDataproviders.searchUtils.status == errorCodes.DONE)
|
72
|
|| fetchDataproviders.searchUtils.status == errorCodes.NONE || fetchDataproviders.searchUtils.status == errorCodes.ERROR" class = "uk-alert ">
|
73
|
|
74
|
You can still deposit your {{requestFor}} in
|
75
|
<a href="{{zenodo}}" target="_blank">OpenAIRE's Zenodo catch-all repository (<i class="custom-external"></i>)</a>
|
76
|
hosted by CERN.
|
77
|
</div>
|
78
|
|
79
|
<button class=" uk-button uk-button-default" type="submit" (click)="goToDeposit()">
|
80
|
<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
|
81
|
</button>
|
82
|
</div>
|
83
|
</div>
|
84
|
</div>
|
85
|
</div>
|
86
|
`
|
87
|
})
|
88
|
|
89
|
export class DepositBySubjectResultComponent {
|
90
|
|
91
|
|
92
|
public status: number;
|
93
|
public errorCodes:ErrorCodes = new ErrorCodes();
|
94
|
|
95
|
sub: any;
|
96
|
subDataproviders: any;
|
97
|
piwiksub: any;
|
98
|
public fetchDataproviders : FetchDataproviders;
|
99
|
|
100
|
public routerHelper:RouterHelper = new RouterHelper();
|
101
|
public linkToSearchDataproviders = "";
|
102
|
public zenodo: string;
|
103
|
public page: number = 1;
|
104
|
@Input() compatibility: string = '';
|
105
|
@Input() requestFor: string = "Research Data";
|
106
|
@Input() subject: string = "";
|
107
|
public newSubject: string= "";
|
108
|
|
109
|
constructor (private _router: Router,
|
110
|
private route: ActivatedRoute,
|
111
|
private _searchDataprovidersService: SearchDataprovidersService, private _meta: Meta, private _piwikService:PiwikService) {
|
112
|
|
113
|
this.zenodo = OpenaireProperties.getZenodoURL();
|
114
|
this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService);
|
115
|
|
116
|
this.status = this.errorCodes.LOADING;
|
117
|
this.updateTitle("Deposit "+this.requestFor);
|
118
|
this.updateDescription("Openaire, repositories, open access, content provider, compatibility, organization, deposit "+ this.requestFor);
|
119
|
this.updateUrl(OpenaireProperties.getBaseLink()+this._router.url);
|
120
|
if(OpenaireProperties.isPiwikTrackEnabled() && (typeof document !== 'undefined')){
|
121
|
this.piwiksub = this._piwikService.trackView("Deposit "+this.requestFor).subscribe();
|
122
|
}
|
123
|
}
|
124
|
updateDescription(description:string){
|
125
|
this._meta.updateMeta("description", description);
|
126
|
this._meta.updateProperty("og:description", description);
|
127
|
}
|
128
|
updateTitle(title:string){
|
129
|
var _prefix ="OpenAIRE | ";
|
130
|
var _title = _prefix + ((title.length> 50 ) ?title.substring(0,50):title);
|
131
|
this._meta.setTitle(_title );
|
132
|
this._meta.updateProperty("og:title",_title);
|
133
|
}
|
134
|
updateUrl(url:string){
|
135
|
this._meta.updateProperty("og:url", url);
|
136
|
}
|
137
|
|
138
|
|
139
|
ngOnInit() {
|
140
|
console.info('depositResult init');
|
141
|
|
142
|
this.sub = this.route.queryParams.subscribe(params => {
|
143
|
this.subject = params['q'];
|
144
|
this.newSubject = this.subject;
|
145
|
this.searchDataproviders();
|
146
|
});
|
147
|
}
|
148
|
|
149
|
totalPages(): number {
|
150
|
let totalPages:any = this.fetchDataproviders.searchUtils.totalResults/(this.fetchDataproviders.searchUtils.size);
|
151
|
if(!(Number.isInteger(totalPages))) {
|
152
|
totalPages = (parseInt(totalPages, 10) + 1);
|
153
|
}
|
154
|
return totalPages;
|
155
|
}
|
156
|
|
157
|
// ngDoCheck() {
|
158
|
// if(this.organizationId == "" || this.organizationId == undefined) {
|
159
|
// this.organizationId = "";
|
160
|
// this.status = this.errorCodes.ERROR;
|
161
|
// }
|
162
|
// }
|
163
|
|
164
|
ngOnDestroy() {
|
165
|
this.sub.unsubscribe();
|
166
|
if(this.subDataproviders != undefined) {
|
167
|
this.subDataproviders.unsubscribe();
|
168
|
}
|
169
|
if(this.piwiksub){
|
170
|
this.piwiksub.unsubscribe();
|
171
|
}
|
172
|
}
|
173
|
|
174
|
public searchDataproviders() {
|
175
|
this.subject = this.newSubject;
|
176
|
this.fetchDataproviders.getResultsBySubjectsForDeposit( (this.subject =="")?"*":this.subject, this.requestFor, this.page, 10);
|
177
|
this.linkToSearchDataproviders = OpenaireProperties.getLinkToSearchDataProviders();
|
178
|
}
|
179
|
|
180
|
|
181
|
|
182
|
goToDeposit() {
|
183
|
if(this.requestFor == "Publications") {
|
184
|
this._router.navigate( ['participate/deposit-publications'] );
|
185
|
} else if(this.requestFor == "Research Data") {
|
186
|
this._router.navigate( ['participate/deposit-datasets'] );
|
187
|
}
|
188
|
}
|
189
|
pageChange($event) {
|
190
|
this.page = +$event.value;
|
191
|
this.searchDataproviders();
|
192
|
}
|
193
|
}
|