From 6cf796d3f91fc6bff29073a6a3c61b42ce1882e7 Mon Sep 17 00:00:00 2001 From: argirok Date: Mon, 20 Nov 2023 17:58:41 +0200 Subject: [PATCH] [WIP] Upload dois: update sorting and filtering --- .../upload-dois/upload-dois.component.html | 158 ++++++++------ src/app/upload-dois/upload-dois.component.ts | 202 ++++++++++-------- src/app/upload-dois/upload-dois.module.ts | 4 +- 3 files changed, 212 insertions(+), 152 deletions(-) diff --git a/src/app/upload-dois/upload-dois.component.html b/src/app/upload-dois/upload-dois.component.html index e98ea65..789bac6 100644 --- a/src/app/upload-dois/upload-dois.component.html +++ b/src/app/upload-dois/upload-dois.component.html @@ -39,7 +39,7 @@
Maximum size: 5 MB
-
+
@@ -53,70 +53,91 @@
+
-
- - -
- -
-
- Filter by - -
-
- Sort by - -
-
-
- Viewing {{((page-1)*size + 1)}}-{{resultsToShow.length>(page)*size? (page)*size : resultsToShow.length}} of {{resultsToShow.length}} -
-
-
    -
  • -
  • -
-
- - -
- - - - - - - - - - - - - - - - - - - - -
TitleAccess ModeAccess Route in OpenAIRE
{{result.title}}{{result.accessMode}}{{result.accessRoute}} {{result.doi}}
-
+ +
+
{{properties.doiURL+id}}
-
+ + +
+ + + +
+ + +
+
+ +
+ +
+
+
+ +
+ +
+ +
+
+
+ + +
+
+ Viewing {{((page-1)*size + 1)}}-{{resultsToShow.length>(page)*size? (page)*size : resultsToShow.length}} of {{resultsToShow.length}} +
+
+
    +
  • +
  • +
+
+ + +
+ + + + + + + + + + + + + + +
Title sortAccess ModeAccess Route Published in a Diamond OA journal
{{result.title}}{{result.accessMode}}{{result.accessRoute}} +
+
+
+
{{foundIds.length}} results found in Irish Monitor
@@ -127,14 +148,18 @@
Embargo
{{stats['embargo']}} ({{getercentage(stats['embargo'])}}%)
Closed
{{stats['closed']}} ({{getercentage(stats['closed'])}}%)

