Revision 59816
Added by Argiro Kokogiannaki over 3 years ago
claimsByToken.component.ts | ||
---|---|---|
1 |
import {Component, ViewChild, ViewChildren, QueryList, Input, ViewEncapsulation} from '@angular/core'; |
|
2 |
import {Location} from '@angular/common'; |
|
1 |
import {Component, ViewChild, ViewChildren, QueryList, ViewEncapsulation} from '@angular/core'; |
|
3 | 2 |
import {ActivatedRoute, Params, Router} from '@angular/router'; |
4 | 3 |
import {Title, Meta} from '@angular/platform-browser'; |
5 | 4 |
|
6 | 5 |
import {DataTableDirective} from 'angular-datatables'; |
7 |
import {Observable, Subject } from 'rxjs';
|
|
6 |
import {Subject, Subscriber} from 'rxjs';
|
|
8 | 7 |
|
9 | 8 |
import{EnvProperties} from '../../utils/properties/env-properties'; |
10 | 9 |
import {ErrorCodes} from '../../utils/properties/errorCodes'; |
11 | 10 |
import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; |
12 |
|
|
13 |
import {ClaimsDatatablePipe} from '../../utils/pipes/claimsDatatable.pipe'; |
|
14 |
|
|
15 | 11 |
import {RouterHelper} from '../../utils/routerHelper.class'; |
16 | 12 |
|
17 | 13 |
import {ModalSelect} from '../../utils/modal/selectModal.component'; |
... | ... | |
39 | 35 |
}) |
40 | 36 |
export class ClaimsByTokenComponent { |
41 | 37 |
public openaireId: string = ""; |
42 |
public sub: any;
|
|
38 |
public subscriptions: any =[];
|
|
43 | 39 |
public project: any; |
44 | 40 |
private claims:any = []; |
45 | 41 |
public pending_claims: any = []; |
... | ... | |
96 | 92 |
this.curated_status = this.errorCodes.LOADING; |
97 | 93 |
} |
98 | 94 |
ngOnInit() { |
99 |
this.sub = this.route.queryParams.subscribe(params => {
|
|
95 |
this.subscriptions.push(this.route.queryParams.subscribe(params => {
|
|
100 | 96 |
this.mode = "pending"; |
101 | 97 |
this.openaireId = params['openaireId']; |
102 | 98 |
this.selectedRight_PendingMode = new Set<string>(); |
... | ... | |
107 | 103 |
this.validateJWTandToken(); |
108 | 104 |
this.updateTitle("Claims For Project Managers"); |
109 | 105 |
} |
110 |
); |
|
106 |
));
|
|
111 | 107 |
|
112 | 108 |
this.dtOptions[0] = { |
113 | 109 |
//"paging": false, |
... | ... | |
161 | 157 |
// Do not forget to unsubscribe the event |
162 | 158 |
this.dtTrigger[0].unsubscribe(); |
163 | 159 |
this.dtTrigger[1].unsubscribe(); |
160 |
this.subscriptions.forEach(subscription => { |
|
161 |
if (subscription instanceof Subscriber) { |
|
162 |
subscription.unsubscribe(); |
|
163 |
} |
|
164 |
}); |
|
164 | 165 |
} |
165 | 166 |
|
166 | 167 |
/* |
... | ... | |
272 | 273 |
this.activeCuratedPage.page = 1; |
273 | 274 |
this.totalCuratedResults.count = 0; |
274 | 275 |
|
275 |
this.claimsByTokenService.getClaims(this.openaireId, this.properties.claimsAPIURL).subscribe( |
|
276 |
this.subscriptions.push(this.claimsByTokenService.getClaims(this.openaireId, this.properties.claimsAPIURL).subscribe(
|
|
276 | 277 |
data => { |
277 | 278 |
//this.closeLoading(); |
278 | 279 |
this.accessStatus = "valid"; |
... | ... | |
347 | 348 |
this.accessStatus = "invalid"; |
348 | 349 |
//console.log(err); |
349 | 350 |
} |
350 |
); |
|
351 |
));
|
|
351 | 352 |
} else { |
352 | 353 |
this.accessStatus = "invalid"; |
353 | 354 |
} |
... | ... | |
463 | 464 |
} else { |
464 | 465 |
let claimCurationInfo: {"id": string, "approved": boolean} = {"id": claim.id, "approved": approved}; |
465 | 466 |
|
466 |
this.claimsByTokenService.updateClaimCuration(claimCurationInfo, this.properties.claimsAPIURL).subscribe( |
|
467 |
this.subscriptions.push(this.claimsByTokenService.updateClaimCuration(claimCurationInfo, this.properties.claimsAPIURL).subscribe(
|
|
467 | 468 |
data => { |
468 | 469 |
this.selectedRight_CuratedMode.delete(claim.id); |
469 | 470 |
this.selectedWrong_CuratedMode.delete(claim.id); |
... | ... | |
476 | 477 |
this.handleError("Error updating claim curation: "+JSON.stringify(claimCurationInfo), err); |
477 | 478 |
this.curated_status = this.errorCodes.NOT_SAVED; |
478 | 479 |
} |
479 |
); |
|
480 |
));
|
|
480 | 481 |
} |
481 | 482 |
} |
482 | 483 |
} |
... | ... | |
488 | 489 |
this.pending_status = this.errorCodes.LOADING; |
489 | 490 |
//this.openLoading(); |
490 | 491 |
//console.info("Changes Saved!, right-wrong", this.selectedRight_PendingMode, this.selectedWrong_PendingMode); |
491 |
this.claimsByTokenService.updateClaimsCuration(this.selectedRight_PendingMode, this.selectedWrong_PendingMode, this.properties.claimsAPIURL).subscribe( |
|
492 |
this.subscriptions.push(this.claimsByTokenService.updateClaimsCuration(this.selectedRight_PendingMode, this.selectedWrong_PendingMode, this.properties.claimsAPIURL).subscribe(
|
|
492 | 493 |
data => { |
493 | 494 |
//this.closeLoading(); |
494 | 495 |
this.mode = "curated"; |
... | ... | |
501 | 502 |
this.handleError("Error updating claims: right: "+JSON.stringify(this.selectedRight_PendingMode)+" and wrong: "+JSON.stringify(this.selectedWrong_PendingMode), err); |
502 | 503 |
this.pending_status = this.errorCodes.NOT_SAVED; |
503 | 504 |
} |
504 |
); |
|
505 |
));
|
|
505 | 506 |
} |
506 | 507 |
} |
507 | 508 |
|
Also available in: Unified diff
[Library|Trunk]
code clean up:
-remove app.* files from library
-remove unused imports, code, files (Old search pages for results, dataproviders, map search page, etc)
-remove Freeguard from modules
-unsubscribe all subscriptions
-Services: configuration, isvocabularies, user management: unsubscribe from app component or the component that uses them (clearSubscriptions())
-Fetchers: unsubscribe from the component that uses them (clearSubscriptions())