@@ -116,8 +145,10 @@ import {Session} from '../../login/utils/helper.class';
})
export class ClaimsByTokenComponent {
+ //change true - false to accept: yes - no
public token: string = "";
public sub: any;
+ public project: any;
private claims:any = [];
public pending_claims: any = [];
public curated_claims: any = [];
@@ -132,6 +163,8 @@ export class ClaimsByTokenComponent {
@ViewChild (ModalSelect) selectModal : ModalSelect;
@ViewChild (ModalLoading) loading : ModalLoading ;
+ public routerHelper:RouterHelper = new RouterHelper();
+
constructor ( private route: ActivatedRoute, private _router:Router, private claimsByTokenService: ClaimsByTokenService ) {
}
@@ -150,15 +183,20 @@ export class ClaimsByTokenComponent {
}
validateJWTandToken() {
- var user_token=Session.getUserJwt();
+ var jwtToken=Session.getUserJwt();
if(this.token) {
- this.claimsByTokenService.getClaims(this.token, user_token).subscribe(
+ this.claimsByTokenService.getClaims(this.token, jwtToken).subscribe(
data => {
this.closeLoading();
this.accessStatus = "valid";
//console.info(data);
this.claims = data.data;
for(let claim of this.claims) {
+ if(claim.targetType == "project") {
+ this.project = claim.target;
+ } else {
+ this.project = claim.source;
+ }
if(claim.curatedBy) {
this.curated_claims.push(claim);
} else {
@@ -229,8 +267,9 @@ export class ClaimsByTokenComponent {
saveChanges() {
console.info("Changes Saved!");
- /*
- this.claimsByTokenService.updateClaimsCuration(this.token, this.selectedRight, this.selectedWrong).subscribe(
+ var jwtToken=Session.getUserJwt();
+
+ this.claimsByTokenService.updateClaimsCuration(jwtToken, this.selectedRight, this.selectedWrong).subscribe(
data => {
console.info(data);
},
@@ -238,7 +277,7 @@ export class ClaimsByTokenComponent {
console.log(err);
}
);
- */
+
}
public closeLoading(){
diff --git a/portal-2/src/app/claims/claimsByToken/claimsByToken.module.ts b/portal-2/src/app/claims/claimsByToken/claimsByToken.module.ts
index f8895afe..a9e68591 100644
--- a/portal-2/src/app/claims/claimsByToken/claimsByToken.module.ts
+++ b/portal-2/src/app/claims/claimsByToken/claimsByToken.module.ts
@@ -1,4 +1,5 @@
import { NgModule } from '@angular/core';
+import { RouterModule } from '@angular/router';
import { SharedModule } from '../../shared/shared.module';
import { ClaimsByTokenComponent } from './claimsByToken.component';
@@ -14,6 +15,7 @@ import {LoginGuard} from'../../login/loginGuard.guard';
@NgModule({
imports: [
+ RouterModule,
SharedModule,
ClaimsByTokenRoutingModule,
ClaimEntityFormatterModule,
diff --git a/portal-2/src/app/claims/claimsByToken/claimsByToken.service.ts b/portal-2/src/app/claims/claimsByToken/claimsByToken.service.ts
index cab2fe27..d38a7c96 100644
--- a/portal-2/src/app/claims/claimsByToken/claimsByToken.service.ts
+++ b/portal-2/src/app/claims/claimsByToken/claimsByToken.service.ts
@@ -10,12 +10,11 @@ export class ClaimsByTokenService {
constructor(private http: Http, public _cache: CacheService) {}
- getClaims(token: string, user_token: string):any {
+ getClaims(token: string, jwtToken: string):any {
console.info("getClaims in service");
let url = OpenaireProperties.getClaimsAPIURL()+"projects/corda__h2020::94c962e736df90a5075a7f660ba3d7f6/claims"
- +"?&token="+user_token;
-console.info(url);
+ +"?&token="+jwtToken;
let key = url;
if (this._cache.has(key)) {
return Observable.of(this._cache.get(key));
@@ -43,17 +42,24 @@ console.info(url);
}
*/
- updateClaimsCuration(token: string, selectedRight: Set
, selectedWrong: Set) {
- let url = OpenaireProperties.getClaimsAPIURL(); // What else?
- let claimsCurationInfo: any = [];
- for(let selected in selectedRight) {
- let claimCurationInfo: any = {"claim_id": selected, "approved": true, "token": token};
- claimsCurationInfo.add(claimCurationInfo);
- }
- for(let selected in selectedWrong) {
- let claimCurationInfo: any = {"claim_id": selected, "approved": false, "token": token};
- claimsCurationInfo.add(claimCurationInfo);
- }
+ updateClaimsCuration(jwtToken: string, selectedRight: Set, selectedWrong: Set) {
+ let url = OpenaireProperties.getClaimsAPIURL() + "curate/bulk?token="+jwtToken;
+ let claimsCurationInfo: any = []; //e.g.: [{"id":"2","approved":true},{"id":"1","approved":true}]
+
+ selectedRight.forEach(function(selected) {
+ console.info(selected);
+ let claimCurationInfo: {"id": string, "approved": boolean} = {"id": selected, "approved": true};
+ claimsCurationInfo.push(claimCurationInfo);
+ });
+
+ selectedWrong.forEach(function(selected) {
+ let claimCurationInfo: any = {"id": selected, "approved": false};
+ claimsCurationInfo.push(claimCurationInfo);
+ });
+
+ console.info("\n\n"+claimsCurationInfo);
+
+
let body = JSON.stringify( claimsCurationInfo );
console.warn('Json body: : '+body);
let headers = new Headers({ 'Content-Type': 'application/json' });
diff --git a/portal-2/src/app/utils/entities/datasetInfo.ts b/portal-2/src/app/utils/entities/datasetInfo.ts
index 9694d50e..d64669d1 100644
--- a/portal-2/src/app/utils/entities/datasetInfo.ts
+++ b/portal-2/src/app/utils/entities/datasetInfo.ts
@@ -1,4 +1,5 @@
export class DatasetInfo {
+ underCurationMessage: boolean;
title: { "name": string, "url": string, "accessMode": string};
authors: { "name": string, "id": string}[];
date: string;
diff --git a/portal-2/src/app/utils/entities/publicationInfo.ts b/portal-2/src/app/utils/entities/publicationInfo.ts
index 16024a5e..5fd9ba2e 100644
--- a/portal-2/src/app/utils/entities/publicationInfo.ts
+++ b/portal-2/src/app/utils/entities/publicationInfo.ts
@@ -1,4 +1,5 @@
export class PublicationInfo {
+ underCurationMessage: boolean;
title: { "name": string, "url": string, "accessMode": string};
authors: { "name": string, "id": string}[];
date: string;