From a168d41aeeb1c79102671158dca44a37041ff614 Mon Sep 17 00:00:00 2001
From: Bartha Maxime <231026@umons.ac.be>
Date: Fri, 19 Apr 2024 12:35:07 +0200
Subject: [PATCH] link listResearchers to ResearcherProfile
---
 frontend/src/App.vue                          |  2 +-
 .../ScientificPublications/ListResearches.vue | 12 +++++----
 .../ResearcherProfile.vue                     | 25 +++++++++++--------
 .../ScientificPublications/ManageResearch.js  |  4 +--
 .../ResearcherProfile.js                      |  4 +++
 frontend/src/rest/apps.js                     |  6 +++--
 6 files changed, 33 insertions(+), 20 deletions(-)
diff --git a/frontend/src/App.vue b/frontend/src/App.vue
index 6dcad67..6a17f6c 100644
--- a/frontend/src/App.vue
+++ b/frontend/src/App.vue
@@ -165,7 +165,7 @@ window.addEventListener('hashchange', () => {
 		border-color:black;
 		height: 100%;
 		position: fixed;
-		overflow:;
+		overflow: scroll;
 		transition-duration: .3s;
 	}
 
diff --git a/frontend/src/Apps/ScientificPublications/ListResearches.vue b/frontend/src/Apps/ScientificPublications/ListResearches.vue
index 64e048b..6c63efa 100644
--- a/frontend/src/Apps/ScientificPublications/ListResearches.vue
+++ b/frontend/src/Apps/ScientificPublications/ListResearches.vue
@@ -3,6 +3,7 @@ import { ref} from "vue";
 import FilterComponent from "@/Apps/ScientificPublications/FilterComponent.vue";
 import ArticleComponent from "@/Apps/ScientificPublications/ResearchComponent.vue";
 import {getFile, fetchAllResearches, addView} from "@/rest/ScientificPublications/ManageResearch.js";
+import {fetchResearch} from "@/rest/ScientificPublications/ResearcherProfile.js";
 const input = ref("")
 const isFilterOpened = ref(false);
 const isResearchOpened = ref(false);
@@ -37,9 +38,10 @@ const downloadBibTex = (research) => {
   getFile(research.bibTexLocation)
 }
 
-const downloadArticle = (research) => {
-  addView(research.pdfLocation)
-  getFile(research.pdfLocation)
+async function downloadArticle (research){
+  await addView(research.pdfLocation)
+  await getFile(research.pdfLocation)
+  articleToDisplay.value = await fetchResearch(articleToDisplay.value.id)
 }
 
 function downloadCoAuthors(){
@@ -97,12 +99,12 @@ function lDistance(s,t){
       
       
       
-
     
     
   
diff --git a/frontend/src/Apps/ScientificPublications/ResearcherProfile.vue b/frontend/src/Apps/ScientificPublications/ResearcherProfile.vue
index 473263e..4c9baea 100644
--- a/frontend/src/Apps/ScientificPublications/ResearcherProfile.vue
+++ b/frontend/src/Apps/ScientificPublications/ResearcherProfile.vue
@@ -9,7 +9,7 @@
 import { ref, reactive } from "vue";
 import FilterComponent from "@/Apps/ScientificPublications/FilterComponent.vue";
 import ArticleComponent from "@/Apps/ScientificPublications/ResearchComponent.vue";
-import {fetchResearcher, fetchResearches, fetchStats} from "@/rest/ScientificPublications/ResearcherProfile.js";
+import {fetchResearcher, fetchResearches, fetchStats, fetchResearch} from "@/rest/ScientificPublications/ResearcherProfile.js";
 import {getFile, addView} from "@/rest/ScientificPublications/ManageResearch.js";
 const input = ref("");
 const statsOf = ref("");
@@ -20,16 +20,18 @@ const articleToDisplay = ref(Object)
 const filters = ref([]);
 let chart;
 
-const researchList = ref(await fetchResearches(1));
-//todo changer dynamiquement le 1 ici en fct de sur quel profil on est
-const researcher = ref(await fetchResearcher(1));
-const stats = ref(await fetchStats(1))
+const researcherId = window.location.href.split("=")[1]
 
 const props = defineProps({
-  researcherId: ref(), //int
-  filters: ref([""]),
+  filters: ref([]),
 });
 
+
+
+const researchList = ref(await fetchResearches(researcherId));
+const researcher = ref(await fetchResearcher(researcherId));
+const stats = ref(await fetchStats(researcherId))
+
 const openFilter = () => {
   isFilterOpened.value = true;
 };
@@ -52,9 +54,12 @@ const downloadBibTex = (research) => {
   getFile(research.bibTexLocation)
 }
 
-const downloadArticle = (research) => {
-  addView(research.pdfLocation)
-  getFile(research.pdfLocation)
+async function downloadArticle (research) {
+  await addView(research.pdfLocation)
+  await getFile(research.pdfLocation)
+  articleToDisplay.value = await fetchResearch(articleToDisplay.value.id)
+  stats.value = await fetchStats(researcher.value.id)
+  update()
 }
 
 function downloadCoAuthors(){
diff --git a/frontend/src/rest/ScientificPublications/ManageResearch.js b/frontend/src/rest/ScientificPublications/ManageResearch.js
index 9231367..49d7ab9 100644
--- a/frontend/src/rest/ScientificPublications/ManageResearch.js
+++ b/frontend/src/rest/ScientificPublications/ManageResearch.js
@@ -29,8 +29,8 @@ export async function fetchAllResearches(){
 
 export async function getFile(url){
     const restURL = import.meta.env.VITE_CLYDE_MODE === 'container' ? "http://localhost:8000": import.meta.env.DEV ? "http://localhost:5173" : "https://clyde.herisson.ovh/api"
-    await fetch(restURL + "/"+url, {method: "GET"})
+    await fetch(restURL + "/" + url, {method: "GET"})
 }
 export async function addView(url){
-    return restPost("/addview/" +url)
+    return restPost("/addview/" + url)
 }
diff --git a/frontend/src/rest/ScientificPublications/ResearcherProfile.js b/frontend/src/rest/ScientificPublications/ResearcherProfile.js
index 54422f6..8e98605 100644
--- a/frontend/src/rest/ScientificPublications/ResearcherProfile.js
+++ b/frontend/src/rest/ScientificPublications/ResearcherProfile.js
@@ -10,4 +10,8 @@ export async function fetchResearches(id){
 
 export async function fetchStats(id){
     return restGet("/stats/" +id)
+}
+
+export async function fetchResearch(id){
+    return restGet("/research/" +id)
 }
\ No newline at end of file
diff --git a/frontend/src/rest/apps.js b/frontend/src/rest/apps.js
index 59ba05d..e3293f0 100644
--- a/frontend/src/rest/apps.js
+++ b/frontend/src/rest/apps.js
@@ -14,6 +14,7 @@ import Msg from "@/Apps/Msg.vue"
 import ManageRequests from "@/Apps/Inscription/ManageRequests.vue";
 import ManageResearcherProfile from "@/Apps/ScientificPublications/ManageResearcherProfile.vue";
 import ListResearches from "@/Apps/ScientificPublications/ListResearches.vue";
+import ResearcherProfile from "@/Apps/ScientificPublications/ResearcherProfile.vue";
 
 const apps = {
 		'/login': LoginPage,
@@ -24,7 +25,8 @@ const apps = {
 		'/students-list' : Students,
 		'/manage-researcher-profile' : ManageResearcherProfile,
 		'/msg' : Msg,
-		'/researches' : ListResearches
+		'/researches' : ListResearches,
+		'/researcher-profile': ResearcherProfile
 }
 
 const appsList = {
@@ -44,7 +46,7 @@ const appsList = {
 const currentPath = ref(window.location.hash)
 
 export const currentView = computed(() => {
-		return apps[currentPath.value.slice(1) || '/']
+		return apps[currentPath.value.split("?")[0].slice(1) || '/']
 })
 
 /**