+
Access Routes
+
Green
{{stats['green']}} ({{getercentage(stats['green'])}}%)
+
Gold
{{stats['gold']}} ({{getercentage(stats['gold'])}}%)
Hybrid
{{stats['hybrid']}} ({{getercentage(stats['hybrid'])}}%)
Bronze
{{stats['bronze']}} ({{getercentage(stats['bronze'])}}%)
-
Diamond
{{stats['diamond']}} ({{getercentage(stats['diamond'])}}%)
+
+
Published in a Diamond OA journal
{{stats['diamond']}} ({{getercentage(stats['diamond'])}}%)
-
+
valid
@@ -142,13 +167,13 @@
-
+
duplicates
@@ -166,6 +191,7 @@
+
diff --git a/src/app/upload-dois/upload-dois.component.ts b/src/app/upload-dois/upload-dois.component.ts index 6a07d8b..888b058 100644 --- a/src/app/upload-dois/upload-dois.component.ts +++ b/src/app/upload-dois/upload-dois.component.ts @@ -6,6 +6,7 @@ import {Subscriber, timer} from "rxjs"; import {properties} from "../../environments/environment"; import {SearchResearchResultsService} from "../openaireLibrary/services/searchResearchResults.service"; import {map} from "rxjs/operators"; +import {Filter} from "../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class"; @Component({ selector: 'upload-dois', @@ -52,26 +53,19 @@ export class UploadDoisComponent implements OnInit { 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"}, - ] + accessModeFilter:Filter = null; + accessRouteFilter:Filter = null; + + /*filterByAccessRouteOptions = [ + {label: "Green OA", value: "route-green"}, + {label: "Published in OA Diamond", value: "route-diamond"}, + ]*/ + sortByTitleAsc = true; + keyword = ""; loading = false; + showFound = true; constructor(private _searchResearchResultsService: SearchResearchResultsService) { } @@ -95,9 +89,9 @@ export class UploadDoisComponent implements OnInit { this.errorMessage = ""; this.results = []; this.resultsToShow = []; - this.sortBy = null; - this.filterBy = null; + this.sortByTitleAsc = true; this.keyword = ""; + this.showFound = true; if (this.filesToUpload.length == 0) { this.errorMessage = "There is no selected file to upload."; return; @@ -130,7 +124,7 @@ export class UploadDoisComponent implements OnInit { let id = this.removeDoubleQuotes(values[0]); if (DOI.isValidDOI(id)) { id = Identifier.getRawDOIValue(id); - console.log(id, id.split("\r")[0]); + // console.log(id, id.split("\r")[0]); id = id.split("\r")[0] if (this.allIds.indexOf(id) > -1) { this.duplicateIds.push(id); @@ -232,20 +226,20 @@ export class UploadDoisComponent implements OnInit { doi: matchingDOI, title: result.title.name, accessMode: result.title.accessMode, - accessRoute: null, - green: false, - openAccessColor:null, - diamond: false, - found: true + accessRoute:"gold", //TODO update when we have the values + green: false, //TODO update when we have the values + diamond: false, //TODO update when we have the values }; this.results.push(showRes) - this.addStatsPerResult(result) + this.addStatsPerResult(showRes) + console.log(showRes, this.stats) + this.initFilters(); } 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.results.push({doi: doi, title: null, accessMode: null, green: false, openAccessColor:null, diamond: false, accessRoute: null, found: false}) } } } @@ -269,34 +263,39 @@ export class UploadDoisComponent implements OnInit { } addStatsPerResult(result) { - if (result.title.accessMode == "Open Access") { - this.stats.open++; - } - if (result.title.accessMode == "Closed Access") { - this.stats.closed++; - } - if (result.title.accessMode == "Embargo") { - this.stats.embargo++; - } - if (result.title.accessMode == "Restricted") { - this.stats.restricted++; + 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++; + } } //TDO add access routes stats + if(result.accessRoute) { + if (result.accessRoute == "gold") { + this.stats.gold++; + } + if (result.accessRoute == "hybrid") { + this.stats.hybrid++; + } + if (result.accessRoute == "bronze") { + this.stats.bronze++; + } + } + } updatePage(page) { this.page = page; } - updateSortBy(sortBy) { - this.sortBy = sortBy; - this.updateView(); - } - - updateFilterBy(filterBy) { - this.filterBy = filterBy; - this.updateView(); - } updateKeyword(keyword){ this.keyword = keyword; this.updateView(); @@ -304,66 +303,66 @@ export class UploadDoisComponent implements OnInit { updateView() { this.resultsToShow = [...this.results]; - if (this.filterBy) { - this.resultsToShow = this.filterResults(); - } + this.resultsToShow = this.filterResultsByAccessMode(); + this.resultsToShow = this.filterResultsByAccessRoute(); if(this.keyword.length > 0){ this.resultsToShow = this.filterResultsByKeyword(); } - if(this.sortBy){ this.resultsToShow= this.sortResults(); - } - - } - - filterResults() { + filterResultsByAccessMode() { + if (this.accessModeFilter.countSelectedValues > 0) { + for (let value of this.accessModeFilter.values) { + if (value.selected == true) { + return this.resultsToShow.filter(res => { + return res.accessMode == value.id; + }); + } + } + } + return this.resultsToShow; + } + filterResultsByAccessRoute() { + if (this.accessRouteFilter.countSelectedValues > 0) { + 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() { 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") { + 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); + return (res.title && res.title.toLowerCase().indexOf(this.keyword.toLowerCase()) !=-1); }) } sortResults(){ - + this.sortByTitleAsc =! this.sortByTitleAsc; 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; - } + 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; + } return 0; }) @@ -378,4 +377,37 @@ export class UploadDoisComponent implements OnInit { var num = new Number((number/from)*100); return num == 100?100:num.toPrecision(2); } + + 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"]}, + {name: "Closed", id: "Closed", selected:false, number:this.stats["closed"]} + ]}; + this.accessRouteFilter = { + countSelectedValues: 0, + filterId: "access-route", + filterOperator: "or", + filterType: "radio", + originalFilterId: "", + title: "Access Route", + valueIsExact: false, + values:[ + {name: "Gold", id: "route-gold", selected:false, number:this.stats["gold"]}, + {name: "Hybrid", id: "route-hybrid", selected:false, number:this.stats["hybrid"]}, + {name: "Bronze", id: "route-bronze", selected:false, number:this.stats["bronze"]} + ]}; + + } + } diff --git a/src/app/upload-dois/upload-dois.module.ts b/src/app/upload-dois/upload-dois.module.ts index a6ddb42..f31600d 100644 --- a/src/app/upload-dois/upload-dois.module.ts +++ b/src/app/upload-dois/upload-dois.module.ts @@ -6,12 +6,14 @@ import {SearchResearchResultsServiceModule} from "../openaireLibrary/services/se import {PagingModule} from "../openaireLibrary/utils/paging.module"; import {SearchInputModule} from "../openaireLibrary/sharedComponents/search-input/search-input.module"; import {IconsModule} from "../openaireLibrary/utils/icons/icons.module"; +import {DropdownFilterModule} from "../openaireLibrary/utils/dropdown-filter/dropdown-filter.module"; +import {SearchFilterModule} from "../openaireLibrary/searchPages/searchUtils/searchFilter.module"; @NgModule({ declarations: [UploadDoisComponent], imports: [ - CommonModule, UploadDoisRoutingModule, SearchResearchResultsServiceModule, PagingModule, SearchInputModule, IconsModule + CommonModule, UploadDoisRoutingModule, SearchResearchResultsServiceModule, PagingModule, SearchInputModule, IconsModule, DropdownFilterModule, SearchFilterModule ], })