1
0
forked from PGL/Clyde

junction front - back

This commit is contained in:
Bartha Maxime 2024-04-15 23:35:05 +02:00
parent eacdf8d47a
commit 63d0087d0c
9 changed files with 176 additions and 68 deletions

View File

@ -114,15 +114,15 @@ public class MockController {
Research jojoResearch = new Research("Graphs : Advanced Search Algorithms",output,new Date(0), Research jojoResearch = new Research("Graphs : Advanced Search Algorithms",output,new Date(0),
PaperType.Article,"here",null,"english", PaperType.Article,"here",null,"english",
Access.OpenSource,"IT","This Article's title speak for itself\n We'll discuss about advanced Graph search Algorithms"); Access.OpenSource,"IT","This Article's title speaks for itself \n We'll discuss about advanced Graph search Algorithms");
Research restrictedResearch = new Research("Graphs : Advanced Search Algorithms",output,new Date(1111111111), Research restrictedResearch = new Research("just another Name",output,new Date(1111111111),
PaperType.Article,"restricted",null,"english", PaperType.Article,"restricted",null,"english",
Access.Restricted,"Restricted","This Article's title speak for itself\n We'll discuss about advanced Graph search Algorithms"); Access.Restricted,"Restricted","This Article's title speaks for itself\n We'll discuss about advanced Graph search Algorithms");
Research privateResearch = new Research("Graphs : Advanced Search Algorithms",output,new Date(), Research privateResearch = new Research("the great Potato War",output,new Date(),
PaperType.Article,"private",null,"english", PaperType.Article,"private",null,"english",
Access.Private,"private","This Article's title speak for itself\n We'll discuss about advanced Graph search Algorithms"); Access.Private,"private","This Article's title speaks for itself\n We'll discuss about advanced Graph search Algorithms");
researchesService.saveResearch(restrictedResearch); researchesService.saveResearch(restrictedResearch);

View File

@ -73,6 +73,25 @@ public class ResearchController {
return new ResponseEntity<>(toReturnResearches,HttpStatus.OK); return new ResponseEntity<>(toReturnResearches,HttpStatus.OK);
} }
@GetMapping("/researches/{id}")
public ResponseEntity<Iterable<ResearchDTO>> getResearchesFromResearcher(@RequestHeader(value = "Authorization",required = false) String token,
@PathVariable Long id
){
Iterable<Research> researches = researchesServ.getResearchesByAuthor(id);
if (researches == null) return new ResponseEntity<>(HttpStatus.NOT_FOUND);
ArrayList<ResearchDTO> toReturnResearches = new ArrayList<>();
for (Research research: researches){
if (researchesServ.hasNoAccessTo(research,authServ.getUserFromToken(token))){
research.setPdfLocation(null);
}
toReturnResearches.add(ResearchDTO.construct(research));
}
return new ResponseEntity<>(toReturnResearches,HttpStatus.OK);
}
/** post a new research /** post a new research
* *
* @return the research saved * @return the research saved

View File

@ -1,6 +1,8 @@
package ovh.herisson.Clyde.Repositories.ScientificPublications; package ovh.herisson.Clyde.Repositories.ScientificPublications;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.CrudRepository;
import ovh.herisson.Clyde.Tables.ScientificPublications.Research;
import ovh.herisson.Clyde.Tables.ScientificPublications.Researcher; import ovh.herisson.Clyde.Tables.ScientificPublications.Researcher;
import ovh.herisson.Clyde.Tables.User; import ovh.herisson.Clyde.Tables.User;
@ -8,4 +10,7 @@ public interface ResearcherRepository extends CrudRepository<Researcher,Long> {
Researcher findByUser(User user); Researcher findByUser(User user);
Researcher findById(long id); Researcher findById(long id);
@Query("select r from Research r where r.author = ?1")
Iterable<Research> findAllByAuthorId(Researcher author);
} }

View File

@ -11,7 +11,7 @@ public interface StatsRepository extends CrudRepository<Research,Long> {
@Query("select new map(to_char(r.releaseDate, 'month') as label, sum(r.views) as y) from Research r group by to_char(r.releaseDate, 'month')") @Query("select new map(to_char(r.releaseDate, 'month') as label, sum(r.views) as y) from Research r group by to_char(r.releaseDate, 'month')")
Iterable<Map<String ,Integer>> viewsByMonths(); Iterable<Map<String ,Integer>> viewsByMonths();
/**
Iterable<Map<String ,Integer>> viewsByYears(); Iterable<Map<String ,Integer>> viewsByYears();
Iterable<Map<String ,Integer>> viewsByTopics(); Iterable<Map<String ,Integer>> viewsByTopics();
Iterable<Map<String ,Integer>> coAuthorByMonths(); Iterable<Map<String ,Integer>> coAuthorByMonths();
@ -22,6 +22,6 @@ public interface StatsRepository extends CrudRepository<Research,Long> {
Iterable<Map<String ,Integer>> researchesByYears(); Iterable<Map<String ,Integer>> researchesByYears();
Iterable<Map<String ,Integer>> researchesByTopics(); Iterable<Map<String ,Integer>> researchesByTopics();
Iterable<Map<String ,Integer>> researchesByMonth(); Iterable<Map<String ,Integer>> researchesByMonth();
**/
} }

