[develop WIP] upload dois: add filters, stats progress bar
This commit is contained in:
parent
373e7c7c42
commit
bd46630319
|
@ -1,42 +1,170 @@
|
||||||
<div class="uk-float-left">
|
<div style="background: #F9FBFC;">
|
||||||
<span class="js-upload" uk-form-custom>
|
<div style="background: #DCE9E3; height: 200px" class="uk-grid uk-padding-large">
|
||||||
<input id="exampleInputFile" class="uk-width-medium" type="file" (change)="fileChangeEvent($event)"/>
|
<div class="uk-width-expand">
|
||||||
<span class="uk-link " style="text-decoration: underline;">Upload a DOI's CSV file </span>
|
<div>Title</div>
|
||||||
|
<div>Lorem ipsum.......</div>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="filesToUpload && !loading" class="uk-width-xlarge">
|
||||||
|
<div class="uk-text-right">
|
||||||
|
<span class="js-upload uk-button uk-button-primary" uk-form-custom>
|
||||||
|
<input id="upload-new" class="uk-width-medium" type="file" (change)="fileChangeEvent($event)"/>
|
||||||
|
<span uk-icon="upload"></span>
|
||||||
|
upload new file
|
||||||
|
<!-- <span class="uk-link " style="text-decoration: underline;">Upload a DOI's CSV file </span>-->
|
||||||
</span>
|
</span>
|
||||||
<!--button class="uk-button portal-button" type="button" tabindex="-1" [class.disabled]="!enableUpload" ><span class="uk-margin-small-right uk-icon" >
|
</div>
|
||||||
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> <polyline fill="none" stroke="#000" points="5 8 9.5 3.5 14 8 "></polyline> <rect x="3" y="17" width="13" height="1"></rect>
|
<div *ngIf="filesToUpload[0]" class="uk-grid">
|
||||||
<line fill="none" stroke="#000" x1="9.5" y1="15" x2="9.5" y2="4"></line></svg></span> Select</button-->
|
<div class="uk-width-auto">
|
||||||
<!--helper div="link-result-bulk" tooltip=true ></helper-->
|
<span uk-icon="icon: file-text; ratio:3"></span>
|
||||||
<span class=" " uk-tooltip><span class="uk-icon" uk-icon="icon: info; ratio: 0.8"> </span> </span>
|
</div>
|
||||||
</div>
|
<div class="uk-width-expand">
|
||||||
<div class="uk-width-1-1">
|
{{filesToUpload[0].name}}
|
||||||
All valid DOIs: {{allIds.length}} <br>
|
<progress class="uk-progress" [value]="enableUpload?100:10" max="100"></progress>
|
||||||
invalid DOIs: {{noValidIds.length}} <br>
|
</div>
|
||||||
duplicate: {{duplicateIds.length}} <br>
|
</div>
|
||||||
found in Openaire: {{foundIds.length}} <br>
|
</div>
|
||||||
not found in Openaire: {{notFoundIds.length}} <br>
|
</div>
|
||||||
</div>
|
<div *ngIf="!filesToUpload || loading" class="uk-section uk-container uk-flex uk-flex-center">
|
||||||
|
<div class="js-upload uk-placeholder uk-text-center uk-width-xlarge" uk-form-custom>
|
||||||
|
<div><span uk-icon="icon: upload; ratio: 3"></span></div>
|
||||||
|
<div><span class="uk-text-large">Drag and Drop your file here</span></div>
|
||||||
|
<div class="uk-text-meta uk-text-small">File supported: CSV</div>
|
||||||
|
<div class="uk-padding">or</div>
|
||||||
|
<div class="uk-button uk-button-secondary">
|
||||||
|
<input id="exampleInputFile" class="" type="file" (change)="fileChangeEvent($event)"/>
|
||||||
|
<span class="uk-link">CHOOSE FILE</span>
|
||||||
|
</div>
|
||||||
|
<div class="uk-text-meta uk-text-small uk-margin-small-top">Maximum size: 5 MB</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="loading" class="uk-section uk-container uk-flex uk-flex-center">
|
||||||
|
<div *ngIf="filesToUpload[0]" class="uk-grid">
|
||||||
|
<div class="uk-width-auto">
|
||||||
|
<span uk-icon="icon: file-text; ratio:3"></span>
|
||||||
|
</div>
|
||||||
|
<div class="uk-width-expand">
|
||||||
|
{{filesToUpload[0].name}}
|
||||||
|
<progress class="uk-progress" [value]="this.getercentage(this.foundIds.length + this.notFoundIds.length, false)" max="100"></progress>
|
||||||
|
<div><span *ngIf="loading">{{this.getercentage(this.foundIds.length + this.notFoundIds.length, false)}}% done</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="filesToUpload && !loading"class=" uk-padding-large">
|
||||||
|
<div class="uk-grid ">
|
||||||
|
|
||||||
<div *ngIf="foundIds.length + notFoundIds.length <allIds.length"> Fetching {{foundIds.length + notFoundIds.length}}/{{allIds.length}}... </div>
|
<div class="uk-width-3-4">
|
||||||
{{results.length}}
|
<modal-loading
|
||||||
<div>
|
[message]="'Uploading, reading your document and fetching results. Please give us a moment..'"></modal-loading>
|
||||||
<div>
|
|
||||||
<paging-no-load [totalResults]="foundIds.length" [size]="size" [currentPage]="page" (pageChange)="updatePage($event)"></paging-no-load>
|
<div>
|
||||||
<table class="uk-table uk-table-responsive uk-table-striped">
|
<!-- Filters-->
|
||||||
<tr *ngFor="let result of results.slice((page-1)*size,page*size)">
|
<div class="uk-grid">
|
||||||
<td>{{result.doi}}</td>
|
<div>
|
||||||
<ng-container *ngIf="result.found">
|
<a class="uk-link uk-width-small" >Filter by</a>
|
||||||
<td>{{result.title}}</td>
|
<div uk-dropdown>
|
||||||
<td>{{result.accessMode}}</td>
|
<ul class="uk-nav uk-dropdown-nav">
|
||||||
<td>{{result.accessRoute}}</td>
|
<li *ngFor="let option of filterByOptions" [class.uk-active]="filterBy == option.value"><a [class.uk-disabled]="stats[option[option.value]]==0" (click)="updateFilterBy(option.value)">{{option.label}}</a></li>
|
||||||
</ng-container>
|
</ul>
|
||||||
<ng-container *ngIf="!result.found">
|
</div>
|
||||||
<td> not found </td>
|
</div>
|
||||||
</ng-container>
|
<div>
|
||||||
|
<a class="uk-link uk-width-small" >Sort by</a>
|
||||||
|
<div uk-dropdown>
|
||||||
|
<ul class="uk-nav uk-dropdown-nav">
|
||||||
|
<li *ngFor="let option of sortByOptions" [class.uk-active]="filterBy == option.value"><a (click)="updateSortBy(option.value)">{{option.label}}</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div search-input [value]="keyword" (valueChange)="updateKeyword($event)"></div>
|
||||||
|
<div>
|
||||||
|
Viewing {{(page-1)*size}}-{{resultsToShow.length>(page)*size? (page)*size : resultsToShow.length}} of {{resultsToShow.length}}
|
||||||
|
</div>
|
||||||
|
<div *ngIf="resultsToShow.length > size">
|
||||||
|
<ul [class.uk-invisible]="resultsToShow.length<size" class="uk-pagination">
|
||||||
|
<li ><a class="uk-icon-button uk-icon-button-small" [class.uk-disabled]="page <= 1" (click)="updatePage(page-1)"><span uk-pagination-previous></span></a></li>
|
||||||
|
<li><a class="uk-icon-button uk-icon-button-small" [class.uk-disabled]="page*size > resultsToShow.length" (click)="updatePage(page+1)"><span uk-pagination-next></span></a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--<paging-no-load [totalResults]="foundIds.length" [size]="size" [currentPage]="page"
|
||||||
|
(pageChange)="updatePage($event)"></paging-no-load>-->
|
||||||
|
</div>
|
||||||
|
<table class="uk-table uk-table-responsive uk-table-striped">
|
||||||
|
<tr>
|
||||||
|
<!-- <th>DOI</th>-->
|
||||||
|
<th>Title</th>
|
||||||
|
<th>Access Mode</th>
|
||||||
|
<th>Access Route</th>
|
||||||
|
<th> in OpenAIRE</th>
|
||||||
|
</tr>
|
||||||
|
<tr *ngFor="let result of resultsToShow.slice((page-1)*size,page*size)">
|
||||||
|
<ng-container *ngIf="result.found">
|
||||||
|
<td><a [href]="'https://beta.explore.openaire.eu/search/result?pid='+result.doi"
|
||||||
|
target="_blank">{{result.title}}</a></td>
|
||||||
|
<td>{{result.accessMode}}</td>
|
||||||
|
<td>{{result.accessRoute}}</td>
|
||||||
|
</ng-container>
|
||||||
|
<ng-container *ngIf="!result.found">
|
||||||
|
<td colspan="3"> {{result.doi}}</td>
|
||||||
|
|
||||||
|
</ng-container>
|
||||||
|
<td><span *ngIf="result.found" uk-icon="check" class="uk-text-success"></span></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="uk-width-1-4">
|
||||||
|
<div class="uk-margin-top">
|
||||||
|
<span class="uk-text-bold uk-margin-small-bottom">{{foundIds.length}} results</span> found in Irish Monitor
|
||||||
|
</div>
|
||||||
|
<div class=" uk-card uk-card-default uk-padding-small uk-margin-small-top uk-margin-small-bottom">
|
||||||
|
<div class="uk-margin-top uk-margin-bottom uk-text-large">Access Rights</div>
|
||||||
|
<div class="uk-grid uk-margin-remove-top"><div class="uk-width-expand"><span class="dot open"></span> Open Access</div><div class="uk-text-right uk-width-auto"> {{stats['open']}} ({{getercentage(stats['open'])}}%)</div></div>
|
||||||
|
<div class="uk-grid uk-margin-remove-top"><div class="uk-width-expand"><span class="dot restricted"></span> Restricted</div><div class="uk-text-right uk-width-auto"> {{stats['restricted']}} ({{getercentage(stats['restricted'])}}%)</div></div>
|
||||||
|
<div class="uk-grid uk-margin-remove-top"><div class="uk-width-expand"><span class="dot embargo"></span> Embargo</div><div class="uk-text-right uk-width-auto"> {{stats['embargo']}} ({{getercentage(stats['embargo'])}}%)</div></div>
|
||||||
|
<div class="uk-grid uk-margin-remove-top"><div class="uk-width-expand"><span class="dot closed"></span> Closed</div><div class="uk-text-right uk-width-auto"> {{stats['closed']}} ({{getercentage(stats['closed'])}}%)</div></div>
|
||||||
|
<hr>
|
||||||
|
<div class="uk-grid uk-margin-remove-top"><div class="uk-width-expand"><span class="dot green"></span> Green</div><div class="uk-text-right uk-width-auto"> {{stats['green']}} ({{getercentage(stats['green'])}}%)</div></div>
|
||||||
|
<div class="uk-grid uk-margin-remove-top"><div class="uk-width-expand"><span class="dot gold"></span> Gold</div><div class="uk-text-right uk-width-auto"> {{stats['gold']}} ({{getercentage(stats['gold'])}}%)</div></div>
|
||||||
|
<div class="uk-grid uk-margin-remove-top"><div class="uk-width-expand"><span class="dot hybrid"></span> Hybrid</div><div class="uk-text-right uk-width-auto"> {{stats['hybrid']}} ({{getercentage(stats['hybrid'])}}%)</div></div>
|
||||||
|
<div class="uk-grid uk-margin-remove-top"><div class="uk-width-expand"><span class="dot bronze"></span> Bronze</div><div class="uk-text-right uk-width-auto"> {{stats['bronze']}} ({{getercentage(stats['bronze'])}}%)</div></div>
|
||||||
|
<div class="uk-grid uk-margin-remove-top"><div class="uk-width-expand"><span class="dot diamond"></span> Diamond</div><div class="uk-text-right uk-width-auto"> {{stats['diamond']}} ({{getercentage(stats['diamond'])}}%)</div></div>
|
||||||
|
</div>
|
||||||
|
<div class=" uk-card uk-card-default uk-padding-small uk-margin-small-top uk-margin-small-bottom">
|
||||||
|
<div class="uk-grid uk-child-width-1-3 ">
|
||||||
|
<div *ngIf="allIds.length > 0" class="uk-text-center ">
|
||||||
|
<div class=""><span uk-icon="icon:check; ratio:2" class="uk-icon-button"></span></div>
|
||||||
|
<div> <div>valid</div>
|
||||||
|
<div class="uk-text-bold">{{allIds.length}}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div *ngIf="notFoundIds.length > 0" class="uk-text-center ">
|
||||||
|
<div class=""><span uk-icon="icon:question; ratio:2" class="uk-icon-button"></span></div>
|
||||||
|
<div> <div>not found</div>
|
||||||
|
<div class="uk-text-bold">{{notFoundIds.length}}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div *ngIf="duplicateIds.length > 0" class="uk-text-center ">
|
||||||
|
<div class=""><span uk-icon="icon:copy; ratio:2" class="uk-icon-button"></span></div>
|
||||||
|
<div> <div>duplicates</div>
|
||||||
|
<div class="uk-text-bold">{{duplicateIds.length}}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!--<div *ngIf="noValidIds.length > 0" class="uk-text-center ">
|
||||||
|
<div class=""><span uk-icon="icon:close; ratio:2" class="uk-icon-button"></span></div>
|
||||||
|
<div> <div>invalid</div>
|
||||||
|
<div class="uk-text-bold">{{noValidIds.length}}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<modal-loading
|
|
||||||
[message]="'Uploading, reading your document and fetching results. Please give us a moment..'"></modal-loading>
|
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
.dot {
|
||||||
|
height: 8px;
|
||||||
|
width: 8px;
|
||||||
|
background-color: #bbb;
|
||||||
|
border-radius: 50%;
|
||||||
|
display: inline-block;
|
||||||
|
margin-right: 4px;
|
||||||
|
}
|
||||||
|
.dot.open{
|
||||||
|
background-color: orange;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dot.restricted{
|
||||||
|
background-color: #920192;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dot.embargo{
|
||||||
|
background-color: #003E92;
|
||||||
|
}
|
||||||
|
.dot.closed{
|
||||||
|
background-color: #E34950;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dot.green{
|
||||||
|
background-color: #24B050;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dot.gold{
|
||||||
|
background-color: #EAB201;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dot.hybrid{
|
||||||
|
background-color: #ED7D31;
|
||||||
|
}
|
||||||
|
.dot.bronze{
|
||||||
|
background-color: #806001;
|
||||||
|
}
|
||||||
|
.dot.diamond{
|
||||||
|
background-color: #595959;
|
||||||
|
}
|
|
@ -1,22 +1,20 @@
|
||||||
import {Component, Input, OnInit, ViewChild} from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
import {Dates, DOI, Identifier, StringUtils} from "../openaireLibrary/utils/string-utils.class";
|
import {DOI, Identifier} from "../openaireLibrary/utils/string-utils.class";
|
||||||
import {EnvProperties} from "../openaireLibrary/utils/properties/env-properties";
|
import {EnvProperties} from "../openaireLibrary/utils/properties/env-properties";
|
||||||
import {ErrorCodes} from "../openaireLibrary/utils/properties/errorCodes";
|
import {ErrorCodes} from "../openaireLibrary/utils/properties/errorCodes";
|
||||||
import {Subscriber, timer} from "rxjs";
|
import {Subscriber, timer} from "rxjs";
|
||||||
import {properties} from "../../environments/environment";
|
import {properties} from "../../environments/environment";
|
||||||
import {ClaimEntity} from "../openaireLibrary/claims/claim-utils/claimHelper.class";
|
|
||||||
import {ModalLoading} from "../openaireLibrary/utils/modal/loading.component";
|
|
||||||
import {SearchResearchResultsService} from "../openaireLibrary/services/searchResearchResults.service";
|
import {SearchResearchResultsService} from "../openaireLibrary/services/searchResearchResults.service";
|
||||||
import {map} from "rxjs/operators";
|
import {map} from "rxjs/operators";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'upload-dois',
|
selector: 'upload-dois',
|
||||||
templateUrl: './upload-dois.component.html',
|
templateUrl: './upload-dois.component.html',
|
||||||
|
styleUrls:['./upload-dois.component.less']
|
||||||
})
|
})
|
||||||
export class UploadDoisComponent implements OnInit {
|
export class UploadDoisComponent implements OnInit {
|
||||||
page: number = 1;
|
page: number = 1;
|
||||||
size: number = 20;
|
size: number = 2;
|
||||||
public keyword: string = "";//"paolo manghi";//'0000-0001-7291-3210';
|
|
||||||
properties: EnvProperties = properties;
|
properties: EnvProperties = properties;
|
||||||
public errorCodes: ErrorCodes = new ErrorCodes();
|
public errorCodes: ErrorCodes = new ErrorCodes();
|
||||||
public warningMessage = "";
|
public warningMessage = "";
|
||||||
|
@ -26,7 +24,8 @@ export class UploadDoisComponent implements OnInit {
|
||||||
filesToUpload: Array<File>;
|
filesToUpload: Array<File>;
|
||||||
|
|
||||||
public select: boolean = true;
|
public select: boolean = true;
|
||||||
public results =[];
|
public results = [];
|
||||||
|
public resultsToShow = [];
|
||||||
|
|
||||||
allIds: string[] = [];
|
allIds: string[] = [];
|
||||||
foundIds: string[] = [];
|
foundIds: string[] = [];
|
||||||
|
@ -38,11 +37,41 @@ export class UploadDoisComponent implements OnInit {
|
||||||
noValidIds: string[] = [];
|
noValidIds: string[] = [];
|
||||||
noValidIdsRow: number[] = [];
|
noValidIdsRow: number[] = [];
|
||||||
showReport: boolean = false;
|
showReport: boolean = false;
|
||||||
@ViewChild(ModalLoading) loading: ModalLoading;
|
|
||||||
errorMessage = "";
|
errorMessage = "";
|
||||||
enableUpload: boolean = true;
|
enableUpload: boolean = true;
|
||||||
exceedsLimit = false;
|
exceedsLimit = false;
|
||||||
fileLimit = 5;
|
fileLimit = 5;
|
||||||
|
stats = {
|
||||||
|
open: 0,
|
||||||
|
closed: 0,
|
||||||
|
embargo: 0,
|
||||||
|
restricted: 0,
|
||||||
|
green:0,
|
||||||
|
gold:0,
|
||||||
|
hybrid:0,
|
||||||
|
bronze:0,
|
||||||
|
diamond:0
|
||||||
|
}
|
||||||
|
filterBy = null;
|
||||||
|
filterByOptions = [{label: "In Openaire", value: "openaire"},
|
||||||
|
{label: "Not found", value: "notFound"},
|
||||||
|
{label: "Open Access", value: "access-open"},
|
||||||
|
{label: "Embargo", value: "access-embargo"},
|
||||||
|
{label: "Restricted", value: "access-restricted"},
|
||||||
|
{label: "Closed", value: "access-closed"},
|
||||||
|
{label: "Green", value: "route-green"},
|
||||||
|
{label: "Gold", value: "route-gold"},
|
||||||
|
{label: "Hybrid", value: "route-hybrid"},
|
||||||
|
{label: "Bronze", value: "route-bronze"},
|
||||||
|
{label: "Diamond", value: "route-diamond"},
|
||||||
|
]
|
||||||
|
sortBy = null;
|
||||||
|
sortByOptions = [{label: "Title", value: "title"},
|
||||||
|
{label: "Access mode", value: "accessMode"},
|
||||||
|
]
|
||||||
|
|
||||||
|
keyword = "";
|
||||||
|
loading = false;
|
||||||
constructor(private _searchResearchResultsService: SearchResearchResultsService) {
|
constructor(private _searchResearchResultsService: SearchResearchResultsService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -58,11 +87,17 @@ export class UploadDoisComponent implements OnInit {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
upload() {
|
upload() {
|
||||||
|
this.loading = true;
|
||||||
this.enableUpload = false;
|
this.enableUpload = false;
|
||||||
this.showReport = false;
|
this.showReport = false;
|
||||||
this.errorMessage = "";
|
this.errorMessage = "";
|
||||||
console.log(this.filesToUpload);
|
this.results = [];
|
||||||
|
this.resultsToShow = [];
|
||||||
|
this.sortBy = null;
|
||||||
|
this.filterBy = null;
|
||||||
|
this.keyword = "";
|
||||||
if (this.filesToUpload.length == 0) {
|
if (this.filesToUpload.length == 0) {
|
||||||
this.errorMessage = "There is no selected file to upload.";
|
this.errorMessage = "There is no selected file to upload.";
|
||||||
return;
|
return;
|
||||||
|
@ -73,8 +108,6 @@ export class UploadDoisComponent implements OnInit {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// this.loading.open();
|
|
||||||
console.log("here!");
|
|
||||||
|
|
||||||
this.makeFileRequest(this.properties.utilsService + '/upload', [], this.filesToUpload).then((result) => {
|
this.makeFileRequest(this.properties.utilsService + '/upload', [], this.filesToUpload).then((result) => {
|
||||||
const rows = (result as any).split('\n'); // I have used space, you can use any thing.
|
const rows = (result as any).split('\n'); // I have used space, you can use any thing.
|
||||||
|
@ -87,18 +120,18 @@ export class UploadDoisComponent implements OnInit {
|
||||||
this.noValidIds = [];
|
this.noValidIds = [];
|
||||||
// this.results.slice(0, this.results.length);
|
// this.results.slice(0, this.results.length);
|
||||||
this.notFoundIds = [];
|
this.notFoundIds = [];
|
||||||
if(rows.length > this.fileLimit){
|
if (rows.length > this.fileLimit) {
|
||||||
this.exceedsLimit = true;
|
this.exceedsLimit = true;
|
||||||
}
|
}
|
||||||
for (let i = 0; i < ( rows.length); i++) {23
|
for (let i = 0; i < (rows.length); i++) {
|
||||||
if (rows[i] && rows[i] != null && rows[i]!="") {
|
if (rows[i] && rows[i] != null && rows[i] != "") {
|
||||||
const values = rows[i].split(',');
|
const values = rows[i].split(',');
|
||||||
|
|
||||||
let id = this.removeDoubleQuotes(values[0]);
|
let id = this.removeDoubleQuotes(values[0]);
|
||||||
if (DOI.isValidDOI(id)) {
|
if (DOI.isValidDOI(id)) {
|
||||||
id = Identifier.getRawDOIValue(id);
|
id = Identifier.getRawDOIValue(id);
|
||||||
console.log(id, id.split("\r")[0]);
|
console.log(id, id.split("\r")[0]);
|
||||||
id=id.split("\r")[0]
|
id = id.split("\r")[0]
|
||||||
if (this.allIds.indexOf(id) > -1) {
|
if (this.allIds.indexOf(id) > -1) {
|
||||||
this.duplicateIds.push(id);
|
this.duplicateIds.push(id);
|
||||||
this.duplicateIdsRow.push(i + 1);
|
this.duplicateIdsRow.push(i + 1);
|
||||||
|
@ -114,16 +147,16 @@ export class UploadDoisComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
this.enableUpload = true;
|
||||||
this.fetchAllResults();
|
this.fetchAllResults();
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
this.enableUpload = true;
|
this.enableUpload = true;
|
||||||
this.loading.close();
|
|
||||||
this.errorMessage = "An error occured.";
|
this.errorMessage = "An error occured.";
|
||||||
this.handleError("Error uploading file", error);
|
this.handleError("Error uploading file", error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private removeDoubleQuotes(value) {
|
private removeDoubleQuotes(value) {
|
||||||
if (value.indexOf('"') == 0) {
|
if (value.indexOf('"') == 0) {
|
||||||
value = value.substring(1, value.length);
|
value = value.substring(1, value.length);
|
||||||
}
|
}
|
||||||
|
@ -134,7 +167,7 @@ export class UploadDoisComponent implements OnInit {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private validateAccessMode(value) {
|
private validateAccessMode(value) {
|
||||||
const accessModes = ["OPEN", "CLOSED", "EMBARGO"];
|
const accessModes = ["OPEN", "CLOSED", "EMBARGO"];
|
||||||
return accessModes.indexOf(value) > -1;
|
return accessModes.indexOf(value) > -1;
|
||||||
}
|
}
|
||||||
|
@ -167,51 +200,63 @@ export class UploadDoisComponent implements OnInit {
|
||||||
|
|
||||||
fetchAllResults() {
|
fetchAllResults() {
|
||||||
let page = 1;
|
let page = 1;
|
||||||
let timerSubscription = timer(0, 1000).pipe(
|
let timerSubscription = timer(0, 1000).pipe(
|
||||||
map(() => {
|
map(() => {
|
||||||
if((page-1)*this.size <= this.allIds.length) {
|
if ((page - 1) * this.size <= this.allIds.length) {
|
||||||
this.fetchResultsByPage(page); // load data contains the http request
|
this.fetchResultsByPage(page); // load data contains the http request
|
||||||
page += 1;
|
page += 1;
|
||||||
}else{
|
} else {
|
||||||
this.stopFetching(timerSubscription);
|
this.stopFetching(timerSubscription);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
).subscribe();
|
).subscribe();
|
||||||
this.subscriptions.push(timerSubscription);
|
this.subscriptions.push(timerSubscription);
|
||||||
}
|
}
|
||||||
stopFetching(timerSubscription){
|
|
||||||
|
stopFetching(timerSubscription) {
|
||||||
timerSubscription.unsubscribe();
|
timerSubscription.unsubscribe();
|
||||||
}
|
this.loading = false;
|
||||||
fetchResultsByPage(page) {
|
|
||||||
let dois = this.allIds.slice((page-1)*this.size,page*this.size);
|
|
||||||
if(dois.length == 0){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let query = ""
|
|
||||||
for (let i = 0; i < dois.length; i++) {
|
|
||||||
query += (query.length > 0 ? " or " : "") + '(pidclassid exact "doi" and pid="' + StringUtils.URIEncode(dois[i]) + '")';
|
|
||||||
}
|
|
||||||
// this.subscriptions.push(this._searchResearchResultsService.advancedSearchResults("publications",query ,1,this.size,null,properties,"&type=results").subscribe(data=>{
|
|
||||||
this.subscriptions.push(this._searchResearchResultsService.fetchByDOIs(dois).subscribe( data => {
|
|
||||||
for(let result of data[1]){
|
|
||||||
let matchingDOI =this.findMatchingDoi(result.DOIs,dois)
|
|
||||||
this.foundIds.push(matchingDOI);
|
|
||||||
this.results.push({ doi:matchingDOI, title: result.title.name, accessMode:result.title.accessMode, accessRoute:null, found: true})
|
|
||||||
}
|
|
||||||
if(data[0]<dois.length){
|
|
||||||
for(let doi of dois){
|
|
||||||
if(this.foundIds.indexOf(doi) ==-1){
|
|
||||||
this.notFoundIds.push(doi);
|
|
||||||
// this.results.push({ doi:doi, title: null, accessMode:null, accessRoute:null, found: false})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
findMatchingDoi(resultDois,requestedDois){
|
fetchResultsByPage(page) {
|
||||||
for(let doi of resultDois){
|
let dois = this.allIds.slice((page - 1) * this.size, page * this.size);
|
||||||
if(requestedDois.indexOf(doi)!=-1){
|
if (dois.length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.subscriptions.push(this._searchResearchResultsService.fetchByDOIs(dois).subscribe(data => {
|
||||||
|
for (let result of data[1]) {
|
||||||
|
let matchingDOI = this.findMatchingDoi(result.DOIs, dois);
|
||||||
|
this.foundIds.push(matchingDOI);
|
||||||
|
let showRes = {
|
||||||
|
doi: matchingDOI,
|
||||||
|
title: result.title.name,
|
||||||
|
accessMode: result.title.accessMode,
|
||||||
|
accessRoute: null,
|
||||||
|
green: false,
|
||||||
|
openAccessColor:null,
|
||||||
|
diamond: false,
|
||||||
|
found: true
|
||||||
|
};
|
||||||
|
this.results.push(showRes)
|
||||||
|
this.addStatsPerResult(result)
|
||||||
|
}
|
||||||
|
if (data[0] < dois.length) {
|
||||||
|
for (let doi of dois) {
|
||||||
|
if (this.foundIds.indexOf(doi) == -1) {
|
||||||
|
this.notFoundIds.push(doi);
|
||||||
|
this.results.push({doi: doi, title: null, accessMode: null, green: false, openAccessColor:null, diamond: false, accessRoute: null, found: false})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.resultsToShow = [...this.results];
|
||||||
|
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
findMatchingDoi(resultDois, requestedDois) {
|
||||||
|
for (let doi of resultDois) {
|
||||||
|
if (requestedDois.indexOf(doi) != -1) {
|
||||||
return doi;
|
return doi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,27 +264,118 @@ export class UploadDoisComponent implements OnInit {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleError(message: string, error) {
|
private handleError(message: string, error) {
|
||||||
console.error("Bulk Claim (component): " + message, error);
|
console.error("Upload error: " + message, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
private isSelected(result: ClaimEntity) {
|
addStatsPerResult(result) {
|
||||||
|
if (result.title.accessMode == "Open Access") {
|
||||||
let found: boolean = false;
|
this.stats.open++;
|
||||||
const id = result.id;
|
|
||||||
for (let _i = 0; _i < this.results.length; _i++) {
|
|
||||||
let item = this.results[_i];
|
|
||||||
if (item.id && item.id == id) {
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return found;
|
if (result.title.accessMode == "Closed Access") {
|
||||||
// indexOf doesn't work when results came from
|
this.stats.closed++;
|
||||||
// return this.selectedResults.indexOf(entity)!=-1;
|
}
|
||||||
|
if (result.title.accessMode == "Embargo") {
|
||||||
|
this.stats.embargo++;
|
||||||
|
}
|
||||||
|
if (result.title.accessMode == "Restricted") {
|
||||||
|
this.stats.restricted++;
|
||||||
|
}
|
||||||
|
//TDO add access routes stats
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePage($event) {
|
updatePage(page) {
|
||||||
this.page = $event.value;
|
this.page = page;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateSortBy(sortBy) {
|
||||||
|
this.sortBy = sortBy;
|
||||||
|
this.updateView();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateFilterBy(filterBy) {
|
||||||
|
this.filterBy = filterBy;
|
||||||
|
this.updateView();
|
||||||
|
}
|
||||||
|
updateKeyword(keyword){
|
||||||
|
this.keyword = keyword;
|
||||||
|
this.updateView();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateView() {
|
||||||
|
this.resultsToShow = [...this.results];
|
||||||
|
if (this.filterBy) {
|
||||||
|
this.resultsToShow = this.filterResults();
|
||||||
|
}
|
||||||
|
if(this.keyword.length > 0){
|
||||||
|
this.resultsToShow = this.filterResultsByKeyword();
|
||||||
|
}
|
||||||
|
if(this.sortBy){
|
||||||
|
this.resultsToShow= this.sortResults();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
filterResults() {
|
||||||
|
return this.results.filter(res =>{
|
||||||
|
if(this.filterBy == "openaire"){
|
||||||
|
return res.found
|
||||||
|
}else if(this.filterBy == "notFound"){
|
||||||
|
return !res.found
|
||||||
|
}else if(this.filterBy == "access-closed"){
|
||||||
|
return res.accessMode == "Closed Access";
|
||||||
|
}else if(this.filterBy == "access-restricted"){
|
||||||
|
return res.accessMode == "Restricted";
|
||||||
|
}else if(this.filterBy == "access-open"){
|
||||||
|
return res.accessMode == "Open Access";
|
||||||
|
}else if(this.filterBy == "access-embargo") {
|
||||||
|
return res.accessMode == "Embargo";
|
||||||
|
}else if(this.filterBy == "route-green") {
|
||||||
|
return res.green;
|
||||||
|
}else if(this.filterBy == "route-diamond") {
|
||||||
|
return res.diamond;
|
||||||
|
}else if(this.filterBy == "route-gold") {
|
||||||
|
return res.openAccessColor == "gold";
|
||||||
|
}else if(this.filterBy == "route-hybrid") {
|
||||||
|
return res.openAccessColor == "hybrid";
|
||||||
|
}else if(this.filterBy == "route-bronze") {
|
||||||
|
return res.openAccessColor == "bronze";
|
||||||
|
}else{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
filterResultsByKeyword() {
|
||||||
|
return this.resultsToShow.filter(res =>{
|
||||||
|
|
||||||
|
return (res.found && (res.title && res.title.toLowerCase().indexOf(this.keyword.toLowerCase()) !=-1))
|
||||||
|
|| (res.doi && res.doi.indexOf(this.keyword.toLowerCase()) != -1);
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
sortResults(){
|
||||||
|
|
||||||
|
return this.resultsToShow.sort((n1, n2) => {
|
||||||
|
if (n1[this.sortBy] && n2[this.sortBy] && n1[this.sortBy] > n2[this.sortBy]) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (n1[this.sortBy] && n2[this.sortBy] && n1[this.sortBy] < n2[this.sortBy]) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
getercentage(number, foundIds = true){
|
||||||
|
if(!number){
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
let from = foundIds?this.foundIds.length:this.allIds.length
|
||||||
|
var num = new Number((number/from)*100);
|
||||||
|
return num == 100?100:num.toPrecision(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,17 +2,16 @@ import {NgModule} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
import {CommonModule} from '@angular/common';
|
||||||
import {UploadDoisComponent} from "./upload-dois.component";
|
import {UploadDoisComponent} from "./upload-dois.component";
|
||||||
import {UploadDoisRoutingModule} from "./upload-dois-routing.module";
|
import {UploadDoisRoutingModule} from "./upload-dois-routing.module";
|
||||||
import {LoadingModalModule} from "../openaireLibrary/utils/modal/loadingModal.module";
|
|
||||||
import {SearchResearchResultsServiceModule} from "../openaireLibrary/services/searchResearchResultsService.module";
|
import {SearchResearchResultsServiceModule} from "../openaireLibrary/services/searchResearchResultsService.module";
|
||||||
import {PagingModule} from "../openaireLibrary/utils/paging.module";
|
import {PagingModule} from "../openaireLibrary/utils/paging.module";
|
||||||
|
import {SearchInputModule} from "../openaireLibrary/sharedComponents/search-input/search-input.module";
|
||||||
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [UploadDoisComponent],
|
declarations: [UploadDoisComponent],
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule, UploadDoisRoutingModule, LoadingModalModule, SearchResearchResultsServiceModule, PagingModule
|
CommonModule, UploadDoisRoutingModule, SearchResearchResultsServiceModule, PagingModule, SearchInputModule
|
||||||
|
|
||||||
],
|
],
|
||||||
// exports: [UploadDoisComponent]
|
|
||||||
})
|
})
|
||||||
export class UploadDoisModule { }
|
export class UploadDoisModule { }
|
||||||
|
|
Loading…
Reference in New Issue