2019-09-13 10:26:09 +02:00
|
|
|
import {Component, ViewChild, ViewChildren, QueryList, Input, ViewEncapsulation} from '@angular/core';
|
|
|
|
import {Location} from '@angular/common';
|
|
|
|
import {ActivatedRoute, Params, Router} from '@angular/router';
|
|
|
|
import {Title, Meta} from '@angular/platform-browser';
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
import {DataTableDirective} from 'angular-datatables';
|
|
|
|
import {Observable, Subject } from 'rxjs';
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
|
|
|
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
|
|
|
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
import {ClaimsDatatablePipe} from '../../utils/pipes/claimsDatatable.pipe';
|
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
import {ModalSelect} from '../../utils/modal/selectModal.component';
|
|
|
|
import {ModalLoading} from '../../utils/modal/loading.component';
|
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
import {ClaimsByTokenService} from './claimsByToken.service';
|
|
|
|
|
|
|
|
import {Session} from '../../login/utils/helper.class';
|
|
|
|
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
|
2020-07-13 16:42:34 +02:00
|
|
|
import {properties} from "../../../../environments/environment";
|
2018-11-14 12:07:45 +01:00
|
|
|
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
@Component({
|
2019-09-13 09:01:19 +02:00
|
|
|
selector: 'claims-project-manager',
|
|
|
|
templateUrl: 'claimsByToken.component.html',
|
|
|
|
styles: [`
|
2019-09-13 10:26:09 +02:00
|
|
|
#table1_info, #table1_paginate, #table1_length, #table1_filter,
|
|
|
|
#table2_info, #table2_paginate, #table2_length, #table2_filter{
|
2019-09-13 09:01:19 +02:00
|
|
|
display: none;
|
|
|
|
}
|
2018-06-29 15:24:49 +02:00
|
|
|
|
2019-09-13 09:01:19 +02:00
|
|
|
`],
|
|
|
|
encapsulation: ViewEncapsulation.None // this used in order styles to work
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
})
|
|
|
|
export class ClaimsByTokenComponent {
|
2018-09-24 12:01:05 +02:00
|
|
|
public openaireId: string = "";
|
2017-12-19 13:53:46 +01:00
|
|
|
public sub: any;
|
|
|
|
public project: any;
|
2019-09-13 10:26:09 +02:00
|
|
|
private claims:any = [];
|
2017-12-19 13:53:46 +01:00
|
|
|
public pending_claims: any = [];
|
|
|
|
public curated_claims: any = [];
|
2018-06-29 15:24:49 +02:00
|
|
|
public selectedRight_PendingMode: Set<string>;
|
|
|
|
public selectedWrong_PendingMode: Set<string>;
|
|
|
|
public selectedRight_CuratedMode: Set<string>;
|
|
|
|
public selectedWrong_CuratedMode: Set<string>;
|
|
|
|
public editable: Set<number>;
|
2017-12-19 13:53:46 +01:00
|
|
|
public contact_person: string[] = ["Konstantina", "Argiro", "Katerina"];
|
|
|
|
|
2018-06-29 15:24:49 +02:00
|
|
|
private errorCodes: ErrorCodes;
|
2019-02-18 15:00:43 +01:00
|
|
|
private errorMessages: ErrorMessagesComponent;
|
2018-06-29 15:24:49 +02:00
|
|
|
public pending_status: number;
|
|
|
|
public curated_status: number;
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
// when 'valid' show proper claims, when 'invalid' show no matched entry-wanna retry
|
|
|
|
public accessStatus: string;// = "empty";
|
|
|
|
|
2018-06-29 15:24:49 +02:00
|
|
|
public mode: string = "pending";
|
|
|
|
public showTables: boolean = true;
|
2017-12-19 13:53:46 +01:00
|
|
|
public rowsOnPage = 5;
|
|
|
|
public sortOrder = "asc";
|
2019-09-13 10:26:09 +02:00
|
|
|
public keyword1:string = "";
|
|
|
|
public keyword2:string = "";
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
public activePendingPage:any = {page: 1};
|
|
|
|
public totalPendingResults:any = {count: 0};
|
|
|
|
public activeCuratedPage:any = {page: 1};
|
|
|
|
public totalCuratedResults:any = {count: 0};
|
2018-06-29 15:24:49 +02:00
|
|
|
dtTrigger: Subject<any>[] = [];
|
|
|
|
private triggered: boolean = false;
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2018-06-29 15:24:49 +02:00
|
|
|
dtOptions: DataTables.Settings[] = [];
|
|
|
|
@ViewChildren(DataTableDirective)
|
|
|
|
dtElements: QueryList<any>;
|
|
|
|
//@ViewChild("table1") table1: DataTableDirective;
|
|
|
|
//@ViewChild("table2") table2: DataTableDirective;
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
@ViewChild (ModalSelect) selectModal : ModalSelect;
|
|
|
|
@ViewChild (ModalLoading) loading : ModalLoading ;
|
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
|
|
|
|
2020-07-13 16:42:34 +02:00
|
|
|
properties:EnvProperties = properties;
|
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
public routerHelper:RouterHelper = new RouterHelper();
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
constructor (private route: ActivatedRoute,
|
|
|
|
private _router: Router,
|
|
|
|
private claimsByTokenService: ClaimsByTokenService,
|
|
|
|
private _meta: Meta, private _title: Title) {
|
2019-09-13 09:01:19 +02:00
|
|
|
this.errorCodes = new ErrorCodes();
|
|
|
|
this.errorMessages = new ErrorMessagesComponent();
|
|
|
|
this.pending_status = this.errorCodes.LOADING;
|
|
|
|
this.curated_status = this.errorCodes.LOADING;
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
ngOnInit() {
|
2019-09-13 10:26:09 +02:00
|
|
|
this.sub = this.route.queryParams.subscribe(params => {
|
2018-06-29 15:24:49 +02:00
|
|
|
this.mode = "pending";
|
2018-09-24 12:01:05 +02:00
|
|
|
this.openaireId = params['openaireId'];
|
2018-06-29 15:24:49 +02:00
|
|
|
this.selectedRight_PendingMode = new Set<string>();
|
|
|
|
this.selectedWrong_PendingMode = new Set<string>();
|
|
|
|
this.selectedRight_CuratedMode = new Set<string>();
|
|
|
|
this.selectedWrong_CuratedMode = new Set<string>();
|
|
|
|
this.editable = new Set<number>();
|
2017-12-19 13:53:46 +01:00
|
|
|
this.validateJWTandToken();
|
|
|
|
this.updateTitle("Claims For Project Managers");
|
|
|
|
}
|
|
|
|
);
|
2018-06-29 15:24:49 +02:00
|
|
|
|
|
|
|
this.dtOptions[0] = {
|
|
|
|
//"paging": false,
|
|
|
|
//"searching": false,
|
|
|
|
//"lengthChange": false,
|
|
|
|
"pageLength": this.rowsOnPage,
|
2019-09-13 10:26:09 +02:00
|
|
|
"columnDefs": [ {
|
2019-09-13 09:01:19 +02:00
|
|
|
"type": "date",
|
|
|
|
"targets": 2
|
2019-09-13 10:26:09 +02:00
|
|
|
} ],
|
|
|
|
"order": [[ 2, 'desc' ]]
|
2018-06-29 15:24:49 +02:00
|
|
|
//"pagingType": 'full_numbers',
|
|
|
|
/*"language": {
|
|
|
|
"search": "",
|
|
|
|
"searchPlaceholder": "Search projects..."
|
|
|
|
}*/
|
|
|
|
};
|
|
|
|
|
|
|
|
this.dtOptions[1] = {
|
|
|
|
"pageLength": this.rowsOnPage,
|
2019-09-13 10:26:09 +02:00
|
|
|
"columnDefs": [ {
|
2019-09-13 09:01:19 +02:00
|
|
|
"type": "date",
|
2019-09-13 10:26:09 +02:00
|
|
|
"targets": [2,4]
|
|
|
|
} ],
|
|
|
|
"order": [[ 4, 'desc' ]]
|
2018-06-29 15:24:49 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
this.dtTrigger[0] = new Subject<any>();
|
|
|
|
this.dtTrigger[1] = new Subject<any>();
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
|
2018-06-29 15:24:49 +02:00
|
|
|
ngAfterViewInit(): void {
|
2019-09-13 10:26:09 +02:00
|
|
|
$.fn['dataTable'].ext.search.push((settings, data, dataIndex) => {
|
|
|
|
if(settings.sTableId == 'table1') {
|
|
|
|
if (this.filterData(data, this.keyword1)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
} else if(settings.sTableId == 'table2') {
|
|
|
|
if (this.filterData(data, this.keyword2)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2019-09-13 09:01:19 +02:00
|
|
|
}
|
|
|
|
});
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
|
2018-06-29 15:24:49 +02:00
|
|
|
ngOnDestroy(): void {
|
|
|
|
$.fn['dataTable'].ext.search.pop();
|
|
|
|
// Do not forget to unsubscribe the event
|
|
|
|
this.dtTrigger[0].unsubscribe();
|
|
|
|
this.dtTrigger[1].unsubscribe();
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2018-06-29 15:24:49 +02:00
|
|
|
/*
|
|
|
|
Trigger a table draw in order to get the initial filtering
|
|
|
|
*/
|
2019-09-13 10:26:09 +02:00
|
|
|
triggerInitialLoad(){
|
2019-09-13 09:01:19 +02:00
|
|
|
this.triggered = true;
|
|
|
|
//console.info("triggerInitialLoad");
|
2019-09-13 10:26:09 +02:00
|
|
|
setTimeout(function(){
|
2019-09-13 09:01:19 +02:00
|
|
|
/*var table1 = <any>$('#table1').DataTable();
|
|
|
|
table1.page( 0 ).draw( false );
|
|
|
|
|
|
|
|
var table2 = <any>$('#table2').DataTable();
|
|
|
|
table2.page( 0 ).draw( false );*/
|
|
|
|
}, 500);
|
|
|
|
setTimeout(() => {
|
|
|
|
this.dtTrigger[0].next();
|
|
|
|
this.dtTrigger[1].next();
|
|
|
|
});
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-06-29 15:24:49 +02:00
|
|
|
rerender(): void {
|
2019-02-14 11:15:44 +01:00
|
|
|
//console.info("RERENDER");
|
2018-06-29 15:24:49 +02:00
|
|
|
this.dtElements.forEach((dtElement: DataTableDirective, index: number) => {
|
|
|
|
dtElement.dtInstance.then((dtInstance: any) => {
|
|
|
|
// Destroy the table first
|
|
|
|
dtInstance.destroy();
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2018-06-29 15:24:49 +02:00
|
|
|
// Call the dtTrigger to rerender again
|
|
|
|
this.dtTrigger[index].next();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
filterData(row: any, query: string) {
|
|
|
|
if(!Session.isLoggedIn()){
|
|
|
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
|
|
|
} else {
|
|
|
|
let returnValue: boolean = false;
|
|
|
|
|
|
|
|
if(query) {
|
|
|
|
for(var i=0; i <3; i++){
|
|
|
|
var r= this.filterQuery(row[i], query);
|
|
|
|
if(r) {
|
|
|
|
returnValue = true;
|
|
|
|
break;
|
|
|
|
}
|
2018-11-14 12:07:45 +01:00
|
|
|
}
|
2018-06-29 15:24:49 +02:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
if(!returnValue) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-09-13 09:01:19 +02:00
|
|
|
}
|
2019-09-13 10:26:09 +02:00
|
|
|
|
|
|
|
return true;
|
2018-11-14 12:07:45 +01:00
|
|
|
}
|
2018-06-29 15:24:49 +02:00
|
|
|
}
|
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
filterQuery(data, query){
|
|
|
|
if(data.toLowerCase().indexOf(query.toLowerCase()) > -1){
|
2018-06-29 15:24:49 +02:00
|
|
|
return true;
|
2019-09-13 10:26:09 +02:00
|
|
|
}else{
|
2018-06-29 15:24:49 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
refreshTable(page:number, whichTable: string) {
|
|
|
|
if(!Session.isLoggedIn()){
|
|
|
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
|
|
|
} else {
|
|
|
|
if(whichTable == "pending") {
|
|
|
|
var table = $('#table1').DataTable();
|
|
|
|
table.page( page - 1 ).draw( false );
|
2018-11-14 12:07:45 +01:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
var info = table.page.info();
|
2018-11-14 12:07:45 +01:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
this.activePendingPage.page = page;//$event.value;
|
|
|
|
this.totalPendingResults.count = info.recordsDisplay;
|
|
|
|
} else if(whichTable == 'curated') {
|
|
|
|
var table = $('#table2').DataTable();
|
|
|
|
table.page( page - 1 ).draw( false );
|
2018-11-14 12:07:45 +01:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
var info = table.page.info();
|
2018-11-14 12:07:45 +01:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
this.activeCuratedPage.page = page;//$event.value;
|
|
|
|
this.totalCuratedResults.count = info.recordsDisplay;
|
2019-09-13 09:01:19 +02:00
|
|
|
}
|
2019-09-13 10:26:09 +02:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-09-13 09:01:19 +02:00
|
|
|
//table.mfActivePage=$event.value;
|
|
|
|
//table.setPage(table.mfActivePage, this.rowsOnPage);
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
validateJWTandToken() {
|
2019-09-13 10:26:09 +02:00
|
|
|
if(!Session.isLoggedIn()){
|
|
|
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
|
|
|
} else {
|
|
|
|
if(this.openaireId) {
|
|
|
|
this.pending_status = this.errorCodes.LOADING;
|
|
|
|
this.curated_status = this.errorCodes.LOADING;
|
2018-06-12 13:15:42 +02:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
this.showTables = false;
|
|
|
|
this.pending_claims = [];
|
|
|
|
this.curated_claims = [];
|
2018-06-29 15:24:49 +02:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
this.activePendingPage.page = 1;
|
|
|
|
this.totalPendingResults.count = 0;
|
|
|
|
this.activeCuratedPage.page = 1;
|
|
|
|
this.totalCuratedResults.count = 0;
|
2018-11-14 12:07:45 +01:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
this.claimsByTokenService.getClaims(this.openaireId, this.properties.claimsAPIURL).subscribe(
|
|
|
|
data => {
|
|
|
|
//this.closeLoading();
|
|
|
|
this.accessStatus = "valid";
|
|
|
|
this.claims = data.data;
|
|
|
|
for(let claim of this.claims) {
|
|
|
|
if(claim.targetType == "project") {
|
|
|
|
this.project = claim.target;
|
2019-09-13 09:01:19 +02:00
|
|
|
} else {
|
2019-09-13 10:26:09 +02:00
|
|
|
this.project = claim.source;
|
2019-09-13 09:01:19 +02:00
|
|
|
}
|
2019-09-13 10:26:09 +02:00
|
|
|
if(claim.curatedBy) {
|
|
|
|
this.curated_claims.push(claim);
|
2018-11-14 12:07:45 +01:00
|
|
|
} else {
|
2019-09-13 10:26:09 +02:00
|
|
|
this.pending_claims.push(claim);
|
|
|
|
}
|
|
|
|
}
|
2018-06-29 15:24:49 +02:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
this.totalPendingResults.count = this.pending_claims.length;
|
|
|
|
this.totalCuratedResults.count = this.curated_claims.length;
|
2018-06-29 15:24:49 +02:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
if(this.project) {
|
|
|
|
this.updateTitle("Claims For Project Managers - "+this.project.name);
|
|
|
|
}
|
|
|
|
this.showTables = true;
|
2018-06-29 15:24:49 +02:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
if(!this.triggered) {
|
|
|
|
//console.info("initial load");
|
|
|
|
this.triggerInitialLoad();
|
|
|
|
} else {
|
|
|
|
//console.info("rerender");
|
|
|
|
var table1 = $('#table1').DataTable();
|
|
|
|
table1.clear();
|
|
|
|
|
|
|
|
var table2 = $('#table2').DataTable();
|
|
|
|
table2.clear();
|
2018-06-29 15:24:49 +02:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
this.rerender();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.pending_status = this.errorCodes.DONE;
|
|
|
|
this.curated_status = this.errorCodes.DONE;
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.handleError("Error getting claims for openaire id: "+this.openaireId, err);
|
|
|
|
this.pending_status = this.errorMessages.getErrorCode(err.status);
|
|
|
|
this.curated_status = this.pending_status;
|
|
|
|
|
|
|
|
/*if(err.status == '404') {
|
|
|
|
this.pending_status = this.errorCodes.NOT_FOUND;
|
|
|
|
this.curated_status = this.errorCodes.NOT_FOUND;
|
|
|
|
} else if(err.status == '500') {
|
|
|
|
this.pending_status = this.errorCodes.ERROR;
|
|
|
|
this.curated_status = this.errorCodes.ERROR;
|
|
|
|
} else {
|
|
|
|
this.pending_status = this.errorCodes.NOT_AVAILABLE;
|
|
|
|
this.curated_status = this.errorCodes.NOT_AVAILABLE;
|
|
|
|
}*/
|
|
|
|
this.showTables = true;
|
|
|
|
|
|
|
|
if(!this.triggered) {
|
|
|
|
this.triggerInitialLoad();
|
|
|
|
} else {
|
|
|
|
var table1 = $('#table1').DataTable();
|
|
|
|
table1.clear();
|
|
|
|
|
|
|
|
var table2 = $('#table2').DataTable();
|
|
|
|
table2.clear();
|
|
|
|
|
|
|
|
this.rerender();
|
2018-06-29 15:24:49 +02:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
this.accessStatus = "invalid";
|
|
|
|
//console.log(err);
|
2019-09-13 09:01:19 +02:00
|
|
|
}
|
2019-09-13 10:26:09 +02:00
|
|
|
);
|
2019-09-13 09:01:19 +02:00
|
|
|
} else {
|
2019-09-13 10:26:09 +02:00
|
|
|
this.accessStatus = "invalid";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
selectApprove(id:string, event, mode: string) {
|
|
|
|
if(!Session.isLoggedIn()){
|
|
|
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
|
|
|
} else {
|
|
|
|
var value = event.currentTarget.checked;
|
|
|
|
if(value){
|
|
|
|
if(mode == "pending") {
|
|
|
|
this.selectedRight_PendingMode.add(id);
|
|
|
|
this.selectedWrong_PendingMode.delete(id);
|
2018-11-14 12:07:45 +01:00
|
|
|
} else {
|
2019-09-13 10:26:09 +02:00
|
|
|
this.selectedRight_CuratedMode.add(id);
|
|
|
|
this.selectedWrong_CuratedMode.delete(id);
|
2018-11-14 12:07:45 +01:00
|
|
|
}
|
2019-09-13 10:26:09 +02:00
|
|
|
}else{
|
|
|
|
if(mode == "pending") {
|
|
|
|
this.selectedRight_PendingMode.delete(id);
|
|
|
|
}
|
|
|
|
// } else {
|
|
|
|
// this.selectedRight_CuratedMode.delete(id);
|
|
|
|
// this.selectedWrong_CuratedMode.add(id);
|
|
|
|
// }
|
2018-06-29 15:24:49 +02:00
|
|
|
}
|
2019-09-13 10:26:09 +02:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
selectDisapprove(id:string, event, mode: string) {
|
|
|
|
if(!Session.isLoggedIn()){
|
|
|
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
|
|
|
} else {
|
|
|
|
var value = event.currentTarget.checked;
|
|
|
|
if(value){
|
|
|
|
if(mode == "pending") {
|
|
|
|
this.selectedWrong_PendingMode.add(id);
|
|
|
|
this.selectedRight_PendingMode.delete(id);
|
2018-11-14 12:07:45 +01:00
|
|
|
} else {
|
2019-09-13 10:26:09 +02:00
|
|
|
this.selectedWrong_CuratedMode.add(id);
|
|
|
|
this.selectedRight_CuratedMode.delete(id);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
if(mode == "pending") {
|
|
|
|
this.selectedWrong_PendingMode.delete(id);
|
2018-11-14 12:07:45 +01:00
|
|
|
}
|
2019-09-13 10:26:09 +02:00
|
|
|
// } else {
|
|
|
|
// this.selectedWrong_CuratedMode.delete(id);
|
|
|
|
// this.selectedRight_CuratedMode.add(id);
|
|
|
|
// }
|
2018-06-29 15:24:49 +02:00
|
|
|
}
|
2019-09-13 10:26:09 +02:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
isSelected(id:string, set:Set<string>) {
|
2018-06-29 15:24:49 +02:00
|
|
|
return set.has(id);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-09-13 09:01:19 +02:00
|
|
|
/*
|
|
|
|
isSelectedWrong(id:string) {
|
|
|
|
return this.selectedWrong.has(id);
|
|
|
|
}
|
|
|
|
*/
|
2018-06-29 15:24:49 +02:00
|
|
|
isRight_CuratedMode(claim: any) {
|
2019-09-13 10:26:09 +02:00
|
|
|
if(this.isSelected(claim.id, this.selectedRight_CuratedMode)) {
|
2017-12-19 13:53:46 +01:00
|
|
|
return true;
|
2019-09-13 10:26:09 +02:00
|
|
|
} else if(claim.approved == true && !this.isSelected(claim.id, this.selectedWrong_CuratedMode)) {
|
2017-12-19 13:53:46 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-06-29 15:24:49 +02:00
|
|
|
isWrong_CuratedMode(claim: any) {
|
2019-09-13 10:26:09 +02:00
|
|
|
if(this.isSelected(claim.id, this.selectedWrong_CuratedMode)) {
|
2017-12-19 13:53:46 +01:00
|
|
|
return true;
|
2019-09-13 10:26:09 +02:00
|
|
|
} else if(claim.approved == false && !this.isSelected(claim.id, this.selectedRight_CuratedMode)) {
|
2017-12-19 13:53:46 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-06-29 15:24:49 +02:00
|
|
|
cancelEditOfCuration(claim: any) {
|
2019-09-13 10:26:09 +02:00
|
|
|
if(!Session.isLoggedIn()){
|
|
|
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
|
|
|
} else {
|
|
|
|
if(claim.approved) {
|
|
|
|
//this.selectedRight_CuratedMode.add(claim.id);
|
|
|
|
this.selectedWrong_CuratedMode.delete(claim.id);
|
2018-11-14 12:07:45 +01:00
|
|
|
} else {
|
2019-09-13 10:26:09 +02:00
|
|
|
this.selectedRight_CuratedMode.delete(claim.id);
|
|
|
|
//this.selectedWrong_CuratedMode.add(claim.id);
|
2018-11-14 12:07:45 +01:00
|
|
|
}
|
2019-09-13 10:26:09 +02:00
|
|
|
}
|
2018-06-29 15:24:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
saveEdited(claim: any, editable_index: number) {
|
2019-09-13 10:26:09 +02:00
|
|
|
if(!Session.isLoggedIn()){
|
|
|
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
|
|
|
} else {
|
|
|
|
this.curated_status = this.errorCodes.LOADING;
|
2018-06-29 15:24:49 +02:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
let approved: boolean = this.isRight_CuratedMode(claim);
|
2018-06-29 15:24:49 +02:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
if(approved == claim.approved) {
|
|
|
|
this.selectedRight_CuratedMode.delete(claim.id);
|
|
|
|
this.selectedWrong_CuratedMode.delete(claim.id);
|
|
|
|
this.editable.delete(editable_index);
|
2018-06-29 15:24:49 +02:00
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
this.curated_status = this.errorCodes.DONE;
|
2019-09-13 09:01:19 +02:00
|
|
|
} else {
|
2019-09-13 10:26:09 +02:00
|
|
|
let claimCurationInfo: {"id": string, "approved": boolean} = {"id": claim.id, "approved": approved};
|
|
|
|
|
|
|
|
this.claimsByTokenService.updateClaimCuration(claimCurationInfo, this.properties.claimsAPIURL).subscribe(
|
2018-06-29 15:24:49 +02:00
|
|
|
data => {
|
2019-09-13 10:26:09 +02:00
|
|
|
this.selectedRight_CuratedMode.delete(claim.id);
|
|
|
|
this.selectedWrong_CuratedMode.delete(claim.id);
|
|
|
|
this.editable.delete(editable_index);
|
|
|
|
|
2018-06-29 15:24:49 +02:00
|
|
|
this.validateJWTandToken();
|
|
|
|
},
|
|
|
|
err => {
|
2019-02-18 15:00:43 +01:00
|
|
|
//console.log(err);
|
2019-09-13 10:26:09 +02:00
|
|
|
this.handleError("Error updating claim curation: "+JSON.stringify(claimCurationInfo), err);
|
|
|
|
this.curated_status = this.errorCodes.NOT_SAVED;
|
2018-06-29 15:24:49 +02:00
|
|
|
}
|
|
|
|
);
|
2019-09-13 09:01:19 +02:00
|
|
|
}
|
2019-09-13 10:26:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
saveChanges() {
|
|
|
|
if(!Session.isLoggedIn()){
|
|
|
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
|
|
|
} else {
|
|
|
|
this.pending_status = this.errorCodes.LOADING;
|
|
|
|
//this.openLoading();
|
|
|
|
//console.info("Changes Saved!, right-wrong", this.selectedRight_PendingMode, this.selectedWrong_PendingMode);
|
|
|
|
this.claimsByTokenService.updateClaimsCuration(this.selectedRight_PendingMode, this.selectedWrong_PendingMode, this.properties.claimsAPIURL).subscribe(
|
|
|
|
data => {
|
|
|
|
//this.closeLoading();
|
|
|
|
this.mode = "curated";
|
|
|
|
this.clearCheckboxes();
|
|
|
|
this.validateJWTandToken();
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
//this.closeLoading();
|
|
|
|
//console.log(err);
|
|
|
|
this.handleError("Error updating claims: right: "+JSON.stringify(this.selectedRight_PendingMode)+" and wrong: "+JSON.stringify(this.selectedWrong_PendingMode), err);
|
|
|
|
this.pending_status = this.errorCodes.NOT_SAVED;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2018-06-29 15:24:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
clearCheckboxes() {
|
2019-09-13 10:26:09 +02:00
|
|
|
if(!Session.isLoggedIn()){
|
|
|
|
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
|
|
|
} else {
|
|
|
|
this.pending_status = this.errorCodes.LOADING;
|
|
|
|
this.selectedRight_PendingMode.clear();
|
|
|
|
this.selectedWrong_PendingMode.clear();
|
|
|
|
this.pending_status = this.errorCodes.DONE;
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
public openLoading(){
|
|
|
|
if(this.loading){
|
2018-06-29 15:24:49 +02:00
|
|
|
this.loading.open();
|
|
|
|
}
|
|
|
|
}
|
2019-09-13 10:26:09 +02:00
|
|
|
public closeLoading(){
|
|
|
|
if(this.loading){
|
2017-12-19 13:53:46 +01:00
|
|
|
this.loading.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
curatorSelected(selected: string) {
|
2019-02-14 11:15:44 +01:00
|
|
|
//console.info("selected curator: "+selected);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
public openSelect(){
|
|
|
|
if(this.selectModal){
|
2017-12-19 13:53:46 +01:00
|
|
|
this.selectModal.open();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
public setMessageSelect(message: string){
|
|
|
|
if(this.selectModal){
|
2017-12-19 13:53:46 +01:00
|
|
|
this.selectModal.message = message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
public setOptionsSelect(options: string[]){
|
|
|
|
if(this.selectModal){
|
2017-12-19 13:53:46 +01:00
|
|
|
this.selectModal.options = options;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
totalPages(totalResults: number): number {
|
2019-09-13 10:26:09 +02:00
|
|
|
let totalPages:any = totalResults/(this.rowsOnPage);
|
|
|
|
if(!(Number.isInteger(totalPages))) {
|
2019-09-13 09:01:19 +02:00
|
|
|
totalPages = (parseInt(totalPages, 10) + 1);
|
|
|
|
}
|
|
|
|
return totalPages;
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
|
2019-09-13 10:26:09 +02:00
|
|
|
updateTitle(title:string){
|
|
|
|
var _prefix ="OpenAIRE | ";
|
|
|
|
var _title = _prefix + ((title.length> 50 ) ?title.substring(0,50):title);
|
|
|
|
this._meta.updateTag({content:_title},"property='og:title'");
|
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
|
|
|
this._title.setTitle(_title);
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
|
2019-02-18 15:00:43 +01:00
|
|
|
private handleError(message: string, error) {
|
2019-09-13 10:26:09 +02:00
|
|
|
console.error("Claims Project Manager Page: "+message, error);
|
2019-02-18 15:00:43 +01:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|