View File

@ -42,6 +42,13 @@ public class ResearchesService {
return articleRepo.findById(id); return articleRepo.findById(id);
} }
public Iterable<Research> getResearchesByAuthor(long authorId){
Researcher researcher = researcherRepo.findById(authorId);
if (researcher == null) return null;
return researcherRepo.findAllByAuthorId(researcher);
}
public boolean hasNoAccessTo(Research research, User user){ public boolean hasNoAccessTo(Research research, User user){

View File

@ -7,18 +7,71 @@
<script setup> <script setup>
import { ref } from "vue"; import { ref } from "vue";
import {onClickOutside} from '@vueuse/core' import {onClickOutside} from '@vueuse/core'
import {w} from "../../../dist/assets/_plugin-vue_export-helper-Bvj9NrzX.js";
let checked = ref([]) let checked = ref([])
const yearList = ref([])
const monthList = ref([])
const accessList = ref([])
const languageList = ref([])
const domainList = ref([])
const paperTypeList = ref([])
const props = defineProps({ const props = defineProps({
isOpen: Boolean, isOpen: Boolean,
allArticles: ref([Object])
}); });
const example = ["A","B", "Lorem Ipsum AAAAAAAAAAAAAAAAAAA",
"H", for (let i=0;i< props.allArticles.length;i++) {
"H", let r = props.allArticles[i];
"H", let year = r.releaseDate.split("-")[0]
"H", let month = r.releaseDate.split("-")[1]
"H",
] if (!yearList.value.includes(year)) yearList.value.push(year);
if (!monthList.value.includes(month)) monthList.value.push(month);
if (!accessList.value.includes(r.access)) accessList.value.push(r.access);
if (!languageList.value.includes(r.language)) languageList.value.push(r.language);
if (!domainList.value.includes(r.domain)) domainList.value.push(r.domain);
if (!paperTypeList.value.includes(r.paperType)) paperTypeList.value.push(r.paperType);
}
function monthtoString(month){
switch (month){
case "01":
return "january"
case "02":
return "february"
case "03":
return "march"
case "04":
return "april"
case "05":
return "may"
case "06":
return "june"
case "07":
return "july"
case "08":
return "august"
case "09":
return "september"
case "10":
return "november"
case "11":
return "october"
case "12":
return "december"
default:
return "unknown"
}
}
const emit = defineEmits(["modal-close"]); const emit = defineEmits(["modal-close"]);
const target = ref(null) const target = ref(null)
@ -31,15 +84,15 @@ onClickOutside(target, ()=>emit('modal-close'))
<div class="modal-wrapper"> <div class="modal-wrapper">
<div class="modal-container" ref="target"> <div class="modal-container" ref="target">
<div id="filterGrid"> <div id="filterGrid">
<div> example :<ul class="checkers"> <li v-for="n in example"> <input type="checkbox" :value=n v-model="checked"> {{n}} </li> </ul> </div> <div> Year :<ul class="checkers"> <li v-for="n in yearList"> <input type="checkbox" :value=n v-model="checked"> {{n}} </li> </ul> </div>
<div class="vl"> example :<ul class="checkers"> <li v-for="n in example"> <input type="checkbox" :value=n v-model="checked"> {{n}} </li> </ul> </div> <div class="vl"> Access :<ul class="checkers"> <li v-for="n in accessList"> <input type="checkbox" :value=n v-model="checked"> {{n}} </li> </ul> </div>
<div class="vl"> example :<ul class="checkers"> <li v-for="n in example"> <input type="checkbox" :value=n v-model="checked"> {{n}} </li> </ul> </div> <div class="vl"> Language :<ul class="checkers"> <li v-for="n in languageList"> <input type="checkbox" :value=n v-model="checked"> {{n}} </li> </ul> </div>
<div> example :<ul class="checkers"> <li v-for="n in example"> <input type="checkbox" :value=n v-model="checked"> {{n}} </li> </ul> </div> <div> Month :<ul class="checkers"> <li v-for="n in monthList"> <input type="checkbox" :value=n v-model="checked"> {{monthtoString(n)}} </li> </ul> </div>
<div class="vl"> example :<ul class="checkers"> <li v-for="n in example"> <input type="checkbox" :value=n v-model="checked"> {{n}} </li> </ul> </div> <div class="vl"> Domain :<ul class="checkers"> <li v-for="n in domainList"> <input type="checkbox" :value=n v-model="checked"> {{n}} </li> </ul> </div>
<div class="vl"> example :<ul class="checkers"> <li v-for="n in example"> <input type="checkbox" :value=n v-model="checked"> {{n}} </li> </ul> </div> <div class="vl"> PaperType :<ul class="checkers"> <li v-for="n in paperTypeList"> <input type="checkbox" :value=n v-model="checked"> {{n}} </li> </ul> </div>
</div> </div>
<div id="submit"> <div id="submit">
<button @click.stop="emit('modal-close')">Submit</button> <button @click.stop="emit('modal-close', 'submit')">Submit</button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -8,16 +8,20 @@
<script setup> <script setup>
import {ref } from "vue"; import {ref } from "vue";
import {onClickOutside} from '@vueuse/core' import {onClickOutside} from '@vueuse/core'
let checked = ref([])
const props = defineProps({ const props = defineProps({
isOpen: Boolean, isOpen: Boolean,
article: ref(Object)
}); });
const example = ["Title","Author",["Co-author1", "co-Authors2"], function format(date){
" Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas condimentum ex tempor leo pulvinar, vitae imperdiet leo pellentesque. Aenean aliquam, ante at tempus sagittis, lorem leo feugiat felis, eget vestibulum tortor est nec libero. Cras sit amet venenatis velit, at rhoncus est. Cras id sem placerat, cursus sem et, aliquam felis. Nullam mi nunc, laoreet eget rutrum ac, blandit nec lorem. Duis fermentum aliquet tortor ac tristique. Aenean ac sagittis nulla, at auctor dolor. Vivamus et neque sodales, vestibulum dolor et, posuere urna. Pellentesque ut elit metus. Cras velit lectus, luctus auctor interdum eu, aliquam nec est. Donec elementum nisl sit amet nibh aliquam ultricies. Nullam felis orci, suscipit eu tincidunt pretium, euismod vel sem. Duis eget vehicula neque, nec gravida leo. Cras pellentesque arcu quis justo lobortis, ut semper massa rhoncus. Quisque sagittis dignissim congue. Nullam tortor ligula, mattis vel cursus id, pretium non lacus.", let split = date.split("-")
"language", let month = split[1]
"access", let day = split[2].split("T")[0]
] let year = split[0]
return day +"/"+ month +"/"+ year
}
const emit = defineEmits(["modal-close"]); const emit = defineEmits(["modal-close"]);
const target = ref(null) const target = ref(null)
@ -29,8 +33,19 @@ onClickOutside(target, ()=>emit('modal-close'))
<div v-if="isOpen" class="modal-mask"> <div v-if="isOpen" class="modal-mask">
<div class="modal-wrapper"> <div class="modal-wrapper">
<div class="modal-container" ref="target"> <div class="modal-container" ref="target">
<ul v-for="n in example"><li>{{n}}</li></ul> <ul>
<div id="downloads"> <li>Article Id : {{article.id}}</li>
<li>Title : {{article.title}}</li>
<li>Author : {{article.researcher.user.lastName + " " + article.researcher.user.firstName}}</li>
<li>Summary : {{article.summary}}</li>
<li>ReleaseDate: {{format(article.releaseDate)}}</li>
<li>Language : {{article.language}}</li>
<li>PaperType : {{article.paperType}}</li>
<li>Domain : {{article.domain}}</li>
<li>Access : {{article.access}}</li>
</ul>
<div id="downloads" v-if="article.pdfLocation !== null">
<button @click.stop="emit('modal-close')">Download BibTex</button> <button @click.stop="emit('modal-close')">Download BibTex</button>
<button @click.stop="emit('modal-close')">Download Research</button> <button @click.stop="emit('modal-close')">Download Research</button>
</div> </div>
@ -59,6 +74,10 @@ onClickOutside(target, ()=>emit('modal-close'))
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.33); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.33);
} }
.modal-container ul{
margin-top: 9px;
}
#downloads { #downloads {
text-align: end; text-align: end;

