1
|
import {Component, ViewChild} from '@angular/core';
|
2
|
import {ElementRef, Input} from '@angular/core';
|
3
|
import {ActivatedRoute, Router} from '@angular/router';
|
4
|
|
5
|
import {Observable} from 'rxjs';
|
6
|
|
7
|
import {EnvProperties} from '../../../utils/properties/env-properties';
|
8
|
import {DeletedByInferenceResult} from '../../../utils/entities/deletedByInferenceResult';
|
9
|
import {RouterHelper} from '../../../utils/routerHelper.class';
|
10
|
import {ErrorCodes} from '../../../utils/properties/errorCodes';
|
11
|
|
12
|
import {DeletedByInferenceService} from './deletedByInference.service';
|
13
|
|
14
|
import {zip} from 'rxjs';
|
15
|
|
16
|
|
17
|
@Component({
|
18
|
selector: 'deletedByInference',
|
19
|
template: `
|
20
|
<errorMessages [status]="[status]" [type]="type" tab_error_class=true></errorMessages>
|
21
|
|
22
|
<div>
|
23
|
<div *ngIf="results.length > pageSize" class="uk-margin-bottom">
|
24
|
<span class="uk-h6">{{results.length | number}} {{type}}, page {{page | number}} of {{totalPages(results.length) | number}}</span>
|
25
|
<paging-no-load class="uk-float-right" [currentPage]="page" [totalResults]="results.length" [size]="pageSize" (pageChange)="updatePage($event)"></paging-no-load>
|
26
|
</div>
|
27
|
|
28
|
<ul class="uk-list uk-list-divider uk-margin">
|
29
|
<li *ngFor="let result of results.slice((page-1)*pageSize, page*pageSize)">
|
30
|
<h5 *ngIf="result.title" class="uk-margin-remove-bottom">
|
31
|
<span [innerHTML]="result.title"></span>
|
32
|
</h5>
|
33
|
<h5 *ngIf="!result.title">
|
34
|
<span>[no title available]</span>
|
35
|
</h5>
|
36
|
|
37
|
<span *ngIf="result.types && result.types.length > 0"class="uk-label custom-label label-blue label-publication" title="Type">{{result.types.join(", ")}}</span>{{" "}}
|
38
|
<span *ngIf="result.languages && result.languages.length > 0" class="uk-label custom-label label-language " title="Language">{{result.languages.join(", ")}}</span>{{" "}}
|
39
|
<span *ngIf="result.countries && result.countries.length > 0" class="uk-label custom-label label-country " title="Country">{{result.countries.join(", ")}}</span>{{" "}}
|
40
|
<span *ngIf="result.accessMode" [class]="'uk-label custom-label label-'+ result.accessMode " title="Access Mode">{{result.accessMode}}</span>{{" "}}
|
41
|
|
42
|
<div>
|
43
|
<showAuthors [authors]="result.authors"></showAuthors>
|
44
|
<span *ngIf="result.date != ''">({{result.date}})</span>
|
45
|
</div>
|
46
|
|
47
|
<div *ngIf="result.identifiers && result.identifiers.size > 0">
|
48
|
<showIdentifiers [identifiers]="result.identifiers"></showIdentifiers>
|
49
|
</div>
|
50
|
|
51
|
<div *ngIf="result['fundedByProjects'] != undefined">
|
52
|
<span class="uk-text-bold"> Project: </span>
|
53
|
<span *ngFor="let project of result['fundedByProjects'].slice(0,15) let i=index">
|
54
|
{{project['funderShortname']?project['funderShortname']:project['funderName']}}
|
55
|
| {{ project['acronym']?project['acronym']:(project['title'].length>25?project['title'].substring(0,25)+'...':project['title'])}} ({{project.code}})<span
|
56
|
|
57
|
*ngIf="!project.id">{{project['funderShortname']?project['funderShortname']:project['funderName']}}<span
|
58
|
*ngIf="project['acronym'] || project['title']"> | {{ project['acronym']?project['acronym']:(project['title'].length>25?project['title'].substring(0,25)+'...':project['title'])}}</span><span
|
59
|
*ngIf="project.code">({{project.code}})</span></span><span
|
60
|
|
61
|
*ngIf="i < result['fundedByProjects'].length-1">,</span>
|
62
|
</span>
|
63
|
<span *ngIf="result['fundedByProjects'].length > 15">...</span>
|
64
|
</div>
|
65
|
|
66
|
<div *ngIf="result.hostedBy_collectedFrom != undefined && result.hostedBy_collectedFrom.length > 0">
|
67
|
<span class="uk-text-bold"> Download From: </span>
|
68
|
<span *ngFor="let available of result.hostedBy_collectedFrom let i=index">
|
69
|
<span *ngIf="available.downloadUrl.length > 1"
|
70
|
class="custom-external custom-icon">
|
71
|
{{available.downloadName}}
|
72
|
<span *ngFor="let url of available.downloadUrl; let i=index;">
|
73
|
<a href="{{url}}" target="_blank"
|
74
|
attr.uk-tooltip="pos:right; delay:10">
|
75
|
[{{(i+1) | number}}]
|
76
|
</a>
|
77
|
</span>
|
78
|
</span><a
|
79
|
class="custom-external custom-icon"
|
80
|
*ngIf="available['downloadUrl'].length == 1"
|
81
|
href="{{available['downloadUrl']}}"
|
82
|
target="_blank"
|
83
|
attr.uk-tooltip="pos:right; delay:10">
|
84
|
{{available.downloadName}}</a><span
|
85
|
*ngIf="i < result['hostedBy_collectedFrom'].length-1">,</span>
|
86
|
</span>
|
87
|
<span *ngIf="result['hostedBy_collectedFrom'].length > 15">...</span>
|
88
|
</div>
|
89
|
|
90
|
<div *ngIf="result.description" class="uk-margin-bottom uk-text-justify descriptionText">
|
91
|
{{result.description}}
|
92
|
</div>
|
93
|
|
94
|
|
95
|
|
96
|
</li>
|
97
|
</ul>
|
98
|
</div>
|
99
|
`
|
100
|
})
|
101
|
|
102
|
export class DeletedByInferenceComponent {
|
103
|
public results: DeletedByInferenceResult[] = [];
|
104
|
@Input() id: string;
|
105
|
@Input() ids: string[] = [];
|
106
|
@Input() type: string;
|
107
|
|
108
|
// Custom tab paging variables
|
109
|
public page: number = 1;
|
110
|
public pageSize: number = 5;
|
111
|
|
112
|
public status: number;
|
113
|
public routerHelper:RouterHelper = new RouterHelper();
|
114
|
public errorCodes:ErrorCodes = new ErrorCodes();
|
115
|
|
116
|
sub: any;
|
117
|
properties:EnvProperties;
|
118
|
|
119
|
constructor ( private element: ElementRef,
|
120
|
private _deletedByInferenceService: DeletedByInferenceService,
|
121
|
private route: ActivatedRoute,
|
122
|
private _router: Router) {
|
123
|
}
|
124
|
|
125
|
ngOnInit() {
|
126
|
this.route.data
|
127
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
128
|
this.properties = data.envSpecific;
|
129
|
|
130
|
});
|
131
|
this.sub = this.route.queryParams.subscribe(data => {
|
132
|
this.errorCodes = new ErrorCodes();
|
133
|
this.status = this.errorCodes.LOADING;
|
134
|
|
135
|
this.getDeletedByInference();
|
136
|
});
|
137
|
}
|
138
|
|
139
|
ngOnDestroy() {}
|
140
|
|
141
|
getDeletedByInference() {
|
142
|
this.results = [];
|
143
|
this.status = this.errorCodes.LOADING;
|
144
|
/*
|
145
|
if(this.ids) {
|
146
|
var allRequests = [];
|
147
|
for(let id of this.ids) {
|
148
|
allRequests.push(this._deletedByInferenceService.getDeletedByInferencePublications(id, this.properties));
|
149
|
}
|
150
|
|
151
|
zip.apply(null, allRequests).subscribe(
|
152
|
// this._deletedByInferenceService.getDeletedByInferencePublications(id, this.properties).subscribe(
|
153
|
data => {
|
154
|
this.results = data;
|
155
|
this.status = this.errorCodes.DONE;
|
156
|
},
|
157
|
error => {
|
158
|
if(error.status == '404') {
|
159
|
this.status = this.errorCodes.NOT_FOUND;
|
160
|
} else if(error.status == '500') {
|
161
|
this.status = this.errorCodes.ERROR;
|
162
|
} else {
|
163
|
this.status = this.errorCodes.NOT_AVAILABLE;
|
164
|
}
|
165
|
}
|
166
|
);
|
167
|
}
|
168
|
*/
|
169
|
this._deletedByInferenceService.getDeletedByInferenceResults(this.id, String(this.ids.length), this.properties).subscribe(
|
170
|
data => {
|
171
|
this.results = data;
|
172
|
this.status = this.errorCodes.DONE;
|
173
|
},
|
174
|
error => {
|
175
|
if(error.status == '404') {
|
176
|
this.status = this.errorCodes.NOT_FOUND;
|
177
|
} else if(error.status == '500') {
|
178
|
this.status = this.errorCodes.ERROR;
|
179
|
} else {
|
180
|
this.status = this.errorCodes.NOT_AVAILABLE;
|
181
|
}
|
182
|
}
|
183
|
);
|
184
|
}
|
185
|
|
186
|
public totalPages(totalResults: number): number {
|
187
|
let totalPages:any = totalResults/this.pageSize;
|
188
|
if(!(Number.isInteger(totalPages))) {
|
189
|
totalPages = (parseInt(totalPages, this.pageSize) + 1);
|
190
|
}
|
191
|
return totalPages;
|
192
|
}
|
193
|
|
194
|
public updatePage($event) {
|
195
|
this.page = $event.value;
|
196
|
}
|
197
|
}
|