Save changes and update database with claims
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@47033 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
6b35091e9c
commit
bf6c47a309
|
@ -9,6 +9,8 @@ import {ModalLoading} from '../../utils/modal/loading.component';
|
||||||
|
|
||||||
import {Session} from '../../login/utils/helper.class';
|
import {Session} from '../../login/utils/helper.class';
|
||||||
|
|
||||||
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'claims-project-manager',
|
selector: 'claims-project-manager',
|
||||||
template: `
|
template: `
|
||||||
|
@ -38,69 +40,96 @@ import {Session} from '../../login/utils/helper.class';
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div *ngIf="accessStatus=='valid'">
|
<div *ngIf="accessStatus=='valid'">
|
||||||
<h1> Pending Claims </h1>
|
<h1> Pending Claims for project:
|
||||||
|
<a [queryParams]="routerHelper.createQueryParam('projectId',project['openaireId'])"
|
||||||
|
routerLinkActive="router-link-active"
|
||||||
|
routerLink="/search/project" >
|
||||||
|
{{project['name']}} ({{project['funderName']}})
|
||||||
|
</a>
|
||||||
|
</h1>
|
||||||
|
|
||||||
<div *ngIf=" pending_claims && pending_claims.length == 0" >
|
<div *ngIf=" pending_claims && pending_claims.length == 0" >
|
||||||
<div class = "uk-alert uk-alert-info " >No pending claims found.</div>
|
<div class = "uk-alert uk-alert-info " >No pending claims found.</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="">
|
<div class="uk-overflow-container">
|
||||||
<table *ngIf="pending_claims && pending_claims.length > 0" class="uk-table uk-table-striped">
|
<table *ngIf="pending_claims && pending_claims.length > 0" class="uk-table uk-table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Research Result</th>
|
<th>Research Result</th>
|
||||||
<th>Link to</th>
|
<!--th>Link to</th-->
|
||||||
<th>Claimed by</th>
|
<th class="uk-text-center">Claimed by</th>
|
||||||
<th>Claimed Date</th>
|
<th class="uk-text-center">Claimed Date</th>
|
||||||
<th>True</th>
|
<th class="uk-text-center">Approve</th>
|
||||||
<th>False</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr *ngFor="let claim of pending_claims ">
|
<tr class="uk-table-middle" *ngFor="let claim of pending_claims ">
|
||||||
<td><claim-entity [entity]="claim.target" [type]="claim.targetType" > </claim-entity></td>
|
<td class="uk-width-2-6" *ngIf="claim.targetType != 'project'"><claim-entity [entity]="claim.target" [type]="claim.targetType" > </claim-entity></td>
|
||||||
<td><claim-entity [entity]="claim.source" [type]="claim.sourceType" > </claim-entity></td>
|
<td class="uk-width-1-6 uk-text-center" *ngIf="claim.sourceType != 'project'"><claim-entity [entity]="claim.source" [type]="claim.sourceType" > </claim-entity></td>
|
||||||
<td>{{claim.userMail}}</td>
|
<td class="uk-width-1-6 uk-text-center">{{claim.userMail}}</td>
|
||||||
<td>{{claim.date}}</td>
|
<td class="uk-width-1-6 uk-text-center">{{claim.date}}</td>
|
||||||
<td><input [id]="claim.id" type="checkbox" (click)="selectApprove(claim.id,$event)" [ngModel]="isSelectedRight(claim.id)"/></td>
|
<!--td>
|
||||||
<td><input [id]="claim.id" type="checkbox" (click)="selectDisapprove(claim.id,$event)" [ngModel]="isSelectedWrong(claim.id)"/></td>
|
<label>
|
||||||
|
Yes <input [id]="claim.id" type="checkbox" (click)="selectApprove(claim.id,$event)" [ngModel]="isSelectedRight(claim.id)"/>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
No <input [id]="claim.id" type="checkbox" (click)="selectDisapprove(claim.id,$event)" [ngModel]="isSelectedWrong(claim.id)"/>
|
||||||
|
</label>
|
||||||
|
</td-->
|
||||||
|
<td class="uk-width-1-6 uk-text-center">
|
||||||
|
|
||||||
|
<label>
|
||||||
|
Yes <input [id]="claim.id" type="checkbox" (click)="selectApprove(claim.id,$event)" [ngModel]="isSelectedRight(claim.id)"/>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
No <input [id]="claim.id" type="checkbox" (click)="selectDisapprove(claim.id,$event)" [ngModel]="isSelectedWrong(claim.id)"/>
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
<h1> Already Curated Claims </h1>
|
<h1> Already Curated Claims </h1>
|
||||||
|
|
||||||
<div *ngIf=" curated_claims && curated_claims.length == 0" >
|
<div *ngIf=" curated_claims && curated_claims.length == 0" >
|
||||||
<div class = "uk-alert uk-alert-info " >No curated claims found.</div>
|
<div class = "uk-alert uk-alert-info " >No curated claims found.</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="">
|
<div class="uk-overflow-container">
|
||||||
<table *ngIf="curated_claims && curated_claims.length > 0" class="uk-table uk-table-striped">
|
<table *ngIf="curated_claims && curated_claims.length > 0" class="uk-table uk-table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Research Result</th>
|
<th>Research Result</th>
|
||||||
<th>Link to</th>
|
<!--th>Link to</th-->
|
||||||
<th>Claimed by</th>
|
<th class="uk-text-center">Claimed by</th>
|
||||||
<th>Claimed Date</th>
|
<th class="uk-text-center">Claimed Date</th>
|
||||||
<th>Curated by</th>
|
<th class="uk-text-center">Curated by</th>
|
||||||
<th>Curation Date</th>
|
<th class="uk-text-center">Curation Date</th>
|
||||||
<th>True</th>
|
<th class="uk-text-center">Approved</th>
|
||||||
<th>False</th>
|
|
||||||
<th></th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr *ngFor="let claim of curated_claims let i=index">
|
<tr class="uk-table-middle" *ngFor="let claim of curated_claims let i=index">
|
||||||
<td><claim-entity [entity]="claim.target" [type]="claim.targetType" > </claim-entity></td>
|
<td class="uk-width-1-6" *ngIf="claim.targetType != 'project'"><claim-entity [entity]="claim.target" [type]="claim.targetType" > </claim-entity></td>
|
||||||
<td><claim-entity [entity]="claim.source" [type]="claim.sourceType" > </claim-entity></td>
|
<td class="uk-width-1-6" *ngIf="claim.sourceType != 'project'"><claim-entity [entity]="claim.source" [type]="claim.sourceType" > </claim-entity></td>
|
||||||
<td>{{claim.userMail}}</td>
|
<td class="uk-width-1-6 uk-text-center">{{claim.userMail}}</td>
|
||||||
<td>{{claim.date}}</td>
|
<td class="uk-width-1-6 uk-text-center">{{claim.date}}</td>
|
||||||
<td>{{claim.curatedBy}}</td>
|
<td class="uk-width-1-6 uk-text-center">{{claim.curatedBy}}</td>
|
||||||
<td>{{claim.curationDate}}</td>
|
<td class="uk-width-1-6 uk-text-center">{{claim.curationDate}}</td>
|
||||||
<td><input [id]="claim.id" type="checkbox" [disabled]="!editable.has(i)" (click)="selectApprove(claim.id,$event)" [ngModel]="isRight(claim)"/></td>
|
<td class="uk-width-1-6 uk-text-center">
|
||||||
<td><input [id]="claim.id" type="checkbox" [disabled]="!editable.has(i)" (click)="selectDisapprove(claim.id,$event)" [ngModel]="isWrong(claim)"/></td>
|
|
||||||
<td><button class="uk-button" (click)="editable.add(i)">Edit</button></td>
|
<label>
|
||||||
|
Yes <input [id]="claim.id" type="checkbox" [disabled]="!editable.has(i)" [ngModel]="isRight(claim)"/>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
No <input [id]="claim.id" type="checkbox" [disabled]="!editable.has(i)" [ngModel]="isWrong(claim)"/>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<!--td><input [id]="claim.id" type="checkbox" [disabled]="!editable.has(i)" (click)="selectDisapprove(claim.id,$event)" [ngModel]="isWrong(claim)"/></td-->
|
||||||
|
<!--td><button class="uk-button" (click)="editable.add(i)">Edit</button></td-->
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -116,8 +145,10 @@ import {Session} from '../../login/utils/helper.class';
|
||||||
|
|
||||||
})
|
})
|
||||||
export class ClaimsByTokenComponent {
|
export class ClaimsByTokenComponent {
|
||||||
|
//change true - false to accept: yes - no
|
||||||
public token: string = "";
|
public token: string = "";
|
||||||
public sub: any;
|
public sub: any;
|
||||||
|
public project: any;
|
||||||
private claims:any = [];
|
private claims:any = [];
|
||||||
public pending_claims: any = [];
|
public pending_claims: any = [];
|
||||||
public curated_claims: any = [];
|
public curated_claims: any = [];
|
||||||
|
@ -132,6 +163,8 @@ export class ClaimsByTokenComponent {
|
||||||
@ViewChild (ModalSelect) selectModal : ModalSelect;
|
@ViewChild (ModalSelect) selectModal : ModalSelect;
|
||||||
@ViewChild (ModalLoading) loading : ModalLoading ;
|
@ViewChild (ModalLoading) loading : ModalLoading ;
|
||||||
|
|
||||||
|
public routerHelper:RouterHelper = new RouterHelper();
|
||||||
|
|
||||||
constructor ( private route: ActivatedRoute, private _router:Router, private claimsByTokenService: ClaimsByTokenService ) {
|
constructor ( private route: ActivatedRoute, private _router:Router, private claimsByTokenService: ClaimsByTokenService ) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -150,15 +183,20 @@ export class ClaimsByTokenComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
validateJWTandToken() {
|
validateJWTandToken() {
|
||||||
var user_token=Session.getUserJwt();
|
var jwtToken=Session.getUserJwt();
|
||||||
if(this.token) {
|
if(this.token) {
|
||||||
this.claimsByTokenService.getClaims(this.token, user_token).subscribe(
|
this.claimsByTokenService.getClaims(this.token, jwtToken).subscribe(
|
||||||
data => {
|
data => {
|
||||||
this.closeLoading();
|
this.closeLoading();
|
||||||
this.accessStatus = "valid";
|
this.accessStatus = "valid";
|
||||||
//console.info(data);
|
//console.info(data);
|
||||||
this.claims = data.data;
|
this.claims = data.data;
|
||||||
for(let claim of this.claims) {
|
for(let claim of this.claims) {
|
||||||
|
if(claim.targetType == "project") {
|
||||||
|
this.project = claim.target;
|
||||||
|
} else {
|
||||||
|
this.project = claim.source;
|
||||||
|
}
|
||||||
if(claim.curatedBy) {
|
if(claim.curatedBy) {
|
||||||
this.curated_claims.push(claim);
|
this.curated_claims.push(claim);
|
||||||
} else {
|
} else {
|
||||||
|
@ -229,8 +267,9 @@ export class ClaimsByTokenComponent {
|
||||||
|
|
||||||
saveChanges() {
|
saveChanges() {
|
||||||
console.info("Changes Saved!");
|
console.info("Changes Saved!");
|
||||||
/*
|
var jwtToken=Session.getUserJwt();
|
||||||
this.claimsByTokenService.updateClaimsCuration(this.token, this.selectedRight, this.selectedWrong).subscribe(
|
|
||||||
|
this.claimsByTokenService.updateClaimsCuration(jwtToken, this.selectedRight, this.selectedWrong).subscribe(
|
||||||
data => {
|
data => {
|
||||||
console.info(data);
|
console.info(data);
|
||||||
},
|
},
|
||||||
|
@ -238,7 +277,7 @@ export class ClaimsByTokenComponent {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public closeLoading(){
|
public closeLoading(){
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
|
import { RouterModule } from '@angular/router';
|
||||||
|
|
||||||
import { SharedModule } from '../../shared/shared.module';
|
import { SharedModule } from '../../shared/shared.module';
|
||||||
import { ClaimsByTokenComponent } from './claimsByToken.component';
|
import { ClaimsByTokenComponent } from './claimsByToken.component';
|
||||||
|
@ -14,6 +15,7 @@ import {LoginGuard} from'../../login/loginGuard.guard';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
|
RouterModule,
|
||||||
SharedModule,
|
SharedModule,
|
||||||
ClaimsByTokenRoutingModule,
|
ClaimsByTokenRoutingModule,
|
||||||
ClaimEntityFormatterModule,
|
ClaimEntityFormatterModule,
|
||||||
|
|
|
@ -10,12 +10,11 @@ export class ClaimsByTokenService {
|
||||||
|
|
||||||
constructor(private http: Http, public _cache: CacheService) {}
|
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");
|
console.info("getClaims in service");
|
||||||
|
|
||||||
let url = OpenaireProperties.getClaimsAPIURL()+"projects/corda__h2020::94c962e736df90a5075a7f660ba3d7f6/claims"
|
let url = OpenaireProperties.getClaimsAPIURL()+"projects/corda__h2020::94c962e736df90a5075a7f660ba3d7f6/claims"
|
||||||
+"?&token="+user_token;
|
+"?&token="+jwtToken;
|
||||||
console.info(url);
|
|
||||||
let key = url;
|
let key = url;
|
||||||
if (this._cache.has(key)) {
|
if (this._cache.has(key)) {
|
||||||
return Observable.of(this._cache.get(key));
|
return Observable.of(this._cache.get(key));
|
||||||
|
@ -43,17 +42,24 @@ console.info(url);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
updateClaimsCuration(token: string, selectedRight: Set<string>, selectedWrong: Set<string>) {
|
updateClaimsCuration(jwtToken: string, selectedRight: Set<string>, selectedWrong: Set<string>) {
|
||||||
let url = OpenaireProperties.getClaimsAPIURL(); // What else?
|
let url = OpenaireProperties.getClaimsAPIURL() + "curate/bulk?token="+jwtToken;
|
||||||
let claimsCurationInfo: any = [];
|
let claimsCurationInfo: any = []; //e.g.: [{"id":"2","approved":true},{"id":"1","approved":true}]
|
||||||
for(let selected in selectedRight) {
|
|
||||||
let claimCurationInfo: any = {"claim_id": selected, "approved": true, "token": token};
|
selectedRight.forEach(function(selected) {
|
||||||
claimsCurationInfo.add(claimCurationInfo);
|
console.info(selected);
|
||||||
}
|
let claimCurationInfo: {"id": string, "approved": boolean} = {"id": selected, "approved": true};
|
||||||
for(let selected in selectedWrong) {
|
claimsCurationInfo.push(claimCurationInfo);
|
||||||
let claimCurationInfo: any = {"claim_id": selected, "approved": false, "token": token};
|
});
|
||||||
claimsCurationInfo.add(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 );
|
let body = JSON.stringify( claimsCurationInfo );
|
||||||
console.warn('Json body: : '+body);
|
console.warn('Json body: : '+body);
|
||||||
let headers = new Headers({ 'Content-Type': 'application/json' });
|
let headers = new Headers({ 'Content-Type': 'application/json' });
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
export class DatasetInfo {
|
export class DatasetInfo {
|
||||||
|
underCurationMessage: boolean;
|
||||||
title: { "name": string, "url": string, "accessMode": string};
|
title: { "name": string, "url": string, "accessMode": string};
|
||||||
authors: { "name": string, "id": string}[];
|
authors: { "name": string, "id": string}[];
|
||||||
date: string;
|
date: string;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
export class PublicationInfo {
|
export class PublicationInfo {
|
||||||
|
underCurationMessage: boolean;
|
||||||
title: { "name": string, "url": string, "accessMode": string};
|
title: { "name": string, "url": string, "accessMode": string};
|
||||||
authors: { "name": string, "id": string}[];
|
authors: { "name": string, "id": string}[];
|
||||||
date: string;
|
date: string;
|
||||||
|
|
Loading…
Reference in New Issue