1 |
61381
|
k.triantaf
|
/*
|
2 |
|
|
import {Component, ViewChild, ViewChildren, QueryList, ViewEncapsulation} from '@angular/core';
|
3 |
|
|
import {ActivatedRoute, Params, Router} from '@angular/router';
|
4 |
|
|
import {Title, Meta} from '@angular/platform-browser';
|
5 |
|
|
|
6 |
|
|
import {DataTableDirective} from 'angular-datatables';
|
7 |
|
|
import {Subject, Subscriber} from 'rxjs';
|
8 |
|
|
|
9 |
|
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
10 |
|
|
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
11 |
|
|
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
|
12 |
|
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
13 |
|
|
|
14 |
|
|
import {ModalSelect} from '../../utils/modal/selectModal.component';
|
15 |
|
|
import {ModalLoading} from '../../utils/modal/loading.component';
|
16 |
|
|
|
17 |
|
|
import {ClaimsByTokenService} from './claimsByToken.service';
|
18 |
|
|
|
19 |
|
|
import {Session} from '../../login/utils/helper.class';
|
20 |
|
|
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
|
21 |
|
|
import {properties} from "../../../../environments/environment";
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
@Component({
|
25 |
|
|
selector: 'claims-project-manager',
|
26 |
|
|
templateUrl: 'claimsByToken.component.html',
|
27 |
|
|
styles: [`
|
28 |
|
|
#table1_info, #table1_paginate, #table1_length, #table1_filter,
|
29 |
|
|
#table2_info, #table2_paginate, #table2_length, #table2_filter{
|
30 |
|
|
display: none;
|
31 |
|
|
}
|
32 |
|
|
|
33 |
|
|
`],
|
34 |
|
|
encapsulation: ViewEncapsulation.None // this used in order styles to work
|
35 |
|
|
|
36 |
|
|
})
|
37 |
|
|
export class ClaimsByTokenComponent {
|
38 |
|
|
public openaireId: string = "";
|
39 |
|
|
public subscriptions: any =[];
|
40 |
|
|
public project: any;
|
41 |
|
|
private claims:any = [];
|
42 |
|
|
public pending_claims: any = [];
|
43 |
|
|
public curated_claims: any = [];
|
44 |
|
|
public selectedRight_PendingMode: Set<string>;
|
45 |
|
|
public selectedWrong_PendingMode: Set<string>;
|
46 |
|
|
public selectedRight_CuratedMode: Set<string>;
|
47 |
|
|
public selectedWrong_CuratedMode: Set<string>;
|
48 |
|
|
public editable: Set<number>;
|
49 |
|
|
public contact_person: string[] = ["Konstantina", "Argiro", "Katerina"];
|
50 |
|
|
|
51 |
|
|
private errorCodes: ErrorCodes;
|
52 |
|
|
private errorMessages: ErrorMessagesComponent;
|
53 |
|
|
public pending_status: number;
|
54 |
|
|
public curated_status: number;
|
55 |
|
|
|
56 |
|
|
// when 'valid' show proper claims, when 'invalid' show no matched entry-wanna retry
|
57 |
|
|
public accessStatus: string;// = "empty";
|
58 |
|
|
|
59 |
|
|
public mode: string = "pending";
|
60 |
|
|
public showTables: boolean = true;
|
61 |
|
|
public rowsOnPage = 5;
|
62 |
|
|
public sortOrder = "asc";
|
63 |
|
|
public keyword1:string = "";
|
64 |
|
|
public keyword2:string = "";
|
65 |
|
|
|
66 |
|
|
public activePendingPage:any = {page: 1};
|
67 |
|
|
public totalPendingResults:any = {count: 0};
|
68 |
|
|
public activeCuratedPage:any = {page: 1};
|
69 |
|
|
public totalCuratedResults:any = {count: 0};
|
70 |
|
|
dtTrigger: Subject<any>[] = [];
|
71 |
|
|
private triggered: boolean = false;
|
72 |
|
|
|
73 |
|
|
dtOptions: DataTables.Settings[] = [];
|
74 |
|
|
@ViewChildren(DataTableDirective)
|
75 |
|
|
dtElements: QueryList<any>;
|
76 |
|
|
//@ViewChild("table1") table1: DataTableDirective;
|
77 |
|
|
//@ViewChild("table2") table2: DataTableDirective;
|
78 |
|
|
|
79 |
|
|
@ViewChild (ModalSelect) selectModal : ModalSelect;
|
80 |
|
|
@ViewChild (ModalLoading) loading : ModalLoading ;
|
81 |
|
|
|
82 |
|
|
properties:EnvProperties = properties;
|
83 |
|
|
|
84 |
|
|
public routerHelper:RouterHelper = new RouterHelper();
|
85 |
|
|
|
86 |
|
|
constructor (private route: ActivatedRoute,
|
87 |
|
|
private _router: Router,
|
88 |
|
|
private claimsByTokenService: ClaimsByTokenService,
|
89 |
|
|
private _meta: Meta, private _title: Title) {
|
90 |
|
|
this.errorCodes = new ErrorCodes();
|
91 |
|
|
this.errorMessages = new ErrorMessagesComponent();
|
92 |
|
|
this.pending_status = this.errorCodes.LOADING;
|
93 |
|
|
this.curated_status = this.errorCodes.LOADING;
|
94 |
|
|
}
|
95 |
|
|
ngOnInit() {
|
96 |
|
|
this.subscriptions.push(this.route.queryParams.subscribe(params => {
|
97 |
|
|
this.mode = "pending";
|
98 |
|
|
this.openaireId = params['openaireId'];
|
99 |
|
|
this.selectedRight_PendingMode = new Set<string>();
|
100 |
|
|
this.selectedWrong_PendingMode = new Set<string>();
|
101 |
|
|
this.selectedRight_CuratedMode = new Set<string>();
|
102 |
|
|
this.selectedWrong_CuratedMode = new Set<string>();
|
103 |
|
|
this.editable = new Set<number>();
|
104 |
|
|
this.validateJWTandToken();
|
105 |
|
|
this.updateTitle("Claims For Project Managers");
|
106 |
|
|
}
|
107 |
|
|
));
|
108 |
|
|
|
109 |
|
|
this.dtOptions[0] = {
|
110 |
|
|
//"paging": false,
|
111 |
|
|
//"searching": false,
|
112 |
|
|
//"lengthChange": false,
|
113 |
|
|
"pageLength": this.rowsOnPage,
|
114 |
|
|
"columnDefs": [ {
|
115 |
|
|
"type": "date",
|
116 |
|
|
"targets": 2
|
117 |
|
|
} ],
|
118 |
|
|
"order": [[ 2, 'desc' ]]
|
119 |
|
|
//"pagingType": 'full_numbers',
|
120 |
|
|
/!*"language": {
|
121 |
|
|
"search": "",
|
122 |
|
|
"searchPlaceholder": "Search projects..."
|
123 |
|
|
}*!/
|
124 |
|
|
};
|
125 |
|
|
|
126 |
|
|
this.dtOptions[1] = {
|
127 |
|
|
"pageLength": this.rowsOnPage,
|
128 |
|
|
"columnDefs": [ {
|
129 |
|
|
"type": "date",
|
130 |
|
|
"targets": [2,4]
|
131 |
|
|
} ],
|
132 |
|
|
"order": [[ 4, 'desc' ]]
|
133 |
|
|
};
|
134 |
|
|
|
135 |
|
|
|
136 |
|
|
this.dtTrigger[0] = new Subject<any>();
|
137 |
|
|
this.dtTrigger[1] = new Subject<any>();
|
138 |
|
|
}
|
139 |
|
|
|
140 |
|
|
ngAfterViewInit(): void {
|
141 |
|
|
$.fn['dataTable'].ext.search.push((settings, data, dataIndex) => {
|
142 |
|
|
if(settings.sTableId == 'table1') {
|
143 |
|
|
if (this.filterData(data, this.keyword1)) {
|
144 |
|
|
return true;
|
145 |
|
|
}
|
146 |
|
|
return false;
|
147 |
|
|
} else if(settings.sTableId == 'table2') {
|
148 |
|
|
if (this.filterData(data, this.keyword2)) {
|
149 |
|
|
return true;
|
150 |
|
|
}
|
151 |
|
|
return false;
|
152 |
|
|
}
|
153 |
|
|
});
|
154 |
|
|
}
|
155 |
|
|
|
156 |
|
|
ngOnDestroy(): void {
|
157 |
|
|
$.fn['dataTable'].ext.search.pop();
|
158 |
|
|
// Do not forget to unsubscribe the event
|
159 |
|
|
this.dtTrigger[0].unsubscribe();
|
160 |
|
|
this.dtTrigger[1].unsubscribe();
|
161 |
|
|
this.subscriptions.forEach(subscription => {
|
162 |
|
|
if (subscription instanceof Subscriber) {
|
163 |
|
|
subscription.unsubscribe();
|
164 |
|
|
}
|
165 |
|
|
});
|
166 |
|
|
}
|
167 |
|
|
|
168 |
|
|
/!*
|
169 |
|
|
Trigger a table draw in order to get the initial filtering
|
170 |
|
|
*!/
|
171 |
|
|
triggerInitialLoad(){
|
172 |
|
|
this.triggered = true;
|
173 |
|
|
//console.info("triggerInitialLoad");
|
174 |
|
|
setTimeout(function(){
|
175 |
|
|
/!*var table1 = <any>$('#table1').DataTable();
|
176 |
|
|
table1.page( 0 ).draw( false );
|
177 |
|
|
|
178 |
|
|
var table2 = <any>$('#table2').DataTable();
|
179 |
|
|
table2.page( 0 ).draw( false );*!/
|
180 |
|
|
}, 500);
|
181 |
|
|
setTimeout(() => {
|
182 |
|
|
this.dtTrigger[0].next();
|
183 |
|
|
this.dtTrigger[1].next();
|
184 |
|
|
});
|
185 |
|
|
|
186 |
|
|
}
|
187 |
|
|
|
188 |
|
|
rerender(): void {
|
189 |
|
|
//console.info("RERENDER");
|
190 |
|
|
this.dtElements.forEach((dtElement: DataTableDirective, index: number) => {
|
191 |
|
|
dtElement.dtInstance.then((dtInstance: any) => {
|
192 |
|
|
// Destroy the table first
|
193 |
|
|
dtInstance.destroy();
|
194 |
|
|
|
195 |
|
|
// Call the dtTrigger to rerender again
|
196 |
|
|
this.dtTrigger[index].next();
|
197 |
|
|
});
|
198 |
|
|
});
|
199 |
|
|
}
|
200 |
|
|
|
201 |
|
|
filterData(row: any, query: string) {
|
202 |
|
|
if(!Session.isLoggedIn()){
|
203 |
|
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
204 |
|
|
} else {
|
205 |
|
|
let returnValue: boolean = false;
|
206 |
|
|
|
207 |
|
|
if(query) {
|
208 |
|
|
for(var i=0; i <3; i++){
|
209 |
|
|
var r= this.filterQuery(row[i], query);
|
210 |
|
|
if(r) {
|
211 |
|
|
returnValue = true;
|
212 |
|
|
break;
|
213 |
|
|
}
|
214 |
|
|
}
|
215 |
|
|
|
216 |
|
|
if(!returnValue) {
|
217 |
|
|
return false;
|
218 |
|
|
}
|
219 |
|
|
}
|
220 |
|
|
|
221 |
|
|
return true;
|
222 |
|
|
}
|
223 |
|
|
}
|
224 |
|
|
|
225 |
|
|
filterQuery(data, query){
|
226 |
|
|
if(data.toLowerCase().indexOf(query.toLowerCase()) > -1){
|
227 |
|
|
return true;
|
228 |
|
|
}else{
|
229 |
|
|
return false;
|
230 |
|
|
}
|
231 |
|
|
}
|
232 |
|
|
|
233 |
|
|
refreshTable(page:number, whichTable: string) {
|
234 |
|
|
if(!Session.isLoggedIn()){
|
235 |
|
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
236 |
|
|
} else {
|
237 |
|
|
if(whichTable == "pending") {
|
238 |
|
|
var table = $('#table1').DataTable();
|
239 |
|
|
table.page( page - 1 ).draw( false );
|
240 |
|
|
|
241 |
|
|
var info = table.page.info();
|
242 |
|
|
|
243 |
|
|
this.activePendingPage.page = page;//$event.value;
|
244 |
|
|
this.totalPendingResults.count = info.recordsDisplay;
|
245 |
|
|
} else if(whichTable == 'curated') {
|
246 |
|
|
var table = $('#table2').DataTable();
|
247 |
|
|
table.page( page - 1 ).draw( false );
|
248 |
|
|
|
249 |
|
|
var info = table.page.info();
|
250 |
|
|
|
251 |
|
|
this.activeCuratedPage.page = page;//$event.value;
|
252 |
|
|
this.totalCuratedResults.count = info.recordsDisplay;
|
253 |
|
|
}
|
254 |
|
|
}
|
255 |
|
|
|
256 |
|
|
//table.mfActivePage=$event.value;
|
257 |
|
|
//table.setPage(table.mfActivePage, this.rowsOnPage);
|
258 |
|
|
}
|
259 |
|
|
|
260 |
|
|
validateJWTandToken() {
|
261 |
|
|
if(!Session.isLoggedIn()){
|
262 |
|
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
263 |
|
|
} else {
|
264 |
|
|
if(this.openaireId) {
|
265 |
|
|
this.pending_status = this.errorCodes.LOADING;
|
266 |
|
|
this.curated_status = this.errorCodes.LOADING;
|
267 |
|
|
|
268 |
|
|
this.showTables = false;
|
269 |
|
|
this.pending_claims = [];
|
270 |
|
|
this.curated_claims = [];
|
271 |
|
|
|
272 |
|
|
this.activePendingPage.page = 1;
|
273 |
|
|
this.totalPendingResults.count = 0;
|
274 |
|
|
this.activeCuratedPage.page = 1;
|
275 |
|
|
this.totalCuratedResults.count = 0;
|
276 |
|
|
|
277 |
|
|
this.subscriptions.push(this.claimsByTokenService.getClaims(this.openaireId, this.properties.claimsAPIURL).subscribe(
|
278 |
|
|
data => {
|
279 |
|
|
//this.closeLoading();
|
280 |
|
|
this.accessStatus = "valid";
|
281 |
|
|
this.claims = data.data;
|
282 |
|
|
for(let claim of this.claims) {
|
283 |
|
|
if(claim.targetType == "project") {
|
284 |
|
|
this.project = claim.target;
|
285 |
|
|
} else {
|
286 |
|
|
this.project = claim.source;
|
287 |
|
|
}
|
288 |
|
|
if(claim.curatedBy) {
|
289 |
|
|
this.curated_claims.push(claim);
|
290 |
|
|
} else {
|
291 |
|
|
this.pending_claims.push(claim);
|
292 |
|
|
}
|
293 |
|
|
}
|
294 |
|
|
|
295 |
|
|
this.totalPendingResults.count = this.pending_claims.length;
|
296 |
|
|
this.totalCuratedResults.count = this.curated_claims.length;
|
297 |
|
|
|
298 |
|
|
if(this.project) {
|
299 |
|
|
this.updateTitle("Claims For Project Managers - "+this.project.name);
|
300 |
|
|
}
|
301 |
|
|
this.showTables = true;
|
302 |
|
|
|
303 |
|
|
if(!this.triggered) {
|
304 |
|
|
//console.info("initial load");
|
305 |
|
|
this.triggerInitialLoad();
|
306 |
|
|
} else {
|
307 |
|
|
//console.info("rerender");
|
308 |
|
|
var table1 = $('#table1').DataTable();
|
309 |
|
|
table1.clear();
|
310 |
|
|
|
311 |
|
|
var table2 = $('#table2').DataTable();
|
312 |
|
|
table2.clear();
|
313 |
|
|
|
314 |
|
|
this.rerender();
|
315 |
|
|
}
|
316 |
|
|
|
317 |
|
|
this.pending_status = this.errorCodes.DONE;
|
318 |
|
|
this.curated_status = this.errorCodes.DONE;
|
319 |
|
|
},
|
320 |
|
|
err => {
|
321 |
|
|
this.handleError("Error getting claims for openaire id: "+this.openaireId, err);
|
322 |
|
|
this.pending_status = this.errorMessages.getErrorCode(err.status);
|
323 |
|
|
this.curated_status = this.pending_status;
|
324 |
|
|
|
325 |
|
|
/!*if(err.status == '404') {
|
326 |
|
|
this.pending_status = this.errorCodes.NOT_FOUND;
|
327 |
|
|
this.curated_status = this.errorCodes.NOT_FOUND;
|
328 |
|
|
} else if(err.status == '500') {
|
329 |
|
|
this.pending_status = this.errorCodes.ERROR;
|
330 |
|
|
this.curated_status = this.errorCodes.ERROR;
|
331 |
|
|
} else {
|
332 |
|
|
this.pending_status = this.errorCodes.NOT_AVAILABLE;
|
333 |
|
|
this.curated_status = this.errorCodes.NOT_AVAILABLE;
|
334 |
|
|
}*!/
|
335 |
|
|
this.showTables = true;
|
336 |
|
|
|
337 |
|
|
if(!this.triggered) {
|
338 |
|
|
this.triggerInitialLoad();
|
339 |
|
|
} else {
|
340 |
|
|
var table1 = $('#table1').DataTable();
|
341 |
|
|
table1.clear();
|
342 |
|
|
|
343 |
|
|
var table2 = $('#table2').DataTable();
|
344 |
|
|
table2.clear();
|
345 |
|
|
|
346 |
|
|
this.rerender();
|
347 |
|
|
}
|
348 |
|
|
|
349 |
|
|
this.accessStatus = "invalid";
|
350 |
|
|
//console.log(err);
|
351 |
|
|
}
|
352 |
|
|
));
|
353 |
|
|
} else {
|
354 |
|
|
this.accessStatus = "invalid";
|
355 |
|
|
}
|
356 |
|
|
}
|
357 |
|
|
}
|
358 |
|
|
|
359 |
|
|
selectApprove(id:string, event, mode: string) {
|
360 |
|
|
if(!Session.isLoggedIn()){
|
361 |
|
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
362 |
|
|
} else {
|
363 |
|
|
var value = event.currentTarget.checked;
|
364 |
|
|
if(value){
|
365 |
|
|
if(mode == "pending") {
|
366 |
|
|
this.selectedRight_PendingMode.add(id);
|
367 |
|
|
this.selectedWrong_PendingMode.delete(id);
|
368 |
|
|
} else {
|
369 |
|
|
this.selectedRight_CuratedMode.add(id);
|
370 |
|
|
this.selectedWrong_CuratedMode.delete(id);
|
371 |
|
|
}
|
372 |
|
|
}else{
|
373 |
|
|
if(mode == "pending") {
|
374 |
|
|
this.selectedRight_PendingMode.delete(id);
|
375 |
|
|
}
|
376 |
|
|
// } else {
|
377 |
|
|
// this.selectedRight_CuratedMode.delete(id);
|
378 |
|
|
// this.selectedWrong_CuratedMode.add(id);
|
379 |
|
|
// }
|
380 |
|
|
}
|
381 |
|
|
}
|
382 |
|
|
}
|
383 |
|
|
|
384 |
|
|
selectDisapprove(id:string, event, mode: string) {
|
385 |
|
|
if(!Session.isLoggedIn()){
|
386 |
|
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
387 |
|
|
} else {
|
388 |
|
|
var value = event.currentTarget.checked;
|
389 |
|
|
if(value){
|
390 |
|
|
if(mode == "pending") {
|
391 |
|
|
this.selectedWrong_PendingMode.add(id);
|
392 |
|
|
this.selectedRight_PendingMode.delete(id);
|
393 |
|
|
} else {
|
394 |
|
|
this.selectedWrong_CuratedMode.add(id);
|
395 |
|
|
this.selectedRight_CuratedMode.delete(id);
|
396 |
|
|
}
|
397 |
|
|
}else{
|
398 |
|
|
if(mode == "pending") {
|
399 |
|
|
this.selectedWrong_PendingMode.delete(id);
|
400 |
|
|
}
|
401 |
|
|
// } else {
|
402 |
|
|
// this.selectedWrong_CuratedMode.delete(id);
|
403 |
|
|
// this.selectedRight_CuratedMode.add(id);
|
404 |
|
|
// }
|
405 |
|
|
}
|
406 |
|
|
}
|
407 |
|
|
}
|
408 |
|
|
|
409 |
|
|
isSelected(id:string, set:Set<string>) {
|
410 |
|
|
return set.has(id);
|
411 |
|
|
}
|
412 |
|
|
/!*
|
413 |
|
|
isSelectedWrong(id:string) {
|
414 |
|
|
return this.selectedWrong.has(id);
|
415 |
|
|
}
|
416 |
|
|
*!/
|
417 |
|
|
isRight_CuratedMode(claim: any) {
|
418 |
|
|
if(this.isSelected(claim.id, this.selectedRight_CuratedMode)) {
|
419 |
|
|
return true;
|
420 |
|
|
} else if(claim.approved == true && !this.isSelected(claim.id, this.selectedWrong_CuratedMode)) {
|
421 |
|
|
return true;
|
422 |
|
|
}
|
423 |
|
|
|
424 |
|
|
return false;
|
425 |
|
|
}
|
426 |
|
|
|
427 |
|
|
isWrong_CuratedMode(claim: any) {
|
428 |
|
|
if(this.isSelected(claim.id, this.selectedWrong_CuratedMode)) {
|
429 |
|
|
return true;
|
430 |
|
|
} else if(claim.approved == false && !this.isSelected(claim.id, this.selectedRight_CuratedMode)) {
|
431 |
|
|
return true;
|
432 |
|
|
}
|
433 |
|
|
|
434 |
|
|
return false;
|
435 |
|
|
}
|
436 |
|
|
|
437 |
|
|
cancelEditOfCuration(claim: any) {
|
438 |
|
|
if(!Session.isLoggedIn()){
|
439 |
|
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
440 |
|
|
} else {
|
441 |
|
|
if(claim.approved) {
|
442 |
|
|
//this.selectedRight_CuratedMode.add(claim.id);
|
443 |
|
|
this.selectedWrong_CuratedMode.delete(claim.id);
|
444 |
|
|
} else {
|
445 |
|
|
this.selectedRight_CuratedMode.delete(claim.id);
|
446 |
|
|
//this.selectedWrong_CuratedMode.add(claim.id);
|
447 |
|
|
}
|
448 |
|
|
}
|
449 |
|
|
}
|
450 |
|
|
|
451 |
|
|
saveEdited(claim: any, editable_index: number) {
|
452 |
|
|
if(!Session.isLoggedIn()){
|
453 |
|
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
454 |
|
|
} else {
|
455 |
|
|
this.curated_status = this.errorCodes.LOADING;
|
456 |
|
|
|
457 |
|
|
let approved: boolean = this.isRight_CuratedMode(claim);
|
458 |
|
|
|
459 |
|
|
if(approved == claim.approved) {
|
460 |
|
|
this.selectedRight_CuratedMode.delete(claim.id);
|
461 |
|
|
this.selectedWrong_CuratedMode.delete(claim.id);
|
462 |
|
|
this.editable.delete(editable_index);
|
463 |
|
|
|
464 |
|
|
this.curated_status = this.errorCodes.DONE;
|
465 |
|
|
} else {
|
466 |
|
|
let claimCurationInfo: {"id": string, "approved": boolean} = {"id": claim.id, "approved": approved};
|
467 |
|
|
|
468 |
|
|
this.subscriptions.push(this.claimsByTokenService.updateClaimCuration(claimCurationInfo, this.properties.claimsAPIURL).subscribe(
|
469 |
|
|
data => {
|
470 |
|
|
this.selectedRight_CuratedMode.delete(claim.id);
|
471 |
|
|
this.selectedWrong_CuratedMode.delete(claim.id);
|
472 |
|
|
this.editable.delete(editable_index);
|
473 |
|
|
|
474 |
|
|
this.validateJWTandToken();
|
475 |
|
|
},
|
476 |
|
|
err => {
|
477 |
|
|
//console.log(err);
|
478 |
|
|
this.handleError("Error updating claim curation: "+JSON.stringify(claimCurationInfo), err);
|
479 |
|
|
this.curated_status = this.errorCodes.NOT_SAVED;
|
480 |
|
|
}
|
481 |
|
|
));
|
482 |
|
|
}
|
483 |
|
|
}
|
484 |
|
|
}
|
485 |
|
|
|
486 |
|
|
saveChanges() {
|
487 |
|
|
if(!Session.isLoggedIn()){
|
488 |
|
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
489 |
|
|
} else {
|
490 |
|
|
this.pending_status = this.errorCodes.LOADING;
|
491 |
|
|
//this.openLoading();
|
492 |
|
|
//console.info("Changes Saved!, right-wrong", this.selectedRight_PendingMode, this.selectedWrong_PendingMode);
|
493 |
|
|
this.subscriptions.push(this.claimsByTokenService.updateClaimsCuration(this.selectedRight_PendingMode, this.selectedWrong_PendingMode, this.properties.claimsAPIURL).subscribe(
|
494 |
|
|
data => {
|
495 |
|
|
//this.closeLoading();
|
496 |
|
|
this.mode = "curated";
|
497 |
|
|
this.clearCheckboxes();
|
498 |
|
|
this.validateJWTandToken();
|
499 |
|
|
},
|
500 |
|
|
err => {
|
501 |
|
|
//this.closeLoading();
|
502 |
|
|
//console.log(err);
|
503 |
|
|
this.handleError("Error updating claims: right: "+JSON.stringify(this.selectedRight_PendingMode)+" and wrong: "+JSON.stringify(this.selectedWrong_PendingMode), err);
|
504 |
|
|
this.pending_status = this.errorCodes.NOT_SAVED;
|
505 |
|
|
}
|
506 |
|
|
));
|
507 |
|
|
}
|
508 |
|
|
}
|
509 |
|
|
|
510 |
|
|
clearCheckboxes() {
|
511 |
|
|
if(!Session.isLoggedIn()){
|
512 |
|
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
513 |
|
|
} else {
|
514 |
|
|
this.pending_status = this.errorCodes.LOADING;
|
515 |
|
|
this.selectedRight_PendingMode.clear();
|
516 |
|
|
this.selectedWrong_PendingMode.clear();
|
517 |
|
|
this.pending_status = this.errorCodes.DONE;
|
518 |
|
|
}
|
519 |
|
|
}
|
520 |
|
|
|
521 |
|
|
public openLoading(){
|
522 |
|
|
if(this.loading){
|
523 |
|
|
this.loading.open();
|
524 |
|
|
}
|
525 |
|
|
}
|
526 |
|
|
public closeLoading(){
|
527 |
|
|
if(this.loading){
|
528 |
|
|
this.loading.close();
|
529 |
|
|
}
|
530 |
|
|
}
|
531 |
|
|
|
532 |
|
|
curatorSelected(selected: string) {
|
533 |
|
|
//console.info("selected curator: "+selected);
|
534 |
|
|
}
|
535 |
|
|
|
536 |
|
|
public openSelect(){
|
537 |
|
|
if(this.selectModal){
|
538 |
|
|
this.selectModal.open();
|
539 |
|
|
}
|
540 |
|
|
}
|
541 |
|
|
|
542 |
|
|
public setMessageSelect(message: string){
|
543 |
|
|
if(this.selectModal){
|
544 |
|
|
this.selectModal.message = message;
|
545 |
|
|
}
|
546 |
|
|
}
|
547 |
|
|
|
548 |
|
|
public setOptionsSelect(options: string[]){
|
549 |
|
|
if(this.selectModal){
|
550 |
|
|
this.selectModal.options = options;
|
551 |
|
|
}
|
552 |
|
|
}
|
553 |
|
|
|
554 |
|
|
totalPages(totalResults: number): number {
|
555 |
|
|
let totalPages:any = totalResults/(this.rowsOnPage);
|
556 |
|
|
if(!(Number.isInteger(totalPages))) {
|
557 |
|
|
totalPages = (parseInt(totalPages, 10) + 1);
|
558 |
|
|
}
|
559 |
|
|
return totalPages;
|
560 |
|
|
}
|
561 |
|
|
|
562 |
|
|
updateTitle(title:string){
|
563 |
|
|
var _prefix ="OpenAIRE | ";
|
564 |
|
|
var _title = _prefix + ((title.length> 50 ) ?title.substring(0,50):title);
|
565 |
|
|
this._meta.updateTag({content:_title},"property='og:title'");
|
566 |
|
|
this._title.setTitle(_title);
|
567 |
|
|
|
568 |
|
|
}
|
569 |
|
|
|
570 |
|
|
private handleError(message: string, error) {
|
571 |
|
|
console.error("Claims Project Manager Page: "+message, error);
|
572 |
|
|
}
|
573 |
|
|
}
|
574 |
|
|
*/
|