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
|
|
11
|
@Component({
|
12
|
selector: 'deposit-result',
|
13
|
template: `
|
14
|
<div class="container uk-margin-top">
|
15
|
<div class="page-header" >
|
16
|
<h2>Deposit {{requestFor}}</h2>
|
17
|
</div>
|
18
|
|
19
|
<div *ngIf="status == errorCodes.LOADING || (status == errorCodes.LOADING && fetchDataproviders.searchUtils.status == errorCodes.LOADING)"
|
20
|
class="uk-alert uk-alert-primary" role="alert">
|
21
|
Loading...
|
22
|
</div>
|
23
|
|
24
|
<div *ngIf="fetchDataproviders.searchUtils.totalResults > 0">
|
25
|
<h2 *ngIf="organization != undefined">
|
26
|
<span>Data providers for institution: </span>
|
27
|
<a *ngIf="organization['url']!=''" href="{{organization.url}}" target="_blank">
|
28
|
<span>{{organization['name']}} (<i class="uk-icon-external-link"></i>)</span>
|
29
|
</a>
|
30
|
<span *ngIf="organization['url']==''">{{organization['name']}}</span>
|
31
|
</h2>
|
32
|
|
33
|
</div>
|
34
|
|
35
|
<div *ngIf="fetchDataproviders.searchUtils.totalResults > 0">
|
36
|
<p>Please use the information/contacts shown below to deposit your {{requestFor}}.</p>
|
37
|
<!--showDataProviders [dataProviders]=dataProviders></showDataProviders-->
|
38
|
<div class = "uk-text-right" *ngIf = "fetchDataproviders.searchUtils.totalResults > 10" ><a [href] = "linkToSearchDataproviders" >View all {{fetchDataproviders.searchUtils.totalResults}} results</a></div>
|
39
|
<!--search-result [(results)]="fetchDataproviders.results" [(status)]= "fetchDataproviders.searchUtils.status"></search-result-->
|
40
|
</div>
|
41
|
|
42
|
<div *ngIf="(fetchDataproviders.searchUtils.totalResults == 0 && status == errorCodes.DONE)
|
43
|
|| status == errorCodes.NONE || status == errorCodes.ERROR" class = "alert alert-warning">
|
44
|
<div *ngIf="organization != undefined">
|
45
|
No data providers found
|
46
|
<span *ngIf="organization != undefined">
|
47
|
for institution:
|
48
|
<a *ngIf="organization['url']!=''" href="{{organization.url}}">
|
49
|
<span>{{organization['name']}}</span>
|
50
|
</a>
|
51
|
<span *ngIf="organization['url']==''">{{organization['name']}}</span>
|
52
|
</span>
|
53
|
.
|
54
|
</div>
|
55
|
<div *ngIf="organization == undefined && organizationId != ''">
|
56
|
No organization with ID: {{organizationId}} found.
|
57
|
</div>
|
58
|
<div *ngIf="organizationId == ''">
|
59
|
No ID for organization.
|
60
|
</div>
|
61
|
|
62
|
You can still deposit your {{requestFor}} in
|
63
|
<a href="{{zenodo}}" target="_blank">OpenAIRE's Zenodo catch-all repository (<i class="uk-icon-external-link"></i>)</a>
|
64
|
hosted by CERN.
|
65
|
</div>
|
66
|
|
67
|
<button class="uk-button" type="submit" (click)="goToDeposit()">
|
68
|
<i class="uk-icon-arrow-circle-left"></i> Back
|
69
|
</button>
|
70
|
</div>
|
71
|
`
|
72
|
})
|
73
|
|
74
|
export class DepositResultComponent {
|
75
|
public organization: {"name": string, "url": string};
|
76
|
public organizationId: string = "";
|
77
|
|
78
|
public status: number;
|
79
|
public errorCodes:ErrorCodes = new ErrorCodes();
|
80
|
|
81
|
sub: any;
|
82
|
subDataproviders: any;
|
83
|
|
84
|
public fetchDataproviders : FetchDataproviders;
|
85
|
public linkToSearchDataproviders = "";
|
86
|
public zenodo: string;
|
87
|
@Input() compatibility: string = '';
|
88
|
@Input() requestFor: string = "Publications";
|
89
|
|
90
|
constructor (private _router: Router,
|
91
|
private route: ActivatedRoute,
|
92
|
private _searchDataprovidersService: SearchDataprovidersService,
|
93
|
private _organizationService: OrganizationService) {
|
94
|
console.info("depositResult constructor");
|
95
|
|
96
|
this.zenodo = OpenaireProperties.getZenodoURL();
|
97
|
this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService);
|
98
|
|
99
|
this.status = this.errorCodes.LOADING;
|
100
|
console.info("loading");
|
101
|
}
|
102
|
|
103
|
ngOnInit() {
|
104
|
console.info('depositResult init');
|
105
|
|
106
|
this.sub = this.route.queryParams.subscribe(params => {
|
107
|
this.organizationId = params['organizationId'];
|
108
|
console.info("Id is :"+this.organizationId);
|
109
|
if(this.organizationId){
|
110
|
this.getOrganizationInfo();
|
111
|
}
|
112
|
});
|
113
|
}
|
114
|
|
115
|
ngDoCheck() {
|
116
|
if(this.organizationId == "" || this.organizationId == undefined) {
|
117
|
this.organizationId = "";
|
118
|
this.status = this.errorCodes.ERROR;
|
119
|
}
|
120
|
}
|
121
|
|
122
|
ngOnDestroy() {
|
123
|
this.sub.unsubscribe();
|
124
|
if(this.subDataproviders != undefined) {
|
125
|
this.subDataproviders.unsubscribe();
|
126
|
}
|
127
|
}
|
128
|
|
129
|
private searchDataproviders() {
|
130
|
// if(this.organization != undefined) {
|
131
|
// this.fetchDataproviders.getResults(this.organization.name, false, 1, 10);
|
132
|
// } else if(this.organizationId != undefined) {
|
133
|
this.fetchDataproviders.getResultsForDeposit( this.organizationId,this.requestFor, 1, 10);
|
134
|
//}
|
135
|
this.linkToSearchDataproviders = OpenaireProperties.getLinkToSearchDataProviders();
|
136
|
}
|
137
|
|
138
|
private getOrganizationInfo () {
|
139
|
console.info("inside getOrganizationInfo of component");
|
140
|
|
141
|
this._organizationService.getOrganizationInfo(this.organizationId).subscribe(
|
142
|
data => {
|
143
|
this.organization = data.title;
|
144
|
this.status = this.errorCodes.DONE;
|
145
|
this.subDataproviders = this.route.queryParams.subscribe(params => {
|
146
|
this.searchDataproviders();
|
147
|
});
|
148
|
},
|
149
|
err => {
|
150
|
//console.log(err)
|
151
|
|
152
|
if(err.status == '404') {
|
153
|
this.status = this.errorCodes.NONE;
|
154
|
console.info("none");
|
155
|
} else {
|
156
|
this.status = this.errorCodes.ERROR;
|
157
|
console.info("error");
|
158
|
}
|
159
|
}
|
160
|
);
|
161
|
}
|
162
|
|
163
|
goToDeposit() {
|
164
|
if(this.requestFor == "Publications") {
|
165
|
this._router.navigate( ['deposit-publications'] );
|
166
|
} else if(this.requestFor == "Research Data") {
|
167
|
this._router.navigate( ['deposit-datasets'] );
|
168
|
}
|
169
|
}
|
170
|
}
|