View File

@ -9,13 +9,23 @@
import { ref, reactive } from "vue"; import { ref, reactive } from "vue";
import FilterComponent from "@/Apps/ScientificPublications/FilterComponent.vue"; import FilterComponent from "@/Apps/ScientificPublications/FilterComponent.vue";
import ArticleComponent from "@/Apps/ScientificPublications/ResearchComponent.vue"; import ArticleComponent from "@/Apps/ScientificPublications/ResearchComponent.vue";
import {fetchResearcher, fetchResearches} from "@/rest/ScientificPublications/ResearcherProfile.js";
const input = ref(""); const input = ref("");
const statsOf = ref(""); const statsOf = ref("");
const statsBy = ref(""); const statsBy = ref("");
const isFilterOpened = ref(false); const isFilterOpened = ref(false);
const isResearchOpened = ref(false); const isResearchOpened = ref(false);
const articleToDisplay = ref(Object)
const filters = ref([""])
const researchList = ref(await fetchResearches(1))
let chart; let chart;
const props = defineProps({
researcher: ref(Object),
filters: ref([""]),
});
const openFilter = () => { const openFilter = () => {
isFilterOpened.value = true; isFilterOpened.value = true;
}; };
@ -23,14 +33,15 @@ const closeFilter = () => {
isFilterOpened.value = false; isFilterOpened.value = false;
}; };
const submitFilters = ()=>{ const submitFilters = ()=>{
// call only with those filters the get
} }
const openResearch = (article) => { const openResearch = (article) => {
isResearchOpened.value = true; isResearchOpened.value = true;
articleToDisplay.value = article;
} }
const closeResearch = () => { const closeResearch = () => {
isResearchOpened.value =false; isResearchOpened.value =false;
articleToDisplay.value = null;
} }
const downloadBibTex = (research) => { const downloadBibTex = (research) => {
@ -40,25 +51,14 @@ const downloadBibTex = (research) => {
const downloadArticle = (research) => { const downloadArticle = (research) => {
//todo //todo
} }
//todo changer dynamiquement le 1 ici en fct de sur quel profil on est
const researcher = ref(await fetchResearcher(1))
function downloadCoAuthors(){
const researchList = [ const data = JSON.stringify(researcher.value);
["The Great Potato War Lorem Ipsum aeaDq Terelumni ","Author",["Co-author1", "co-Authors2"], const blob = new Blob([data], {type:"application/json"});
" Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas condimentum ex tempor leo pulvinar, vitae imperdiet leo pellentesque. Aenean aliquam, ante at tempus sagittis, lorem leo feugiat felis, eget vestibulum tortor est nec libero. Cras sit amet venenatis velit, at rhoncus est. Cras id sem placerat, cursus sem et, aliquam felis. Nullam mi nunc, laoreet eget rutrum ac, blandit nec lorem. Duis fermentum aliquet tortor ac tristique. Aenean ac sagittis nulla, at auctor dolor. Vivamus et neque sodales, vestibulum dolor et, posuere urna. Pellentesque ut elit metus. Cras velit lectus, luctus auctor interdum eu, aliquam nec est. Donec elementum nisl sit amet nibh aliquam ultricies. Nullam felis orci, suscipit eu tincidunt pretium, euismod vel sem. Duis eget vehicula neque, nec gravida leo. Cras pellentesque arcu quis justo lobortis, ut semper massa rhoncus. Quisque sagittis dignissim congue. Nullam tortor ligula, mattis vel cursus id, pretium non lacus.", return URL.createObjectURL(blob);
"language", }
"access",
],
["The First Ever Paper","Author",["Co-author1", "co-Authors2"],
" Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas condimentum ex tempor leo pulvinar, vitae imperdiet leo pellentesque. Aenean aliquam, ante at tempus sagittis, lorem leo feugiat felis, eget vestibulum tortor est nec libero. Cras sit amet venenatis velit, at rhoncus est. Cras id sem placerat, cursus sem et, aliquam felis. Nullam mi nunc, laoreet eget rutrum ac, blandit nec lorem. Duis fermentum aliquet tortor ac tristique. Aenean ac sagittis nulla, at auctor dolor. Vivamus et neque sodales, vestibulum dolor et, posuere urna. Pellentesque ut elit metus. Cras velit lectus, luctus auctor interdum eu, aliquam nec est. Donec elementum nisl sit amet nibh aliquam ultricies. Nullam felis orci, suscipit eu tincidunt pretium, euismod vel sem. Duis eget vehicula neque, nec gravida leo. Cras pellentesque arcu quis justo lobortis, ut semper massa rhoncus. Quisque sagittis dignissim congue. Nullam tortor ligula, mattis vel cursus id, pretium non lacus.",
"language",
"access",
],
["the atomic disintegration of particular radioactive cells","Author",["Co-author1", "co-Authors2"],
" Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas condimentum ex tempor leo pulvinar, vitae imperdiet leo pellentesque. Aenean aliquam, ante at tempus sagittis, lorem leo feugiat felis, eget vestibulum tortor est nec libero. Cras sit amet venenatis velit, at rhoncus est. Cras id sem placerat, cursus sem et, aliquam felis. Nullam mi nunc, laoreet eget rutrum ac, blandit nec lorem. Duis fermentum aliquet tortor ac tristique. Aenean ac sagittis nulla, at auctor dolor. Vivamus et neque sodales, vestibulum dolor et, posuere urna. Pellentesque ut elit metus. Cras velit lectus, luctus auctor interdum eu, aliquam nec est. Donec elementum nisl sit amet nibh aliquam ultricies. Nullam felis orci, suscipit eu tincidunt pretium, euismod vel sem. Duis eget vehicula neque, nec gravida leo. Cras pellentesque arcu quis justo lobortis, ut semper massa rhoncus. Quisque sagittis dignissim congue. Nullam tortor ligula, mattis vel cursus id, pretium non lacus.",
"language",
"access",
],
]
const jsonMockViewsByYears= [ const jsonMockViewsByYears= [
@ -71,13 +71,9 @@ const jsonMockViewsByYears= [
function searchInList(list, searchInput) { function searchInList(list, searchInput) {
let retList = [] let retList = []
if (searchInput === ""){
list.forEach(r => retList.push(r.slice(0, 2)))
return retList
}
for (let i = 0; i < list.length; i++) { for (let i = 0; i < list.length; i++) {
if (lDistance(list[i][0], searchInput) < 10 || list[i][0].toUpperCase().indexOf(searchInput.toUpperCase()) > -1){ if (lDistance(list[i].title, searchInput) < 10 || list[i].title.toUpperCase().indexOf(searchInput.toUpperCase()) > -1){
retList.push(list[i].slice(0,2)) retList.push(list[i])
} }
} }
return retList return retList
@ -138,22 +134,20 @@ function update(){
<template> <template>
<div id="main"> <div id="main">
<FilterComponent :isOpen="isFilterOpened" @modal-close="closeFilter" @submit="submitFilters"></FilterComponent> <FilterComponent :isOpen="isFilterOpened" :allArticles="researchList" @modal-close="closeFilter" @submit="submitFilters()"></FilterComponent>
<ArticleComponent :isOpen="isResearchOpened" @modal-close="closeResearch"></ArticleComponent> <ArticleComponent :article="articleToDisplay" :isOpen="isResearchOpened" @modal-close="closeResearch"></ArticleComponent>
<div id="profilePicture"> <div id="profilePicture">
<img src="/Clyde.png" /> <img src="/Clyde.png" />
</div> </div>
<div id="researcherInfos"> <div id="researcherInfos">
<div class="surrounded">John Doe</div> <div class="surrounded">{{researcher.user.lastName}} {{researcher.user.firstName}}</div>
<div class="surrounded">Orcid : 12144-2144-12336-B</div> <div class="surrounded">Orcid : {{researcher.orcidId}}</div>
<div class="surrounded">Email : John.Doe@umons.ac.be</div> <div class="surrounded">Email : {{researcher.user.email}}</div>
<div class="surrounded"> <div class="surrounded">
site : site : <a :href=researcher.site style="color: #007aff"> {{researcher.site}}</a>
<a href="http://localhost:5173" style="color: #007aff">here</a>
</div> </div>
<div class="surrounded">Domain : physics, IT</div> <div class="surrounded">Domain : {{researcher.domain}}</div>
<div id="coAuthorList" class="surrounded">Co-authors list : D</div> <div id="coAuthorList" class="surrounded">Co-authors list : <a :href=downloadCoAuthors() download="coAuthors.json"> here </a></div>
</div> </div>
<div id="stats"> <div id="stats">
<div class="surrounded"> <div class="surrounded">
@ -184,9 +178,9 @@ function update(){
</div> </div>
<ul id="researchUL"> <ul id="researchUL">
<li id="researchLi" v-for="n in searchInList(researchList,input)"> <li id="researchLi" v-for="n in searchInList(researchList,input)">
<div class="vl"> {{n[0]}}</div> <div class="vl"> {{n.title}}</div>
<div class="vl"> {{n[1]}}</div> <div class="vl"> {{ n.researcher.user.firstName +" "+ n.researcher.user.lastName }}</div>
<a @click="openResearch"> MoreInfo </a></li> <a @click="openResearch(n)"> MoreInfo </a></li>
</ul> </ul>
</div> </div>
</div> </div>

View File

@ -0,0 +1,11 @@
import { restGet, restPost, restDelete, restPatch } from '../restConsumer.js'
export async function fetchResearcher(id){
return restGet("/researcher/" + id)
}
export async function fetchResearches(id){
return restGet("/researches/" + id)
}