From 3f4f6ed49a7991912ab6d9876a6ed88ea2cadc57 Mon Sep 17 00:00:00 2001
From: Bartha Maxime <231026@umons.ac.be>
Date: Thu, 18 Apr 2024 18:34:52 +0200
Subject: [PATCH] added List researches Backend
---
.../EndPoints/ApplicationsController.java | 1 +
.../herisson/Clyde/Tables/Applications.java | 4 +-
frontend/public/i18n/EN.txt | 2 +-
frontend/public/i18n/FR.txt | 2 +-
.../ScientificPublications/ListResearches.vue | 108 +++++++++++++++++-
.../ScientificPublications/ManageResearch.js | 2 +-
6 files changed, 111 insertions(+), 8 deletions(-)
diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java
index 5b49c66..d95a7ff 100644
--- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java
+++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java
@@ -52,6 +52,7 @@ public class ApplicationsController {
//if unAuthed
authorizedApps.add(Applications.Login);
+ authorizedApps.add(Applications.ListResearches);
User user = authServ.getUserFromToken(token);
if(user == null)
diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java
index a47997f..0b4514e 100644
--- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java
+++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java
@@ -21,5 +21,7 @@ public enum Applications {
// profile of a researcher
ResearcherProfile,
ManageResearcherProfile,
- StudentsList
+
+ //the list of all researches (filterable)
+ ListResearches, StudentsList
}
diff --git a/frontend/public/i18n/EN.txt b/frontend/public/i18n/EN.txt
index 0600571..c316597 100644
--- a/frontend/public/i18n/EN.txt
+++ b/frontend/public/i18n/EN.txt
@@ -29,7 +29,7 @@ app.manage.profile=Manage profile
app.studentList=Students List
app.users=Users
app.manage.researcherProfile=Manage researcher profile
-app.list.researches = List researches
+app.list.researches=List researches
request.moreInfos=More Infos
request.accept=Accept
request.refuse=Refuse
diff --git a/frontend/public/i18n/FR.txt b/frontend/public/i18n/FR.txt
index a057080..e86b19b 100644
--- a/frontend/public/i18n/FR.txt
+++ b/frontend/public/i18n/FR.txt
@@ -29,7 +29,7 @@ app.manage.profile=Gérer le profil
app.studentList=Liste des étudiants
app.users=Utilisateurs
app.manage.researcherProfile= gérer son profil de chercheur
-app.list.researches = lister les recherches
+app.list.researches=Lister les recherches
request.moreInfos=Plus d'Infos
request.accept=Accepter
request.refuse=Refuser
diff --git a/frontend/src/Apps/ScientificPublications/ListResearches.vue b/frontend/src/Apps/ScientificPublications/ListResearches.vue
index 1ce1df9..64e048b 100644
--- a/frontend/src/Apps/ScientificPublications/ListResearches.vue
+++ b/frontend/src/Apps/ScientificPublications/ListResearches.vue
@@ -2,13 +2,14 @@
import { ref} from "vue";
import FilterComponent from "@/Apps/ScientificPublications/FilterComponent.vue";
import ArticleComponent from "@/Apps/ScientificPublications/ResearchComponent.vue";
-import {getFile, fetchResearches, addView} from "@/rest/ScientificPublications/ManageResearch.js";
+import {getFile, fetchAllResearches, addView} from "@/rest/ScientificPublications/ManageResearch.js";
const input = ref("")
const isFilterOpened = ref(false);
const isResearchOpened = ref(false);
const articleToDisplay = ref(Object)
-const researchList = ref(await fetchResearches(1));
+const researchList = ref(await fetchAllResearches());
+const isResearcher = ref(false)
const props = defineProps({
filters: ref([""]),
@@ -52,7 +53,11 @@ function downloadCoAuthors(){
function searchInList(list, searchInput) {
let retList = []
for (let i = 0; i < list.length; i++) {
- if (lDistance(list[i].title, searchInput) < 10 || list[i].title.toUpperCase().indexOf(searchInput.toUpperCase()) > -1){
+ let researcher = list[i].researcher.user.firstName + " " +list[i].researcher.user.lastName
+ if (isResearcher.value && (lDistance(researcher, searchInput) < 5 || researcher.toUpperCase().indexOf(searchInput.toUpperCase()) > -1)){
+ retList.push(list[i])
+ }
+ if (!isResearcher.value && (lDistance(list[i].title, searchInput) < 10 || list[i].title.toUpperCase().indexOf(searchInput.toUpperCase()) > -1)){
retList.push(list[i])
}
}
@@ -87,8 +92,12 @@ function lDistance(s,t){