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