2023-11-09 14:35:44 +01:00
|
|
|
import {Component, OnInit} from '@angular/core';
|
|
|
|
import {DOI, Identifier} from "../openaireLibrary/utils/string-utils.class";
|
2023-10-25 16:42:38 +02:00
|
|
|
import {EnvProperties} from "../openaireLibrary/utils/properties/env-properties";
|
|
|
|
import {ErrorCodes} from "../openaireLibrary/utils/properties/errorCodes";
|
|
|
|
import {Subscriber, timer} from "rxjs";
|
|
|
|
import {properties} from "../../environments/environment";
|
|
|
|
import {SearchResearchResultsService} from "../openaireLibrary/services/searchResearchResults.service";
|
|
|
|
import {map} from "rxjs/operators";
|
2023-11-20 16:58:41 +01:00
|
|
|
import {Filter} from "../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class";
|
2023-11-28 17:43:42 +01:00
|
|
|
import {LogService} from "../openaireLibrary/utils/log/log.service";
|
2023-12-12 12:50:19 +01:00
|
|
|
import {BaseComponent} from '../openaireLibrary/sharedComponents/base/base.component';
|
|
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
|
|
|
import {SEOService} from '../openaireLibrary/sharedComponents/SEO/SEO.service';
|
|
|
|
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
|
|
|
|
import {Meta, Title} from '@angular/platform-browser';
|
2023-10-25 16:42:38 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'upload-dois',
|
2023-12-07 16:01:53 +01:00
|
|
|
templateUrl: './upload-dois.component.html'
|
2023-10-25 16:42:38 +02:00
|
|
|
})
|
2023-12-12 12:50:19 +01:00
|
|
|
export class UploadDoisComponent extends BaseComponent implements OnInit {
|
|
|
|
private static UPLOAD_TIMEOUT = 2000;
|
2023-10-25 16:42:38 +02:00
|
|
|
page: number = 1;
|
2023-11-14 14:09:36 +01:00
|
|
|
size: number = 100;
|
2023-11-28 10:05:33 +01:00
|
|
|
requestSize: number = 80;
|
2023-10-25 16:42:38 +02:00
|
|
|
properties: EnvProperties = properties;
|
|
|
|
public errorCodes: ErrorCodes = new ErrorCodes();
|
|
|
|
public warningMessage = "";
|
|
|
|
public infoMessage = "";
|
|
|
|
|
|
|
|
subscriptions = [];
|
|
|
|
filesToUpload: Array<File>;
|
|
|
|
|
|
|
|
public select: boolean = true;
|
2023-11-09 14:35:44 +01:00
|
|
|
public results = [];
|
|
|
|
public resultsToShow = [];
|
2023-10-25 16:42:38 +02:00
|
|
|
|
|
|
|
allIds: string[] = [];
|
|
|
|
foundIds: string[] = [];
|
|
|
|
existedIds: string[] = [];
|
|
|
|
duplicateIds: string[] = [];
|
|
|
|
duplicateIdsRow: number[] = [];
|
|
|
|
notFoundIds: string[] = [];
|
|
|
|
notFoundIdsRow: number[] = [];
|
|
|
|
noValidIds: string[] = [];
|
|
|
|
noValidIdsRow: number[] = [];
|
|
|
|
showReport: boolean = false;
|
|
|
|
errorMessage = "";
|
|
|
|
enableUpload: boolean = true;
|
|
|
|
exceedsLimit = false;
|
|
|
|
fileLimit = 5;
|
2023-11-09 14:35:44 +01:00
|
|
|
stats = {
|
|
|
|
open: 0,
|
|
|
|
closed: 0,
|
|
|
|
embargo: 0,
|
|
|
|
restricted: 0,
|
|
|
|
green:0,
|
|
|
|
gold:0,
|
|
|
|
hybrid:0,
|
|
|
|
bronze:0,
|
|
|
|
diamond:0
|
|
|
|
}
|
2023-11-20 16:58:41 +01:00
|
|
|
accessModeFilter:Filter = null;
|
|
|
|
accessRouteFilter:Filter = null;
|
2023-11-27 16:06:46 +01:00
|
|
|
onlyGreen:boolean = false;
|
|
|
|
onlyDiamond:boolean = false;
|
2023-11-20 16:58:41 +01:00
|
|
|
/*filterByAccessRouteOptions = [
|
|
|
|
{label: "Green OA", value: "route-green"},
|
|
|
|
{label: "Published in OA Diamond", value: "route-diamond"},
|
|
|
|
]*/
|
|
|
|
sortByTitleAsc = true;
|
|
|
|
|
2023-11-09 14:35:44 +01:00
|
|
|
|
|
|
|
keyword = "";
|
|
|
|
loading = false;
|
2023-11-20 16:58:41 +01:00
|
|
|
showFound = true;
|
2023-12-12 12:50:19 +01:00
|
|
|
constructor(private _searchResearchResultsService: SearchResearchResultsService,
|
|
|
|
private _logService: LogService,
|
|
|
|
protected _router: Router,
|
|
|
|
protected _route: ActivatedRoute,
|
|
|
|
protected seoService: SEOService,
|
|
|
|
protected _piwikService: PiwikService,
|
|
|
|
protected _title: Title,
|
|
|
|
protected _meta: Meta) {
|
|
|
|
super();
|
2023-10-25 16:42:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
2023-12-12 12:50:19 +01:00
|
|
|
this.title = 'Upload DOIs';
|
|
|
|
this.description = 'Upload DOIs';
|
|
|
|
this.setMetadata();
|
2023-10-25 16:42:38 +02:00
|
|
|
}
|
2023-11-09 14:35:44 +01:00
|
|
|
|
2023-10-25 16:42:38 +02:00
|
|
|
upload() {
|
2023-11-09 14:35:44 +01:00
|
|
|
this.loading = true;
|
2023-10-25 16:42:38 +02:00
|
|
|
this.enableUpload = false;
|
|
|
|
this.showReport = false;
|
|
|
|
this.errorMessage = "";
|
2023-11-09 14:35:44 +01:00
|
|
|
this.results = [];
|
|
|
|
this.resultsToShow = [];
|
2023-11-20 16:58:41 +01:00
|
|
|
this.sortByTitleAsc = true;
|
2023-11-27 16:06:46 +01:00
|
|
|
this.onlyGreen = false;
|
|
|
|
this.onlyDiamond =false;
|
2023-11-09 14:35:44 +01:00
|
|
|
this.keyword = "";
|
2023-11-20 16:58:41 +01:00
|
|
|
this.showFound = true;
|
2023-11-28 10:05:33 +01:00
|
|
|
this.stats = {
|
|
|
|
open: 0,
|
|
|
|
closed: 0,
|
|
|
|
embargo: 0,
|
|
|
|
restricted: 0,
|
|
|
|
green:0,
|
|
|
|
gold:0,
|
|
|
|
hybrid:0,
|
|
|
|
bronze:0,
|
|
|
|
diamond:0
|
|
|
|
}
|
2023-10-25 16:42:38 +02:00
|
|
|
if (this.filesToUpload.length == 0) {
|
|
|
|
this.errorMessage = "There is no selected file to upload.";
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
if (this.filesToUpload[0].name.indexOf(".csv") == -1 ||
|
|
|
|
(this.filesToUpload[0].type != "text/csv" && this.filesToUpload[0].type != "application/vnd.ms-excel")) {
|
|
|
|
this.errorMessage = "No valid file type. The required type is CSV";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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.
|
|
|
|
this.exceedsLimit = false;
|
|
|
|
let invalid_rows = 0;
|
|
|
|
this.duplicateIds = [];
|
|
|
|
this.existedIds = [];
|
|
|
|
this.allIds = [];
|
|
|
|
this.foundIds = [];
|
|
|
|
this.noValidIds = [];
|
|
|
|
// this.results.slice(0, this.results.length);
|
|
|
|
this.notFoundIds = [];
|
2023-11-09 14:35:44 +01:00
|
|
|
if (rows.length > this.fileLimit) {
|
2023-10-25 16:42:38 +02:00
|
|
|
this.exceedsLimit = true;
|
|
|
|
}
|
2023-11-09 14:35:44 +01:00
|
|
|
for (let i = 0; i < (rows.length); i++) {
|
|
|
|
if (rows[i] && rows[i] != null && rows[i] != "") {
|
2023-12-05 13:51:29 +01:00
|
|
|
try {
|
|
|
|
const values = rows[i].split(',');
|
2023-10-25 16:42:38 +02:00
|
|
|
|
2023-12-05 13:51:29 +01:00
|
|
|
let id = this.removeDoubleQuotes(values[0]);
|
|
|
|
if (DOI.isValidDOI(id)) {
|
|
|
|
id = Identifier.getRawDOIValue(id);
|
|
|
|
// console.log(id, id.split("\r")[0]);
|
|
|
|
id = id.split("\r")[0]
|
|
|
|
if (this.allIds.indexOf(id) > -1) {
|
|
|
|
this.duplicateIds.push(id);
|
|
|
|
this.duplicateIdsRow.push(i + 1);
|
|
|
|
} else {
|
|
|
|
this.allIds.push(id);
|
|
|
|
}
|
2023-10-25 16:42:38 +02:00
|
|
|
} else {
|
2023-12-05 13:51:29 +01:00
|
|
|
this.noValidIds.push(id);
|
|
|
|
this.noValidIdsRow.push(i + 1);
|
2023-10-25 16:42:38 +02:00
|
|
|
}
|
2023-12-05 13:51:29 +01:00
|
|
|
}catch (e){
|
|
|
|
invalid_rows++;
|
2023-10-25 16:42:38 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
invalid_rows++;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2023-11-09 14:35:44 +01:00
|
|
|
this.enableUpload = true;
|
2023-11-28 17:50:21 +01:00
|
|
|
if(properties.logServiceUrl) {
|
2023-11-28 17:43:42 +01:00
|
|
|
this.subscriptions.push(this._logService.logUploadDOIs(properties, this.allIds.length).subscribe(res => { }));
|
|
|
|
}
|
2023-12-05 13:51:29 +01:00
|
|
|
if(this.allIds.length > 0) {
|
|
|
|
this.fetchAllResults();
|
2023-12-12 12:50:19 +01:00
|
|
|
} else {
|
|
|
|
setTimeout(() => {
|
|
|
|
this.loading = false;
|
|
|
|
}, UploadDoisComponent.UPLOAD_TIMEOUT);
|
2023-12-05 13:51:29 +01:00
|
|
|
}
|
2023-10-25 16:42:38 +02:00
|
|
|
}, (error) => {
|
|
|
|
this.enableUpload = true;
|
|
|
|
this.errorMessage = "An error occured.";
|
|
|
|
this.handleError("Error uploading file", error);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-11-09 14:35:44 +01:00
|
|
|
private removeDoubleQuotes(value) {
|
2023-10-25 16:42:38 +02:00
|
|
|
if (value.indexOf('"') == 0) {
|
|
|
|
value = value.substring(1, value.length);
|
|
|
|
}
|
|
|
|
const index = +value.indexOf('"');
|
|
|
|
if (index == (value.length - 1) || index == (value.length - 2)) {
|
|
|
|
value = value.substring(0, index);
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2023-11-09 14:35:44 +01:00
|
|
|
private validateAccessMode(value) {
|
2023-10-25 16:42:38 +02:00
|
|
|
const accessModes = ["OPEN", "CLOSED", "EMBARGO"];
|
|
|
|
return accessModes.indexOf(value) > -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
fileChangeEvent(fileInput: any) {
|
|
|
|
this.filesToUpload = <Array<File>>fileInput.target.files;
|
|
|
|
this.upload();
|
|
|
|
}
|
|
|
|
|
|
|
|
makeFileRequest(url: string, params: Array<string>, files: Array<File>) {
|
|
|
|
return new Promise<void>((resolve, reject) => {
|
|
|
|
const formData: any = new FormData();
|
|
|
|
const xhr = new XMLHttpRequest();
|
|
|
|
for (let i = 0; i < files.length; i++) {
|
|
|
|
formData.append("uploads[]", files[i], files[i].name);
|
|
|
|
}
|
|
|
|
xhr.onreadystatechange = function () {
|
|
|
|
if (xhr.readyState == 4) {
|
|
|
|
if (xhr.status == 200) {
|
|
|
|
resolve(xhr.response);
|
|
|
|
} else {
|
|
|
|
reject(xhr.response);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
xhr.open("POST", url, true);
|
|
|
|
xhr.send(formData);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
fetchAllResults() {
|
|
|
|
let page = 1;
|
2023-12-12 12:50:19 +01:00
|
|
|
let timerSubscription = timer(0, UploadDoisComponent.UPLOAD_TIMEOUT).pipe(
|
2023-10-25 16:42:38 +02:00
|
|
|
map(() => {
|
2023-11-28 10:05:33 +01:00
|
|
|
if ((page - 1) * this.requestSize <= this.allIds.length) {
|
2023-10-25 16:42:38 +02:00
|
|
|
this.fetchResultsByPage(page); // load data contains the http request
|
|
|
|
page += 1;
|
2023-11-09 14:35:44 +01:00
|
|
|
} else {
|
2023-10-25 16:42:38 +02:00
|
|
|
this.stopFetching(timerSubscription);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
).subscribe();
|
|
|
|
this.subscriptions.push(timerSubscription);
|
|
|
|
}
|
2023-11-09 14:35:44 +01:00
|
|
|
|
|
|
|
stopFetching(timerSubscription) {
|
2023-10-25 16:42:38 +02:00
|
|
|
timerSubscription.unsubscribe();
|
2023-11-09 14:35:44 +01:00
|
|
|
this.loading = false;
|
2023-10-25 16:42:38 +02:00
|
|
|
}
|
2023-11-09 14:35:44 +01:00
|
|
|
|
2023-10-25 16:42:38 +02:00
|
|
|
fetchResultsByPage(page) {
|
2023-11-28 10:05:33 +01:00
|
|
|
let dois = this.allIds.slice((page - 1) * this.requestSize, page * this.requestSize);
|
2023-11-09 14:35:44 +01:00
|
|
|
if (dois.length == 0) {
|
|
|
|
return;
|
2023-10-25 16:42:38 +02:00
|
|
|
}
|
2023-11-09 14:35:44 +01:00
|
|
|
|
2023-11-28 10:05:33 +01:00
|
|
|
this.subscriptions.push(this._searchResearchResultsService.fetchByDOIs(dois, "&fq=country=IE").subscribe(data => {
|
2023-11-09 14:35:44 +01:00
|
|
|
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,
|
2023-11-20 16:58:41 +01:00
|
|
|
accessRoute:"gold", //TODO update when we have the values
|
2023-11-27 16:06:46 +01:00
|
|
|
green: true, //TODO update when we have the values
|
|
|
|
diamond: true, //TODO update when we have the values
|
2023-11-09 14:35:44 +01:00
|
|
|
};
|
|
|
|
this.results.push(showRes)
|
2023-11-20 16:58:41 +01:00
|
|
|
this.addStatsPerResult(showRes)
|
2023-12-05 13:51:29 +01:00
|
|
|
// console.log(showRes, this.stats)
|
2023-11-09 14:35:44 +01:00
|
|
|
}
|
|
|
|
if (data[0] < dois.length) {
|
|
|
|
for (let doi of dois) {
|
|
|
|
if (this.foundIds.indexOf(doi) == -1) {
|
|
|
|
this.notFoundIds.push(doi);
|
2023-11-20 16:58:41 +01:00
|
|
|
// this.results.push({doi: doi, title: null, accessMode: null, green: false, openAccessColor:null, diamond: false, accessRoute: null, found: false})
|
2023-10-25 16:42:38 +02:00
|
|
|
}
|
|
|
|
}
|
2023-11-09 14:35:44 +01:00
|
|
|
}
|
2023-11-28 10:05:33 +01:00
|
|
|
this.initFilters();
|
2023-11-27 16:06:46 +01:00
|
|
|
this.updateView();
|
2023-11-09 14:35:44 +01:00
|
|
|
|
|
|
|
}));
|
2023-10-25 16:42:38 +02:00
|
|
|
}
|
|
|
|
|
2023-11-09 14:35:44 +01:00
|
|
|
findMatchingDoi(resultDois, requestedDois) {
|
|
|
|
for (let doi of resultDois) {
|
|
|
|
if (requestedDois.indexOf(doi) != -1) {
|
2023-10-25 16:42:38 +02:00
|
|
|
return doi;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2023-11-09 14:35:44 +01:00
|
|
|
private handleError(message: string, error) {
|
|
|
|
console.error("Upload error: " + message, error);
|
|
|
|
}
|
|
|
|
|
|
|
|
addStatsPerResult(result) {
|
2023-11-20 16:58:41 +01:00
|
|
|
if(result.accessMode) {
|
|
|
|
if (result.accessMode == "Open Access") {
|
|
|
|
this.stats.open++;
|
|
|
|
}
|
|
|
|
if (result.accessMode == "Closed Access") {
|
|
|
|
this.stats.closed++;
|
|
|
|
}
|
|
|
|
if (result.accessMode == "Embargo") {
|
|
|
|
this.stats.embargo++;
|
|
|
|
}
|
|
|
|
if (result.accessMode == "Restricted") {
|
|
|
|
this.stats.restricted++;
|
|
|
|
}
|
2023-11-09 14:35:44 +01:00
|
|
|
}
|
2023-11-27 16:06:46 +01:00
|
|
|
if(result.green){
|
|
|
|
this.stats.green++;
|
|
|
|
}
|
|
|
|
if(result.diamond){
|
|
|
|
this.stats.diamond++;
|
|
|
|
}
|
2023-11-20 16:58:41 +01:00
|
|
|
if(result.accessRoute) {
|
|
|
|
if (result.accessRoute == "gold") {
|
|
|
|
this.stats.gold++;
|
|
|
|
}
|
|
|
|
if (result.accessRoute == "hybrid") {
|
|
|
|
this.stats.hybrid++;
|
|
|
|
}
|
|
|
|
if (result.accessRoute == "bronze") {
|
|
|
|
this.stats.bronze++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-25 16:42:38 +02:00
|
|
|
}
|
|
|
|
|
2023-12-12 10:27:58 +01:00
|
|
|
updatePage($event) {
|
|
|
|
this.page = $event.value;
|
2023-11-09 14:35:44 +01:00
|
|
|
}
|
2023-10-25 16:42:38 +02:00
|
|
|
|
2023-11-09 14:35:44 +01:00
|
|
|
updateKeyword(keyword){
|
|
|
|
this.keyword = keyword;
|
|
|
|
this.updateView();
|
|
|
|
}
|
|
|
|
|
|
|
|
updateView() {
|
|
|
|
this.resultsToShow = [...this.results];
|
2023-11-20 16:58:41 +01:00
|
|
|
this.resultsToShow = this.filterResultsByAccessMode();
|
|
|
|
this.resultsToShow = this.filterResultsByAccessRoute();
|
2023-11-27 16:06:46 +01:00
|
|
|
if(this.onlyGreen){
|
|
|
|
this.resultsToShow = this.resultsToShow.filter(res => res.green);
|
|
|
|
}
|
|
|
|
if(this.onlyDiamond){
|
|
|
|
this.resultsToShow = this.resultsToShow.filter(res => res.diamond);
|
|
|
|
}
|
2023-11-09 14:35:44 +01:00
|
|
|
if(this.keyword.length > 0){
|
|
|
|
this.resultsToShow = this.filterResultsByKeyword();
|
2023-10-25 16:42:38 +02:00
|
|
|
}
|
2023-11-09 14:35:44 +01:00
|
|
|
this.resultsToShow= this.sortResults();
|
2023-11-20 16:58:41 +01:00
|
|
|
}
|
|
|
|
filterResultsByAccessMode() {
|
2023-11-27 16:06:46 +01:00
|
|
|
if (this.accessModeFilter && this.accessModeFilter.countSelectedValues > 0) {
|
2023-11-20 16:58:41 +01:00
|
|
|
for (let value of this.accessModeFilter.values) {
|
|
|
|
if (value.selected == true) {
|
|
|
|
return this.resultsToShow.filter(res => {
|
|
|
|
return res.accessMode == value.id;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2023-11-09 14:35:44 +01:00
|
|
|
}
|
2023-11-20 16:58:41 +01:00
|
|
|
return this.resultsToShow;
|
2023-11-09 14:35:44 +01:00
|
|
|
}
|
2023-11-20 16:58:41 +01:00
|
|
|
filterResultsByAccessRoute() {
|
2023-11-27 16:06:46 +01:00
|
|
|
if (this.accessRouteFilter && this.accessRouteFilter.countSelectedValues > 0) {
|
2023-11-20 16:58:41 +01:00
|
|
|
for (let value of this.accessRouteFilter.values) {
|
|
|
|
if (value.selected == true) {
|
|
|
|
return this.resultsToShow.filter(res => {
|
|
|
|
return res.accessRoute == value.id;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return this.resultsToShow;
|
|
|
|
}
|
|
|
|
/*filterResults() {
|
2023-11-09 14:35:44 +01:00
|
|
|
return this.results.filter(res =>{
|
2023-11-20 16:58:41 +01:00
|
|
|
if(this.filterBy == "route-green") {
|
2023-11-09 14:35:44 +01:00
|
|
|
return res.green;
|
|
|
|
}else if(this.filterBy == "route-diamond") {
|
|
|
|
return res.diamond;
|
|
|
|
}else{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
})
|
2023-11-20 16:58:41 +01:00
|
|
|
}*/
|
2023-11-09 14:35:44 +01:00
|
|
|
filterResultsByKeyword() {
|
|
|
|
return this.resultsToShow.filter(res =>{
|
2023-10-25 16:42:38 +02:00
|
|
|
|
2023-11-20 16:58:41 +01:00
|
|
|
return (res.title && res.title.toLowerCase().indexOf(this.keyword.toLowerCase()) !=-1);
|
2023-11-09 14:35:44 +01:00
|
|
|
|
|
|
|
})
|
|
|
|
}
|
2023-11-27 16:06:46 +01:00
|
|
|
sortResults(changeSorting= false){
|
|
|
|
if(changeSorting) {
|
|
|
|
this.sortByTitleAsc = !this.sortByTitleAsc;
|
|
|
|
}
|
2023-11-09 14:35:44 +01:00
|
|
|
return this.resultsToShow.sort((n1, n2) => {
|
|
|
|
|
2023-11-20 16:58:41 +01:00
|
|
|
if (n1.title && n2.title && ((!this.sortByTitleAsc && n1.title > n2.title) || (this.sortByTitleAsc && n1.title < n2.title))) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n1.title && n2.title && ((this.sortByTitleAsc && n1.title > n2.title) || (!this.sortByTitleAsc && n1.title < n2.title))) {
|
|
|
|
return -1;
|
|
|
|
}
|
2023-11-09 14:35:44 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
getercentage(number, foundIds = true){
|
|
|
|
if(!number){
|
2023-12-12 12:50:19 +01:00
|
|
|
return "0";
|
2023-11-09 14:35:44 +01:00
|
|
|
}
|
|
|
|
let from = foundIds?this.foundIds.length:this.allIds.length
|
|
|
|
var num = new Number((number/from)*100);
|
|
|
|
return num == 100?100:num.toPrecision(2);
|
2023-10-25 16:42:38 +02:00
|
|
|
}
|
2023-11-20 16:58:41 +01:00
|
|
|
|
|
|
|
initFilters(){
|
|
|
|
this.accessModeFilter = {
|
|
|
|
countSelectedValues: 0,
|
|
|
|
filterId: "access-mode",
|
|
|
|
filterOperator: "or",
|
|
|
|
filterType: "radio",
|
|
|
|
originalFilterId: "",
|
|
|
|
title: "Access Mode",
|
|
|
|
valueIsExact: false,
|
|
|
|
|
|
|
|
values:[
|
|
|
|
{name: "Open Access", id: "Open Access", selected:false, number:this.stats["open"]},
|
|
|
|
{name: "Embargo", id: "Embargo", selected:false, number:this.stats["embargo"]},
|
|
|
|
{name: "Restricted", id: "Restricted", selected:false, number:this.stats["restricted"]},
|
2023-11-28 10:05:33 +01:00
|
|
|
{name: "Closed Access", id: "Closed Access", selected:false, number:this.stats["closed"]}
|
2023-11-20 16:58:41 +01:00
|
|
|
]};
|
|
|
|
this.accessRouteFilter = {
|
|
|
|
countSelectedValues: 0,
|
|
|
|
filterId: "access-route",
|
|
|
|
filterOperator: "or",
|
|
|
|
filterType: "radio",
|
|
|
|
originalFilterId: "",
|
|
|
|
title: "Access Route",
|
|
|
|
valueIsExact: false,
|
|
|
|
values:[
|
2023-11-27 16:06:46 +01:00
|
|
|
{name: "Gold", id: "gold", selected:false, number:this.stats["gold"]},
|
|
|
|
{name: "Hybrid", id: "hybrid", selected:false, number:this.stats["hybrid"]},
|
|
|
|
{name: "Bronze", id: "bronze", selected:false, number:this.stats["bronze"]}
|
2023-11-20 16:58:41 +01:00
|
|
|
]};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-10-25 16:42:38 +02:00
|
|
|
}
|